Документация
local get_args = require('Модуль:Arguments').getArgs
local mHatnote = require('Модуль:Hatnote/песочница')

local p = {}

function p.main(frame, _tracking_categories)
	local args = get_args(frame)
	local prefixes = mw.loadData('Модуль:Другие значения/data')
	local type = args.type or args['тип'] or 'default'
	local tracking_categories = {
		red_link = 'Другие значения: указана несуществующая страница',
		no_links = 'Другие значения: не найдена страница значений',
		bad_type = 'Другие значения: указан несуществующий тип'
	}
	
	local categories = mHatnote.make_categories(
		setmetatable(_tracking_categories or {}, {
			__index = tracking_categories
		})
	)
	if not prefixes[type] then
		type = 'default'
		categories:add('bad_type')
	end
	
	local hatnote_args = setmetatable({
		prefix = prefixes[type],
		hide_disambig = true,
		dot = true,
		empty_list_message = 'Не найдено ни одной страницы разрешения неоднозначности',
		preview_error = true
	}, {
		__index = args
	})
	
	if not args[1] then
		local disambig_page
		local without = mHatnote.remove_precision{mw.title.getCurrentTitle().text}
		local with = without .. ' (значения)'
		
		--[[ страница "XXX (значения)" априори считается дизамбигом, 
		     поэтому проверяется только её существование ]]
		if mw.title.new(with).exists then
			disambig_page = with
		elseif mHatnote.is_disambig{without} then
			disambig_page = without
		end
	
		hatnote_args[1] = disambig_page
		hatnote_args['l1'] = args['l1'] or without
	end
	
	return mHatnote.main(hatnote_args, tracking_categories) .. categories
end

return p