import { defineComponent, ref, watch, computed, h, Teleport } from 'vue';
import { getSlot } from '../vnode';

var lazyTeleport = defineComponent({
  name: 'LazyTeleport',
  props: {
    to: {
      type: [String, Object],
      default: undefined
    },
    disabled: Boolean,
    show: {
      type: Boolean,
      required: true
    }
  },
  setup(props) {
    const showTeleport = ref(props.show);
    watch(() => props.show, val => {
      if (val) {
        showTeleport.value = true;
      }
    });
    return {
      showTeleport,
      mergedTo: computed(() => {
        var _props$to;
        return (_props$to = props.to) !== null && _props$to !== void 0 ? _props$to : 'body';
      })
    };
  },
  render() {
    return this.showTeleport ? this.disabled ? getSlot(this.$slots) : h(Teleport, {
      disabled: this.disabled,
      to: this.mergedTo
    }, getSlot(this.$slots)) : null;
  }
});

export { lazyTeleport as default };
