/**
 * @packageDocumentation
 * @module jldbq-extension
 */

import {
  JupyterFrontEnd,
  JupyterFrontEndPlugin
} from '@jupyterlab/application';
import { Dialog, ICommandPalette, showDialog } from '@jupyterlab/apputils';
import { Widget } from '@lumino/widgets';

const plugin: JupyterFrontEndPlugin<void> = {
  id: '@jupyterlab/mytest-extension',
  autoStart: true,
  requires: [ICommandPalette],
  activate: async (app: JupyterFrontEnd, palette: ICommandPalette) => {
    const command = 'mytest-command';
    app.commands.addCommand(command, {
      label: command,
      execute: async () => {
        await showDialog({
          title: 'test',
          body: new (class
            extends Widget
            implements Dialog.IBodyWidget<string> {
            getValue(): string {
              throw new Error('test');
            }
          })()
        });
      }
    });
    palette.addItem({ command, category: 'mytest', args: { isPalette: true } });
  }
};

export default plugin;
