--[==[
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"]`.
]==]

-- Idaho
local ID = {}

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

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

ID.I.link =  {
	["15W"]  = "Interstate 15W (Idaho)",
	["86"]  = "Interstate 86 (Idaho)",
	["180"] = "Interstate 180 (Idaho)",
	["184"] = "Interstate 184",
	default = "Interstate %route% in Idaho"
}

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

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

ID.US.name = "U.S. Highway %route%"
ID.US.link = "U.S. Route %route% in Idaho"

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

for _,auxType in ipairs({"Alt", "Bus", "Byp", "City", "Conn", "Emerg", "Opt", "Scenic", "Spur", "Temp", "Toll", "Truck"}) do
	local spec = ID[" aux "][auxType]
		for k, v in pairs(ID) do if k:find (auxType) then if k:find ("^US") then
			v.name = ID.US.name .. " " .. spec.name
			v.link = ID.US.base .. " " .. spec.name .. suffix
			end
		end
	end
end
         
ID.SH = {
	base = "Idaho State Highway %route%",
	shield = "Idaho %route%.svg",
	name = "State Highway %route%",
	link = "Idaho State Highway %route% [dab||(%dab%)|]",
	abbr = "SH-%route%",
	width = "expand"
	
}
ID.ID = ID.SH

for _,type in ipairs({'SH', "ID"}) do
	for _,year in ipairs({"1926", "1930", "1955", "1980"}) do
		ID["SH " .. year] = {
			shield = format("Idaho %%route%% (%s).svg", year),
			name = ID.SH.name,
			link = ID.SH.link,
			abbr = ID.SH.abbr,
			width = "square",
		}
	end
end
ID["SH 1980"].shield = "ID-%route%.svg"
ID["ID 1980"] = ID["SH 1980"]
ID["SH 1970"] = ID["SH 1955"]

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

ID["SH 1980-Scenic"] = {
	shield = "ID-Scenic-%route%.svg",
	name = "Scenic " .. ID.SH.name,
	link = ID.SH.link,
	abbr = ID.SH.abbr .. " Scenic",
	width = "square"
}

-- add new types above this line if you want it to have the state highway browse and maint
for k, v in pairs(ID) do if k:find ("^%a") then
	v.maint = "[[Idaho Transportation Department|ITD]]"
	v.browse = "[[State Highways in Idaho]]"
	v.browselinks = {
		[1] = "[[List of Interstate Highways in Idaho|Interstate]]",
		[2] = "[[List of U.S. Highways in Idaho|US]]",
		[3] = "[[List of state highways in Idaho|State]]"
	}
	end
end

ID.CR.shield = ""
ID.CR.maint = ""

ID.WA = {alias = {module = "USA/WA", type = "SR"}}
ID.OR = {alias = {module = "USA/OR", type = "OR"}}
ID.NV = {alias = {module = "USA/NV", type = "NV"}}
ID.UT = {alias = {module = "USA/UT", type = "SR"}}
ID.WY = {alias = {module = "USA/WY", type = "WY"}}
ID.MT = {alias = {module = "USA/MT", type = "MT"}}
ID.BC = {alias = {module = "CAN/BC", type = "BC"}}

return ID