1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["chunks/PlayerBlock-Eg3tEU1U.js","chunks/error-kqOC86ip.js","app-0.5.6.js","chunks/global-nglKSoR3.js","chunks/_commonjsHelpers-CE1G-McA.js","chunks/index-CMW59wn3.js","chunks/camera-B1gsgm9y.js","chunks/user-DJPGqo8-.js","assets/PlayerBlock-1iuAxqQ1.css","chunks/IframeBlock-DUKXWBLH.js","chunks/StaticImageBlock-CugAyNha.js","assets/StaticImageBlock-0d1Ggcs9.css","chunks/PopupBlock-Ca-M9ahI.js","chunks/NotificationBlock-B22ZTlm_.js"])))=>i.map(i=>d[i]); 2import{r as y,q as X,c as z,d as S,u as Z,o as K,w as h,a as ee,b as c,e as r,f as s,g as _,h as t,n as U,t as l,i as te,F as M,s as O,m as D,v as ae,j as R,k as se,l as oe,T as ie,p as ne,_ as w}from"../app-0.5.6.js";import{c as o,e as B,i as F,p as re}from"./error-kqOC86ip.js";import{u as le}from"./index-CDVnYzO2.js";import{y as Q}from"./youtube-rNzLVd8q.js";import{t as d,w as $}from"./global-nglKSoR3.js";import{c as W}from"./camera-B1gsgm9y.js";import"./index-CMW59wn3.js";import"./user-DJPGqo8-.js";import"./_commonjsHelpers-CE1G-McA.js";const H=1e4,ce="stopped",C="waiting",G="preparing",A="presentation",P="in_progress",x="results",j=z(()=>e.countries?e.countries.reduce((a,n)=>a+n.votes,0):0),T=z(()=>e.countries?e.countries.find(a=>a.is_valid):{}),e=X({videoId:null,liveChatId:null,nextPageToken:null,dailyQuotaUsed:0,dailyQuotaUsedAt:null,votedUsers:new Set,lastVotedUser:null,showLastVotedUser:!1,lastMessageTime:Date.now(),isChatActive:!0,gameStatus:G,gameIsStopped:!1,intervalId:null,countries:[]}),v=y({}),L=y(null),b=y(1),f=y(0),V=y(0),E=y(null),N=y(null);async function ue(){try{if(!L.value){e.gameIsStopped=!0;return}const a=await Q.getLiveChatId(L.value);e.dailyQuotaUsed+=1;const n=a.items?.[0];n&&n.liveStreamingDetails&&n.liveStreamingDetails.activeLiveChatId?(e.liveChatId=n.liveStreamingDetails.activeLiveChatId,console.log(`Live Chat ID найден: ${e.liveChatId}`)):console.log("Live Chat ID не найден. УбедиÑеÑÑ, ÑÑо ÑÑÑим запÑÑен.")}catch(a){e.gameIsStopped=!0,console.log("ÐÑибка пÑи полÑÑении Live Chat ID:",a.message)}}async function Y(){o.isLoading=!0;const a=o.currentCamera?.post_id;o.disabledNextCam=!0;try{const n=await Q.getNextCam({post_id:o.currentPostId,filters:JSON.stringify(v.value.filters),p:b.value,locale:o.locale});if(n?.post_id||await B.throwError(d.value.nothing_found),n.post_id===a){o.isFilterError=!0,o.disabledNextCam=!1;return}e.countries=n.random_categories,o.currentPostId=a,o.currentCamera=n}catch(n){o.isFilterError=!0,o.disabledNextCam=!1,await B.handleError(n)}b.value++,a===o.currentCamera?.post_id&&(b.value=1),o.isLoading=!1}async function de(){if(e.gameIsStopped){console.log("ÐгÑа не акÑивна");return}if(!e.liveChatId||!e.isChatActive){console.log("Ð§Ð°Ñ Ð½ÐµÐ°ÐºÑивен или не найден.");return}if(e.dailyQuotaUsed>=H){e.dailyQuotaUsedAt||(e.dailyQuotaUsedAt=Date.now()),console.error("ÐÑевÑÑен дневной Ð»Ð¸Ð¼Ð¸Ñ ÐºÐ²Ð¾ÑнÑÑ ÐµÐ´Ð¸Ð½Ð¸Ñ. ÐÐ¾Ñ Ð¾ÑÑановлен.");return}try{const a=await Q.getLiveChatMessages(e.liveChatId,e.nextPageToken);e.dailyQuotaUsed+=5;const n=a.items;if(e.nextPageToken=a.nextPageToken,n.length===0){console.log("ÐÐµÑ Ð½Ð¾Ð²ÑÑ ÑообÑений.");return}e.lastMessageTime=Date.now(),n.forEach(u=>{const I=u.authorDetails.channelId,i=u.snippet.displayMessage;if(console.log(i),e.votedUsers.has(I)){console.log(`ÐолÑзоваÑÐµÐ»Ñ Ñже голоÑовал: ${u.authorDetails.displayName}`);return}if(i.match(/^!vote [A-Z]$/i)){const m=i.split(" ")[1].toUpperCase(),k=e.countries.find(p=>p.option===m);if(!k)return;k.votes+=1,console.log(`ÐолÑзоваÑÐµÐ»Ñ ${u.authorDetails.displayName} пÑоголоÑовал за: ${m}`),e.votedUsers.add(I),e.lastVotedUser={id:I,name:u.authorDetails.displayName,vote:m}}})}catch(a){console.error("ÐÑибка пÑи ÑÑении ÑаÑа:",a.message)}}function me(){const n=(Date.now()-e.lastMessageTime)/1e3;e.lastMessageTime&&n>60*v.value.before_pause?(e.isChatActive=!1,e.gameIsStopped=!0,e.gameStatus=ce,e.intervalId&&clearInterval(e.intervalId),console.log("Ð§Ð°Ñ Ð½ÐµÐ°ÐºÑивен. Ðжидаем новÑÑ ÑообÑений..."),setTimeout(()=>{e.gameIsStopped=!1,e.isChatActive=!0,e.gameStatus=G,e.lastMessageTime=Date.now(),setTimeout(()=>{e.gameStatus=C},500)},1e3*60*v.value.pause)):e.isChatActive=!0}function q(){e.votedUsers.clear(),e.lastVotedUser=null,console.log("ÐолоÑа ÑбÑоÑенÑ. ÐаÑалÑÑ Ð½Ð¾Ð²Ñй ÑаÑнд.")}function ve(a){return j.value===0?0:a.votes/j.value*100}async function pe(){await Y(),await J(),q(),await _e()}async function _e(){if(e.gameStatus=G,e.liveChatId||await ue(),!e.liveChatId){e.gameIsStopped=!0;return}e.gameStatus=A,await he(),e.gameStatus=P,e.intervalId=setInterval(async()=>{e.dailyQuotaUsed>=H&&(e.dailyQuotaUsedAt||(e.dailyQuotaUsedAt=Date.now()),clearInterval(e.intervalId),e.gameIsStopped=!0,e.gameStatus=C),await de(),me()},v.value.chat_check*1e3),await Ie(),clearInterval(e.intervalId),e.gameStatus=x,await ye(),e.gameStatus=C}async function J(){o.currentViewComponent="camera",W.prepareStreamData({type:o.currentCamera?.camera?.type,url:o.currentCamera?.camera?.url}),W.prepareComponent(o.currentCamera?.camera?.type),o.currentCamera?.post_id&&(o.currentPostId=o.currentCamera.post_id),o.keyIndex++}function ge(){const a=v.value.timeout??10;f.value=a*60,E.value&&clearInterval(E.value)}function fe(){V.value=v.value.presentation,N.value&&clearInterval(N.value)}async function he(){return new Promise(a=>setTimeout(()=>a(!0),v.value.presentation*1e3))}async function ye(){return new Promise(a=>setTimeout(()=>a(!0),v.value.results*1e3))}async function Ie(){const a=v.value.timeout??10;return new Promise(n=>setTimeout(()=>n(!0),a*1e3*60))}const g={getNextCam:Y,resetVotes:q,getPercentage:ve,prepareNextGame:pe,initStream:J,prepareCountdown:ge,preparePresentationCountdown:fe},Se={class:"client-cam"},we={id:"video-player",ref:"video-section",class:"video-player"},Te={class:"header"},Ce={key:0,class:"logo"},ke=["src"],Ue={class:"presentation-box"},Ae={class:"countries-result"},Pe={key:0},xe={key:1},De={class:"chart-container"},be={class:"bar"},Le={key:2,class:"country-option"},Ve={class:"opt-letter"},Ee=["src","alt"],Ne={key:1,class:"opt-flag opt-flag--empty"}
2,Qe={class:"opt-name"},Ge={class:"opt-votes"},Me={key:3,class:"result-message"},Oe={class:"result-message__inner"},Re={class:"result-message__label"},Be={class:"result-message__answer"},Fe={class:"result-message__option"},$e=["src","alt"],We={class:"result-message__name"},je={key:1,class:"chat-not-active presentation-container active"},ze={class:"presentation-box"},He={key:2,class:"game-is-over presentation-container active"},Ye={class:"timer-svg",viewBox:"0 0 110 110"},qe={class:"timer-number"},Je={key:4,class:"voted-user-container"},Xe={class:"voted-user-box"},Ze=["innerHTML"],Ke={class:"video-container"},et={components:{PlayerBlock:S(()=>w(()=>import("./PlayerBlock-Eg3tEU1U.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))),IframeBlock:S(()=>w(()=>import("./IframeBlock-DUKXWBLH.js"),__vite__mapDeps([9,1,2,3]))),StaticImageBlock:S(()=>w(()=>import("./StaticImageBlock-CugAyNha.js"),__vite__mapDeps([10,1,2,3,11]))),PopupBlock:S(()=>w(()=>import("./PopupBlock-Ca-M9ahI.js"),__vite__mapDeps([12,1,2,3]))),NotificationBlock:S(()=>w(()=>import("./NotificationBlock-B22ZTlm_.js"),__vite__mapDeps([13,1,2,3])))}},ut=Object.assign(et,{__name:"YoutubeGameCam",props:["filters","videoId","timeout","presentation","results","before_pause","pause","chat_check","show_user_vote_time"],setup(a){const n=Z("video-section"),u=le("youtube-game-storage",{});function I(i,m){a.videoId in u.value||(u.value[a.videoId]={}),u.value[a.videoId][i]=m}return K(async()=>{o.parentEl=n.value,o.additionalVideoOptions={other:{disableModelPopup:!0}},o.locale=$.value.locale,L.value=a.videoId,a.videoId in u.value&&(e.liveChatId=u.value[a.videoId].liveChatId??null,e.nextPageToken=u.value[a.videoId].nextPageToken??null),e.dailyQuotaUsed=u.value.dailyQuotaUsed??0,e.dailyQuotaUsedAt=u.value.dailyQuotaUsedAt??null,e.dailyQuotaUsedAt&&Date.now()-e.dailyQuotaUsedAt>864e5&&(e.dailyQuotaUsed=0,e.dailyQuotaUsedAt=null),v.value={filters:a.filters,timeout:a.timeout,presentation:a.presentation,results:a.results,before_pause:a.before_pause,pause:a.pause,chat_check:a.chat_check,show_user_vote_time:a.show_user_vote_time},await g.prepareNextGame()}),h(()=>o.currentCamera.is_exception,async i=>{if(parseInt(i)){if(e.gameIsStopped)return;await g.getNextCam(),await g.initStream(),g.resetVotes()}}),h(()=>e.gameStatus,async i=>{console.log(i),!e.gameIsStopped&&(i===C&&await g.prepareNextGame(),i===A&&(g.preparePresentationCountdown(),N.value=setInterval(()=>{V.value--},1e3)),i===P&&(g.prepareCountdown(),E.value=setInterval(()=>{f.value--},1e3)))}),h(()=>e.lastVotedUser,async i=>{i&&(e.showLastVotedUser=!0,setTimeout(()=>{e.showLastVotedUser=!1},v.value.show_user_vote_time*1e3))}),h(()=>e.liveChatId,async i=>{I("liveChatId",i)}),h(()=>e.nextPageToken,async i=>{I("nextPageToken",i)}),h(()=>e.dailyQuotaUsed,async i=>{u.value.dailyQuotaUsed=i}),h(()=>e.dailyQuotaUsedAt,async i=>{u.value.dailyQuotaUsedAt=i}),(i,m)=>{const k=ee("notification-block");return r(),c("section",Se,[s("div",we,[s("div",Te,[i.hideLogo?_("",!0):(r(),c("div",Ce,[s("img",{width:"35",height:"35",src:t($).templateDirectoryUri+"/images/logo.svg",class:"custom-logo",alt:"Worldviewstream",decoding:"async"},null,8,ke),m[0]||(m[0]=s("h1",null,"Worldviewstream",-1))]))]),s("div",{class:U(["presentation-container",{active:t(e).gameStatus===t(A)}])},[s("div",Ue,[s("h3",null,l(t(d).how_to_play),1),s("p",null,l(t(d).description_how_to_play),1),s("p",null,[te(l(t(d).example_how_to_vote)+" ",1),m[1]||(m[1]=s("b",null,"!vote A",-1))]),s("p",null,l(t(d).time_for_play.replace("%1",t(v).timeout)),1),s("p",null,l(t(d).game_start_countdown.replace("%1",t(V))),1)])],2),!t(e).gameIsStopped&&t(e).gameStatus!==t(A)?(r(),c("div",{key:0,class:U(["countries-result-container",{active:t(e).gameStatus===t(x)}])},[s("div",Ae,[t(e).gameStatus===t(x)?(r(),c("h3",Pe,l(t(d).results),1)):(r(),c("h4",xe,l(t(d).what_kind_of_country),1)),s("div",De,[(r(!0),c(M,null,O(t(e).countries,p=>(r(),c("div",{class:"option",key:p.id},[s("div",be,[s("div",{class:"fill",style:D({height:t(g).getPercentage(p)+"%"})},null,4)]),s("div",null,[s("b",null,l(p.option),1)])]))),128))]),t(e).gameStatus!==t(x)?(r(),c("div",Le,[(r(!0),c(M,null,O(t(e).countries,p=>
2(r(),c("div",{class:"option",key:p.id},[s("span",Ve,l(p.option),1),p.flag?(r(),c("img",{key:0,class:"opt-flag",src:p.flag,alt:p.name,width:"26",height:"17"},null,8,Ee)):(r(),c("span",Ne)),s("span",Qe,l(p.name),1),s("span",Ge,l(p.votes)+" "+l(t(d).votes),1)]))),128))])):(r(),c("div",Me,[s("div",Oe,[s("div",Re,l(t(d).correct_answer),1),s("div",Be,[s("span",Fe,l(t(T).option),1),t(T).flag?(r(),c("img",{key:0,src:t(T).flag,alt:t(T).name,class:"result-message__flag",width:"36",height:"22"},null,8,$e)):_("",!0),s("span",We,l(t(T).name),1)])])]))])],2)):_("",!0),t(e).gameIsStopped&&!t(e).isChatActive?(r(),c("div",je,[s("div",ze,[s("h3",null,l(t(d).pause_game),1),s("p",null,l(t(d).no_active_participants.replace("%1",t(v).pause)),1)])])):t(e).gameIsStopped&&t(e).gameStatus===t(C)?(r(),c("div",He,[s("h3",null,l(t(d).game_is_over),1),s("p",null,l(t(d).game_is_over_description),1)])):_("",!0),t(e).gameStatus===t(P)&&!t(e).gameIsStopped&&t(f)>=0?(r(),c("div",{key:3,class:U(["timer-container",{"timer-urgent":t(f)<=5}])},[m[3]||(m[3]=s("div",{class:"timer-bg"},null,-1)),(r(),c("svg",Ye,[m[2]||(m[2]=ae('<defs><linearGradient id="timerGradient" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" stop-color="#3b82f6"></stop><stop offset="100%" stop-color="#8b5cf6"></stop></linearGradient><linearGradient id="timerUrgentGradient" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" stop-color="#ef4444"></stop><stop offset="100%" stop-color="#f97316"></stop></linearGradient></defs><circle cx="55" cy="55" r="46" class="timer-track"></circle>',2)),s("circle",{cx:"55",cy:"55",r:"46",class:"timer-ring",style:D({strokeDashoffset:289-289*t(f)/(t(v).timeout*60),stroke:t(f)<=5?"url(#timerUrgentGradient)":"url(#timerGradient)"})},null,4)])),s("div",qe,l(t(f)),1)],2)):_("",!0),t(e).gameStatus===t(P)&&t(e).showLastVotedUser&&!t(e).gameIsStopped&&t(f)>=0?(r(),c("div",Je,[s("div",Xe,[s("span",{innerHTML:t(d).voted_user.replace("%1",t(e).lastVotedUser.name).replace("%2",t(e).lastVotedUser.vote)},null,8,Ze)])])):_("",!0),s("div",Ke,[s("div",{class:U(["camera-layer-block",{active:t(F)}])},[se(ie,{name:"slide-fade"},{default:oe(()=>[t(F)?(r(),R(k,{key:0})):_("",!0)]),_:1})],2),t(o).component?(r(),R(ne(t(o).component),{style:D(t(re)),key:"video-block-"+t(o).keyIndex},null,8,["style"])):_("",!0)])],512)])}}});
2export{ut as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.