import * as THREE from "three";
import { BaseViewer } from "./BaseViewer";
import { ViewerName } from "./Constants";
import { Model2dConfig, Viewer2dConfig } from "../../core/Configs";
import { DxfData, DxfLayer } from "../../core/dxf";
import { Model2d } from "../../core/model";
export interface EntityData {
    modelId: string;
    layerName: string;
}
/**
 * A group of dxf/dwg layers for a drawing.
 */
export interface DxfLayers {
    modelId: string;
    layers: Record<string, DxfLayer>;
}
export interface PdfLayers {
    modelId: string;
    layers: Record<string, PdfLayer>;
}
export interface PdfLayer {
    name: string;
    id: string;
    index: string;
    visible: boolean;
}
/**
 * Represents the loaded data structure for a PDF file in Viewer2d.
 * Similar to {@link DxfData} but designed for PDF files.
 */
export interface PdfData {
    /**
     * Root object for the entire PDF document.
     */
    threejsObject: THREE.Object3D;
    /**
     * Layer definitions for the PDF document.
     * The key is the layer name.
     */
    layers: Record<string, PdfLayer>;
    /**
     * Organizes threejs objects by layer name. The key is layer name.
     * This field is optional and may be undefined if layer-to-object mapping is not available.
     */
    layersAndThreejsObjects?: Record<string, THREE.Object3D[]>;
    /**
     * Created/loaded entity count. Mainly for log usage, not an accurate value.
     * We cannot get this value from threejsObject because it may be merged.
     */
    loadedEntityCount: number;
}
/**
 * @hidden
 */
export declare const GroundPlaneRenderOrder = -1000;
/**
 * Threejs objects are organized in tree view as below:
 *
 * - modelLevelObject1              (THREE.Group, name = <modelId>)
 *     - layoutLevelObject1         (THREE.Group, name = <layout name>, used to control layout visibility)
 *         - entityLevelObject1     (THREE.Point/Line/Mesh/Group)
 *
 * - Layer threejs objects
 * {
 *    layerName:[threejsObject1,threejsObject2,threejsObject3,...] (THREE.Point/Line/Mesh)
 * }
 */
/**
 * "dwg" is short for "drawing", it is a file format saved by AutoCAD.
 * And "dxf" is data exchange format, which can be converted from a dwg file.
 * We cannot read dwg directly, and need to convert it to dxf first via ODA.
 *
 * Supported dxf version: AutoCAD 2018. Both binary and ascii are supported.
 *
 * Json Encoding: UTF-8 encoding without BOM
 *
 * Coordinate system: right-handed, y-up
 *
 * About units:
 * - The unit of distance follows the master dxf file's unit
 * - The unit of area follows the master dxf file's unit
 * - The unit of angle is "degree", counterclockwise
 * - The unit of time is "second"
 *
 * Color: use rgb/rgba, values between 0-1
 *
 * About Measurement in Viewer2d:
 * - A measurement is generated by Viewer2d.
 * - Measurements data should be stored by users, so users can restore measurements data into Viewer2d later.
 * - Viewer2d manages measurements data, it can be created, removed, hidden, etc.
 * - Viewer2d doesn't maintain the relationship between measurement and layout.
 *
 * About Markup in Viewer2d:
 * Markup is pretty similar to measurement.
 *
 * About Hotpoint in Viewer2d:
 * - A hotpoint is created and stored by user.
 * - A hotpoint can be added to, and removed from Viewer2d.
 * - Caller should set a hotpointId that is unique in the session of current Viewer2d.
 * - Viewer2d doesn't hide a hotpoint, user is able to do it.
 * - Viewer2d doesn't maintain the relationship between hotpoint and layout.
 *
 * About layouts
 * - Each layout has its own home view.
 * - When switching to another layout, it clears all measurements, markups and hotpoints.
 * - When switching to another layout, it deactivates any in-progress operation like measurement, markup, etc.
 *
 * About overlay
 * - It supports to add as many models as user want, as long as the browser has sufficient memory, cpu/gpu, etc.
 * - The first model is called "master" model, others are called "overlay" models.
 * - It ignores an overlay model's paper space.
 * - An overlay model's unit should be converted to master model's unit if they are not the same.
 * - We'll append modelId as prefix for getLayers()
 *
 * About comparision
 * - It compares just "Model" spaces.
 * - It compares entities with the same handles and types.
 * - It compares entities' geometries, positions, scales, etc.
 * - It ignores a layer's visibility, freeze settings.
 * - It ignores an entity's properties, like linetype, line width, fill pattern, font, color, etc.
 * - It ignores spatial filters (xclip) of block references.
 * - It ignores layer relative operations, like moving an entity to another layer, changing a layer color, etc.
 * - By default, an "Added" entity is rendered in green, a "Removed" entity is in red, a "Modified" entity is composed by two parts, one "Removed" and another "Added".
 *
 * About undo/redo
 * - It supports undo/redo for measurement and markup operations. E.g., creating/deleting/moving a markup.
 * - Setting/removing a batch of measurements or markups will be taken as one operation.
 * - Switching to another layout clears all undo/redo history.
 *
 * About OSnap
 * - It supports snapping to the end points and middle point of a line.
 * - It supports snapping to the intersection point of two lines.
 * - It supports snapping to the foot of perpendicular against a line.
 * - It supports snapping to any point along a line.
 *
 * @example
 * ``` typescript
 * const viewerCfg = {
 *     containerId: "myCanvas",
 *     enableSpinner: true,
 *     enableLayoutBar: true,
 * };
 * const modelCfg = {
 *     modelId: "id_0",
 *     name: "sample",
 *     src: "http://www.abc.com/sample.dwg",
 * }
 * const fontFiles = ["http://www.abc.com/hztxt.shx", "http://www.abc.com/simplex.shx"];
 *
 * const viewer = new Viewer2d(viewerCfg);
 * await viewer.setFont(fontFiles);
 * await viewer.loadModel(modelCfg);
 * ```
 */
export declare class Viewer2d extends BaseViewer {
    name: ViewerName;
    loadedModels: Model2d[];
    groundPlane?: THREE.Mesh;
    raycastableObjects?: THREE.Object3D[];
    constructor(viewerCfg: Viewer2dConfig);
    get camera(): THREE.OrthographicCamera;
    /**
     * Loads a DXF/DWG model.
     * The first loaded file becomes the "master" model.
     * Any other files are non-master, we call "overlay" model.
     * We'll load everything of a master model, including model and paper space.
     * For an overlay model, we'll only load its model space. And its model space can only
     * overly to master model's model space.
     * @param modelCfg Configuration of the model to load.
     * @param onProgress Optional callback for loading progress.
     * @example
     * ``` typescript
     * const viewerCfg = {
     *     containerId: "myCanvas",
     * };
     * const modelCfg = {
     *     modelId: "id_0",
     *     name: "dxf 0",
     *     src: "http://www.abc.com/sample.dwg",
     * }
     * const viewer = new Viewer2d(viewerCfg);
     * await viewer.loadModel(modelCfg, (event) => {
     *     const progress = (event.loaded * 100) / event.total;
     *     console.log(`Loading progress: ${progress}%`);
     * });
     * console.log("Loaded");
     * ```
     */
    loadModel(modelCfg: Model2dConfig, onProgress?: ((event: ProgressEvent<EventTarget>) => void) | undefined): Promise<undefined>;
    /**
     * Parses a dwg or dxf and return json object.
     * @param modelCfg
     * @param onProgress
     */
    parseFile(modelCfg: Model2dConfig, onProgress?: ((event: ProgressEvent<EventTarget>) => void) | undefined): Promise<DxfData>;
    addModel(model: Model2d): void;
    setObjectHighlight(object: THREE.Object3D): void;
    setObjectUnHighlight(object: THREE.Object3D): void;
    clearHighlight(): void;
    clearSelection(): void;
    /**
     * Gets if selection is enabled.
     */
    get enableSelection(): boolean;
    /**
     * Sets if selection is enabled.
     */
    set enableSelection(enable: boolean);
    getRaycastableObjects(): THREE.Object3D[];
    /**
     * Gets the world position by the mouse's position.
     */
    getWorldPositionByMousePick(mousePosition: THREE.Vector2): THREE.Vector3 | undefined;
    /**
     * Activates a layout tab (model or paper space).
     * @param layoutName Layout name to activate.
     * @example
     * ```typescript
     * viewer.activateLayout('Layout1');
     * ```
     */
    activateLayout(layoutName?: string): void;
    /**
     * Gets loaded entity count
     * @hidden
     * @returns {number}
     */
    getEntityCount(): number;
    /**
     * @description Gets layout names of the master model.
     * @returns Layout names of the master model.
     * @example
     * ```typescript
     * const layoutNames = viewer.getLayoutNames();
     * console.log(layoutNames); // ['Model', 'Layout1', 'Layout2']
     * ```
     */
    getLayoutNames(): string[];
    goToHomeView(): void;
    zoomToBBox(bbox: THREE.Box3): void;
    /**
     * Returns the current view extent in world XY (from NDC corners).
     * Useful to save as a viewpoint and restore the same framing later.
     * @example
     * ``` typescript
     * const box = viewer.getCurrentViewExtent();
     * console.log("Current view extent:", box);
     * ```
     */
    getCurrentViewExtent(): THREE.Box2 | undefined;
    /**
     * Gets hit result by Normalized Device Coordinates.
     * Lower left coordinate: (-1, -1)
     * Upper right coordinate: (1, 1)
     */
    protected getHitResultByNdcCoordinate(coord: THREE.Vector2): THREE.Vector2 | undefined;
    /**
     * Returns the active layout name, or undefined if none.
     * @example
     * ``` typescript
     * const activeLayout = viewer.getActiveLayoutName();
     * console.log(activeLayout);
     * ```
     */
    getActiveLayoutName(): string | undefined;
    zoomIn(step?: number): void;
    zoomOut(step?: number): void;
    /**
     * Returns layer tables grouped by loaded model (master first, then overlays).
     * @example
     * ``` typescript
     * const dxfLayers = viewer.getLayers();
     * for (let i = 0; i < dxfLayers.length; ++i) {
     *     const layers = dxfLayers[i].layers;
     *     const layerNames = Object.keys(layers).sort();
     *     console.log(layerNames);
     * }
     * ```
     */
    getLayers(): (DxfLayers | PdfLayers)[];
    /**
     * Sets visibility of a layer by name.
     * @param layerName Layer to show or hide.
     * @param visible Target visibility.
     * @param modelId When multiple models are loaded, target model; defaults to the master model.
     * @throws If `modelId` does not match any loaded model.
     * @example
     * ``` typescript
     * // Hides layer "0"
     * viewer.setLayerVisibility("0", false);
     * ```
     */
    setLayerVisibility(layerName: string, visible: boolean, modelId?: string): void;
    /**
     * Enables small feature culling in order to improve performance.
     */
    enableSmallFeatureCulling(enable: boolean): void;
    /**
     * If small feature culling is enabled.
     */
    isSmallFeatureCullingEnabled(): boolean;
}
