local lib = require("lib")

---@alias QGColor
---| "red"
---| "green"
---| "black"
---| "cyan"
---| "purple"
---| "yellow"
---| "white"
---| "orange"
---| "pink"
---| "blue"
---| "lime"
---Color of the contents of a flask

---@type table<number, QGColor>
local colors = {
	"red",
	"green",
	"black",
	"cyan",
	"purple",
	"yellow",
	"white",
	"orange",
	"pink",
	"blue",
	"lime",
}

---@alias QGContents
---| "empty"
---| "liquid"
---| "frozen"
---Contents of a flask

---@type table<number, QGContents>
local contents = {
	"empty",
	"liquid",
	"frozen",
}

---@alias VariantName
---| "empty"
---| "liquid_red"
---| "liquid_green"
---| "liquid_black"
---| "liquid_cyan"
---| "liquid_purple"
---| "liquid_yellow"
---| "liquid_white"
---| "liquid_orange"
---| "liquid_pink"
---| "liquid_blue"
---| "liquid_lime"
---| "frozen_red"
---| "frozen_green"
---| "frozen_black"
---| "frozen_cyan"
---| "frozen_purple"
---| "frozen_yellow"
---| "frozen_white"
---| "frozen_orange"
---| "frozen_pink"
---| "frozen_blue"
---| "frozen_lime"

---@alias ModelId
---| "cone_normal"
---| "cone_slim"
---| "cone_inverted"
---| "cylinder"
---| "tube_one"
---| "tube_two"
---| "tube_three"
---| "sphere_normal"
---| "sphere_tiny"
---| "sphere_double"
---| "sphere_tubed"
---| "sphere_hemi"
---| "sphere_spiked"
---| "hourglass"
---| "torus"
---| "klein"
---| "pyramid"
---| "cube"
---| "triangle"
---| "triangle_alt"
---| "pentagon"
---| "hexagon" 
---Identifier for a model of flask.

---@type table<number, ModelId>
local base_models = {
	"cone_normal",
	"cone_slim",
	"cone_inverted",
	"cylinder",
	"tube_one",
	"tube_two",
	"tube_three",
	"sphere_normal",
	"sphere_tiny",
	"sphere_double",
	"sphere_tubed",
	"sphere_hemi",
	"sphere_spiked",
	"hourglass",
	"torus",
	"klein",
	"pyramid",
	"cube",
	"triangle",
	"triangle_alt",
	"pentagon",
	"hexagon",
}

---@type table<number, ModelId>
local frozen_models = {
	"cone_normal",
}

---@alias Variant { name: VariantName, model: ModelId, color: QGColor?, contents: QGContents, assigned_to: string?  }
---A variant of a flask

---@alias Model { name: ModelId, variants: table<VariantName, Variant>  }

---@type table<ModelId, Model>
---Table of all flask models and their variants provided by Quality Glassware
local models = {}
for _, model in ipairs(base_models) do
	---@type table<VariantName, Variant>
	local variants = {
		empty = {
			name = "empty",
			model = model,
			contents = "empty"
		}
	}
	for _, color in ipairs(colors) do
		variants["liquid_" .. color] = {
			name = "liquid_" .. color,
			model = model,
			color = color,
			contents = "liquid"
		}
	end
	if lib.contains(frozen_models, model) then
		for _, color in ipairs(colors) do
			variants["frozen_" .. color] = {
				model = model,
				name = "frozen_" .. color,
				color = color,
				contents = "frozen"
			}
		end
	end
	models[model] = {
		name = model,
		variants = variants,
	}
end

return {
	models = models,
	colors = colors,
	contents = contents,
}
