import{_ as T,a as w,b as B}from"./13.js";import{H as x}from"./Heading.js";import{C as D}from"./Button.js";import{_ as f,o,c as _,a as e,r as m,h,w as r,b as s,T as u,e as E,f as d,F as O,i as S,n as v,d as b,t as a,p as N,g as K}from"./index.js";import{R as U}from"./RubleIcon.js";import{f as Y}from"./numbers.js";import"./telegram-authenticator.js";import"./close2.js";import"./donate.js";import"./money.js";const P={},R={width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},L=e("circle",{render:!0,cx:"10",cy:"10",r:"10",fill:"#0D73FD"},null,-1),F=e("path",{render:!0,d:"M6 11.2857L7.77778 13L14 7",stroke:"white","stroke-width":"1.5","stroke-linecap":"round"},null,-1),H=[L,F];function V(c,i){return o(),_("svg",R,H)}const M=f(P,[["render",V]]),l=c=>(N("data-v-f26ddcfc"),c=c(),K(),c),A={key:0,class:"buy-ticket iface-container"},Q={class:"buy-ticket__container"},z=l(()=>e("div",{class:"buy-ticket__container-after"},null,-1)),W={key:0,class:"buy-ticket__cards"},j=["onClick"],X={class:"buy-ticket__card--name"},q={class:"buy-ticket__card--value"},G={class:"buy-ticket__card--number"},J={key:0,class:"buy-ticket__result"},Z={class:"buy-ticket__card--name"},$={class:"buy-ticket__card--value"},tt={class:"buy-ticket__card--number"},et={key:0,class:"buy-ticket__result-text"},st=l(()=>e("img",{class:"bg",src:T},null,-1)),ct={key:0,class:"buy-ticket__price"},ot=l(()=>e("div",{class:"buy-ticket__price-text"},"Итого",-1)),it={class:"buy-ticket__price-value"},nt={key:0,class:"buy-ticket__controls"},_t={class:"buy-ticket__controls--button"},rt=l(()=>e("div",{class:"text"},"Оплатить счет",-1)),at={class:"buy-ticket__controls--button"},ut=l(()=>e("div",{class:"text"},"Закрыть",-1));function dt(c,i,kt,mt,t,y){const C=m("UIHeading"),k=m("UIControlButton"),g=m("IconDone"),I=m("RubleIcon");return o(),h(u,{name:"fade"},{default:r(()=>[t.closeState?(o(),_("div",A,[e("div",Q,[z,s(u,{name:"fade"},{default:r(()=>[t.state?d("",!0):(o(),h(C,{key:0},{default:r(()=>[E("Мой билет")]),_:1}))]),_:1}),s(u,{name:"fade"},{default:r(()=>[t.state?d("",!0):(o(),_("div",W,[s(k,{text:"Q",onPressed:i[0]||(i[0]=n=>t.ticket=0),keyCode:t.KEY_CODE_Q},null,8,["keyCode"]),(o(!0),_(O,null,S(t.tickets,(n,p)=>(o(),_("div",{class:v(["buy-ticket__card",{active:t.ticket==p}]),key:p,onClick:yt=>t.ticket=p,style:b(`background-image: url('${t.cardIcons[`/src/assets/images/buy_ticket/cards/${n.type}.svg`]}')`)},[e("div",X,a(n.name),1),e("div",q,a(n.param)+" "+a(n.param==1?"поездка":"поездок"),1),e("div",G,"№"+a(n.number),1)],14,j))),128)),s(k,{text:"E",onPressed:i[1]||(i[1]=n=>t.ticket=1),keyCode:t.KEY_CODE_E},null,8,["keyCode"])]))]),_:1}),s(u,{name:"fade"},{default:r(()=>[t.state?(o(),_("div",J,[e("div",{class:v(["buy-ticket__card",{active:!0,result:t.state>=2,left:t.ticket==0,right:t.ticket==1}]),style:b(`background-image: url('${t.cardIcons[`/src/assets/images/buy_ticket/cards/${t.tickets[t.ticket].type}.svg`]}')`)},[e("div",Z,a(t.tickets[t.ticket].name),1),e("div",$,a(t.tickets[t.ticket].param+" "+t.tickets[t.ticket].param==1?"поездка":"поездок"),1),e("div",tt,"№"+a(t.tickets[t.ticket].number),1)],6),s(u,{name:"fade"},{default:r(()=>[t.state==3?(o(),_("div",et,[s(g),E("Билет успешно куплен")])):d("",!0)]),_:1}),st])):d("",!0)]),_:1}),s(u,{name:"fade"},{default:r(()=>[t.state?d("",!0):(o(),_("div",ct,[ot,e("div",it,[s(I),e("span",null,a(y.formatNumberWithSpaces(t.tickets[t.ticket].price)),1)])]))]),_:1}),s(u,{name:"fade"},{default:r(()=>[t.state?d("",!0):(o(),_("div",nt,[e("div",_t,[s(k,{text:"Enter",onPressed:i[2]||(i[2]=n=>y.onBuy()),keyCode:t.KEY_CODE_ENTER},null,8,["keyCode"]),rt]),e("div",at,[s(k,{onPressed:i[3]||(i[3]=n=>y.close()),keyCode:t.KEY_CODE_ESC},null,8,["keyCode"]),ut])]))]),_:1})])])):d("",!0)]),_:1})}const lt={props:["openParams"],components:{UIHeading:x,UIControlButton:D,IconDone:M,RubleIcon:U},data(){return{cardIcons:Object.assign({"/src/assets/images/buy_ticket/cards/0.svg":w,"/src/assets/images/buy_ticket/cards/1.svg":B}),KEY_CODE_ESC:window.KEY_CODE_ESC,KEY_CODE_ENTER:window.KEY_CODE_ENTER,KEY_CODE_Q:81,KEY_CODE_E:69,CLOSE_INTERFACE_TIMEOUT:2e3,tickets:[],ticket:0,price:2138,closeState:0,state:0}},created(){this.$data.noAdaptation=!0,this.closeState=1,this.openParams&&this.openParams.forEach(c=>{this.tickets.push({type:c[0],name:c[1],param:c[2],number:c[3],price:c[4]})})},methods:{formatNumberWithSpaces:Y,close(){window.closeInterface("BuyTicket")},buy(){sendClientEvent(gm.EVENT_EXECUTE_PUBLIC,"TrainMetro_OnPlayerBuyTicket",this.ticket)},setBuy(){this.state=3,setTimeout(()=>this.close(),this.CLOSE_INTERFACE_TIMEOUT)},onBuy(){this.state=1,this.$nextTick(()=>{this.state=2,setTimeout(()=>{this.buy()},250)})}}},wt=f(lt,[["render",dt],["__scopeId","data-v-f26ddcfc"]]);export{wt as default};
