--[==[
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))
]==]

--Colorado
local CO = require("Module:Road data/strings/USA")

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

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

CO.I.link = {
	["76"] = "Interstate 76 (Colorado–Nebraska)",
	["225"] = "Interstate 225",
	["270"] = "Interstate 270 (Colorado)",
	["425"] = "Interstate 425",
	["470"] = "Interstate 470 (Colorado)",
	default = "Interstate %route% in Colorado"
}

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

CO.BL.link = "Interstate %route% Business ([dab||%dab%, |]Colorado)"
CO.BS.link = CO.BL.link

for k, v in pairs(CO) do if k:find ("^B%a") then 
	v.link = CO.BL.link
	end
end

CO.US.name = "U.S. Highway %route%"
CO.US.link = {
	["138"] = "U.S. Route 138",
	["350"] = "U.S. Route 350",
	["400"] = "U.S. Route 400",
	["491"] = "U.S. Route 491",
	["550"] = "U.S. Route 550",
	["650"] = "U.S. Route 650",
	default = "U.S. Route %route% in Colorado"
}

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

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

for _,year in ipairs({'1948', '1961'}) do
	for _,auxType in ipairs({"Alt", "Bus", "Byp", "Conn", "Opt", "Scenic", "Spur", "Temp", "Truck"}) do
		local type = "US" .. " ".. year
		local spec = CO[" aux "][auxType]
		CO[type .. "-" .. auxType] = {
			shield = CO[type].shield,
			shieldmain = CO[type].shieldmain,
			name = CO[type].name .. " " .. spec.name,
			link = CO[type].base .. " " .. spec.name .. suffix,
			abbr = CO[type].abbr .. " " .. spec.abbrsuffix,
			banner = spec.bannerprefix .. " plate" .. year .. ".svg",
			aux = spec.aux,
			width = CO[type].width
		}
	end
end


CO.SH = {
	base = "Colorado State Highway %route%",
	shield = {
		hook = "splitlen",
		split = 3,
		above = "Colorado %route% wide.svg",
		below = "Colorado %route%.svg",
	},
	shieldmain = {
		default = {
			hook = "splitlen",
			split = 3,
			above = "Colorado %route% wide.svg",
			below = "Colorado %route%.svg",
		},
		["65"] = {"Colorado %route%.svg", "Colorado Scenic Byway.png"},
	},
	name = "State Highway %route%",
	link = "Colorado State Highway %route% [dab||(%dab%)|]",
	abbr = "SH&nbsp;%route%",
	width = "expand"
}

CO.CO = CO.SH

for _,type in ipairs({'SH', 'CO'}) do
	for _,year in ipairs({"1926", "1946", "1952", "1969"}) do
		CO[type .. " " .. year] = {
			shield = format("Colorado %%route%% (%s).svg", year),
			name = CO.SH.name,
			link = CO.SH.link,
			abbr = CO.SH.abbr,
			width = "square",
		}
	end
end

CO["SH 1969"].shield = "Colorado %route%.svg"
CO["CO 1969"].shield = CO["SH 1969"].shield

for _,type in ipairs({'SH', 'CO'}) do
	for _,auxType in ipairs({"Alt", "Bus", "Byp", "Conn", "Spur", "Truck"}) do
		local spec = CO[" aux "][auxType]
		CO[type .. "-" .. auxType] = {
			shield = CO.SH.shield,
			name = CO.SH.name .. " " .. spec.name,
			link = CO.SH.base .. " " .. spec.name .. CO[" dab "],
			abbr = CO.SH.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(CO) do if k:find ("^%a") then
	v.maint = "[[Colorado Department of Transportation|CDOT]]"
	end
end

CO.E = {
	shield = "E%route%.svg",
	name = "E-%route%",
    link = "E-%route%",
    abbr = "E-%route%",
	maint = "E-470 Public Highway Authority"
}

CO.NW = {
	shield = "NorthwestParkwayLogo.svg",
	name = "Northwest Parkway",
    link = "Northwest Parkway",
    abbr = "Northwest Parkway",
	maint = "Northwest Parkway Public Highway Authority"
}

CO.AZ = {alias = {module = "USA/AZ", type = "SR"}}
CO.KS = {alias = {module = "USA/KS", type = "K"}}
CO.NE = {alias = {module = "USA/NE", type = "N"}}
CO["I-NE"] = {alias = {module = "USA/NE", type = "I"}}
CO.NM = {alias = {module = "USA/NM", type = "NM"}}
CO.OK = {alias = {module = "USA/OK", type = "SH"}}
CO.UT = {alias = {module = "USA/UT", type = "UT"}}
CO.WY = {alias = {module = "USA/WY", type = "WY"}}

return CO