import {dom as $b7b7a92703138c9b$export$df3a06d6289f983e, Provider as $b7b7a92703138c9b$export$2881499e37b75b9a, useContextProps as $b7b7a92703138c9b$export$29f1550f4b0d4415, useRenderProps as $b7b7a92703138c9b$export$4d86445c2cf5e3} from "./utils.js";
import $jX5VW$intlStringsjs from "./intlStrings.js";
import {TextContext as $20d769b1e2b13352$export$9afb8bc826b033ea} from "./Text.js";
import {useDrop as $jX5VW$useDrop} from "react-aria/useDrop";
import {filterDOMProps as $jX5VW$filterDOMProps} from "react-aria/private/utils/filterDOMProps";
import {getEventTarget as $jX5VW$getEventTarget, nodeContains as $jX5VW$nodeContains} from "react-aria/private/utils/shadowdom/DOMFunctions";
import {isFocusable as $jX5VW$isFocusable} from "react-aria/private/utils/isFocusable";
import {mergeProps as $jX5VW$mergeProps} from "react-aria/mergeProps";
import $jX5VW$react, {createContext as $jX5VW$createContext, forwardRef as $jX5VW$forwardRef, useRef as $jX5VW$useRef} from "react";
import {useButton as $jX5VW$useButton} from "react-aria/useButton";
import {useClipboard as $jX5VW$useClipboard} from "react-aria/useClipboard";
import {useFocusRing as $jX5VW$useFocusRing} from "react-aria/useFocusRing";
import {useHover as $jX5VW$useHover} from "react-aria/useHover";
import {useLabels as $jX5VW$useLabels} from "react-aria/private/utils/useLabels";
import {useLocalizedStringFormatter as $jX5VW$useLocalizedStringFormatter} from "react-aria/useLocalizedStringFormatter";
import {useObjectRef as $jX5VW$useObjectRef} from "react-aria/useObjectRef";
import {useSlotId as $jX5VW$useSlotId} from "react-aria/private/utils/useId";
import {VisuallyHidden as $jX5VW$VisuallyHidden} from "react-aria/VisuallyHidden";


function $parcel$interopDefault(a) {
  return a && a.__esModule ? a.default : a;
}
/*
 * Copyright 2023 Adobe. All rights reserved.
 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy
 * of the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
 * OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */ 

















const $ceb97195dd95fbc4$export$14a72053295ff9a6 = /*#__PURE__*/ (0, $jX5VW$createContext)(null);
const $ceb97195dd95fbc4$export$3c6489d84dc98b6 = /*#__PURE__*/ (0, $jX5VW$forwardRef)(function DropZone(props, ref) {
    let { isDisabled: isDisabled = false } = props;
    [props, ref] = (0, $b7b7a92703138c9b$export$29f1550f4b0d4415)(props, ref, $ceb97195dd95fbc4$export$14a72053295ff9a6);
    let dropzoneRef = (0, $jX5VW$useObjectRef)(ref);
    let buttonRef = (0, $jX5VW$useRef)(null);
    let { dropProps: dropProps, dropButtonProps: dropButtonProps, isDropTarget: isDropTarget } = (0, $jX5VW$useDrop)({
        ...props,
        ref: buttonRef,
        hasDropButton: true
    });
    let { buttonProps: buttonProps } = (0, $jX5VW$useButton)(dropButtonProps || {}, buttonRef);
    let { hoverProps: hoverProps, isHovered: isHovered } = (0, $jX5VW$useHover)(props);
    let { focusProps: focusProps, isFocused: isFocused, isFocusVisible: isFocusVisible } = (0, $jX5VW$useFocusRing)();
    let stringFormatter = (0, $jX5VW$useLocalizedStringFormatter)((0, ($parcel$interopDefault($jX5VW$intlStringsjs))), 'react-aria-components');
    let textId = (0, $jX5VW$useSlotId)();
    let ariaLabel = props['aria-label'] || stringFormatter.format('dropzoneLabel');
    let messageId = props['aria-labelledby'];
    let ariaLabelledby = [
        textId,
        messageId
    ].filter(Boolean).join(' ');
    let labelProps = (0, $jX5VW$useLabels)({
        'aria-label': ariaLabel,
        'aria-labelledby': ariaLabelledby
    });
    let { clipboardProps: clipboardProps } = (0, $jX5VW$useClipboard)({
        isDisabled: isDisabled,
        onPaste: (items)=>{
            var _props_onDrop;
            return (_props_onDrop = props.onDrop) === null || _props_onDrop === void 0 ? void 0 : _props_onDrop.call(props, {
                type: 'drop',
                items: items,
                x: 0,
                y: 0,
                dropOperation: 'copy'
            });
        }
    });
    let renderProps = (0, $b7b7a92703138c9b$export$4d86445c2cf5e3)({
        ...props,
        values: {
            isHovered: isHovered,
            isFocused: isFocused,
            isFocusVisible: isFocusVisible,
            isDropTarget: isDropTarget,
            isDisabled: isDisabled
        },
        defaultClassName: 'react-aria-DropZone'
    });
    let DOMProps = (0, $jX5VW$filterDOMProps)(props, {
        global: true
    });
    delete DOMProps.id;
    return /*#__PURE__*/ (0, $jX5VW$react).createElement((0, $b7b7a92703138c9b$export$2881499e37b75b9a), {
        values: [
            [
                (0, $20d769b1e2b13352$export$9afb8bc826b033ea),
                {
                    id: textId,
                    slot: 'label'
                }
            ]
        ]
    }, /*#__PURE__*/ (0, $jX5VW$react).createElement((0, $b7b7a92703138c9b$export$df3a06d6289f983e).div, {
        ...(0, $jX5VW$mergeProps)(DOMProps, renderProps, dropProps, hoverProps),
        slot: props.slot || undefined,
        ref: dropzoneRef,
        onClick: (e)=>{
            let target = (0, $jX5VW$getEventTarget)(e);
            while(target && (0, $jX5VW$nodeContains)(dropzoneRef.current, target)){
                if ((0, $jX5VW$isFocusable)(target)) break;
                else if (target === dropzoneRef.current) {
                    var _buttonRef_current;
                    (_buttonRef_current = buttonRef.current) === null || _buttonRef_current === void 0 ? void 0 : _buttonRef_current.focus();
                    break;
                }
                target = target.parentElement;
            }
        },
        "data-hovered": isHovered || undefined,
        "data-focused": isFocused || undefined,
        "data-focus-visible": isFocusVisible || undefined,
        "data-drop-target": isDropTarget || undefined,
        "data-disabled": isDisabled || undefined
    }, /*#__PURE__*/ (0, $jX5VW$react).createElement((0, $jX5VW$VisuallyHidden), null, /*#__PURE__*/ (0, $jX5VW$react).createElement("button", {
        ...(0, $jX5VW$mergeProps)(buttonProps, focusProps, clipboardProps, labelProps),
        ref: buttonRef
    })), renderProps.children));
});


export {$ceb97195dd95fbc4$export$14a72053295ff9a6 as DropZoneContext, $ceb97195dd95fbc4$export$3c6489d84dc98b6 as DropZone};
//# sourceMappingURL=DropZone.js.map
