import { defineComponent as d, ref as i, openBlock as P, createElementBlock as g } from "vue";
import { nanoid as f } from "nanoid";
const V = ["poster", "autoplay", "controls", "loop", "muted", "src"], H = d({ name: "zv-media-video" }), h = /* @__PURE__ */ d({
  ...H,
  props: {
    basicOption: {},
    sources: {},
    useEvents: {}
  },
  emits: [
    "on-video-progress",
    "on-video-play",
    "on-video-pause",
    "on-video-ended",
    "on-video-playing",
    "on-video-timeupdate",
    "on-video-error",
    "on-video-volumechange"
  ],
  setup(t, { expose: a, emit: r }) {
    const e = t, v = i(f()), s = i(), o = r, p = () => {
      o("on-video-progress"), window.SHJParseEvent(e.useEvents, "on-video-progress");
    }, u = () => {
      o("on-video-play"), window.SHJParseEvent(e.useEvents, "on-video-play");
    }, l = () => {
      o("on-video-pause"), window.SHJParseEvent(e.useEvents, "on-video-pause");
    }, c = () => {
      o("on-video-ended"), window.SHJParseEvent(e.useEvents, "on-video-ended");
    }, m = () => {
      o("on-video-playing"), window.SHJParseEvent(e.useEvents, "on-video-playing");
    }, E = () => {
      o("on-video-timeupdate"), window.SHJParseEvent(e.useEvents, "on-video-timeupdate");
    }, y = () => {
      o("on-video-error"), window.SHJParseEvent(e.useEvents, "on-video-error");
    }, w = () => {
      o("on-video-volumechange"), window.SHJParseEvent(e.useEvents, "on-video-volumechange");
    };
    return a({
      /** 开始播放 */
      play: () => {
        s.value && s.value.play();
      },
      /** 暂停播放 */
      pause: () => {
        s.value && s.value.pause();
      }
    }), (n, J) => (P(), g("video", {
      ref_key: "videoRef",
      ref: s,
      key: v.value,
      poster: n.basicOption.poster,
      autoplay: n.basicOption.autoplay,
      controls: n.basicOption.controls,
      loop: n.basicOption.loop,
      muted: n.basicOption.muted,
      class: "zerov-widget-video",
      src: n.basicOption.src,
      onProgress: p,
      onPlay: u,
      onEnded: c,
      onPlaying: m,
      onPause: l,
      onTimeupdate: E,
      onError: y,
      onVolumechange: w
    }, null, 40, V));
  }
});
export {
  h as default
};
