import { createVNode, Fragment, mergeProps } from "vue";
import "./styles/message-provider.scss";
import { filterAlertProps, Alert } from "../alert/alert.mjs";
import { MessageKey, message, provideMessage, useMessage } from "../../composables/message/index.mjs";
import { Overlay } from "../overlay/overlay.mjs";
import { defineComponent } from "../../utils/define-component.mjs";
import { useRender } from "../../utils/dist/index.mjs";
const MessageProvider = defineComponent({
  name: "VeMessageProvider",
  register(app) {
    app.provide(MessageKey, message);
  },
  props: {
    registered: Boolean
  },
  setup(props, {
    slots
  }) {
    const message2 = !props.registered ? provideMessage() : useMessage();
    const {
      items,
      remove
    } = message2;
    useRender(() => {
      var _a;
      return createVNode(Fragment, null, [(_a = slots.default) == null ? void 0 : _a.call(slots), createVNode(Overlay, {
        "modelValue": items.value.length > 0,
        "scrim": false,
        "scrollStrategy": "none",
        "class": ["ve-message-provider"]
      }, {
        ...slots,
        default: () => createVNode("ul", null, [items.value.map((item) => {
          const [alertProps] = filterAlertProps(item);
          return createVNode(Alert, mergeProps({
            "key": item.id,
            "tag": "li",
            "appear": true,
            "modelValue": item.modelValue,
            "onUpdate:modelValue": ($event) => item.modelValue = $event,
            "on-after-leave": () => remove(item.id)
          }, alertProps), null);
        })])
      })]);
    });
    return message2;
  }
});
export {
  MessageProvider
};
//# sourceMappingURL=message-provider.mjs.map
