import{K as m,i as M,r as f,a as g,o as _,f as v,g as w,h as S,x as b,y as T,w as h,d as I,p as P}from"./index-DNcc_XYj.js";import{_ as B}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{e as d}from"./artplayer-ueyOVO3X.js";const E="https://display24.ru";async function $(o,i,t,e,r,u,l,a,s,n=1){const p=await m("statisticsDB",1,{upgrade(c){c.objectStoreNames.contains("statistics")||c.createObjectStore("statistics",{keyPath:"id",autoIncrement:!0})}}),y=JSON.parse(JSON.stringify(s));try{const c={timestamp:Date.now(),partner:o||null,client:i||null,display:t||null,media:e||null,adv:r||0,rate:u||0,duration:l||0,order:a||null,face:y||null,counter:n||1};await p.add("statistics",c),(data==null?void 0:data.code)==200&&console.log("Лог статистики записан")}catch(c){return 0}}async function N(){await(await m("statisticsDB",1)).clear("statistics")}async function R(){if(!navigator.onLine){console.log("Нет сети, отправка отложена");return}const i=await(await m("statisticsDB",1)).getAll("statistics");if(i.length===0){console.log("Нет данных для отправки");return}try{const e=(await M.post("".concat(E,"/api/v1/player/statistics"),{action:"statistics.bulk",records:i},{headers:{"Content-Type":"application/json"},timeout:5e3})).data;if(!e||typeof e!="object"||e.online!==!0)throw new Error("OFFLINE_OR_HTML_STUB_200");(e==null?void 0:e.code)===200&&(console.info("Результат отправки статистики:",e==null?void 0:e.data),await N())}catch(t){console.error("Ошибка при отправке статистики:",t.message)}}const x=["src"],C={__name:"PlaylistImageContainer",props:{id:String,mediaMode:Number,filename:String,type:String,isVisible:Boolean,partner:String},setup(o){const i=f(null),t=o,e=g({id:null,mediaMode:2,filename:"",type:""}),r=async(l,a)=>{const s="https://cdn.display24.ru/partners/".concat(t.partner,"/").concat(l);return await b(s,a)},u=()=>{switch(e.mediaMode){case 1:return{objectFit:"fill",width:"100%",height:"100%"};case 2:return{objectFit:"cover",width:"100%",height:"100%"};default:return{objectFit:"none"}}};return _(async()=>{e.id=t.id,e.mediaMode=t.mediaMode,e.filename=t.filename,e.type=t.type,e.filename&&(i.value=await r(e.filename,e.type))}),(l,a)=>(w(),v("img",{src:i.value,class:"content-image",style:S(u())},null,12,x))}},U=B(C,[["__scopeId","data-v-2097a35e"]]),V={__name:"PlaylistVideoContainer",props:{id:String,mediaMode:Number,filename:String,type:String,isVisible:Boolean,partner:String},setup(o){d.CONTEXTMENU=!1,d.NOTICE_TIME=0,d.CONTROL_HIDE_TIME=0,d.RECONNECT_TIME_MAX=10;const i=o,t=g({id:null,mediaMode:2,filename:"",type:""}),e=f(null),r=f(T(32));h(()=>i.isVisible,a=>{if(e.value)if(a)e.value.play().catch(s=>{console.warn("play() при isVisible=true не удался",s)});else{try{e.value.pause()}catch(s){}try{e.value.currentTime=0}catch(s){}}});const u=a=>{var s,n;switch(a){case 1:return{objectFit:"fill",width:t.width+"px",height:t.height+"px"};case 2:return{objectFit:"cover",width:"100%",height:"100%"};default:return{objectFit:"none",width:((s=t.content)==null?void 0:s.width)+"px",height:((n=t.content)==null?void 0:n.height)+"px"}}};async function l(a,s){const n="https://cdn.display24.ru/partners/".concat(i.partner,"/").concat(a),p=navigator.userAgent||"";return p.includes("SMART-TV")||p.includes("Tizen")?n:await b(n,s)}return _(async()=>{t.id=i.id,t.mediaMode=i.mediaMode,t.filename=i.filename,t.type=i.type}),h(()=>t.filename,async a=>{if(!a||(a==null?void 0:a.length)==0)return;const s=document.querySelector(".video-"+r.value);if(s){const n=await l(t.filename,t.type);e.value&&e.value.destroy(),e.value=new d({container:s,url:n,poster:"/poster.png",autoSize:!0,miniProgressBar:!1,loop:!1,muted:!1,autoplay:!1,aspectRatio:!0,controls:[],volume:.8,playsInline:!0,isLive:!0,mutex:!1,setting:!1,preload:"auto",clickToPlay:!1,show:!1,icons:{state:""}})}else console.error("Контейнер для плеера не найден")}),I(()=>{e.value&&e.value.destroy&&e.value.destroy(!1)}),(a,s)=>(w(),v("div",{class:P("video-"+r.value),style:S(u(t.mediaMode)),key:r.value},null,6))}};export{U as P,V as _,$ as a,R as s};
