import{r as S,a as D,c as j,n as C,o as N,b as i,d as z,w as I,e as F,v as J,f as T,g as B,k as H,t as L,h as g,i as m,s as v,j as b,m as E}from"./index-DNcc_XYj.js";import{_ as M}from"./_plugin-vue_export-helper-DlAUqK2U.js";const R={__name:"ClockContainer",props:{id:String,layoutId:String,partner:String},setup(x){const d="https://display24.ru",h=x,c=S(!1),p=S("");let u=null;const e=D({id:null,layoutId:null}),_=j(()=>{var n,a,t,o,s,l,r,y,w;return{top:"".concat(e.top,"px"),left:"".concat(e.left,"px"),width:"".concat(e.width,"px"),height:"".concat(e.height,"px"),backgroundColor:C((n=e.background)==null?void 0:n.color)||C("#000"),zIndex:e.zIndex||0,border:"".concat(((a=e.border)==null?void 0:a.width)||0,"px ").concat(((t=e.border)==null?void 0:t.style)||"solid"," ").concat(((o=e.border)==null?void 0:o.color)||"#fff"),borderRadius:"".concat((s=e.border)==null?void 0:s.radius,"px"),boxShadow:"".concat((l=e.shadow)==null?void 0:l.x,"px ").concat((r=e.shadow)==null?void 0:r.y,"px ").concat((y=e.shadow)==null?void 0:y.b,"px ").concat((w=e.shadow)==null?void 0:w.color)}}),k=()=>{var n,a,t,o,s,l,r;switch((n=e.content)==null?void 0:n.mediaMode){case 1:return{objectFit:"fill",width:"100%",height:"100%",fontSize:((a=e.content)==null?void 0:a.fontSize)+"px",color:(t=e.content)==null?void 0:t.color};case 2:return{objectFit:"cover",width:"100%",height:"100%",fontSize:((o=e.content)==null?void 0:o.fontSize)+"px",color:(s=e.content)==null?void 0:s.color};default:return{objectFit:"none",fontSize:((l=e.content)==null?void 0:l.fontSize)+"px",color:(r=e.content)==null?void 0:r.color}}},f=()=>{var a;const n=E();p.value=n.format((a=e.content)!=null&&a.showSeconds?"HH:mm:ss":"HH:mm")};async function O(){var n;try{const t=(await m.get("".concat(d,"/api/v1/player/layouts/").concat(e.layoutId,"?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 o=((n=t.data)==null?void 0:n[0])||{};o=JSON.parse(JSON.stringify(o));let s=o==null?void 0:o.content.find(l=>l.id==e.id);s&&Object.assign(e,s),v("layouts",e.layoutId,o).then(l=>l&&console.info("ClockContainer (layouts): Сохранение данных в кэш")).catch(console.error)}else console.warn("ClockContainer (layouts): Нет данных")}catch(a){let t=await b("layouts",e.layoutId)||{};if(t=JSON.parse(JSON.stringify(t)),t){let o=t==null?void 0:t.content.find(s=>s.id==e.id);return o&&Object.assign(e,o),console.warn("ClockContainer (layouts): Данные загружены из кэша"),!0}else return console.error("ClockContainer (layouts): Нет данных в кэше."),!1}}async function $(){var n;if(e.schedule)try{const t=(await m.get("".concat(d,"/api/v1/player/schedules/").concat(e.schedule,"?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 o=((n=t.data)==null?void 0:n[0])||{};o=JSON.parse(JSON.stringify(o));let s=(o==null?void 0:o.content)||null;Object.assign(e,{scheduleData:s}),c.value=i(e==null?void 0:e.scheduleData),v("schedule",e.schedule,o).then(l=>l&&console.info("ClockContainer (schedules): Сохранение данных в кэш")).catch(console.error)}else console.warn("ClockContainer (schedules): Нет данных")}catch(a){let t=await b("schedule",e.schedule)||{};if(t=JSON.parse(JSON.stringify(t)),t){let o=(t==null?void 0:t.content)||null;return Object.assign(e,{scheduleData:o}),c.value=i(e==null?void 0:e.scheduleData),console.warn("ClockContainer (schedules): Данные загружены из кэша"),!0}else return console.error("ClockContainer (schedules): Нет данных в кэше"),!1}}return N(async()=>{e.id=h.id,e.layoutId=h.layoutId,await O(),await $(),f(),u=setInterval(()=>{f(),c.value=i(e==null?void 0:e.scheduleData)},1e3)}),z(()=>{u&&clearInterval(u)}),I(()=>e.scheduleData,n=>{c.value=i(n)}),(n,a)=>F((B(),T("div",{class:"container",style:g(_.value)},[H("div",{class:"content-clock",style:g(k())},L(p.value),5)],4)),[[J,c.value]])}},q=M(R,[["__scopeId","data-v-875c3488"]]);export{q as default};
