import { defineComponent as s, createElementBlock as u, openBlock as f, ref as m, onMounted as d, onBeforeUnmount as l } from "vue";
const y = ["src"], w = s({ name: "zv-scene-unity-webgl" }), I = /* @__PURE__ */ s({
  ...w,
  props: {
    basicOption: {},
    sources: {},
    useEvents: {},
    uuid: {},
    isPreview: { type: Boolean },
    disableDrag: { type: Boolean }
  },
  emits: [
    "unity-scene-on-message"
  ],
  setup(a, { emit: i }) {
    const t = a, o = i, r = () => {
      const e = m();
      return d(() => {
        window.SHJSceneUnityIframeInstance || (window.SHJSceneUnityIframeInstance = {}), window.SHJSceneUnityIframeInstance.url = t.basicOption.url + "/index.html", window.SHJSceneUnityIframeInstance.ref = e.value;
      }), l(() => {
        window.SHJSceneUnityIframeInstance = null;
      }), window.addEventListener("message", (n) => {
        o("unity-scene-on-message", n.data), window.SHJParseEvent(t.useEvents, "unity-scene-on-message", n.data);
      }, !1), { unityIframeRef: e };
    }, { unityIframeRef: c } = r();
    return (e, n) => (f(), u("iframe", {
      ref_key: "unityIframeRef",
      ref: c,
      class: "unity-wrap",
      src: `${e.basicOption.url}/index.html`,
      frameborder: "0"
    }, null, 8, y));
  }
});
export {
  I as default
};
