<commit_before>import main from './main';
import {types, wrappers} from './formly';

export /*@ngInject*/function config($locationProvider,$compileProvider,$httpProvider,$urlRouterProvider,stateHelperProvider,formlyConfigProvider){
  $locationProvider.html5Mode(true);
  $compileProvider.debugInfoEnabled(false);
  $httpProvider.interceptors.push('userInterceptor');
  $httpProvider.defaults.paramSerializer = '$httpParamSerializerJQLike';
  stateHelperProvider.state(main);
  $urlRouterProvider.otherwise('/home');
  formlyConfigProvider.disableWarnings = true;
  formlyConfigProvider.setWrapper(wrappers);
  formlyConfigProvider.setType(types);
}

export /*@ngInject*/function run($rootScope,$state,$stateParams,Permission,user,formlyValidationMessages){
  $rootScope.$state = $state;
  $rootScope.$stateParams = $stateParams;
  $rootScope.$on('$stateChangeStart',function(event,toState,toParams,fromState,fromParams){
    $rootScope.prevState = fromState;
    $rootScope.prevParams = fromParams;
  });
  $rootScope.$on('$stateChangeError',function(event, toState, toParams, fromState, fromParams, error){
    console.error(error); // eslint-disable-line no-console
  });
  $rootScope.$on('$stateChangePermissionDenied',function(event,toState,toParams){
    user.login()
    .result.then(
      () => {
        $state.go(toState.name,toParams);
      },
      () => {
        if($rootScope.prevState.name === ''){
          $state.go('main.home');
        }
      }
    );
  });
  Permission.defineRole('anonymous',() => {
    return !user.authenticated;
  });
  Permission.defineRole('user',() => {
    return user.role === 'user';
  });
  Permission.defineRole('author',() => {
    return user.role === 'author' ? true : false;
  });
  formlyValidationMessages.addStringMessage('json','JSON ist invalid');
  formlyValidationMessages.addTemplateOptionValueMessage('minlength','minlength','Bitte mindestens','Zeichen eingeben');
  formlyValidationMessages.addTemplateOptionValueMessage('maxlength','maxlength','Bitte höchstens','Zeichen eingeben');
  formlyValidationMessages.addTemplateOptionValueMessage('required','label','','ist erforderlich');
  formlyValidationMessages.messages.email = function($viewValue){
    return `${$viewValue} ist keine gültige E-Mail-Adresse`;
  };
}<commit_msg>Fix roles for angular-permission<commit_after>import main from './main';
import {types, wrappers} from './formly';

export /*@ngInject*/function config($locationProvider,$compileProvider,$httpProvider,$urlRouterProvider,stateHelperProvider,formlyConfigProvider){
  $locationProvider.html5Mode(true);
  $compileProvider.debugInfoEnabled(false);
  $httpProvider.interceptors.push('userInterceptor');
  $httpProvider.defaults.paramSerializer = '$httpParamSerializerJQLike';
  stateHelperProvider.state(main);
  $urlRouterProvider.otherwise('/home');
  formlyConfigProvider.disableWarnings = true;
  formlyConfigProvider.setWrapper(wrappers);
  formlyConfigProvider.setType(types);
}

export /*@ngInject*/function run($rootScope,$state,$stateParams,PermissionStore,user,formlyValidationMessages){
  $rootScope.$state = $state;
  $rootScope.$stateParams = $stateParams;
  $rootScope.$on('$stateChangeStart',function(event,toState,toParams,fromState,fromParams){
    $rootScope.prevState = fromState;
    $rootScope.prevParams = fromParams;
  });
  $rootScope.$on('$stateChangeError',function(event, toState, toParams, fromState, fromParams, error){
    console.error(error); // eslint-disable-line no-console
  });
  $rootScope.$on('$stateChangePermissionDenied',function(event,toState,toParams){
    user.login()
    .result.then(
      () => {
        $state.go(toState.name,toParams);
      },
      () => {
        if($rootScope.prevState.name === ''){
          $state.go('main.home');
        }
      }
    );
  });
  PermissionStore.definePermission('anonymous',() => {
    return !user.authenticated;
  });
  PermissionStore.definePermission('user',() => {
    return user.role === 'user';
  });
  PermissionStore.definePermission('author',() => {
    return user.role === 'author' ? true : false;
  });
  formlyValidationMessages.addStringMessage('json','JSON ist invalid');
  formlyValidationMessages.addTemplateOptionValueMessage('minlength','minlength','Bitte mindestens','Zeichen eingeben');
  formlyValidationMessages.addTemplateOptionValueMessage('maxlength','maxlength','Bitte höchstens','Zeichen eingeben');
  formlyValidationMessages.addTemplateOptionValueMessage('required','label','','ist erforderlich');
  formlyValidationMessages.messages.email = function($viewValue){
    return `${$viewValue} ist keine gültige E-Mail-Adresse`;
  };
}
{'fraction_non_alphanumeric': 0.15508711550871154, 'fraction_numerical': 0.00043020004302000433, 'mean_word_length': 5.909361069836553, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6365348', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1356, 'n_words': 167}