-- Implements টেমপ্লেট:ফুটবল বাক্স-এর জন্য local p = {} local lang = nil local delink = require('মডিউল:Delink')._delink local eventschema = "http://schema.org/SportsEvent" local teamschema = "http://schema.org/SportsTeam" local placeschema = "http://schema.org/Place" local penalties = 'পেনাল্টি' local aet = 'অ.স.প.' local asdet = 'আ.মৃ.অ.স.প.' local agget = 'অ.স.প./গো.গো.' local asget = 'অ.স.প./সি.গো.' local attendance = 'দর্শক সংখ্যা:' local referee = 'রেফারি:' local templatestyles = 'মডিউল:ফুটবল বাক্স/শৈলী.css'  local tracking, preview  local function checkarg(k,v) 	if not k or type(k) ~= 'string' or 'স্ট্রিং' then return end 	 	if  k == 'assistantreferees2'or k == 'সহকারীরেফারি২' then 		table.insert(tracking, '২') 	elseif k == 'aggregatescore' or k == 'assistantreferees' or  			k == 'fourthofficial' or k == 'game' or k == 'motm' or  			k == 'nobars' or k == 'note' or k == 'result' or             k == 'সমষ্টিগতফলাফল' or k == 'সহকারীরেফারি' or  			k == 'চতুর্থরেফারি' or k == 'খেলা' or k == 'ম্যাচসেরা' or  			k == 'দন্ডহীন' or k == 'টীকা' or k == 'ফল' then 		-- valid and tracked 		table.insert(tracking, 'বিষয়শ্রেণী:' .. k .. 'সহ ফুটবল বাক্স ব্যবহার করা পাতা') 	elseif k == 'size' or k == 'bg' or k == 'id' or k == 'event' or 		k == 'date' or k == 'time' or k == 'round' or k == 'team1' or  		k == 'team2' or k == 'score1' or k == 'score2' or k == 'score' or k == 'scorenote' or 		k == 'aet' or k == 'asdet' or k == 'agget' or k == 'asget' or k == 'goals1' or k == 'report' or k == 'goals2' or  		k == 'penaltyscore' or k == 'penalties1' or k == 'penalties2' or  		k == 'stadium' or k == 'location' or k == 'attendance' or  		k == 'referee' or k == 'stack' or k == 'section' or k == 'transcludesection' or                  k == 'আকার' or k == 'পটভূমি' or k == 'সূত্র' or k == 'প্রতিযোগিতা' or  		k == 'তারিখ' or k == 'সময়' or k == 'পর্ব' or k == 'দল১' or  		k == 'দল২' or k == 'ফল১' or k == 'ফল২' or k == 'ফলাফল' or k == 'ফলাফলটীকা' or 		k == 'অসপ' or k == 'আমৃঅসপ' or k == 'গোগোঅসপ' or k == 'সিগোঅসপ' or k == 'গোল১' or k == 'প্রতিবেদন' or k == 'গোল২' or  		k == 'পেনাল্টিফলাফল' or k == 'পেনাল্টি১' or k == 'পেনাল্টি২' or  		k == 'মাঠ' or k == 'অবস্থান' or k == 'দর্শক' or  		k == 'রেফারি'  or k == 'স্তূপ' or k == 'অনুচ্ছেদ' or k == 'অন্তর্ভূক্তিঅনুচ্ছেদ' then 		-- valid and not tracked 	else 		-- invalid 		local vlen = mw.ustring.len(k) 		k = mw.ustring.sub(k, 1, (vlen < 25) and vlen or 25)  		k = mw.ustring.gsub(k, '[^%w%-_ ]', '?') 		table.insert(tracking, '' .. k .. '') 		table.insert(preview, '"' .. k .. '"') 	end end  local function timestamp(d, t) 	if not d then return nil end 	 	lang = lang or mw.language.getContentLanguage() -- lazy initialize 	local success, timestamp = pcall(lang.formatDate, lang, 'c', delink({d .. ' ' .. (t or )})) 	if success then 		return timestamp 	else 		return nil 	end end  local function fmtlist(s) 	s = mw.ustring.gsub(s or , '%[%[ *([%?-]) *%]%]', '%1') 	s = mw.ustring.gsub(s, '%[%[ *[%?-] *| *(.-) *%]%]', '%1') 	if mw.ustring.sub(s, 1, 1) == '*' then 		-- could also expand plainlist here 		return mw.getCurrentFrame():extensionTag{ 			name = 'templatestyles', args = { src = 'Plainlist/styles.css' } 		} .. tostring(  mw.html.create('div'):addClass('plainlist'):newline():wikitext(s)) 	end 	return s end  local function makelink(s,t) 	if s:match('^[Hh][Tt][Tt][Pp][Ss]?:[^ ]*$') then 		return '[' .. s .. ' ' .. t .. ']' 	end 	return s end  local function trim(s) 	return s:match('^[\'"%s]*(.-)[\'"%s]*$') end  local function getid(s) 	s = trim(s or ) 	if s and s ~=  then 		return s 	end 	return nil end  local function makeanchor(s) 	s = mw.ustring.gsub(s, '%[%[[Ff][Ii][Ll][Ee]:[^%[%]]*%]%]', ) 	s = mw.ustring.gsub(s, '<[Ss][Pp][Aa][Nn][^<>]*>', ) 	s = mw.ustring.gsub(s, '</[Ss][Pp][Aa][Nn][^<>]*>', ) 	s = mw.ustring.gsub(s, '<[Aa][Bb][Bb][Rr][^>]*>([^<]*)</[Aa][Bb][Bb][Rr]>', '%1') 	s = mw.ustring.gsub(s, '[\'"]', ) 	s = mw.ustring.gsub(s, '%s* %s*', ' ') 	s = mw.ustring.gsub(s, '%[%[[^%[%]%|]*%|([^%[%]]*)%]%]', '%1') 	s = mw.ustring.gsub(s, '%[%[([^%[%]]*)%]%]', '%1') 	s = mw.ustring.gsub(s, '\127[^\127]*UNIQ%-%-[^\127]*%-%x+%-QINU[^\127]*\127', ) 	s = mw.ustring.gsub(s, '<[Ss][Uu][Pp]>[^<>]*</[Ss][Uu][Pp]>', ) 	s = mw.ustring.gsub(s, '%s%s*', ' ') 	return s end  local function checkTitle()     local pageTitle = mw.title.getCurrentTitle().text     local titlePhrases = {         "গ্রুপ পর্ব", "নকআউট পর্ব", "নকআউট পর্যায়", "ফাইনাল পর্যায়", "লিগ পর্যায়", "ক্লাব বিশ্বকাপ",         "পর্ব", "লিগ পর্ব", "বছাই", "বাছাইপর্ব", "প্লে%-অফ", "নেশনস লিগ", "আন্তক্লাব"     }          for _, phrase in ipairs(titlePhrases) do         if mw.ustring.match(mw.ustring.lower(pageTitle), phrase) then             return true         end     end          return false end  function p.main(frame) 	-- Exit early if we are using section transclusion for a different section 	local tsection = frame:getParent().args['transcludesection'] or frame:getParent().args['section'] or 	local bsection = frame.args['section'] or  	if( tsection ~=  and bsection ~=  ) then 		if( tsection ~= bsection ) then 			return 		end 	end  	local args = require('মডিউল:Arguments').getArgs(frame)         args['সূত্র'] = args['সূত্র'] or args['id']         args['তারিখ'] = args['তারিখ'] or args['date']         args['সময়'] = args['সময়'] or args['time']         args['প্রতিযোগিতা'] = args['প্রতিযোগিতা'] or args['event']         args['পর্ব'] = args['পর্ব'] or args['round']         args['দল১'] = args['দল১'] or args['team1']         args['দল২'] = args['দল২'] or args['team2']         args['ফল১'] = args['ফল১'] or args['score1']         args['ফল২'] = args['ফল২'] or args['score2']         args['ফল২'] = args['ফল২'] or args['score2']         args['ফলাফল'] = args['ফলাফল'] or args['score']         args['ফলাফলটীকা'] = args['ফলাফলটীকা'] or args['scorenote']         args['অসপ'] = args['অসপ'] or args['aet']         args['আমৃঅসপ'] = args['আমৃঅসপ'] or args['asdet']         args['গোগোঅসপ'] = args['গোগোঅসপ'] or args['agget']         args['সিগোঅসপ'] = args['সিগোঅসপ'] or args['asget']         args['প্রতিবেদন'] = args['প্রতিবেদন'] or args['report']         args['গোল১'] = args['গোল১'] or args['goals1']         args['গোল২'] = args['গোল২'] or args['goals2']         args['পেনাল্টি১'] = args['পেনাল্টি১'] or args['penalties1']         args['পেনাল্টি২'] = args['পেনাল্টি২'] or args['penalties2']         args['পেনাল্টিফলাফল'] = args['পেনাল্টিফলাফল'] or args['penaltyscore']         args['মাঠ'] = args['মাঠ'] or args['stadium']         args['অবস্থান'] = args['অবস্থান'] or args['location']         args['দর্শক'] = args['দর্শক'] or args['attendance']         args['রেফারি'] = args['রেফারি'] or args['referee'] 	local id = getid(args['সূত্র']) 	local d = timestamp(args['তরিখ'], args['সময়']) 	local block 	 	tracking, preview = {}, {}     for k, v in pairs(args) do     	if v ~=  then     		checkarg(k,v)     	end 	end  	local score = 'বনাম' 	if args['ফল১'] or args['ফল২'] then 		score = (args['ফল১'] or '0') .. '–' .. (args['ফল২'] or '0') 	elseif args['ফলাফল'] and args['ফলাফল'] ~=  then 		score = args['ফলাফল'] 	end 	if args['অসপ'] then 		score = score .. ' (' .. aet .. ')' 	elseif args['আমৃঅসপ'] then 		score = score .. ' (' .. asdet .. ')' 	elseif args['গোগোঅসপ'] then 		score = score .. ' (' .. agget .. ')' 	elseif args['সিগোঅসপ'] then 		score = score .. ' (' .. asget .. ')' 	end 	if args['ফলাফলটীকা'] then 		score = score .. '' .. args['ফলাফলটীকা'] 	end 	 	-- Generate an anchor 	if id and id == 'প্রতিযোগিতা' and args['প্রতিযোগিতা'] then 		id = makeanchor(args['প্রতিযোগিতা']) 	end 	if (id and id == 'সয়ংক্রিয়') or (not id and checkTitle()) then 		id = makeanchor((args['দল১'] or 'দল ১') .. ' v ' .. (args['দল২'] or 'দল ২')) 	end 	 	-- Start box 	local root =  		mw.html.create('div') 			:attr('itemscope', ) 			:attr('itemtype', eventschema) 			:addClass('footballbox') 			:css('width', args['আকার']) 			:css('background-color', args['পটভূমি']) 			:attr('id', id) 	root:newline() 	 	if args['প্রতিযোগিতা'] then 		root:tag('div') 			:addClass('ftitle') 			:wikitext(args['প্রতিযোগিতা']) 	end 	 	-- Start left block 	block = root:tag('div') 		:addClass('fleft') 	 	local timetag = block:tag('time') 		:attr('itemprop', d and 'startDate' or nil) 		:attr('datetime', d) 		 	timetag:tag('div') 		:addClass('fdate') 		:wikitext(args['তারিখ']) 	 	if args['সময়'] then 		timetag:tag('div') 			:addClass('ftime') 			:wikitext(args['সময়']) 	end 	 	if args['পর্ব'] then 		block:tag('div') 			:addClass('frnd') 			:wikitext(args['পর্ব']) 	end 	-- End block 	 	-- Start table 	local rtable = root:tag('table') 		:addClass('fevent') 	local row = rtable:tag('tr') 		:attr('itemprop', 'name') 	row:newline() 	row:tag('th') 		:addClass('fhome') 		:attr('itemprop', 'homeTeam') 		:attr('itemscope', ) 		:attr('itemtype', teamschema) 		:tag('span') 			:attr('itemprop', 'name') 			:wikitext(args['দল১']) 	row:tag('th') 		:addClass('fscore') 		:wikitext(score) 	row:tag('th') 		:addClass('faway') 		:attr('itemprop', 'awayTeam') 		:attr('itemscope', ) 		:attr('itemtype', teamschema) 		:tag('span') 			:attr('itemprop', 'name') 			:wikitext(args['দল২'])  	row = rtable:tag('tr') 		:addClass('fgoals') 		:newline() 	row:tag('td') 		:addClass('fhgoal') 		:wikitext(fmtlist(args['গোল১'])) 	row:newline() 	row:tag('td') 		:wikitext(makelink(args['প্রতিবেদন'] or , 'প্রতিবেদন')) 	row:newline() 	row:tag('td') 		:addClass('fagoal') 		:wikitext(fmtlist(args['গোল২'])) 	row:newline()	 	 	if args['পেনাল্টিফলাফল'] then 		rtable 			:tag('tr') 				:tag('th') 					:attr('colspan', 3) 					:wikitext(penalties) 		row = rtable:tag('tr') 			:addClass('fgoals') 		row:newline() 		row:tag('td') 			:addClass('fhgoal') 			:wikitext(fmtlist(args['পেনাল্টি১'])) 		row:newline() 		row:tag('th') 			:wikitext(args['পেনাল্টিফলাফল']) 		row:newline() 		row:tag('td') 			:addClass('fagoal') 			:wikitext(fmtlist(args['পেনাল্টি২'])) 		row:newline() 	end 	-- End table 	 	-- Start right block 	block = root:tag('div') 		:addClass('fright') 	 	if args['মাঠ'] then 		local sdiv = block:tag('div') 			:attr('itemprop', 'অবস্থান') 			:attr('itemscope', ) 			:attr('itemtype', placeschema) 		if args['অবস্থান'] then 			sdiv:tag('span') 				:attr('itemprop', 'name') 				:wikitext(args['মাঠ']) 			sdiv:wikitext(', ') 			sdiv:tag('span') 				:attr('itemprop', 'ঠিকানা') 				:wikitext(args['অবস্থান']) 		else 			sdiv:tag('span') 				:attr('itemprop', 'নাম ঠিকানা') 				:wikitext(args['মাঠ']) 		end 	end 	 	if args['দর্শক'] then 		block:tag('div'):wikitext(attendance ..' ' .. args['দর্শক']) 	end 	if args['রেফারি'] then 		block:tag('div'):wikitext(referee .. ' ' .. args['রেফারি']) 	end  	local trackstr = (#tracking > 0) and table.concat(tracking, ) or  	if #preview > 0 then 		trackstr = require('মডিউল:If preview')._warning({ 			'Unknown parameters ' .. table.concat(preview, '; ') .. '.' 		}) .. trackstr 	end 	 	return frame:extensionTag{ name = 'templatestyles', args = { src = templatestyles} } .. tostring(root) .. trackstr end  return p