/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import { h, Host, } from "@stencil/core";
import { Angle, Euler, Matrix4, Point, Quaternion, Vector3, } from "@vertexvis/geometry";
import classNames from "classnames";
import { readDOM, writeDOM } from "../../lib/stencil";
import { TransformController } from "../../lib/transforms/controller";
import { AngleUnits, DistanceUnits, } from "../../lib/types";
import { focusInputElement } from "./dom";
import { calculateNewRotationAngle, computeHandleDeltaTransform, computeInputDeltaTransform, computeInputDisplayValue, computeInputPosition, convertCanvasPointToWorld, convertPointToCanvas, } from "./util";
import { TransformWidgetInput, TransformWidgetInputWrapper, } from "./viewer-transform-widget-components";
import { TransformWidget } from "./widget";
export class ViewerTransformWidget {
    constructor() {
        /**
         * Determines whether the x-rotation is disabled on the widget
         */
        this.xRotationDisabled = false;
        /**
         * Determines whether the y-rotation is disabled on the widget
         */
        this.yRotationDisabled = false;
        /**
         * Determines whether the z-rotation is disabled on the widget
         */
        this.zRotationDisabled = false;
        /**
         * Determines whether the x-translation is disabled on the widget
         */
        this.xTranslationDisabled = false;
        /**
         * Determines whether the y-translation is disabled on the widget
         */
        this.yTranslationDisabled = false;
        /**
         * Determines whether the z-translation is disabled on the widget
         */
        this.zTranslationDisabled = false;
        /**
         * Determines whether the xy-translation is disabled on the widget
         */
        this.xyTranslationDisabled = false;
        /**
         * Determines whether the xz-translation is disabled on the widget
         */
        this.xzTranslationDisabled = false;
        /**
         * Determines whether the yz-translation is disabled on the widget
         */
        this.yzTranslationDisabled = false;
        /**
         * Whether to show inputs beside the widget handles when they are interacted with.
         * Defaults to `true`.
         */
        this.showInputs = true;
        /**
         * The unit to show for translation inputs. Defaults to `millimeters`.
         *
         * @see DistanceUnitType
         */
        this.distanceUnit = 'millimeters';
        /**
         * The unit to show for rotation inputs. Defaults to `degrees`.
         *
         * @see AngleUnitType
         */
        this.angleUnit = 'degrees';
        /**
         * The number of decimal places to show in the input. Defaults to `1`.
         */
        this.decimalPlaces = 1;
        /**
         * When rotationSnapDegrees is defined, the widget will snap to the degree of the
         * nearest multiple of the given number when the user is rotating with the widget
         * and holding the key defined here. Defaults to the shift key.
         */
        this.rotationSnapKey = 'shift';
        /**
         * Scalar to increase the size of the translation handles of this widget.
         * Values above zero and below three will result in the best visual representation
         * of the handles, and values above three may produce unexpected results.
         *
         * Defaults to `1`.
         */
        this.translationHandleScalar = 1;
        /**
         * Scalar to increase the size of the rotation handles of this widget.
         * Values above zero and below three will result in the best visual representation
         * of the handles, and values above three may produce unexpected results.
         *
         * Defaults to `1`.
         */
        this.rotationHandleScalar = 1;
        /**
         * Specifies the frequency, in milliseconds, to update the transform while interacting with the widget.
         *
         * This delay is used to group events happening in quick succession and results in smoother
         * widget movement.
         */
        this.interactionThrottle = 75;
        /**
         * **EXPERIMENTAL.**
         *
         * Enables Command+Z and Control+Z keybindings to perform an undo of
         * the previous delta transformation.
         *
         * @see `EXPERIMENTAL_undo`
         */
        this.EXPERIMENTAL_undoKeybindings = false;
        this.inputValue = 0;
        this.isEndingTransform = false;
        this.inputShouldFocus = false;
        this.xArrowColor = '#ea3324';
        this.yArrowColor = '#4faf32';
        this.zArrowColor = '#0000ff';
        this.twoAxesSquareColor = '#e0e0e0';
        this.hoveredColor = '#ffff00';
        this.lastAngle = 0;
        this.handleHoveredDrawableChanged = (drawable) => {
            this.hovered = drawable;
        };
        this.handleViewerFrameDrawn = () => {
            this.updatePropsFromViewer();
        };
        this.handleViewerDimensionsChange = () => {
            writeDOM(() => {
                if (this.viewer != null && this.canvasRef != null) {
                    this.canvasRef.width = this.viewer.viewport.width;
                    this.canvasRef.height = this.viewer.viewport.height;
                    this.updateCanvasBounds(this.canvasRef);
                }
            });
        };
        this.handleResize = () => {
            if (this.canvasRef != null) {
                this.updateCanvasBounds(this.canvasRef);
            }
        };
        this.handleInputResize = () => {
            if (this.inputWrapperRef != null) {
                const wrapperElement = this.inputWrapperRef;
                readDOM(() => {
                    this.inputBounds = wrapperElement.getBoundingClientRect();
                });
            }
        };
        this.handleStyleChange = () => {
            readDOM(() => {
                const hostStyles = window.getComputedStyle(this.hostEl);
                this.xArrowColor = hostStyles
                    .getPropertyValue('--viewer-transform-widget-x-axis-arrow-color')
                    .trim();
                this.yArrowColor = hostStyles
                    .getPropertyValue('--viewer-transform-widget-y-axis-arrow-color')
                    .trim();
                this.zArrowColor = hostStyles
                    .getPropertyValue('--viewer-transform-widget-z-axis-arrow-color')
                    .trim();
                this.twoAxesSquareColor = hostStyles
                    .getPropertyValue('--viewer-transform-widget-two-axes-square-color')
                    .trim();
                this.hoveredColor = hostStyles
                    .getPropertyValue('--viewer-transform-widget-hovered-arrow-color')
                    .trim();
                this.getTransformWidget().updateColors({
                    xArrow: this.xArrowColor,
                    yArrow: this.yArrowColor,
                    zArrow: this.zArrowColor,
                    twoAxesSquare: this.twoAxesSquareColor,
                    hovered: this.hoveredColor,
                });
            });
        };
        this.handlePointerMove = (event) => {
            if (this.dragging == null) {
                const canvasPoint = convertPointToCanvas(Point.create(event.clientX, event.clientY), this.getCanvasBounds());
                const widget = this.getTransformWidget();
                if (canvasPoint != null && widget.boundsContainsPoint(canvasPoint)) {
                    widget.updateCursor(canvasPoint);
                }
                else {
                    widget.updateCursor(undefined);
                    this.hovered = undefined;
                }
            }
        };
        this.handleBeginDrag = async (event) => {
            var _a, _b, _c;
            const canvasBounds = this.getCanvasBounds();
            if (this.hovered != null &&
                canvasBounds != null &&
                this.viewer != null &&
                this.position != null &&
                this.viewer.frame != null) {
                this.dragging = this.hovered;
                if (this.dragging.identifier !== ((_a = this.lastDragged) === null || _a === void 0 ? void 0 : _a.identifier)) {
                    this.inputValue = 0;
                    this.dragStartTransform = this.currentTransform;
                    this.updateInputPosition();
                    this.updateInputValue();
                }
                this.lastDragged = undefined;
                const currentCanvas = convertPointToCanvas(Point.create(event.clientX, event.clientY), canvasBounds);
                const widgetCenter = this.viewer.viewport.transformWorldToViewport(this.position, this.viewer.frame.scene.camera.projectionViewMatrix);
                this.lastAngle =
                    currentCanvas != null
                        ? Angle.fromPoints(widgetCenter, currentCanvas)
                        : 0;
                this.lastWorldPosition = convertCanvasPointToWorld(currentCanvas, (_b = this.viewer) === null || _b === void 0 ? void 0 : _b.frame, (_c = this.viewer) === null || _c === void 0 ? void 0 : _c.viewport, this.currentTransform);
                this.interactionStarted.emit();
                window.removeEventListener('pointermove', this.handlePointerMove);
                window.addEventListener('pointermove', this.handleDragWithTimer);
                window.addEventListener('pointerup', this.handleEndTransform);
            }
        };
        this.handleDragWithTimer = async (event) => {
            if (event != null) {
                // Prevent selection of text and interaction with view cube while dragging the widget
                event.preventDefault();
                this.lastMouseEvent = event;
            }
            if (this.interactionTimer == null) {
                this.interactionTimer = window.setTimeout(async () => {
                    this.interactionTimer = undefined;
                    await this.handleDrag();
                    this.lastMouseEvent = undefined;
                }, this.interactionThrottle);
            }
        };
        this.handleDrag = async () => {
            var _a, _b, _c;
            const canvasBounds = this.getCanvasBounds();
            if (this.dragging != null &&
                this.lastWorldPosition != null &&
                canvasBounds != null &&
                this.viewer != null &&
                this.viewer.frame != null &&
                this.position != null &&
                this.lastMouseEvent != null) {
                // Begin the transform on the first `pointermove` event as opposed to the
                // `pointerdown` to prevent accidental no-op transforms (identity matrix).
                await ((_a = this.controller) === null || _a === void 0 ? void 0 : _a.beginTransform());
                const currentCanvas = convertPointToCanvas(Point.create(this.lastMouseEvent.clientX, this.lastMouseEvent.clientY), canvasBounds);
                const widgetCenter = this.viewer.viewport.transformWorldToViewport(this.position, this.viewer.frame.scene.camera.projectionViewMatrix);
                const currentWorld = convertCanvasPointToWorld(currentCanvas, (_b = this.viewer) === null || _b === void 0 ? void 0 : _b.frame, (_c = this.viewer) === null || _c === void 0 ? void 0 : _c.viewport, this.currentTransform);
                if (currentWorld != null &&
                    currentCanvas != null &&
                    widgetCenter != null) {
                    const angle = Angle.fromPoints(widgetCenter, currentCanvas);
                    const angleToUse = calculateNewRotationAngle(this.lastMouseEvent, this.rotationSnapKey, angle, this.lastAngle, this.getDisplayedAngle(), this.rotationSnapDegrees);
                    this.transform(this.lastWorldPosition, currentWorld, angleToUse - this.lastAngle);
                    this.updateInputPosition();
                    this.updateInputValue();
                    this.lastWorldPosition = currentWorld;
                    this.lastAngle = angleToUse;
                }
            }
        };
        this.handleEndTransform = async (event) => {
            var _a, _b;
            const canvasPoint = convertPointToCanvas(Point.create(event.clientX, event.clientY), this.getCanvasBounds());
            const widget = this.getTransformWidget();
            this.lastDragged = this.dragging;
            this.dragging = undefined;
            this.lastWorldPosition = undefined;
            this.lastAngle = 0;
            this.updateInputPosition();
            this.updateInputValue();
            widget.updateCursor(canvasPoint);
            widget.updateTransform(this.currentTransform);
            this.beginEndTransform();
            window.removeEventListener('pointermove', this.handleDragWithTimer);
            window.removeEventListener('pointerup', this.handleEndTransform);
            try {
                const delta = (_a = this.controller) === null || _a === void 0 ? void 0 : _a.getCurrentDelta();
                await ((_b = this.controller) === null || _b === void 0 ? void 0 : _b.endTransform());
                this.interactionEnded.emit(delta);
            }
            catch (e) {
                console.error('Failed to end transform interaction', e);
            }
            window.addEventListener('pointermove', this.handlePointerMove);
            this.completeEndTransform();
        };
        this.handleInputStep = async (step) => {
            if (this.inputValue != null && this.lastInputValue != null) {
                // If modifying angle units, we want to adjust the step to always
                // perform the equivalent of a 1 degree rotation.
                if (this.isModifyingAngleUnits()) {
                    const angles = new AngleUnits(this.angleUnit);
                    const previous = angles.convertFrom(this.lastInputValue);
                    const next = Angle.normalizeRadians(previous + Angle.toRadians(step));
                    this.inputValue = angles.convertTo(next);
                }
                else {
                    this.inputValue = this.lastInputValue + step;
                }
                await this.updateTransformFromInput(this.inputValue);
            }
        };
        this.handleInputChange = async (value) => {
            await this.updateTransformFromInput(value);
        };
        this.handleKeyDown = async (event) => {
            const commandOrControlModifier = event.ctrlKey || event.metaKey;
            if (event.key === 'z' &&
                commandOrControlModifier &&
                this.EXPERIMENTAL_undoKeybindings) {
                event.stopPropagation();
                await this.EXPERIMENTAL_undo();
            }
        };
        this.updateTransformFromInput = async (value) => {
            var _a, _b, _c;
            if (this.lastDragged != null &&
                this.currentTransform != null &&
                this.startingTransform != null &&
                this.lastInputValue != null) {
                this.currentTransform = computeInputDeltaTransform(this.currentTransform, this.lastDragged.identifier, value, this.lastInputValue, this.distanceUnit, this.angleUnit);
                this.updateInputValue();
                this.lastInputValue = value;
                await ((_a = this.controller) === null || _a === void 0 ? void 0 : _a.beginTransform());
                this.getTransformWidget().updateTransform(this.currentTransform);
                await ((_b = this.controller) === null || _b === void 0 ? void 0 : _b.updateTransform(Matrix4.multiply(this.currentTransform, Matrix4.invert(this.startingTransform))));
                this.updateInputPosition();
                await ((_c = this.controller) === null || _c === void 0 ? void 0 : _c.endTransformDebounced(this.beginEndTransform, this.completeEndTransform));
            }
        };
        this.updatePropsFromViewer = () => {
            const { frame } = this.viewer || {};
            if (frame != null) {
                const widget = this.getTransformWidget();
                widget.updateFrame(frame, this.dragging == null);
                this.updateInputPosition();
            }
        };
        this.setupTransformWidget = (canvasRef) => {
            var _a, _b;
            console.debug(`Initializing transform widget. [initial-position=${JSON.stringify(this.position)}, has-initial-frame=${((_a = this.viewer) === null || _a === void 0 ? void 0 : _a.frame) != null}]`);
            const effectiveArrowScalar = this.getTranslationScalar();
            const effectiveSquareScalar = this.getRotationScalar();
            this.widget = new TransformWidget(canvasRef, {
                colors: {
                    xArrow: this.xArrowColor,
                    yArrow: this.yArrowColor,
                    zArrow: this.zArrowColor,
                    twoAxesSquare: this.twoAxesSquareColor,
                    hovered: this.hoveredColor,
                },
                scalars: {
                    xTranslation: effectiveArrowScalar,
                    yTranslation: effectiveArrowScalar,
                    zTranslation: effectiveArrowScalar,
                    xyTranslation: effectiveSquareScalar,
                    xzTranslation: effectiveSquareScalar,
                    yzTranslation: effectiveSquareScalar,
                    xRotation: effectiveSquareScalar,
                    yRotation: effectiveSquareScalar,
                    zRotation: effectiveSquareScalar,
                },
            });
            if (this.rotation != null) {
                this.currentTransform = this.getTransformForNewRotation(this.rotation);
                this.startingTransform = this.currentTransform;
                this.widget.updateTransform(this.currentTransform);
            }
            if (this.position != null) {
                this.currentTransform = this.getTransformForNewPosition(this.position);
                this.startingTransform = this.currentTransform;
                this.widget.updateTransform(this.currentTransform);
            }
            if (((_b = this.viewer) === null || _b === void 0 ? void 0 : _b.frame) != null) {
                this.widget.updateFrame(this.viewer.frame, true);
            }
            this.handleSettingDisabledAxis();
            this.hoveredChangeDisposable = this.widget.onHoveredChanged(this.handleHoveredDrawableChanged);
            return this.widget;
        };
        this.updateCanvasBounds = (canvasElement) => {
            readDOM(() => {
                this.canvasBounds = canvasElement.getBoundingClientRect();
                this.getTransformWidget().updateDimensions(canvasElement);
            });
        };
        this.updateInputValue = () => {
            var _a, _b, _c;
            const dragging = (_a = this.dragging) !== null && _a !== void 0 ? _a : this.lastDragged;
            const isDraggingTwoAxesTranslation = (dragging === null || dragging === void 0 ? void 0 : dragging.identifier) === 'xy-translate' ||
                (dragging === null || dragging === void 0 ? void 0 : dragging.identifier) === 'xz-translate' ||
                (dragging === null || dragging === void 0 ? void 0 : dragging.identifier) === 'yz-translate';
            if (dragging != null &&
                this.currentTransform != null &&
                this.dragStartTransform != null &&
                !isDraggingTwoAxesTranslation) {
                this.lastInputValue = this.inputValue;
                this.inputValue = computeInputDisplayValue(dragging.identifier, this.currentTransform, this.dragStartTransform, this.distanceUnit, this.angleUnit);
                if (this.inputRef != null) {
                    const definedValue = (_c = (_b = this.getDisplayedDistance()) !== null && _b !== void 0 ? _b : this.getDisplayedAngle()) !== null && _c !== void 0 ? _c : 0;
                    const displayValue = `${parseFloat(definedValue.toFixed(this.decimalPlaces))}`;
                    this.inputRef.value = displayValue;
                }
            }
        };
        this.updateInputPosition = () => {
            var _a, _b;
            const dragging = (_a = this.dragging) !== null && _a !== void 0 ? _a : this.lastDragged;
            const isDraggingTwoAxesTranslation = (dragging === null || dragging === void 0 ? void 0 : dragging.identifier) === 'xy-translate' ||
                (dragging === null || dragging === void 0 ? void 0 : dragging.identifier) === 'xz-translate' ||
                (dragging === null || dragging === void 0 ? void 0 : dragging.identifier) === 'yz-translate';
            if (this.showInputs &&
                ((_b = this.viewer) === null || _b === void 0 ? void 0 : _b.frame) != null &&
                this.position != null &&
                dragging != null &&
                !isDraggingTwoAxesTranslation) {
                const widget = this.getTransformWidget();
                const widgetBounds = widget.getFullBounds();
                this.inputPosition =
                    widgetBounds != null
                        ? computeInputPosition(this.viewer.viewport, widgetBounds, dragging.points.toArray())
                        : undefined;
            }
            else if (isDraggingTwoAxesTranslation) {
                this.inputPosition = undefined;
            }
        };
        this.beginEndTransform = () => {
            const widget = this.getTransformWidget();
            widget.updateDisabledAxis({
                xRotation: true,
                yRotation: true,
                zRotation: true,
                xTranslation: true,
                yTranslation: true,
                zTranslation: true,
                xyTranslation: true,
                xzTranslation: true,
                yzTranslation: true,
            });
            this.isEndingTransform = true;
        };
        this.completeEndTransform = () => {
            const widget = this.getTransformWidget();
            widget.updateDisabledAxis({
                xRotation: this.xRotationDisabled,
                yRotation: this.yRotationDisabled,
                zRotation: this.zRotationDisabled,
                xTranslation: this.xTranslationDisabled,
                yTranslation: this.yTranslationDisabled,
                zTranslation: this.zTranslationDisabled,
                xyTranslation: this.xyTranslationDisabled,
                xzTranslation: this.xzTranslationDisabled,
                yzTranslation: this.yzTranslationDisabled,
            });
            this.isEndingTransform = false;
            this.inputShouldFocus = true;
            if (this.currentTransform != null) {
                this.position = Vector3.fromMatrixPosition(this.currentTransform);
                this.rotation = Euler.fromRotationMatrix(this.currentTransform);
            }
        };
        this.isModifyingAngleUnits = () => {
            var _a, _b, _c;
            const draggingIdentifier = (_b = (_a = this.dragging) === null || _a === void 0 ? void 0 : _a.identifier) !== null && _b !== void 0 ? _b : (_c = this.lastDragged) === null || _c === void 0 ? void 0 : _c.identifier;
            return !!(draggingIdentifier === null || draggingIdentifier === void 0 ? void 0 : draggingIdentifier.includes('rotate'));
        };
        this.getTranslationScalar = () => {
            if (this.translationHandleScalar > 0) {
                return this.translationHandleScalar;
            }
            console.warn('Invalid value provided for translation-handle-scalar. Expected a positive value greater than zero.');
            return 1;
        };
        this.getRotationScalar = () => {
            if (this.rotationHandleScalar > 0) {
                return this.rotationHandleScalar;
            }
            console.warn('Invalid value provided for rotation-handle-scalar. Expected a positive value greater than zero.');
            return 1;
        };
        this.getDisplayedUnits = () => {
            if (this.isModifyingAngleUnits()) {
                return new AngleUnits(this.angleUnit);
            }
            return new DistanceUnits(this.distanceUnit);
        };
        this.getDisplayedAngle = () => {
            if (this.isModifyingAngleUnits()) {
                return this.inputValue;
            }
        };
        this.getDisplayedDistance = () => {
            var _a, _b, _c;
            const draggingIdentifier = (_b = (_a = this.dragging) === null || _a === void 0 ? void 0 : _a.identifier) !== null && _b !== void 0 ? _b : (_c = this.lastDragged) === null || _c === void 0 ? void 0 : _c.identifier;
            if (draggingIdentifier === null || draggingIdentifier === void 0 ? void 0 : draggingIdentifier.includes('translate')) {
                return this.inputValue;
            }
        };
        this.getTransformForNewPosition = (newPosition) => {
            if (newPosition != null) {
                const c = this.currentTransform != null
                    ? this.currentTransform
                    : Matrix4.makeIdentity();
                const currentRotation = Matrix4.makeRotation(Quaternion.fromMatrixRotation(c));
                const position = Matrix4.makeTranslation(newPosition);
                return Matrix4.multiply(position, currentRotation);
            }
        };
        this.getTransformForNewRotation = (newRotationEuler) => {
            const c = this.currentTransform != null
                ? this.currentTransform
                : Matrix4.makeIdentity();
            const oldRotation = Matrix4.invert(Matrix4.makeRotation(Quaternion.fromMatrixRotation(c)));
            const newRotation = Matrix4.makeRotation(Quaternion.fromEuler(newRotationEuler));
            const oldTranslation = Matrix4.multiply(c, oldRotation);
            return Matrix4.multiply(oldTranslation, newRotation);
        };
        this.getCanvasBounds = () => {
            if (this.canvasBounds != null) {
                return this.canvasBounds;
            }
            else if (this.canvasRef != null) {
                this.updateCanvasBounds(this.canvasRef);
                return this.canvasBounds;
            }
        };
        this.getTransformWidget = () => {
            if (this.widget == null && this.canvasRef != null) {
                return this.setupTransformWidget(this.canvasRef);
            }
            else if (this.widget != null) {
                return this.widget;
            }
            else {
                throw new Error('Transform widget was not initialized. The canvas element may not have been initialized.');
            }
        };
    }
    componentDidLoad() {
        window.addEventListener('pointermove', this.handlePointerMove);
        this.canvasResizeObserver = new ResizeObserver(this.handleResize);
        this.inputResizeObserver = new ResizeObserver(this.handleInputResize);
        this.hostStyleObserver = new MutationObserver(this.handleStyleChange);
        if (this.canvasRef != null) {
            this.canvasResizeObserver.observe(this.canvasRef);
            this.setupTransformWidget(this.canvasRef);
        }
        this.hostStyleObserver.observe(this.hostEl, {
            attributes: true,
            attributeFilter: ['style'],
        });
        this.handleViewerChanged(this.viewer, undefined);
        this.handleStyleChange();
    }
    disconnectedCallback() {
        var _a, _b, _c, _d, _e;
        window.removeEventListener('pointermove', this.handlePointerMove);
        (_a = this.canvasResizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
        (_b = this.inputResizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
        (_c = this.hostStyleObserver) === null || _c === void 0 ? void 0 : _c.disconnect();
        (_d = this.hoveredChangeDisposable) === null || _d === void 0 ? void 0 : _d.dispose();
        (_e = this.widget) === null || _e === void 0 ? void 0 : _e.dispose();
    }
    componentDidRender() {
        if (this.inputShouldFocus && this.inputRef != null) {
            focusInputElement(this.inputRef);
            this.inputShouldFocus = false;
        }
    }
    /**
     * **EXPERIMENTAL.**
     *
     * Performs an undo of the most recent set of transform manipulations,
     * categorized by the last pause in interactivity (pointerup on a handle,
     * Enter press on an input, keyup on an input).
     *
     * Note that this *does not* work repeatedly. I.e. only one undo can be
     * performed, and once another set of transform manipulations is performed,
     * the history is lost.
     */
    async EXPERIMENTAL_undo() {
        var _a, _b;
        const undoDelta = await ((_a = this.controller) === null || _a === void 0 ? void 0 : _a.EXPERIMENTAL_undoTransform());
        if (this.currentTransform != null && undoDelta != null) {
            this.currentTransform = Matrix4.multiply(undoDelta, this.currentTransform);
            (_b = this.widget) === null || _b === void 0 ? void 0 : _b.updateTransform(this.currentTransform);
            this.updateInputPosition();
            this.updateInputValue();
            this.lastInputValue = this.inputValue;
            this.position = Vector3.fromMatrixPosition(this.currentTransform);
            this.rotation = Euler.fromRotationMatrix(this.currentTransform);
        }
    }
    /**
     * @ignore
     */
    handleViewerChanged(newViewer, oldViewer) {
        var _a;
        oldViewer === null || oldViewer === void 0 ? void 0 : oldViewer.removeEventListener('frameDrawn', this.handleViewerFrameDrawn);
        oldViewer === null || oldViewer === void 0 ? void 0 : oldViewer.removeEventListener('dimensionschange', this.handleViewerDimensionsChange);
        newViewer === null || newViewer === void 0 ? void 0 : newViewer.addEventListener('frameDrawn', this.handleViewerFrameDrawn);
        newViewer === null || newViewer === void 0 ? void 0 : newViewer.addEventListener('dimensionschange', this.handleViewerDimensionsChange);
        if ((newViewer === null || newViewer === void 0 ? void 0 : newViewer.stream) != null) {
            (_a = this.controller) === null || _a === void 0 ? void 0 : _a.dispose();
            this.controller = new TransformController(newViewer.stream);
        }
    }
    /**
     * @ignore
     */
    handleDisabledPropertyChanged() {
        var _a;
        (_a = this.widget) === null || _a === void 0 ? void 0 : _a.updateDisabledAxis({
            xRotation: this.xRotationDisabled,
            yRotation: this.yRotationDisabled,
            zRotation: this.zRotationDisabled,
            xTranslation: this.xTranslationDisabled,
            yTranslation: this.yTranslationDisabled,
            zTranslation: this.zTranslationDisabled,
            xyTranslation: this.xyTranslationDisabled,
            xzTranslation: this.xzTranslationDisabled,
            yzTranslation: this.yzTranslationDisabled,
        });
    }
    /**
     * @ignore
     */
    handleTransformHandleScalarChanged() {
        var _a;
        const effectiveArrowScalar = this.getTranslationScalar();
        const effectiveSquareScalar = this.getRotationScalar();
        (_a = this.widget) === null || _a === void 0 ? void 0 : _a.updateScalars({
            xTranslation: effectiveArrowScalar,
            yTranslation: effectiveArrowScalar,
            zTranslation: effectiveArrowScalar,
            xyTranslation: effectiveSquareScalar,
            xzTranslation: effectiveSquareScalar,
            yzTranslation: effectiveSquareScalar,
            xRotation: effectiveSquareScalar,
            yRotation: effectiveSquareScalar,
            zRotation: effectiveSquareScalar,
        });
    }
    /**
     * @ignore
     */
    handleRotationChanged(newRotation, oldRotation) {
        var _a;
        const rotationToApply = newRotation !== null && newRotation !== void 0 ? newRotation : Euler.create();
        this.currentTransform = this.getTransformForNewRotation(rotationToApply);
        this.startingTransform = this.currentTransform;
        // If the removal of the previous rotation above results in an identity matrix,
        // clear the transformation on the widget to prevent it from appearing at the origin.
        if (newRotation == null &&
            this.currentTransform != null &&
            Matrix4.isIdentity(this.currentTransform)) {
            this.currentTransform = undefined;
            this.startingTransform = this.currentTransform;
        }
        (_a = this.widget) === null || _a === void 0 ? void 0 : _a.updateTransform(this.currentTransform);
        console.debug(`Updating widget rotation [previous=${JSON.stringify(oldRotation)}, current=${JSON.stringify(newRotation)}]`);
        this.rotationChanged.emit(newRotation);
    }
    /**
     * @ignore
     */
    handlePositionChanged(newPosition, oldPosition) {
        var _a, _b;
        this.currentTransform = this.getTransformForNewPosition(newPosition);
        this.startingTransform = this.currentTransform;
        console.debug(`Updating widget position [previous=${JSON.stringify(oldPosition)}, current=${JSON.stringify(newPosition)}]`);
        (_a = this.widget) === null || _a === void 0 ? void 0 : _a.updateTransform(this.currentTransform);
        if (newPosition == null) {
            this.lastDragged = undefined;
            this.inputPosition = undefined;
            (_b = this.controller) === null || _b === void 0 ? void 0 : _b.clearTransform();
        }
        this.positionChanged.emit(newPosition);
    }
    /**
     * @ignore
     */
    handleInputFormattingChanged() {
        this.updateInputValue();
        this.lastInputValue = this.inputValue;
    }
    render() {
        var _a, _b, _c, _d, _e, _f;
        return (h(Host, { key: 'cf84e5bc2f1ab1878b131f3cd9be1548a5c82646' }, h("canvas", { key: '255699b0cb6a07ab8be50f0c81e0b7df5feb9719', ref: (el) => {
                this.canvasRef = el;
            }, class: classNames('widget', {
                hovered: this.hovered != null,
            }), tabindex: "0", width: (_a = this.viewer) === null || _a === void 0 ? void 0 : _a.viewport.width, height: (_b = this.viewer) === null || _b === void 0 ? void 0 : _b.viewport.height, onPointerDown: this.handleBeginDrag, onKeyDown: this.handleKeyDown }), this.showInputs && this.inputPosition && ((_c = this.viewer) === null || _c === void 0 ? void 0 : _c.viewport) && (h(TransformWidgetInputWrapper, { key: '5fa899a22f96025973a53defc673e9e9650d5ef4', ref: (el) => {
                var _a, _b;
                if (el != null) {
                    (_a = this.inputResizeObserver) === null || _a === void 0 ? void 0 : _a.observe(el);
                }
                else if (this.inputRef != null) {
                    (_b = this.inputResizeObserver) === null || _b === void 0 ? void 0 : _b.unobserve(this.inputRef);
                }
                this.inputWrapperRef = el;
            }, bounds: this.inputBounds, viewport: this.viewer.viewport, point: this.inputPosition.point, placement: this.inputPosition.placement, displayUnit: this.getDisplayedUnits() }, h(TransformWidgetInput, { key: 'db03509252b8e72fb975337274e693cc4d0bebf1', ref: (el) => {
                this.inputRef = el;
            }, identifier: (_e = (_d = this.dragging) === null || _d === void 0 ? void 0 : _d.identifier) !== null && _e !== void 0 ? _e : (_f = this.lastDragged) === null || _f === void 0 ? void 0 : _f.identifier, disabled: this.isEndingTransform, onChange: this.handleInputChange, onIncrement: () => this.handleInputStep(1), onDecrement: () => this.handleInputStep(-1), onBlur: () => {
                this.inputShouldFocus = false;
            }, onUndo: this.EXPERIMENTAL_undoKeybindings
                ? () => this.EXPERIMENTAL_undo()
                : undefined })))));
    }
    transform(previous, next, angle) {
        var _a, _b;
        if (this.position != null &&
            this.startingTransform != null &&
            this.currentTransform != null &&
            this.dragging != null &&
            this.viewer != null &&
            this.viewer.frame != null) {
            this.currentTransform = computeHandleDeltaTransform(this.currentTransform, previous, next, (_a = this.viewer) === null || _a === void 0 ? void 0 : _a.frame.scene.camera.viewVector, angle, this.dragging.identifier);
            this.getTransformWidget().updateTransform(this.currentTransform);
            (_b = this.controller) === null || _b === void 0 ? void 0 : _b.updateTransform(Matrix4.multiply(this.currentTransform, Matrix4.invert(this.startingTransform)));
        }
    }
    handleSettingDisabledAxis() {
        if (this.widget) {
            this.widget.updateDisabledAxis({
                xRotation: this.xRotationDisabled,
                yRotation: this.yRotationDisabled,
                zRotation: this.zRotationDisabled,
                xTranslation: this.xTranslationDisabled,
                yTranslation: this.yTranslationDisabled,
                zTranslation: this.zTranslationDisabled,
                xyTranslation: this.xyTranslationDisabled,
                xzTranslation: this.xzTranslationDisabled,
                yzTranslation: this.yzTranslationDisabled,
            });
        }
        else {
            console.warn('Cannot set disabled values - no widget defined');
        }
    }
    static get is() { return "vertex-viewer-transform-widget"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["viewer-transform-widget.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["viewer-transform-widget.css"]
        };
    }
    static get properties() {
        return {
            "viewer": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "HTMLVertexViewerElement",
                    "resolved": "HTMLVertexViewerElement | undefined",
                    "references": {
                        "HTMLVertexViewerElement": {
                            "location": "global",
                            "id": "global::HTMLVertexViewerElement"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "The viewer to connect to transforms. If nested within a <vertex-viewer>,\nthis property will be populated automatically."
                },
                "getter": false,
                "setter": false
            },
            "position": {
                "type": "unknown",
                "mutable": true,
                "complexType": {
                    "original": "Vector3.Vector3",
                    "resolved": "Vector3 | undefined",
                    "references": {
                        "Vector3": {
                            "location": "import",
                            "path": "@vertexvis/geometry",
                            "id": "../geometry/dist/index.d.ts::\"/home/runner/work/vertex-web-sdk/vertex-web-sdk/packages/geometry/dist/vector3\"",
                            "referenceLocation": "Vector3"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "The starting position of this transform widget. This position will be updated\nas transforms occur. Setting this value to `undefined` will remove the widget."
                },
                "getter": false,
                "setter": false
            },
            "rotation": {
                "type": "unknown",
                "mutable": true,
                "complexType": {
                    "original": "Euler.Euler",
                    "resolved": "Euler | undefined",
                    "references": {
                        "Euler": {
                            "location": "import",
                            "path": "@vertexvis/geometry",
                            "id": "../geometry/dist/index.d.ts::\"/home/runner/work/vertex-web-sdk/vertex-web-sdk/packages/geometry/dist/euler\"",
                            "referenceLocation": "Euler"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "The starting angle for the transform widget. This rotation will be updated\nas the rotations occur."
                },
                "getter": false,
                "setter": false
            },
            "controller": {
                "type": "unknown",
                "mutable": true,
                "complexType": {
                    "original": "TransformController",
                    "resolved": "TransformController | undefined",
                    "references": {
                        "TransformController": {
                            "location": "import",
                            "path": "../../lib/transforms/controller",
                            "id": "src/lib/transforms/controller.ts::TransformController",
                            "referenceLocation": "TransformController"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "The controller that is responsible for performing transforms."
                },
                "getter": false,
                "setter": false
            },
            "xRotationDisabled": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Determines whether the x-rotation is disabled on the widget"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "x-rotation-disabled",
                "defaultValue": "false"
            },
            "yRotationDisabled": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Determines whether the y-rotation is disabled on the widget"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "y-rotation-disabled",
                "defaultValue": "false"
            },
            "zRotationDisabled": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Determines whether the z-rotation is disabled on the widget"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "z-rotation-disabled",
                "defaultValue": "false"
            },
            "xTranslationDisabled": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Determines whether the x-translation is disabled on the widget"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "x-translation-disabled",
                "defaultValue": "false"
            },
            "yTranslationDisabled": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Determines whether the y-translation is disabled on the widget"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "y-translation-disabled",
                "defaultValue": "false"
            },
            "zTranslationDisabled": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Determines whether the z-translation is disabled on the widget"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "z-translation-disabled",
                "defaultValue": "false"
            },
            "xyTranslationDisabled": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Determines whether the xy-translation is disabled on the widget"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "xy-translation-disabled",
                "defaultValue": "false"
            },
            "xzTranslationDisabled": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Determines whether the xz-translation is disabled on the widget"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "xz-translation-disabled",
                "defaultValue": "false"
            },
            "yzTranslationDisabled": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Determines whether the yz-translation is disabled on the widget"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "yz-translation-disabled",
                "defaultValue": "false"
            },
            "showInputs": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Whether to show inputs beside the widget handles when they are interacted with.\nDefaults to `true`."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "show-inputs",
                "defaultValue": "true"
            },
            "distanceUnit": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "DistanceUnitType",
                    "resolved": "\"centimeters\" | \"feet\" | \"inches\" | \"meters\" | \"millimeters\" | \"yards\"",
                    "references": {
                        "DistanceUnitType": {
                            "location": "import",
                            "path": "../../lib/types",
                            "id": "src/lib/types/index.ts::DistanceUnitType",
                            "referenceLocation": "DistanceUnitType"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "see",
                            "text": "DistanceUnitType"
                        }],
                    "text": "The unit to show for translation inputs. Defaults to `millimeters`."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "distance-unit",
                "defaultValue": "'millimeters'"
            },
            "angleUnit": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "AngleUnitType",
                    "resolved": "\"degrees\" | \"radians\"",
                    "references": {
                        "AngleUnitType": {
                            "location": "import",
                            "path": "../../lib/types",
                            "id": "src/lib/types/index.ts::AngleUnitType",
                            "referenceLocation": "AngleUnitType"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "see",
                            "text": "AngleUnitType"
                        }],
                    "text": "The unit to show for rotation inputs. Defaults to `degrees`."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "angle-unit",
                "defaultValue": "'degrees'"
            },
            "decimalPlaces": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The number of decimal places to show in the input. Defaults to `1`."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "decimal-places",
                "defaultValue": "1"
            },
            "rotationSnapDegrees": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "When defined, the widget will snap to the degree of the nearest multiple of\nthe given number when the user is rotating with the widget and holding the\nkey defined by rotationSnapKey. Defaults to undefined."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "rotation-snap-degrees"
            },
            "rotationSnapKey": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "ModifierKey",
                    "resolved": "\"alt\" | \"ctrl\" | \"meta\" | \"shift\"",
                    "references": {
                        "ModifierKey": {
                            "location": "import",
                            "path": "../../lib/types/keys",
                            "id": "src/lib/types/keys.ts::ModifierKey",
                            "referenceLocation": "ModifierKey"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "When rotationSnapDegrees is defined, the widget will snap to the degree of the\nnearest multiple of the given number when the user is rotating with the widget\nand holding the key defined here. Defaults to the shift key."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "rotation-snap-key",
                "defaultValue": "'shift'"
            },
            "translationHandleScalar": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Scalar to increase the size of the translation handles of this widget.\nValues above zero and below three will result in the best visual representation\nof the handles, and values above three may produce unexpected results.\n\nDefaults to `1`."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "translation-handle-scalar",
                "defaultValue": "1"
            },
            "rotationHandleScalar": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Scalar to increase the size of the rotation handles of this widget.\nValues above zero and below three will result in the best visual representation\nof the handles, and values above three may produce unexpected results.\n\nDefaults to `1`."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "rotation-handle-scalar",
                "defaultValue": "1"
            },
            "interactionThrottle": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Specifies the frequency, in milliseconds, to update the transform while interacting with the widget.\n\nThis delay is used to group events happening in quick succession and results in smoother\nwidget movement."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "interaction-throttle",
                "defaultValue": "75"
            },
            "EXPERIMENTAL_undoKeybindings": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "see",
                            "text": " `EXPERIMENTAL_undo`"
                        }],
                    "text": "**EXPERIMENTAL.**\n\nEnables Command+Z and Control+Z keybindings to perform an undo of\nthe previous delta transformation."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "e-x-p-e-r-i-m-e-n-t-a-l_undo-keybindings",
                "defaultValue": "false"
            },
            "hovered": {
                "type": "unknown",
                "mutable": true,
                "complexType": {
                    "original": "Drawable",
                    "resolved": "Drawable<DrawablePoints> | undefined",
                    "references": {
                        "Drawable": {
                            "location": "import",
                            "path": "../../lib/transforms/drawable",
                            "id": "src/lib/transforms/drawable.ts::Drawable",
                            "referenceLocation": "Drawable"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [{
                            "name": "internal",
                            "text": undefined
                        }, {
                            "name": "ignore",
                            "text": "Visible for testing."
                        }],
                    "text": ""
                },
                "getter": false,
                "setter": false
            }
        };
    }
    static get states() {
        return {
            "inputPosition": {},
            "inputValue": {},
            "isEndingTransform": {},
            "inputShouldFocus": {}
        };
    }
    static get events() {
        return [{
                "method": "positionChanged",
                "name": "positionChanged",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "An event that is emitted when the position of the widget changes."
                },
                "complexType": {
                    "original": "Vector3.Vector3 | undefined",
                    "resolved": "Vector3 | undefined",
                    "references": {
                        "Vector3": {
                            "location": "import",
                            "path": "@vertexvis/geometry",
                            "id": "../geometry/dist/index.d.ts::\"/home/runner/work/vertex-web-sdk/vertex-web-sdk/packages/geometry/dist/vector3\"",
                            "referenceLocation": "Vector3"
                        }
                    }
                }
            }, {
                "method": "rotationChanged",
                "name": "rotationChanged",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "An event that is emitted when the rotation of the widget changes."
                },
                "complexType": {
                    "original": "Euler.Euler | undefined",
                    "resolved": "Euler | undefined",
                    "references": {
                        "Euler": {
                            "location": "import",
                            "path": "@vertexvis/geometry",
                            "id": "../geometry/dist/index.d.ts::\"/home/runner/work/vertex-web-sdk/vertex-web-sdk/packages/geometry/dist/euler\"",
                            "referenceLocation": "Euler"
                        }
                    }
                }
            }, {
                "method": "interactionEnded",
                "name": "interactionEnded",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "An event that is emitted when the interaction has ended"
                },
                "complexType": {
                    "original": "Matrix4.Matrix4 | undefined",
                    "resolved": "[number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number] | undefined",
                    "references": {
                        "Matrix4": {
                            "location": "import",
                            "path": "@vertexvis/geometry",
                            "id": "../geometry/dist/index.d.ts::\"/home/runner/work/vertex-web-sdk/vertex-web-sdk/packages/geometry/dist/matrix4\"",
                            "referenceLocation": "Matrix4"
                        }
                    }
                }
            }, {
                "method": "interactionStarted",
                "name": "interactionStarted",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "An event that is emitted an interaction with the widget has started"
                },
                "complexType": {
                    "original": "void",
                    "resolved": "void",
                    "references": {}
                }
            }];
    }
    static get methods() {
        return {
            "EXPERIMENTAL_undo": {
                "complexType": {
                    "signature": "() => Promise<void>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "**EXPERIMENTAL.**\n\nPerforms an undo of the most recent set of transform manipulations,\ncategorized by the last pause in interactivity (pointerup on a handle,\nEnter press on an input, keyup on an input).\n\nNote that this *does not* work repeatedly. I.e. only one undo can be\nperformed, and once another set of transform manipulations is performed,\nthe history is lost.",
                    "tags": []
                }
            }
        };
    }
    static get elementRef() { return "hostEl"; }
    static get watchers() {
        return [{
                "propName": "viewer",
                "methodName": "handleViewerChanged"
            }, {
                "propName": "xTranslationDisabled",
                "methodName": "handleDisabledPropertyChanged"
            }, {
                "propName": "yTranslationDisabled",
                "methodName": "handleDisabledPropertyChanged"
            }, {
                "propName": "zTranslationDisabled",
                "methodName": "handleDisabledPropertyChanged"
            }, {
                "propName": "xyTranslationDisabled",
                "methodName": "handleDisabledPropertyChanged"
            }, {
                "propName": "xzTranslationDisabled",
                "methodName": "handleDisabledPropertyChanged"
            }, {
                "propName": "yzTranslationDisabled",
                "methodName": "handleDisabledPropertyChanged"
            }, {
                "propName": "xRotationDisabled",
                "methodName": "handleDisabledPropertyChanged"
            }, {
                "propName": "yRotationDisabled",
                "methodName": "handleDisabledPropertyChanged"
            }, {
                "propName": "zRotationDisabled",
                "methodName": "handleDisabledPropertyChanged"
            }, {
                "propName": "translationHandleScalar",
                "methodName": "handleTransformHandleScalarChanged"
            }, {
                "propName": "rotationHandleScalar",
                "methodName": "handleTransformHandleScalarChanged"
            }, {
                "propName": "rotation",
                "methodName": "handleRotationChanged"
            }, {
                "propName": "position",
                "methodName": "handlePositionChanged"
            }, {
                "propName": "distanceUnit",
                "methodName": "handleInputFormattingChanged"
            }, {
                "propName": "angleUnit",
                "methodName": "handleInputFormattingChanged"
            }, {
                "propName": "decimalPlaces",
                "methodName": "handleInputFormattingChanged"
            }];
    }
}
//# sourceMappingURL=viewer-transform-widget.js.map
