// packages/components/src/slot-fill/index.tsx
import { forwardRef, useContext } from "@wordpress/element";
import BaseFill from "./fill.js";
import BaseSlot from "./slot.js";
import BubblesVirtuallyFill from "./bubbles-virtually/fill.js";
import BubblesVirtuallySlot from "./bubbles-virtually/slot.js";
import BubblesVirtuallySlotFillProvider from "./bubbles-virtually/slot-fill-provider.js";
import SlotFillProvider from "./provider.js";
import SlotFillContext from "./bubbles-virtually/slot-fill-context.js";
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { default as default2 } from "./bubbles-virtually/use-slot.js";
import { default as default3 } from "./bubbles-virtually/use-slot-fills.js";
function Fill(props) {
  return /* @__PURE__ */ _jsxs(_Fragment, {
    children: [/* @__PURE__ */ _jsx(BaseFill, {
      ...props
    }), /* @__PURE__ */ _jsx(BubblesVirtuallyFill, {
      ...props
    })]
  });
}
function UnforwardedSlot(props, ref) {
  const {
    bubblesVirtually,
    ...restProps
  } = props;
  if (bubblesVirtually) {
    return /* @__PURE__ */ _jsx(BubblesVirtuallySlot, {
      ...restProps,
      ref
    });
  }
  return /* @__PURE__ */ _jsx(BaseSlot, {
    ...restProps
  });
}
var Slot = forwardRef(UnforwardedSlot);
function Provider({
  children,
  passthrough = false
}) {
  const parent = useContext(SlotFillContext);
  if (!parent.isDefault && passthrough) {
    return /* @__PURE__ */ _jsx(_Fragment, {
      children
    });
  }
  return /* @__PURE__ */ _jsx(SlotFillProvider, {
    children: /* @__PURE__ */ _jsx(BubblesVirtuallySlotFillProvider, {
      children
    })
  });
}
Provider.displayName = "SlotFillProvider";
function createSlotFill(key) {
  const baseName = typeof key === "symbol" ? key.description : key;
  const FillComponent = (props) => /* @__PURE__ */ _jsx(Fill, {
    name: key,
    ...props
  });
  FillComponent.displayName = `${baseName}Fill`;
  const SlotComponent = (props) => /* @__PURE__ */ _jsx(Slot, {
    name: key,
    ...props
  });
  SlotComponent.displayName = `${baseName}Slot`;
  SlotComponent.__unstableName = key;
  return {
    name: key,
    Fill: FillComponent,
    Slot: SlotComponent
  };
}
export {
  Fill,
  Provider,
  Slot,
  UnforwardedSlot,
  createSlotFill,
  default2 as useSlot,
  default3 as useSlotFills
};
//# sourceMappingURL=index.js.map
