/* @oracle/oraclejet-preact: undefined */
export { D as Dialog } from './Dialog-fbbcc306.js';
import { useState, useRef } from 'preact/hooks';
import 'preact/jsx-runtime';
import 'preact/compat';
import './WindowOverlay-a07b2e24.js';
import './mergeInterpolations-e2db2a66.js';
import './classNames-4e12b00d.js';
import './mergeDeepWithKey-08531060.js';
import './_curry3-0b4222d7.js';
import './_curry1-25297e59.js';
import './_curry2-34316bcf.js';
import './_isObject-1fab0f5b.js';
import './vanilla-extract-dynamic.esm-2955d60a.js';
import './UNSAFE_WindowOverlay/themes/WindowOverlayStyles.css.js';
import './WindowOverlayStyles.styles.css';
import './UNSAFE_WindowOverlay/themes/WindowOverlayContract.css.js';
import './useUser-1cd223a9.js';
import './LayerHost-e6402730.js';
import './Common/themes/redwood/theme.js';
import './Common/themes/themeContract.css.js';
import 'preact';
import './UNSAFE_Layer/themes/LayerHostStyles.css.js';
import './LayerHostStyles.styles.css';
import './useComponentTheme-d2f9e47f.js';
import './logger-c92f309c.js';
import './UNSAFE_WindowOverlay/themes/redwood/WindowOverlayTheme.js';
import './UNSAFE_WindowOverlay/themes/redwood/WindowOverlayBaseTheme.css.js';
import './UNSAFE_WindowOverlay/themes/redwood/WindowOverlayBaseTheme.styles.css';
import './UNSAFE_WindowOverlay/themes/redwood/WindowOverlayVariants.css.js';
import './vanilla-extract-recipes-createRuntimeFn.esm-2aaf8c98.js';
import './useTestId-9b504481.js';
import './useAnimation-a5eb7604.js';
import './refUtils-b9d8d91a.js';
import './UNSAFE_Dialog/themes/redwood/DialogTheme.js';
import './UNSAFE_Dialog/themes/DialogStyles.css.js';
import './DialogStyles.styles.css';
import './UNSAFE_Dialog/themes/redwood/DialogBaseTheme.css.js';
import './ImageVars.styles.css';
import './UNSAFE_Dialog/themes/redwood/DialogBaseTheme.styles.css';
import './UNSAFE_Dialog/themes/redwood/DialogVariants.css.js';
import './FocusTrap-9e80c124.js';
import './tabbableUtils-6ceb767f.js';
import './clientHints-f850225e.js';
import './head-6f17c50c.js';
import './_arity-be492b9e.js';
import './_isArray-694cc52d.js';
import './_isString-675f1de9.js';
import './FocusTracker-3d6ef02a.js';
import './PRIVATE_FocusTracker/themes/FocusTrackerStyles.css.js';
import './FocusTrackerStyles.styles.css';
import './Layer-446bf21e.js';
import './UNSAFE_Layer/themes/LayerStyles.css.js';
import './LayerStyles.styles.css';
import './useThemeInterpolations-8dd8029f.js';
import './useColorScheme-c4e237ad.js';
import './useScale-83881775.js';
import './theme-63551f30.js';
import './Theme-e6dec6db.js';
import './useDensity-c17603b2.js';
import './Modal-24a0bf4b.js';
import './useModal-953082f2.js';
import './UNSAFE_Modal/themes/ModalStyles.css.js';
import './ModalStyles.styles.css';
import './popupUtils-58411a98.js';
import './ImageVars.css-7b3180c8.js';
import './useId-03dbfdf0.js';
import './dimensions-d4159ace.js';
import './size-18139a3a.js';
import './utils-a4102e03.js';
import './colorUtils-16eb823f.js';
import './useResizeObserver-838164c1.js';
import './useVisAddBusyState-994e0324.js';
import './VisBusyStateContext-9ae84b1d.js';
import './useVisBusyStateContext-a1df0764.js';
import './useDraggable-e1aaa8f3.js';
import './positionUtils-f26caad9.js';
import './Floating-f02677ba.js';
import './useFloating-953362cf.js';
import './useOutsideClick-fd9ad806.js';
import './arrayUtils-35a58161.js';
import './UNSAFE_Floating/themes/redwood/FloatingTheme.js';
import './UNSAFE_Floating/themes/FloatingStyles.css.js';
import './FloatingStyles.styles.css';
import './UNSAFE_Floating/themes/redwood/FloatingBaseTheme.css.js';
import './UNSAFE_Floating/themes/redwood/FloatingBaseTheme.styles.css';
import './UNSAFE_Floating/themes/redwood/FloatingVariants.css.js';
import './UNSAFE_Floating/themes/FloatingContract.css.js';
import './IconButton-19fcf0a8.js';
import './BaseButton-61f6baa8.js';
import './usePress-051f5adb.js';
import './usePressClick-945cc43b.js';
import './useHover-19340c22.js';
import './useToggle-8b7fcefe.js';
import './useActive-fb6d4d52.js';
import './TabbableModeContext-7d8ad946.js';
import './useTabbableMode-a3a351d0.js';
import './mergeProps-88ea8306.js';
import './UNSAFE_BaseButton/themes/redwood/BaseButtonTheme.js';
import './UNSAFE_BaseButton/themes/BaseButtonStyles.css.js';
import './BaseButtonStyles.styles.css';
import './UNSAFE_BaseButton/themes/redwood/BaseButtonVariants.css.js';
import './UNSAFE_BaseButton/themes/redwood/BaseButtonBaseTheme.styles.css';
import './ButtonLabelLayout-e9f8cbc0.js';
import './Text-f8d4ff78.js';
import './UNSAFE_Text/themes/TextStyles.css.js';
import './TextStyles.styles.css';
import './useButtonLabelLayoutTheme-a1b95a52.js';
import './UNSAFE_ButtonLabelLayout/themes/redwood/ButtonLabelLayoutTheme.js';
import './UNSAFE_ButtonLabelLayout/themes/ButtonLabelLayoutStyles.css.js';
import './ButtonLabelLayoutStyles.styles.css';
import './UNSAFE_ButtonLabelLayout/themes/redwood/ButtonLabelLayoutBaseTheme.css.js';
import './UNSAFE_ButtonLabelLayout/themes/redwood/ButtonLabelLayoutBaseTheme.styles.css';
import './UNSAFE_ButtonLabelLayout/themes/redwood/ButtonLabelLayoutVariants.css.js';
import './ButtonLabelLayoutVariants.styles.css';
import './useTooltip-89ca3f3e.js';
import './useFocus-38c95977.js';
import './useTouch-4828df25.js';
import './hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentTheme.js';
import './hooks/UNSAFE_useTooltip/themes/TooltipContentStyles.css.js';
import './TooltipContentStyles.styles.css';
import './hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentBaseTheme.css.js';
import './hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentBaseTheme.styles.css';
import './hooks/UNSAFE_useTooltip/themes/redwood/TooltipContentVariants.css.js';
import './TooltipContentVariants.styles.css';
import './tooltipUtils-768450a7.js';
import './EnvironmentProvider-bada8909.js';
import './LayerManager-fa745cec.js';
import './buttonUtils-be059939.js';
import './id-83adac50.js';
import './Close-0791782f.js';
import './Icon-030b6dd4.js';
import './UNSAFE_Icon/themes/IconStyle.css.js';
import './IconStyle.styles.css';
import './Resizable-ea74f2fd.js';
import './PRIVATE_Resizable/themes/ResizableStyles.css.js';
import './ResizableStyles.styles.css';
import './useBreakpoints-13aa87e6.js';
import './useTranslationBundle-09302c20.js';
import './animationUtils-e6081007.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] = useState();
    const [dimensions, setDimensions] = useState();
    const coordsRef = useRef(null);
    const origPosRef = useRef(null);
    const origSizeRef = 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 })
    };
};

export { useFlexibleComponent };
//# sourceMappingURL=UNSAFE_Dialog.js.map
