--[==[
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))
To inspect a particular route type, change `p` above to include the route type,
e.g., `p.I` and `p["US-Hist"]`.
]==]

-- Connecticut
local CT = {}

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

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

CT.I.link = {
	["384"] = "Interstate 384",
	["395"] = "Interstate 395 (Connecticut–Massachusetts)",
	["684"] = "Interstate 684",
	["691"] = "Interstate 691",
	default = {
		hook = "split",
		split = 100,
		above = "Interstate %route% (Connecticut)",
		below = "Interstate %route% in Connecticut"
	}
}
        
for k, v in pairs(CT) do if k:find ("^I") then 
	v.link = CT.I.link
	end
end
                
CT.US.link = {
	["1"] = "U.S. Route 1 in Connecticut",
	["5"] = "U.S. Route 5 in Connecticut",
	["6"] = "U.S. Route 6 in Connecticut",
	["7"] = "U.S. Route 7 in Connecticut",
	["202"] = "U.S. Route 202 in Connecticut",
	default = "U.S. Route %route% [dab||(%dab%, Connecticut)|]"
}

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

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

CT.CT = {
	base = "Connecticut Route %route%",
	shield = {
		hook = "splitlen",
		split = 3,
		above = "Connecticut Highway %route% wide.svg",
		below = "Connecticut Highway %route%.svg",
	},
	shieldmain = {
		["75"] = {"Connecticut Highway %route%.svg", "MA Route %route%.svg"},
		["83"] = {"Connecticut Highway %route%.svg", "MA Route %route%.svg"},
		["109"] = {"Connecticut Highway %route%.svg", "MA Route %route%.svg"},
		["131"] = {"Connecticut Highway %route%.svg", "MA Route %route%.svg"},
		["159"] = {"Connecticut Highway %route%.svg", "MA Route %route%.svg"},
		["168"] = {"Connecticut Highway %route%.svg", "MA Route %route%.svg"},
		["169"] = {"Connecticut Highway %route%.svg", "MA Route %route%.svg"},
		["186"] = {"Connecticut Highway %route%.svg", "MA Route %route%.svg"},
		["187"] = {"Connecticut Highway %route%.svg", "MA Route %route%.svg"},
		["189"] = {"Connecticut Highway %route%.svg", "MA Route %route%.svg"},
		["192"] = {"Connecticut Highway %route%.svg", "MA Route %route%.svg"},
		["193"] = {"Connecticut Highway %route%.svg", "MA Route %route%.svg"},
		["197"] = {"Connecticut Highway %route%.svg", "MA Route %route%.svg"},
		["198"] = {"Connecticut Highway %route%.svg", "MA Route %route%.svg"},
		["220"] = {"Connecticut Highway %route%.svg", "MA Route %route%.svg"},
		default = "Connecticut Highway %route%.svg",
	},
	name = "Route %route%",
	link = "Connecticut Route %route%",
	abbr = "Route&nbsp;%route%",
	width = "expand"
}

CT.Route = CT.CT

for _,year in ipairs({"1926", "1948", "1956", "1963"}) do
	CT["CT " .. year] = {
		shield = format("CT %%route%% (%s).svg", year),
		name = CT.CT.name,
		link = CT.CT.link,
		abbr = CT.CT.abbr,
		width = "square",
	}
end

CT["CT 1963"].shield = "Connecticut Highway %route%.svg"
				 
CT.CTTP = {
	shield = "", -- Conn Tpk.gif
	name = "Gov. John Davis Lodge Turnpike",
	link = "Connecticut Turnpike",
	abbr = "Conn. Turnpike",
}

CT.Merritt = {
	shield = "Merritt Pkwy Shield.svg",
	shieldmain = {"Merritt Pkwy Shield.svg", "Connecticut Highway 15.svg"},
	name = "Merritt Parkway",
	link = "Merritt Parkway",
	abbr = "Merritt Parkway",
	bannersuffix = "blue"
}

CT.SSR = {
	name = "Special Service Road %route%",
	link = {
		ifexists = true,
		default = "Special Service Road %route% (Connecticut)",
		otherwise = "List of Special Service Roads in Connecticut#SSR0%route%"
	},
	abbr = "SSR %route%"
}
          
CT.SR = {
	name = "State Road %route%",
	link = {
		ifexists = true,
		default = CT.CT.link,
		otherwise = "List of State Roads in Connecticut#SR0%route%"
	},
	abbr = "SR %route%"
}

-- add new types above this line if you want it to have the state highway browse and maint
for k, v in pairs(CT) do if k:find ("^%a") then
	v.maint = "[[Connecticut Department of Transportation|CTDOT]]"
	v.browse = "Routes in Connecticut"
	v.browselinks = {
		[1] = "[[List of Interstate Highways in Connecticut|Interstate]]",
		[2] = "[[List of U.S. Highways in Connecticut|US]]",
		[3] = "[[List of state routes in Connecticut|State]]",
		[4] = "[[List of Special Service Roads in Connecticut|SSR]]",
		[5] = "[[List of State Roads in Connecticut|SR]]"
	}
	end
end
		 
return CT