local AS = unpack(AddOnSkins)

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

	AS:SkinFrame(GarrisonMissionFrame, nil, nil, true)
	AS:StripTextures(GarrisonMissionFrame.GarrCorners)
	AS:SkinCloseButton(GarrisonMissionFrame.CloseButton)

	for i = 1, 2 do
		AS:SkinTab(_G["GarrisonMissionFrameTab"..i])
		AS:SkinTab(_G["GarrisonMissionFrameMissionsTab"..i])
	end

	AS:StripTextures(GarrisonMissionFrameMissions.MaterialFrame)
	GarrisonMissionFrameMissions.MaterialFrame.Icon:SetAtlas('GarrMission_CurrencyIcon-Material')
	AS:SkinScrollBar(GarrisonMissionFrameMissionsListScrollFrameScrollBar)
	AS:StripTextures(GarrisonMissionFrameMissions)

	AS:StripTextures(GarrisonCapacitiveDisplayFrame, nil, nil, true)
	AS:CreateBackdrop(GarrisonCapacitiveDisplayFrame)
	AS:StripTextures(GarrisonCapacitiveDisplayFrameInset)
	AS:SkinCloseButton(GarrisonCapacitiveDisplayFrame.CloseButton)
	AS:SkinButton(GarrisonCapacitiveDisplayFrame.StartWorkOrderButton, true)
	AS:SkinButton(GarrisonCapacitiveDisplayFrame.CreateAllWorkOrdersButton, true)

	AS:Kill(GarrisonCapacitiveDisplayFramePortrait)
	GarrisonCapacitiveDisplayFrameLeft:SetTexture(nil)
	GarrisonCapacitiveDisplayFrameMiddle:SetTexture(nil)
	GarrisonCapacitiveDisplayFrameRight:SetTexture(nil)

	GarrisonCapacitiveDisplayFrame.CapacitiveDisplay.IconBG:SetTexture(nil)
	AS:SkinTexture(GarrisonCapacitiveDisplayFrame.CapacitiveDisplay.ShipmentIconFrame.Icon)
	GarrisonCapacitiveDisplayFrame.CapacitiveDisplay.ShipmentIconFrame.Icon:SetInside()

	AS:SkinArrowButton(GarrisonCapacitiveDisplayFrame.DecrementButton, 'left')
	AS:SkinArrowButton(GarrisonCapacitiveDisplayFrame.IncrementButton, 'right')
	AS:SkinEditBox(GarrisonCapacitiveDisplayFrame.Count)

	hooksecurefunc('GarrisonCapacitiveDisplayFrame_Update', function(self)
		for _, Reagent in ipairs(self.CapacitiveDisplay.Reagents) do
			if not Reagent.Backdrop then
				Reagent.NameFrame:SetTexture('')
				AS:SkinTexture(Reagent.Icon, true)
				AS:CreateBackdrop(Reagent)
				Reagent.Backdrop:SetPoint('TOPLEFT', Reagent.Icon, 'TOPRIGHT', -1, 0)
				Reagent.Backdrop:SetPoint('BOTTOMLEFT', Reagent.Icon, 'BOTTOMRIGHT', -1, 0)
				Reagent.Backdrop:SetPoint('RIGHT', Reagent, 'RIGHT', -5, 0)
			end
		end
	end)

	AS:UnregisterSkinEvent(addon, event)
end

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

	AS:SkinFrame(ItemUpgradeFrame)
	--AS:Kill(ItemUpgradeFrameShadows)

	AS:SkinCloseButton(ItemUpgradeFrameCloseButton)

	AS:SkinIconButton(ItemUpgradeFrame.ItemButton, true)

	hooksecurefunc('ItemUpgradeFrame_Update', function()
		if GetItemUpgradeItemInfo() then
			ItemUpgradeFrame.ItemButton.IconTexture:SetAlpha(1)
			AS:SkinTexture(ItemUpgradeFrame.ItemButton.IconTexture)
		else
			ItemUpgradeFrame.ItemButton.IconTexture:SetAlpha(0)
		end
	end)

	ItemUpgradeFrameMoneyFrame:StripTextures()
	AS:SkinButton(ItemUpgradeFrameUpgradeButton, true)
	AS:Kill(ItemUpgradeFrame.FinishedGlow)
	ItemUpgradeFrame.ButtonFrame:DisableDrawLayer('BORDER')

	AS:UnregisterSkinEvent(addon, event)
end

AS:RegisterSkin('Blizzard_GarrisonUI', AS.Blizzard_GarrisonUI, 'ADDON_LOADED')
AS:RegisterSkin("Blizzard_ItemUpgradeUI", AS.Blizzard_ItemUpgradeUI, 'ADDON_LOADED')
