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

-- Arizona
local AZ = {}

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

local suffix = " ([dab||%dab%, |]Arizona)"
local maint = "[[Arizona Department of Transportation|ADOT]]"

AZ.I.link = {
	["8"] = "Interstate 8",
	["11"] = "Interstate 11",
	["17"] = "Interstate 17",
	["19"] = "Interstate 19",
	default = {
		hook = "splitlen",
		split = 3,
		above = "Interstate %route% (Arizona)",
		below = "Interstate %route% in Arizona"
	}
}

AZ["I 1957"].shield = "I-%route% (AZ 1957).svg"

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

AZ.BL.link = "Interstate %route% Business" .. suffix
AZ.BL.abbr = "BL&nbsp;%route%"
AZ.BS.link = "Interstate %route% Business Spur" .. suffix
AZ.BS.name = "Interstate %route% Business Spur"
AZ.BS.abbr = "BS&nbsp;%route%"

AZ["BL 1957"].shield = "Business Loop %route% (AZ 1957).svg"
AZ["BL 1957"].name = "Interstate %route% Business"
AZ["BL 1957"].link = AZ.BL.link
AZ["BS 1957"].shield = "Business Spur %route% (AZ 1957).svg"
AZ["BS 1957"].name = "Interstate %route% Business Spur"
AZ["BS 1957"].link = AZ.BS.link

AZ.US.link = "U.S. Route %route% [dab||(%dab%, Arizona)|in Arizona]"

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

AZ["US-Alt"].shield = {
	["89"] = "US %route%A.svg",
	default = AZ.US.shield
	}
AZ["US-Alt"].link = {
	["89"] = "U.S. Route 89A",
	default = "U.S. Route %route% Alternate" .. suffix
}
AZ["US-Alt"].abbr = {
	["89"] = "US&nbsp;89A",
	default = "US&nbsp;%route%&nbsp;Alt."
	}
AZ["US-Alt"].banner = {
	["89"] = "",
	default = "Alternate plate.svg"
}
AZ["US-Temp"].name = AZ.US.name .. "T"
AZ["US-Temp"].abbr = "US&nbsp;%route%T"

AZ["US-Hist"].shieldmain = {
	["66"] = {"US %route% (AZ historic).svg", "MUTCD_D6-4.svg"},
	default = "US %route% (AZ historic).svg"
	}
AZ["US-Hist"].name = {
	default = "Historic U.S. Route %route%",
	["66"] = "Historic Route 66",
	["89A"] = "Jerome–Clarkdale–Cottonwood Historic Road"
	}
AZ["US-Hist"].link = "Historic U.S. Route %route% (Arizona)"
AZ["US-Hist"].orientation = ""
AZ["US-Hist"].width = "expand"

AZ["US 1941"] = {
	shield = AZ["US 1926"].shield,
	shieldmain = AZ["US 1926"].shield
}
--[["US 1941" is only meant for use on major intersection lists depicting alignments or highways after 1941.
Photographs and state highway maps suggest this type of shield was used on guide signage after 1941
while the standard 1926 shield with the state name was used for reassurance markers. ]]

AZ["US Pre-1956"] = AZ["US 1941"]
AZ["US 1948"] = AZ["US 1941"]

AZ["US 1956 W"] = {
	shield = "US %route% Arizona 1956 West.svg"
}

AZ["US 1956 E"] = {
	shield = "US %route% Arizona 1956 East.svg"
}

AZ["US 1956 N"] = {
	shield = "US %route% Arizona 1956 North.svg"
}

AZ["US 1956 S"] = {
	shield = "US %route% Arizona 1956 South.svg"
}

AZ["US 1956"] = {
	shield = "US %route% Arizona 1956.svg"
}

AZ["US 1960 Even"] = {
	shield = {"US %route% (AZ 1960 east).svg", "US %route% (AZ 1960 west).svg"}
}

AZ["US 1960 Odd"] = {
	shield = {"US %route% (AZ 1960 north).svg", "US %route% (AZ 1960 south).svg"}
}

AZ["US 1960 N"] = {
	shield = "US %route% (AZ 1960 north).svg"
}

AZ["US 1960 S"] = {
	shield = "US %route% (AZ 1960 south).svg"
}

AZ["US 1960 W"] = {
	shield = "US %route% (AZ 1960 west).svg"
}

AZ["US 1960 E"] = {
	shield = "US %route% (AZ 1960 east).svg"
}

AZ["US 1963"] = {
    shield = "US %route% 1963 (AZ).svg",
    shieldmain = "US %route% 1963 (AZ).svg",
	color = {
		arg = "route",
		["66"] = "hist",
		["80"] = "hist",
		default = "USA"
	}
}

AZ["US 1974"] = {
	shield = AZ["US 1963"].shield,
	shieldmain = AZ["US 1963"].shield
}
--[["US 1974" is only meant for use on infoboxes for U.S. Highways decommissioned after 1974 and before 1991.
This was the year the ASHD became part of ADOT.]]

AZ["US 1961"] = AZ["US 1963"]

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

AZ["US 1926-Alt"] = {
	shield = AZ["US 1926"].shield,
	shieldmain = AZ["US 1926"].shieldmain,
	name = AZ["US-Alt"].name,
	link = AZ["US-Alt"].link,
	abbr = AZ["US-Alt"].abbr,
	banner = "Alternate plate 1927.svg"
}

AZ["US 1926-Temp"] = {
	shield = AZ["US 1926"].shield,
	shieldmain = AZ["US 1926"].shieldmain,
	name = AZ["US-Temp"].name,
	link = {
		arg = "route",
		default = AZ["US-Temp"].link,
		["60"] = "U.S. Route 60T (1935–1938)"
	},
	abbr = AZ["US-Temp"].abbr,
	banner = "Temporary plate 1927.svg"
}

AZ["US 1941-Alt"] = {
	shield = AZ["US 1926"].shield,
	shieldmain = AZ["US 1926"].shield,
	name = AZ["US-Alt"].name,
	link = AZ["US-Alt"].link,
	abbr = AZ["US-Alt"].abbr,
	banner = "Alternate plate 1927.svg"
}

AZ["US Pre-1956-Alt"] = AZ["US 1941-Alt"]
AZ["US 1948-Alt"] = AZ["US 1941-Alt"]

AZ["US 1941-Bus"] = {
    shield = AZ["US 1926"].shield,
    shieldmain = AZ["US 1926"].shield,
    name = AZ["US-Bus"].name,
    link = AZ["US-Bus"].link,
    abbr = AZ["US-Bus"].abbr,
    banner = "Business plate.svg"
}

AZ["US 1948-Bus"] = AZ["US 1941-Bus"]
AZ["US Pre-1956-Bus"] = AZ["US 1941-Bus"]

AZ["US 1956-Alt"] = {
	shield = AZ["US 1956"].shield,
	name = AZ["US-Alt"].name,
	link = AZ["US-Alt"].link,
	abbr = AZ["US-Alt"].abbr,
	banner = "Alternate plate.svg"
}

AZ["US 1963-Bus"] = {
	shield = "US %route% 1963 (AZ).svg",
	name = AZ["US-Bus"].name,
	link = AZ["US-Bus"].link,
	abbr = AZ["US-Bus"].abbr,
	banner = "Business plate.svg"
}

AZ["US 1963-Alt"] = {
	shield = "US %route% 1963 (AZ).svg",
	name = AZ["US-Alt"].name,
	link = AZ["US-Alt"].link,
	abbr = AZ["US-Alt"].abbr,
	banner = "Alternate plate.svg"
}
	
AZ["US 1963-Truck"] = {	shield = "US %route% 1963 (AZ).svg",
	name = AZ["US-Truck"].name,
	link = AZ["US-Truck"].link,
	abbr = AZ["US-Truck"].abbr,
	banner = "Truck plate.svg",
	width = "square"}

AZ["US 1963-Spur"] = {
	shield = "US %route% 1963 (AZ).svg",
	name = AZ["US-Spur"].name,
	link = AZ["US-Spur"].link,
	abbr = AZ["US-Spur"].abbr,
	banner = "Spur plate.svg"
}

for k, v in pairs(AZ) do if k:find ("^US") then 
	v.nbrowse = AZ.US.nbrowse
	v.nbrowselinks = AZ.US.nbrowselinks
	end
end

AZ.SR = {
	base = "Arizona State Route %route%",
	shield = "Arizona %route%.svg",
	shieldmain = {
		["66"] = {"Arizona %route%.svg", "US 66 (AZ historic).svg"},
		["78"] = {"Arizona %route%.svg", "New Mexico %route%.svg"},
		default = "Arizona %route%.svg",
	},
	name = {
		["78"] = "Arizona State Route %route% and<br>New Mexico State Road %route%",
		default = "State Route %route%"
	},
	link = "Arizona State Route %route% [dab||(%dab%)|]",
	abbr = "SR&nbsp;%route%",
	width = "expand",
	color = {
		arg = "route",
		["88"] = "hist",
		default = "USA"
	}
}
AZ.AZ = AZ.SR

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

AZ.SR.link = {
	arg = "route",
	["81"] = "Arizona State Route 81 (1962–2003)",
	default = "Arizona State Route %route% [dab||(%dab%)|]"
}

AZ["SR-Alt"].name = "State Route %route%A"
AZ["SR-Alt"].link = "Arizona State Route %route%A"
AZ["SR-Alt"].abbr = "SR&nbsp;%route%A"
AZ["AZ-Alt"] = AZ["SR-Alt"]

AZ["SR-Spur"].shield = {
	default = AZ.SR.shield,
	["95"] = "Arizona 95S.svg",
	["202"] = "Arizona Loop 202.svg"
	}
AZ["SR-Spur"].abbr = {
	default = AZ.SR.abbr .. " Spur",
	["202"] = "Loop&nbsp;202 Spur"
	}

AZ["SR-Temp"].name = {
	default = "State Route %route%T",
	}
AZ["SR-Temp"].abbr = "SR&nbsp;%route%T"
AZ["AZ-Temp"] = AZ["SR-Temp"]

AZ["SR-Loop"] = {
	shield = {
		default = "Arizona %route%L.svg",
		["101"] = "Arizona Loop 101.svg",
		["202"] = "Arizona Loop 202.svg",
		["303"] = "Arizona Loop 303.svg",
		["404"] = "Arizona Loop 404.svg"
		},
	name = {
		default = "SR&nbsp;%route%L",
		["101"] = "State Loop&nbsp;101",
		["202"] = "State Loop&nbsp;202",
		["303"] = "State Loop&nbsp;303",
		["404"] = "State Loop&nbsp;404"
		},	
	link = {
		default = "Arizona State Route %route%L",
		["101"]	= AZ.SR.link,
		["202"] = AZ.SR.link,
		["303"] = AZ.SR.link,
		["404"] = AZ.SR.link
		},
	abbr = {
		default = "SR&nbsp;%route%L",
		["101"] = "Loop&nbsp;101",
		["202"] = "Loop&nbsp;202",
		["303"] = "Loop&nbsp;303",
		["404"] = "Loop&nbsp;404"
		},
	width = "wide"
}
AZ["AZ-Loop"] = AZ["SR-Loop"]
AZ.Loop = AZ["SR-Loop"]

AZ["Loop 1987"] = {
	shield = "Old Arizona Loop %route%.svg",
	name = AZ["SR-Loop"].name,
	link = AZ["SR-Loop"].link,
	abbr = AZ["SR-Loop"].abbr,
	width = "wide"
}

for _,type in ipairs({'SR', 'AZ'}) do
	for _,year in ipairs({"1927", "1941", "1956", "1963", "1973", "1978"}) do
		AZ[type .. " " .. year] = {
			shield = format("Arizona %%route%% %s.svg", year),
			name = AZ.SR.name.default,
			link = AZ.SR.link,
			abbr = AZ.SR.abbr,
		}
	end
end

AZ["SR 1927"].link = {
	arg = "route",
	default = AZ.SR.link,
	["63"] = "Arizona State Route 63 (1932–1951)",
	["74"] = "Arizona State Route 74 (1927–1931)",
	["79"] = "Arizona State Route 79 (1927–1941)",
	["81"] = "Arizona State Route 81 (1927–1938)"
}

AZ["AZ 1927"].link = AZ["SR 1927"].link

AZ["SR 1941"].link = {
	arg = "route",
	default = AZ.SR.link,
	["79"] = "Arizona State Route 79 (1950–1993)",
	["63"] = "Arizona State Route 63 (1932–1951)"
}
	
AZ["AZ 1941"].link = AZ["SR 1941"].link

AZ["SR 1963"].link = {
	arg = "route",
	default = AZ.SR.link,
	["63"] = "Arizona State Route 63 (1961–1981)",
	["79"] = "Arizona State Route 79 (1950–1993)",
	["81"] = "Arizona State Route 81 (1962–2003)"
}
	
AZ["AZ 1963"].link = AZ["SR 1963"].link

AZ["SR 1973"].link = {
	arg = "route",
	default = AZ.SR.link,
	["63"] = "Arizona State Route 63 (1961–1981)",
	["79"] = "Arizona State Route 79 (1950–1993)",
	["81"] = "Arizona State Route 81 (1962–2003)"
}
	
AZ["AZ 1973"].link = AZ["SR 1973"].link

AZ["SR 1978"].link = {
	arg = "route",
	default = AZ.SR.link,
	["63"] = "Arizona State Route 63 (1961–1981)",
	["79"] = "Arizona State Route 79 (1950–1993)",
	["81"] = "Arizona State Route 81 (1962–2003)"
}
	
AZ["AZ 1978"].link = AZ["SR 1978"].link

AZ["SR 1960 Even"] = {
	shield = {"Arizona %route% (1960 east).svg", "Arizona %route% (1960 west).svg"}
}

AZ["SR 1960 Odd"] = {
	shield = {"Arizona %route% (1960 north).svg", "Arizona %route% (1960 south).svg"}
}

AZ["AZ 1960 Even"] = AZ["SR 1960 Even"]

AZ["AZ 1960 Odd"] = AZ["SR 1960 Odd"]

AZ["SR 1960 W"] = {
	shield = "Arizona %route% (1960 west).svg"
}
AZ["AZ 1960 W"] =  AZ["SR 1960 W"]  

AZ["SR 1960 E"] = {
	shield = "Arizona %route% (1960 east).svg"
}
AZ["AZ 1960 E"] =  AZ["SR 1960 E"]  

AZ["SR 1960 N"] = {
	shield = "Arizona %route% (1960 north).svg"
}
AZ["AZ 1960 N"] =  AZ["SR 1960 N"]  

AZ["SR 1960 S"] = {	
	shield = "Arizona %route% (1960 south).svg"
}
AZ["AZ 1960 S"] =  AZ["SR 1960 S"]

for k, v in pairs(AZ) do if k:find ("^SR %d") then 
	v.name = AZ.SR.name.default
	v.link = AZ.SR.link
	v.abbr = AZ.SR.abbr
	end
end

for _,type in ipairs({'SR', 'AZ'}) do
	for _,year in ipairs({"1941", "1956", "1963", "1973", "1978"}) do
		for _,auxType in ipairs({"Alt", "Spur", "Temp"}) do
			local spec = AZ[" aux "][auxType]
			AZ[type .. " " .. year .. "-" .. auxType] = {
				shield = format("Arizona %%route%% %s.svg", year),
				name = AZ[type .. "-" .. auxType].name,
				link = AZ[type .. "-" .. auxType].link,
				abbr = AZ[type .. "-" .. auxType].abbr,
				banner = spec.name .. " plate 1948.svg",
				aux = spec.aux,
				width = "square",
			}
		end
	end
end

AZ["SR 1941-Alt"].shield = "Arizona %route% 1941.svg"
AZ["SR 1956-Alt"].shield = "Arizona %route%A 1956.svg"
AZ["SR 1963-Alt"].shield = "Arizona %route%A 1963.svg"
AZ["SR 1973-Alt"].shield = "Arizona %route%A 1973.svg"
AZ["SR 1978-Alt"].shield = "Arizona %route%A 1973.svg"
AZ["SR 1941-Alt"].banner = "Alternate plate 1927.svg"
AZ["SR 1956-Alt"].banner = ""
AZ["SR 1963-Alt"].banner = ""
AZ["SR 1973-Alt"].banner = ""
AZ["SR 1978-Alt"].banner = ""
AZ["AZ 1941-Alt"] =  AZ["SR Pre1956-Alt"]
AZ["AZ 1956-Alt"] =  AZ["SR 1956-Alt"]
AZ["AZ 1963-Alt"] =  AZ["SR 1963-Alt"]
AZ["AZ 1973-Alt"] =  AZ["SR 1973-Alt"]
AZ["AZ 1978-Alt"] =  AZ["SR 1978-Alt"]
AZ["SR Pre-1956"] =  AZ["SR 1941"]
AZ["SR Pre-1956-Alt"] =  AZ["SR 1941-Alt"]
AZ["AZ Pre-1956"] =  AZ["SR 1941"]
AZ["AZ Pre-1956-Alt"] =  AZ["SR 1941-Alt"]

AZ["SR 1978-Temp"] = {
	shield = "Arizona %route% 1978.svg",
	name = AZ["SR-Temp"].name,
	link = AZ["SR-Temp"].link,
	abbr = AZ["SR-Temp"].abbr,
	banner = "Temporary plate.svg",
	width = "square"
}

AZ["AZ 1978-Temp"] =  AZ["SR 1978-Temp"]

AZ["SR 1974"] = {
	shield = AZ["SR 1973"].shield,
	shieldmain = AZ["SR 1973"].shield
}
AZ["AZ 1974"] = AZ["SR 1974"]
--[["SR 1974" is only for use in large infoboxes, for state routes decommissioned between 1974 and 1978,
using the 1973 spec shields. This is the year the ASHD became part of ADOT.]] 

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

for k, v in pairs(AZ) do if k:match ("^%a*%s19[2-6]") then
	v.maint = "[[Arizona State Highway Department|ASHD]]"
	end
end

for k, v in pairs(AZ) do if k:match ("1927") then
	v.maint = "[[Arizona State Highway Department|ASHD]]"
	end
end

for k, v in pairs(AZ) do if k:match ("1941") then
	v.maint = "[[Arizona State Highway Department|ASHD]]"
	end
end

for k, v in pairs(AZ) do if k:match ("1956") then
	v.maint = "[[Arizona State Highway Department|ASHD]]"
	end
end

for k, v in pairs(AZ) do if k:match ("1963") then
	v.maint = "[[Arizona State Highway Department|ASHD]]"
	end
end

AZ.NV = {alias = {module = "USA/NV", type = "NV"}}
AZ.CA = {alias = {module = "USA/CA", type = "SR"}}
AZ.NM = {alias = {module = "USA/NM", type = "NM"}}
AZ.UT = {alias = {module = "USA/UT", type = "SR"}}
AZ.MEX = {alias = {module = "MEX", type = "FH"}}
AZ.SON = {alias = {module = "MEX", type = "SH", state="SON"}}

AZ.MC = {
	shield = AZ.CR.shield,
	shieldmain = AZ.CR.shield,
	name = "MC&nbsp;%route%",
	link = "Maricopa County Route %route%",
	abbr = "MC&nbsp;%route%"
}

AZ.BIA = {
	shield = "Indian Route&nbsp;%route%.svg",
	name = "BIA Route&nbsp;%route%",
	link = {
		default = "BIA Route&nbsp;%route%",
		["12"] = "U.S. Route 191 in Arizona#State Route 63 and BIA Route 12",
		["170"] = "Arizona State Route 170"
	},
	abbr = "BIA Route&nbsp;%route%"
}

AZ.N = {
	shield = AZ.BIA.shield,
	name = "Navajo Route&nbsp;%route%",
	link = "Navajo Route&nbsp;%route%",
	abbr = "N%route%"
}

AZ.Historic = {
	shield = "Arizona Scenic Road Marker.svg",
	name = "%route% Historic Road",
	link = "%route% Historic Road (Arizona)",
	abbr = "%route% Historic Road",
	orientation = "upright"
}

AZ.Scenic = {
	shield = AZ.Historic.shield,
	name = "%route% Scenic Road",
	link = "%route% Scenic Road (Arizona)",
	abbr = "%route% Scenic Road",
	orientation = "upright"
}
	        
AZ.Parkway = {
	shield = AZ.Historic.shield,
	name = "%route% Parkway",
	link = "%route% Parkway (Arizona)",
	abbr = "%route% Parkway",
	orientation = "upright"
}

return AZ