"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("vue"),r=require("hls.js"),u=require("lodash"),b=["poster","autoplay","controls","loop","muted"],h=i.defineComponent({name:"zv-media-m3u8"}),O=i.defineComponent({...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(v,{expose:p,emit:l}){const o=v,c=()=>{const e=i.ref(),t=a=>{if(a)if(r.isSupported()){const d=new r;d.loadSource(a),d.attachMedia(e.value),d.on(r.Events.MANIFEST_PARSED,()=>{o.basicOption.autoplay&&e.value.play()})}else e.value.canPlayType("application/vnd.apple.mpegurl")&&(e.value.src=a)};return i.onMounted(()=>t(o.basicOption.src)),{videoRef:e,initM3u8Video:t}},{videoRef:s,initM3u8Video:E}=c();i.watch(()=>u.cloneDeep(o.basicOption),(e,t)=>{u.isEqual(e,t)||E(e.src)},{deep:!0});const n=l,m=()=>{n("on-video-progress"),window.SHJParseEvent(o.useEvents,"on-video-progress")},y=()=>{n("on-video-play"),window.SHJParseEvent(o.useEvents,"on-video-play")},f=()=>{n("on-video-pause"),window.SHJParseEvent(o.useEvents,"on-video-pause")},P=()=>{n("on-video-ended"),window.SHJParseEvent(o.useEvents,"on-video-ended")},g=()=>{n("on-video-playing"),window.SHJParseEvent(o.useEvents,"on-video-playing")},w=()=>{n("on-video-timeupdate"),window.SHJParseEvent(o.useEvents,"on-video-timeupdate")},S=()=>{n("on-video-error"),window.SHJParseEvent(o.useEvents,"on-video-error")},V=()=>{n("on-video-volumechange"),window.SHJParseEvent(o.useEvents,"on-video-volumechange")};return p({play:()=>{s.value&&s.value.play()},pause:()=>{s.value&&s.value.pause()}}),(e,t)=>(i.openBlock(),i.createElementBlock("video",{ref_key:"videoRef",ref:s,class:"zerov-widget",poster:e.basicOption.poster,autoplay:e.basicOption.autoplay,controls:e.basicOption.controls,loop:e.basicOption.loop,muted:e.basicOption.muted,onProgress:m,onPlay:y,onEnded:P,onPlaying:g,onPause:f,onTimeupdate:w,onError:S,onVolumechange:V},null,40,b))}});exports.default=O;
