var $048d76b84370f141$exports = require("./utils.cjs");
var $5724b511a2687756$exports = require("./intlStrings.cjs");
var $cab7d9a238d19c33$exports = require("./Text.cjs");
var $2uDYL$reactariauseDrop = require("react-aria/useDrop");
var $2uDYL$reactariaprivateutilsfilterDOMProps = require("react-aria/private/utils/filterDOMProps");
var $2uDYL$reactariaprivateutilsshadowdomDOMFunctions = require("react-aria/private/utils/shadowdom/DOMFunctions");
var $2uDYL$reactariaprivateutilsisFocusable = require("react-aria/private/utils/isFocusable");
var $2uDYL$reactariamergeProps = require("react-aria/mergeProps");
var $2uDYL$react = require("react");
var $2uDYL$reactariauseButton = require("react-aria/useButton");
var $2uDYL$reactariauseClipboard = require("react-aria/useClipboard");
var $2uDYL$reactariauseFocusRing = require("react-aria/useFocusRing");
var $2uDYL$reactariauseHover = require("react-aria/useHover");
var $2uDYL$reactariaprivateutilsuseLabels = require("react-aria/private/utils/useLabels");
var $2uDYL$reactariauseLocalizedStringFormatter = require("react-aria/useLocalizedStringFormatter");
var $2uDYL$reactariauseObjectRef = require("react-aria/useObjectRef");
var $2uDYL$reactariaprivateutilsuseId = require("react-aria/private/utils/useId");
var $2uDYL$reactariaVisuallyHidden = require("react-aria/VisuallyHidden");


function $parcel$interopDefault(a) {
  return a && a.__esModule ? a.default : a;
}

function $parcel$export(e, n, v, s) {
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}

$parcel$export(module.exports, "DropZoneContext", function () { return $2d794bb643c28122$export$14a72053295ff9a6; });
$parcel$export(module.exports, "DropZone", function () { return $2d794bb643c28122$export$3c6489d84dc98b6; });
/*
 * 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 $2d794bb643c28122$export$14a72053295ff9a6 = /*#__PURE__*/ (0, $2uDYL$react.createContext)(null);
const $2d794bb643c28122$export$3c6489d84dc98b6 = /*#__PURE__*/ (0, $2uDYL$react.forwardRef)(function DropZone(props, ref) {
    let { isDisabled: isDisabled = false } = props;
    [props, ref] = (0, $048d76b84370f141$exports.useContextProps)(props, ref, $2d794bb643c28122$export$14a72053295ff9a6);
    let dropzoneRef = (0, $2uDYL$reactariauseObjectRef.useObjectRef)(ref);
    let buttonRef = (0, $2uDYL$react.useRef)(null);
    let { dropProps: dropProps, dropButtonProps: dropButtonProps, isDropTarget: isDropTarget } = (0, $2uDYL$reactariauseDrop.useDrop)({
        ...props,
        ref: buttonRef,
        hasDropButton: true
    });
    let { buttonProps: buttonProps } = (0, $2uDYL$reactariauseButton.useButton)(dropButtonProps || {}, buttonRef);
    let { hoverProps: hoverProps, isHovered: isHovered } = (0, $2uDYL$reactariauseHover.useHover)(props);
    let { focusProps: focusProps, isFocused: isFocused, isFocusVisible: isFocusVisible } = (0, $2uDYL$reactariauseFocusRing.useFocusRing)();
    let stringFormatter = (0, $2uDYL$reactariauseLocalizedStringFormatter.useLocalizedStringFormatter)((0, ($parcel$interopDefault($5724b511a2687756$exports))), 'react-aria-components');
    let textId = (0, $2uDYL$reactariaprivateutilsuseId.useSlotId)();
    let ariaLabel = props['aria-label'] || stringFormatter.format('dropzoneLabel');
    let messageId = props['aria-labelledby'];
    let ariaLabelledby = [
        textId,
        messageId
    ].filter(Boolean).join(' ');
    let labelProps = (0, $2uDYL$reactariaprivateutilsuseLabels.useLabels)({
        'aria-label': ariaLabel,
        'aria-labelledby': ariaLabelledby
    });
    let { clipboardProps: clipboardProps } = (0, $2uDYL$reactariauseClipboard.useClipboard)({
        isDisabled: isDisabled,
        onPaste: (items)=>props.onDrop?.({
                type: 'drop',
                items: items,
                x: 0,
                y: 0,
                dropOperation: 'copy'
            })
    });
    let renderProps = (0, $048d76b84370f141$exports.useRenderProps)({
        ...props,
        values: {
            isHovered: isHovered,
            isFocused: isFocused,
            isFocusVisible: isFocusVisible,
            isDropTarget: isDropTarget,
            isDisabled: isDisabled
        },
        defaultClassName: 'react-aria-DropZone'
    });
    let DOMProps = (0, $2uDYL$reactariaprivateutilsfilterDOMProps.filterDOMProps)(props, {
        global: true
    });
    delete DOMProps.id;
    return /*#__PURE__*/ (0, ($parcel$interopDefault($2uDYL$react))).createElement((0, $048d76b84370f141$exports.Provider), {
        values: [
            [
                (0, $cab7d9a238d19c33$exports.TextContext),
                {
                    id: textId,
                    slot: 'label'
                }
            ]
        ]
    }, /*#__PURE__*/ (0, ($parcel$interopDefault($2uDYL$react))).createElement((0, $048d76b84370f141$exports.dom).div, {
        ...(0, $2uDYL$reactariamergeProps.mergeProps)(DOMProps, renderProps, dropProps, hoverProps),
        slot: props.slot || undefined,
        ref: dropzoneRef,
        onClick: (e)=>{
            let target = (0, $2uDYL$reactariaprivateutilsshadowdomDOMFunctions.getEventTarget)(e);
            while(target && (0, $2uDYL$reactariaprivateutilsshadowdomDOMFunctions.nodeContains)(dropzoneRef.current, target)){
                if ((0, $2uDYL$reactariaprivateutilsisFocusable.isFocusable)(target)) break;
                else if (target === dropzoneRef.current) {
                    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, ($parcel$interopDefault($2uDYL$react))).createElement((0, $2uDYL$reactariaVisuallyHidden.VisuallyHidden), null, /*#__PURE__*/ (0, ($parcel$interopDefault($2uDYL$react))).createElement("button", {
        ...(0, $2uDYL$reactariamergeProps.mergeProps)(buttonProps, focusProps, clipboardProps, labelProps),
        ref: buttonRef
    })), renderProps.children));
});


//# sourceMappingURL=DropZone.cjs.map
