"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),H=require("nanoid"),u=require("lodash"),J=require("../../commons/core/datasource/index.js"),b=["poster","autoplay","controls","loop","muted","src"],k=o.defineComponent({name:"zv-media-video-dynamic"}),_=o.defineComponent({...k,props:{basicOption:{},sources:{},useEvents:{},uuid:{}},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(v,{expose:c,emit:l}){const e=v,p=()=>{const n=o.ref(""),r=o.ref(H.nanoid()),d=()=>{J.SHJDatasourceV2.parse({tId:e.uuid,sources:e.sources,callback:({data:a})=>{try{window.SHJParseEvent(e.useEvents,"dataListener",a),n.value=a[0].data[0].src}catch{window.SHJParseEvent(e.useEvents,"dataListener",null)}}})};return o.onMounted(()=>o.nextTick(()=>d())),{init:d,src:n,key:r}},{init:t,src:E,key:m}=p();o.watch(()=>u.cloneDeep(e.sources),(n,r)=>{u.isEqual(n,r)||t()},{deep:!0});const i=o.ref(),s=l,y=()=>{s("on-video-progress"),window.SHJParseEvent(e.useEvents,"on-video-progress")},w=()=>{s("on-video-play"),window.SHJParseEvent(e.useEvents,"on-video-play")},f=()=>{s("on-video-pause"),window.SHJParseEvent(e.useEvents,"on-video-pause")},P=()=>{s("on-video-ended"),window.SHJParseEvent(e.useEvents,"on-video-ended")},g=()=>{s("on-video-playing"),window.SHJParseEvent(e.useEvents,"on-video-playing")},h=()=>{s("on-video-timeupdate"),window.SHJParseEvent(e.useEvents,"on-video-timeupdate")},S=()=>{s("on-video-error"),window.SHJParseEvent(e.useEvents,"on-video-error")},V=()=>{s("on-video-volumechange"),window.SHJParseEvent(e.useEvents,"on-video-volumechange")};return c({play:()=>{i.value&&i.value.play()},pause:()=>{i.value&&i.value.pause()},refresh:()=>t(),refreshView:()=>t(),refreshData:()=>t()}),(n,r)=>(o.openBlock(),o.createElementBlock("video",{ref_key:"videoRef",ref:i,key:o.unref(m),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:o.unref(E),onProgress:y,onPlay:w,onEnded:P,onPlaying:g,onPause:f,onTimeupdate:h,onError:S,onVolumechange:V},null,40,b))}});exports.default=_;
