"use strict";function Reset(){this.clearCookies()}function SignalrManager(isInSteamBrowser){this.connectedCallbacks=[];this.isInSteamBrowser=isInSteamBrowser;$.connection.hub.connectionSlow(function(){})}function History(){var self,state;window.history&&typeof history.replaceState=="function"&&typeof history.pushState=="function"&&typeof history.back=="function"&&typeof window.history.forward=="function"&&(this.popStateHandlers=[],History.apiPushState=history.pushState.bind(history),History.apiReplaceState=history.replaceState.bind(history),history.pushState=History.pushState,history.replaceState=History.replaceState,self=this,window.onpopstate=function(e){if(e.state){History.enableNavigation(e.state);History.setPageUrl();for(var i=0;i<self.popStateHandlers.length;++i)self.popStateHandlers[i](e.state)}},window.addEventListener("keydown",function(e){var d=e.srcElement||e.target;e.keyCode===8&&d.tagName.toUpperCase()!=="INPUT"&&d.tagName.toUpperCase()!=="TEXTAREA"&&(e.preventDefault(),self.goBack())}),$("#go-back-history-btn").click(function(){self.goBack()}),$("#go-forward-history-btn").click(function(){window.history.forward()}),state=history.state,state&&state.historyLength||(state=state||{},state.historyLength=history.length,History.apiReplaceState(state,"history")),History.enableNavigation(state))}function Search(){function search(event){var $selectedGame,url;switch(event.keyCode){case 40:self.next();return;case 38:self.prev();self.$input.val(self.$input.val());return;case 27:self.$dropdown.hide();return;case 13:if($selectedGame=$(".dropdown-menu__item._active"),console.log($selectedGame.length),$selectedGame.length>0&&(url=$selectedGame.attr("href"),url)){window.location.href=url;return}default:self.init()}self.$input.doTimeout("text-type",500,function(){var val=self.$input.val().trim(),timestamp;if(!val||val.length<2){self.$dropdown.hide();return}timestamp=(new Date).getTime();$.ajax({url:window.urls.search,cache:!1,data:{timestamp:timestamp,query:val},success:function(data){data?(self.$dropdown.html(data),self.$dropdown.show()):self.$dropdown.hide()}})})}this.$searchWrapper=$("#header-search-wrapper");this.$form=this.$searchWrapper.find("#header-search-form");this.$input=this.$form.find("#header-search-input");this.$dropdown=this.$searchWrapper.find("#header-search-dropdown");var self=this;self.$input.on("keyup",function(event){search(event);event.stopPropagation()});self.$input.on("focus",function(event){self.$input.addClass("focus");search(event)});self.$input.on("focusout",function(){self.$input.removeClass("focus")});self.$input.each(function(){var $searchIcon=self.$searchWrapper.find(".search__icon");$(this).focus(function(){$searchIcon.addClass("_focus")}).blur(function(){$searchIcon.removeClass("_focus")})});$("html").click(function(){self.$dropdown.hide();self.init()});self.$searchWrapper.click(function(event){event.stopPropagation()});self.init()}function CarouselHelper(){}function versionCompare(v1,v2,options){function isValidPart(x){return(lexicographical?/^\d+[A-Za-z]*$/:/^\d+$/).test(x)}var lexicographical=options&&options.lexicographical,zeroExtend=options&&options.zeroExtend,v1Parts=v1.split("."),v2Parts=v2.split("."),i;if(!v1Parts.every(isValidPart)||!v2Parts.every(isValidPart))return NaN;if(zeroExtend){while(v1Parts.length<v2Parts.length)v1Parts.push("0");while(v2Parts.length<v1Parts.length)v2Parts.push("0")}for(lexicographical||(v1Parts=v1Parts.map(Number),v2Parts=v2Parts.map(Number)),i=0;i<v1Parts.length;++i){if(v2Parts.length===i)return 1;if(v1Parts[i]===v2Parts[i])continue;else return v1Parts[i]>v2Parts[i]?1:-1}return v1Parts.length!==v2Parts.length?-1:0}function getCookieValue(cookieName,fieldName){var cookieValueRe=new RegExp("(?:^|; )"+cookieName+"=([^;]+)"),cookieValueMatches=document.cookie.match(cookieValueRe),cookieValue,fieldValueRe,fieldValueMatches;return cookieValueMatches?(cookieValue=cookieValueMatches[1],!fieldName)?cookieValue:(fieldValueRe=new RegExp("(?:^|&)"+fieldName+"=([^&]+)"),fieldValueMatches=cookieValue.match(fieldValueRe),fieldValueMatches?fieldValueMatches[1]:undefined):undefined}function getParameterByName(name,url){url||(url=window.location.href);name=name.replace(/[\[\]]/g,"\\$&");var regex=new RegExp("[?&]"+name+"(=([^&#]*)|&|#|$)"),results=regex.exec(url);return results?results[2]?decodeURIComponent(results[2].replace(/\+/g," ")):"":null}function selectText(selector){var target=document.getElementById(selector),rng,sel;target&&(document.createRange?(rng=document.createRange(),rng.selectNode(target),sel=window.getSelection(),sel.removeAllRanges(),sel.addRange(rng)):(rng=document.body.createTextRange(),rng.moveToElementText(target),rng.select()))}function domainsEquals(url1,url2){var hostname1=$("<a>").prop("href",url1).prop("hostname"),hostname2=$("<a>").prop("href",url2).prop("hostname");return hostname1===hostname2}function getValueByKey(key,data){for(var len=data.length,i=0;i<len;i++)if(data[i]&&data[i].key===key)return data[i].value;return-1}function NewsletterSubscription($input,$button){const self=this;self.$input=$input;$input&&$input.keyup(function(ev){ev.which===13&&self.subscribe()});$button&&$button.click(function(){self.subscribe()})}function Notifications(ga){if(typeof window.global.currentUserId=="number"&&!(window.global.currentUserId<=0)){this.ga=ga;this.acceptInviteRequest=new $.tabletopia.post.playground.players.acceptInvite;this.declineInviteRequest=new $.tabletopia.delete.playground.players.declineInvite;$.tabletopia.postbox&&(this.roomCreatorShortUrl=ko.observable().subscribeTo($.tabletopia.postbox.room.creatorShortUrl,!0),this.roomShortUrl=ko.observable().subscribeTo($.tabletopia.postbox.room.shortUrl,!0));window.global.signalrManager.extendQueryString({userId:window.global.currentUserId});this.roomNotificationTypes=["PlayerJoinedSeat","PlayerLeftSeat","PlayerWasKicked","RoomClosed","GameStarted","RoomChatMessageAdded","PlayerInvitedToRoom","RoomReadyCheckStarted","RoomReadyCheckCancelled"];this.newNotificationSound=new Howl({urls:[window.urls.cdnUrl+"/DefaultResources/Notifications/new_notification.mp3",window.urls.cdnUrl+"/DefaultResources/Notifications/new_notification.ogg",window.urls.cdnUrl+"/DefaultResources/Notifications/new_notification.wav"]});this.initHubMethods($.connection.nh);this.initNotificationsDialog();$("body").on("click",".messager-user-settings",function(){window.location.href="/players/"+window.user.shortUrl+"/edit#settings"})}}function App(unity,ga,gaFunc){var self=this;self.unity=unity;self.settings={};self.initUserData(function(){ko.postbox&&ko.postbox.publish($.tabletopia.postbox.common.userDataReady);self.initTtCookie(gaFunc);self.reloginSteamUser();self.initTooltip();self.carousel($(".carousel:not(._modal)"));self.modalCarousel($(".carousel._modal"));self.modal();self.initWindowControlBtns();self.initPageUrl();self.initGames($(".game-short-item"));self.fixPasteToTextInputs();self.initGetPremium();self.initNotificationForDemoUser();self.initRating(unity,ga);self.welcomeManager=new WelcomeManager(ga,unity);self.initPlayingNowRooms();self.initInsertTextToActiveInput();self.initReposrtIssue()})}function ActiveRooms(){this.rooms=[];this.roomsCountChangedCallbacks=[]}function FavoriteGames(){const self=this;self.data=null;self.loading=!1;self.favoritesQueue=[];self.load=function(){self.loading||(self.loading=!0,self.data=null,$.ajax({url:"/api/games/bookmarks/id?format=json",cache:!1,success:function(data){if(self.data=data,self.loading=!1,self.favoritesQueue.length>0){for(var i=0;i<self.favoritesQueue.length;i++)self.processData(self.favoritesQueue[i]);self.favoritesQueue=[]}}}))};self.processData=function(favorites){if(favorites&&favorites.length!==0){if(self.loading){self.favoritesQueue.push(favorites);return}if(self.data!=null&&self.data.length!==0){const usersBookmarks=favorites.filter(function(){var bookmark=$(this);return $.inArray(parseInt(bookmark.attr("data-public-id")),self.data.publicIds)!==-1});usersBookmarks.each(function(i,e){var element=$(e);element.hasClass("_active")||(element.attr("title",window.SR.RemoveFromBookmarks),element.fadeTo(700,.3,function(){element.addClass("_active");element.fadeTo(300,1,function(){})}))})}}};self.init($(".favorite-game-js"))}function UsersManager(){this.userJoinedPageCallbacks=[];this.userLeftPageCallbacks=[];this.readyCheckOpenGameCallbacks=[];this.initHubMethods()}function WelcomeManager(ga,unity){this.ga=ga;this.unity=unity;this.$dlg=$("#welcome-dlg");this.init($(".welcome-slider-items",this.$dlg))}function RatingManager(ga,unity){this._isRateAvailable()&&(this.ga=ga,this.unity=unity,this.$dlg=$("#rate-dlg"),this.$rating=$("#rating-stars",this.$dlg),this._init())}var servicestack,Tabletopia;window.Log=function(message){typeof message=="string"&&message.length!==0&&$.ajax({url:location.protocol+"//"+location.host+"/api/client/log",type:"POST",global:!1,cache:!1,data:{message:message}})};Reset.prototype.clearCookies=function(){var date=new Date,dateStr;date.setTime(date.getTime()+-864e5);dateStr=date.toGMTString();document.cookie="tt-redirect=; expires="+dateStr+"; path=/; secure; SameSite=Lax";document.cookie="tt-ca=; expires="+dateStr+"; path=/; secure; SameSite=None";document.cookie="tt-dz=; expires="+dateStr+"; path=/; secure; SameSite=Lax";document.cookie="tt-user-invite=; expires="+dateStr+"; path=/; secure; SameSite=Lax"};SignalrManager.prototype.extendQueryString=function(queryString){if(typeof queryString=="object"&&!$.isEmptyObject(queryString)){var hubConnection=$.connection.hub;hubConnection.qs=hubConnection.qs||{};$.extend(hubConnection.qs,queryString)}};SignalrManager.prototype.registerConnectedCallback=function(connectedCallback){typeof connectedCallback=="function"&&this.connectedCallbacks.push(connectedCallback)};SignalrManager.prototype.connect=function(){var connectOptions={},hubConnection;connectOptions.waitForPageLoad=!1;this.isInSteamBrowser===1&&(connectOptions.transport="longPolling");hubConnection=$.connection.hub;hubConnection.start(connectOptions).done(function(){console.log("SignalR connected. ConnectionId: "+hubConnection.id)},this.connectedCallbacks).fail(function(){console.log("SignalR failed to connect")})};servicestack=function(){var JSC=function(baseUri){this.baseSyncReplyUri=path.combine(baseUri,"Json/SyncReply");this.baseAsyncOneWayUri=path.combine(baseUri,"Json/AsyncOneWay")},P=JSC.prototype,is,S,A,O,path,urn,dto;P.send=function(request,onSuccess,onError,ajaxOptions){var data,webMethod,k,ajax;if(ajaxOptions=ajaxOptions||{},data={},webMethod=typeof request=="string"?request:null,webMethod===null)for(webMethod in request){data=request[webMethod]||{};typeof data!="object"&&(data={Id:data});ajaxOptions.contentType===jsonContentType&&(data=JSON.stringify(data));break}var startCallTime=new Date,requestUrl=path.combine(this.baseSyncReplyUri,webMethod),id=JSC.id++,options={type:"GET",url:requestUrl,data:data,dataType:"json",success:function(response){var endCallTime=new Date,callDuration=endCallTime.getTime()-startCallTime.getTime(),status;if(!response){onSuccess&&onSuccess(null);return}if(status=JSC.parseResponseStatus(response.ResponseStatus),status.isSuccess){onSuccess&&onSuccess(response);JSC.onSuccess({id:id,webMethod:webMethod,request:data,response:response,durationMs:callDuration})}else{onError&&onError(status);JSC.onError({id:id,webMethod:webMethod,request:data,error:status,durationMs:callDuration})}},error:function(xhr){var endCallTime=new Date,callDuration=endCallTime.getTime()-startCallTime.getTime(),response;try{response=xhr.responseText;try{response=JSON.parse(response)}catch(e){}onError&&onError(response)}catch(e){}JSC.onError({id:id,webMethod:webMethod,request:data,error:xhr.responseText,durationMs:callDuration})}};for(k in ajaxOptions)options[k]=ajaxOptions[k];ajax=JSC.ajax(options)};P.getFromService=function(request,onSuccess,onError){var options=document.all?{cache:!1}:null;this.send(request,onSuccess,onError,options)};P.postFormDataToService=function(request,onSuccess,onError){this.send(request,onSuccess,onError,{type:"POST"})};P.postToService=function(request,onSuccess,onError){this.send(request,onSuccess,onError,{type:"POST",processData:!1,contentType:jsonContentType})};P.putToService=function(request,onSuccess,onError){this.send(request,onSuccess,onError,{type:"PUT",processData:!1,contentType:jsonContentType})};P.deleteFromService=function(request,onSuccess,onError){this.send(request,onSuccess,onError,{type:"DELETE",processData:!1,contentType:jsonContentType})};JSC.parseResponseStatus=function(status){var result,i,len,err,error;if(!status)return{isSuccess:!0};if(result={isSuccess:status.ErrorCode===undefined||status.ErrorCode===null,errorCode:status.ErrorCode,message:status.Message,errorMessage:status.ErrorMessage,stackTrace:status.StackTrace,fieldErrors:[],fieldErrorMap:{}},status.FieldErrors)for(i=0,len=status.FieldErrors.length;i<len;i++)err=status.FieldErrors[i],error={errorCode:err.ErrorCode,fieldName:err.FieldName,errorMessage:err.ErrorMessage||""},result.fieldErrors.push(error),error.fieldName&&(result.fieldErrorMap[error.fieldName]=error);return result};JSC.id=0;JSC.onError=function(){};JSC.onSuccess=function(){};JSC.toJsonDate=function(date){var jsDate=is.Date(date)?date:new Date(date)};var jsonContentType="application/json; charset=utf-8",rquery=/\?/,rts=/(\?|&)_=.*?(&|$)/,ajaxSettings={type:"GET",contentType:"application/x-www-form-urlencoded",dataType:"json",accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}};return JSC.ajax=function(s){var k,xhr,ts,ret,headers,data,strData;if(typeof $!==undefined)return $.ajax(s);for(k in ajaxSettings)s[k]||(s[k]=ajaxSettings[k]);xhr=new goog.net.XhrIo;goog.events.listen(xhr,"complete",function(){if(xhr.isSuccess()){if(!s.success)return;s.dataType=="json"?s.success(xhr.getResponseJson()):s.dataType=="xml"?s.success(xhr.getResponseXml()):s.success(xhr.getResponseText())}else{if(!s.error)return;s.error(xhr,xhr.getLastErrorCode(),xhr.getLastError())}});s.cache===!1&&type==="GET"&&(ts=(new Date).getTime(),ret=s.url.replace(rts,"$1_="+ts+"$2"),s.url=ret+(ret===s.url?(rquery.test(s.url)?"&":"?")+"_="+ts:""));headers={"Content-Type":s.contentType};data=goog.Uri.QueryData.createFromMap(new goog.structs.Map(s.data));s.type=="GET"?(s.url+=(rquery.test(s.url)?"&":"?")+data.toString(),xhr.send(s.url,"GET",null,headers)):(strData=s.contentType==jsonContentType?s.data:data.toString(),xhr.send(s.url,s.type,strData,headers))},is={Null:function(a){return a===null},Undefined:function(a){return a===undefined},Empty:function(a){return a===null||a===undefined||a===""},Function:function(a){return typeof a=="function"?a.constructor.toString().match(/Function/)!==null:!1},String:function(a){return a===null||a===undefined||a.type?!1:typeof a=="string"?!0:typeof a=="object"?a.constructor.toString().match(/string/i)!==null:!1},Array:function(a){return is.Empty(a)||a.type?!1:typeof a=="object"?a.constructor.toString().match(/array/i)!==null||a.length!==undefined:!1},Boolean:function(a){return is.Empty(a)||a.type?!1:typeof a=="boolean"?!0:typeof a=="object"?a.constructor.toString().match(/boolean/i)!==null:!1},Date:function(a){return is.Empty(a)||a.type?!1:typeof a=="date"?!0:typeof a=="object"?a.constructor.toString().match(/date/i)!==null:!1},Number:function(a){return is.Empty(a)||a.type?!1:typeof a=="number"?!0:typeof a=="object"?a.constructor.toString().match(/Number/)!==null:!1},ValueType:function(a){return is.Empty(a)||a.type?!1:is.String(a)||is.Date(a)||is.Number(a)||is.Boolean(a)}},S={},S.rtrim=function(str,chars){return chars=chars||"\\s",str.replace(new RegExp("["+chars+"]+$","g"),"")},S.toString=function(){var s,i,arg,o,name;if(arguments.length==0||!arguments[0])return null;for(s="",i=0;i<arguments.length;i++)if(arg=arguments[i],s&&(s+="/"),is.String(arg))s+=arg;else if(is.ValueType(arg))s+=arg.toString();else if(is.Array(arg))s+="["+A.join(arg,",")+"]";else{o="";for(name in arg)o&&(o+=","),o+=name+":"+S.safeString(arg[name]);s+="{"+o+"}"}return s},S.safeString=function(str){return str?S.containsAny(str,["[","]","{","}",","])?'"'+str+'"':str:str},S.containsAny=function(str,tests){if(is.String(str)){for(var i=0,len=tests.length;i<len;i++)if(str.indexOf(tests[i])!=-1)return!0;return!1}},S.startsWith=function(text,startsWith){return!text||!startsWith?!1:text.lastIndexOf(startsWith,0)==0},S.pad=function(text,padLen,padChar,rpad){var padChar=padChar||(rpad?" ":"0");for(text=text.toString();text.length<padLen;)text=rpad?text+padChar:padChar+text;return text},S.padLeft=function(text,padLen,padChar){return S.pad(text,padLen,padChar,!1)},S.padRight=function(text,padLen,padChar){return S.pad(text,padLen,padChar,!0)},S.lpad=S.padLeft,S.rpad=S.padRight,A={},A.each=function(array,fn){if(array)for(var i=0,len=array.length;i<len;i++)fn(array[i])},A.convertAll=function(array,convertFn){for(var to=[],i=0,len=array.length;i<len;i++)to[i]=convertFn(array[i]);return to},A.join=function(array,on){var s="",i,len;for(on=on||",",i=0,len=array.length;i<len;i++)s&&(s+=on),s+=array[i];return s},A.toTable=function(array,tableFormatFns){var cols,sb,i,len,obj,j,colsLen,k,data;for(tableFormatFns=tableFormatFns||{},cols=[],sb=[],i=0,len=array.length;i<len;i++)if(obj=array[i],obj){if(i==0){sb.push("<table><thead><tr>");for(k in obj)cols.push(k),sb.push("<th>"+k+"<\/th>");sb.push("<\/tr><\/thead><tbody>")}for(sb.push("<tr>"),j=0,colsLen=cols.length;j<colsLen;j++)k=cols[j],data=tableFormatFns[k]?tableFormatFns[k](obj[k]):dto.formatValue(obj[k]),sb.push("<td>"+data+"<\/td>");sb.push("<\/tr>")}return sb.push("<\/tbody><\/table>"),sb.join("")},O={},O.keys=function(obj){var keys=[];for(var key in obj)keys.push(key);return keys},path={},path.combine=function(){for(var paths="",i=0,len=arguments.length;i<len;i++)paths.length>0&&(paths+="/"),paths+=S.rtrim(arguments[i],"/");return paths},path.getFirstArg=function(path){return path?path.split("/")[0]:null},path.getFirstValue=function(path){return!path||path.indexOf("/")==-1?null:path.substr(path.indexOf("/")+1)},path.getArgs=function(path){return path?path.split("/"):null},urn={},urn.toId=function(urn){return urn.replace(/:/g,"_")},urn.getIdValue=function(urn){return urn.split(":")[2]},urn.fromId=function(urn){return urn.replace(/_/g,":")},dto={},dto.toArray=function(array){return is.Array(array)?S.toString(array):"["+S.toString(array)+"]"},dto.toUtcDate=function(date){return date.getUTCFullYear()+"-"+S.lpad(date.getUTCMonth()+1,2)+"-"+S.lpad(date.getUTCDate(),2)+"T"+S.lpad(date.getUTCHours(),2)+":"+S.lpad(date.getUTCMinutes(),2)+":"+S.lpad(date.getUTCSeconds(),2)+"Z"},dto.isJsonDate=function(str){return is.String(str)?S.startsWith(str,dto.WcfDatePrefix):!1},dto.WcfDatePrefix="/Date(",dto.toJsonDate=function(date){return date=dto.parseJsonDate(date),dto.WcfDatePrefix+date.getTime()+"+0000)/"},dto.parseJsonDate=function(date){return is.Date(date)?date:S.startsWith(date,dto.WcfDatePrefix)?new Date(parseInt(date.substring(dto.WcfDatePrefix.length,date.length-2))):new Date(date)},dto.formatDate=function(date){return date=dto.parseJsonDate(date),date.getUTCFullYear()+"/"+S.lpad(date.getUTCMonth()+1,2)+"/"+S.lpad(date.getUTCDate(),2)},dto.formatValue=function(value){return dto.isJsonDate(value)?dto.formatDate(value):is.Empty(value)?"":value},{ClientGateway:JSC,dto:dto,string:S,array:A,object:O,path:path,urn:urn}}();this.JSON||(JSON=function(){function f(n){return n<10?"0"+n:n}function stringify(value,whitelist){var a,i,k,l,r=/["\\\x00-\x1f\x7f-\x9f]/g,v;switch(typeof value){case"string":return r.test(value)?'"'+value.replace(r,function(a){var c=m[a];return c?c:(c=a.charCodeAt(),"\\u00"+Math.floor(c/16).toString(16)+(c%16).toString(16))})+'"':'"'+value+'"';case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value)return"null";if(typeof value.toJSON=="function")return stringify(value.toJSON());if(a=[],typeof value.length=="number"&&!value.propertyIsEnumerable("length")){for(l=value.length,i=0;i<l;i+=1)a.push(stringify(value[i],whitelist)||"null");return"["+a.join(",")+"]"}if(whitelist)for(l=whitelist.length,i=0;i<l;i+=1)k=whitelist[i],typeof k=="string"&&(v=stringify(value[k],whitelist),v&&a.push(stringify(k)+":"+v));else for(k in value)typeof k=="string"&&(v=stringify(value[k],whitelist),v&&a.push(stringify(k)+":"+v));return"{"+a.join(",")+"}"}}Date.prototype.toJSON=function(){return this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z"};var m={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};return{stringify:stringify,parse:function(text,filter){function walk(k,v){var i,n;if(v&&typeof v=="object")for(i in v)Object.prototype.hasOwnProperty.apply(v,[i])&&(n=walk(i,v[i]),n!==undefined&&(v[i]=n));return filter(k,v)}var j;if(/^[\],:{}\s]*$/.test(text.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),typeof filter=="function"?walk("",j):j;throw new SyntaxError("parseJSON");}}}());History.prototype.goBack=function(){var regex=new RegExp("/playground/players/[^/]+/[a-zA-Z0-9]{6}");if(regex.test(document.location.href.toLowerCase())){document.location.href="/";return}window.history.back()};History.prototype.registerPopStateHandler=function(callback){typeof callback=="function"&&this.popStateHandlers.push(callback)};History.pushState=function(state,title,url){var curState=history.state;state&&curState&&curState.historyLength&&(state.historyLength=curState.historyLength+1);History.apiPushState(state,title,url);History.setPageUrl()};History.replaceState=function(state,title,url){var curState=history.state;state&&curState&&curState.historyLength&&(state.historyLength=curState.historyLength);History.apiReplaceState(state,title,url);History.setPageUrl()};History.enableNavigation=function(state){var $backBtn,$forwardBtn;window.history.length!==1&&state&&state.historyLength&&(state.historyLength>1&&($backBtn=$("#go-back-history-btn"),$backBtn.addClass("_active")),state.historyLength<window.history.length&&($forwardBtn=$("#go-forward-history-btn"),$forwardBtn.addClass("_active")))};History.setPageUrl=function(){$("#page-url-input").val(window.location.href)};Search.prototype.init=function(){this.currentItemIndex=-1;this.$currentItem=undefined;this.$dropdown.find("[data-dropdown-search-item]").removeClass("_active")};Search.prototype.next=function(){var $items=this.$dropdown.find("[data-dropdown-search-item]");$items.removeClass("_active");this.currentItemIndex<$items.length-1&&(this.currentItemIndex+=1);this.makeItemActive($items)};Search.prototype.prev=function(){var $items=this.$dropdown.find("[data-dropdown-search-item]");$items.removeClass("_active");this.currentItemIndex>0&&(this.currentItemIndex-=1);this.makeItemActive($items)};Search.prototype.makeItemActive=function($items){this.currentItemIndex>=0&&(this.$currentItem=$items.eq(this.currentItemIndex),this.$currentItem.addClass("_active"))};CarouselHelper.prototype.initModalCarousel=function($carousels,carouselSettings){function initCarusel(self){var $parentModal=$(self).parents(".modal-dialog"),slidesLength;$parentModal.removeClass(function(index,css){return(css.match(/(^|\s)_slides_\S+/g)||[]).join(" ")});slidesLength=$(self).find(".carousel__item").length;slidesLength>0&&(slidesLength>4?(window.innerWidth>=window.global.breakpointXLg&&$parentModal.addClass("_slides_more"),slidesLength>5||window.innerWidth<=window.global.breakpointXLg&&slidesLength>4?$(".slick-slider",$parentModal).addClass("_more"):$(".slick-slider",$parentModal).removeClass("_more")):slidesLength===1?$parentModal.addClass("_slides_2"):$parentModal.addClass("_slides_"+slidesLength))}$carousels.on("init reInit",function(){initCarusel(this)});$carousels.slick(carouselSettings);var $window=$(window);$window.resize(function(){$carousels.each(function(idx,el){initCarusel(el)})})};Tabletopia=Tabletopia||{};Tabletopia.Common=Tabletopia.Common||{};Tabletopia.Common.createHiddenInput=function(name,value){return $("<input name='"+name+"' type='hidden' value='"+value+"'>")};Tabletopia.Common.createArrayHiddenInput=function(name,value,type){var allInputsCount=$("input[name*="+name+"]").length,count=allInputsCount>0?allInputsCount/3:allInputsCount,inputArray;return count===0?(inputArray=[],inputArray.push($("<input type='hidden' name='"+name+"["+count+"].Type' value='"+type+"'>")),inputArray.push($("<input type='hidden' name='"+name+"["+count+"].Id' value='"+value+"'>")),inputArray.push($("<input type='hidden' name='"+name+"["+count+"].LanguageIdentity' value>")),inputArray):null};Tabletopia.Common.objectEquals=function(obj1,obj2){var i,j;for(i in obj1)if(obj1.hasOwnProperty(i)&&(!obj2.hasOwnProperty(i)||obj1[i]!==obj2[i]))return!1;for(j in obj2)if(obj2.hasOwnProperty(j)&&(!obj1.hasOwnProperty(j)||obj1[j]!==obj2[j]))return!1;return!0};Tabletopia.Common.keysToCamel=function(object){if(object!==Object(object)||Array.isArray(object)||typeof object=="function"){if(Array.isArray(object))return object.map(function(i){return Tabletopia.Common.keysToCamel(i)})}else{const n={},keys=Object.keys(object);for(let i=0;i<keys.length;i++)n[keys[i].lowercaseFirst()]=this.keysToCamel(object[keys[i]]);return n}return object};NewsletterSubscription.prototype.subscribe=function(){const email=this.$input.val();if(email.length!==0){const gateway=new servicestack.ClientGateway(location.protocol+"//"+location.host+"/api/");gateway.postToService({SubscribeEmail:{email:email}});Messenger().post({extraClasses:"messenger-fixed messenger-on-bottom messenger-on-right",message:"Thank you! You successfully subscribed to the Tabletopia newsletter.",showCloseButton:!0,hideAfter:6});this.$input.val("")}};Notifications.prototype.initHubMethods=function(proxy){var self=this;proxy.client.addNotification=function(notification){typeof notification!="undefined"&&self.addNotification(notification)};proxy.client.removeNotifications=function(notificationId){typeof notificationId!="undefined"&&self.removeNotification(notificationId)}};Notifications.prototype.addNotification=function(notification){typeof notification!="undefined"&&(this.roomNotificationTypes.indexOf(notification.TypeStr)!==-1&&notification.TypeStr!=="PlayerWasKicked"&&notification.TypeStr!=="RoomReadyCheckCancelled"&&this.isInRoom(notification.Content.UserShortUrl,notification.Content.RoomShortUrl)||(notification.Id>0&&this.addDialogNotification(notification),this.showMessenger(notification)))};Notifications.prototype.isInRoom=function(userShortUrl,roomShortUrl){return typeof room!="undefined"?window.room.creatorShortUrl===userShortUrl&&window.room.shortUrl.toLowerCase()===roomShortUrl.toLowerCase():this.roomCreatorShortUrl?this.roomCreatorShortUrl()===userShortUrl&&this.roomShortUrl().toLowerCase()===roomShortUrl.toLowerCase():void 0};Notifications.prototype.showMessenger=function(notification){var options=this.getMessengerOptions(notification);Messenger({extraClasses:"messenger-fixed messenger-on-bottom messenger-on-right"}).post(options);this.newNotificationSound.stop().play()};Notifications.prototype.getMessengerOptions=function(notification){var options={type:"info",hideAfter:10,showCloseButton:!0};return this.roomNotificationTypes.indexOf(notification.TypeStr)!==-1?this.fillMessagerOptionsForRoom(notification,options):notification.TypeStr==="GameSuggested"&&this.fillMessagerOptionsForGameSuggested(notification,options),options.message=this.createMessagerMessage(notification),options};Notifications.prototype.fillMessagerOptionsForRoom=function(notification,options){var self=this;options.onClickClose=function(){};notification.Content.HasNoActions!==!0&&(options.actions=notification.TypeStr==="PlayerInvitedToRoom"?{playAction:{label:window.SR.Join,action:function(){var n=this;self.acceptInvitation(notification.Id,notification.Content.InvitationId,function(jqXHR){n.hide();window.location.href=jqXHR.result||jqXHR.reason!=="PremiumSetupNotAvailable"?window.urls.roomTemplate.replace("user-short-url",notification.Content.UserShortUrl).replace("room-short-url",notification.Content.RoomShortUrl):window.urls.zoneBuySubscription.replace("user-short-url",notification.Content.UserShortUrl).replace("room-short-url",notification.Content.RoomShortUrl)},function(jqXHR){jqXHR.status===403&&(n.hide(),window.location.href=window.urls.sessionManager.replace("user-short-url",notification.Content.UserShortUrl).replace("room-short-url",notification.Content.RoomShortUrl))})}},cancelAction:{label:window.SR.Reject,action:function(){this.hide();self.declineInvitation(notification.Id,notification.Content.InvitationId)}}}:notification.TypeStr==="RoomReadyCheckStarted"?{playAction:{label:window.SR.Ready,action:function(){var n=this;self.readyCheckSetReady(notification.Id,notification.Content.RoomShortUrl,function(res){n.hide();typeof res!="undefined"&&res.gameIsOpening&&self.isInRoom(notification.Content.UserShortUrl,notification.Content.RoomShortUrl)||(window.location.href=window.urls.roomTemplate.replace("user-short-url",notification.Content.UserShortUrl).replace("room-short-url",notification.Content.RoomShortUrl))})}},cancelAction:{label:window.SR.LeaveRoom,action:function(){this.hide();self.readyCheckLeaveGame(notification.Id,notification.Content.RoomShortUrl)}}}:{playAction:{label:notification.TypeStr==="GameStarted"?window.SR.Play:window.SR.GoToRoom,action:function(){this.hide();self.markAsRead(notification.Id,function(){var templateUrl;templateUrl=notification.TypeStr==="GameStarted"?window.urls.roomPlayTemplate:window.urls.roomTemplate;window.location.href=templateUrl.replace("user-short-url",notification.Content.UserShortUrl).replace("room-short-url",notification.Content.RoomShortUrl)})}}});(notification.TypeStr==="PlayerJoinedSeat"||notification.TypeStr==="PlayerLeftSeat")&&notification.Content.MinPlayersNeeded===0?(options.id=notification.TypeStr+notification.Content.UserShortUrl+notification.Content.RoomShortUrl+notification.Content.MinPlayersNeeded,options.hideAfter=3600):notification.TypeStr==="PlayerInvitedToRoom"?options.hideAfter=3600:(notification.TypeStr==="RoomReadyCheckStarted"||notification.TypeStr==="RoomReadyCheckCancelled")&&(options.id="RoomReadyCheckStartedOrCancelled"+notification.Content.UserShortUrl+notification.Content.RoomShortUrl,notification.TypeStr==="RoomReadyCheckStarted"&&(options.hideAfter=typeof window.global.readyCheckTimeoutSeconds!="undefined"?window.global.readyCheckTimeoutSeconds:300))};Notifications.prototype.fillMessagerOptionsForGameSuggested=function(notification,options){var self=this;options.actions={playAction:{label:window.SR.Yes,action:function(){var n=this;self.acceptGameSuggestion(notification.Id,notification.Content.GamePublicId,notification.Content.GameName,function(resp){n.hide();resp.reachedSessionsLimit?self.showReachedSessionsLimitMessage():self.showGameSuggestionAcceptedMessage()})}},laterAction:{label:window.SR.NotNow,action:function(){this.hide();self.rejectGameSuggestion(notification.Id,notification.Content.GamePublicId,notification.Content.GameName)}}};options.hideAfter=3600};Notifications.prototype.showGameSuggestionAcceptedMessage=function(){Messenger({extraClasses:"messenger-fixed messenger-on-bottom messenger-on-right"}).post({type:"success",hideAfter:30,showCloseButton:!0,message:window.SR.GameWillStartWhenEnoughUsersAccept})};Notifications.prototype.showReachedSessionsLimitMessage=function(){Messenger({extraClasses:"messenger-fixed messenger-on-bottom messenger-on-right"}).post({type:"warning",hideAfter:60,showCloseButton:!0,message:window.SR.CloseSessionsToPlayGame})};Notifications.prototype.createMessagerMessage=function(notification){var $message=$("#messager-message-template").clone().removeClass("hidden"),$img;return $message.find("table").attr("data-id",notification.Id),typeof notification.Content!="undefined"&&($img=$message.find(".messager-image-cell img"),typeof notification.Content.ImageUrl!="undefined"&&notification.Content.ImageUrl.length>0&&$img.attr("src",notification.Content.ImageUrl+$img.attr("data-img-query")).css("opacity",1),typeof notification.Content.Title!="undefined"&&notification.Content.Title.length>0&&($message.find(".messager-title-cell").append("<strong>"+notification.Content.Title+"<\/strong>"),$img.attr("alt",notification.Content.Title)),typeof notification.Content.Message!="undefined"&&notification.Content.Message.length>0&&$message.find(".messager-text-cell").append(notification.Content.Message)),$message.html()};Notifications.prototype.initNotificationsDialog=function(){var self=this,$dlg=$("#notifications-dialog"),$indicator=$("#page-notifications-indicator");$dlg.find(".overall-notify__clear").click(function(){self.markAsReadAll()});$indicator.click(function(e){(e.preventDefault(),$indicator.hasClass("disabled"))||$dlg.toggleClass("hidden")});$(document).click(function(e){var $target=$(e.target);$target.is($indicator)||$target.closest($indicator).length!==0||$target.hasClass("notify-item__closer")||$target.hasClass("notify-item__button")||$target.is($dlg)||$target.closest($dlg).length!==0||$dlg.hasClass("hidden")||$dlg.addClass("hidden")});this.loadDialogNotifications()};Notifications.prototype.loadDialogNotifications=function(){var self=this;$.ajax({url:window.urls.notificationGet,cache:!1,global:!1,dataType:"html",success:function(html){typeof html!="undefined"&&html!==""&&self.processDialogNotifications($(html))}})};Notifications.prototype.processDialogNotifications=function($notifications){this.processRoomInvitationNotifications($notifications.filter("[data-type=PlayerInvitedToRoom]"));this.processReadyCheckNotifications($notifications.filter("[data-type=RoomReadyCheckStarted]"));this.processGameSuggestedNotifications($notifications.filter("[data-type=GameSuggested]"));var $standardNotifications=$notifications.filter(function(){var type=$(this).attr("data-type");return type!=="PlayerInvitedToRoom"&&type!=="RoomReadyCheckStarted"&&type!=="GameSuggested"});this.processStandardNotifications($standardNotifications);$("#notifications-dialog").find(".overall-notify__list").prepend($notifications);this.updateDialogNotificationsCount()};Notifications.prototype.processRoomInvitationNotifications=function($roomInvitations){var self=this;$roomInvitations.find(".notify-item__closer").click(function(){var $notification=$(this).parents(".notify-item"),invData=$notification.find("input[name=invitation-data]");self.declineInvitation($notification.attr("data-id"),invData.attr("data-inv-id"))});$roomInvitations.find(".notify-item__buttons .notify-item__button").click(function(e){e.preventDefault();var $this=$(this),$notification=$this.parents(".notify-item"),invData=$notification.find("input[name=invitation-data]");$this.hasClass("_play")?self.acceptInvitation($notification.attr("data-id"),invData.attr("data-inv-id"),function(jqXHR){window.location.href=jqXHR.result||jqXHR.reason!=="PremiumSetupNotAvailable"?window.urls.roomTemplate.replace("user-short-url",invData.attr("data-user-url")).replace("room-short-url",invData.attr("data-room-url")):window.urls.zoneBuySubscription.replace("user-short-url",invData.attr("data-user-url")).replace("room-short-url",invData.attr("data-room-url"))},function(jqXHR){jqXHR.status===403&&(window.location.href=window.urls.sessionManager.replace("user-short-url",invData.attr("data-user-url")).replace("room-short-url",invData.attr("data-room-url")))}):$this.hasClass("js-cancel")&&self.declineInvitation($notification.attr("data-id"),invData.attr("data-inv-id"))})};Notifications.prototype.processReadyCheckNotifications=function($readyChecks){var self=this;$readyChecks.find(".notify-item__closer").click(function(){var $notification=$(this).parents(".notify-item");self.markAsRead($notification.attr("data-id"))});$readyChecks.find(".notify-item__buttons .notify-item__button").click(function(e){var $this=$(this),$notification=$this.parents(".notify-item"),readyCheckData=$notification.find("input[name=ready-check-data]");$this.hasClass("_play")?(e.preventDefault(),self.readyCheckSetReady($notification.attr("data-id"),readyCheckData.attr("data-room-url"),function(){window.location.href=window.urls.roomTemplate.replace("user-short-url",readyCheckData.attr("data-user-url")).replace("room-short-url",readyCheckData.attr("data-room-url"))})):$this.hasClass("js-cancel")&&(e.preventDefault(),self.readyCheckLeaveGame($notification.attr("data-id"),readyCheckData.attr("data-room-url")))})};Notifications.prototype.processGameSuggestedNotifications=function($suggestions){var self=this;$suggestions.find(".notify-item__closer").click(function(){var $notification=$(this).parents(".notify-item"),suggestData=$notification.find("input[name=game-suggestion-data]");self.rejectGameSuggestion($notification.attr("data-id"),suggestData.attr("data-game-public-id"),suggestData.attr("data-game-name"))});$suggestions.find(".notify-item__buttons .notify-item__button").click(function(e){e.preventDefault();var $this=$(this),$notification=$this.parents(".notify-item"),suggestData=$notification.find("input[name=game-suggestion-data]");$this.hasClass("_play")?self.acceptGameSuggestion($notification.attr("data-id"),suggestData.attr("data-game-public-id"),suggestData.attr("data-game-name"),function(resp){resp.reachedSessionsLimit?self.showReachedSessionsLimitMessage():self.showGameSuggestionAcceptedMessage()}):$this.hasClass("js-cancel")&&self.rejectGameSuggestion($notification.attr("data-id"),suggestData.attr("data-game-public-id"),suggestData.attr("data-game-name"))})};Notifications.prototype.processStandardNotifications=function($notifications){var self=this;$notifications.find(".notify-item__closer").click(function(){var $notification=$(this).parents(".notify-item");self.markAsRead(parseInt($notification.attr("data-id")))});$notifications.find(".notify-item__buttons .notify-item__button._play").click(function(e){e.preventDefault();var $this=$(this),$notification=$this.parents(".notify-item");self.markAsRead($notification.attr("data-id"),function(){window.location.href=$this.attr("href")})})};Notifications.prototype.updateDialogNotificationsCount=function(){var $dlg=$("#notifications-dialog"),count=$dlg.find(".notify-item").length,$notyCount,$notyBtn;count===0?this.clearAndHideNotificationsDialog():($dlg.find(".overall-notify__title").text(count+" "+(count>1?window.SR.Notifications:window.SR.Notification)),$notyCount=$("#page-notifications-counter"),$notyCount.fadeTo(1e3,.3,function(){$notyCount.text(count);$notyCount.fadeTo(300,1)}),$notyBtn=$("#page-notifications-indicator"),$notyBtn.fadeTo(1e3,.5,function(){$notyBtn.removeClass("disabled");$notyBtn.fadeTo(300,1)}))};Notifications.prototype.clearAndHideNotificationsDialog=function(){var $dlg=$("#notifications-dialog"),$notyBtn;$dlg.addClass("hidden");$dlg.find(".overall-notify__list").empty();$notyBtn=$("#page-notifications-indicator");$notyBtn.fadeTo(700,1,function(){$notyBtn.addClass("disabled");$notyBtn.fadeTo(300,.5,function(){$("#page-notifications-counter",$notyBtn).text("")})})};Notifications.prototype.addDialogNotification=function(notification){var $n=$("#dialog-notification-template").clone().removeAttr("id").removeClass("hidden").attr("data-id",notification.Id).attr("data-type",notification.TypeStr),$img,$invDataInput,$readyCheckDataInput,roomUrl,templateUrl,$suggestDataInput;if($n.toggleClass("_nobuttons",notification.Content.HasNoActions),typeof notification.Content.ImageUrl=="undefined"||notification.Content.ImageUrl.length===0?$n.find(".notify-item__image").remove():($img=$n.find(".notify-item__image img"),$img.attr("src",notification.Content.ImageUrl+$img.attr("data-img-query")).css("opacity",1)),$n.find(".notify-item__game span").text(notification.Content.Title),$n.find(".notify-item__info").html(notification.Content.Message),$n.find(".notify-item__time").text(notification.Timestamp),notification.Content.HasNoActions!==!0){var $playAction=$n.find(".notify-item__buttons ._play"),$cancelAction=$n.find(".notify-item__buttons .js-cancel"),$linkAction=$n.find(".notify-item__buttons ._link");this.roomNotificationTypes.indexOf(notification.TypeStr)!==-1?notification.TypeStr==="PlayerInvitedToRoom"?($invDataInput=$("<input type='hidden' name='invitation-data'/>").attr("data-inv-id",notification.Content.InvitationId).attr("data-user-url",notification.Content.UserShortUrl).attr("data-room-url",notification.Content.RoomShortUrl),$invDataInput.insertAfter($cancelAction),$playAction.text(window.SR.Join),$cancelAction.addClass("_cancel").removeClass("hidden").text(window.SR.Reject)):notification.TypeStr==="RoomReadyCheckStarted"?($readyCheckDataInput=$("<input type='hidden' name='ready-check-data'/>").attr("data-user-url",notification.Content.UserShortUrl).attr("data-room-url",notification.Content.RoomShortUrl),$readyCheckDataInput.insertAfter($cancelAction),$playAction.text(window.SR.Ready),$cancelAction.addClass("_cancel").removeClass("hidden").text(window.SR.LeaveRoom),roomUrl=window.urls.roomTemplate.replace("user-short-url",notification.Content.UserShortUrl).replace("room-short-url",notification.Content.RoomShortUrl),$linkAction.attr("href",roomUrl).removeClass("hidden").text(window.SR.GoToRoom)):(templateUrl=notification.TypeStr==="GameStarted"?window.urls.roomPlayTemplate:window.urls.roomTemplate,$playAction.attr("href",templateUrl.replace("user-short-url",notification.Content.UserShortUrl).replace("room-short-url",notification.Content.RoomShortUrl)),$playAction.text(notification.TypeStr==="GameStarted"?window.SR.Play:window.SR.GoToRoom)):notification.TypeStr==="GameSuggested"&&($suggestDataInput=$("<input type='hidden' name='game-suggestion-data'/>").attr("data-game-public-id",notification.Content.GamePublicId).attr("data-game-name",notification.Content.GameName),$suggestDataInput.insertAfter($cancelAction),$playAction.text(window.SR.Yes),$cancelAction.addClass("_bordered").removeClass("hidden").text(window.SR.NotNow))}this.processDialogNotifications($n)};Notifications.prototype.markAsRead=function(notificationId,successCallback){if(typeof notificationId!="number"||notificationId<=0){typeof successCallback=="function"&&successCallback();return}$.ajax({type:"POST",cache:!1,url:window.urls.notificationMarkAsRead,data:{id:notificationId},success:successCallback});this.removeNotification(notificationId)};Notifications.prototype.markAsReadAll=function(){$.ajax({type:"POST",url:window.urls.notificationMarkAsReadAll});this.clearAndHideNotificationsDialog()};Notifications.prototype.acceptInvitation=function(notificationId,invitationId,successCallback,errorCallback){this.acceptInviteRequest.isLoading()||(this.acceptInviteRequest.setUrl($.tabletopia.routes.playground.api("inviteplayers","invite",invitationId)),this.acceptInviteRequest.load().then(successCallback,errorCallback),this.removeNotification(notificationId))};Notifications.prototype.declineInvitation=function(notificationId,invitationId){this.declineInviteRequest.isLoading()||(this.declineInviteRequest.setUrl($.tabletopia.routes.playground.api("inviteplayers","invite",invitationId)),this.declineInviteRequest.load(),this.removeNotification(notificationId))};Notifications.prototype.readyCheckSetReady=function(notificationId,roomShortUrl,successCallback){$.ajax({type:"POST",cache:!1,url:window.urls.readyCheckSetReady,data:{roomShortUrl:roomShortUrl},success:successCallback});this.removeNotification(notificationId)};Notifications.prototype.readyCheckLeaveGame=function(notificationId,roomShortUrl){$.ajax({type:"POST",cache:!1,url:window.urls.leaveRoom,data:{roomShortUrl:roomShortUrl,userId:window.global.currentUserId}});this.removeNotification(notificationId)};Notifications.prototype.removeNotification=function(notificationId){typeof notificationId=="undefined"||notificationId<=0||(Messenger().$el.find("table[data-id="+notificationId+"]").parents(".messenger-message-slot").remove(),$("#notifications-dialog").find(".notify-item[data-id="+notificationId+"]").remove(),this.updateDialogNotificationsCount())};Notifications.prototype.acceptGameSuggestion=function(notificationId,gamePublicId,gameName,successCallback){$.ajax({type:"POST",cache:!1,url:"/api/games/suggestions/"+gamePublicId+"/accept",dataType:"json",success:successCallback});this.removeNotification(notificationId)};Notifications.prototype.rejectGameSuggestion=function(notificationId,gamePublicId){$.ajax({type:"POST",cache:!1,url:"/api/games/suggestions/"+gamePublicId+"/reject",dataType:"json"});this.removeNotification(notificationId)},function($){function httpRequest(url,options){const self=this;let o=$.extend(!0,{},httpRequestDefaults,options),ajax=null;self.url=typeof url=="function"?url():url;self.data=$.isArray(o.emptyValue)?ko.observableArray(o.emptyValue):ko.observable(o.emptyValue);self.rawData=$.isArray(o.emptyValue)?ko.observableArray(o.emptyValue):ko.observable(o.emptyValue);self.hasData=ko.observable(!1);self.isLoading=ko.observable(!1);self.error=ko.observable("");self.requestCanceled=ko.observable(!1);self.state=ko.pureComputed(function(){return{data:self.data(),hasData:self.hasData(),isLoading:self.isLoading(),error:self.error()}});self.load=function(data,timeout){if(!self.isLoading()){self.isLoading(!0);self.hasData(!1);self.data(o.emptyValue);self.rawData(o.emptyValue);self.error("");self.requestCanceled(!1);let finished=$.Deferred(),request={url:self.url,type:o.type,traditional:o.traditional,processData:o.processData,data:data,cache:o.cache,global:o.global,context:self};return request.processData===!1&&(request.contentType=!1),setTimeout(function(){ajax=$.ajax(request).done(function(rawJson,textStatus,xhr){self.checkUnauthorizedResponse(xhr);try{let values=o.responseConverter(rawJson);self.data(values);self.rawData(rawJson);self.hasData(!0);self.isLoading(!1)}catch(err){self.error(o.errorMessage);self.hasData(!1);console.error(err)}finished.resolve(rawJson)}).fail(function(e){let errorMessage=e.responseJSON&&e.responseJSON.message?e.responseJSON.message:o.errorMessage;e.getAllResponseHeaders()||(self.requestCanceled(!0),errorMessage="Request Canceled.");self.error(errorMessage);$(window).scrollTop(0);console.error(e);finished.reject(e)}).always(function(){self.isLoading(!1)})},timeout?timeout:0),finished.promise()}};self.checkUnauthorizedResponse=function(xhr){try{let header=xhr.getResponseHeader("X-Responded-JSON");if(header){let obj=JSON.parse(header);obj.status==401&&(window.location.href=obj.headers.location)}}catch(err){console.error(err)}};self.loadIfNoData=function(data){self.hasData()||self.isLoading()||self.load(data)};self.cancel=function(){ajax&&(ajax.abort(),self.requestCanceled(!0))};self.setData=function(data){self.data(data);self.hasData(JSON.stringify(data)!=JSON.stringify(o.emptyValue));self.isLoading(!1);self.error("");self.requestCanceled(!1)};self.setUrl=function(url){self.url=url}}function httpGet(url,options){var o=$.extend(!0,{type:"GET"},options);httpRequest.call(this,url,o)}function httpDelete(url,options){var o=$.extend(!0,{type:"DELETE"},options);httpRequest.call(this,url,o)}function httpPost(url,options){var o=$.extend(!0,{type:"POST"},options);httpRequest.call(this,url,o)}function httpPut(url,options){var o=$.extend(!0,{type:"PUT"},options);httpRequest.call(this,url,o)}var $routes=$.tabletopia.routes,httpRequestDefaults={errorMessage:"Loading Error.",responseConverter:function(data){return data},emptyValue:{},type:undefined,traditional:!1,processData:!0,cache:!1,global:!0};const getRequests={subscriptions:{my:function(){httpGet.call(this,$routes.subscriptions.my(),{emptyValue:{}})}},users:{current:function(){httpGet.call(this,$routes.users.current(),{emptyValue:{}})},resetToken:function(){httpGet.call(this,$routes.users.getResetToken(),{emptyValue:{}})}},findPlay:{playNow:function(){httpGet.call(this,$routes.findPlay.playNow(),{traditional:!0})},playLater:function(){httpGet.call(this,$routes.findPlay.playLater(),{traditional:!0})},playInProgress:function(){httpGet.call(this,$routes.findPlay.playInProgress(),{traditional:!0})},recommendedGames:function(){httpGet.call(this,$routes.findPlay.recommendedGames(),{emptyValue:{},cache:!0})},recommendedWidgetGames:function(){httpGet.call(this,$routes.findPlay.recommendedWidgetGames(),{traditional:!0,cache:!0})}},whitelabel:{findPlay:{playNow:function(whitelabel,whitelabelEvent){httpGet.call(this,$routes.whitelabel.api(whitelabel,whitelabelEvent,"find-play","now"),{traditional:!0})},playLater:function(whitelabel,whitelabelEvent){httpGet.call(this,$routes.whitelabel.api(whitelabel,whitelabelEvent,"find-play","later"),{traditional:!0})},playInProgress:function(whitelabel,whitelabelEvent){httpGet.call(this,$routes.whitelabel.api(whitelabel,whitelabelEvent,"find-play","in-progress"),{traditional:!0})}},room:{room:function(whitelabel,whitelabelEvent,room){const url=$routes.whitelabel.api(whitelabel,whitelabelEvent,room);httpGet.call(this,url,{emptyValue:{},global:!1})},searchGames:function(whitelabel,whitelabelEvent){const url=$routes.whitelabel.api(whitelabel,whitelabelEvent,"search");httpGet.call(this,url,{emptyValue:{},global:!1})}}},playground:{room:function(room){const url=$routes.playground.api("rooms",room);httpGet.call(this,url,{emptyValue:{},global:!1})},roomExists:function(){httpGet.call(this,"",{emptyValue:{},global:!1})},searchGames:function(){const url=$routes.playground.api("search-games");httpGet.call(this,url,{emptyValue:{},global:!1})},invitations:function(){const url=$routes.playground.invitations();httpGet.call(this,url,{emptyValue:{},global:!1})},sessionsManager:function(){const url=$routes.playground.sessionsManager();httpGet.call(this,url,{emptyValue:{},global:!1})},chat:{room:{messages:function(roomShortUrl){const url=$routes.playground.api("chat","room",roomShortUrl);httpGet.call(this,url,{emptyValue:{},global:!1})}}}},geolocation:{countries:function(){httpGet.call(this,$routes.geolocation.countries(),{emptyValue:{}})}}},postRequests={subscriptions:{create:function(){httpPost.call(this,$routes.subscriptions.baseRoute(),{emptyValue:{},traditional:!0})},activate:function(){httpPost.call(this,$routes.subscriptions.activate(),{emptyValue:{},traditional:!0})},steam:{buy:function(subscriptionId){const url=$routes.subscriptions.steam.buy(subscriptionId,"buy");httpPost.call(this,url,{emptyValue:{},global:!1})},synchronizeDlc:function(){httpPost.call(this,$routes.subscriptions.steam.synchronizeDlc,{emptyValue:{},global:!1})},finalize:function(){httpPost.call(this,$routes.subscriptions.steam.finalize,{emptyValue:{},global:!1})}}},users:{login:function(){httpPost.call(this,$routes.users.login())},loginOverSSO:function(){httpPost.call(this,$routes.users.loginOverSSO())},signup:function(){httpPost.call(this,$routes.users.signup())},resetPassword:function(){httpPost.call(this,$routes.users.resetPassword())},activateCoupon:function(coupon){httpPost.call(this,$routes.users.activateCoupon(coupon))}},whitelabel:{room:{create:function(whitelabel,whitelabelEvent){const url=$routes.whitelabel.api(whitelabel,whitelabelEvent);httpPost.call(this,url,{emptyValue:{},global:!1})},game:{change:function(whitelabel,whitelabelEvent,room){const url=$routes.whitelabel.api(whitelabel,whitelabelEvent,room,"game");httpPost.call(this,url,{emptyValue:{},global:!1})}},players:{join:function(whitelabel,whitelabelEvent,room){const url=$routes.whitelabel.api(whitelabel,whitelabelEvent,room,"players");httpPost.call(this,url,{emptyValue:{},cache:!1})}}}},playground:{registerUser:function(){const url=$routes.playground.api("register-user");httpPost.call(this,url,{emptyValue:{},cache:!1})},create:function(zoneShortUrl){const url=$routes.playground.api("rooms",zoneShortUrl);httpPost.call(this,url,{emptyValue:{},global:!1})},game:{setScheduledGame:function(room){const url=$routes.playground.api("rooms",room,"scheduled-game");httpPost.call(this,url,{emptyValue:{},global:!1})},setWelcomeMessage:function(room){const url=$routes.playground.api("rooms",room,"welcome-message");httpPost.call(this,url,{emptyValue:{},global:!1})},setTableAccessType:function(room){const url=$routes.playground.api("rooms",room,"access-type");httpPost.call(this,url,{emptyValue:{},global:!1})},setTableSettings:function(room){const url=$routes.playground.api("rooms",room,"settings");httpPost.call(this,url,{emptyValue:{},global:!1})},change:function(room){const url=$routes.playground.api("rooms",room,"game");httpPost.call(this,url,{emptyValue:{},global:!1})},playNow:function(room){const url=$routes.playground.api("rooms",room,"play");httpPost.call(this,url,{emptyValue:{},global:!1})}},setup:{change:function(room){const url=$routes.playground.api("rooms",room,"setup");httpPost.call(this,url,{emptyValue:{},global:!1})}},seats:{add:function(room){const url=$routes.playground.api("rooms",room,"seat");httpPost.call(this,url,{emptyValue:{},cache:!1})}},players:{join:function(room){const url=$routes.playground.api("rooms",room,"players");httpPost.call(this,url,{emptyValue:{},cache:!1})},invite:function(){const url=$routes.playground.api("inviteplayers","invite");httpPost.call(this,url,{emptyValue:{},cache:!1})},acceptInvite:function(){httpPost.call(this,"",{emptyValue:{},cache:!1})}},readyCheck:{start:function(room){const url=$routes.playground.api("rooms",room,"readycheck");httpPost.call(this,url,{emptyValue:{},cache:!1})},ready:function(room){const url=$routes.playground.api("rooms",room,"readycheck","ready");httpPost.call(this,url,{emptyValue:{},cache:!1})}},chat:{room:{send:function(room){const url=$routes.playground.api("chat","room",room);httpPost.call(this,url,{emptyValue:{},global:!1})}}}}},deleteRequests={subscriptions:{subscription:function(data){const url=$routes.subscriptions.baseRoute(data);httpDelete.call(this,url)},paymentInfo:function(userId){const url=$routes.subscriptions.paymentInfo(userId);httpDelete.call(this,url,{emptyValue:{},global:!1})}},playground:{room:function(room){const url=$routes.playground.api("rooms",room);httpDelete.call(this,url,{emptyValue:{},global:!1})},game:{deleteScheduledGame:function(room){const url=$routes.playground.api("rooms",room,"scheduled-game");httpDelete.call(this,url,{emptyValue:{},global:!1})}},seats:{remove:function(){httpDelete.call(this,"",{emptyValue:{},cache:!1})}},players:{leave:function(room){const url=$routes.playground.api("rooms",room,"players");httpDelete.call(this,url,{emptyValue:{},cache:!1})},declineInvite:function(){httpDelete.call(this,"",{emptyValue:{},cache:!1})}},readyCheck:{cancel:function(room){const url=$routes.playground.api("rooms",room,"readycheck");httpDelete.call(this,url,{emptyValue:{},cache:!1})}}}},putRequests={subscriptions:{update:function(){httpPut.call(this,$routes.subscriptions.baseRoute(),{emptyValue:{},traditional:!0})},updatePaymentInfo:function(){const url=$routes.subscriptions.paymentInfo();httpPut.call(this,url,{emptyValue:{},cache:!1})}}};$.extend(!0,$,{tabletopia:{get:getRequests,post:postRequests,"delete":deleteRequests,put:putRequests}})}(jQuery);App.prototype.initTtCookie=function(){var cookie=window.cookie.environmentCookieName+"="+window.cookie.retinaValueName+"="+(window.devicePixelRatio>1)+"&"+window.cookie.timezoneOffsetValueName+"="+(new Date).getTimezoneOffset();document.cookie=cookie+"; path=/; secure; SameSite=Lax"};App.prototype.initPlayingNowRooms=function(){var self=this;$("#playing-now-room-btn").click(function(){$(this).hasClass("disabled")||$.ajax({url:window.urls.playingNowRooms,cache:!1,success:function(data){$(".playing-now-rooms-dynamic-js").each(function(i,e){$(e).html(data);$("#playing-now-room-dlg").modal();var count=$("#playing-now-room-dlg .carousel__item").not("._empty").length;$(".playing-now-rooms-count-dynamic-js").html(count);self.modalCarousel($("#playing-now-room-dlg .carousel._modal"));initPlayingNowRooms()})}})})};App.prototype.initTooltip=function(){$("body").tooltip({selector:"[title]",html:!0,container:"body"})};App.prototype.carousel=function($carousels,settings){typeof settings=="undefined"&&(settings=window.global.carouselSettings);$carousels.not(".slick-initialized").slick(settings);$carousels.removeClass("hidden")};App.prototype.modalCarousel=function($carousels){this.carouselHelper=new CarouselHelper;this.carouselHelper.initModalCarousel($carousels,window.global.carouselSettings)};App.prototype.modal=function(){$(".modal").on("shown.bs.modal",function(){$(this).find(".carousel").slick("setPosition")})};App.prototype.initWindowControlBtns=function(){if(this.unity&&typeof this.unity.sendMessage=="function"){var self=this,unity=self.unity;window.SetFullscreen=function(fullscreen,json){self.setMaximizeButtonType(json.value)};$("#maximize-wnd-btn").removeClass("hidden").click(function(){unity.sendMessage("SwitchFullscreen",{})});window.global.isWinOs()&&$("#minimize-wnd-btn").removeClass("hidden").click(function(){unity.sendMessage("MinimizeWindow",{})});$("#close-wnd-btn").removeClass("hidden").click(function(){unity.sendMessage("ApplicationExit",{})})}};App.prototype.setMaximizeButtonType=function(fullScreen){fullScreen?$("#maximize-wnd-btn").addClass("_off"):$("#maximize-wnd-btn").removeClass("_off")};App.prototype.initPageUrl=function(){var self=this;$("#page-url-input").click(function(){if(this.innerText&&this.innerText.length>0){var range,selection;window.getSelection&&document.createRange?(selection=window.getSelection(),range=document.createRange(),range.selectNodeContents(this),selection.removeAllRanges(),selection.addRange(range)):document.selection&&document.body.createTextRange&&(range=document.body.createTextRange(),range.moveToElementText(this),range.select())}});$("#page-url-copy-btn").click(function(){var text=$("#page-url-input").text();self.unity&&typeof self.unity.sendMessage=="function"&&text&&self.unity.sendMessage("CopyToClipboard",{data:text})})};App.prototype.initGames=function($games){$games.click(function(){var $this=$(this),url=$this.attr("data-game-url");url&&(window.location.href=url)});$games.find(".play-now-button-js").click(App.prototype.createRoom)};App.prototype.urlClickOnce=function(e){e.stopPropagation();var $this=$(this);return $this.attr("data-clicked")!==undefined?!1:($this.attr("data-clicked",!0),!0)};App.prototype.fixPasteToTextInputs=function(){if(window.global.isMacOs()&&this.unity&&typeof this.unity.sendMessage=="function")$("input[type=text]").on("paste",function(){var self=this,selStart=this.selectionStart,selEnd=this.selectionEnd,origLength=this.value.length;setTimeout(function(){var newVal=self.value,halfPasted,fixedVal;if(newVal.length!==0){var pastedLength=newVal.length-(origLength-(selEnd-selStart)),pastedEnd=selStart+pastedLength,pasted=newVal.slice(selStart,pastedEnd);pasted.length!==0&&(halfPasted=pasted.substring(0,pasted.length/2),fixedVal="",selStart>0&&(fixedVal+=newVal.substring(0,selStart)),fixedVal+=halfPasted,pastedEnd<newVal.length&&(fixedVal+=newVal.substring(pastedEnd)),self.value=fixedVal)}},10)})};App.prototype.initGetPremium=function(){$(".js-get-premium").click(function(){ko.postbox.publish($.tabletopia.postbox.subscriptions.show,{buySuccessUrl:window.location.origin+window.location.pathname})})};App.prototype.initNotificationForDemoUser=function(){window.user.isDemoUser===1&&$("#notification-container").show()};App.prototype.initRating=function(unity,ga){var gameDurationSeconds,seconds,ratingManager;window.user.isInSteamBrowser===1&&(gameDurationSeconds=getCookieValue("tt-gds"),gameDurationSeconds&&(seconds=parseInt(gameDurationSeconds),seconds>=1800&&seconds<=10800&&(ratingManager=new RatingManager(ga,unity))))};App.prototype.reloginSteamUser=function(){var self=this;typeof self.unity!="undefined"&&typeof self.unity.sendMessage=="function"&&window.global.currentUserId===0&&self.unity.sendMessage("Relogin",{})};App.prototype.initUserData=function(callback){$.ajax({url:"/api/security/currentuser",cache:!1,dataType:"JSON",success:function(data){var $premiumBtnArea,$roomsBtn,$roomsCount,$userLink,$mainAvatar,$img;if(data.isAuthenticated&&data.userId>0?(window.global.currentUserId=data.userId,window.user.id=data.userId,window.user.isAuthenticated=1,window.user.isAdmin=data.isAdmin,window.user.isPremium=data.isPremium,window.user.email=data.email,window.user.shortUrl=data.shortUrl,window.user.trialAllowed(data.trialAllowed)):(window.global.currentUserId=0,window.user.id=0,window.user.isAuthenticated=0,window.user.isAdmin=!1,window.user.isPremium=!1,window.user.email="",window.user.shortUrl=""),window.user.isDemoUser=data.isDemoUser,window.user.isInSteamBrowser=data.isInSteamBrowser?1:0,window.user.hasAnySubscriptions=data.hasAnySubscriptions?1:0,data.isPremium||data.isDemoUser||($premiumBtnArea=$(".js-get-premium"),$premiumBtnArea.fadeTo(700,.5,function(){$premiumBtnArea.removeClass("hidden");$premiumBtnArea.fadeTo(300,1,function(){})})),data.gameSessions>0&&$("#playing-now-room-btn").length!==0&&($roomsBtn=$(".playing-now-rooms-show-hidden-js"),$roomsCount=$(".playing-now-rooms-count-dynamic-js"),$roomsBtn.fadeTo(700,.5,function(){$roomsBtn.removeClass("disabled");$roomsCount.html(data.gameSessions);$roomsBtn.fadeTo(300,1)})),window.user.hasAnySubscriptions===0&&window.user.isAuthenticated&&!window.user.isDemoUser){if(!ko.postbox)return;ko.postbox.publish($.tabletopia.postbox.subscriptions.show,{canClose:!1})}window.user.isInSteamBrowser===1?($userLink=$("#user-name-menu-item a"),$userLink.length>0&&$userLink.fadeTo(700,.3,function(){data.isPremium&&$userLink.addClass("user-premium");$userLink.text(data.displayName);$userLink.fadeTo(300,1,function(){})})):($mainAvatar=$("#popup-profile"),$mainAvatar.length>0&&($img=$("img",$mainAvatar),$img.attr("alt",data.displayName),$img.fadeTo(700,.1,function(){data.avatarUri?($img.attr("src",data.avatarUri+"?width=40&height=40&scale=both&mode=crop"),window.user.avatarUrl=data.avatarUri):$img.attr("src",window.urls.cdnUrl+window.urls.defaultUserAvatar+"?width=40&height=40&scale=both&mode=crop");$img.on("load",function(){$img.fadeTo(300,1)})})));callback&&callback()}})};App.prototype.showAskUserEmail=function(successCallback,closeCallback,errorCallback){var self=this,$dlg,$form,$email,url,userId;if((!localStorage["ask-user-email"]||!(new Date<new Date(localStorage["ask-user-email"])))&&($dlg=$("#ask-user-email-dlg"),$dlg.lenght!==0)){if($dlg.attr("data-is-initialized")!=="1"){$dlg.attr("data-is-initialized","1");$dlg.find(".js-close-btn").click(function(){typeof closeCallback=="function"&&closeCallback()});$dlg.on("hide.bs.modal",function(){var date=new Date;date.setDate(date.getDate()+3);localStorage["ask-user-email"]=date});$form=$("#ask-user-email-form",$dlg);$email=$("#Email-Add-Email",$form);$email.keyup(function(){self.destroyErrorTooltip($email)});url=$form.prop("action");userId=$("#Email-Add-UserId",$form).val();$form.submit(function(e){e.preventDefault();var email=$("#Email-Add-Email",$form).val(),subscribeOnNews=$("#SubscribeOnNews",$form).is(":checked");if(!self.isEmail(email)){self.destroyErrorTooltip($email);self.showErrorTooltip($email,"Enter correct email.");return}$.ajax({url:url,data:{userId:userId,email:email,subscribeOnNews:subscribeOnNews},type:"POST",cache:!1,success:function(data){self.destroyErrorTooltip($email);data.success?($dlg.modal("hide"),typeof successCallback=="function"&&successCallback(email)):data.emailError&&(data.emailDublicate?self.showErrorTooltip($email,"This email is using by another user."):self.showErrorTooltip($email,"Enter correct email."),$email.tooltip("show"),typeof errorCallback=="function"&&errorCallback())},error:function(){$dlg.modal("hide");typeof errorCallback=="function"?errorCallback():$("#error-dlg").modal()}})})}$dlg.modal()}};App.prototype.showErrorTooltip=function($element,text){setTimeout(function(){$element.tooltip({"class":"tooltip_error",placement:"right",trigger:"manual",title:text}).tooltip("show")},500)};App.prototype.destroyErrorTooltip=function($element){$element.tooltip("destroy")};App.prototype.isEmail=function(email){return/^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email)};App.prototype.openUrl=function(e,unity,url,isSteamBrowser){if(e.preventDefault(),isSteamBrowser===1)url&&typeof unity!="undefined"&&unity.sendMessage("OpenUrl",{openUrl:url});else{const newTab=window.open(url,"_blank","noopener,noreferrer");newTab.opener=null}};App.prototype.initCommentBlock=function(){window.game.displayComments&&$.ajax({url:"/playground/home/commentblock",type:"GET",cache:!1,async:!0,success:function(data){$("#comment-block-container").html(data)}})};App.prototype.initInsertTextToActiveInput=function(){this.unity&&typeof this.unity.subscribe=="function"&&window.global.isMacOs()&&(window.InsertTextToActiveInput=function(funcName,json){$(document.activeElement).val(json.value)})};App.prototype.initAdRiver=function(){};App.prototype.initReposrtIssue=function(){var $form=$("#reposrt-an-issue-form"),url;$(".js-example-basic-single",$form).select2();$("#report-an-issue").click(function(){$("#reposrt-an-issue").modal()});$form.validate({ignore:[],rules:{Summary:{required:!0},Description:{required:!0},Name:{required:!0},Email:{required:!0,email:!0},FeedbackType:{required:!0}},tooltip_options:{Summary:{trigger:"focus",placement:"top","class":"tooltip_error"},Description:{trigger:"focus",placement:"top","class":"tooltip_error"},Name:{trigger:"focus",placement:"top","class":"tooltip_error"},Email:{trigger:"focus",placement:"top","class":"tooltip_error"},FeedbackType:{trigger:"focus",placement:"top","class":"tooltip_error"}}});url=$form.attr("action");$("#reposrt-an-issue-submit").click(function(){$form.valid()&&$.ajax({url:url,type:"POST",dataType:"json",data:{Summary:$("#Summary",$form).val(),Description:$("#Description",$form).val(),Name:$("#Name",$form).val(),Email:$("#feedback-email",$form).val(),FeedbackType:$("#FeedbackType",$form).val()},success:function(){$("#reposrt-an-issue-form-container").addClass("hidden");$("#reposrt-an-issue-result-container").removeClass("hidden");setTimeout(function(){$("#reposrt-an-issue").modal("hide");$("body").click();setTimeout(function(){$("#reposrt-an-issue-form-container").removeClass("hidden");$("#reposrt-an-issue-result-container").addClass("hidden");$("#Summary,#Description,#Name,#feedback-email",$form).val("")},1e3)},3e3)},error:function(){}})})};ActiveRooms.prototype.add=function($container,roomsCountChangedCallback){var self=this;roomsCountChangedCallback&&self.roomsCountChangedCallbacks.push(roomsCountChangedCallback);$container.find(".continue-button").click(function(e){e.stopPropagation()});$(".carousel__item",$container).not("._empty").not(".hidden").each(function(i,el){self.rooms.push(el)});$(".carousel__item",$container).click(function(){var link=$(this).attr("data-room-url");link&&(window.location.href=link)});$("._abandon-game",$container).click(function(e){e.stopPropagation();var $this=$(this),isMyRoom=parseInt($this.attr("data-is-my-room")),$modalTitle=$("#leave-room-model-title");if(isMyRoom===1){$modalTitle.text(window.SR.areYouSureYouWantToFinishGameAndDeleteRoom);$("#confirm-abandon-room").modal("show").off("click",".ok-btn").one("click",".ok-btn",function(){self.closeRoom($this.attr("data-room-id"),window.urls.closeRoom,$this)})}else{$modalTitle.text(window.SR.areYouSureYouWantToLeaveRoom);$("#confirm-abandon-room").modal("show").off("click",".ok-btn").one("click",".ok-btn",function(){self.closeRoom($this.attr("data-room-id"),window.urls.leaveRoom,$this,window.global.currentUserId)})}})};ActiveRooms.prototype.closeRoom=function(id,url,$closeBtn,userId){var self=this,roomsForCloseArr=self.rooms.filter(function(elem){return $(elem).attr("data-room-id")===id}),roomShortUrl=$closeBtn.attr("data-room-url");$.ajax({type:"POST",url:url,data:{roomShortUrl:roomShortUrl,userId:userId},cache:!1,success:function(){var roomsCount,i;for($(roomsForCloseArr).each(function(i,room){var $room=$(room),$parentCarousel=$room.parents(".carousel"),itemIndex=$parentCarousel.find(".carousel__item").index($room);$parentCarousel.slick("slickRemove",itemIndex,!1);$parentCarousel.slick("setPosition")}),self.rooms=self.rooms.filter(function(elem){return $(elem).attr("data-room-id")!==id}),roomsCount=self.getUniqRoomsCount(),i=0;i<self.roomsCountChangedCallbacks.length;i++)self.roomsCountChangedCallbacks[i](roomsCount)}})};ActiveRooms.prototype.getUniqRoomsCount=function(){for(var hashTable={},i=0;i<this.rooms.length;++i)hashTable[this.rooms[i].getAttribute("data-room-id")]=1;return Object.keys(hashTable).length};FavoriteGames.prototype.registerCallbacks=function(addCallback,removeCallback){this.addCallback=addCallback;this.removeCallback=removeCallback};FavoriteGames.prototype.init=function(favorites){if(favorites&&favorites.length!==0&&window.user.id>0){const self=this;self.data==null&&self.load();self.processData(favorites);favorites.click(function(e){e.stopPropagation();var $this=$(this),publicId=$this.attr("data-public-id");publicId&&($this.hasClass("_active")?$.ajax({url:"/api/games/unfavor?format=json",data:{gamePublicId:publicId},cache:!1,async:!0,type:"POST",success:function(){self.load();var $favorite=$(".favorite[data-public-id="+publicId+"]");$favorite.removeClass("_active");$favorite.attr("data-original-title",window.SR.addFavorite);self.removeCallback&&self.removeCallback(publicId)}}):$.ajax({url:"/api/games/favor?format=json",data:{gamePublicId:publicId},cache:!1,async:!0,type:"POST",success:function(){var $favorite,$item;self.load();$favorite=$(".favorite[data-public-id="+publicId+"]");$favorite.addClass("_active");$favorite.attr("data-original-title",window.SR.removeFavorite);self.addCallback&&($item=$this.parents(".item"),self.addCallback(publicId,$item))}}))})}};UsersManager.prototype.initHubMethods=function(){var self=this,usersHubProxy=$.connection.uh;usersHubProxy.client.userJoinedPage=function(userId,pageType,userInfo){for(var i=0;i<self.userJoinedPageCallbacks.length;i++)self.userJoinedPageCallbacks[i](userId,pageType,userInfo)};usersHubProxy.client.userLeftPage=function(userId,pageType,completelyLeft){for(var i=0;i<self.userLeftPageCallbacks.length;i++)self.userLeftPageCallbacks[i](userId,pageType,completelyLeft)};usersHubProxy.client.readyCheckOpenGame=function(roomShortUrl){for(var i=0;i<self.readyCheckOpenGameCallbacks.length;i++)self.readyCheckOpenGameCallbacks[i](roomShortUrl)}};UsersManager.prototype.addUserJoinedPageCallback=function(callBack){typeof callBack=="function"&&this.userJoinedPageCallbacks.push(callBack)};UsersManager.prototype.addUserLeftPageCallback=function(callBack){typeof callBack=="function"&&this.userLeftPageCallbacks.push(callBack)};UsersManager.prototype.addReadyCheckOpenGameCallback=function(callBack){typeof callBack=="function"&&this.readyCheckOpenGameCallbacks.push(callBack)};window.global=window.global||{};window.global.breakpointXLg=1480;window.global.breakpointLg=1199;window.global.carouselSettings={slidesToShow:5,slidesToScroll:5,arrows:!1,dots:!0,variableWidth:!0,infinite:!1,draggable:!1,lazyLoad:"ondemand",responsive:[{breakpoint:window.global.breakpointXLg,settings:{slidesToShow:4,slidesToScroll:4}}]};window.global.linkifySettings={format:{url:function(value){return value.length>30?value.slice(0,30)+"...":value}}};window.global.htmlRegex=/<(br|basefont|hr|input|source|frame|param|area|meta|!--|col|link|option|base|img|wbr|!DOCTYPE).*?>|<(a|abbr|acronym|address|applet|article|aside|audio|b|bdi|bdo|big|blockquote|body|button|canvas|caption|center|cite|code|colgroup|command|datalist|dd|del|details|dfn|dialog|dir|div|dl|dt|em|embed|fieldset|figcaption|figure|font|footer|form|frameset|head|header|hgroup|h1|h2|h3|h4|h5|h6|html|i|iframe|ins|kbd|keygen|label|legend|li|map|mark|menu|meter|nav|noframes|noscript|object|ol|optgroup|output|p|pre|progress|q|rp|rt|ruby|s|samp|script|section|select|small|span|strike|strong|style|sub|summary|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|track|tt|u|ul|var|video).*?<\/\2>/i;window.global.isWinOs=function(){return window.navigator.platform&&window.navigator.platform.toLowerCase().indexOf("win")>-1};window.global.isMacOs=function(){return window.navigator.platform&&window.navigator.platform.toLowerCase().indexOf("mac")>-1};window.global.browserSupportsLocalStorage=function(){try{return"localStorage"in window&&window.localStorage!==null}catch(e){return!1}};$.ajaxSetup({beforeSend:function(jqxhr,settings){if(settings.global){var errorCallback=settings.error;settings.error=function(jqxhr,textStatus,errorThrown){typeof jqxhr=="object"&&jqxhr.status===401?window.location.href=window.urls.login.replace("redirect_url",window.location.pathname+window.location.search):typeof errorCallback=="function"&&errorCallback(jqxhr,textStatus,errorThrown)}}}}),function(){var myNav=navigator.userAgent.toLowerCase(),html=document.documentElement,ie;myNav.indexOf("msie")!==-1?(ie=myNav.indexOf("msie")!==-1?parseInt(myNav.split("msie")[1]):!1,html.className+=" ie ie"+ie):!myNav.match(/trident.*rv\:11\./)||(html.className+=" ie ie11");myNav.indexOf("safari")!==-1&&(html.className+=myNav.indexOf("chrome")===-1?" safari":" chrome");myNav.indexOf("firefox")!==-1&&(html.className+=" firefox");myNav.indexOf("windows")!==-1&&(html.className+=" windows")}();$(function(){const inSteamBrowser=window.unity&&typeof window.unity.client!="undefined"?1:0;window.global.reset=new Reset;window.global.signalrManager=new SignalrManager(inSteamBrowser);window.global.app=new App(inSteamBrowser===0?{}:window.unity.client,typeof ga!="function"?function(){}:ga,typeof gaFunc!="function"?function(){}:gaFunc);window.global.history=new History;window.global.usersManager=new UsersManager;window.global.search=new Search;window.global.activeRooms=new ActiveRooms;window.global.favoriteGames=new FavoriteGames;window.global.newsletterSubscription=new NewsletterSubscription($("#subscribe-newsletter"),$("#subscribeme"));window.global.notifications=new Notifications(typeof ga!="function"?function(){}:ga)});WelcomeManager.prototype.init=function($carousel){const self=this;if(window.user.hasAnySubscriptions!==0&&$carousel.length!==0&&localStorage["welcome-showed"]!=="1"){$carousel.slick({slidesToShow:1,slidesToScroll:1,arrows:!1,dots:!0,variableWidth:!0,draggable:!1,autoplay:!1});$carousel.slick("slickGoTo",0);const i18n={current:window.SR.WelcomeToTabletopia,previous:window.SR.Previous,next:window.SR.Next,close:window.SR.Close,xhrError:window.SR.FailedToLoad,imgError:window.SR.FailedToLoad};$(".welcome-video").colorbox($.extend({trapFocus:!1,onClosed:function(){self.$dlg.modal("hide");window.location.pathname!=="/profile"&&(window.location.href="/profile")}},i18n,{rel:"screenshots",iframe:!0,innerWidth:853,innerHeight:480}));$(".js-play-solo",self.$dlg).click(function(){self.$dlg.modal("hide");window.location.href="/playground/cardsplayground/play-solo/182821"});window.user.isInSteamBrowser===1&&$("#welcome-screen-discord",self.$dlg).click(function(e){e.preventDefault();var link=$(this).attr("href");self.unity&&typeof self.unity.sendMessage=="function"&&link&&self.unity.sendMessage("OpenUrlInSteamOverlay",{openUrl:link})});self.$dlg.modal();self.$dlg.on("hidden.bs.modal",function(){localStorage["welcome-showed"]="1"})}};RatingManager.prototype._init=function(){var self=this,$input;$(".js-no-thanks",self.$dlg).click(function(e){e.preventDefault();localStorage["rate-tt"]=self._addMonthsToCurrentDate(3)});$(".js-remind-later",self.$dlg).click(function(e){e.preventDefault()});self.$rating.barrating({_initialRating:0,allowEmpty:!0,emptyValue:"",showSelectedRating:!1,theme:"css-stars",readonly:!1,onSelect:function(value,text,event){self._onSelectRate(value,text,event)}});$input=$(".review-message",self.$dlg);$input.on("focus",function(){$input.addClass("focus")});$input.on("focusout",function(){$input.removeClass("focus")});self._showRateDlg(self.$dlg)};RatingManager.prototype._onSelectRate=function(value,text,event){var self=this,rating;typeof event!="undefined"?(self.$rating.barrating("readonly",!0),rating=parseInt(value),localStorage["rate-tt"]=self._addMonthsToCurrentDate(6),rating>3?self._effectRateDlg(function(){self._showThanksDlg()}):self._effectRateDlg(function(){self._showFeedbackDlg(rating)})):$("#error-dlg").modal()};RatingManager.prototype._showRateDlg=function(){var self=this;self.$dlg.modal("show")};RatingManager.prototype._afterRate=function(){var self=this;$(".rate-refuse-button",self.$dlg).addClass("hidden");$(".small-close-btn",self.$dlg).removeClass("hidden");$(".invitations-text",self.$dlg).text(window.SR.RateThankYouTitle)};RatingManager.prototype._showThanksDlg=function(){var self=this,$reviewBtn;self._afterRate(self.$dlg);$(".rate-tabletopia-text",self.$dlg).text(window.SR.RateThankYouText);$(".modal__buttons",self.$dlg).addClass("_call-to-action");$reviewBtn=$(".js-write-review-button",self.$dlg);$reviewBtn.removeClass("hidden");$reviewBtn.click(function(e){if(e.preventDefault(),self.unity&&typeof self.unity.sendMessage=="function"){var reviewUrl=$(this).attr("href");self.unity.sendMessage("OpenUrlInSteamOverlay",{openUrl:reviewUrl})}})};RatingManager.prototype._showFeedbackDlg=function(rating){var self=this,$feedbackBtn;self._afterRate(self.$dlg);$(".rate-tabletopia-text",self.$dlg).text(window.SR.RateTabletopiaWhatToMake);$(".review-message",self.$dlg).removeClass("hidden");$(".modal__buttons",self.$dlg).addClass("_review-button");$feedbackBtn=$(".js-send-feed-back-button",self.$dlg);$feedbackBtn.removeClass("hidden");$feedbackBtn.click(function(e){var sourceMessage,messageText;e.preventDefault();sourceMessage=$(".review-message",self.$dlg).val();sourceMessage&&(messageText="[rate] "+rating+"-stars: "+sourceMessage,$.ajax({url:"/api/support/bugs/submit",data:{userId:window.global.currentUserId,message:messageText},type:"POST",cache:!1,success:function(){},error:function(){$("#error-dlg").modal()}}))})};RatingManager.prototype._effectRateDlg=function(callback){var self=this;$("#rate-dlg-content",self.$dlg).animate({left:"+=450"},700,function(){$(this).css("left","0px").css("display","block");callback&&callback()})};RatingManager.prototype._addMonthsToCurrentDate=function(addMonthsCount){var date=new Date;return date.setMonth(date.getMonth()+addMonthsCount),date};RatingManager.prototype._isRateAvailable=function(){return window.global.browserSupportsLocalStorage()?localStorage["rate-tt"]?new Date>=new Date(localStorage["rate-tt"]):!0:!1},function(f){function p(){if(a.verbose&&f.console&&f.console.log)try{f.console.log.apply(f.console,arguments)}catch(c){}}var a=window.slimmage||{};window.slimmage=a;void 0===a.verbose&&(a.verbose=!1);void 0===a.tryWebP&&(a.tryWebP=!1);void 0===a.maxWidth&&(a.maxWidth=2048);void 0===a.widthStep&&(a.widthStep=160);void 0===a.jpegQuality&&(a.jpegQuality=90);void 0===a.jpegRetinaQuality&&(a.jpegRetinaQuality=80);void 0===a.webpTimeout&&(a.webpTimeout=0);a.changed=[];a.j=function(){if(a.tryWebP&&!a.c){a.c=!0;var c=new Image;c.onload=c.onerror=function(){a.webp=2==c.height;a.c=!1;a.a&&a.a()};c.src="data:image/webp;base64,UklGRjoAAABXRUJQVlA4IC4AAACyAgCdASoCAAIALmk0mk0iIiIiIgBoSygABc6WWgAA/veff/0PP8bA//LwYAAA"}};a.j();a.b=function(a,e,b){e=e.toLowerCase();"class"==e?a.className=b:"tabindex"==e?a.tabIndex=b:"usemap"==e?a.useMap=b:a.setAttribute(e,b)};a.setAttribute=a.b;a.f=function(a){return"none"===a||null===a||void 0===a||""===a||!1===a};a.getCssValue=function(c,e){var b="undefined"!=typeof getComputedStyle&&window.getComputedStyle(c,null).getPropertyValue(e);return a.f(b)?(c.currentStyle&&(b=c.currentStyle[e.replace(/([a-z])\-([a-z])/,function(a,c,b){return c+b.toUpperCase()})]||c.currentStyle[e]),a.f(b)?null:b):b};a.getCssPixels=function(c,e){var b=a.getCssValue(c,e),d;return null===b||"0"===b||0===b?b:"px"==b.slice(-2)?parseFloat(b.slice(0,-2)):(d=document.createElement("div"),d.style.overflow=d.style.visibility="hidden",d.style.cssFloat="none",c.parentNode.appendChild(d),d.style.width=b,b=d.offsetWidth,c.parentNode.removeChild(d),b)};a.g=function(a){for(var e=[],b=a.length>>>0;b--;)e[b]=a[b];return e};a.mutateUrl=function(a,e,b,d){a=/^([^?#]*)?(\?([^#]*))?(#.*)?/.exec(a);var l=a[3]||"",f=/(^&*|&+)([^&=]*)=?([^&]*)/g;return l.replace(f,e),e="?"+l.replace(f,b).replace(/(?:^\?*&*)|(?:[?&]+$)/g,"").replace(/&&+/g,"&"),(a[1]||"")+d(e)+(a[4]||"")};a.getImageInfo=function(c,e,b,d){var f={webp:a.webp,width:c,dpr:window.devicePixelRatio||1,src:e,element:d},m,n,g,h;return(d=a.webp?65:a.jpegRetinaQuality,m=a.webp?78:a.jpegQuality,f.quality=1.49<f.dpr?d:m,f.requestedWidth=Math.min(a.maxWidth,Math.round(Math.ceil(c*f.dpr/a.widthStep)*a.widthStep)),(c=a.adjustImageParameters)&&"function"==typeof c&&c(f),n=f.requestedWidth,n>b)?(g={},h={},{src:a.mutateUrl(e,function(a,b,c,d){g[c.toLowerCase()]=d},function(a,b,c){if(void 0===h.zoom&&(h.zoom=parseFloat(g.zoom||1),isNaN(h.zoom)&&(h.zoom=1),h.i=(n/h.zoom).toFixed()),void 0===h.h){var d=parseFloat(g.width||g.i||g.n),e=parseFloat(g.height||g.e||g.m);!isNaN(d)&&!isNaN(e)&&0<d&&0<e?(h.h=d/e,h.e=(n/h.zoom/d*e).toFixed()):h.h="noclue"}return c.match(/^format$/i)&&f.webp?b+"format=webp":c.match(/^quality/i)?b+"quality="+f.quality:c.match(/^(w|width|maxwidth)$/i)?b+c+"="+h.i:c.match(/^(h|height|maxheight)$/i)?b+c+"="+h.e:a},function(a){return a}),"data-pixel-width":n}):null};a.adjustImageSrc=function(c,e){var b=a.getCssPixels(c,"max-width"),d=a.getImageInfo(b,e,c.getAttribute("data-pixel-width")|0,c);d?(c.src=d.src,a.b(c,"data-pixel-width",d["data-pixel-width"]),a.enforceCss&&(b<d["data-pixel-width"]?(c.style.width=a.getCssValue(c,"max-width"),a.b(c,"data-width-enforced",!0)):c.style.width="auto"),a.changed.push(c),p("Slimming: updating "+d.src)):a.enforceCss&&c.getAttribute("data-width-enforced")&&(d=parseFloat(c.getAttribute("data-pixel-width")),!isNaN(d)&&b>=d&&(c.style.width="auto",c.removeAttribute("data-width-enforced")))};a.a=function(c){var e,b,d,l,m,n,g,h,k;if(0<a.d&&f.clearTimeout(a.d),a.d=0,a.c&&0<a.webpTimeout&&!a.l&&(a.l=!0,c=a.webpTimeout),c&&0<c)a.d=f.setTimeout(a.a,c);else{for(c=(new Date).getTime(),n=0,m=a.g(f.document.getElementsByTagName("noscript")),e=0,b=m.length;e<b;e++)if(g=m[e],null!==g.getAttribute("data-slimmage")){if(d=f.document.createElement("div"),(l=g.textContent||g.innerHTML)&&0!==l.replace(/[\s\t\r\n]+/,"").length)d.innerHTML=l.replace(/\s+src\s*=\s*(['"])/i," data-src=$1").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");else{for(l=new Image,h=0;h<g.attributes.length;h++)k=g.attributes[h],k&&k.specified&&0===k.name.indexOf("data-img-")&&a.b(l,k.name.slice(9-k.name.length),k.value);d.appendChild(l)}for(h=d.getElementsByTagName("img"),d=0,l=h.length;d<l;d++)k=h[d],null!==k.src&&0<k.src.length&&(a.b(k,"data-src",k.src),k.src=""),a.b(k,"data-slimmage",!0),g.parentNode.insertBefore(k,g),n++;g.parentNode.removeChild(g)}for("function"==typeof a.beforeAdjustSrc&&a.beforeAdjustSrc(),e=0,g=a.g(f.document.getElementsByTagName("img")),b=0,m=g.length;b<m;b++)null!==g[b].getAttribute("data-slimmage")&&(d=g[b].getAttribute("data-src")||g[b].src,a.adjustImageSrc(g[b],d),e++);b=a.changed.slice();a.changed.length=0;(0<b.length||!a.k)&&"function"==typeof a.readyCallback&&(a.readyCallback(b),a.k=!0);p("Slimmage: restored "+n+" images from noscript tags, checked "+e+" images, changed "+b.length+". "+((new Date).getTime()-c)+"ms")}};a.checkResponsiveImages=a.a;f.addEventListener?(f.addEventListener("resize",function(){a.a(500)},!1),f.addEventListener("DOMContentLoaded",function(){a.a();f.removeEventListener("load",a.a,!1)},!1),f.addEventListener("load",a.a,!1)):f.attachEvent&&(f.attachEvent("onload",a.a),f.attachEvent("onresize",function(){a.a(500)}))}(this)