local function W(W)for Q,i in pairs(bodyPartAssetTypeIds)do if not W[i]then return false end end return true end return function(Q)return function(i)local f=Q.isEditable or W(Q.assets)i:dispatch(EquipOutfit(Q.assets,f))if true then local W=(i:getState()).AvatarExperience.AvatarScene.TryOn.SelectedItem.itemId if W then i:dispatch(ClearSelectedItem())i:dispatch(CloseAllItemDetails((i:getState()).Navigation.history))end end if f then if not FFlagAvatarEditorKeepYourColor or FFlagAvatarEditorKeepYourColor and not AvatarEditorUtils.isPresetCostume(Q)then i:dispatch(SetBodyColors(Q.bodyColors))end i:dispatch(SetAvatarScales(Q.scales))i:dispatch(SetAvatarType(Q.avatarType))end end end

local function isFullyQualifiedOutfit(assets)
	for _, assetTypeId in pairs(bodyPartAssetTypeIds) do
		if not assets[assetTypeId] then
			return false
		end
	end

	return true
end

return function(outfit)
	return function(store)
		local fullReset = outfit.isEditable or isFullyQualifiedOutfit(outfit.assets)

		-- Do a full reset on a user costume, or a preset fully qualified one. Otherwise swap the existing parts.
		store:dispatch(EquipOutfit(outfit.assets, fullReset))

		if true then
			local selectedItem = store:getState().AvatarExperience.AvatarScene.TryOn.SelectedItem.itemId
			if selectedItem then
				store:dispatch(ClearSelectedItem())
				store:dispatch(CloseAllItemDetails(store:getState().Navigation.history))
			end
		end

		if fullReset then
			-- Preset costumes should not replace body colors.
			if not FFlagAvatarEditorKeepYourColor or
				(FFlagAvatarEditorKeepYourColor and not AvatarEditorUtils.isPresetCostume(outfit)) then
				store:dispatch(SetBodyColors(outfit.bodyColors))
			end
			store:dispatch(SetAvatarScales(outfit.scales))
			store:dispatch(SetAvatarType(outfit.avatarType))
		end
	end
end
