pdf-factory 0.2.0 → 0.3.0
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/README.md +205 -0
- package/dist/parser.cjs +9 -9
- package/dist/parser.cjs.map +1 -1
- package/dist/parser.js +1213 -1209
- package/dist/parser.js.map +1 -1
- package/dist/pdf-factory.cjs +4 -4
- package/dist/pdf-factory.cjs.map +1 -1
- package/dist/pdf-factory.js +769 -721
- package/dist/pdf-factory.js.map +1 -1
- package/dist/src/__tests__/fixtureGuard.d.ts +11 -0
- package/dist/src/__tests__/fixtureGuard.d.ts.map +1 -0
- package/dist/src/comparison/visualCompare.d.ts.map +1 -0
- package/dist/src/composition/editorTypes.d.ts.map +1 -0
- package/dist/src/composition/footerLayouts.d.ts.map +1 -0
- package/dist/src/composition/headerLayouts.d.ts.map +1 -0
- package/dist/src/composition/page.d.ts.map +1 -0
- package/dist/src/composition/printDispatcher.d.ts.map +1 -0
- package/dist/src/composition/printModalTypes.d.ts.map +1 -0
- package/dist/src/composition/seedingsFooter.d.ts.map +1 -0
- package/dist/src/config/compositionCatalog.d.ts.map +1 -0
- package/dist/src/config/formatPresets.d.ts.map +1 -0
- package/dist/src/config/types.d.ts.map +1 -0
- package/dist/src/core/drawsDataToDrawData.d.ts.map +1 -0
- package/dist/src/core/extractCompassData.d.ts.map +1 -0
- package/dist/src/core/extractCourtCardData.d.ts.map +1 -0
- package/dist/src/core/extractDrawData.d.ts.map +1 -0
- package/dist/src/core/extractParticipantData.d.ts.map +1 -0
- package/dist/src/core/extractRoundRobinData.d.ts.map +1 -0
- package/dist/src/core/extractScheduleData.d.ts.map +1 -0
- package/dist/src/generators/courtCard.d.ts.map +1 -0
- package/dist/src/generators/drawPDF.d.ts.map +1 -0
- package/dist/src/generators/drawSheet.d.ts.map +1 -0
- package/dist/src/generators/generateFromEventData.d.ts.map +1 -0
- package/dist/src/generators/matchCard.d.ts.map +1 -0
- package/dist/src/generators/playerList.d.ts.map +1 -0
- package/dist/src/generators/schedule.d.ts.map +1 -0
- package/dist/src/generators/scheduleV2.d.ts.map +1 -0
- package/dist/src/generators/sequentialOOP.d.ts.map +1 -0
- package/dist/src/generators/signInSheet.d.ts.map +1 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/layout/brackets.d.ts.map +1 -0
- package/dist/src/layout/fonts.d.ts.map +1 -0
- package/dist/src/layout/headers.d.ts.map +1 -0
- package/dist/src/layout/tables.d.ts.map +1 -0
- package/dist/src/parser/coordinateClustering.d.ts.map +1 -0
- package/dist/src/parser/drawExtractor.d.ts.map +1 -0
- package/dist/src/parser/pdfExtractor.d.ts.map +1 -0
- package/dist/src/parser/regionDetector.d.ts.map +1 -0
- package/dist/src/parser/textAnalyzer.d.ts.map +1 -0
- package/dist/src/parser/textMerger.d.ts.map +1 -0
- package/dist/src/parser.d.ts.map +1 -0
- package/dist/src/renderers/backdrawDraw.d.ts.map +1 -0
- package/dist/src/renderers/compassDraw.d.ts.map +1 -0
- package/dist/src/renderers/consolationDraw.d.ts.map +1 -0
- package/dist/src/renderers/doubleEliminationDraw.d.ts.map +1 -0
- package/dist/src/renderers/drawSplitter.d.ts.map +1 -0
- package/dist/src/renderers/formatEntry.d.ts.map +1 -0
- package/dist/src/renderers/luckyDraw.d.ts.map +1 -0
- package/dist/src/renderers/mirroredDraw.d.ts.map +1 -0
- package/dist/{renderers → src/renderers}/roundRobinDraw.d.ts +1 -1
- package/dist/src/renderers/roundRobinDraw.d.ts.map +1 -0
- package/dist/{renderers → src/renderers}/traditionalDraw.d.ts +1 -1
- package/dist/src/renderers/traditionalDraw.d.ts.map +1 -0
- package/dist/src/utils/primitives.d.ts.map +1 -0
- package/package.json +8 -8
- package/dist/comparison/visualCompare.d.ts.map +0 -1
- package/dist/composition/editorTypes.d.ts.map +0 -1
- package/dist/composition/footerLayouts.d.ts.map +0 -1
- package/dist/composition/headerLayouts.d.ts.map +0 -1
- package/dist/composition/page.d.ts.map +0 -1
- package/dist/composition/printDispatcher.d.ts.map +0 -1
- package/dist/composition/printModalTypes.d.ts.map +0 -1
- package/dist/composition/seedingsFooter.d.ts.map +0 -1
- package/dist/config/compositionCatalog.d.ts.map +0 -1
- package/dist/config/formatPresets.d.ts.map +0 -1
- package/dist/config/types.d.ts.map +0 -1
- package/dist/core/drawsDataToDrawData.d.ts.map +0 -1
- package/dist/core/extractCompassData.d.ts.map +0 -1
- package/dist/core/extractCourtCardData.d.ts.map +0 -1
- package/dist/core/extractDrawData.d.ts.map +0 -1
- package/dist/core/extractParticipantData.d.ts.map +0 -1
- package/dist/core/extractRoundRobinData.d.ts.map +0 -1
- package/dist/core/extractScheduleData.d.ts.map +0 -1
- package/dist/generators/courtCard.d.ts.map +0 -1
- package/dist/generators/drawPDF.d.ts.map +0 -1
- package/dist/generators/drawSheet.d.ts.map +0 -1
- package/dist/generators/generateFromEventData.d.ts.map +0 -1
- package/dist/generators/matchCard.d.ts.map +0 -1
- package/dist/generators/playerList.d.ts.map +0 -1
- package/dist/generators/schedule.d.ts.map +0 -1
- package/dist/generators/scheduleV2.d.ts.map +0 -1
- package/dist/generators/sequentialOOP.d.ts.map +0 -1
- package/dist/generators/signInSheet.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/layout/brackets.d.ts.map +0 -1
- package/dist/layout/fonts.d.ts.map +0 -1
- package/dist/layout/headers.d.ts.map +0 -1
- package/dist/layout/tables.d.ts.map +0 -1
- package/dist/parser/coordinateClustering.d.ts.map +0 -1
- package/dist/parser/drawExtractor.d.ts.map +0 -1
- package/dist/parser/pdfExtractor.d.ts.map +0 -1
- package/dist/parser/regionDetector.d.ts.map +0 -1
- package/dist/parser/textAnalyzer.d.ts.map +0 -1
- package/dist/parser/textMerger.d.ts.map +0 -1
- package/dist/parser.d.ts.map +0 -1
- package/dist/renderers/backdrawDraw.d.ts.map +0 -1
- package/dist/renderers/compassDraw.d.ts.map +0 -1
- package/dist/renderers/consolationDraw.d.ts.map +0 -1
- package/dist/renderers/doubleEliminationDraw.d.ts.map +0 -1
- package/dist/renderers/drawSplitter.d.ts.map +0 -1
- package/dist/renderers/formatEntry.d.ts.map +0 -1
- package/dist/renderers/luckyDraw.d.ts.map +0 -1
- package/dist/renderers/mirroredDraw.d.ts.map +0 -1
- package/dist/renderers/roundRobinDraw.d.ts.map +0 -1
- package/dist/renderers/traditionalDraw.d.ts.map +0 -1
- package/dist/utils/primitives.d.ts.map +0 -1
- /package/dist/{comparison → src/comparison}/visualCompare.d.ts +0 -0
- /package/dist/{composition → src/composition}/editorTypes.d.ts +0 -0
- /package/dist/{composition → src/composition}/footerLayouts.d.ts +0 -0
- /package/dist/{composition → src/composition}/headerLayouts.d.ts +0 -0
- /package/dist/{composition → src/composition}/page.d.ts +0 -0
- /package/dist/{composition → src/composition}/printDispatcher.d.ts +0 -0
- /package/dist/{composition → src/composition}/printModalTypes.d.ts +0 -0
- /package/dist/{composition → src/composition}/seedingsFooter.d.ts +0 -0
- /package/dist/{config → src/config}/compositionCatalog.d.ts +0 -0
- /package/dist/{config → src/config}/formatPresets.d.ts +0 -0
- /package/dist/{config → src/config}/types.d.ts +0 -0
- /package/dist/{core → src/core}/drawsDataToDrawData.d.ts +0 -0
- /package/dist/{core → src/core}/extractCompassData.d.ts +0 -0
- /package/dist/{core → src/core}/extractCourtCardData.d.ts +0 -0
- /package/dist/{core → src/core}/extractDrawData.d.ts +0 -0
- /package/dist/{core → src/core}/extractParticipantData.d.ts +0 -0
- /package/dist/{core → src/core}/extractRoundRobinData.d.ts +0 -0
- /package/dist/{core → src/core}/extractScheduleData.d.ts +0 -0
- /package/dist/{generators → src/generators}/courtCard.d.ts +0 -0
- /package/dist/{generators → src/generators}/drawPDF.d.ts +0 -0
- /package/dist/{generators → src/generators}/drawSheet.d.ts +0 -0
- /package/dist/{generators → src/generators}/generateFromEventData.d.ts +0 -0
- /package/dist/{generators → src/generators}/matchCard.d.ts +0 -0
- /package/dist/{generators → src/generators}/playerList.d.ts +0 -0
- /package/dist/{generators → src/generators}/schedule.d.ts +0 -0
- /package/dist/{generators → src/generators}/scheduleV2.d.ts +0 -0
- /package/dist/{generators → src/generators}/sequentialOOP.d.ts +0 -0
- /package/dist/{generators → src/generators}/signInSheet.d.ts +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{layout → src/layout}/brackets.d.ts +0 -0
- /package/dist/{layout → src/layout}/fonts.d.ts +0 -0
- /package/dist/{layout → src/layout}/headers.d.ts +0 -0
- /package/dist/{layout → src/layout}/tables.d.ts +0 -0
- /package/dist/{parser → src/parser}/coordinateClustering.d.ts +0 -0
- /package/dist/{parser → src/parser}/drawExtractor.d.ts +0 -0
- /package/dist/{parser → src/parser}/pdfExtractor.d.ts +0 -0
- /package/dist/{parser → src/parser}/regionDetector.d.ts +0 -0
- /package/dist/{parser → src/parser}/textAnalyzer.d.ts +0 -0
- /package/dist/{parser → src/parser}/textMerger.d.ts +0 -0
- /package/dist/{parser.d.ts → src/parser.d.ts} +0 -0
- /package/dist/{renderers → src/renderers}/backdrawDraw.d.ts +0 -0
- /package/dist/{renderers → src/renderers}/compassDraw.d.ts +0 -0
- /package/dist/{renderers → src/renderers}/consolationDraw.d.ts +0 -0
- /package/dist/{renderers → src/renderers}/doubleEliminationDraw.d.ts +0 -0
- /package/dist/{renderers → src/renderers}/drawSplitter.d.ts +0 -0
- /package/dist/{renderers → src/renderers}/formatEntry.d.ts +0 -0
- /package/dist/{renderers → src/renderers}/luckyDraw.d.ts +0 -0
- /package/dist/{renderers → src/renderers}/mirroredDraw.d.ts +0 -0
- /package/dist/{utils → src/utils}/primitives.d.ts +0 -0
package/dist/pdf-factory.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-350yNsax.cjs`);let t=require(`jspdf`);t=e.n(t);let n=require(`jspdf-autotable`);n=e.n(n);var r={F:`Final`,SF:`Semi-Finals`,QF:`Quarter-Finals`,R16:`Round of 16`,R32:`Round of 32`,R64:`Round of 64`,R128:`Round of 128`},i={F:`Final`,SF:`Semi-Finals`,QF:`Quarter-Finals`,R16:`Fourth Round`,R32:`Third Round`,R64:`Second Round`,R128:`First Round`},a={F:`Final`,SF:`Semifinals`,QF:`Quarterfinals`,R16:`Round 4`,R32:`Round 3`,R64:`Round 2`,R128:`Round 1`},o={F:`FINALE`,SF:`1/2 FINALE`,QF:`1/4 FINALE`,R16:`1/8 FINALE`,R32:`3eme TOUR`,R64:`2eme TOUR`,R128:`1er TOUR`},s={pageSize:`a4`,orientation:`auto`,margins:{top:15,right:10,bottom:15,left:10}},c=`LAST, First`,l=`bare`,u=`before-position`,d=`brackets`,f=`-`,p=`traditional-lines`,m={wimbledon:{nameFormat:c,nationalityFormat:l,seedPosition:u,seedFormat:d,entryFormat:`parens`,gameScoreSeparator:f,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:i,renderStyle:p,page:{...s}},usOpen:{nameFormat:c,nationalityFormat:l,seedPosition:u,seedFormat:d,entryFormat:`parens`,gameScoreSeparator:f,setScoreSeparator:` | `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:a,renderStyle:p,page:{...s}},rolandGarros:{nameFormat:`LAST First`,nationalityFormat:l,seedPosition:`after-country`,seedFormat:d,entryFormat:`parens`,gameScoreSeparator:`/`,setScoreSeparator:` `,retirementLabel:`Ab`,walkoverLabel:`w/o`,roundLabels:o,renderStyle:p,page:{...s}},australianOpen:{nameFormat:c,nationalityFormat:`parens`,seedPosition:`after-name`,seedFormat:d,entryFormat:`hyphen`,gameScoreSeparator:`/`,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:r,renderStyle:p,page:{...s,pageSize:`letter`,orientation:`portrait`}},itfJunior:{nameFormat:c,nationalityFormat:l,seedPosition:u,seedFormat:d,entryFormat:`bare`,gameScoreSeparator:f,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:r,renderStyle:p,page:{...s}},usta:{nameFormat:c,nationalityFormat:l,seedPosition:u,seedFormat:d,entryFormat:`bare`,gameScoreSeparator:f,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`W/O`,roundLabels:r,renderStyle:p,page:{...s}}};function h(e){return m[e]||m.itfJunior}function g(e,t){return{...h(e),...t}}var _=`itfJunior`,v=`combined-tour`,y={"grand-slam":{id:`grand-slam`,name:`Grand Slam`,description:`Minimal chrome — large tournament name, timestamp footer`,category:`grand-slam`,tier:1,header:{layout:`grand-slam`},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`wimbledon`},wimbledon:{id:`wimbledon`,name:`Wimbledon`,description:`Green/purple Grand Slam style with crest`,category:`grand-slam`,tier:1,header:{layout:`grand-slam`},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`wimbledon`},"australian-open":{id:`australian-open`,name:`Australian Open`,description:`Grand Slam with seedings + prize money footer`,category:`grand-slam`,tier:2,header:{layout:`grand-slam`},footer:{layout:v,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`australianOpen`},"wta-500":{id:`wta-500`,name:`WTA 500`,description:`Tour header with logos, seedings + prize money footer`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:v,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:_},"wta-1000":{id:`wta-1000`,name:`WTA 1000`,description:`Tour header with logos, full footer with officials`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:v,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:_},"atp-250":{id:`atp-250`,name:`ATP 250`,description:`ATP tour header, seedings + prize money footer with sign-off`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:v,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:_},"atp-finals":{id:`atp-finals`,name:`ATP Finals`,description:`Full official sign-off with signature lines`,category:`tour`,tier:3,header:{layout:`grand-slam`},footer:{layout:`officials-signoff`,showTimestamp:!0},drawFormatPreset:_},"itf-junior":{id:`itf-junior`,name:`ITF Junior`,description:`ITF header with metadata row, officials sign-off footer`,category:`itf`,tier:3,header:{layout:`itf`},footer:{layout:`officials-signoff`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:_},"itf-pro-circuit":{id:`itf-pro-circuit`,name:`ITF Pro Circuit`,description:`ITF header, seedings + officials footer`,category:`itf`,tier:2,header:{layout:`itf`},footer:{layout:v,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:_},"national-federation":{id:`national-federation`,name:`National Federation`,description:`Detailed metadata header, full sign-off footer with ceremony date`,category:`national`,tier:3,header:{layout:`national-federation`},footer:{layout:`officials-signoff`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`usta`},"collegiate-ncaa":{id:`collegiate-ncaa`,name:`NCAA Collegiate`,description:`Mirrored bracket layout, team logos, minimal footer`,category:`collegiate`,tier:1,header:{layout:`grand-slam`},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:_},"club-basic":{id:`club-basic`,name:`Club Basic`,description:`Minimal header, standard footer — clean and simple`,category:`club`,tier:1,header:{layout:`minimal`},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:_}};function b(e){return y[e]}function x(e){let t=Object.values(y);return e?t.filter(t=>t.category===e):t}function S(e,t,n){let r=y[e]||y[`club-basic`];return{header:{...r.header,...t},footer:{...r.footer,...n}}}function C(e){let t=e.roundMatchUps||{},n=e.roundProfile||{},r=Object.keys(t).map(Number).sort((e,t)=>e-t),i=new Map;for(let e of r)for(let n of t[e]||[])for(let e of n.sides||[])if(e?.drawPosition&&!i.has(e.drawPosition)){let t=e.entryStatus||e.participant?.entryStatus,n=t&&t!==`DIRECT_ACCEPTANCE`?t:void 0;i.set(e.drawPosition,{drawPosition:e.drawPosition,participantName:e.participant?.participantName||``,nationality:e.participant?.nationalityCode||``,seedValue:e.seedValue,entryStatus:n,isBye:e.bye===!0})}let a=[];for(let e of r)for(let n of t[e]||[])a.push({roundNumber:n.roundNumber,roundPosition:n.roundPosition,drawPositions:n.drawPositions||[],score:n.score?.scoreStringSide1||``,winningSide:n.winningSide,matchUpStatus:n.matchUpStatus});let o={};for(let e of r){let t=n[e];o[e]=t?.abbreviatedRoundName||t?.roundName||`R${e}`}let s=r.length>0?Math.max(...r):0,c=[...i.values()].sort((e,t)=>e.drawPosition-t.drawPosition);return{drawName:e.structureName||``,drawSize:c.length,drawType:`SINGLE_ELIMINATION`,totalRounds:s,slots:c,matchUps:a,seedAssignments:(e.seedAssignments||[]).filter(e=>e.participantName).map(e=>({seedValue:e.seedValue,participantName:e.participantName||``,nationality:e.nationalityCode||``})),roundLabelMap:o}}function w(e,t){return e?.[0]?.structures?.find(e=>e.stage===t)}function T(e,n){let r=e.orientation;return r===`auto`&&(r=n&&n>=32?`landscape`:`portrait`),new t.default({orientation:r,format:e.pageSize,unit:`mm`})}function E(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=t;return{headerHeight:n,footerHeight:r,contentY:o.top+n,contentHeight:a-o.top-o.bottom-n-r,contentWidth:i-o.left-o.right,pageWidth:i,pageHeight:a}}function ee(){return{pageSize:`a4`,orientation:`auto`,margins:{top:15,right:10,bottom:15,left:10}}}var D={REGULAR:`helvetica`,BOLD:`helvetica`},O={NORMAL:`normal`,BOLD:`bold`,ITALIC:`italic`},k={TITLE:16,SUBTITLE:12,HEADING:10,BODY:8,SMALL:7,TINY:6};function A(e,t,n=O.NORMAL){e.setFont(D.REGULAR,n),e.setFontSize(t)}function j(e,t,n){switch(t.layout){case`grand-slam`:return M(e,t,n);case`itf`:return N(e,t,n);case`minimal`:return P(e,t,n);case`wta-tour`:return F(e,t,n);case`national-federation`:return te(e,t,n);case`none`:return 0}}function M(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth(),a=i-r.right,o=r.top;A(e,18,O.BOLD),e.text(t.tournamentName.toUpperCase(),i/2,o,{align:`center`}),o+=7,t.subtitle&&(A(e,12,O.BOLD),e.text(t.subtitle.toUpperCase(),i/2,o,{align:`center`}),o+=6),A(e,k.BODY,O.NORMAL);let s=[];if(t.startDate){let e=t.endDate?`${t.startDate} - ${t.endDate}`:t.startDate;s.push(e)}return t.location&&s.push(t.location),s.forEach((t,n)=>{e.text(t,a,r.top+n*4,{align:`right`})}),o+=2,e.setDrawColor(0),e.setLineWidth(.5),e.line(r.left,o,a,o),o+=3,o-r.top}function N(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth()-r.right,a=r.top;A(e,k.TITLE,O.BOLD),e.text(t.tournamentName,r.left,a),a+=6,t.subtitle&&(A(e,k.SUBTITLE,O.BOLD),e.text(t.subtitle,r.left,a),a+=5),A(e,k.SMALL,O.NORMAL);let o=[];t.grade&&o.push(`Grade: ${t.grade}`),t.surface&&o.push(`Surface: ${t.surface}`),t.supervisor&&o.push(`Supervisor: ${t.supervisor}`),o.forEach((t,n)=>{e.text(t,i,r.top+n*3.5,{align:`right`})}),A(e,k.BODY,O.NORMAL);let s=[];return t.startDate&&s.push(t.startDate),t.location&&s.push(t.location),t.organizer&&s.push(t.organizer),s.length&&(e.text(s.join(` | `),r.left,a),a+=4),a+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,a,i,a),a+=3,a-r.top}function P(e,t,n){let{margins:r}=n,i=r.top;A(e,k.SUBTITLE,O.BOLD),e.text(t.tournamentName,r.left,i);let a=e.getTextWidth(t.tournamentName);return t.subtitle&&(A(e,k.BODY,O.NORMAL),e.text(` - ${t.subtitle}`,r.left+a,i)),i+=6,i-r.top}function F(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth(),a=i-r.right,o=i/2,s=r.top;if(t.leftLogoBase64)try{e.addImage(t.leftLogoBase64,`PNG`,r.left,s-2,12,12)}catch{}if(t.rightLogoBase64)try{e.addImage(t.rightLogoBase64,`PNG`,a-12,s-2,12,12)}catch{}A(e,14,O.BOLD),e.text(t.tournamentName,o,s,{align:`center`}),s+=5;let c=[t.city,t.country].filter(Boolean).join(`, `);c&&(A(e,k.BODY,O.NORMAL),e.setTextColor(80),e.text(c.toUpperCase(),o,s,{align:`center`}),e.setTextColor(0),s+=4);let l=[];if(t.startDate){let e=t.endDate?`${t.startDate} - ${t.endDate}`:t.startDate;l.push(e)}if(t.prizeMoney){let e=t.currency?`${t.currency} ${t.prizeMoney}`:t.prizeMoney;l.push(e)}return t.surface&&l.push(t.surface),l.length&&(A(e,k.SMALL,O.NORMAL),e.text(l.join(` | `),o,s,{align:`center`}),s+=4),t.sectionLabel&&(A(e,k.SMALL,O.BOLD),e.text(t.sectionLabel.toUpperCase(),a,s,{align:`right`}),s+=3),s+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,s,a,s),s+=3,s-r.top}function te(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth()-r.right,a=r.top;if(t.rightLogoBase64)try{e.addImage(t.rightLogoBase64,`PNG`,i-14,a-2,14,14)}catch{}A(e,k.TITLE,O.BOLD),e.text(t.tournamentName,r.left,a),a+=6,t.subtitle&&(A(e,k.HEADING,O.BOLD),e.text(t.subtitle,r.left,a),a+=4),A(e,k.TINY,O.NORMAL),e.setTextColor(80);let o=[];return t.startDate&&o.push(t.startDate),t.organizer&&o.push(t.organizer),(t.city||t.country)&&o.push([t.city,t.country].filter(Boolean).join(`, `)),t.tournamentId&&o.push(`ID: ${t.tournamentId}`),t.grade&&o.push(`Grade: ${t.grade}`),t.chiefUmpire&&o.push(`Umpire: ${t.chiefUmpire}`),o.length&&(e.text(o.join(` | `),r.left,a),a+=3),e.setTextColor(0),a+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,a,i,a),a+=3,a-r.top}function ne(e,t,n,r){switch(t.layout){case`standard`:return re(e,t,n,r);case`seedings`:case`seedings-table`:return ie(e,t,n,r);case`prize-money`:return ae(e,t,n,r);case`officials`:case`officials-signoff`:return oe(e,t,n,r);case`combined-tour`:return se(e,t,n,r);case`none`:return 0}}function I(e){switch(e.layout){case`standard`:return 8+(e.notes?.length||0)*3;case`seedings`:case`seedings-table`:return 12+Math.ceil((e.seedAssignments?.length||0)/2)*3;case`prize-money`:return 12+(e.prizeMoney?.length||0)*2.5;case`officials`:case`officials-signoff`:return 12+(e.signatureLines?.length||e.officials?.length||0)*5;case`combined-tour`:{let t=Math.ceil((e.seedAssignments?.length||0)/2),n=e.prizeMoney?.length||0;return 16+Math.max(t*3,n*2.5)+(e.withdrawals?.length?6:0)}case`none`:return 0}}function re(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=a-o.bottom;if(A(e,k.TINY,O.NORMAL),e.setTextColor(120),t.showTimestamp&&e.text(`Generated ${new Date().toLocaleDateString()}`,o.left,c),t.showPageNumbers&&r!==void 0&&e.text(`Page ${r}`,s,c,{align:`right`}),e.setTextColor(0),c-=3,e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,c,s,c),c-=2,t.notes?.length){A(e,k.TINY,O.ITALIC),e.setTextColor(100);for(let n=t.notes.length-1;n>=0;n--)e.text(t.notes[n],o.left,c),c-=3;e.setTextColor(0)}return I(t)}function ie(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=I(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3,A(e,k.SMALL,O.BOLD),e.text(`Seeded Players`,o.left,l),l+=3;let u=t.seedAssignments||[],d=(s-o.left)/2;A(e,k.TINY,O.NORMAL);for(let t=0;t<u.length;t++){let n=t<Math.ceil(u.length/2)?0:1,r=n===0?t:t-Math.ceil(u.length/2),i=o.left+n*d,a=l+r*3,s=u[t],c=s.ranking?` (${s.ranking})`:``;e.text(`${s.seedValue}. ${s.participantName}${c}`,i,a)}let f=Math.ceil(u.length/2);return l+=f*3+2,L(e,t,n,r,l),c}function ae(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=I(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3,A(e,k.SMALL,O.BOLD),e.text(`Prize Money`,o.left,l),l+=3;let u=t.prizeMoney||[];A(e,k.TINY,O.NORMAL);for(let t of u){let n=[t.round];t.amount&&n.push(t.amount),t.points&&n.push(`${t.points} pts`),e.text(n.join(` — `),o.left,l),l+=2.5}return l+=2,L(e,t,n,r,l),c}function oe(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=I(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=4,t.drawCeremonyDate&&(A(e,k.TINY,O.ITALIC),e.setTextColor(80),e.text(`Draw ceremony: ${t.drawCeremonyDate}`,o.left,l),e.setTextColor(0),l+=3),t.releaseDate&&(A(e,k.TINY,O.ITALIC),e.setTextColor(80),e.text(`Released: ${t.releaseDate}`,o.left,l),e.setTextColor(0),l+=3);let u=t.signatureLines||(t.officials||[]).map(e=>({role:e})),d=(s-o.left)/Math.min(u.length,3);for(let t=0;t<u.length;t++){let n=t%3,r=Math.floor(t/3),i=o.left+n*d,a=l+r*10;A(e,k.TINY,O.ITALIC),e.setTextColor(100),e.text(u[t].role,i,a),e.setTextColor(0),u[t].name&&(A(e,k.TINY,O.BOLD),e.text(u[t].name,i,a+3)),e.setDrawColor(150),e.setLineWidth(.15),e.line(i,a+5,i+d-8,a+5)}let f=Math.ceil(u.length/3);return l+=f*10+2,L(e,t,n,r,l),c}function se(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=I(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3;let u=s-o.left,d=o.left,f=o.left+u*.55,p=l,m=l,h=t.seedAssignments||[];if(h.length){A(e,k.SMALL,O.BOLD),e.text(`Seeded Players`,d,p),p+=3,A(e,k.TINY,O.NORMAL);for(let t of h){let n=t.ranking?` (${t.ranking})`:``;e.text(`${t.seedValue}. ${t.participantName}${n}`,d,p),p+=2.5}}let g=t.prizeMoney||[];if(g.length){A(e,k.SMALL,O.BOLD),e.text(`Prize Money`,f,m),m+=3,A(e,k.TINY,O.NORMAL);for(let t of g){let n=[t.round];t.amount&&n.push(t.amount),t.points&&n.push(`${t.points} pts`),e.text(n.join(` — `),f,m),m+=2.5}}if(l=Math.max(p,m)+2,t.withdrawals?.length){A(e,k.TINY,O.ITALIC),e.setTextColor(80);let n=t.withdrawals.map(e=>e.reason?`${e.name} (${e.reason})`:e.name).join(`, `);e.text(`Withdrawals: ${n}`,o.left,l,{maxWidth:u}),e.setTextColor(0),l+=3}return t.luckyLosers?.length&&(A(e,k.TINY,O.ITALIC),e.setTextColor(80),e.text(`Lucky Losers: ${t.luckyLosers.join(`, `)}`,o.left,l,{maxWidth:u}),e.setTextColor(0),l+=3),t.officials?.length&&(A(e,k.TINY,O.NORMAL),e.setTextColor(80),e.text(t.officials.join(` | `),o.left,l),e.setTextColor(0),l+=3),L(e,t,n,r,l),c}function L(e,t,n,r,i){let a=e.internal.pageSize.getWidth(),o=e.internal.pageSize.getHeight(),{margins:s}=n,c=a-s.right,l=o-s.bottom+2;if(A(e,k.TINY,O.NORMAL),e.setTextColor(120),t.showTimestamp&&e.text(`Generated ${new Date().toLocaleDateString()}`,s.left,l),t.releaseDate){let n=t.showTimestamp?s.left+50:s.left;e.text(`Released: ${t.releaseDate}`,n,l)}t.showPageNumbers&&r!==void 0&&e.text(`Page ${r}`,c,l,{align:`right`}),e.setTextColor(0)}var ce=5,le=2.5;function ue(e,t,n,r){let i=t.seedAssignments;if(!i.length)return r;let a=n.page.margins,o=e.internal.pageSize.getWidth()-a.left-a.right;A(e,ce+1,O.BOLD),e.text(`Seeded players`,a.left,r),e.setDrawColor(150),e.setLineWidth(.15),e.line(a.left,r+1,a.left+o*.5,r+1),r+=3;let s=Math.ceil(i.length/2),c=i.slice(0,s),l=i.slice(s),u=o*.25,d=r;for(let t=0;t<Math.max(c.length,l.length);t++)c[t]&&de(e,c[t],a.left,d,u),l[t]&&de(e,l[t],a.left+u+4,d,u),d+=le;return d}function de(e,t,n,r,i){A(e,ce,O.BOLD),e.text(`${t.seedValue}`,n+4,r,{align:`right`}),A(e,ce,O.NORMAL),e.text(t.participantName,n+6,r),e.setTextColor(100),e.text(t.nationality,n+45,r),e.setTextColor(0)}function fe(e){return e===0?0:4+Math.ceil(e/2)*le}function pe(e,t){return e.type?e.composition?{success:!0,filename:me(e)}:{success:!1,error:`Missing composition config`}:{success:!1,error:`Missing request type`}}function me(e){let t=new Date().toISOString().slice(0,10);switch(e.type){case`draw`:return`draw-${t}.pdf`;case`schedule`:return`order-of-play-${e.scheduledDate||t}.pdf`;case`playerList`:return`player-list-${t}.pdf`;case`courtCards`:return`court-cards-${t}.pdf`;case`signInSheet`:return`sign-in-sheet-${t}.pdf`;case`matchCard`:return`match-cards-${t}.pdf`}}var he=[{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`}],ge=[{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`}],_e=[{value:`a4`,label:`A4 (210 × 297mm)`},{value:`letter`,label:`US Letter (216 × 279mm)`}],ve=[{value:`auto`,label:`Auto (landscape for large draws)`},{value:`landscape`,label:`Landscape`},{value:`portrait`,label:`Portrait`}],ye=[{value:`single-page`,label:`Single Page (dense)`},{value:`halves`,label:`Two Halves (64+64)`},{value:`quarters`,label:`Four Quarters (32×4)`}],be=[{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`}]}],xe=[{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 R(e){if(!e)return``;if(e.person){let{standardFamilyName:t,standardGivenName:n}=e.person;if(t)return`${t.toUpperCase()}, ${n||``}`.trim()}return e.participantName||``}function z(e){return e&&e.person?.nationalityCode||``}function Se(e){return e?`[${e}]`:``}function Ce(e){return e?{DIRECT_ACCEPTANCE:`DA`,WILDCARD:`WC`,LUCKY_LOSER:`LL`,QUALIFIER:`Q`,ALTERNATE:`A`,SPECIAL_EXEMPT:`SE`}[e]||e:``}function we(e){return e?typeof e==`string`?e:e.scoreStringSide1?e.scoreStringSide1:``:``}function Te(e){return e?new Date(e+`T00:00:00`).toLocaleDateString(`en-US`,{day:`2-digit`,month:`short`,year:`numeric`}):``}function B(e){if(!e)return``;let[t,n]=e.split(`:`),r=parseInt(t),i=r>=12?`PM`:`AM`,a=r;return r===0?a=12:r>12&&(a=r-12),`${a}:${n} ${i}`}function Ee(e){return e?e.split(/\s+/).map(e=>e[0]).join(``).toUpperCase():``}function De(e,t){let n=t-e+1;return n===1?`F`:n===2?`SF`:n===3?`QF`:`R${2**n}`}function Oe(e){let{drawDefinition:t,participants:n=[]}=e;if(!t)return Ae();let r=e.structureId?t.structures?.find(t=>t.structureId===e.structureId):t.structures?.[0];if(!r)return Ae();let i=new Map;n.forEach(e=>i.set(e.participantId,e));let a=r.positionAssignments||[],o=(r.matchUps||[]).reduce((e,t)=>Math.max(e,t.roundNumber||0),0),s=e.structureId?a.length:t.drawSize||a.length,c=e.structureId?o:Math.log2(s),l=r.seedAssignments||[],u=a.map(e=>{let t=e.participantId?i.get(e.participantId):void 0,n=l.find(t=>t.participantId===e.participantId);return{drawPosition:e.drawPosition,participantName:t?R(t):``,nationality:t?z(t):``,seedValue:n?.seedValue,entryStatus:e.entryStatus,isBye:e.bye===!0}}),d=(r.matchUps||[]).map(e=>({roundNumber:e.roundNumber,roundPosition:e.roundPosition,drawPositions:e.drawPositions||[],score:we(e.score),winningSide:e.winningSide,matchUpStatus:e.matchUpStatus})),f=l.filter(e=>e.participantId).map(e=>{let t=i.get(e.participantId);return{seedValue:e.seedValue,participantName:t?R(t):``,nationality:t?z(t):``}}).sort((e,t)=>e.seedValue-t.seedValue),p=ke(d,c,e.processedMatchUps);return{drawName:t.drawName||``,drawSize:s,drawType:t.drawType||`SINGLE_ELIMINATION`,totalRounds:c,slots:u,matchUps:d,seedAssignments:f,roundLabelMap:p}}function V(e,t){return De(e,t)}function ke(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]=De(n,t);return e}let a={};for(let e of i)a[e]=`R${e}`;return a}function Ae(){return{drawName:``,drawSize:0,drawType:``,totalRounds:0,slots:[],matchUps:[],seedAssignments:[]}}function je(e){let{matchUps:t=[],venues:n=[],scheduledDate:r=``}=e,i=new Set;n.forEach(e=>{(e.courts||[]).forEach(e=>{i.add(e.courtName||`Court ${e.courtId}`)})});let a=new Map;n.forEach(e=>{(e.courts||[]).forEach(e=>{a.set(e.courtId,e.courtName||`Court ${e.courtId}`)})});let o=t.filter(e=>e.schedule?.scheduledDate===r||!r),s=new Map;for(let e of o){let t=e.schedule||{},n=t.scheduledTime||`00:00`,r=t.venueCourtId||t.courtId||``,o=a.get(r)||r;o&&i.add(o);let c=e.sides||[],l=Me(c[0]),u=Me(c[1]),d={courtName:o,scheduledTime:B(n),eventName:e.eventName||e.event?.eventName||``,eventAbbr:Ee(e.eventName||e.event?.eventName||``),roundName:e.roundName||``,side1:l,side2:u,score:we(e.score),matchUpStatus:e.matchUpStatus,notBeforeTime:t.notBeforeTime?B(t.notBeforeTime):void 0},f=t.notBeforeTime||n;s.has(f)||s.set(f,[]),s.get(f).push(d)}let c=[...s.keys()].sort().map(e=>({time:e,label:B(e)||`TBD`,matches:s.get(e)||[]}));return{scheduledDate:r,courts:[...i].sort(),timeSlots:c}}function Me(e){if(!e)return{name:``,nationality:``};let t=e.participant;return t?{name:R(t),nationality:z(t)}:{name:``,nationality:``}}function Ne(e){let{participants:t=[],eventEntries:n=[]}=e,r=new Map;for(let{eventName:e,entries:t}of n)for(let n of t){let t=n.participantId;r.has(t)||r.set(t,{events:[],entryStatus:``,seedValue:void 0});let i=r.get(t);i.events.push(e),n.entryStatus&&(i.entryStatus=n.entryStatus)}return t.filter(e=>e.participantType===`INDIVIDUAL`).map(e=>{let t=r.get(e.participantId);return{name:R(e),nationality:z(e),ranking:e.rankings?.[0]?.ranking?.toString()||``,seedValue:t?.seedValue,entryStatus:Ce(t?.entryStatus||``),events:t?.events||[],signedIn:e.signInStatus===`SIGNED_IN`}}).sort((e,t)=>e.name.localeCompare(t.name))}function Pe(e){let{matchUps:t=[],venues:n=[]}=e,r=new Map;n.forEach(e=>{(e.courts||[]).forEach(t=>{r.set(t.courtId,{courtName:t.courtName||`Court ${t.courtId}`,venueName:e.venueName||``})})});let i=new Map;for(let e of t){let t=e.schedule?.venueCourtId||e.schedule?.courtId;t&&(i.has(t)||i.set(t,[]),i.get(t).push(e))}let a=[];for(let[e,t]of i){let n=r.get(e)||{courtName:e,venueName:``};t.sort((e,t)=>{let n=e.schedule?.scheduledTime||``,r=t.schedule?.scheduledTime||``;return n.localeCompare(r)});let i=t.find(e=>e.matchUpStatus===`IN_PROGRESS`),o=t.filter(e=>![`COMPLETED`,`RETIRED`,`WALKOVER`,`DEFAULTED`,`ABANDONED`].includes(e.matchUpStatus)),s=i||o[0],c=i?o.find(e=>e!==i):o[1];a.push({courtName:n.courtName,venueName:n.venueName,currentMatch:s?Fe(s):void 0,nextMatch:c?Fe(c):void 0})}return a.sort((e,t)=>e.courtName.localeCompare(t.courtName))}function Fe(e){let t=e.sides||[];return{eventName:e.eventName||e.event?.eventName||``,roundName:e.roundName||``,scheduledTime:e.schedule?.scheduledTime?B(e.schedule.scheduledTime):void 0,side1:Ie(t[0]),side2:Ie(t[1])}}function Ie(e){return e?.participant?{name:R(e.participant),nationality:z(e.participant)}:{name:`TBD`,nationality:``}}function Le(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?R(t):``,nationality:t?z(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=we(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}}):[]}function Re(e,t){if(e.isBye)return`Bye`;if(!e.participantName)return``;let n=ze(e.participantName,t),r=Be(e.nationality,t),i=e.seedValue?Ve(e.seedValue,t):``,a=e.entryStatus?Ue(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 H(e,t){if(e.isBye)return{name:`Bye`,nationality:``};if(!e.participantName)return{name:``,nationality:``};let n=ze(e.participantName,t),r=e.seedValue?Ve(e.seedValue,t):``,i=e.entryStatus?Ue(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 ze(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 Be(e,t){if(!e)return``;switch(t.nationalityFormat){case`parens`:return`(${e})`;case`hyphen`:return`-${e}`;default:return e}}function Ve(e,t){return t.seedFormat===`parens`?`(${e})`:`[${e}]`}var He={DIRECT_ACCEPTANCE:``,WILDCARD:`WC`,QUALIFIER:`Q`,LUCKY_LOSER:`LL`,SPECIAL_EXEMPT:`SE`,ALTERNATE:`ALT`,PROTECTED_RANKING:`PR`,JUNIOR_EXEMPT:`JE`,ORGANISER_ACCEPTANCE:`OA`};function Ue(e,t){if(!e)return``;let n=He[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 U(e,t){return e?t.gameScoreSeparator===`/`?e.replace(/(\d)-(\d)/g,`$1/$2`):e:``}function We(e,t){let n=Math.log2(e),r=(t.contentHeight-9)/e,i=r<3.5,a=i?.8:1.5,o=n,s=a*(o+1),c=r<2,l=i?.18:.3,u=Math.min(i?38:65,t.contentWidth*l),d=t.contentWidth-u-s,f=c?8:0,p=d-f,m=Math.min(65,Math.max(8,p/Math.max(1,o))),h=m+f,g=k.SMALL;return r<2.5?g=5:r<3.5&&(g=k.TINY),{lineHeight:r,roundColumnWidth:m,firstRoundWidth:u,secondRoundWidth:h,connectorGap:a,fontSize:g,scoreFontSize:i?5:k.TINY}}function W(e,t,n,r,i=0,a){Ge(t.matchUps)?Ke(e,t,n,r):Je(e,t,n,r,i,a)}function Ge(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 Ke(e,t,n,r){let i=n.page.margins,a=r.contentY+9,o=r.contentHeight-9,s=new Map;for(let e of t.matchUps)s.has(e.roundNumber)||s.set(e.roundNumber,[]),s.get(e.roundNumber).push(e);for(let[,e]of s)e.sort((e,t)=>e.roundPosition-t.roundPosition);let c=[...s.keys()].sort((e,t)=>e-t),l=c.length,u=new Map(t.slots.map(e=>[e.drawPosition,e])),d=new Set;for(let e=1;e<c.length;e++){let t=s.get(c[e-1])?.length||0;(s.get(c[e])?.length||0)>=t&&d.add(c[e])}let f=1.5,p=o/((s.get(c[0])?.length||1)*2),m=p<3.5,h=Math.min(m?50:60,r.contentWidth*.25),g=r.contentWidth-h-f*(l+1),_=Math.max(8,g/Math.max(1,l)),v=k.SMALL;p<2.5?v=5:p<3.5&&(v=k.TINY);let y=m?5:k.TINY,b={lineHeight:p,roundColumnWidth:_,firstRoundWidth:h,secondRoundWidth:_,connectorGap:f,fontSize:v,scoreFontSize:y},x=e=>e===0?i.left:i.left+h+f+(e-1)*(_+f);qe(e,c,t,b,n,r,x,l,_);let S=new Map;for(let e=0;e<l;e++){let t=c[e],n=s.get(t)?.length||0;if(d.has(t)){let r=c[e-1],i=(S.get(r)||[]).slice(0,n).map(e=>e.bottomY-e.topY>p*2?{topY:e.midY-p,bottomY:e.midY+p,midY:e.midY}:{topY:e.topY,bottomY:e.bottomY,midY:e.midY});S.set(t,i)}else if(e===0){let e=o/(n*2+1),r=[];for(let t=0;t<n;t++){let n=a+e*(t*2+1),i=a+e*(t*2+2);r.push({topY:n,bottomY:i,midY:(n+i)/2})}S.set(t,r)}else{let r=c[e-1],i=S.get(r)||[],a=[];for(let e=0;e<n;e++){let t=i[e*2],n=i[e*2+1];if(t&&n){let e=t.midY,r=n.midY;a.push({topY:e,bottomY:r,midY:(e+r)/2})}}S.set(t,a)}}for(let t=0;t<l;t++){let r=c[t],i=s.get(r)||[],a=S.get(r)||[],o=x(t),p=t===0?h:_,m=d.has(r),g=o+p;for(let r=0;r<i.length;r++){let p=i[r],v=a[r];if(!v)continue;e.setDrawColor(40),e.setLineWidth(.25);let S=t<l-1&&d.has(c[t+1]);if(t===0)p.drawPositions[0]&&q(e,u.get(p.drawPositions[0]),p.drawPositions[0],n,b,o,v.topY,h),p.drawPositions[1]&&q(e,u.get(p.drawPositions[1]),p.drawPositions[1],n,b,o,v.bottomY,h),S?e.line(g,v.topY,g,v.bottomY):(e.line(g+f,v.topY,g+f,v.bottomY),e.line(g,v.topY,g+f,v.topY),e.line(g,v.bottomY,g+f,v.bottomY));else if(m){let r=c[t-1],i=s.get(r)||[],a=new Set;for(let e of i)e.winningSide&&a.add(e.drawPositions[e.winningSide-1]);let l=p.drawPositions.find(e=>e&&a.has(e)),d=p.drawPositions.find(e=>e&&e!==l);if(e.line(o,v.midY,o,v.bottomY),d?q(e,u.get(d),d,n,b,o,v.topY,_):e.line(o,v.topY,o+_,v.topY),e.line(o,v.bottomY,o+_,v.bottomY),l){let t=u.get(l);t?.participantName&&Xe(e,t,n,b,o,v.bottomY)}S?e.line(g,v.topY,g,v.bottomY):(e.line(g+f,v.topY,g+f,v.bottomY),e.line(g,v.topY,g+f,v.topY),e.line(g,v.bottomY,g+f,v.bottomY))}else{if(e.line(o,v.topY,o+_,v.topY),e.line(o,v.bottomY,o+_,v.bottomY),p.drawPositions[0]){let t=u.get(p.drawPositions[0]);t?.participantName&&Xe(e,t,n,b,o,v.topY)}if(p.drawPositions[1]){let t=u.get(p.drawPositions[1]);t?.participantName&&Xe(e,t,n,b,o,v.bottomY)}S?e.line(g,v.topY,g,v.bottomY):(e.line(g+f,v.topY,g+f,v.bottomY),e.line(g,v.topY,g+f,v.topY),e.line(g,v.bottomY,g+f,v.bottomY))}if(t<l-1){let n=x(t+1);S?e.line(g,v.midY,n,v.midY):e.line(g+f,v.midY,n,v.midY)}if(p.score){let t=U(p.score,n);A(e,y,O.NORMAL),e.setTextColor(60,60,160);let r=v.midY+y*.12;e.text(t,g-1,r,{align:`right`}),e.setTextColor(0)}}}if(!t.noWinnerColumn){let t=x(l),r=c[l-1],i=(S.get(r)||[])[0]?.midY||a+o/2;e.setDrawColor(40),e.setLineWidth(.25),e.line(t,i,t+Math.min(65,_),i);let d=(s.get(r)||[])[0];if(d?.winningSide){let r=d.drawPositions[d.winningSide-1],a=u.get(r);if(a){A(e,v+1,O.BOLD);let{name:r}=H(a,n);if(e.text(r,t+1,i-.5),d.score){let r=U(d.score,n);A(e,y,O.NORMAL),e.setTextColor(60,60,160),e.text(r,t+1,i+y*.4),e.setTextColor(0)}}}}}function qe(e,t,n,r,i,a,o,s,c){A(e,r.fontSize<=k.TINY?5.5:k.SMALL,O.BOLD),e.setTextColor(40);for(let l=0;l<s;l++){let s=t[l],u=V(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 Je(e,t,n,r,i=0,a){let o=a||t.drawSize,s=Math.log2(o),c=We(o,r),l=n.page.margins.left,u=r.contentY+9;Ye(e,s,t.totalRounds,c,n,l,r.contentY+2,t.roundLabelMap,t.noWinnerColumn);for(let r=0;r<s;r++){let a=o/2**(r+1),d=c.lineHeight*2**r,f=K(r,c,l),p=(2**r-1)*c.lineHeight/2,m=2**(r+1)*c.lineHeight;for(let o=0;o<a;o++){let a=u+p+o*m,h=a+d,g=(a+h)/2;if(r===0){let r=i+o*2+1,s=i+o*2+2,l=Qe(t.slots,r),u=Qe(t.slots,s);q(e,l,r,n,c,f,a),q(e,u,s,n,c,f,h)}else{let t=G(r,c);e.setDrawColor(40),e.setLineWidth(.25),e.line(f,a,f+t,a),e.line(f,h,f+t,h)}let _=f+G(r,c),v=K(r+1,c,l);e.setDrawColor(40),e.setLineWidth(.25),e.line(_+c.connectorGap,a,_+c.connectorGap,h),e.line(_,a,_+c.connectorGap,a),e.line(_,h,_+c.connectorGap,h),e.line(_+c.connectorGap,g,v,g);let y=$e(t.matchUps,r+1,o+1);if(r<s-1&&y?.winningSide){let r=y.drawPositions[y.winningSide-1],i=Qe(t.slots,r);i&&Xe(e,i,n,c,v,g)}if(y?.score&&r<s-1){let t=U(y.score,n);if(A(e,c.scoreFontSize,O.NORMAL),e.setTextColor(60,60,160),d*2<c.scoreFontSize*1.2){let n=v+G(r+1,c)-1;e.text(t,n,g-.5,{align:`right`})}else{let n=c.scoreFontSize*.4;e.text(t,v+1,g-.5+n)}e.setTextColor(0)}}}if(t.noWinnerColumn)return;let d=K(s,c,l),f=(2**(s-1)-1)*c.lineHeight/2,p=c.lineHeight*2**(s-1),m=u+f+p/2;e.setDrawColor(40),e.setLineWidth(.25),e.line(d,m,d+c.roundColumnWidth,m);let h=$e(t.matchUps,s,1);if(h?.winningSide){let r=h.drawPositions[h.winningSide-1],i=Qe(t.slots,r);if(i){A(e,c.fontSize+1,O.BOLD);let{name:t}=H(i,n);if(e.text(t,d+1,m-.5),h.score){let t=U(h.score,n);A(e,c.scoreFontSize,O.NORMAL),e.setTextColor(60,60,160),e.text(t,d+1,m+c.scoreFontSize*.4),e.setTextColor(0)}}}}function Ye(e,t,n,r,i,a,o,s,c){A(e,r.fontSize<=k.TINY?5.5:k.SMALL,O.BOLD),e.setTextColor(40);for(let c=0;c<t;c++){let l=n-t+c+1,u=V(l,n),d=s?.[l]||i.roundLabels[u]||u,f=K(c,r,a),p=G(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=K(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 G(e,t){return e===0?t.firstRoundWidth:e===1?t.secondRoundWidth:t.roundColumnWidth}function K(e,t,n){if(e===0)return n;let r=n+t.firstRoundWidth+t.connectorGap;for(let n=1;n<e;n++)r+=G(n,t)+t.connectorGap;return r}function q(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;A(e,i.scoreFontSize,O.NORMAL),e.setTextColor(120),e.text(`${n}`,a,o-d,{align:`left`}),e.setTextColor(0),t?.nationality&&(A(e,i.scoreFontSize,O.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}=H(t,r);if(!m)return;A(e,i.fontSize,t.isBye?O.ITALIC:O.NORMAL),t.isBye&&e.setTextColor(150);let h=p-f-2,g=m;e.getTextWidth(m)>h&&(g=Ze(t.participantName));let _=i.lineHeight<2?.2:.5;e.text(g,f+1,o-_),t.isBye&&e.setTextColor(0)}function Xe(e,t,n,r,i,a){let o=Ze(t.participantName),s=``;t.seedValue&&(s=n.seedFormat===`parens`?`(${t.seedValue})`:`[${t.seedValue}]`);let c=s?`${o} ${s}`:o;A(e,r.fontSize,O.BOLD),e.text(c,i+1,a-.5)}function Ze(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 Qe(e,t){return e.find(e=>e.drawPosition===t)}function $e(e,t,n){return e.find(e=>e.roundNumber===t&&e.roundPosition===n)}var et=[200,200,200],tt=[20,80,20],nt=[160,40,40],rt=[50,50,50];function it(e,t,r,i,a){let o=r.page.margins,s=t.participants.length;A(e,k.HEADING,O.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=at(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:et}});else{let r=l[t]?.[e];if(r){let e=r.isWin?tt:nt;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:rt,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 at(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=U(n.score,t),s=n.winningSide===1;r[e][a]={score:o,isWin:s},r[a][e]={score:ot(o),isWin:!s}}return r}function ot(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 J=1,st=16,ct=1;function lt(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(st,(u-(f+1)*ct)/f);A(e,k.SMALL,O.BOLD),e.setTextColor(30,60,120);for(let a=0;a<c;a++){let o=s[a],c=n.roundLabels[V(o,t.totalRounds)]||V(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);ut(e,c[t],o,n,m,r,d,p)}}}function ut(e,t,n,r,i,a,o,s){let c=s<10?5:k.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=Re(u,r);A(e,c,t.winningSide===1?O.BOLD:O.NORMAL),e.text(n,i+J,l-c*.15,{maxWidth:o-2*J})}let d=t.drawPositions[1]?n.get(t.drawPositions[1]):void 0;if(d){let n=Re(d,r);A(e,c,t.winningSide===2?O.BOLD:O.NORMAL),e.text(n,i+J,l+c*.55,{maxWidth:o-2*J})}if(t.score){let n=U(t.score,r);A(e,c,O.NORMAL),e.setTextColor(60,60,160),e.text(n,i+o-J,a+c*.5,{align:`right`}),e.setTextColor(0)}}var dt={maxPositionsPerPage:64,includeOverlapRounds:!0,summaryPage:!0};function ft(e,t=dt){let{drawSize:n,slots:r,matchUps:i,totalRounds:a,roundLabelMap:o}=e;if(n<=t.maxPositionsPerPage)return[{label:`Full Draw`,startPosition:1,endPosition:n,slots:r,matchUps:i,segmentRounds:a}];let s=t.maxPositionsPerPage,c=Math.ceil(n/s),l=Math.log2(s),u=[];for(let e=0;e<c;e++){let t=e*s+1,a=Math.min((e+1)*s,n),o=`Section ${e+1}`;c===2&&(o=e===0?`Top Half`:`Bottom Half`);let d=r.filter(e=>e.drawPosition>=t&&e.drawPosition<=a),f=i.filter(e=>e.roundNumber>l?!1:e.drawPositions.every(e=>e>=t&&e<=a)),p=new Map;for(let e of f)p.has(e.roundNumber)||p.set(e.roundNumber,[]),p.get(e.roundNumber).push(e);let m=[];for(let[,e]of p)e.sort((e,t)=>e.roundPosition-t.roundPosition),e.forEach((e,t)=>{m.push({...e,roundPosition:t+1})});u.push({label:o,startPosition:t,endPosition:a,slots:d,matchUps:m,segmentRounds:l,noWinnerColumn:!0})}if(t.summaryPage&&c>1){let e=Math.max(1,a-5+1),t=i.filter(t=>t.roundNumber>=e),n=a-e+1,s=e-1,c=i.filter(t=>t.roundNumber===e).sort((e,t)=>e.roundPosition-t.roundPosition),l=c.length*2,d=new Map,f=1;for(let e of c)for(let t of e.drawPositions)t&&!d.has(t)&&d.set(t,f++);let p=t.map(t=>({...t,roundNumber:t.roundNumber-s,roundPosition:t.roundNumber===e?c.findIndex(e=>e.roundPosition===t.roundPosition)+1:t.roundPosition,drawPositions:t.drawPositions.map(e=>d.get(e)||e)})),m=new Map;for(let e of p)m.has(e.roundNumber)||m.set(e.roundNumber,[]),m.get(e.roundNumber).push(e);let h=[];for(let[,e]of m)e.sort((e,t)=>e.roundPosition-t.roundPosition),e.forEach((e,t)=>{h.push({...e,roundPosition:t+1})});let g=[];for(let[e,t]of d){let n=r.find(t=>t.drawPosition===e);n&&g.push({...n,drawPosition:t})}g.sort((e,t)=>e.drawPosition-t.drawPosition);let _=o?Object.fromEntries(Object.entries(o).filter(([t])=>Number(t)>=e).map(([e,t])=>[Number(e)-s,t])):void 0;u.push({label:`Final Rounds`,startPosition:1,endPosition:l,slots:g,matchUps:h,segmentRounds:n,roundLabelMap:_})}return u}var pt=[`E`,`W`,`N`,`S`,`NE`,`NW`,`SE`,`SW`];function mt(e,t,n,r){let i=n.page.margins,a=[...t.structures].sort((e,t)=>pt.indexOf(e.abbreviation)-pt.indexOf(t.abbreviation)),o=r.contentY+3;for(let s of a){if(s.drawSize===0)continue;let a=ht(s,r);o+a>r.contentY+r.contentHeight&&(e.addPage(),o=r.contentY);let c=s.abbreviation===`E`;A(e,c?k.HEADING:k.BODY,O.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};W(e,gt(s,t.drawName),n,u),o+=a+3}}function ht(e,t){let n=t.contentHeight*.7,r=Math.max(5,Math.min(8,n/e.drawSize));return e.drawSize*r+10}function gt(e,t){return{drawName:`${t} - ${e.name}`,drawSize:e.drawSize,drawType:`SINGLE_ELIMINATION`,totalRounds:e.totalRounds,slots:e.slots,matchUps:e.matchUps,seedAssignments:[]}}function _t(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?R(t):``,nationality:t?z(t):``,seedValue:n?.seedValue,isBye:e.bye===!0}}),s=(t.matchUps||[]).map(e=>({roundNumber:e.roundNumber,roundPosition:e.roundPosition,drawPositions:e.drawPositions||[],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?R(t):``,nationality:t?z(t):``}}),roundLabelMap:p}}})}function vt(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,A(e,o?k.HEADING:k.BODY,O.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)};W(e,t.drawData,n,c),a+=s+4}}function yt(e,t,n,r){let i=n.page.margins,a=r.contentHeight,o=a*.44,s=a*.44,c=r.contentWidth-30-8,l=bt(t.winnersBracket),u=r.contentY+3;A(e,k.BODY,O.BOLD),e.setTextColor(30,80,30),e.text(`Winner's Bracket`,i.left,u),e.setTextColor(0),u+=3,W(e,l,n,{...r,contentY:u,contentHeight:o-6,contentWidth:c}),u=r.contentY+o+6,A(e,k.BODY,O.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};W(e,t.losersBracket,n,d);let f=i.left+c+8,p=r.contentY+a/2;if(A(e,k.SMALL,O.BOLD),e.text(`Decider`,f+28/2,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-14/2-1,f+28,p-14/2-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;A(e,k.TINY,r?O.BOLD:O.NORMAL),e.text(t.participantName,f+1,p-14/2-3,{maxWidth:26})}}if(n.drawPositions[1]){let t=r.get(n.drawPositions[1]);if(t?.participantName){let r=n.winningSide===2;A(e,k.TINY,r?O.BOLD:O.NORMAL),e.text(t.participantName,f+1,p-3,{maxWidth:26})}}n.score&&(A(e,k.TINY,O.NORMAL),e.setTextColor(60,60,160),e.text(n.score,f+28-1,p-14+2,{align:`right`}),e.setTextColor(0))}}function bt(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 xt={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 St(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=xt[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?R(t):``,nationality:t?z(t):``,seedValue:n?.seedValue,isBye:e.bye===!0}}),l=(e.matchUps||[]).map(e=>({roundNumber:e.roundNumber,roundPosition:e.roundPosition,drawPositions:e.drawPositions||[],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}}function Y(e,t,n=15){let r=e.internal.pageSize.getWidth(),i=n;A(e,k.TITLE,O.BOLD),e.text(t.tournamentName,15,i),i+=7,t.subtitle&&(A(e,k.SUBTITLE,O.BOLD),e.text(t.subtitle,15,i),i+=6),A(e,k.BODY,O.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 Ct(e,t,n){let r=e.internal.pageSize.getWidth(),i=e.internal.pageSize.getHeight();A(e,k.SMALL,O.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 X={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]}},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}}},wt={slotWidth:90,slotHeight:14,roundGap:20,verticalGap:4,startX:15,startY:10};function Tt(e,t=wt,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 Et(e,t){if(e.setDrawColor(150),e.setLineWidth(.3),e.rect(t.x,t.y,t.width,t.height),t.isBye){A(e,k.SMALL,O.ITALIC),e.setTextColor(150),e.text(`Bye`,t.x+2,t.y+t.height/2+1.5),e.setTextColor(0);return}t.participantName&&(t.seed?(A(e,k.TINY,O.BOLD),e.text(`[${t.seed}]`,t.x+1,t.y+t.height/2+1),A(e,k.SMALL,O.NORMAL),e.text(t.participantName,t.x+9,t.y+t.height/2+1)):(A(e,k.SMALL,O.NORMAL),e.text(t.participantName,t.x+2,t.y+t.height/2+1)),t.nationality&&(A(e,k.TINY,O.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 Dt(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 Ot(e,t,n,r){A(e,k.TINY,O.NORMAL),e.setTextColor(60,60,180),e.text(t,n,r),e.setTextColor(0)}function kt(e,n={}){let{header:r,includeSeedings:i=!0,includeScores:a=!0}=n,o=new t.default({orientation:e.drawSize>=32?`landscape`:`portrait`,format:`a4`}),s=15;if(r){let t=`${e.drawName} - ${e.drawType.replace(/_/g,` `)} (${e.drawSize})`;s=Y(o,{...r,subtitle:t})}return s=e.drawSize<=64&&e.drawSize>0?At(o,e,s,a):jt(o,e,s),i&&e.seedAssignments.length>0&&Mt(o,e,s+8),Ct(o,`Generated ${new Date().toLocaleDateString()}`),o}function At(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={...wt,slotWidth:l,slotHeight:u,verticalGap:Math.max(1,u*.3),startX:15,startY:n},f=Tt(t.drawSize,d,s),p=new Map(t.slots.map(e=>[e.drawPosition,e]));A(e,k.SMALL,O.BOLD);for(let t=0;t<c;t++){let r=d.startX+t*(d.slotWidth+d.roundGap),i=V(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)Et(e,n);if(Dt(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&&Ot(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 jt(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,{...X.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 Mt(e,t,r){A(e,k.HEADING,O.BOLD),e.text(`Seeded Players`,15,r),r+=4;let i=[{header:`Seed`,dataKey:`seed`},{header:`Player`,dataKey:`name`},{header:`Nat.`,dataKey:`nat`}],a=t.seedAssignments.map(e=>({seed:e.seedValue,name:e.participantName,nat:e.nationality}));return(0,n.default)(e,{...X.compact,startY:r,columns:i,body:a,tableWidth:120,columnStyles:{seed:{cellWidth:15,halign:`center`,fontStyle:`bold`},name:{cellWidth:`auto`},nat:{cellWidth:20,halign:`center`}}}),e.lastAutoTable?.finalY||r+20}function Nt(e,r={}){let{header:i,fullCourtNames:a=!0,notes:o}=r,s=new t.default({orientation:(r.landscape===`auto`?e.courts.length>=5:r.landscape)?`landscape`:`portrait`,format:`a4`}),c=15;if(i){let t=e.scheduledDate?`Order of Play - ${e.scheduledDate}`:`Order of Play`;c=Y(s,{...i,subtitle:t})}let l=e.courts,u=a?l:l.map(Ft);for(let t of e.timeSlots){A(s,k.BODY,O.BOLD),s.setTextColor(30,60,120),s.text(t.label,15,c),s.setTextColor(0),c+=4;let e=u.map(e=>({header:e,dataKey:e})),r=new Map;l.forEach(e=>r.set(e,[]));for(let e of t.matches){let t=Pt(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)),d=[];for(let e=0;e<o;e++){let t={};l.forEach((n,i)=>{let o=r.get(n)||[],s=a?n:u[i];t[s]=o[e]||``}),d.push(t)}(0,n.default)(s,{...X.schedule,startY:c,columns:e,body:d,tableWidth:`auto`,didDrawPage:e=>{Ct(s,i?.tournamentName||``,e.pageNumber)}}),c=s.lastAutoTable?.finalY+6||c+20}if(o?.length){c+=4,A(s,k.SMALL,O.ITALIC),s.setTextColor(80);for(let e of o)s.text(e,15,c),c+=4;s.setTextColor(0)}return s}function Pt(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(`
|
|
2
|
-
`)}function
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-350yNsax.cjs`);let t=require(`jspdf`);t=e.n(t);let n=require(`jspdf-autotable`);n=e.n(n);var r={F:`Final`,SF:`Semi-Finals`,QF:`Quarter-Finals`,R16:`Round of 16`,R32:`Round of 32`,R64:`Round of 64`,R128:`Round of 128`},i={F:`Final`,SF:`Semi-Finals`,QF:`Quarter-Finals`,R16:`Fourth Round`,R32:`Third Round`,R64:`Second Round`,R128:`First Round`},a={F:`Final`,SF:`Semifinals`,QF:`Quarterfinals`,R16:`Round 4`,R32:`Round 3`,R64:`Round 2`,R128:`Round 1`},o={F:`FINALE`,SF:`1/2 FINALE`,QF:`1/4 FINALE`,R16:`1/8 FINALE`,R32:`3eme TOUR`,R64:`2eme TOUR`,R128:`1er TOUR`},s={pageSize:`a4`,orientation:`auto`,margins:{top:15,right:10,bottom:15,left:10}},c=`LAST, First`,l=`bare`,u=`before-position`,d=`brackets`,f=`-`,p=`traditional-lines`,m={wimbledon:{nameFormat:c,nationalityFormat:l,seedPosition:u,seedFormat:d,entryFormat:`parens`,gameScoreSeparator:f,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:i,renderStyle:p,page:{...s}},usOpen:{nameFormat:c,nationalityFormat:l,seedPosition:u,seedFormat:d,entryFormat:`parens`,gameScoreSeparator:f,setScoreSeparator:` | `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:a,renderStyle:p,page:{...s}},rolandGarros:{nameFormat:`LAST First`,nationalityFormat:l,seedPosition:`after-country`,seedFormat:d,entryFormat:`parens`,gameScoreSeparator:`/`,setScoreSeparator:` `,retirementLabel:`Ab`,walkoverLabel:`w/o`,roundLabels:o,renderStyle:p,page:{...s}},australianOpen:{nameFormat:c,nationalityFormat:`parens`,seedPosition:`after-name`,seedFormat:d,entryFormat:`hyphen`,gameScoreSeparator:`/`,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:r,renderStyle:p,page:{...s,pageSize:`letter`,orientation:`portrait`}},itfJunior:{nameFormat:c,nationalityFormat:l,seedPosition:u,seedFormat:d,entryFormat:`bare`,gameScoreSeparator:f,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`w/o`,roundLabels:r,renderStyle:p,page:{...s}},usta:{nameFormat:c,nationalityFormat:l,seedPosition:u,seedFormat:d,entryFormat:`bare`,gameScoreSeparator:f,setScoreSeparator:` `,retirementLabel:`Ret.`,walkoverLabel:`W/O`,roundLabels:r,renderStyle:p,page:{...s}}};function h(e){return m[e]||m.itfJunior}function g(e,t){return{...h(e),...t}}var _=`itfJunior`,v=`combined-tour`,y=`grand-slam`,b=`officials-signoff`,x={[y]:{id:y,name:`Grand Slam`,description:`Minimal chrome — large tournament name, timestamp footer`,category:y,tier:1,header:{layout:y},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`wimbledon`},wimbledon:{id:`wimbledon`,name:`Wimbledon`,description:`Green/purple Grand Slam style with crest`,category:y,tier:1,header:{layout:y},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`wimbledon`},"australian-open":{id:`australian-open`,name:`Australian Open`,description:`Grand Slam with seedings + prize money footer`,category:y,tier:2,header:{layout:y},footer:{layout:v,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`australianOpen`},"wta-500":{id:`wta-500`,name:`WTA 500`,description:`Tour header with logos, seedings + prize money footer`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:v,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:_},"wta-1000":{id:`wta-1000`,name:`WTA 1000`,description:`Tour header with logos, full footer with officials`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:v,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:_},"atp-250":{id:`atp-250`,name:`ATP 250`,description:`ATP tour header, seedings + prize money footer with sign-off`,category:`tour`,tier:2,header:{layout:`wta-tour`},footer:{layout:v,showPageNumbers:!1,showTimestamp:!0},drawFormatPreset:_},"atp-finals":{id:`atp-finals`,name:`ATP Finals`,description:`Full official sign-off with signature lines`,category:`tour`,tier:3,header:{layout:y},footer:{layout:b,showTimestamp:!0},drawFormatPreset:_},"itf-junior":{id:`itf-junior`,name:`ITF Junior`,description:`ITF header with metadata row, officials sign-off footer`,category:`itf`,tier:3,header:{layout:`itf`},footer:{layout:b,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:_},"itf-pro-circuit":{id:`itf-pro-circuit`,name:`ITF Pro Circuit`,description:`ITF header, seedings + officials footer`,category:`itf`,tier:2,header:{layout:`itf`},footer:{layout:v,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:_},"national-federation":{id:`national-federation`,name:`National Federation`,description:`Detailed metadata header, full sign-off footer with ceremony date`,category:`national`,tier:3,header:{layout:`national-federation`},footer:{layout:b,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:`usta`},"collegiate-ncaa":{id:`collegiate-ncaa`,name:`NCAA Collegiate`,description:`Mirrored bracket layout, team logos, minimal footer`,category:`collegiate`,tier:1,header:{layout:y},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:_},"club-basic":{id:`club-basic`,name:`Club Basic`,description:`Minimal header, standard footer — clean and simple`,category:`club`,tier:1,header:{layout:`minimal`},footer:{layout:`standard`,showPageNumbers:!0,showTimestamp:!0},drawFormatPreset:_}};function S(e){return x[e]}function C(e){let t=Object.values(x);return e?t.filter(t=>t.category===e):t}function w(e,t,n){let r=x[e]||x[`club-basic`];return{header:{...r.header,...t},footer:{...r.footer,...n}}}function T(e){let t=e.roundMatchUps||{},n=e.roundProfile||{},r=Object.keys(t).map(Number).sort((e,t)=>e-t),i=new Map;for(let e of r)for(let n of t[e]||[])for(let e of n.sides||[])if(e?.drawPosition&&!i.has(e.drawPosition)){let t=e.entryStatus||e.participant?.entryStatus,n=t&&t!==`DIRECT_ACCEPTANCE`?t:void 0;i.set(e.drawPosition,{drawPosition:e.drawPosition,participantName:e.participant?.participantName||``,nationality:e.participant?.nationalityCode||``,seedValue:e.seedValue,entryStatus:n,isBye:e.bye===!0})}let a=[];for(let e of r)for(let n of t[e]||[])a.push({roundNumber:n.roundNumber,roundPosition:n.roundPosition,drawPositions:n.drawPositions||[],score:n.score?.scoreStringSide1||``,winningSide:n.winningSide,matchUpStatus:n.matchUpStatus});let o={};for(let e of r){let t=n[e];o[e]=t?.abbreviatedRoundName||t?.roundName||`R${e}`}let s=r.length>0?Math.max(...r):0,c=[...i.values()].sort((e,t)=>e.drawPosition-t.drawPosition),l=e.stage===`QUALIFYING`,u=t[s]?.length||0,d=l||u>1;return{drawName:e.structureName||``,drawSize:c.length,drawType:`SINGLE_ELIMINATION`,totalRounds:s,noWinnerColumn:d,slots:c,matchUps:a,seedAssignments:(e.seedAssignments||[]).filter(e=>e.participantName).map(e=>({seedValue:e.seedValue,participantName:e.participantName||``,nationality:e.nationalityCode||``})),roundLabelMap:o}}function E(e,t){return e?.[0]?.structures?.find(e=>e.stage===t)}function D(e,n){let r=e.orientation;return r===`auto`&&(r=n&&n>=32?`landscape`:`portrait`),new t.default({orientation:r,format:e.pageSize,unit:`mm`})}function O(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=t;return{headerHeight:n,footerHeight:r,contentY:o.top+n,contentHeight:a-o.top-o.bottom-n-r,contentWidth:i-o.left-o.right,pageWidth:i,pageHeight:a}}function k(){return{pageSize:`a4`,orientation:`auto`,margins:{top:15,right:10,bottom:15,left:10}}}var A={REGULAR:`helvetica`,BOLD:`helvetica`},j={NORMAL:`normal`,BOLD:`bold`,ITALIC:`italic`},M={TITLE:16,SUBTITLE:12,HEADING:10,BODY:8,SMALL:7,TINY:6};function N(e,t,n=j.NORMAL){e.setFont(A.REGULAR,n),e.setFontSize(t)}function P(e,t,n){switch(t.layout){case`grand-slam`:return F(e,t,n);case`itf`:return ee(e,t,n);case`minimal`:return te(e,t,n);case`wta-tour`:return ne(e,t,n);case`national-federation`:return re(e,t,n);case`none`:return 0}}function F(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth(),a=i-r.right,o=r.top;N(e,18,j.BOLD),e.text(t.tournamentName.toUpperCase(),i/2,o,{align:`center`}),o+=7,t.subtitle&&(N(e,12,j.BOLD),e.text(t.subtitle.toUpperCase(),i/2,o,{align:`center`}),o+=6),N(e,M.BODY,j.NORMAL);let s=[];if(t.startDate){let e=t.endDate?`${t.startDate} - ${t.endDate}`:t.startDate;s.push(e)}return t.location&&s.push(t.location),s.forEach((t,n)=>{e.text(t,a,r.top+n*4,{align:`right`})}),o+=2,e.setDrawColor(0),e.setLineWidth(.5),e.line(r.left,o,a,o),o+=3,o-r.top}function ee(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth()-r.right,a=r.top;N(e,M.TITLE,j.BOLD),e.text(t.tournamentName,r.left,a),a+=6,t.subtitle&&(N(e,M.SUBTITLE,j.BOLD),e.text(t.subtitle,r.left,a),a+=5),N(e,M.SMALL,j.NORMAL);let o=[];t.grade&&o.push(`Grade: ${t.grade}`),t.surface&&o.push(`Surface: ${t.surface}`),t.supervisor&&o.push(`Supervisor: ${t.supervisor}`),o.forEach((t,n)=>{e.text(t,i,r.top+n*3.5,{align:`right`})}),N(e,M.BODY,j.NORMAL);let s=[];return t.startDate&&s.push(t.startDate),t.location&&s.push(t.location),t.organizer&&s.push(t.organizer),s.length&&(e.text(s.join(` | `),r.left,a),a+=4),a+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,a,i,a),a+=3,a-r.top}function te(e,t,n){let{margins:r}=n,i=r.top;N(e,M.SUBTITLE,j.BOLD),e.text(t.tournamentName,r.left,i);let a=e.getTextWidth(t.tournamentName);return t.subtitle&&(N(e,M.BODY,j.NORMAL),e.text(` - ${t.subtitle}`,r.left+a,i)),i+=6,i-r.top}function ne(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth(),a=i-r.right,o=i/2,s=r.top;if(t.leftLogoBase64)try{e.addImage(t.leftLogoBase64,`PNG`,r.left,s-2,12,12)}catch{}if(t.rightLogoBase64)try{e.addImage(t.rightLogoBase64,`PNG`,a-12,s-2,12,12)}catch{}N(e,14,j.BOLD),e.text(t.tournamentName,o,s,{align:`center`}),s+=5;let c=[t.city,t.country].filter(Boolean).join(`, `);c&&(N(e,M.BODY,j.NORMAL),e.setTextColor(80),e.text(c.toUpperCase(),o,s,{align:`center`}),e.setTextColor(0),s+=4);let l=[];if(t.startDate){let e=t.endDate?`${t.startDate} - ${t.endDate}`:t.startDate;l.push(e)}if(t.prizeMoney){let e=t.currency?`${t.currency} ${t.prizeMoney}`:t.prizeMoney;l.push(e)}return t.surface&&l.push(t.surface),l.length&&(N(e,M.SMALL,j.NORMAL),e.text(l.join(` | `),o,s,{align:`center`}),s+=4),t.sectionLabel&&(N(e,M.SMALL,j.BOLD),e.text(t.sectionLabel.toUpperCase(),a,s,{align:`right`}),s+=3),s+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,s,a,s),s+=3,s-r.top}function re(e,t,n){let{margins:r}=n,i=e.internal.pageSize.getWidth()-r.right,a=r.top;if(t.rightLogoBase64)try{e.addImage(t.rightLogoBase64,`PNG`,i-14,a-2,14,14)}catch{}N(e,M.TITLE,j.BOLD),e.text(t.tournamentName,r.left,a),a+=6,t.subtitle&&(N(e,M.HEADING,j.BOLD),e.text(t.subtitle,r.left,a),a+=4),N(e,M.TINY,j.NORMAL),e.setTextColor(80);let o=[];return t.startDate&&o.push(t.startDate),t.organizer&&o.push(t.organizer),(t.city||t.country)&&o.push([t.city,t.country].filter(Boolean).join(`, `)),t.tournamentId&&o.push(`ID: ${t.tournamentId}`),t.grade&&o.push(`Grade: ${t.grade}`),t.chiefUmpire&&o.push(`Umpire: ${t.chiefUmpire}`),o.length&&(e.text(o.join(` | `),r.left,a),a+=3),e.setTextColor(0),a+=1,e.setDrawColor(0),e.setLineWidth(.3),e.line(r.left,a,i,a),a+=3,a-r.top}function ie(e,t,n,r){switch(t.layout){case`standard`:return ae(e,t,n,r);case`seedings`:case`seedings-table`:return oe(e,t,n,r);case`prize-money`:return se(e,t,n,r);case`officials`:case`officials-signoff`:return ce(e,t,n,r);case`combined-tour`:return le(e,t,n,r);case`none`:return 0}}function I(e){switch(e.layout){case`standard`:return 8+(e.notes?.length||0)*3;case`seedings`:case`seedings-table`:return 12+Math.ceil((e.seedAssignments?.length||0)/2)*3;case`prize-money`:return 12+(e.prizeMoney?.length||0)*2.5;case`officials`:case`officials-signoff`:return 12+(e.signatureLines?.length||e.officials?.length||0)*5;case`combined-tour`:{let t=Math.ceil((e.seedAssignments?.length||0)/2),n=e.prizeMoney?.length||0;return 16+Math.max(t*3,n*2.5)+(e.withdrawals?.length?6:0)}case`none`:return 0}}function ae(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=a-o.bottom;if(N(e,M.TINY,j.NORMAL),e.setTextColor(120),t.showTimestamp&&e.text(`Generated ${new Date().toLocaleDateString()}`,o.left,c),t.showPageNumbers&&r!==void 0&&e.text(`Page ${r}`,s,c,{align:`right`}),e.setTextColor(0),c-=3,e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,c,s,c),c-=2,t.notes?.length){N(e,M.TINY,j.ITALIC),e.setTextColor(100);for(let n=t.notes.length-1;n>=0;n--)e.text(t.notes[n],o.left,c),c-=3;e.setTextColor(0)}return I(t)}function oe(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=I(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3,N(e,M.SMALL,j.BOLD),e.text(`Seeded Players`,o.left,l),l+=3;let u=t.seedAssignments||[],d=(s-o.left)/2;N(e,M.TINY,j.NORMAL);for(let t=0;t<u.length;t++){let n=t<Math.ceil(u.length/2)?0:1,r=n===0?t:t-Math.ceil(u.length/2),i=o.left+n*d,a=l+r*3,s=u[t],c=s.ranking?` (${s.ranking})`:``;e.text(`${s.seedValue}. ${s.participantName}${c}`,i,a)}let f=Math.ceil(u.length/2);return l+=f*3+2,ue(e,t,n,r,l),c}function se(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=I(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3,N(e,M.SMALL,j.BOLD),e.text(`Prize Money`,o.left,l),l+=3;let u=t.prizeMoney||[];N(e,M.TINY,j.NORMAL);for(let t of u){let n=[t.round];t.amount&&n.push(t.amount),t.points&&n.push(`${t.points} pts`),e.text(n.join(` — `),o.left,l),l+=2.5}return l+=2,ue(e,t,n,r,l),c}function ce(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=I(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=4,t.drawCeremonyDate&&(N(e,M.TINY,j.ITALIC),e.setTextColor(80),e.text(`Draw ceremony: ${t.drawCeremonyDate}`,o.left,l),e.setTextColor(0),l+=3),t.releaseDate&&(N(e,M.TINY,j.ITALIC),e.setTextColor(80),e.text(`Released: ${t.releaseDate}`,o.left,l),e.setTextColor(0),l+=3);let u=t.signatureLines||(t.officials||[]).map(e=>({role:e})),d=(s-o.left)/Math.min(u.length,3);for(let t=0;t<u.length;t++){let n=t%3,r=Math.floor(t/3),i=o.left+n*d,a=l+r*10;N(e,M.TINY,j.ITALIC),e.setTextColor(100),e.text(u[t].role,i,a),e.setTextColor(0);let s=u[t].name;s&&(N(e,M.TINY,j.BOLD),e.text(s,i,a+3)),e.setDrawColor(150),e.setLineWidth(.15),e.line(i,a+5,i+d-8,a+5)}let f=Math.ceil(u.length/3);return l+=f*10+2,ue(e,t,n,r,l),c}function le(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=e.internal.pageSize.getHeight(),{margins:o}=n,s=i-o.right,c=I(t),l=a-o.bottom-c+4;e.setDrawColor(180),e.setLineWidth(.2),e.line(o.left,l,s,l),l+=3;let u=s-o.left,d=o.left,f=o.left+u*.55,p=l,m=l,h=t.seedAssignments||[];if(h.length){N(e,M.SMALL,j.BOLD),e.text(`Seeded Players`,d,p),p+=3,N(e,M.TINY,j.NORMAL);for(let t of h){let n=t.ranking?` (${t.ranking})`:``;e.text(`${t.seedValue}. ${t.participantName}${n}`,d,p),p+=2.5}}let g=t.prizeMoney||[];if(g.length){N(e,M.SMALL,j.BOLD),e.text(`Prize Money`,f,m),m+=3,N(e,M.TINY,j.NORMAL);for(let t of g){let n=[t.round];t.amount&&n.push(t.amount),t.points&&n.push(`${t.points} pts`),e.text(n.join(` — `),f,m),m+=2.5}}if(l=Math.max(p,m)+2,t.withdrawals?.length){N(e,M.TINY,j.ITALIC),e.setTextColor(80);let n=t.withdrawals.map(e=>e.reason?`${e.name} (${e.reason})`:e.name).join(`, `);e.text(`Withdrawals: ${n}`,o.left,l,{maxWidth:u}),e.setTextColor(0),l+=3}return t.luckyLosers?.length&&(N(e,M.TINY,j.ITALIC),e.setTextColor(80),e.text(`Lucky Losers: ${t.luckyLosers.join(`, `)}`,o.left,l,{maxWidth:u}),e.setTextColor(0),l+=3),t.officials?.length&&(N(e,M.TINY,j.NORMAL),e.setTextColor(80),e.text(t.officials.join(` | `),o.left,l),e.setTextColor(0),l+=3),ue(e,t,n,r,l),c}function ue(e,t,n,r,i){let a=e.internal.pageSize.getWidth(),o=e.internal.pageSize.getHeight(),{margins:s}=n,c=a-s.right,l=o-s.bottom+2;if(N(e,M.TINY,j.NORMAL),e.setTextColor(120),t.showTimestamp&&e.text(`Generated ${new Date().toLocaleDateString()}`,s.left,l),t.releaseDate){let n=t.showTimestamp?s.left+50:s.left;e.text(`Released: ${t.releaseDate}`,n,l)}t.showPageNumbers&&r!==void 0&&e.text(`Page ${r}`,c,l,{align:`right`}),e.setTextColor(0)}var de=5,fe=2.5;function pe(e,t,n,r){let i=t.seedAssignments;if(!i.length)return r;let a=n.page.margins,o=e.internal.pageSize.getWidth()-a.left-a.right;N(e,de+1,j.BOLD),e.text(`Seeded players`,a.left,r),e.setDrawColor(150),e.setLineWidth(.15),e.line(a.left,r+1,a.left+o*.5,r+1),r+=3;let s=Math.ceil(i.length/2),c=i.slice(0,s),l=i.slice(s),u=o*.25,d=r;for(let t=0;t<Math.max(c.length,l.length);t++)c[t]&&me(e,c[t],a.left,d,u),l[t]&&me(e,l[t],a.left+u+4,d,u),d+=fe;return d}function me(e,t,n,r,i){N(e,de,j.BOLD),e.text(`${t.seedValue}`,n+4,r,{align:`right`}),N(e,de,j.NORMAL),e.text(t.participantName,n+6,r),e.setTextColor(100),e.text(t.nationality,n+45,r),e.setTextColor(0)}function he(e){return e===0?0:4+Math.ceil(e/2)*fe}function ge(e,t){return e.type?e.composition?{success:!0,filename:_e(e)}:{success:!1,error:`Missing composition config`}:{success:!1,error:`Missing request type`}}function _e(e){let t=new Date().toISOString().slice(0,10);switch(e.type){case`draw`:return`draw-${t}.pdf`;case`schedule`:return`order-of-play-${e.scheduledDate||t}.pdf`;case`playerList`:return`player-list-${t}.pdf`;case`courtCards`:return`court-cards-${t}.pdf`;case`signInSheet`:return`sign-in-sheet-${t}.pdf`;case`matchCard`:return`match-cards-${t}.pdf`}}var ve=[{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`}],ye=[{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`}],be=[{value:`a4`,label:`A4 (210 × 297mm)`},{value:`letter`,label:`US Letter (216 × 279mm)`}],xe=[{value:`auto`,label:`Auto (landscape for large draws)`},{value:`landscape`,label:`Landscape`},{value:`portrait`,label:`Portrait`}],Se=[{value:`single-page`,label:`Single Page (dense)`},{value:`halves`,label:`Two Halves (64+64)`},{value:`quarters`,label:`Four Quarters (32×4)`}],Ce=[{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`}]}],we=[{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 L(e){if(!e)return``;if(e.person){let{standardFamilyName:t,standardGivenName:n}=e.person;if(t)return`${t.toUpperCase()}, ${n||``}`.trim()}return e.participantName||``}function R(e){return e&&e.person?.nationalityCode||``}function Te(e){return e?`[${e}]`:``}function Ee(e){return e?{DIRECT_ACCEPTANCE:`DA`,WILDCARD:`WC`,LUCKY_LOSER:`LL`,QUALIFIER:`Q`,ALTERNATE:`A`,SPECIAL_EXEMPT:`SE`}[e]||e:``}function De(e){return e?typeof e==`string`?e:e.scoreStringSide1?e.scoreStringSide1:``:``}function Oe(e){return e?new Date(e+`T00:00:00`).toLocaleDateString(`en-US`,{day:`2-digit`,month:`short`,year:`numeric`}):``}function z(e){if(!e)return``;let[t,n]=e.split(`:`),r=parseInt(t),i=r>=12?`PM`:`AM`,a=r;return r===0?a=12:r>12&&(a=r-12),`${a}:${n} ${i}`}function ke(e){return e?e.split(/\s+/).map(e=>e[0]).join(``).toUpperCase():``}function Ae(e,t){let n=t-e+1;return n===1?`F`:n===2?`SF`:n===3?`QF`:`R${2**n}`}function je(e){let{drawDefinition:t,participants:n=[]}=e;if(!t)return Ne();let r=e.structureId?t.structures?.find(t=>t.structureId===e.structureId):t.structures?.[0];if(!r)return Ne();let i=new Map;n.forEach(e=>i.set(e.participantId,e));let a=r.positionAssignments||[],o=(r.matchUps||[]).reduce((e,t)=>Math.max(e,t.roundNumber||0),0),s=e.structureId?a.length:t.drawSize||a.length,c=e.structureId?o:Math.log2(s),l=r.seedAssignments||[],u=a.map(e=>{let t=e.participantId?i.get(e.participantId):void 0,n=l.find(t=>t.participantId===e.participantId);return{drawPosition:e.drawPosition,participantName:t?L(t):``,nationality:t?R(t):``,seedValue:n?.seedValue,entryStatus:e.entryStatus,isBye:e.bye===!0}}),d=(r.matchUps||[]).map(e=>({roundNumber:e.roundNumber,roundPosition:e.roundPosition,drawPositions:e.drawPositions||[],score:De(e.score),winningSide:e.winningSide,matchUpStatus:e.matchUpStatus})),f=l.filter(e=>e.participantId).map(e=>{let t=i.get(e.participantId);return{seedValue:e.seedValue,participantName:t?L(t):``,nationality:t?R(t):``}}).sort((e,t)=>e.seedValue-t.seedValue),p=Me(d,c,e.processedMatchUps);return{drawName:t.drawName||``,drawSize:s,drawType:t.drawType||`SINGLE_ELIMINATION`,totalRounds:c,slots:u,matchUps:d,seedAssignments:f,roundLabelMap:p}}function B(e,t){return Ae(e,t)}function Me(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]=Ae(n,t);return e}let a={};for(let e of i)a[e]=`R${e}`;return a}function Ne(){return{drawName:``,drawSize:0,drawType:``,totalRounds:0,slots:[],matchUps:[],seedAssignments:[]}}function Pe(e){let{matchUps:t=[],venues:n=[],scheduledDate:r=``}=e,i=new Set;n.forEach(e=>{(e.courts||[]).forEach(e=>{i.add(e.courtName||`Court ${e.courtId}`)})});let a=new Map;n.forEach(e=>{(e.courts||[]).forEach(e=>{a.set(e.courtId,e.courtName||`Court ${e.courtId}`)})});let o=t.filter(e=>e.schedule?.scheduledDate===r||!r),s=new Map;for(let e of o){let t=e.schedule||{},n=t.scheduledTime||`00:00`,r=t.venueCourtId||t.courtId||``,o=a.get(r)||r;o&&i.add(o);let c=e.sides||[],l=Fe(c[0]),u=Fe(c[1]),d={courtName:o,scheduledTime:z(n),eventName:e.eventName||e.event?.eventName||``,eventAbbr:ke(e.eventName||e.event?.eventName||``),roundName:e.roundName||``,side1:l,side2:u,score:De(e.score),matchUpStatus:e.matchUpStatus,notBeforeTime:t.notBeforeTime?z(t.notBeforeTime):void 0},f=t.notBeforeTime||n;s.has(f)||s.set(f,[]),s.get(f).push(d)}let c=[...s.keys()].sort().map(e=>({time:e,label:z(e)||`TBD`,matches:s.get(e)||[]}));return{scheduledDate:r,courts:[...i].sort(),timeSlots:c}}function Fe(e){if(!e)return{name:``,nationality:``};let t=e.participant;return t?{name:L(t),nationality:R(t)}:{name:``,nationality:``}}function Ie(e){let{participants:t=[],eventEntries:n=[]}=e,r=new Map;for(let{eventName:e,entries:t}of n)for(let n of t){let t=n.participantId;r.has(t)||r.set(t,{events:[],entryStatus:``,seedValue:void 0});let i=r.get(t);i.events.push(e),n.entryStatus&&(i.entryStatus=n.entryStatus)}return t.filter(e=>e.participantType===`INDIVIDUAL`).map(e=>{let t=r.get(e.participantId);return{name:L(e),nationality:R(e),ranking:e.rankings?.[0]?.ranking?.toString()||``,seedValue:t?.seedValue,entryStatus:Ee(t?.entryStatus||``),events:t?.events||[],signedIn:e.signInStatus===`SIGNED_IN`}}).sort((e,t)=>e.name.localeCompare(t.name))}function Le(e){let{matchUps:t=[],venues:n=[]}=e,r=new Map;n.forEach(e=>{(e.courts||[]).forEach(t=>{r.set(t.courtId,{courtName:t.courtName||`Court ${t.courtId}`,venueName:e.venueName||``})})});let i=new Map;for(let e of t){let t=e.schedule?.venueCourtId||e.schedule?.courtId;t&&(i.has(t)||i.set(t,[]),i.get(t).push(e))}let a=[];for(let[e,t]of i){let n=r.get(e)||{courtName:e,venueName:``};t.sort((e,t)=>{let n=e.schedule?.scheduledTime||``,r=t.schedule?.scheduledTime||``;return n.localeCompare(r)});let i=new Set([`COMPLETED`,`RETIRED`,`WALKOVER`,`DEFAULTED`,`ABANDONED`]),o=t.find(e=>e.matchUpStatus===`IN_PROGRESS`),s=t.filter(e=>!i.has(e.matchUpStatus)),c=t.filter(e=>i.has(e.matchUpStatus)),l=o||s[0]||c.at(-1),u;o?u=s[0]:s.length>1&&(u=s[1]),a.push({courtName:n.courtName,venueName:n.venueName,currentMatch:l?Re(l):void 0,nextMatch:u?Re(u):void 0})}return a.sort((e,t)=>e.courtName.localeCompare(t.courtName))}function Re(e){let t=e.sides||[];return{eventName:e.eventName||e.event?.eventName||``,roundName:e.roundName||``,scheduledTime:e.schedule?.scheduledTime?z(e.schedule.scheduledTime):void 0,side1:ze(t[0]),side2:ze(t[1])}}function ze(e){return e?.participant?{name:L(e.participant),nationality:R(e.participant)}:{name:`TBD`,nationality:``}}function Be(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?L(t):``,nationality:t?R(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=De(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}}):[]}function Ve(e,t){if(e.isBye)return`Bye`;if(!e.participantName)return``;let n=He(e.participantName,t),r=Ue(e.nationality,t),i=e.seedValue?We(e.seedValue,t):``,a=e.entryStatus?Ke(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 V(e,t){if(e.isBye)return{name:`Bye`,nationality:``};if(!e.participantName)return{name:``,nationality:``};let n=He(e.participantName,t),r=e.seedValue?We(e.seedValue,t):``,i=e.entryStatus?Ke(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 He(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 Ue(e,t){if(!e)return``;switch(t.nationalityFormat){case`parens`:return`(${e})`;case`hyphen`:return`-${e}`;default:return e}}function We(e,t){return t.seedFormat===`parens`?`(${e})`:`[${e}]`}var Ge={DIRECT_ACCEPTANCE:``,WILDCARD:`WC`,QUALIFIER:`Q`,LUCKY_LOSER:`LL`,SPECIAL_EXEMPT:`SE`,ALTERNATE:`ALT`,PROTECTED_RANKING:`PR`,JUNIOR_EXEMPT:`JE`,ORGANISER_ACCEPTANCE:`OA`};function Ke(e,t){if(!e)return``;let n=Ge[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 H(e,t){return e?t.gameScoreSeparator===`/`?e.replace(/(\d)-(\d)/g,`$1/$2`):e:``}function qe(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,_=M.SMALL;return i<2.5?_=5:i<3.5&&(_=M.TINY),{lineHeight:i,roundColumnWidth:h,firstRoundWidth:d,secondRoundWidth:g,connectorGap:o,fontSize:_,scoreFontSize:a?5:M.TINY}}function U(e,t,n,r,i=0,a){Je(t.matchUps)?Ye(e,t,n,r):st(e,t,n,r,i,a)}function Je(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 Ye(e,t,n,r){let i=n.page.margins,a=r.contentY+9,o=r.contentHeight-9,s=Xe(t.matchUps),c=[...s.keys()].sort((e,t)=>e-t),l=c.length,u=new Map(t.slots.map(e=>[e.drawPosition,e])),d=Ze(c,s),{feedConfig:f,connectorGap:p,firstRoundWidth:m,roundColumnWidth:h,fontSize:g,scoreFontSize:_}=Qe(o,s,c,l,r),v=e=>e===0?i.left:i.left+m+p+(e-1)*(h+p);ot(e,c,t,f,n,r,v,l,h);let y=$e(c,l,s,d,a,o,f.lineHeight);et(e,c,l,s,y,d,u,f,n,v,m,h,p,_),at(e,t,c,l,s,y,u,v,a,o,h,g,_,n)}function Xe(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 Ze(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 Qe(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=M.SMALL;o<2.5?d=5:o<3.5&&(d=M.TINY);let f=s?5:M.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 $e(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 et(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?tt(e,a,h,o,c,s,v,u,x,f,S):b?nt(e,a,h,o,r,t,m,c,s,v,d,x,f,S):rt(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=H(a.score,c);N(e,p,j.NORMAL),e.setTextColor(60,60,160);let n=h.midY+p*.12;e.text(t,x-1,n,{align:`right`}),e.setTextColor(0)}}}}}function tt(e,t,n,r,i,a,o,s,c,l,u){t.drawPositions[0]&&K(e,r.get(t.drawPositions[0]),t.drawPositions[0],i,a,o,n.topY,s),t.drawPositions[1]&&K(e,r.get(t.drawPositions[1]),t.drawPositions[1],i,a,o,n.bottomY,s),it(e,n,c,l,u)}function nt(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&&g.add(e.drawPositions[e.winningSide-1]);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?K(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&&q(e,t,s,c,l,n.bottomY)}it(e,n,d,f,p)}function rt(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&&q(e,s,i,a,o,n.topY)}if(t.drawPositions[1]){let s=r.get(t.drawPositions[1]);s?.participantName&&q(e,s,i,a,o,n.bottomY)}it(e,n,c,l,u)}function it(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 at(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=_.drawPositions[_.winningSide-1],n=o.get(t);if(n){N(e,d+1,j.BOLD);let{name:t}=V(n,p);if(e.text(t,m+1,g-.5),_.score){let t=H(_.score,p);N(e,f,j.NORMAL),e.setTextColor(60,60,160),e.text(t,m+1,g+f*.4),e.setTextColor(0)}}}}function ot(e,t,n,r,i,a,o,s,c){N(e,r.fontSize<=M.TINY?5.5:M.SMALL,j.BOLD),e.setTextColor(40);for(let l=0;l<s;l++){let s=t[l],u=B(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 st(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=qe(o,r,l),d=n.page.margins.left,f=r.contentY+9;dt(e,l,t.totalRounds,u,n,d,r.contentY+2,t.roundLabelMap,t.noWinnerColumn);for(let r=0;r<l;r++)ct(e,t,n,u,o,r,l,d,f,i);t.noWinnerColumn||ut(e,t,n,u,l,d,f)}function ct(e,t,n,r,i,a,o,s,c,l){let u=i/2**(a+1),d=r.lineHeight*2**a,f=G(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;K(e,J(t.slots,a),a,n,r,f,u),K(e,J(t.slots,o),o,n,r,f,h)}else{let t=W(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+W(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=G(a+1,r,s);e.line(v+r.connectorGap,g,t,g)}let y=pt(t.matchUps,a+1,i+1);if(_&&t.noWinnerColumn){let i=mt(y,t.slots);i&&(e.setDrawColor(40),e.setLineWidth(.25),e.line(v+r.connectorGap,g,v+r.connectorGap+r.roundColumnWidth,g),q(e,i,n,r,v+r.connectorGap,g),y?.score&<(e,y,n,r,d,v+r.connectorGap,a,g))}else if(!_){let i=mt(y,t.slots);if(i){let t=G(a+1,r,s);q(e,i,n,r,t,g),y?.score&<(e,y,n,r,d,t,a,g)}}}}function lt(e,t,n,r,i,a,o,s){let c=H(t.score,n);if(N(e,r.scoreFontSize,j.NORMAL),e.setTextColor(60,60,160),i*2<r.scoreFontSize*1.2){let t=a+W(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 ut(e,t,n,r,i,a,o){let s=G(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=pt(t.matchUps,i,1);if(d?.winningSide){let i=d.drawPositions[d.winningSide-1],a=J(t.slots,i);if(a){N(e,r.fontSize+1,j.BOLD);let{name:t}=V(a,n);if(e.text(t,s+1,u-.5),d.score){let t=H(d.score,n);N(e,r.scoreFontSize,j.NORMAL),e.setTextColor(60,60,160),e.text(t,s+1,u+r.scoreFontSize*.4),e.setTextColor(0)}}}}function dt(e,t,n,r,i,a,o,s,c){N(e,r.fontSize<=M.TINY?5.5:M.SMALL,j.BOLD),e.setTextColor(40);for(let c=0;c<t;c++){let l=n-t+c+1,u=B(l,n),d=s?.[l]||i.roundLabels[u]||u,f=G(c,r,a),p=W(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=G(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 W(e,t){return e===0?t.firstRoundWidth:e===1?t.secondRoundWidth:t.roundColumnWidth}function G(e,t,n){if(e===0)return n;let r=n+t.firstRoundWidth+t.connectorGap;for(let n=1;n<e;n++)r+=W(n,t)+t.connectorGap;return r}function K(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;N(e,i.scoreFontSize,j.NORMAL),e.setTextColor(120),e.text(`${n}`,a,o-d,{align:`left`}),e.setTextColor(0),t?.nationality&&(N(e,i.scoreFontSize,j.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}=V(t,r);if(!m)return;N(e,i.fontSize,t.isBye?j.ITALIC:j.NORMAL),t.isBye&&e.setTextColor(150);let h=p-f-2,g=m;e.getTextWidth(m)>h&&(g=ft(t.participantName));let _=i.lineHeight<2?.2:.5;e.text(g,f+1,o-_),t.isBye&&e.setTextColor(0)}function q(e,t,n,r,i,a){let o=ft(t.participantName),s=``;t.seedValue&&(s=n.seedFormat===`parens`?`(${t.seedValue})`:`[${t.seedValue}]`);let c=s?`${o} ${s}`:o;N(e,r.fontSize,j.BOLD),e.text(c,i+1,a-.5)}function ft(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 J(e,t){return e.find(e=>e.drawPosition===t)}function pt(e,t,n){return e.find(e=>e.roundNumber===t&&e.roundPosition===n)}function mt(e,t){if(e){if(e.winningSide){let n=e.drawPositions[e.winningSide-1];return J(t,n)}if(e.matchUpStatus===`BYE`)for(let n of e.drawPositions){let e=J(t,n);if(e&&!e.isBye&&e.participantName)return e}}}var ht=[200,200,200],gt=[20,80,20],_t=[160,40,40],vt=[50,50,50];function yt(e,t,r,i,a){let o=r.page.margins,s=t.participants.length;N(e,M.HEADING,j.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=bt(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:ht}});else{let r=l[t]?.[e];if(r){let e=r.isWin?gt:_t;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:vt,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 bt(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=H(n.score,t),s=n.winningSide===1;r[e][a]={score:o,isWin:s},r[a][e]={score:xt(o),isWin:!s}}return r}function xt(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 Y=1,St=16,Ct=1;function wt(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(St,(u-(f+1)*Ct)/f);N(e,M.SMALL,j.BOLD),e.setTextColor(30,60,120);for(let a=0;a<c;a++){let o=s[a],c=n.roundLabels[B(o,t.totalRounds)]||B(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);Tt(e,c[t],o,n,m,r,d,p)}}}function Tt(e,t,n,r,i,a,o,s){let c=s<10?5:M.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=Ve(u,r);N(e,c,t.winningSide===1?j.BOLD:j.NORMAL),e.text(n,i+Y,l-c*.15,{maxWidth:o-2*Y})}let d=t.drawPositions[1]?n.get(t.drawPositions[1]):void 0;if(d){let n=Ve(d,r);N(e,c,t.winningSide===2?j.BOLD:j.NORMAL),e.text(n,i+Y,l+c*.55,{maxWidth:o-2*Y})}if(t.score){let n=H(t.score,r);N(e,c,j.NORMAL),e.setTextColor(60,60,160),e.text(n,i+o-Y,a+c*.5,{align:`right`}),e.setTextColor(0)}}var Et={maxPositionsPerPage:64,includeOverlapRounds:!0,summaryPage:!0};function Dt(e,t=Et){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(Ot(e,o,s,c,n,r,i));return t.summaryPage&&s>1&&l.push(kt(e)),l}function Ot(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=At(o.filter(e=>e.roundNumber>r?!1:e.drawPositions.every(e=>e>=s&&e<=c)));return{label:l,startPosition:s,endPosition:c,slots:u,matchUps:d,segmentRounds:r,noWinnerColumn:!0}}function kt(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=jt(c),d=At(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=>u.get(e)||e)}))),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 At(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 jt(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}var Mt=[`E`,`W`,`N`,`S`,`NE`,`NW`,`SE`,`SW`];function Nt(e,t,n,r){let i=n.page.margins,a=[...t.structures].sort((e,t)=>Mt.indexOf(e.abbreviation)-Mt.indexOf(t.abbreviation)),o=r.contentY+3;for(let s of a){if(s.drawSize===0)continue;let a=Pt(s,r);o+a>r.contentY+r.contentHeight&&(e.addPage(),o=r.contentY);let c=s.abbreviation===`E`;N(e,c?M.HEADING:M.BODY,j.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};U(e,Ft(s,t.drawName),n,u),o+=a+3}}function Pt(e,t){let n=t.contentHeight*.7,r=Math.max(5,Math.min(8,n/e.drawSize));return e.drawSize*r+10}function Ft(e,t){return{drawName:`${t} - ${e.name}`,drawSize:e.drawSize,drawType:`SINGLE_ELIMINATION`,totalRounds:e.totalRounds,slots:e.slots,matchUps:e.matchUps,seedAssignments:[]}}function It(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?L(t):``,nationality:t?R(t):``,seedValue:n?.seedValue,isBye:e.bye===!0}}),s=(t.matchUps||[]).map(e=>({roundNumber:e.roundNumber,roundPosition:e.roundPosition,drawPositions:e.drawPositions||[],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?L(t):``,nationality:t?R(t):``}}),roundLabelMap:p}}})}function Lt(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,N(e,o?M.HEADING:M.BODY,j.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)};U(e,t.drawData,n,c),a+=s+4}}function Rt(e,t,n,r){let i=n.page.margins,a=r.contentHeight,o=a*.44,s=a*.44,c=r.contentWidth-30-8,l=zt(t.winnersBracket),u=r.contentY+3;N(e,M.BODY,j.BOLD),e.setTextColor(30,80,30),e.text(`Winner's Bracket`,i.left,u),e.setTextColor(0),u+=3,U(e,l,n,{...r,contentY:u,contentHeight:o-6,contentWidth:c}),u=r.contentY+o+6,N(e,M.BODY,j.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};U(e,t.losersBracket,n,d);let f=i.left+c+8,p=r.contentY+a/2;if(N(e,M.SMALL,j.BOLD),e.text(`Decider`,f+28/2,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-14/2-1,f+28,p-14/2-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;N(e,M.TINY,r?j.BOLD:j.NORMAL),e.text(t.participantName,f+1,p-14/2-3,{maxWidth:26})}}if(n.drawPositions[1]){let t=r.get(n.drawPositions[1]);if(t?.participantName){let r=n.winningSide===2;N(e,M.TINY,r?j.BOLD:j.NORMAL),e.text(t.participantName,f+1,p-3,{maxWidth:26})}}n.score&&(N(e,M.TINY,j.NORMAL),e.setTextColor(60,60,160),e.text(n.score,f+28-1,p-14+2,{align:`right`}),e.setTextColor(0))}}function zt(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 Bt={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 Vt(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=Bt[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?L(t):``,nationality:t?R(t):``,seedValue:n?.seedValue,isBye:e.bye===!0}}),l=(e.matchUps||[]).map(e=>({roundNumber:e.roundNumber,roundPosition:e.roundPosition,drawPositions:e.drawPositions||[],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}}function X(e,t,n=15){let r=e.internal.pageSize.getWidth(),i=n;N(e,M.TITLE,j.BOLD),e.text(t.tournamentName,15,i),i+=7,t.subtitle&&(N(e,M.SUBTITLE,j.BOLD),e.text(t.subtitle,15,i),i+=6),N(e,M.BODY,j.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 Ht(e,t,n){let r=e.internal.pageSize.getWidth(),i=e.internal.pageSize.getHeight();N(e,M.SMALL,j.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 Z={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]}},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}}},Ut={slotWidth:90,slotHeight:14,roundGap:20,verticalGap:4,startX:15,startY:10};function Wt(e,t=Ut,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 Gt(e,t){if(e.setDrawColor(150),e.setLineWidth(.3),e.rect(t.x,t.y,t.width,t.height),t.isBye){N(e,M.SMALL,j.ITALIC),e.setTextColor(150),e.text(`Bye`,t.x+2,t.y+t.height/2+1.5),e.setTextColor(0);return}t.participantName&&(t.seed?(N(e,M.TINY,j.BOLD),e.text(`[${t.seed}]`,t.x+1,t.y+t.height/2+1),N(e,M.SMALL,j.NORMAL),e.text(t.participantName,t.x+9,t.y+t.height/2+1)):(N(e,M.SMALL,j.NORMAL),e.text(t.participantName,t.x+2,t.y+t.height/2+1)),t.nationality&&(N(e,M.TINY,j.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 Kt(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 qt(e,t,n,r){N(e,M.TINY,j.NORMAL),e.setTextColor(60,60,180),e.text(t,n,r),e.setTextColor(0)}function Jt(e,n={}){let{header:r,includeSeedings:i=!0,includeScores:a=!0}=n,o=new t.default({orientation:e.drawSize>=32?`landscape`:`portrait`,format:`a4`}),s=15;if(r){let t=`${e.drawName} - ${e.drawType.replace(/_/g,` `)} (${e.drawSize})`;s=X(o,{...r,subtitle:t})}return s=e.drawSize<=64&&e.drawSize>0?Yt(o,e,s,a):Xt(o,e,s),i&&e.seedAssignments.length>0&&Zt(o,e,s+8),Ht(o,`Generated ${new Date().toLocaleDateString()}`),o}function Yt(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={...Ut,slotWidth:l,slotHeight:u,verticalGap:Math.max(1,u*.3),startX:15,startY:n},f=Wt(t.drawSize,d,s),p=new Map(t.slots.map(e=>[e.drawPosition,e]));N(e,M.SMALL,j.BOLD);for(let t=0;t<c;t++){let r=d.startX+t*(d.slotWidth+d.roundGap),i=B(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)Gt(e,n);if(Kt(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&&qt(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 Xt(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,{...Z.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 Zt(e,t,r){N(e,M.HEADING,j.BOLD),e.text(`Seeded Players`,15,r),r+=4;let i=[{header:`Seed`,dataKey:`seed`},{header:`Player`,dataKey:`name`},{header:`Nat.`,dataKey:`nat`}],a=t.seedAssignments.map(e=>({seed:e.seedValue,name:e.participantName,nat:e.nationality}));return(0,n.default)(e,{...Z.compact,startY:r,columns:i,body:a,tableWidth:120,columnStyles:{seed:{cellWidth:15,halign:`center`,fontStyle:`bold`},name:{cellWidth:`auto`},nat:{cellWidth:20,halign:`center`}}}),e.lastAutoTable?.finalY||r+20}function Qt(e,r={}){let{header:i,fullCourtNames:a=!0,notes:o}=r,s=new t.default({orientation:(r.landscape===`auto`?e.courts.length>=5:r.landscape)?`landscape`:`portrait`,format:`a4`}),c=15;if(i){let t=e.scheduledDate?`Order of Play - ${e.scheduledDate}`:`Order of Play`;c=X(s,{...i,subtitle:t})}let l=e.courts,u=a?l:l.map(en);for(let t of e.timeSlots){N(s,M.BODY,j.BOLD),s.setTextColor(30,60,120),s.text(t.label,15,c),s.setTextColor(0),c+=4;let e=u.map(e=>({header:e,dataKey:e})),r=new Map;l.forEach(e=>r.set(e,[]));for(let e of t.matches){let t=$t(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)),d=[];for(let e=0;e<o;e++){let t={};l.forEach((n,i)=>{let o=r.get(n)||[],s=a?n:u[i];t[s]=o[e]||``}),d.push(t)}(0,n.default)(s,{...Z.schedule,startY:c,columns:e,body:d,tableWidth:`auto`,didDrawPage:e=>{Ht(s,i?.tournamentName||``,e.pageNumber)}}),c=s.lastAutoTable?.finalY+6||c+20}if(o?.length){c+=4,N(s,M.SMALL,j.ITALIC),s.setTextColor(80);for(let e of o)s.text(e,15,c),c+=4;s.setTextColor(0)}return s}function $t(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(`
|
|
2
|
+
`)}function en(e){return e.replace(/^Court\s*/i,`Ct `)}function tn(e,r={}){let{header:i,includeRanking:a=!0,includeEvents:o=!0}=r,s=new t.default({orientation:`portrait`,format:`a4`}),c=15;i&&(c=X(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,{...Z.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=>{Ht(s,`Generated ${new Date().toLocaleDateString()}`,e.pageNumber)}}),s}function nn(e,n={}){let{tournamentName:r=``,pageSize:i=`a5`,cardsPerPage:a=1}=n,o=new t.default({orientation:`landscape`,format:i});return e.forEach((e,t)=>{t>0&&o.addPage(),rn(o,e,r,a)}),o}function rn(e,t,r,i){let a=e.internal.pageSize.getWidth(),o=a/2,s=15;if(r&&(N(e,M.BODY,j.NORMAL),e.setTextColor(100),e.text(r,o,s,{align:`center`}),e.setTextColor(0),s+=8),N(e,28,j.BOLD),e.text(t.courtName,o,s,{align:`center`}),s+=5,t.venueName&&(N(e,M.HEADING,j.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&&(N(e,M.HEADING,j.BOLD),e.setTextColor(30,60,120),e.text(`NOW PLAYING`,o,s,{align:`center`}),e.setTextColor(0),s+=6,N(e,M.BODY,j.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,N(e,M.BODY,j.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,N(e,M.BODY,j.NORMAL),e.text(`${t.nextMatch.eventName} - ${t.nextMatch.roundName}`,o,s,{align:`center`}),s+=5,N(e,M.HEADING,j.NORMAL),e.text(`${t.nextMatch.side1.name} vs. ${t.nextMatch.side2.name}`,o,s,{align:`center`})}}function an(e,r={}){let{header:i,eventName:a,signInDate:o,signInTime:s}=r,c=new t.default({orientation:`portrait`,format:`a4`}),l=15;if(i&&(l=X(c,{...i,subtitle:i.subtitle||`Player Sign-In Sheet`})),a||o){N(c,M.BODY,j.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 on(e,t={}){let n=e.courts.length>=4,r={pageSize:t.page?.pageSize||`a4`,orientation:t.page?.orientation||(n?`landscape`:`portrait`),margins:t.page?.margins||{top:12,right:8,bottom:10,left:8}},i=D(r),a=t.footer||{layout:`standard`,showTimestamp:!0,showPageNumbers:!0},o=I(a)+(t.notes?.length?t.notes.length*3:0),s=r.margins.top;if(t.header){let e=P(i,t.header,r);s=r.margins.top+e}t.alertBanner&&(s=sn(i,t.alertBanner,r,s)),cn(i,e,r,s,t);let c=i.internal.pageSize.getHeight();if(t.notes?.length){let e=c-r.margins.bottom-o+2;N(i,M.TINY,j.ITALIC),i.setTextColor(80);for(let n of t.notes)i.text(n,r.margins.left,e),e+=3;i.setTextColor(0)}if(t.officials?.length){let e=c-r.margins.bottom-6;fn(i,t.officials,r,e)}return ie(i,a,r,1),i}function sn(e,t,n,r){let{margins:i}=n,a=e.internal.pageSize.getWidth(),o=a-i.left-i.right;return e.setFillColor(200,30,30),e.rect(i.left,r,o,7,`F`),N(e,M.SMALL,j.BOLD),e.setTextColor(255,255,255),e.text(t,a/2,r+4.5,{align:`center`}),e.setTextColor(0),r+9}function cn(e,t,r,i,a){let{margins:o}=r,s=t.courts,c=a.cellStyle===`compact`,l=[{header:``,dataKey:`slot`}];for(let e of s)l.push({header:e,dataKey:e});let u=[];t.timeSlots.forEach((e,t)=>{let n=[],r=ln(e,t);n.push({content:r,styles:{fontStyle:`bold`,valign:`top`,cellWidth:12}});for(let t of s){let r=e.matches.filter(e=>e.courtName===t),i=r.length>0?r.map(e=>un(e,c)).join(`
|
|
3
3
|
---
|
|
4
|
-
`):``;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
|
|
5
|
-
`)}function Gt(e,t){return e.name?t||e.nationality?`${e.name} (${e.nationality})`:e.name:`TBD`}function Kt(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),A(e,k.TINY,O.NORMAL);let o=(a-i.left-i.right)/t.length;t.forEach((t,n)=>{let a=i.left+n*o;A(e,k.TINY,O.ITALIC),e.setTextColor(100),e.text(t.role,a,r),A(e,k.TINY,O.BOLD),e.setTextColor(0),e.text(t.name,a,r+3)})}var qt=[120,50,140];function Jt(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=T(n),{margins:i}=n,a=r.internal.pageSize.getWidth(),o=r.internal.pageSize.getHeight(),s=a-i.left-i.right,c=t.accentColor||qt,l=t.footer||{layout:`none`},u=I(l),d=i.top;t.header&&(d=i.top+j(r,t.header,n)+3);let f=$t(e);for(let[e,a]of f){d+30>o-i.bottom-u&&(en(r,t,n,l),r.addPage(),d=i.top),d=Yt(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&&(en(r,t,n,l),r.addPage(),d=i.top),d=Xt(r,a,!!e.notBeforeTime,i.left,d,s,c),f=a),d+22>o-i.bottom-u&&(en(r,t,n,l),r.addPage(),d=i.top),d=Zt(r,e,i.left,d,s)}d+=4}return t.disclaimer&&(d+=2,A(r,k.TINY,O.ITALIC),r.setTextColor(100),r.text(t.disclaimer,a/2,d,{align:`center`}),r.setTextColor(0)),en(r,t,n,l),r}function Yt(e,t,n,r,i){return A(e,k.HEADING,O.BOLD),e.setTextColor(40),e.text(t.toUpperCase(),n+i/2,r,{align:`center`}),e.setTextColor(0),r+7}function Xt(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`),A(e,k.SMALL,O.ITALIC),e.setTextColor(255,255,255),e.text(s,r+a/2,i+3.5,{align:`center`}),e.setTextColor(0),i+7}function Zt(e,t,n,r,i){let a=n+15,o=i-30,s=r;A(e,k.TINY,O.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&&(A(e,k.SMALL,O.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=Qt(e,t.side1,a,r,o),A(e,k.TINY,O.ITALIC),e.setTextColor(120),e.text(`vs`,a+o/2,r+2.5,{align:`center`}),e.setTextColor(0),r+=4,r=Qt(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 Qt(e,t,n,r,i){if(!t.name||t.name===`TBD`)return A(e,k.BODY,O.ITALIC),e.setTextColor(150),e.text(`TBD`,n+10,r+3),e.setTextColor(0),r+4;A(e,k.BODY,O.NORMAL);let a=t.nationality?`${t.name} ${t.nationality}`:t.name;return e.text(a,n+10,r+3),r+4}function $t(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 en(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;A(e,k.TINY,O.BOLD),e.text(t.role,o,n),A(e,k.TINY,O.NORMAL),e.text(t.name,o,n+3)})}ne(e,r,n)}function tn(e,n={}){let{cardsPerPage:r=2,includeScoreBoxes:i=!0}=n,a=new t.default({orientation:`landscape`,format:`a5`});return e.forEach((e,t)=>{t>0&&(r===1||t%r===0)&&a.addPage(),nn(a,e,r===2&&t%2==1?a.internal.pageSize.getHeight()/2:5,i)}),a}function nn(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=i/2,o=n;if(t.tournamentName&&(A(e,k.BODY,O.NORMAL),e.setTextColor(100),e.text(t.tournamentName,a,o,{align:`center`}),e.setTextColor(0),o+=5),A(e,k.HEADING,O.BOLD),e.text(`${t.eventName} - ${t.roundName}`,a,o,{align:`center`}),o+=5,t.courtName||t.scheduledTime){A(e,k.BODY,O.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,rn(e,t.side1,10,o,i),o+=8,A(e,k.BODY,O.ITALIC),e.setTextColor(120),e.text(`vs.`,a,o,{align:`center`}),e.setTextColor(0),o+=6,rn(e,t.side2,10,o,i),o+=8,r){e.setDrawColor(0),e.setLineWidth(.5),e.line(10,o,i-10,o),o+=4,A(e,k.SMALL,O.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),A(e,k.TINY,O.NORMAL),e.setTextColor(150),e.text(`Set ${t+1}`,n+12/2,o-5,{align:`center`}),e.setTextColor(0)}o+=14,A(e,k.SMALL,O.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 rn(e,t,n,r,i){A(e,14,O.BOLD);let a=t.seedValue?`[${t.seedValue}] `:``;e.text(`${a}${t.name}`,n,r),A(e,k.HEADING,O.NORMAL),e.setTextColor(80),e.text(t.nationality,i-n,r,{align:`right`}),e.setTextColor(0)}function an(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=k.SMALL;p<2.5?b=5:m&&(b=k.TINY);let x=m?5:k.TINY,S={lineHeight:p,roundColumnWidth:y,firstRoundWidth:g,connectorGap:h,fontSize:b,scoreFontSize:x},C=t.slots.filter(e=>e.drawPosition<=s),w=t.slots.filter(e=>e.drawPosition>s),T=t.matchUps.filter(e=>e.drawPositions.every(e=>e<=s)),E=t.matchUps.filter(e=>e.drawPositions.every(e=>e>s)),ee=w.map(e=>({...e,drawPosition:e.drawPosition-s})),D=new Map;for(let e of E)D.has(e.roundNumber)||D.set(e.roundNumber,[]),D.get(e.roundNumber).push(e);let j=[];for(let[,e]of D)e.sort((e,t)=>e.roundPosition-t.roundPosition),e.forEach((e,t)=>{j.push({...e,drawPositions:e.drawPositions.map(e=>e-s),roundPosition:t+1})});let M=new Map;for(let e of T)M.has(e.roundNumber)||M.set(e.roundNumber,[]),M.get(e.roundNumber).push(e);let N=[];for(let[,e]of M)e.sort((e,t)=>e.roundPosition-t.roundPosition),e.forEach((e,t)=>{N.push({...e,roundPosition:t+1})});cn(e,c,t.totalRounds,S,n,i.left,i.left+l,r.contentY+2,t.roundLabelMap),A(e,m?5.5:k.SMALL,O.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),on(e,C,N,c,S,n,i.left,a,t.totalRounds),sn(e,ee,j,c,S,n,i.left+l,a,t.totalRounds);let P=t.matchUps.find(e=>e.roundNumber===t.totalRounds);if(P){let r=a+o/2;if(e.setDrawColor(40),e.setLineWidth(.25),e.line(f+2,r,f+u-2,r),P.winningSide){let i=P.drawPositions[P.winningSide-1],a=t.slots.find(e=>e.drawPosition===i);if(a){let{name:t}=H(a,n);A(e,b+1,O.BOLD),e.text(t,f+u/2,r-1,{align:`center`})}}P.score&&(A(e,x,O.NORMAL),e.setTextColor(60,60,160),e.text(U(P.score,n),f+u/2,r+x*.4,{align:`center`}),e.setTextColor(0))}}function on(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=ln(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=ln(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=pn(n,t+1,u+1);if(t<r-1&&b?.winningSide){let t=b.drawPositions[b.winningSide-1],n=l.get(t);if(n){A(e,i.fontSize,O.BOLD);let t=n.participantName;e.getTextWidth(t)>i.roundColumnWidth-2&&(t=fn(t)),e.text(t,y+1,_-.5)}}b?.score&&t<r-1&&(A(e,i.scoreFontSize,O.NORMAL),e.setTextColor(60,60,160),e.text(U(b.score,a),y+1,_-.5+i.scoreFontSize*.4),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=un(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=un(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=pn(n,t+1,u+1);if(t<r-1&&b?.winningSide){let t=b.drawPositions[b.winningSide-1],n=l.get(t);if(n){A(e,i.fontSize,O.BOLD);let t=n.participantName;e.getTextWidth(t)>i.roundColumnWidth-2&&(t=fn(t));let r=y;e.text(t,r+i.roundColumnWidth-1,_-.5,{align:`right`})}}if(b?.score&&t<r-1){let t=y;A(e,i.scoreFontSize,O.NORMAL),e.setTextColor(60,60,160),e.text(U(b.score,a),t+i.roundColumnWidth-1,_-.5+i.scoreFontSize*.4,{align:`right`}),e.setTextColor(0)}}}}function cn(e,t,n,r,i,a,o,s,c){A(e,r.fontSize<=k.TINY?5.5:k.SMALL,O.BOLD),e.setTextColor(40);for(let l=0;l<t;l++){let u=n-t+l+1,d=V(u,n),f=c?.[u]||i.roundLabels[d]||d,p=l===0?r.firstRoundWidth:r.roundColumnWidth,m=ln(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=un(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 ln(e,t,n){return e===0?n:n+t.firstRoundWidth+t.connectorGap+(e-1)*(t.roundColumnWidth+t.connectorGap)}function un(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&&(A(e,n.fontSize,O.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}]`:``;A(e,n.fontSize,O.NORMAL);let c=t.participantName,l=s?`${s} ${c}`:c;e.getTextWidth(l)>a-2&&(c=fn(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 fn(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 pn(e,t,n){return e.find(e=>e.roundNumber===t&&e.roundPosition===n)}function mn(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),w=x*(S/(S+C)),T=x-w,E=i.left+T+b,ee=S>0?(w-b*S)/S:0,D=E+28+b,j=C>0?(T-b*C)/C:0,M=i.left+T,N=o/g,P=N<3.5,F=k.SMALL;N<2.5?F=5:P&&(F=k.TINY);let te=P?5:k.TINY;vn(e,_,y,t,n,E,28,D,ee,M,j,b,r.contentY+2,F);for(let t=0;t<h;t++){let n=m[t],r=a+t*N*2,i=r+N,o=(r+i)/2,s=n.drawPositions[0],c=n.drawPositions[1],l=N*.9;e.setDrawColor(40),e.setLineWidth(.3),e.rect(E,r,28,l),e.rect(E,i,28,l);let u=s?f.get(s):void 0,d=c?f.get(c):void 0;if(A(e,F,O.NORMAL),s&&(e.setTextColor(120),e.text(`${s}`,E+1,r+l/2+F*.12),e.setTextColor(0),u?.participantName)){let t=Z(u.participantName);A(e,F,n.winningSide===1?O.BOLD:O.NORMAL),e.text(t,E+5,r+l/2+F*.12,{maxWidth:22})}if(c&&(e.setTextColor(120),A(e,F,O.NORMAL),e.text(`${c}`,E+1,i+l/2+F*.12),e.setTextColor(0),d?.participantName)){let t=Z(d.participantName);A(e,F,n.winningSide===2?O.BOLD:O.NORMAL),e.text(t,E+5,i+l/2+F*.12,{maxWidth:22})}e.setDrawColor(40),e.setLineWidth(.25),e.line(E+28,r+l/2,E+28+b,r+l/2),e.line(E+28,i+l/2,E+28+b,i+l/2),e.line(E+28+b,r+l/2,E+28+b,i+l/2),e.line(E+28+b,o,D,o),y>0&&(e.line(E,r+l/2,E-b,r+l/2),e.line(E,i+l/2,E-b,i+l/2),e.line(E-b,r+l/2,E-b,i+l/2),e.line(E-b,o,M,o))}hn(e,c,f,_,h,D,ee,b,a,N,F,te,n,t.mainDraw.roundLabelMap),gn(e,u,p,y,M,j,b,a,N,h,F,te,n,t.consolation.roundLabelMap)}function hn(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),_n(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&&(A(e,d,O.NORMAL),e.setTextColor(60,60,160),e.text(U(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=n.get(g.drawPositions[g.winningSide-1]);if(t){let{name:n}=H(t,f);A(e,u+1,O.BOLD),e.text(n,m+1,h-.5)}}}function gn(e,t,n,r,i,a,o,s,c,l,u,d,f,p){for(let l=0;l<r;l++){let p=l+1,m=t.filter(e=>e.roundNumber===p).sort((e,t)=>e.roundPosition-t.roundPosition),h=c*2**(l+1),g=(2**(l+1)-1)*c/2,_=i-(l+1)*(a+o);for(let t=0;t<m.length;t++){let c=m[t],p=s+g+t*h*2,v=p+h,y=(p+v)/2;if(e.setDrawColor(40),e.setLineWidth(.25),e.line(_,p,_+a,p),e.line(_,v,_+a,v),c.drawPositions[0]){let t=n.get(c.drawPositions[0]);if(t?.participantName){A(e,u,O.BOLD);let n=t.participantName;e.getTextWidth(n)>a-2&&(n=Z(n)),e.text(n,_+a-1,p-.3,{align:`right`})}}if(c.drawPositions[1]){let t=n.get(c.drawPositions[1]);if(t?.participantName){A(e,u,O.BOLD);let n=t.participantName;e.getTextWidth(n)>a-2&&(n=Z(n)),e.text(n,_+a-1,v-.3,{align:`right`})}}if(l<r-1){e.line(_-o,p,_-o,v),e.line(_,p,_-o,p),e.line(_,v,_-o,v);let t=i-(l+2)*(a+o);e.line(_-o,y,t+a,y)}c.score&&(A(e,d,O.NORMAL),e.setTextColor(60,60,160),e.text(U(c.score,f),_+1,y+d*.12),e.setTextColor(0))}}if(r>0){let l=i-(r+1)*(a+o),d=s+(2**r-1)*c/2+c*2**(r-1);e.setDrawColor(40),e.setLineWidth(.25),e.line(l,d,l+a,d);let p=t.find(e=>e.roundNumber===r);if(p?.winningSide){let t=n.get(p.drawPositions[p.winningSide-1]);if(t){let{name:n}=H(t,f);A(e,u+1,O.BOLD),e.text(n,l+a-1,d-.5,{align:`right`})}}}}function _n(e,t,n,r,i,a,o,s,c){if(t.drawPositions[0]){let a=n.get(t.drawPositions[0]);if(a?.participantName){A(e,s,O.BOLD);let t=a.participantName;e.getTextWidth(t)>o-2&&(t=Z(t)),e.text(t,r+1,i-.3)}}if(t.drawPositions[1]){let i=n.get(t.drawPositions[1]);if(i?.participantName){A(e,s,O.BOLD);let t=i.participantName;e.getTextWidth(t)>o-2&&(t=Z(t)),e.text(t,r+1,a-.3)}}}function vn(e,t,n,r,i,a,o,s,c,l,u,d,f,p){A(e,p<=k.TINY?5.5:k.SMALL,O.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 Z(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 yn(e,t={}){return bn(e.matchUps)?Cn(e,t):xn(e,t)}function bn(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 xn(e,t={}){if(e.drawSize>=256)return Sn(e,{...t,maxPositionsPerPage:64});let n=Q(e.drawSize,t),r=E(n.doc,n.pageConfig,n.headerH,n.footerH);return W(n.doc,e,n.format,r),$(n),n.doc}function Sn(e,t={}){let n=Q(e.drawSize,t),r=ft(e,{maxPositionsPerPage:t.maxPositionsPerPage||32,includeOverlapRounds:!0,summaryPage:!0});for(let t=0;t<r.length;t++){t>0&&n.doc.addPage();let i=j(n.doc,{...n.headerConfig,subtitle:r[t].label},n.pageConfig),a=E(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};W(n.doc,s,n.format,a,i.startPosition-1,o)}}return $(n),n.doc}function Cn(e,t={}){let n=e.totalRounds>=5||e.slots.length>=12,r=Q(e.drawSize,t,n),i=E(r.doc,r.pageConfig,r.headerH,r.footerH);return W(r.doc,e,r.format,i),$(r),r.doc}function wn(e,t={}){let n=Q(Math.max(...e.map(e=>e.drawData.drawSize),8),t),r=E(n.doc,n.pageConfig,n.headerH,n.footerH);return vt(n.doc,e,n.format,r),An(n,1),$(n),n.doc}function Tn(e,t={}){let n=Q(e.mainStructure?.drawSize||8,t),r=E(n.doc,n.pageConfig,n.headerH,n.footerH);return mt(n.doc,e,n.format,r),An(n,1),$(n),n.doc}function En(e,t={}){let n=Q(e.drawSize,t,!0),r=E(n.doc,n.pageConfig,n.headerH,n.footerH);return an(n.doc,e,n.format,r),$(n),n.doc}function Dn(e,t={}){let n=Q(e.mainDraw.drawSize,t,!0),r=E(n.doc,n.pageConfig,n.headerH,n.footerH);return mn(n.doc,e,n.format,r),$(n),n.doc}function On(e,t={}){let n=Q(Math.max(e.winnersBracket.drawSize,e.losersBracket.drawSize,8),t,!0),r=E(n.doc,n.pageConfig,n.headerH,n.footerH);return yt(n.doc,e,n.format,r),$(n),n.doc}function kn(e,t={}){let n=Q(e.drawSize,t),r=E(n.doc,n.pageConfig,n.headerH,n.footerH);return lt(n.doc,e,n.format,r),$(n),n.doc}function Q(e,t,n){let r=t.format||h(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=T(i,e),c=I(o);return{doc:s,pageConfig:i,headerConfig:a,footerConfig:o,format:r,headerH:j(s,a,i),footerH:c}}function An(e,t){let n=e.doc.getNumberOfPages();for(let r=t+1;r<=n;r++)e.doc.setPage(r),j(e.doc,e.headerConfig,e.pageConfig)}function $(e){let t=e.doc.getNumberOfPages();for(let n=1;n<=t;n++)e.doc.setPage(n),ne(e.doc,e.footerConfig,e.pageConfig,n);e.doc.setPage(t)}function jn(e,t={}){let n=e?.drawsData||[],r=e?.tournamentInfo||{},i=e?.eventInfo||{},a=b(t.catalogPreset||`club-basic`),o=h(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 On({winnersBracket:f?C(f):Mn(),losersBracket:w(n,`CONSOLATION`)?C(w(n,`CONSOLATION`)):Mn(),deciderMatch:w(n,`PLAY_OFF`)?C(w(n,`PLAY_OFF`)):void 0},p);if(u)return wn(l.map(e=>({name:e.structureName,stage:e.stage,drawData:C(e)})),p);let m=t.structureId&&l.find(e=>e.structureId===t.structureId)||f;if(!m)return T({pageSize:`a4`,orientation:`portrait`,margins:{top:12,right:15,bottom:12,left:15}});let g=C(m);return t.mirrored?En(g,p):t.splitPages||g.drawSize>=256?Sn(g,{...p,maxPositionsPerPage:t.maxPositionsPerPage||32}):xn(g,p)}function Mn(){return{drawName:``,drawSize:0,drawType:``,totalRounds:0,slots:[],matchUps:[],seedAssignments:[]}}exports.COMPOSITION_CATALOG=y,exports.DRAW_MODAL_TABS=be,exports.FONT=D,exports.FOOTER_LAYOUT_OPTIONS=ge,exports.HEADER_LAYOUT_OPTIONS=he,exports.ORIENTATION_OPTIONS=ve,exports.PAGE_SIZE_OPTIONS=_e,exports.PRESETS=m,exports.SCHEDULE_MODAL_TABS=xe,exports.SIZE=k,exports.SPLIT_STRATEGY_OPTIONS=ye,exports.STYLE=O,exports.TABLE_STYLES=X,exports.calculateBracketPositions=Tt,exports.createDoc=T,exports.drawBracketConnectors=Dt,exports.drawBracketSlot=Et,exports.drawPageFooter=Ct,exports.drawTournamentHeader=Y,exports.entryStatusDisplay=Ce,exports.eventAbbreviation=Ee,exports.executePrint=pe,exports.extractCompassData=St,exports.extractConsolationStructures=_t,exports.extractCourtCardData=Pe,exports.extractDrawData=Oe,exports.extractParticipantData=Ne,exports.extractRoundRobinData=Le,exports.extractScheduleData=je,exports.findStructure=w,exports.formatDate=Te,exports.formatMatchScore=U,exports.formatPlayerEntry=Re,exports.formatScore=we,exports.formatTime=B,exports.generateBackdrawPDF=Dn,exports.generateCompassDrawPDF=Tn,exports.generateConsolationDrawPDF=wn,exports.generateCourtCardPDF=Lt,exports.generateDoubleEliminationPDF=On,exports.generateDrawPDF=yn,exports.generateDrawSheetPDF=kt,exports.generateFeedInDrawPDF=Cn,exports.generateFromEventData=jn,exports.generateLuckyDrawPDF=kn,exports.generateMatchCardPDF=tn,exports.generateMirroredDrawPDF=En,exports.generatePlayerListPDF=It,exports.generateSchedulePDF=Nt,exports.generateScheduleV2PDF=Bt,exports.generateSequentialOOP=Jt,exports.generateSignInSheetPDF=zt,exports.generateSplitDrawPDF=Sn,exports.generateTraditionalDrawPDF=xn,exports.getCatalogPreset=b,exports.getDefaultPageConfig=ee,exports.getPageRegions=E,exports.getPreset=h,exports.getRoundLabel=V,exports.listCatalogPresets=x,exports.measureFooterHeight=I,exports.measureSeedingsHeight=fe,exports.mergeCatalogPreset=S,exports.mergePreset=g,exports.nationality=z,exports.participantName=R,exports.renderCompassDraw=mt,exports.renderConsolationDraw=vt,exports.renderDoubleEliminationDraw=yt,exports.renderFooter=ne,exports.renderHeader=j,exports.renderLuckyDraw=lt,exports.renderRoundRobinGroup=it,exports.renderSeedingsFooter=ue,exports.renderTraditionalDraw=W,exports.roundName=De,exports.seedDisplay=Se,exports.setFont=A,exports.splitDraw=ft,exports.structureToDrawData=C;
|
|
4
|
+
`):``;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 ln(e,t){return`${t+1}`}function un(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=dn(e.side1,t);r&&n.push(r),n.push(`vs.`);let i=dn(e.side2,t);return i&&n.push(i),e.score?n.push(e.score):e.matchUpStatus===`IN_PROGRESS`&&n.push(`In progress`),n.join(`
|
|
5
|
+
`)}function dn(e,t){return e.name?t||e.nationality?`${e.name} (${e.nationality})`:e.name:`TBD`}function fn(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),N(e,M.TINY,j.NORMAL);let o=(a-i.left-i.right)/t.length;t.forEach((t,n)=>{let a=i.left+n*o;N(e,M.TINY,j.ITALIC),e.setTextColor(100),e.text(t.role,a,r),N(e,M.TINY,j.BOLD),e.setTextColor(0),e.text(t.name,a,r+3)})}var pn=[120,50,140];function mn(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=D(n),{margins:i}=n,a=r.internal.pageSize.getWidth(),o=r.internal.pageSize.getHeight(),s=a-i.left-i.right,c=t.accentColor||pn,l=t.footer||{layout:`none`},u=I(l),d=i.top;t.header&&(d=i.top+P(r,t.header,n)+3);let f=yn(e);for(let[e,a]of f){d+30>o-i.bottom-u&&(bn(r,t,n,l),r.addPage(),d=i.top),d=hn(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&&(bn(r,t,n,l),r.addPage(),d=i.top),d=gn(r,a,!!e.notBeforeTime,i.left,d,s,c),f=a),d+22>o-i.bottom-u&&(bn(r,t,n,l),r.addPage(),d=i.top),d=_n(r,e,i.left,d,s)}d+=4}return t.disclaimer&&(d+=2,N(r,M.TINY,j.ITALIC),r.setTextColor(100),r.text(t.disclaimer,a/2,d,{align:`center`}),r.setTextColor(0)),bn(r,t,n,l),r}function hn(e,t,n,r,i){return N(e,M.HEADING,j.BOLD),e.setTextColor(40),e.text(t.toUpperCase(),n+i/2,r,{align:`center`}),e.setTextColor(0),r+7}function gn(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`),N(e,M.SMALL,j.ITALIC),e.setTextColor(255,255,255),e.text(s,r+a/2,i+3.5,{align:`center`}),e.setTextColor(0),i+7}function _n(e,t,n,r,i){let a=n+15,o=i-30,s=r;N(e,M.TINY,j.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&&(N(e,M.SMALL,j.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=vn(e,t.side1,a,r,o),N(e,M.TINY,j.ITALIC),e.setTextColor(120),e.text(`vs`,a+o/2,r+2.5,{align:`center`}),e.setTextColor(0),r+=4,r=vn(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 vn(e,t,n,r,i){if(!t.name||t.name===`TBD`)return N(e,M.BODY,j.ITALIC),e.setTextColor(150),e.text(`TBD`,n+10,r+3),e.setTextColor(0),r+4;N(e,M.BODY,j.NORMAL);let a=t.nationality?`${t.name} ${t.nationality}`:t.name;return e.text(a,n+10,r+3),r+4}function yn(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 bn(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;N(e,M.TINY,j.BOLD),e.text(t.role,o,n),N(e,M.TINY,j.NORMAL),e.text(t.name,o,n+3)})}ie(e,r,n)}function xn(e,n={}){let{cardsPerPage:r=2,includeScoreBoxes:i=!0}=n,a=new t.default({orientation:`landscape`,format:`a5`});return e.forEach((e,t)=>{t>0&&(r===1||t%r===0)&&a.addPage(),Sn(a,e,r===2&&t%2==1?a.internal.pageSize.getHeight()/2:5,i)}),a}function Sn(e,t,n,r){let i=e.internal.pageSize.getWidth(),a=i/2,o=n;if(t.tournamentName&&(N(e,M.BODY,j.NORMAL),e.setTextColor(100),e.text(t.tournamentName,a,o,{align:`center`}),e.setTextColor(0),o+=5),N(e,M.HEADING,j.BOLD),e.text(`${t.eventName} - ${t.roundName}`,a,o,{align:`center`}),o+=5,t.courtName||t.scheduledTime){N(e,M.BODY,j.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,Cn(e,t.side1,10,o,i),o+=8,N(e,M.BODY,j.ITALIC),e.setTextColor(120),e.text(`vs.`,a,o,{align:`center`}),e.setTextColor(0),o+=6,Cn(e,t.side2,10,o,i),o+=8,r){e.setDrawColor(0),e.setLineWidth(.5),e.line(10,o,i-10,o),o+=4,N(e,M.SMALL,j.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),N(e,M.TINY,j.NORMAL),e.setTextColor(150),e.text(`Set ${t+1}`,n+12/2,o-5,{align:`center`}),e.setTextColor(0)}o+=14,N(e,M.SMALL,j.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 Cn(e,t,n,r,i){N(e,14,j.BOLD);let a=t.seedValue?`[${t.seedValue}] `:``;e.text(`${a}${t.name}`,n,r),N(e,M.HEADING,j.NORMAL),e.setTextColor(80),e.text(t.nationality,i-n,r,{align:`right`}),e.setTextColor(0)}function wn(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=M.SMALL;p<2.5?b=5:m&&(b=M.TINY);let x=m?5:M.TINY,S={lineHeight:p,roundColumnWidth:y,firstRoundWidth:g,connectorGap:h,fontSize:b,scoreFontSize:x},C=t.slots.filter(e=>e.drawPosition<=s),w=t.slots.filter(e=>e.drawPosition>s),T=t.matchUps.filter(e=>e.drawPositions.every(e=>e<=s)),E=t.matchUps.filter(e=>e.drawPositions.every(e=>e>s)),D=w.map(e=>({...e,drawPosition:e.drawPosition-s})),O=new Map;for(let e of E)O.has(e.roundNumber)||O.set(e.roundNumber,[]),O.get(e.roundNumber).push(e);let k=[];for(let[,e]of O)e.sort((e,t)=>e.roundPosition-t.roundPosition),e.forEach((e,t)=>{k.push({...e,drawPositions:e.drawPositions.map(e=>e-s),roundPosition:t+1})});let A=new Map;for(let e of T)A.has(e.roundNumber)||A.set(e.roundNumber,[]),A.get(e.roundNumber).push(e);let P=[];for(let[,e]of A)e.sort((e,t)=>e.roundPosition-t.roundPosition),e.forEach((e,t)=>{P.push({...e,roundPosition:t+1})});Dn(e,c,t.totalRounds,S,n,i.left,i.left+l,r.contentY+2,t.roundLabelMap),N(e,m?5.5:M.SMALL,j.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),Tn(e,C,P,c,S,n,i.left,a,t.totalRounds),En(e,D,k,c,S,n,i.left+l,a,t.totalRounds);let F=t.matchUps.find(e=>e.roundNumber===t.totalRounds);if(F){let r=a+o/2;if(e.setDrawColor(40),e.setLineWidth(.25),e.line(f+2,r,f+u-2,r),F.winningSide){let i=F.drawPositions[F.winningSide-1],a=t.slots.find(e=>e.drawPosition===i);if(a){let{name:t}=V(a,n);N(e,b+1,j.BOLD),e.text(t,f+u/2,r-1,{align:`center`})}}F.score&&(N(e,x,j.NORMAL),e.setTextColor(60,60,160),e.text(H(F.score,n),f+u/2,r+x*.4,{align:`center`}),e.setTextColor(0))}}function Tn(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=On(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;An(e,l.get(t),i,m,c,h,`ltr`),An(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=On(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=Mn(n,t+1,u+1);if(t<r-1&&b?.winningSide){let t=b.drawPositions[b.winningSide-1],n=l.get(t);if(n){N(e,i.fontSize,j.BOLD);let t=n.participantName;e.getTextWidth(t)>i.roundColumnWidth-2&&(t=jn(t)),e.text(t,y+1,_-.5)}}b?.score&&t<r-1&&(N(e,i.scoreFontSize,j.NORMAL),e.setTextColor(60,60,160),e.text(H(b.score,a),y+1,_-.5+i.scoreFontSize*.4),e.setTextColor(0))}}}function En(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=kn(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;An(e,l.get(t),i,m,c,h,`rtl`),An(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=kn(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=Mn(n,t+1,u+1);if(t<r-1&&b?.winningSide){let t=b.drawPositions[b.winningSide-1],n=l.get(t);if(n){N(e,i.fontSize,j.BOLD);let t=n.participantName;e.getTextWidth(t)>i.roundColumnWidth-2&&(t=jn(t));let r=y;e.text(t,r+i.roundColumnWidth-1,_-.5,{align:`right`})}}if(b?.score&&t<r-1){let t=y;N(e,i.scoreFontSize,j.NORMAL),e.setTextColor(60,60,160),e.text(H(b.score,a),t+i.roundColumnWidth-1,_-.5+i.scoreFontSize*.4,{align:`right`}),e.setTextColor(0)}}}}function Dn(e,t,n,r,i,a,o,s,c){N(e,r.fontSize<=M.TINY?5.5:M.SMALL,j.BOLD),e.setTextColor(40);for(let l=0;l<t;l++){let u=n-t+l+1,d=B(u,n),f=c?.[u]||i.roundLabels[d]||d,p=l===0?r.firstRoundWidth:r.roundColumnWidth,m=On(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=kn(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 On(e,t,n){return e===0?n:n+t.firstRoundWidth+t.connectorGap+(e-1)*(t.roundColumnWidth+t.connectorGap)}function kn(e,t,n){return e===0?n-t.firstRoundWidth:n-t.firstRoundWidth-t.connectorGap-(e-1)*(t.roundColumnWidth+t.connectorGap)-t.roundColumnWidth}function An(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&&(N(e,n.fontSize,j.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}]`:``;N(e,n.fontSize,j.NORMAL);let c=t.participantName,l=s?`${s} ${c}`:c;e.getTextWidth(l)>a-2&&(c=jn(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 jn(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 Mn(e,t,n){return e.find(e=>e.roundNumber===t&&e.roundPosition===n)}function Nn(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),w=x*(S/(S+C)),T=x-w,E=i.left+T+b,D=S>0?(w-b*S)/S:0,O=E+28+b,k=C>0?(T-b*C)/C:0,A=i.left+T,j=o/g,N=j<3.5,P=M.SMALL;j<2.5?P=5:N&&(P=M.TINY);let F=N?5:M.TINY;Hn(e,_,y,t,n,E,28,O,D,A,k,b,r.contentY+2,P),Pn(e,m,h,f,E,28,b,O,A,a,j,P,y),In(e,c,f,_,h,O,D,b,a,j,P,F,n,t.mainDraw.roundLabelMap),Ln(e,u,p,y,A,k,b,a,j,h,P,F,n,t.consolation.roundLabelMap)}function Pn(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;N(e,d,j.NORMAL),_&&Fn(e,_,b,n.winningSide===1,i,m,y,a,d),v&&Fn(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 Fn(e,t,n,r,i,a,o,s,c){if(e.setTextColor(120),N(e,c,j.NORMAL),e.text(`${t}`,i+1,a+o/2+c*.12),e.setTextColor(0),n?.participantName){let t=Un(n.participantName);N(e,c,r?j.BOLD:j.NORMAL),e.text(t,i+5,a+o/2+c*.12,{maxWidth:s-6})}}function In(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),Vn(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&&(N(e,d,j.NORMAL),e.setTextColor(60,60,160),e.text(H(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=n.get(g.drawPositions[g.winningSide-1]);if(t){let{name:n}=V(t,f);N(e,u+1,j.BOLD),e.text(n,m+1,h-.5)}}}function Ln(e,t,n,r,i,a,o,s,c,l,u,d,f,p){for(let l=0;l<r;l++)Rn(e,t,n,l,r,i,a,o,s,c,u,d,f);Bn(e,t,n,r,i,a,o,s,c,u,f)}function Rn(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),zn(e,l.drawPositions[0],n,u,_,o,p),zn(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&&(N(e,d,j.NORMAL),e.setTextColor(60,60,160),e.text(H(l.score,f),_+1,y+d*.12),e.setTextColor(0))}}function zn(e,t,n,r,i,a,o){if(!t)return;let s=n.get(t);if(!s?.participantName)return;N(e,r,j.BOLD);let c=s.participantName;e.getTextWidth(c)>a-2&&(c=Un(c)),e.text(c,i+a-1,o-.3,{align:`right`})}function Bn(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=n.get(p.drawPositions[p.winningSide-1]);if(t){let{name:n}=V(t,u);N(e,l+1,j.BOLD),e.text(n,d+a-1,f-.5,{align:`right`})}}}function Vn(e,t,n,r,i,a,o,s,c){if(t.drawPositions[0]){let a=n.get(t.drawPositions[0]);if(a?.participantName){N(e,s,j.BOLD);let t=a.participantName;e.getTextWidth(t)>o-2&&(t=Un(t)),e.text(t,r+1,i-.3)}}if(t.drawPositions[1]){let i=n.get(t.drawPositions[1]);if(i?.participantName){N(e,s,j.BOLD);let t=i.participantName;e.getTextWidth(t)>o-2&&(t=Un(t)),e.text(t,r+1,a-.3)}}}function Hn(e,t,n,r,i,a,o,s,c,l,u,d,f,p){N(e,p<=M.TINY?5.5:M.SMALL,j.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 Un(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 Wn(e,t={}){return Gn(e.matchUps)?Jn(e,t):Kn(e,t)}function Gn(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 Kn(e,t={}){if(e.drawSize>=256)return qn(e,{...t,maxPositionsPerPage:64});let n=Q(e.drawSize,t),r=O(n.doc,n.pageConfig,n.headerH,n.footerH);return U(n.doc,e,n.format,r),$(n),n.doc}function qn(e,t={}){let n=Q(e.drawSize,t),r=Dt(e,{maxPositionsPerPage:t.maxPositionsPerPage||32,includeOverlapRounds:!0,summaryPage:!0});for(let t=0;t<r.length;t++){t>0&&n.doc.addPage();let i=P(n.doc,{...n.headerConfig,subtitle:r[t].label},n.pageConfig),a=O(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};U(n.doc,s,n.format,a,i.startPosition-1,o)}}return $(n),n.doc}function Jn(e,t={}){let n=e.totalRounds>=5||e.slots.length>=12,r=Q(e.drawSize,t,n),i=O(r.doc,r.pageConfig,r.headerH,r.footerH);return U(r.doc,e,r.format,i),$(r),r.doc}function Yn(e,t={}){let n=Q(Math.max(...e.map(e=>e.drawData.drawSize),8),t),r=O(n.doc,n.pageConfig,n.headerH,n.footerH);return Lt(n.doc,e,n.format,r),tr(n,1),$(n),n.doc}function Xn(e,t={}){let n=Q(e.mainStructure?.drawSize||8,t),r=O(n.doc,n.pageConfig,n.headerH,n.footerH);return Nt(n.doc,e,n.format,r),tr(n,1),$(n),n.doc}function Zn(e,t={}){let n=Q(e.drawSize,t,!0),r=O(n.doc,n.pageConfig,n.headerH,n.footerH);return wn(n.doc,e,n.format,r),$(n),n.doc}function Qn(e,t={}){let n=Q(e.mainDraw.drawSize,t,!0),r=O(n.doc,n.pageConfig,n.headerH,n.footerH);return Nn(n.doc,e,n.format,r),$(n),n.doc}function $n(e,t={}){let n=Q(Math.max(e.winnersBracket.drawSize,e.losersBracket.drawSize,8),t,!0),r=O(n.doc,n.pageConfig,n.headerH,n.footerH);return Rt(n.doc,e,n.format,r),$(n),n.doc}function er(e,t={}){let n=Q(e.drawSize,t),r=O(n.doc,n.pageConfig,n.headerH,n.footerH);return wt(n.doc,e,n.format,r),$(n),n.doc}function Q(e,t,n){let r=t.format||h(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=D(i,e),c=I(o);return{doc:s,pageConfig:i,headerConfig:a,footerConfig:o,format:r,headerH:P(s,a,i),footerH:c}}function tr(e,t){let n=e.doc.getNumberOfPages();for(let r=t+1;r<=n;r++)e.doc.setPage(r),P(e.doc,e.headerConfig,e.pageConfig)}function $(e){let t=e.doc.getNumberOfPages();for(let n=1;n<=t;n++)e.doc.setPage(n),ie(e.doc,e.footerConfig,e.pageConfig,n);e.doc.setPage(t)}function nr(e,t={}){let n=e?.drawsData||[],r=e?.tournamentInfo||{},i=e?.eventInfo||{},a=S(t.catalogPreset||`club-basic`),o=h(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 $n({winnersBracket:f?T(f):rr(),losersBracket:E(n,`CONSOLATION`)?T(E(n,`CONSOLATION`)):rr(),deciderMatch:E(n,`PLAY_OFF`)?T(E(n,`PLAY_OFF`)):void 0},p);if(u)return Yn(l.map(e=>({name:e.structureName,stage:e.stage,drawData:T(e)})),p);let m=t.structureId&&l.find(e=>e.structureId===t.structureId)||f;if(!m)return D({pageSize:`a4`,orientation:`portrait`,margins:{top:12,right:15,bottom:12,left:15}});let g=T(m);return t.mirrored?Zn(g,p):t.splitPages||g.drawSize>=256?qn(g,{...p,maxPositionsPerPage:t.maxPositionsPerPage||32}):Kn(g,p)}function rr(){return{drawName:``,drawSize:0,drawType:``,totalRounds:0,slots:[],matchUps:[],seedAssignments:[]}}exports.COMPOSITION_CATALOG=x,exports.DRAW_MODAL_TABS=Ce,exports.FONT=A,exports.FOOTER_LAYOUT_OPTIONS=ye,exports.HEADER_LAYOUT_OPTIONS=ve,exports.ORIENTATION_OPTIONS=xe,exports.PAGE_SIZE_OPTIONS=be,exports.PRESETS=m,exports.SCHEDULE_MODAL_TABS=we,exports.SIZE=M,exports.SPLIT_STRATEGY_OPTIONS=Se,exports.STYLE=j,exports.TABLE_STYLES=Z,exports.calculateBracketPositions=Wt,exports.createDoc=D,exports.drawBracketConnectors=Kt,exports.drawBracketSlot=Gt,exports.drawPageFooter=Ht,exports.drawTournamentHeader=X,exports.entryStatusDisplay=Ee,exports.eventAbbreviation=ke,exports.executePrint=ge,exports.extractCompassData=Vt,exports.extractConsolationStructures=It,exports.extractCourtCardData=Le,exports.extractDrawData=je,exports.extractParticipantData=Ie,exports.extractRoundRobinData=Be,exports.extractScheduleData=Pe,exports.findStructure=E,exports.formatDate=Oe,exports.formatMatchScore=H,exports.formatPlayerEntry=Ve,exports.formatScore=De,exports.formatTime=z,exports.generateBackdrawPDF=Qn,exports.generateCompassDrawPDF=Xn,exports.generateConsolationDrawPDF=Yn,exports.generateCourtCardPDF=nn,exports.generateDoubleEliminationPDF=$n,exports.generateDrawPDF=Wn,exports.generateDrawSheetPDF=Jt,exports.generateFeedInDrawPDF=Jn,exports.generateFromEventData=nr,exports.generateLuckyDrawPDF=er,exports.generateMatchCardPDF=xn,exports.generateMirroredDrawPDF=Zn,exports.generatePlayerListPDF=tn,exports.generateSchedulePDF=Qt,exports.generateScheduleV2PDF=on,exports.generateSequentialOOP=mn,exports.generateSignInSheetPDF=an,exports.generateSplitDrawPDF=qn,exports.generateTraditionalDrawPDF=Kn,exports.getCatalogPreset=S,exports.getDefaultPageConfig=k,exports.getPageRegions=O,exports.getPreset=h,exports.getRoundLabel=B,exports.listCatalogPresets=C,exports.measureFooterHeight=I,exports.measureSeedingsHeight=he,exports.mergeCatalogPreset=w,exports.mergePreset=g,exports.nationality=R,exports.participantName=L,exports.renderCompassDraw=Nt,exports.renderConsolationDraw=Lt,exports.renderDoubleEliminationDraw=Rt,exports.renderFooter=ie,exports.renderHeader=P,exports.renderLuckyDraw=wt,exports.renderRoundRobinGroup=yt,exports.renderSeedingsFooter=pe,exports.renderTraditionalDraw=U,exports.roundName=Ae,exports.seedDisplay=Te,exports.setFont=N,exports.splitDraw=Dt,exports.structureToDrawData=T;
|
|
6
6
|
//# sourceMappingURL=pdf-factory.cjs.map
|