import{u as I,r as B,a as z,c as f,n as N,o as M,b as m,d as O,w as j,e as E,v as F,f as y,g as x,j as k,h as C,l as R,i as T,p as U,q as v,s as J,x as V}from"./index-DmCbOAxb.js";import{l as W,a as q}from"./containers-B-x1Py5x.js";import{_ as H}from"./_plugin-vue_export-helper-DlAUqK2U.js";const A=["src"],G={__name:"LinkContainer",props:{id:String,layoutId:String,partner:String,code:String},emits:["context"],setup(b,{emit:g}){I();const p="https://display24.ru",c=B(!1);let h=null;const w=g;function S(o){o.preventDefault(),w("context")}const d=b,e=z({id:null,displayCode:null,layoutId:null,content:null,code:null}),_=f(()=>{var o,n,r,s,u,t,l,a,i;return{top:e.top+"px",left:e.left+"px",width:e.width+"px",height:e.height+"px",backgroundColor:N((o=e.background)==null?void 0:o.color)||"#000",zIndex:e.zIndex||0,borderColor:((n=e.border)==null?void 0:n.color)||"#fff",borderStyle:((r=e.border)==null?void 0:r.style)||"solid",borderWidth:(((s=e.border)==null?void 0:s.width)||0)+"px",borderRadius:((u=e.border)==null?void 0:u.radius)+"px",boxShadow:"".concat((t=e.shadow)==null?void 0:t.x,"px ").concat((l=e.shadow)==null?void 0:l.y,"px ").concat((a=e.shadow)==null?void 0:a.b,"px ").concat((i=e.shadow)==null?void 0:i.color)}}),L=f(()=>{const o=e.content.code||"",n=o.includes("?")?"&":"?";return"".concat(o).concat(n,"code=").concat(d.code,"&v=")+Date.now()}),D=f(()=>{if(!e.content)return"";switch(e.content.mediaMode){case 1:return"stretch";case 2:return"crop";default:return"original"}});async function $(){var n,r,s;const o=(n=e.content)==null?void 0:n.id;try{const t=(await U.get("".concat(p,"/api/v1/player/links/").concat(o,"?v=")+Date.now(),{headers:{"Content-Type":"application/json"},timeout:5e3})).data;if(!t||typeof t!="object"||t.online!==!0)throw new Error("OFFLINE_OR_HTML_STUB_200");if((t==null?void 0:t.code)==200){let l=t.data||[];e.data=l.find(a=>{var i;return a.id==((i=e.content)==null?void 0:i.id)})||null,e.content.code=v((r=e.data)==null?void 0:r.code),J("links",o,e.data).then(a=>a&&console.info("LinkContainer (links): Сохранение данных в кэш")).catch(console.error)}else console.warn("LinkContainer (links): Нет данных")}catch(u){let t=await V("links",o)||[];return t=JSON.parse(JSON.stringify(t)),t?(e.data=t.find(l=>{var a;return l.id==((a=e.content)==null?void 0:a.id)})||null,e.content.code=v((s=e.data)==null?void 0:s.code),console.warn("LinkContainer (links): Данные загружены из кэша"),!0):(console.error("LinkContainer (links): Нет данных в кэше"),!1)}}return M(async()=>{e.id=d.id,e.displayCode=d.code,e.layoutId=d.layoutId,await W(e,p,"LinkContainer (layouts)"),await q(e,c,p,"LinkContainer (schedule)"),await $(),h=setInterval(()=>{c.value=m(e==null?void 0:e.scheduleData)},1e3)}),O(()=>{h&&clearInterval(h)}),j(()=>e.scheduleData,o=>{c.value=m(o)}),(o,n)=>{var r;return E((x(),y("div",{class:"container",onContextmenu:S,style:T(_.value)},[k("div",{class:"settings-btn",onClick:n[0]||(n[0]=s=>w("context"))},"⚙"),C("",!0),(r=e.content)!=null&&r.code?(x(),y("div",{key:1,class:R(["content",D.value])},[k("iframe",{src:L.value,frameborder:"0",style:{width:"100%",height:"100%"},sandbox:"allow-same-origin allow-scripts allow-popups",allow:"encrypted-media",scrolling:"no"},null,8,A)],2)):C("",!0)],36)),[[F,c.value]])}}},X=H(G,[["__scopeId","data-v-eed3807a"]]);export{X as default};
