import Vue from 'vue';
import axios from 'axios';
import VueAxios from 'vue-axios';
import BootstrapVue from 'bootstrap-vue';
import App from './App.vue';
import router from './router';
import store from './store';
import VueSweetalert2 from 'vue-sweetalert2';
import VueCookies from 'vue-cookies';
import VueLogger from 'vuejs-logger';
import VueSocketIOExt from 'vue-socket.io-extended';
import io from 'socket.io-client';
import i18n from '@/plugins/i18n';
import { ValidationObserver, ValidationProvider, extend, localize } from 'vee-validate';
// @ts-ignore
import FlagIcon from 'vue-flag-icon';
// @ts-ignore
import VueMoment from 'vue-moment';
// following is to avoid missing type definitions
// const FlagIcon = require('vue-flag-icon');

import {library} from '@fortawesome/fontawesome-svg-core';
import {
  faCoffee,
  faDoorOpen,
  faCheck,
  faPlus,
  faScroll,
  faCircle,
  faArrowCircleLeft,
  faArrowCircleRight,
  faList,
  faTrash,
  faPencilAlt,
  faCogs,
  faAt,
  faIdBadge,
  faUser,
  faEnvelope,
  faHome,
  faSync,
  faCode,
  faBarcode,
  faTag,
  faTags,
  faVideo,
  faLock,
  faLockOpen,
  faWrench,
  faPlay,
  faFrown,
  faSmile,
  faUserTag,
  faExternalLinkAlt,
  faThumbsUp,
  faThumbsDown,
} from '@fortawesome/free-solid-svg-icons';

import { faOpenid,
} from '@fortawesome/free-brands-svg-icons';

import {
  faDotCircle,
} from '@fortawesome/free-regular-svg-icons';

import {FontAwesomeIcon} from '@fortawesome/vue-fontawesome';


// import 'bootstrap';
// import 'bootstrap/dist/css/bootstrap.min.css';

import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap-vue/dist/bootstrap-vue.css';

const isProduction = process.env.NODE_ENV === 'production';
Vue.prototype.$isProduction = isProduction;

library.add(faCoffee, faTrash, faPencilAlt, faScroll, faCheck, faCircle, faList, faPlus, faDoorOpen, faCogs, faAt,
  faUser, faEnvelope, faUserTag, faExternalLinkAlt, faSync, faHome, faCode, faBarcode, faTag, faTags, faVideo, faLock,
  faLockOpen, faArrowCircleLeft, faArrowCircleRight, faWrench, faPlay, faFrown, faSmile, faThumbsUp, faThumbsDown,
  faOpenid, faDotCircle, faIdBadge);

Vue.component('font-awesome-icon', FontAwesomeIcon);

const loggerOptions = {
  isEnabled: true,
  logLevel : isProduction ? 'error' : 'debug',
  //logLevel: 'debug',
  stringifyArguments: false,
  showLogLevel: true,
  showMethodName: true,
  separator: '|',
  showConsoleColors: true,
};

//Vue.use(VueLogger, loggerOptions);
Vue.use(VueAxios, axios);
Vue.use(BootstrapVue);
Vue.use(FlagIcon);
Vue.use(VueCookies);
Vue.use(VueSweetalert2);
Vue.use(VueMoment);


import en from 'vee-validate/dist/locale/en.json';
import de from 'vee-validate/dist/locale/de.json';
import es from 'vee-validate/dist/locale/es.json';
import * as rules from 'vee-validate/dist/rules';

// install rules and localization
Object.keys(rules).forEach((rule) => {
  // @ts-ignore
  extend(rule, rules[rule]);
});

localize('de', de);

// Install components globally
Vue.component('ValidationObserver', ValidationObserver);
Vue.component('ValidationProvider', ValidationProvider);

// const socket = io('ws://localhost:5000',{autoConnect: false, reconnectionAttempts: 3});
const socket = io('ws://localhost:5443', {
  autoConnect: false,
  reconnectionAttempts: 3,
  query: {jwt: store.state.access_token},
});
Vue.use(VueSocketIOExt, socket);



Vue.config.productionTip = false;


// @ts-ignore
String.prototype.isEmpty = function() {
  return (this.length === 0 || !this.trim());
};

new Vue({
  i18n,
  router,
  store,
  render: (h) => h(App),
}).$mount('#app');

