import { defineComponent, defineAsyncComponent, h, mergeProps, hydrateOnVisible } from 'vue';
import { h as useNuxtApp } from './server.mjs';

function defineLazyComponent(props, defineStrategy) {
  return (id, loader) => defineComponent({
    inheritAttrs: false,
    props,
    emits: ["hydrated"],
    setup(props2, ctx) {
      {
        const nuxtApp = useNuxtApp();
        nuxtApp.hook("app:rendered", ({ ssrContext }) => {
          ssrContext.modules.delete(id);
        });
      }
      const child = defineAsyncComponent({ loader });
      const comp = defineAsyncComponent({
        hydrate: defineStrategy(props2),
        loader: () => Promise.resolve(child)
      });
      const onVnodeMounted = () => {
        ctx.emit("hydrated");
      };
      return () => h(comp, mergeProps(ctx.attrs, { onVnodeMounted }), ctx.slots);
    }
  });
}
const createLazyVisibleComponent = defineLazyComponent(
  {
    hydrateOnVisible: {
      type: [Object, Boolean],
      required: false
    }
  },
  (props) => hydrateOnVisible(props.hydrateOnVisible === true ? void 0 : props.hydrateOnVisible)
);
const createLazyTimeComponent = defineLazyComponent(
  {
    hydrateAfter: {
      type: Number,
      required: true
    }
  },
  (props) => props.hydrateAfter === 0 ? void 0 : (hydrate) => {
    const id = setTimeout(hydrate, props.hydrateAfter);
    return () => clearTimeout(id);
  }
);

export { createLazyTimeComponent as a, createLazyVisibleComponent as c };
//# sourceMappingURL=lazy-hydrated-component-BSU3unDO.mjs.map
