/* eslint-disable @typescript-eslint/naming-convention */
import {
	StacksEditor,
	StacksEditorOptions
} from '@microsoft/stacks-editor/dist/stacks-editor/editor';
import { Node } from 'prosemirror-model';

export const editorId = '#docs-markdown-editor';
export const editorTag = 'docs-markdown-editor';

export const buttonsMap = new Map<string, string>([
	['Headings', 'js-heading-btn'],
	['Bold', 'js-bold-btn'],
	['Italics', 'js-italic-btn'],
	['Inline Code', 'js-code-btn'],
	['Strikethrough', 'js-strike-btn'],
	['Link', 'js-insert-link-btn'],
	['Blockquote', 'js-blockquote-btn'],
	['Codeblock', 'js-code-block-btn'],
	['Image', 'js-insert-image-btn'],
	['Numbered List', 'js-numbered-list-btn'],
	['Bulleted List', 'js-bullet-list-btn'],
	['hr', 'js-horizontal-rule-btn'],
	['disabled', 'is-disabled']
]);

export enum EditorModes {
	qna = 'qna',
	renewalAsessments = 'renewal-assessments',
	selfAssessments = 'self-assessments',
	docs = 'docs'
}

export const modeButtonsToDisable: ModeDisableButtons = {
	docs: 'hr,Strikethrough',
	'renewal-assessments': 'Headings,Link,Blockquote,Image,hr,Strikethrough,disabled,disabled',
	'self-assessments': '',
	qna: ''
};
export interface ModeDisableButtons extends IObjectKeys {
	docs: string;
	'renewal-assessments': string;
	'self-assessments': string;
	qna: string;
}
export interface IObjectKeys {
	[key: string]: any;
}
export interface NodeWithPosition {
	node: Node;
	pos: number;
	parent: Node;
}

export type ImageStore = Map<string, Image>;

export interface Image {
	file: File;
	data: string;
	id: string;
}

export type getPosParam = boolean | (() => number);

export enum AltTextValidationResult {
	Ok,
	AltTextTooLong,
	AltTextDoesntEndWithPeriod,
	AltTextStartsWithLowerCase
}

export const images: ImageStore = new Map<string, Image>();

export interface GitHubAttributes {
	repo: string;
	org: string;
	path: string;
	branch: string;
}

export interface DocsMarkdownEditor extends HTMLElement {
	content: string;
	mode: EditorModes;
	gitHubAttributes: GitHubAttributes;
	images: ImageStore;
	onToggleClick: EventListener;
	onMenuClick: EventListener;
	toggle: HTMLElement;
	editor: StacksEditor;
	options: StacksEditorOptions;
}
