localp={RD={'準々決勝','準決勝','決勝','3位決定戦'},-- The text and background colors are paired and when you set one, you should set the other (accessibility)textColor={head='#202122','#202122','#202122','#202122','#202122'},bgColor={head='#f2f2f2','gold','silver','#C96','#f9f9f9'},reuseStr={},saveStr=function(self,name,...)ifnotself.reuseStr[name]thenself.reuseStr[name]=table.concat{...}endreturnself.reuseStr[name]end}--Provides a convenient naming shortcut up to {{#invoke:RoundN|N512}} = {{invoke:RoundN|main|columns = 9}}forcolumns=1,9dolocalN=math.pow(2,columns)p['N'..N]=function(frame)returnp.main(frame.args,columns)endp['n'..N]=p['N'..N]--to make case insensitiveend--saves memory and avoids errors when using a nil as a table by providing a temporary table; if using nil as false; use 'table(k)' to look up table[k]p.nilAsTab={__index=function(t,i)returnsetmetatable({},setmetatable(p.nilAsTab,{__index={t=t,i=i}}))end,__newindex=function(pt,pi,v)--store new values in actual table rather than temporaryrawset(p.nilAsTab.t,p.nilAsTab.i,{})[p.nilAsTab.i][pi]=vsetmetatable(p.nilAsTab.t[p.nilAsTab.i],{__call=p.nilAsTab.__call})end,__call=function(t,i)returntandrawget(t,i)end}--never assign a value to these or they will stop being emptylocalinfiniteEmpty=setmetatable({},{__index=setmetatable({},p.nilAsTab),p.nilAsTab})-- infiniteEmpty[1][2][3]...[infinity] = {}localcallableEmpty=setmetatable({},p.nilAsTab)localrowNum,head,m,col,tab,esc={},{},{num=1,phase=0,bold=infiniteEmpty},{},mw.html.create'table',{bs=require'Module:Escape',--backslashcomma={['(%([^,]*),([^%)]*%))']='%1|@!#|%2'},--escape commas in ()}localnodeFunc={scanPattern=function(self,args,step)self.pattern=nilifargs[step]thenself.pattern,self.nonFunc=string.match(esc.bs:text(args[step]),'^node_function{(.-)}(.*)')endifself.patternthenfork,vinpairs(esc.comma)doself.pattern=self.pattern:gsub(k,v)endself.nonFunc=self.nonFuncandesc.bs:undo(self.nonFunc)self.pattern=mw.text.split(self.pattern,'%s*,%s*')fork,vinipairs(self.pattern)dolocalfunc,arg=string.match(v,'^(%w+)%(?([^%)]*)')iffuncandself[func]andself[func].mainthenself.pattern[k]=funcifargthenforx,yinpairs(esc.comma)doarg=esc.bs:undo(arg):gsub(y:gsub('%%%d',''),x:match('%)([^%(])%(')orx:gsub('\\',''))endself[func].arg=self[func].argor{}self[func].arg[m.num]=argendendendendreturnself.patternend,helper={topBranch=function()--node is top of fork if top is 0return(m.num-col.top)%2end,addText=function(text)iftextandtext~=''thentab.r:wikitext(text)endend},line={--this node is omitted and replaced with a linemain=function(x)localh=p.getNodeFunc()ifm.availablethenlocaltext,topId,isTop,notTop=h.line.arg[m.num]or'',h.topBranch()isTop=topId==0notTop={[isTopand1or0]=p.reuseStr.solid}fork=0,1dotab.r=rowNum[m.r+k*4]:tag'td':css(notTop[k]and{[isTopand'border-top'or'border-bottom']=notTop[k]}or{}):attr{rowspan=({[0]=4,2})[k],colspan=p.colspan}h.addText(textorh.nonFunc)text=nilendm.available=falseelsereturnnilendreturnxend},bridge={--Draw a line to the neighboring node in the same column that is not connected to the current nodemain=function(x)localh=p.getNodeFunc()h.bridge.lay[col.c][m.num-col.top+1+(h.topBranch()==1and1or-1)]=trueh.addText(nonFunc)returnxend,lay=setmetatable({},p.nilAsTab)},canvas={--Merges all cells in node. Content will be the next parameter.main=function(x)localh=p.getNodeFunc()ifm.availablethentab.r=rowNum[m.r]:tag'td':attr{rowspan=6,colspan=p.colspan}h.addText(h.nonFunc)m.available=falsereturnxelsereturnnilendend},orphan={--sets a flag for skipMatch to be set by p._mainmain=function(x)p.getNodeFunc().orphan.num=m.numreturnxend},skipAllowed={--table of supported node functions when node is skipped (i.e. by skipmatch)bridge=true,canvas=true}}setmetatable(nodeFunc.helper,{__index=nodeFunc})functionp.getNodeFunc()returnnodeFunc.helperendlocalfunctionnewRow(bodyRow)localfirst=p.flex_tree.mergeandmw.clone(p.flex_tree.cell)orp.flex_tree.celltab.r=tab:tag'tr':node(first)ifbodyRowthentable.insert(rowNum,bodyRow,tab.r)ifp.flex_tree.mergethenrowNum[bodyRow].first=firstrowNum[bodyRow].first.unchanged=trueendendendlocalfunctiondrawHead(text,row3rd)localtd=(row3rdandrowNum[row3rd]:tag'td':attr{rowspan=2}orhead.row:tag'td'):attr{colspan=p.colspan}iftext~='omit_label'thentd:wikitext(text):css{['text-align']='center',border='1px solid #aaa',['background-color']=p.bgColor.head,color=p.textColor.head}endendlocalfunctionspacer(width)tab.r:tag'td':attr{width=width}:wikitext(p.no_column_headand''or' ')endlocalfunctiondpBox(v,r)p.dpBoxBase=p.dpBoxBaseormw.html.create'td':attr{rowspan=2,colspan=p.colspan}ifnotvthenp.dpBoxEmpty=p.previewnumbersandmw.clone(p.dpBoxBase)orp.dpBoxEmptyormw.clone(p.dpBoxBase):wikitext(p.flex_tree.wt)rowNum[r]:node(p.dpBoxEmpty)elserowNum[r]:node(mw.clone(p.dpBoxBase):wikitext(v))endendp.scoreWasher={numberFormat='%-?%d+%.?%d*',main=function(self,s)ifsthenfor_,cycleinipairs(self.cycles)dos=s:gsub(unpack(cycle))endifp.scoreSumBoxandself.plusthenlocalt=0for_,partinipairs(mw.text.split(s,self.plus))dot=t+(tonumber(part:match('%-?%d+%.?%d*'))or0)endreturntendreturntonumber(s:match(self.numberFormat))ormath.hugeendreturn0end,spin=function(self,v)table.insert(self,v)returnselfend,load=function(self,cycle)localwash,rinse=0,{spin=self.spin}forvincycle:gfind('%(([^%(%)]-)%)')doifv=='_plus_'thenself.plus=vrinse:spin(v)cycle=cycle:gsub('%(_plus_%)','',1)elsewash=wash+1rinse:spin('%'):spin(wash)endendtable.insert(self.cycles,{esc.bs:undo(cycle,'%%'),table.concat(rinse)})end,init=function(self,setting)self.cycles={original=setting}forcyclein(settingandesc.bs:text(setting)or'{<.->} {[^%d]*}'):gfind('{(.-)}')doself:load(cycle)endend,sum=function(clean)localsum={0,0}for_,boxinipairs(clean)doforteam,scoreinipairs(box)dosum[team]=sum[team]+scoreendendreturnunpack(math.max(unpack(sum))==math.hugeand{'—','—'}orsum)end}localfunctionboldWin(s1,s2)returnsetmetatable(p.boldands1~=s2and(math[({'min','max'})[p.bold]](s1,s2)==s1and{true}or{[2]=true})orcallableEmpty,p.nilAsTab)endlocalfunctionmaxSpan(span,start,rows)returnmath.min(span,math.max(0,rows-start+1))end--in case of templates like RDseed need padding valuep.teamBoxPadding=function()return'.6ex'endp.teamBoxPadTab={padding='0 '..p.teamBoxPadding()}p.teamBoxNormal={border='1px solid #aaa',['background-color']=p.bgColor[4],color=p.textColor[4]}localfunctionteamBox(v,r,f)ifp.flex_tree.mergeandnotvandf.phase==2thenfori=-2,0doifrowNum[r+i].first.unchangedthenrowNum[r+i].first.unchanged=nilrowNum[r+i].first:node(p.unflex_div)endendtab.r:attr{rowspan=4}:css{['vertical-align']='center'}elseifnotp.boldthen--backwards compatability (wikitemplates bold each arg individually)localhasBold,b=tostring(v):gsub("([^']*)'''([^']*)",'%1<b>%2</b>')ifb==1thenv=hasBoldendendlocalcelliff[1]thencell=f.sumBoxandf.sumBox[1]and{padding=f.sumBox[1]}or{['border-left']=f.borderLeft}cell['text-align']=vandf[1]elsecell=p.teamBoxPadTabendlocaltext=vorf[1]and''or' 'iff.boldthentext=mw.ustring.gsub(text,'(%(%[%[[^%[%]]*%]%]%))','<span style="font-weight:normal">%1</span>')endtab.r=rowNum[r]:tag'td':css(p.teamBoxCSS):css(cell):attr{rowspan=2}:node(mw.html.create(f.boldand'b'):wikitext(text))endendfunctionp._main(args)functionargs:clean(key,params)--prevent html comments from breaking named args and reduces repeat concatenationparams=paramsor{}localclean=args[key]orparams.ifNilifcleanthenparams.append=params.appendor''clean=mw.text.decode(clean):gsub('<!%-.-%->',''):gsub(params.patternor'[^%w-;%.]','')..params.appendclean=clean~=params.appendandcleanorparams.ifNilendargs[key]=params.keepOldandargs[key]orcleanreturncleanendp.cols=tonumber(args:clean('columns',{pattern='%D'}))p.tCols=(tonumber(args:clean('final_RDs_excluded',{pattern='%D'}))or0)+p.colslocalmatchPer={pattern='%d*per%d+[%-x]%d+',vals='(%d*)per(%d+)([%-x])(%d+)'}localskipMatch,unBold={},{}--(skip|manualbold)match# to booleanfork,_inpairs(args)dolocalmType,mNum=string.match(k,'^(%l+)match(%d*)$')mType,mNum=({skip=skipMatch,manualbold=unBold})[mType],tonumber(mNum)ifmTypethenifmNumthenmType[mNum]=args:clean(k)=='yes'orargs[k]=='true'elseforpatterninargs:clean(k,{ifNil=''}):gfind(matchPer.pattern)dolocald1,period,op,d2=pattern:match(matchPer.vals)d1=tonumber(d1)or1d2=op=='-'andd2or(d1+period*(d2-1))fory=d1,d2,perioddomType[y]=trueendendfor_,xinipairs(mw.text.split(args[k]:gsub(matchPer.pattern,''):gsub('[;%-%a][;%-%a]+',';'):match('^;*(.-)[;%-]*$'),';'))dox=mw.text.split(x,'-')fory=tonumber(x[1])or1,tonumber(x[2]orx[1])or0domType[y]=trueendendendendendfor_,vinipairs({--more args to boolean'widescore','color','color_repechage','3rdplace','omit_blanks','scroll_head_unlock','previewnumbers','flex_tree','no_column_head','short_brackets','branch_upwards'})doifargs[v]and(p[v]==nilortype(p[v])=='boolean')thenp[v]=args:clean(v)=='yes'orargs[v]=='true'endendp.namespace=mw.title.getCurrentTitle().namespacep.previewnumbers=p.namespace~=0andp.previewnumbersp.scoreWasher:init(args['score-clean'])p.scoreWasher.demo=args.demoWashandtonumber(args:clean('demoWash',{pattern='%D'}),10)p.scoreSumBox=args['score-boxes']andargs['score-boxes']:match('%d ?%+ ?sum')p.bold=({low=1,high=2})[args:clean('bold_winner')]orp.scoreSumBoxand2localsumBox=p.scoreSumBoxand1or0p.scoreBoxes=(tonumber(args:clean('score-boxes',{pattern='%D'}))or1)+sumBoxp.scoreSumBox=p.scoreBoxes>0andp.scoreSumBoxornillocalboxStyle=p.scoreBoxes>1and(p.scoreSumBoxandsetmetatable({{},[p.scoreBoxes]={'0 1ex'}},{__call=function(t,i)ift[i]thenreturnnilendreturn0end})orsetmetatable({},{__call=function()return0end}))orsetmetatable({},{__call=function()returnnilend})p.colspan=p.scoreBoxes>0and(p.scoreBoxes+1)ornillocalnodeArgs={score=p.scoreBoxes-sumBox,team={offset=1+p.scoreBoxes-sumBox}}nodeArgs.all=1+nodeArgs.team.offset*2nodeArgs.tableSum={__add=function(v,t)if#t==3thenreturnv+nodeArgs.allendlocals=vfori,ninipairs(t)dos=s+nendreturns--[[ + (p.scoreSumBox and #t == 3 and -2 or 0) --merging disabled with score boxes, uncomment if enable]]end}nodeArgs.team[1]=1--constant to be replaced later by new paramnodeArgs.team[2]=nodeArgs.team[1]+nodeArgs.team.offsetnodeArgs.blank=setmetatable({},nodeArgs.tableSum)p.unflex_div=mw.html.create'div':css{overflow='hidden',height='1ex'}:wikitext' 'p.flex_tree=setmetatable({},{__index={merge=p.flex_treeandp.scoreBoxes==0,wt=p.flex_treeand''or' ',cell=mw.html.create'td':node(notp.flex_treeandp.unflex_divornil)}})ifargs:clean'scroll_height'thenlocalfontSize,fontUnit=args.styleandargs.style:match('font%-size *: *(%d+)([^ ]+)')iffontSizethenlocalunits={em=1,ex=2,['%']=0.01}fontSize,fontUnit={fontSize*fontUnit}endendtab:cssText(table.concat{args.scroll_heightand'padding'or'margin',':',fontSizeand(math.ceil(fontSize*10)/10)or'.9','em 2em 1em 1em;border:0;',fontSizeand''or'font-size:90%;border-collapse:separate;',args.style}):attr{cellpadding=0,cellspacing=0}ifnotp.no_column_headthen--headings rownewRow()head.row=tab.r:css{['white-space']=args.scroll_heightand'nowrap'}newRow()elsetab.r=tab:tag'tr'tab.r:tag'td'endlocalsp={--set column widthsargs['team-width']or170,p.widescoreand40or30,p.short_bracketsand6or15,p.short_bracketsand4or20}localscoreWidth=args:clean('score-width',{pattern='[^%d;]'})andmw.text.split(args['score-width'],';')or{}scoreWidth[1]=tonumber(scoreWidth[1],10)ifp.scoreSumBoxand#scoreWidth~=1thenlocal_scoreWidth={}fork=1,p.scoreBoxes-1do_scoreWidth[k]=tonumber(scoreWidth[k],10)ormath.ceil(sp[2]*0.75)endsetmetatable(scoreWidth,_scoreWidth)endlocalhead_br={count=0,compare=function(self,text)iftextandargs.scroll_heightthenlocal_,count=text:gsub('<br[ >/]','%1')self.count=math.max(self.count,count)endreturntextend}p.branch_upwards=p.branch_upwardsand0fork=1,p.colsdoifk>1thenspacer(sp[3])spacer(sp[4])ifnotp.no_column_headthenhead.row:tag'td':attr{colspan=2}endendspacer(sp[1])fors=1,p.scoreBoxesdospacer(#scoreWidth==1andscoreWidth[1]orscoreWidth[s]orsp[2])endifnotp.no_column_headthenhead.wt=head_br:compare(args:clean('RD'..k,{pattern=''}))orp.RD[#p.RD+k-p.tCols-1]or('Round of '..math.pow(2,p.tCols-k+1))drawHead(head.wt)endendsp.row=tab.rcol.tot=math.pow(2,p.tCols-1)localstep,bump,bumpBase,rows=1,0,mw.html.create'td':attr{colspan=p.colspan},col.tot*6--Begin body row outputargs.line_px=table.concat{args:clean('line_px')or3,args.line_px~='0'and'px'ornil}tab.line={--reduces concats and 'or' statements{[true]=args.line_px,[false]=0},args.line_px:rep(2):gsub('(%a)(%d)','%1 %2',1)}p['3rdplace']=p.tCols==p.colsand(p['3rdplace']orp.cols>3andnil==p['3rdplace']andnotp.no_column_head)ifp['3rdplace']thenp.textThird=args.Consolorargs['RD'..(p.cols+1)]orp.RD[4]localno3rdText=p.no_column_headorp.textThirdandp.textThird:match('omit_label')rowNum.third=math.max(math.pow(2,p.branch_upwardsand-3orp.cols-2)*9+(no3rdTextand4or9),no3rdTextand12or17,rows)endforr=1,rowNum.thirdorrowsdonewRow(r)endp:saveStr('solid',tab.line[1][true],' solid')p.cornerDiv=mw.html.create'div':css{height=tab.line[1][true],['border-right']=p.reuseStr.solid}forc=1,p.colsdocol.c=clocalbumps=bumpifc>1thencol.tot=col.tot+math.pow(2,p.tCols-c)ifp.branch_upwardsthenbumps=0rowNum[1]:tag'td':attr{rowspan=4}elserowNum[1]:node(c<p.colsandmw.clone(bumpBase):attr{rowspan=bump})endendcol.top=m.nump.span=p.tCols>candbump*2orp.branch_upwardsormath.max((bump-1)/2,2)col.color_repechage=p['color_repechage']and((c==p.tCols)or((c==p.tCols-1)andskipMatch[math.pow(2,p.tCols)-1]))col.show3rd=p['3rdplace']andc==p.tColsandrowNum.thirdlocalcolorFinal,bumpMid=p.colorandc==p.tCols,p.span>0andmw.clone(bumpBase):attr{rowspan=p.span}ornilforr=1,col.show3rdorrows,2dom.r=r+bumpsifcol.show3rdorrowNum[m.r]andm.num<=col.totthenifm.phase==0thenm.showBox=setmetatable({1,nodeArgs.team.offset,nodeArgs.team.offset},nodeArgs.tableSum)ifnodeFunc:scanPattern(args,step)thennodeFunc.called={}m.available=trueelsem.available=nilendendifskipMatch[m.num]thenifm.phase==0thenifnodeFunc.patternthenforx,yinipairs(nodeFunc.pattern)doifnodeFunc.skipAllowed[y]thennodeFunc.called[y]=nodeFunc[y].main(x)endendendlocalcanvas=nodeFunc.patternandnodeFunc.called.canvasand6rowNum[m.r+(canvasor0)]:tag'td':attr{rowspan=maxSpan((canvasand0or6)+bump*2,m.r+(canvasor0),rows),colspan=p.colspan}elseifm.phase==2thenifnodeFunc.patternand(nodeFunc.called.bridgeornodeFunc.called.canvas)thenstep=step+1endm.num=m.num+1step=step+(p.omit_blanksand0orm.showBox)bumps=bumps+(col.show3rdand0ormaxSpan(p.span,m.r,rows))endelseifm.phase==0thenifnodeFunc.patternthenforx,yinipairs(nodeFunc.pattern)doifnodeFunc[y]andnodeFunc[y].mainthennodeFunc.called[y]=nodeFunc[y].main(x)endendifm.available==falsethenm.showBox=nodeArgs.blankstep=step+1endendifm.showBox[1]thenifcol.show3rdthencol.show3rd=(m.num-col.top)*2ifcol.show3rd==2thenifp.textThird:match('omit_label')thenp.textThird=nilendifrowNum[rows+1]andp.cols>1then--if 3rd place extends below bottom cellrowNum[rows+1]:tag'td':attr{rowspan=m.r+9-rows-(textand0or2),colspan=(p.cols-1)*(3+p.scoreBoxes)}endifp.tCols==1thenbumps=p.textThirdand3or0elseifp.branch_upwardsthenr=7bumps=p.textThirdand2or0endm.r=r+bumpsifp.textThirdthendrawHead(p.textThird,m.r)bumps=bumps+2m.r=r+bumpsendendenddpBox(nodeFunc.patternandnodeFunc.nonFuncorargs[step],m.r)ifp.previewnumbersthenrowNum[m.r].nodes[#rowNum[m.r].nodes]:tag'div':css{float='left',border='1px solid red',padding='0 .5ex',['color']='red'}:wikitext(m.num):attr{title='Number only visible outside article space (e.g. template) when |numberpreview=yes'}endendifp.colspanthenm.nonEmpty={}fors=step+2,step+nodeArgs.team.offsetdolocali={s,s+nodeArgs.team.offset}ifargs[i[1]]orargs[i[2]]thentable.insert(m.nonEmpty,i)endendifp.boldandm.showBox[2]andm.showBox[3]andnotunBold[m.num]thenm.bold={box={},clean={}}localnotSummed=notp.scoreSumBoxor#m.nonEmpty<2fors,iinipairs(m.nonEmpty)dom.bold.clean[s]={p.scoreWasher:main(args[i[1]]),p.scoreWasher:main(args[i[2]])}m.bold.box[s]=notSummedandboldWin(m.bold.clean[s][1],m.bold.clean[s][2])orcallableEmptyendifp.scoreSumBoxandm.nonEmpty[2]thenlocali={-step,-step-1}table.insert(m.nonEmpty,i)args[i[1]],args[i[2]]=p.scoreWasher.sum(m.bold.clean)m.bold.box[p.scoreBoxes]=boldWin(args[i[1]],args[i[2]])endgetmetatable(boxStyle).__index=p.scoreSumBoxesand{[#m.nonEmpty]=boxStyle[p.scoreBoxes]}m.bold.win=m.bold.box[#m.nonEmpty]orcallableEmptyelsem.bold=infiniteEmptyendendelseifm.showBox[m.phase]thenifcol.color_repechagethencol.color_repechage=2endifp.boldthenifm.bold.win(m.phase)and(colorFinalorcol.color_repechage)thencolor_index=1+(col.show3rdor0)+(col.color_repechageor0)elseifm.bold.box[#m.nonEmpty]thencolor_index=2+(col.show3rdor0)+(col.color_repechageor0)elsecolor_index=4endp.teamBoxCSS=(colorFinalorcol.color_repechage)and{border=p.teamBoxNormal.border,['background-color']=p.bgColor[color_index],color=p.textColor[color_index]}orp.teamBoxNormalelsep.teamBoxCSS=(colorFinalorcol.color_repechage)and{border=p.teamBoxNormal.border,['background-color']=p.bgColor[m.phase+(col.show3rdor0)+(col.color_repechageor0)],color=p.textColor[m.phase+(col.show3rdor0)+(col.color_repechageor0)]}orp.teamBoxNormalendlocalf={phase=m.phase,bold=m.bold.win(m.phase)}teamBox(args[step+nodeArgs.team[m.phase]],m.r,f)f[1]='center'ifp.colspanthenifm.nonEmpty[1]thenlocalloneSumif#m.nonEmpty<p.scoreBoxesthenloneSum=#m.nonEmpty==1andboxStyle[p.scoreBoxes]tab.r:attr{colspan=1+p.scoreBoxes-#m.nonEmpty}endfors,iinipairs(m.nonEmpty)dof.borderLeft=boxStyle(s)f.sumBox=loneSumorboxStyle[s]f.bold=m.bold.box[s](m.phase)teamBox(args[i[m.phase]],m.r,f)endelsefors=1,p.scoreBoxesdof.borderLeft=boxStyle(s)teamBox(nil,m.r,f)endendendendifm.phase==2thencol.show3rd=col.show3rd~=2andcol.show3rdornilifp.scoreWasher.demoandp.scoreWasher.demo==m.numandp.namespace~=0thentable.insert(m.bold.clean,1,{args[step+nodeArgs.team[1]],args[step+nodeArgs.team[2]]})returntable.concat{'Score data for match specified by <code>|demoWash=</code>:<br>',mw.dumpObject{scores=m.bold.clean,cycles=p.scoreWasher.cycles,sum=p.scoreSumBoxand{m.nonEmpty[#m.nonEmpty][1],m.nonEmpty[#m.nonEmpty][1]}},'<table>',tostring(sp.row),'<tr>',tostring(rowNum[m.r-4]),'<tr>',tostring(rowNum[m.r-2]),'<tr>',tostring(rowNum[m.r]),'</table>',}endifnodeFunc.orphan.num==m.numthenskipMatch[m.num]='orphan'endstep=step+m.showBoxm.num=m.num+1ifbump>0androwNum[m.r+2]andnot(nodeFunc.patternandnodeFunc.called.canvas)thenbumps=bumps+p.spanrowNum[m.r+2]:node(bumpMid)endr=r+(col.show3rdorbump)endendm.phase=(m.phase+1)%3endendifp.cols>cthen--draw lines to next roundp.unit=bump+3bump=3*math.pow(2,c)-3bumps=p.branch_upwardsand4or(p.unit+1)rowNum[1]:tag'td':attr{rowspan=bumps}ifnotp.branch_upwardsthenrowNum[1]:tag'td':attr{rowspan=(p.branch_upwardsorbump)+4}:css(nodeFunc.bridge.lay[c](0)and{['border-right']=p.reuseStr.solid}or{})endcol.n=0forr=bumps+1,rows,p.unit*2dotab.r=rowNum[r]:tag'td'localinterval=((r-bumps-1)/(p.unit*2))%4ifinterval%2==0then--col.t and col.t2 control whether lines are drawncol.t=col.t2orskipMatch[col.tot+col.n/2+1]and3or((skipMatch[col.top]and1or0)+(skipMatch[col.top+1]and2or0))col.n=col.n+2col.t2=skipMatch[col.tot+col.n/2+1]and3or((skipMatch[col.top+col.n]and1or0)+(skipMatch[col.top+col.n+1]and2or0))ifcol.t==0thentab.r:attr{rowspan=maxSpan(p.unit*2,r,rows)}:css(skipMatch[col.tot+col.n/2]and{}or{border=p.reuseStr.solid,['border-left']=0})elsetab.r:attr{rowspan=maxSpan(p.unit,r,rows)}:cssText(col.t==2andp:saveStr('topRight','border-width:',tab.line[2],' 0 0;border-style:solid')orcol.t==1and(nodeFunc.bridge.lay[c](col.n-2)andp:saveStr('right',';border-right:',p.reuseStr.solid)or'vertical-align:bottom')ornil):node(col.t==1andinterval>0andnotnodeFunc.bridge.lay[c](col.n-2)andp.cornerDiv)rowNum[r+(p.branch_upwardsand(4-bump)orp.unit)]:tag'td':attr{rowspan=maxSpan(p.unit,r+p.unit,rows)}:cssText(col.t==1andp:saveStr('bttmRght','border-width:0 ',tab.line[2],' 0;border-style:solid')orcol.t==2and(nodeFunc.bridge.lay[c](col.n+2)andp:saveStr('right',';border-right:',p.reuseStr.solid)or'vertical-align:top')ornil):node(col.t==2andinterval~=2andnotnodeFunc.bridge.lay[c](col.n+2)andp.cornerDiv)endcol.t={col.t<3,rowNum[r+p.unit*5]andcol.t2<3orfalse}rowNum[r+(p.branch_upwardsorp.unit)]:tag'td':attr{rowspan=maxSpan(p.unit*4,r+(p.branch_upwardsand(4-bump)orp.unit),rows)}:css(interval==0and(col.t[1]orcol.t[2])and{['border-width']=table.concat{tab.line[1][col.t[1]],' 0 ',tab.line[1][col.t[2]]},['border-style']='solid'}or{})elsetab.r:attr{rowspan=maxSpan(p.unit*2,r,rows)}:css(nodeFunc.bridge.lay[c](col.n)and{['border-right']=p.reuseStr.solid}or{})endendendendlocallock_height=(head_br.countor0)+1returnargs.scroll_heightandmw.html.create'div':cssText'border-bottom:1px solid #eee;display:inline-block':node(not(p.scroll_head_unlockorp.no_column_head)andmw.html.create'div':css{overflow='hidden',height=lock_height*1.4+1.6..'em',['border-bottom']='inherit',['margin-right']='17px'}:node(mw.clone(tab))):tag'div':css{['overflow-y']='scroll',['max-height']=tonumber(args.scroll_height,10)andargs.scroll_height..'px'orargs.scroll_height}:node(not(p.scroll_head_unlockorp.no_column_head)andtab:css{['margin-top']=math.floor(-10*(lock_height*1.4+1.6)/(fontSizeor.9))/10..'em',['padding-top']='-3px'}ortab):done()ortabend--[[local standard = { 'beta' = { bold_winner = 'high', omit_blanks = 'yes', auto_3rd = 'yes' }}--]]functionp.main(frame,columns)localargs=require'Module:Arguments'.getArgs(frame,{trim=false})args.columns=args.columnsorcolumnsreturnp._main(args)endfunctionp.seed(frame)localparent=frame:getParent()orframelocalfunctionarg(k,alt)returnparent.args[k]orframe.args[k]oraltendlocalpadding,width=arg(2,p.teamBoxPadding()),arg(3,arg('widescore')and40or30)padding=tonumber(padding)andtonumber(padding)..'px'orpaddingwidth=tonumber(width)andtonumber(width)..'px'orwidthreturnmw.html.create'div':css{margin=('-1px %s -1px -0.7ex'):format(padding,padding),float='left',['background-color']=p.bgColor.head,border='1px solid #aaa',color=p.textColor.head,['text-align']='center',width=width}:wikitext(arg(1,' '))endreturnp