import { EventSource, Events, EventObserver, AnyEvent, PropertyChange } from '../coreUtils/events';
import { LabelLanguageSelector, Translation } from '../coreUtils/i18n';
import { LinkTypeIri } from '../data/model';
import * as Rdf from '../data/rdf/rdfModel';
import { Element, ElementEvents, Link, LinkEvents, LinkTypeVisibility } from './elements';
import { Graph, CellsChangedEvent } from './graph';
import { CommandHistory } from './history';
/**
 * Event data for {@link DiagramModel} events.
 *
 * @see {@link DiagramModel}
 */
export interface DiagramModelEvents {
    /**
     * Triggered on {@link DiagramModel.language} property change.
     */
    changeLanguage: PropertyChange<DiagramModel, string>;
    /**
     * Triggered on {@link DiagramModel.selection} property change.
     */
    changeSelection: PropertyChange<DiagramModel, ReadonlyArray<Element | Link>>;
    /**
     * Triggered when some elements and/or links were added or removed.
     */
    changeCells: CellsChangedEvent;
    /**
     * Triggered when diagram cells were re-ordered.
     */
    changeCellOrder: {
        readonly source: DiagramModel;
    };
    /**
     * Triggered on any event from an element in the graph.
     */
    elementEvent: AnyEvent<ElementEvents>;
    /**
     * Triggered on any event from a link in the graph.
     */
    linkEvent: AnyEvent<LinkEvents>;
    /**
     * Triggered when visibility mode changes for a link type.
     */
    changeLinkVisibility: PropertyChange<LinkTypeIri, LinkTypeVisibility>;
    /**
     * Triggered when the graph is reset and any related state (i.e. a cache)
     * should be discarded, active operations cancelled.
     */
    discardGraph: {
        readonly source: DiagramModel;
    };
}
/**
 * Provides graph content: elements and connected links.
 *
 * @category Core
 */
export interface GraphStructure {
    /**
     * Provides an [RDF term factory](https://rdf.js.org/data-model-spec/#datafactory-interface)
     * to create RDF terms for identifiers and property values.
     */
    get factory(): Rdf.DataFactory;
    /**
     * All elements (nodes) in the graph.
     */
    get elements(): ReadonlyArray<Element>;
    /**
     * All links (edges) between elements in the graph.
     */
    get links(): ReadonlyArray<Link>;
    /**
     * Gets an element by its {@link Element.id} in the graph if exists.
     */
    getElement(elementId: string): Element | undefined;
    /**
     * Gets all links connected to the specified element in the graph.
     *
     * If element is not in the graph, no links would be returned.
     */
    getElementLinks(element: Element): ReadonlyArray<Link>;
    /**
     * Gets a link by its {@link Link.id} in the graph if exists.
     */
    getLink(linkId: string): Link | undefined;
    /**
     * Searches for any link of the specified type between elements with
     * specified IDs in the graph if exists.
     *
     * If multiple links is found, any of them could be returned.
     */
    findLink(linkTypeId: LinkTypeIri, sourceId: string, targetId: string): Link | undefined;
    /**
     * Gets a source element for the specified `link` in the graph.
     *
     * If link is not in the graph, `undefined` would be returned instead.
     */
    sourceOf(link: Link): Element | undefined;
    /**
     * Gets a target element for the specified `link` in the graph.
     *
     * If link is not in the graph, `undefined` would be returned instead.
     */
    targetOf(link: Link): Element | undefined;
    /**
     * Gets current visibility mode for the specified link type.
     */
    getLinkVisibility(linkTypeId: LinkTypeIri): LinkTypeVisibility;
}
/** @hidden */
export interface DiagramModelOptions {
    history: CommandHistory;
    translation: Translation;
    selectLabelLanguage?: LabelLanguageSelector;
}
/**
 * Stores the diagram content: graph (elements, links);
 * maintains selection and the current language to display the data.
 *
 * Additionally, the diagram model provides the means to undo/redo commands
 * via {@link DiagramModel.history history}.
 *
 * @category Core
 */
export declare class DiagramModel implements GraphStructure {
    /**
     * Event source to trigger events.
     */
    protected readonly source: EventSource<DiagramModelEvents>;
    /**
     * Events for the diagram model.
     */
    readonly events: Events<DiagramModelEvents>;
    private _language;
    private _selection;
    protected graph: Graph;
    protected graphListener: EventObserver;
    /**
     * Provides the mechanism to undo/redo commands on the diagram.
     */
    readonly history: CommandHistory;
    /**
     * Provides the methods to format the content according to the current language.
     *
     * @deprecated Use {@link useTranslation} hook instead.
     */
    readonly locale: LocaleFormatter;
    /** @hidden */
    constructor(options: DiagramModelOptions);
    protected createLocale(translation: Translation): this['locale'];
    /**
     * Current language for the diagram content.
     *
     * Language code is specified as lowercase [BCP47](https://www.rfc-editor.org/rfc/rfc5646)
     * string (examples: `en`, `en-gb`, etc).
     *
     * Initial language is `en`.
     */
    get language(): string;
    /**
     * Sets current language for the diagram content.
     *
     * Language code is specified as lowercase [BCP47](https://www.rfc-editor.org/rfc/rfc5646)
     * string (examples: `en`, `en-gb`, etc).
     */
    setLanguage(value: string): void;
    /**
     * Current diagram selection (elements and/or links).
     */
    get selection(): readonly (Element | Link)[];
    /**
     * Sets current diagram selection (elements and/or links).
     *
     * When called, selected cells will be brought to the front
     * before all other diagram cells.
     */
    setSelection(value: ReadonlyArray<Element | Link>): void;
    get factory(): Rdf.DataFactory;
    get elements(): ReadonlyArray<Element>;
    get links(): ReadonlyArray<Link>;
    /**
     * Provides RDF term factory for the diagram model.
     */
    protected getTermFactory(): Rdf.DataFactory;
    getElement(elementId: string): Element | undefined;
    getElementLinks(element: Element): ReadonlyArray<Link>;
    getLink(linkId: string): Link | undefined;
    findLink(linkTypeId: LinkTypeIri, sourceId: string, targetId: string): Link | undefined;
    sourceOf(link: Link): Element | undefined;
    targetOf(link: Link): Element | undefined;
    getLinkVisibility(linkTypeId: LinkTypeIri): LinkTypeVisibility;
    /**
     * Sets current visibility mode for the specified link type.
     */
    setLinkVisibility(linkTypeId: LinkTypeIri, value: LinkTypeVisibility): void;
    protected resetGraph(): void;
    protected subscribeGraph(): void;
    protected triggerChangeCells(e: CellsChangedEvent): void;
    protected triggerElementEvent(e: AnyEvent<ElementEvents>): void;
    protected triggerLinkEvent(e: AnyEvent<LinkEvents>): void;
    /**
     * Changes display order of elements on the diagram.
     *
     * @param compare Sort comparator to establish a particular ordering
     */
    reorderElements(compare: (a: Element, b: Element) => number): void;
    /**
     * Puts specified elements before or after all other in the display order.
     */
    bringElements(targets: ReadonlyArray<Element>, to: 'front' | 'back'): void;
    /**
     * Adds the element to the diagram.
     *
     * Throws an error if element with the same {@link Element.id} already exists
     * in the graph.
     *
     * The operation puts a command to the {@link DiagramModel.history command history}.
     */
    addElement(element: Element): void;
    /**
     * Removes the element with specified ID from the diagram if exists.
     *
     * When element is removed, all connected links will be removed as well.
     *
     * The operation puts a command to the {@link DiagramModel.history command history}.
     */
    removeElement(elementId: string): void;
    /**
     * Adds the link to the diagram.
     *
     * Throws an error if link with the same {@link Link.id} already exists
     * in the graph or any of source or target is not in the graph.
     *
     * The operation puts a command to the {@link DiagramModel.history command history}.
     */
    addLink(link: Link): void;
    /**
     * Removes the link with specified ID from the diagram if exists.
     *
     * The operation puts a command to the {@link DiagramModel.history command history}.
     */
    removeLink(linkId: string): void;
}
/**
 * Provides utility methods to format the diagram content according
 * to the current language.
 *
 * @deprecated Use {@link Translation} interface instead.
 */
export interface LocaleFormatter {
    /**
     * Selects a single preferred literal for the target language out of several candidates.
     *
     * Language code is specified as lowercase [BCP47](https://www.rfc-editor.org/rfc/rfc5646)
     * string (examples: `en`, `en-gb`, etc).
     *
     * **Example**:
     * ```ts
     * model.setLanguage('de');
     * // Returns: Rdf.Literal { value = 'Apfel', language = 'de' }
     * const name = model.locale.formatLabel([
     *     model.factory.literal('Apple', 'en'),
     *     model.factory.literal('Apfel', 'de'),
     *     model.factory.literal('Яблоко', 'ru'),
     * ]);
     * ```
     *
     * @param labels candidate literal with same or different language codes
     * @param language target language code (defaults to the {@link DiagramModel.language})
     * @returns selected literal or `undefined` if no suitable literal was found
     */
    selectLabel(labels: ReadonlyArray<Rdf.Literal>, language?: string): Rdf.Literal | undefined;
    /**
     * Same as {@link selectLabel selectLabel()} but uses local part of
     * the `fallbackIri` as a fallback to display an entity referred by IRI
     * even if there is no suitable label to use.
     *
     * **Example**:
     * ```ts
     * // Returns: 'Apple'
     * const name = model.locale.formatLabel(
     *     [
     *         model.factory.literal('Apfel', 'de'),
     *         model.factory.literal('Яблоко', 'ru'),
     *     ],
     *     'http://example.com/entity/Apple',
     *     'en'
     * );
     * ```
     */
    formatLabel(labels: ReadonlyArray<Rdf.Literal> | undefined, fallbackIri: string, language?: string): string;
    /**
     * Formats IRI to display in the UI:
     *   - usual IRIs are enclosed in `<IRI>`;
     *   - anonymous element IRIs displayed as `(blank node)`.
     */
    formatIri(iri: string): string;
}
export declare class DiagramLocaleFormatter implements LocaleFormatter {
    protected readonly model: DiagramModel;
    protected readonly translation: Translation;
    constructor(model: DiagramModel, translation: Translation);
    selectLabel(labels: ReadonlyArray<Rdf.Literal>, language?: string): Rdf.Literal | undefined;
    formatLabel(labels: ReadonlyArray<Rdf.Literal> | undefined, fallbackIri: string, language?: string): string;
    formatIri(iri: string): string;
}
//# sourceMappingURL=model.d.ts.map