--[==[
To inspect the content of this data module, use [[Special:ExpandTemplates]]
and enter the following input text:
  {{#invoke:Road data/dump|dump|module=Module:<name-of-this-module>}}

To inspect the content of this data module when editing, enter the following
into the Debug console:
  local util = require("Module:Road data/util")
  print(util.arrayToString(p))
]==]

--Maine

local ME = require("Module:Road data/strings/USA")
local format = mw.ustring.format
local util = require("Module:Road data/util")

local suffix = " ([dab||%dab%, |]Maine)"

ME.I.link = {
	["95"] = "Interstate 95 in Maine",
	["495"] = "[dab||Maine Turnpike|Falmouth Spur]",
	default = "Interstate %route% (Maine)"
	
}

for k, v in pairs(ME) do if k:find ("^I") then 
	v.link = ME.I.link
	end
end

ME.US.link = ME.US.base .. " [dab||(%dab%, Maine)|in Maine]"

for k, v in pairs(ME) do if k:find ("^US %d") then 
	v.name = ME.US.name
	v.link = ME.US.link
	end
end

for _,auxType in ipairs({"Alt", "Bus", "Byp", "City", "Conn", "Emerg", "Opt", "Scenic", "Spur", "Temp", "Toll", "Truck"}) do
	local spec = ME[" aux "][auxType]
		for k, v in pairs(ME) do if k:find (auxType) then if k:find ("^US") then
			v.link = ME.US.base .. " " .. spec.name .. suffix
			end
		end
	end
end

ME.SR = {
	shield = "Maine %route%.svg",
	name = "State Route %route%",
	base = "Maine State Route %route%",
	link = "Maine State Route %route%",
	abbr = "SR&nbsp;%route%",
	maint = maint,
	width = "expand"
}
ME.ME = ME.SR

for _,type in ipairs({"SR", "ME"}) do
	for _,year in ipairs({"1926", "1951"}) do
		ME[type .. " " .. year] = {
			shield = format("Maine %%route%% %s.svg", year),
			name = ME.ME.name,
			link = ME.ME.link,
			abbr = ME.ME.abbr,
			width = "square"
		}
	end
end

for _,type in ipairs({'SR', 'ME'}) do
	for _,auxType in ipairs({"Alt", "Bus", "Byp", "Spur","Truck"}) do
		local spec = ME[" aux "][auxType]
		ME[type .. "-" .. auxType] = {
			shield = ME[type].shield,
			name = ME.SR.name .. " " .. spec.name,
			link = ME.SR.base .. " " .. spec.name .. ME[" dab "],
			abbr = ME.SR.abbr .. " " .. spec.abbrsuffix,
			banner = spec.bannerprefix .. " plate.svg",
			aux = spec.aux,
			width = "expand",
		}
	end
end

-- add new types above this line if you want it to have the state highway browse and maint
for k, v in pairs(ME) do if k:find ("^%a") then
	v.maint = "[[Maine Department of Transportation|MaineDOT]]"
	v.browse = "[[Maine State Highway System]]"
	v.browselinks = {
		[1] = "[[List of Interstate Highways in Maine|Interstate]]",
		[2] = "[[List of U.S. Highways in Maine|US]]",
		[3] = "[[List of state routes in Maine|State]]",
		[4] = "[[List of auto trails in Maine|Auto trails]]",
		[5] = "[[List of lettered highways in Maine|Lettered]]"
	}
	end
end

ME.METP = {
	shield = "Maine Turnpike sign.svg",
	name = "Maine Turnpike",
	link = "Maine Turnpike",
	abbr = "Maine Turnpike",
	bannersuffix = "green",
	maint = "[[Maine Turnpike Authority]]"
}

ME.NB = {alias = {module = "CAN/NB", type = "NB"}}
ME.QC = {alias = {module = "CAN/QC", type = "Route"}}
ME.A = {alias = {module = "CAN/QC", type = "A"}}

return ME