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

-- Delaware
local DE = {}

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

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

DE.I.link = "Interstate %route% (Delaware)"
DE["I-Alt"].banner = "Alt plate blue.svg"

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

DE.US.link = "U.S. Route %route% in Delaware"

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

for _,auxType in ipairs({"Alt", "Bus", "Byp", "City", "Conn", "Emerg", "Opt", "Scenic", "Spur", "Temp", "Toll", "Truck"}) do
	local spec = DE[" aux "][auxType]
		for k, v in pairs(DE) do if k:find (auxType) then if k:find ("^US") then
			v.link = DE.US.base .. " " .. spec.name .. " ([dab||%dab%, |]Delaware)"
			v.banner = spec.banneralt .. " plate.svg"
			end
		end
	end
end
DE["US-Toll"].link = DE.US.link
DE["US-Toll"].banner = "Toll plate yellow.svg"
DE["US 1961"].bannersuffix = "1961"

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

DE.SR = {
	base = "Delaware Route %route%",
	shield = {
		hook = "splitlen",
		split = 3,
		above = "Ellipse sign %route%.svg",
		below = "Elongated circle %route%.svg"
	},
	shieldmain = {
		["261"] = {"Ellipse sign %route%.svg", "PA-%route%.svg"},
		default = {
			hook = "splitlen",
			split = 3,
			above = "Ellipse sign %route%.svg",
		below = "Elongated circle %route%.svg"
		}
	},
	name = {
		["261"] = "Route %route%",
		default = "Delaware Route %route%"
	},
	link = "Delaware Route %route% [dab||(%dab%)|]",
	abbr = "DE&nbsp;%route%",
	width = "expand"
}

DE.DE = DE.SR

for _,type in ipairs({'SR', "DE"}) do
	for _,auxType in ipairs({"Alt", "Bus", "Byp", "Conn", "Opt", "Scenic", "Spur", "Temp", "Toll", "Truck"}) do
		local spec = DE[" aux "][auxType]
		DE[type .. "-" .. auxType] = {
			shield = DE.SR.shield,
			name = DE.SR.name.default .. " " .. spec.name,
			link = DE.SR.base .. " " .. spec.name .. DE[" dab "],
			abbr = DE.SR.abbr .. " " .. spec.abbrsuffix,
			banner = spec.banneralt .. " plate.svg",
			aux = spec.aux,
			width = "expand",
		}
	end
end
DE["SR-Toll"].banner = "Toll plate yellow.svg"
DE["DE-Toll"].banner = DE["SR-Toll"].banner

for _,type in ipairs({'SR', "DE"}) do
	for _,year in ipairs({"1926", "1955", "1964", "1970", "1978"}) do
		DE[type .. " " .. year] = {
			shield = format("Delaware %%route%% %s.svg", year),
			name = DE.SR.name.default,
			link = DE.SR.link,
			abbr = DE.SR.abbr,
			width = "square",
		}
	end
end
DE["SR 1926"].orientation = "upright"
DE["DE 1926"].orientation = "upright"
DE["SR 1955"].orientation = "upright"
DE["DE 1955"].orientation = "upright"
DE["SR 1970"].shield = "Circle sign %route%.svg"
DE["DE 1970"].shield = "Circle sign %route%.svg"
DE["SR 1978"].shield = {
	hook = "splitlen",
	split = 3,
	below = "Circle sign %route%.svg",
	above = "Elongated circle %route%.svg"
}
DE["DE 1978"].shield = DE["SR 1978"].shield
DE["SR 1978"].width = DE.SR.width
DE["DE 1978"].width = DE.SR.width
DE["SR 1926"].bannersuffix = "1926"
DE["DE 1926"].bannersuffix = "1926"
DE["SR 1955"].bannersuffix = "1961"
DE["DE 1955"].bannersuffix = "1961"
DE["SR 1964"].bannersuffix = "1961"
DE["DE 1964"].bannersuffix = "1961"
				  
DE["SR 1978-Alt"] = {
	shield = DE["SR 1978"].shield,
	name = DE["SR-Alt"].name,
	link = DE["SR-Alt"].link,
	abbr = DE["SR-Alt"].abbr,
	banner = "Alt plate.svg",
	width = "expand"
} 
DE["DE 1978-Alt"] = DE["SR 1978-Alt"]

DE.DETP = {
	shield = "Delaware Turnpike logo.png",
	name = "Delaware Turnpike",
	link = "Delaware Turnpike",
	abbr = "Delaware Turnpike",
	width = 29
}
         
DE.Byway = {
	shield = "Delaware Byways.png",
	name = "%route%",
	link = "%route%",
	abbr = "%route%",
	color = "hist"
}

DE.SBR = {
	shield = "US Bike %route% (M1-8).svg",
	name = "Bike Route %route%",
	link = "Delaware Bicycle Route %route%",
	abbr = "Bike Route %route%",
	orientation = "upright"
}

-- add new types above this line if you want it to have the state highway browse and maint
for k, v in pairs(DE) do if k:find ("^%a") then
	v.maint = "[[Delaware Department of Transportation|DelDOT]]"
	v.browse = "[[Delaware State Route System]]"
	v.browselinks = {
		[1] = "[[List of numbered routes in Delaware|List]]",
		[2] = "[[Delaware Byways|Byways]]"
	}
	end
end

DE.DEMD = {
	shield = {"MD Route %route%.svg", DE.SR.shield},
	name = "Route %route%",
	link = "Route %route% (Delaware–Maryland)",
	abbr = "Route&nbsp;%route%",
	width = 40
}

DE.NJTP = {alias = {module = "USA/NJ", type = "NJTP"}}
DE.MD = {alias = {module = "USA/MD", type = "MD"}}

return DE