import{C as E}from"./Close.js";import{w as y}from"./dom.js";import{c as p,b as u,d as f,e as w,f as D,i as T,a as g,g as v,h as L,_ as S}from"./timer.js";import{r as k,o as t,c as r,h as O,a,d as _,n as d,t as K,e as h,F as m,i as b,f as A,_ as I}from"./index.js";import"./telegram-authenticator.js";import"./close2.js";import"./Button.js";import"./donate.js";import"./money.js";const N={class:"new-year-calendar__sidebar"},P={class:"new-year-calendar__sidebar__content"},V=a("img",{class:"new-year-calendar__sidebar__image",src:f},null,-1),$=a("div",{class:"new-year-calendar__title"},[h("Праздничный"),a("div",{class:"new-year-calendar__title__text"},"календарь")],-1),M=a("div",{class:"new-year-calendar__text"},"Открывайте календарь каждый день и получайте подарки!",-1),B={key:0,class:"new-year-calendar__hint__bg",src:w},U={key:1,class:"new-year-calendar__hint__bg",src:D},W={key:2,class:"new-year-calendar__hint__content"},F={key:3,class:"new-year-calendar__hint__content"},Y=a("img",{src:T},null,-1),z={class:"new-year-calendar__hint__value"},G=["onClick"],R=a("img",{class:"new-year-calendar__item__arrow",src:g},null,-1),J=a("div",{class:"new-year-calendar__item__bg"},null,-1),X={key:1,class:"new-year-calendar__item__lock",src:v},q={key:2,class:"new-year-calendar__item__passed",src:L},H={key:3,class:"new-year-calendar__item__active",src:S};function Q(e,n,l,j,x,i){const C=k("ControlsClose");return t(),r("div",{class:d(["new-year-calendar iface-container",{"new-year-calendar_mobile":i.isMobile}])},[i.isMobile?(t(),r("img",{key:1,class:"new-year-calendar__close",src:p,onClick:n[0]||(n[0]=(...o)=>i.close&&i.close(...o))})):(t(),O(C,{key:0,onClose:i.close},null,8,["onClose"])),a("img",{class:"new-year-calendar__bg",src:u,ref:"background",style:_({transform:`scale(${e.scale})`})},null,4),a("div",N,[a("div",P,[V,$,M,a("div",{class:d(["new-year-calendar__hint",{"new-year-calendar__hint_limited":e.time>0}])},[e.time>0?(t(),r("img",B)):(t(),r("img",U)),e.time?(t(),r("div",F,[Y,a("div",z,K(i.formatedTimer),1),h("осталось отыграть до подарка")])):(t(),r("div",W,"Забирайте свой подарок с календаря!"))],2)])]),a("div",{class:"new-year-calendar__content",style:_({transform:`scale(${e.scale})`,right:`${7*e.scale}vh`,top:`${15.46*e.scale}vh`})},[(t(!0),r(m,null,b(e.cells,(o,c)=>(t(),r("div",{class:"new-year-calendar__item",key:c,onClick:ee=>o===e.STATE.SELECTED&&i.openGift(c)},[o===e.STATE.SELECTED?(t(),r(m,{key:0},[R,J],64)):o===e.STATE.LOCKED?(t(),r("img",X)):o===e.STATE.PASSED?(t(),r("img",q)):o===e.STATE.ACTIVE?(t(),r("img",H)):A("",!0)],8,G))),128))],4)],2)}const s={LOCKED:0,PASSED:1,ACTIVE:2,SELECTED:3},Z={props:["openParams"],components:{ControlsClose:E},data:()=>({STATE:s,scale:1,time:0,timer:null,cells:[s.PASSED,s.SELECTED,s.LOCKED,s.LOCKED,s.LOCKED,s.LOCKED,s.LOCKED,s.ACTIVE,s.LOCKED,s.LOCKED,s.LOCKED,s.LOCKED,s.LOCKED,s.LOCKED,s.LOCKED,s.LOCKED,s.LOCKED,s.LOCKED,s.LOCKED,s.LOCKED]}),computed:{formatedTimer(){const e=new Date(this.time),n=e.getUTCMinutes().toString().padStart(2,"0"),l=e.getUTCSeconds().toString().padStart(2,"0");return`${n}:${l}`},isMobile(){return this.$root.isMobile}},created(){if(this.$data.noAdaptation=!0,this.openParams){const[e,n]=this.openParams;this.updateTimer(e*1e3-new Date),this.setCells(n)}else this.updateTimer(12e4)},mounted(){const e=this.$refs.background;y(()=>{if(e.offsetWidth<document.documentElement.offsetWidth){const n=document.documentElement.offsetWidth/e.offsetWidth;this.scale=n}})},unmounted(){this.timer&&(clearInterval(this.timer),this.timer=null)},methods:{setCells(e){const n=typeof e=="string"?JSON.parse(e):e;this.cells=n},openGift(e){sendClientEvent(gm.EVENT_EXECUTE_PUBLIC,"ADVCAL_OnPlayerTakeReward",e)},close(){window.closeInterface("NewYearCalendar")},updateTimer(e){this.timer&&clearInterval(this.timer),this.time=e,this.timer=setInterval(()=>{if(this.time<=0){this.time=0,clearInterval(this.timer),this.timer=null;return}this.time-=1e3},1e3)}}},_e=I(Z,[["render",Q]]);export{_e as default};
