/* @oracle/oraclejet-preact: undefined */
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var Dialog = require('./Dialog-4a0ba834.js');
var hooks = require('preact/hooks');
require('preact/jsx-runtime');
require('preact/compat');
require('./WindowOverlay-7ef8a86f.js');
require('./mergeInterpolations-6727b536.js');
require('./classNames-c14c6ef3.js');
require('./mergeDeepWithKey-210b024d.js');
require('./_curry3-18677bca.js');
require('./_curry1-e8f0d7ea.js');
require('./_curry2-c15d89cd.js');
require('./_isObject-28636267.js');
require('./vanilla-extract-dynamic.esm-d5dffce7.js');
require('./UNSAFE_WindowOverlay/themes/WindowOverlayStyles.css.js');

require('./UNSAFE_WindowOverlay/themes/WindowOverlayContract.css.js');
require('./useUser-c85f9587.js');
require('./LayerHost-8ec73638.js');
require('./Common/themes/redwood/theme.js');
require('./Common/themes/themeContract.css.js');
require('preact');
require('./UNSAFE_Layer/themes/LayerHostStyles.css.js');

require('./useComponentTheme-082fc8e4.js');
require('./logger-2b636482.js');
require('./UNSAFE_WindowOverlay/themes/redwood/WindowOverlayTheme.js');
require('./UNSAFE_WindowOverlay/themes/redwood/WindowOverlayBaseTheme.css.js');

require('./UNSAFE_WindowOverlay/themes/redwood/WindowOverlayVariants.css.js');
require('./vanilla-extract-recipes-createRuntimeFn.esm-d1301b2d.js');
require('./useTestId-32c35bff.js');
require('./useAnimation-fb11e4cc.js');
require('./refUtils-915b985d.js');
require('./UNSAFE_Dialog/themes/redwood/DialogTheme.js');
require('./UNSAFE_Dialog/themes/DialogStyles.css.js');

require('./UNSAFE_Dialog/themes/redwood/DialogBaseTheme.css.js');


require('./UNSAFE_Dialog/themes/redwood/DialogVariants.css.js');
require('./FocusTrap-3d81c5e3.js');
require('./tabbableUtils-66ae6ba3.js');
require('./clientHints-89c01238.js');
require('./head-68d0992f.js');
require('./_arity-c228159c.js');
require('./_isArray-73160ad5.js');
require('./_isString-f4443c9e.js');
require('./FocusTracker-ea643cb1.js');
require('./PRIVATE_FocusTracker/themes/FocusTrackerStyles.css.js');

require('./Layer-2352de5e.js');
require('./UNSAFE_Layer/themes/LayerStyles.css.js');

require('./useThemeInterpolations-e3c7807c.js');
require('./useColorScheme-b4de9e67.js');
require('./useScale-779458a9.js');
require('./theme-dfd6a9fe.js');
require('./Theme-f06687af.js');
require('./useDensity-301606ec.js');
require('./Modal-64a0608b.js');
require('./useModal-0739a528.js');
require('./UNSAFE_Modal/themes/ModalStyles.css.js');

require('./popupUtils-79b1d484.js');
require('./ImageVars.css-3fbb1c0b.js');
require('./useId-6c0eeb27.js');
require('./dimensions-b4be9793.js');
require('./size-0056ef1a.js');
require('./utils-606327d1.js');
require('./colorUtils-fe6f2fbf.js');
require('./useResizeObserver-1597395f.js');
require('./useVisAddBusyState-1564f647.js');
require('./VisBusyStateContext-223f53dd.js');
require('./useVisBusyStateContext-090a1870.js');
require('./useDraggable-aa4ac3a2.js');
require('./positionUtils-a780137e.js');
require('./Floating-dd6667de.js');
require('./useFloating-c64ecd7f.js');
require('./useOutsideClick-8e9209c6.js');
require('./arrayUtils-7d8dcfc3.js');
require('./UNSAFE_Floating/themes/redwood/FloatingTheme.js');
require('./UNSAFE_Floating/themes/FloatingStyles.css.js');

require('./UNSAFE_Floating/themes/redwood/FloatingBaseTheme.css.js');

require('./UNSAFE_Floating/themes/redwood/FloatingVariants.css.js');
require('./UNSAFE_Floating/themes/FloatingContract.css.js');
require('./IconButton-fad4e4b2.js');
require('./BaseButton-590432e4.js');
require('./usePress-886180e4.js');
require('./usePressClick-7a34624a.js');
require('./useHover-c099039f.js');
require('./useToggle-3ebba7d8.js');
require('./useActive-6770f917.js');
require('./TabbableModeContext-e99d527e.js');
require('./useTabbableMode-5c8fd9e5.js');
require('./mergeProps-e3da7237.js');
require('./UNSAFE_BaseButton/themes/redwood/BaseButtonTheme.js');
require('./UNSAFE_BaseButton/themes/BaseButtonStyles.css.js');

require('./UNSAFE_BaseButton/themes/redwood/BaseButtonVariants.css.js');

require('./ButtonLabelLayout-b421d34a.js');
require('./Text-15923d58.js');
require('./UNSAFE_Text/themes/TextStyles.css.js');

require('./useButtonLabelLayoutTheme-b7b3bdb6.js');
require('./UNSAFE_ButtonLabelLayout/themes/redwood/ButtonLabelLayoutTheme.js');
require('./UNSAFE_ButtonLabelLayout/themes/ButtonLabelLayoutStyles.css.js');

require('./UNSAFE_ButtonLabelLayout/themes/redwood/ButtonLabelLayoutBaseTheme.css.js');

require('./UNSAFE_ButtonLabelLayout/themes/redwood/ButtonLabelLayoutVariants.css.js');

require('./useTooltip-cf4a15f3.js');
require('./useFocus-1b288fb9.js');
require('./useTouch-4dec8729.js');
require('./hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentTheme.js');
require('./hooks/UNSAFE_useTooltip/themes/TooltipContentStyles.css.js');

require('./hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentBaseTheme.css.js');

require('./hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentVariants.css.js');

require('./tooltipUtils-d461919d.js');
require('./EnvironmentProvider-753342f1.js');
require('./LayerManager-4857dbaf.js');
require('./buttonUtils-1f339a8e.js');
require('./id-86356250.js');
require('./Close-e7ca2eed.js');
require('./Icon-6baa1a6f.js');
require('./UNSAFE_Icon/themes/IconStyle.css.js');

require('./Resizable-e5428244.js');
require('./PRIVATE_Resizable/themes/ResizableStyles.css.js');

require('./useBreakpoints-f5c06998.js');
require('./useTranslationBundle-38c0edae.js');
require('./animationUtils-54852d03.js');

/**
 * A custom hook that adds drag and/or resize capabilities to a component (e. g. Dialog).
 * The hook maintains the original and current position and size and returns handlers and
 * props to be spread on the component to make it "flexible". In addition, allows its consumer
 * to be notified when the drag or resize life-cycle events occur.
 */
const useFlexibleComponent = ({ isDisabled = false, isDraggable = false, isResizable = false, onDragStart: onDragStartHandler, onDragMove: onDragMoveHandler, onDragEnd: onDragEndHandler, onResizeStart: onResizeStartHandler, onResize: onResizeHandler, onResizeEnd: onResizeEndHandler }) => {
    const [coords, _setCoords] = hooks.useState();
    const [dimensions, setDimensions] = hooks.useState();
    const coordsRef = hooks.useRef(null);
    const origPosRef = hooks.useRef(null);
    const origSizeRef = hooks.useRef(null);
    const setCoords = (coords) => {
        _setCoords({ x: coords.x, y: coords.y });
        coordsRef.current = { x: coords.x, y: coords.y };
    };
    if (isDisabled || (!isDraggable && !isResizable)) {
        return {};
    }
    const onDragStart = (pos) => {
        setCoords({ x: pos.x, y: pos.y });
        origPosRef.current = { x: pos.x, y: pos.y };
        onDragStartHandler?.({
            originalPosition: { x: origPosRef.current.x, y: origPosRef.current.y },
            position: { x: pos.x, y: pos.y }
        });
    };
    const onDragMove = (pos) => {
        setCoords({ x: pos.x, y: pos.y });
        onDragMoveHandler?.({
            originalPosition: { x: origPosRef.current.x, y: origPosRef.current.y },
            position: { x: pos.x, y: pos.y }
        });
    };
    const onDragEnd = (pos) => {
        setCoords({ x: pos.x, y: pos.y });
        onDragEndHandler?.({
            originalPosition: { x: origPosRef.current.x, y: origPosRef.current.y },
            position: { x: pos.x, y: pos.y }
        });
        origPosRef.current = null;
    };
    const onResizeStart = (rect) => {
        setCoords({ x: rect.x, y: rect.y });
        origPosRef.current = { x: rect.x, y: rect.y };
        setDimensions({ width: (rect.width + 'px'), height: (rect.height + 'px') });
        origSizeRef.current = { width: rect.width, height: rect.height };
        onResizeStartHandler?.({
            originalPosition: { x: origPosRef.current.x, y: origPosRef.current.y },
            originalSize: { width: origSizeRef.current.width, height: origSizeRef.current.height },
            position: { x: rect.x, y: rect.y },
            size: { width: rect.width, height: rect.height }
        });
    };
    const onResize = (rect) => {
        setCoords({ x: rect.x, y: rect.y });
        setDimensions({ width: (rect.width + 'px'), height: (rect.height + 'px') });
        onResizeHandler?.({
            originalPosition: { x: origPosRef.current.x, y: origPosRef.current.y },
            originalSize: { width: origSizeRef.current.width, height: origSizeRef.current.height },
            position: { x: rect.x, y: rect.y },
            size: { width: rect.width, height: rect.height }
        });
    };
    const onResizeEnd = (rect) => {
        setCoords({ x: rect.x, y: rect.y });
        setDimensions({ width: (rect.width + 'px'), height: (rect.height + 'px') });
        onResizeEndHandler?.({
            originalPosition: { x: origPosRef.current.x, y: origPosRef.current.y },
            originalSize: { width: origSizeRef.current.width, height: origSizeRef.current.height },
            position: { x: rect.x, y: rect.y },
            size: { width: rect.width, height: rect.height }
        });
        origPosRef.current = null;
        origSizeRef.current = null;
    };
    return {
        ...(isDraggable && { onDragStart, onDragMove, onDragEnd }),
        ...(isResizable && { onResizeStart, onResize, onResizeEnd }),
        ...(coords && { anchorRef: coordsRef }),
        ...(dimensions && { width: dimensions.width, height: dimensions.height })
    };
};

exports.Dialog = Dialog.Dialog;
exports.useFlexibleComponent = useFlexibleComponent;
//# sourceMappingURL=UNSAFE_Dialog.js.map
