/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

module.exports = angular.module('trafficPortal.private.profiles.diff', [])
	.config(function($stateProvider, $urlRouterProvider) {
		$stateProvider
			.state('trafficPortal.private.profiles.diff', {
				url: '/{profile1Id:[0-9]{1,8}}/{profile2Id:[0-9]{1,8}}/compare/diff',
				views: {
					profilesContent: {
						templateUrl: 'common/modules/table/profilesParamsCompare/table.profilesParamsCompare.tpl.html',
						controller: 'TableProfilesParamsCompareController',
						resolve: {
							profile1: function($stateParams, profileService) {
								return profileService.getProfile($stateParams.profile1Id, { includeParams: true });
							},
							profile2: function($stateParams, profileService) {
								return profileService.getProfile($stateParams.profile2Id, { includeParams: true });
							},
							/**
							 * @param {{params: {id: unknown}[]}} profile1
							 * @param {{params: {id: unknown}[]}} profile2
							 * @param {import("../../../../../common/service/utils/CollectionUtils")} collectionUtils
							 */
							profilesParams: function(profile1, profile2, collectionUtils) {
								return collectionUtils.uniqArray(profile1.params, profile2.params, 'id');
							},
							showAll: function() {
								return false;
							}
						}
					}
				}
			})
		;
		$urlRouterProvider.otherwise('/');
	});
