// Copyright (c) 2026 Modelware. All rights reserved.

export const MarkdownExecutionRequest = 'oml/markdown';

export type MdBlockKind =
    | 'table'
    | 'tree'
    | 'graph'
    | 'chart'
    | 'diagram'
    | 'list'
    | 'text'
    | 'matrix'
    | 'table-editor';

export interface MdExecutableBlock {
    id: string;
    kind: MdBlockKind;
    source: string;
    meta?: string;
    options?: Record<string, unknown>;
    lineStart: number;
    lineEnd: number;
}

export interface MdExecuteBlocksParams {
    markdownUri: string;
    modelUri: string;
    blocks: MdExecutableBlock[];
}

export type MdExecutionStatus = 'ok' | 'error' | 'unimplemented';

export type MdTableCellValueKind = 'iri' | 'literal' | 'bnode' | 'unknown';

export interface MdTableCellValue {
    kind: MdTableCellValueKind;
    value: string;
    datatype?: string;
    language?: string;
}

export type MdTableCellKind = 'iri' | 'literal' | 'bnode' | 'unknown';

export interface MdTableCell {
    kind: MdTableCellKind;
    value: string;
    values: MdTableCellValue[];
    datatype?: string;
    language?: string;
}

export interface MdTablePayload {
    columns: string[];
    rows: string[][];
    rowsTyped?: MdTableCell[][];
}

export interface MdBlockExecutionResult {
    blockId: string;
    kind: MdBlockKind;
    status: MdExecutionStatus;
    format: 'table' | 'message';
    payload?: MdTablePayload;
    message?: string;
}

export interface MdExecuteBlocksResult {
    results: MdBlockExecutionResult[];
    contextQuadCount?: number;
}
