import { createApp } from 'vue';

import '@fontsource/inter';

import { createRouter, createWebHashHistory } from 'vue-router';
import { tooltip } from '@cloudron/pankow';
import i18n from './i18n.js';
import FileManager from './components/FileManager.vue';
import FolderView from './components/FolderView.vue';
import FileViewer from './components/FileViewer.vue';

import './style.css';

const routes = [
  { path: '/', redirect: '/home' },
  { path: '/home/:type?/:resourceId?/:cwd*', component: FolderView },
  { path: '/viewer/:type/:resourceId/:filePath*', component: FileViewer }
];

const router = createRouter({
  // 4. Provide the history implementation to use. We are using the hash history for simplicity here.
  history: createWebHashHistory(),
  routes,
});

(async function init() {
  const app = createApp(FileManager);

  app.directive('tooltip', tooltip);

  app.use(await i18n());
  app.use(router);

  app.mount('#app');
})();
