"use client";
'use strict';

var _3NDVDEB4 = require('./3NDVDEB4.cjs');
var KFH4SEIX = require('./KFH4SEIX.cjs');
var WYCIER3C = require('./WYCIER3C.cjs');
var XL7CSKGW = require('./XL7CSKGW.cjs');
var YV4JVR4I = require('./YV4JVR4I.cjs');
var ABQUS43J = require('./ABQUS43J.cjs');
var _3YLGPPWQ = require('./3YLGPPWQ.cjs');
var React = require('react');
var jsxRuntime = require('react/jsx-runtime');

function DialogBackdrop({
  store,
  backdrop,
  alwaysVisible,
  hidden
}) {
  const ref = React.useRef(null);
  const disclosure = WYCIER3C.useDisclosureStore({ disclosure: store });
  const contentElement = YV4JVR4I.useStoreState(store, "contentElement");
  React.useEffect(() => {
    const backdrop2 = ref.current;
    const dialog = contentElement;
    if (!backdrop2) return;
    if (!dialog) return;
    backdrop2.style.zIndex = getComputedStyle(dialog).zIndex;
  }, [contentElement]);
  ABQUS43J.useSafeLayoutEffect(() => {
    const id = contentElement == null ? void 0 : contentElement.id;
    if (!id) return;
    const backdrop2 = ref.current;
    if (!backdrop2) return;
    return _3NDVDEB4.markAncestor(backdrop2, id);
  }, [contentElement]);
  const props = KFH4SEIX.useDisclosureContent({
    ref,
    store: disclosure,
    role: "presentation",
    "data-backdrop": (contentElement == null ? void 0 : contentElement.id) || "",
    alwaysVisible,
    hidden: hidden != null ? hidden : void 0,
    style: {
      position: "fixed",
      top: 0,
      right: 0,
      bottom: 0,
      left: 0
    }
  });
  if (!backdrop) return null;
  if (React.isValidElement(backdrop)) {
    return /* @__PURE__ */ jsxRuntime.jsx(XL7CSKGW.Role, _3YLGPPWQ.__spreadProps(_3YLGPPWQ.__spreadValues({}, props), { render: backdrop }));
  }
  const Component = typeof backdrop !== "boolean" ? backdrop : "div";
  return /* @__PURE__ */ jsxRuntime.jsx(XL7CSKGW.Role, _3YLGPPWQ.__spreadProps(_3YLGPPWQ.__spreadValues({}, props), { render: /* @__PURE__ */ jsxRuntime.jsx(Component, {}) }));
}

exports.DialogBackdrop = DialogBackdrop;
//# sourceMappingURL=JEWPFJH2.cjs.map
