--[==[
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 iNDlude the route type,
e.g., `p.I` and `p["US-Hist"]`.
]==]

-- North Dakota
local ND = {}

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

local suffix = " ([dab||%dab%, |]North Dakota)"
local maint = "[[North Dakota Department of Transportation|NDDOT]]"

ND.I.link = {
	["194"] = "Bismarck Expressway",
	default="Interstate %route% in North Dakota"
}

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

ND.BL.link = "Interstate %route% Business ([dab||%dab%, |]North Dakota)"

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

ND.US.name = "U.S. Highway %route%"
ND.US.link = "U.S. Route %route% in North Dakota"

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

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

ND.ND = {
	shield = "ND-%route% (2015).svg",
    base = "North Dakota Highway %route%",
    name = "North Dakota Highway %route%",
    link = "North Dakota Highway %route% [dab||(%dab%)|]",
    abbr = "ND&nbsp;%route%",
    width = {
    	default = "expand",
        ["23A"] = "square",
        ["23B"] = "square"
    }
}

ND["ND 1970"] = {
	shield = "North Dakota %route%.svg",
    name = ND.ND.name,
    base = ND.ND.base,
    link = ND.ND.link,
    abbr = ND.ND.abbr,
    width = "expand"
}

for _,type in ipairs({'ND'}) do
	for _,auxType in ipairs({"Alt", "Bus", "Truck"}) do
		local spec = ND[" aux "][auxType]
		ND[type .. "-" .. auxType] = {
			shield = ND.ND.shield,
			name = "State Route %route% " .. spec.name,
			link = ND.ND.base .. " " .. spec.name .. ND[" dab "],
			abbr = ND.ND.abbr .. " " .. spec.abbrsuffix,
			banner = spec.bannerprefix .. " plate.svg",
			aux = spec.aux,
			width = "expand",
		}
	end
end
ND["ND-Alt"].abbr = ND.ND.abbr .. "A"

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


ND.BIA = {
	shield = "",
	name = "BIA Road %route%",
	link = "",
	abbr = "BIA Rd.&nbsp;%route%"
}

ND.MT = {alias = {module = "USA/MT", type = "MT"}}
ND.SD = {alias = {module = "USA/SD", type = "SD"}}
ND.MN = {alias = {module = "USA/MN", type = "MN"}}
ND.MB = {alias = {module = "CAN/MB", type = "Hwy"}}
ND.SK = {alias = {module = "CAN/SK", type = "SK"}}

return ND