local AS = unpack(AddOnSkins)

function AS:Blizzard_TalentUI(event, addon)
	if addon ~= 'Blizzard_TalentUI' then return end

	AS:SkinBackdropFrame(PlayerTalentFrame)
	PlayerTalentFramePortrait:Hide()
	AS:SkinCloseButton(PlayerTalentFrameCloseButton)
	PlayerTalentFrame.Backdrop:SetPoint('TOPLEFT', 13, -12)
	PlayerTalentFrame.Backdrop:SetPoint('BOTTOMRIGHT', -31, 76)

	for i = 1, 5 do
		AS:SkinTab(_G["PlayerTalentFrameTab"..i])
	end

	AS:SkinButton(PlayerTalentFrameCancelButton)

	AS:StripTextures(PlayerTalentFrameScrollFrame)

	AS:SkinScrollBar(PlayerTalentFrameScrollFrameScrollBar)
	PlayerTalentFrameScrollFrameScrollBar:SetPoint('TOPLEFT', PlayerTalentFrameScrollFrame, 'TOPRIGHT', 10, -16)

	PlayerTalentFrameSpentPoints:SetPoint('TOP', 0, -42)
	PlayerTalentFrameTalentPointsText:SetPoint('BOTTOMRIGHT', PlayerTalentFrame, 'BOTTOMLEFT', 220, 84)

	for i = 1, MAX_NUM_TALENTS do
		local talent = _G['PlayerTalentFrameTalent'..i]
		local icon = _G['PlayerTalentFrameTalent'..i..'IconTexture']
		local rank = _G['PlayerTalentFrameTalent'..i..'Rank']

		if talent then
			AS:SkinBackdropFrame(talent)
			AS:StyleButton(talent)
			talent.Backdrop:SetFrameStrata('LOW')
			talent.Backdrop:SetFrameLevel(talent:GetFrameLevel() - 1)

			AS:SetInside(icon, talent.Backdrop, 2, 2)
			AS:SkinTexture(icon)
			icon:SetDrawLayer('ARTWORK')
			rank:SetDrawLayer('OVERLAY')

			rank:SetFont(AS.Font, 12, 'OUTLINE') -- easier to read
		end
	end

	AS:UnregisterSkinEvent(addon, event)
end

AS:RegisterSkin('Blizzard_TalentUI', AS.Blizzard_TalentUI, 'ADDON_LOADED')
