<template>
  <div>
    <PluginEmbed :walletConnect="walletConnect" :mode="mode" :entry="entry" />
  </div>
</template>
<script setup lang="ts">
import { useWalletConnect } from "@cverse/core-connector-beta";
import { watch, PropType } from "vue";
import { Entry } from "@cverse/core-lib-vue-beta";
import { PluginMode } from "@cverse/core-lib-beta";
import { Embed as PluginEmbed } from "@cverse/plugin-engine-rule-ultra-beta/lib/embed";

let { walletConnect, walletConnectRefresh } = useWalletConnect();

const props = defineProps({
  mode: {
    type: String as PropType<PluginMode>,
  },
  entry: {
    type: Entry,
  },
});
walletConnectRefresh();
watch(
  () => props.entry,
  async () => {
    if (!walletConnect.walletAddress && (window as any).walletConnect) {
      walletConnect.value = (window as any).walletConnect.value;
    }
  },
  { immediate: true, deep: true }
);
</script>
