-- ApiVault Complete Developer Session Export. Added in v1.2.0 must-have tooling rebuild.
-- Builds copyable report from existing ApiVault runtime records. No source file reads.
local addonName, ApiVault = ...

ApiVault.DeveloperSessionExport = ApiVault.DeveloperSessionExport or {}
local Exporter = ApiVault.DeveloperSessionExport

local function line(lines, value)
	table.insert(lines, tostring(value or ""))
end

function Exporter:BuildReport()
	local lines = {}
	line(lines, "ApiVault Complete Developer Session Export")
	line(lines, "version: " .. tostring(ApiVault.version))
	if ApiVault.GetClientBuildText then
		line(lines, "client: " .. tostring(ApiVault:GetClientBuildText()))
	end
	line(lines, "")

	if ApiVault.DeveloperAPI and ApiVault.DeveloperAPI.FormatAllReports then
		line(lines, "## Public Developer API Reports")
		line(lines, ApiVault.DeveloperAPI:FormatAllReports())
		line(lines, "")
	end

	if ApiVault.ErrorInbox and ApiVault.ErrorInbox.FormatList then
		line(lines, "## Error Inbox")
		line(lines, ApiVault.ErrorInbox:FormatList(""))
		line(lines, "")
	end

	if ApiVault.BugAdvisor and ApiVault.BugAdvisor.FormatErrorList then
		line(lines, "## Bug Advisor")
		line(lines, ApiVault.BugAdvisor:FormatErrorList(""))
		line(lines, "")
	end

	if ApiVault.SavedVariablesSchemaInspector and ApiVault.SavedVariablesSchemaInspector.FormatReport then
		line(lines, "## SavedVariables")
		line(lines, ApiVault.SavedVariablesSchemaInspector:FormatReport(""))
		line(lines, "")
	end

	if ApiVault.TaintCombatSafetyAssistant and ApiVault.TaintCombatSafetyAssistant.FormatReport then
		line(lines, "## Taint / Combat Safety Checklist")
		line(lines, ApiVault.TaintCombatSafetyAssistant:FormatReport(""))
		line(lines, "")
	end

	if ApiVault.UIStability and ApiVault.UIStability.FormatStatus then
		line(lines, "## UI Stability")
		line(lines, ApiVault.UIStability:FormatStatus())
		line(lines, "")
	end

	line(lines, "## Notes")
	line(lines, "This report is generated from current ApiVault runtime metadata and debug records. Live source context may still be required.")
	return table.concat(lines, "\n")
end

function Exporter:GetStats()
	return 1
end
