catlab-remote-client 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var io,s,t,e,A,i,h,a;define("CatLab/Webremote/Tools/Net",[],function(){"use strict";return{loadJSON:function(e,t,i){var n=new XMLHttpRequest;n.onreadystatechange=function(){n.readyState===XMLHttpRequest.DONE&&200===n.status&&t&&t(JSON.parse(n.responseText))},n.onerror=function(e){e&&i(n,e)},n.open("GET",e,!0),n.send()}}}),define("CatLab/Webremote/Tools/Deferred",[],function(){function l(e){return"[object Array]"===Object.prototype.toString.call(e)}function c(e,t){if(l(e))for(var i=0;i<e.length;i++)t(e[i]);else t(e)}function u(e){var n="pending",s=[],o=[],r=[],a=null,i={done:function(){for(var e=0;e<arguments.length;e++)if(arguments[e])if(l(arguments[e]))for(var t=arguments[e],i=0;i<t.length;i++)"resolved"===n&&t[i].apply(this,a),s.push(t[i]);else"resolved"===n&&arguments[e].apply(this,a),s.push(arguments[e]);return this},fail:function(){for(var e=0;e<arguments.length;e++)if(arguments[e])if(l(arguments[e]))for(var t=arguments[e],i=0;i<t.length;i++)"rejected"===n&&t[i].apply(this,a),o.push(t[i]);else"rejected"===n&&arguments[e].apply(this,a),o.push(arguments[e]);return this},always:function(){return this.done.apply(this,arguments).fail.apply(this,arguments)},progress:function(){for(var e=0;e<arguments.length;e++)if(arguments[e])if(l(arguments[e]))for(var t=arguments[e],i=0;i<t.length;i++)"pending"===n&&r.push(t[i]);else"pending"===n&&r.push(arguments[e]);return this},then:function(){1<arguments.length&&arguments[1]&&this.fail(arguments[1]),0<arguments.length&&arguments[0]&&this.done(arguments[0]),2<arguments.length&&arguments[2]&&this.progress(arguments[2])},promise:function(e){if(null==e)return i;for(var t in i)e[t]=i[t];return e},state:function(){return n},debug:function(){console.log("[debug]",s,o,n)},isRejected:function(){return"rejected"===n},isResolved:function(){return"resolved"===n},pipe:function(e,t,i){return u(function(i){c(e,function(t){"function"==typeof t?h.done(function(){var e=t.apply(this,arguments);e&&"function"==typeof e?e.promise().then(i.resolve,i.reject,i.notify):i.resolve(e)}):h.done(i.resolve)}),c(t,function(t){"function"==typeof t?h.fail(function(){var e=t.apply(this,arguments);e&&"function"==typeof e?e.promise().then(i.resolve,i.reject,i.notify):i.reject(e)}):h.fail(i.reject)})}).promise()}},h={resolveWith:function(e){if("pending"===n){n="resolved";for(var t=a=1<arguments.length?arguments[1]:[],i=0;i<s.length;i++)s[i].apply(e,t)}return this},rejectWith:function(e){if("pending"===n){n="rejected";for(var t=a=1<arguments.length?arguments[1]:[],i=0;i<o.length;i++)o[i].apply(e,t)}return this},notifyWith:function(e){if("pending"===n)for(var t=a=1<arguments.length?arguments[1]:[],i=0;i<r.length;i++)r[i].apply(e,t);return this},resolve:function(){return this.resolveWith(this,arguments)},reject:function(){return this.rejectWith(this,arguments)},notify:function(){return this.notifyWith(this,arguments)}},t=i.promise(h);return e&&e.apply(t,[t]),t}return u.when=function(){var e;if(arguments.length<2)return((e=arguments.length?arguments[0]:void 0)&&"function"==typeof e.isResolved&&"function"==typeof e.isRejected?e:u().resolve(e)).promise();for(var i=arguments,n=u(),s=i.length,o=0,r=new Array(s),t=0;t<i.length;t++)!function(e){var t;i[e].done?i[e].done(function(){r[e]=arguments.length<2?arguments[0]:arguments,++o==s&&n.resolve.apply(n,r)}).fail(function(){n.reject(arguments)}):(t=i[e],i[e]=new Deferred,i[e].done(function(){r[e]=arguments.length<2?arguments[0]:arguments,++o==s&&n.resolve.apply(n,r)}).fail(function(){n.reject(arguments)}).resolve(t))}(t);return n.promise()},u}),define("CatLab/Webremote/Collections/ServerList",["CatLab/Webremote/Tools/Deferred"],function(s){"use strict";function e(e,t){this.defaultId=e.default,this.servers=e.servers,this.connectUrl=e.connectUrl,this.selectedServerId=null,this.preferredServer=t,this.assetsUrl=e.assetsUrl}var t=e.prototype;return t.getFromToken=function(e){if(e.length<8)return{host:this.getDefault().host,token:e};var t=e.substr(0,2);if(t){t=this.getFromId(t);if(t)return{host:t.host,token:e.substr(2)}}throw new Error("Code does not correspondent to any servers.")},t.getSelectedServer=function(){var t=new s;return this.selectedServerId?this.getFromId(this.selectedServerId)?t.resolve(this.getFromId(this.selectedServerId).host):t.reject("Selected remote server not found in server list. Please make sure you are connected to the right network."):this.selectBestServer().then(function(e){this.selectedServerId||(this.selectServer(e.id),t.resolve(e.host))}.bind(this)),t.promise()},t.selectBestServer=function(){var i=new s;if(this.preferredServer)for(var e=0;e<this.servers.length;e++)if(this.servers[e].id==this.preferredServer)return i.resolve(this.servers[e]),i.promise();var n=!1;return this.servers.forEach(function(t){t.discoverable&&this.measureRequestSpeed("https://"+t.host+"/info").then(function(e){console.log("[ServerList] "+t.host+" took "+e+"ms"),n||(n=!0,i.resolve(t))}.bind(this))}.bind(this)),i.promise()},t.selectServer=function(e){this.selectedServerId=e},t.measureRequestSpeed=function(e){var t=new Date,i=new s,n=new XMLHttpRequest;return n.onreadystatechange=function(){var e;4==this.readyState&&200==this.status&&(e=(new Date).getTime()-t.getTime(),i.resolve(e))},n.open("GET",e),n.send(),i.promise()},t.getConnectURL=function(){if(this.selectedServerId){var e=this.getFromId(this.selectedServerId);if(e.connectUrl)return e.connectUrl}return this.connectUrl},t.getAssetURL=function(){var e;return this.assetsUrl||((e=this.getConnectURL())?("http"!==e.substring(0,4)&&(e="https://"+e),this.assetsUrl=e+"/assets/",this.assetsUrl):void 0)},t.getConnectToken=function(e){return this.getFromId(this.selectedServerId).connectUrl?e:this.selectedServerId+e},t.getFromId=function(e){for(var t=0;t<this.servers.length;t++)if(this.servers[t].id==e)return this.servers[t];return null},t.getDefault=function(){return this.getFromId(this.defaultId)},t.serialize=function(){return{server:this.selectedServerId}},t.unserialize=function(e){this.selectServer(e.server)},e}),define("CatLab/Webremote/Config",["CatLab/Webremote/Tools/Net","CatLab/Webremote/Collections/ServerList"],function(i,e){"use strict";var t="http";return{_options:{host:"www.catlab.tv",serverlist:null,preferredServer:null,protocol:t="undefined"!=typeof window&&void 0!==window.location&&void 0!==window.location.protocol?window.location.protocol.substr(0,window.location.protocol.length-1):t,debug:!1,proxy:"",imageproxy:"",smileys:!0,assetsUrl:null,vendorPath:"/vendor/",audioSync:!1,allowAuthentication:!0,canFullscreen:!0,oauth:{redirectUrl:null}},_initialized:!1,audioSyncConfig:{alphabet:"qwertyuiop",length:5,freqMin:524,freqMax:1593,freqError:25,debug:!1},set:function(e){void 0!==e&&(e.host,this._options.host=e.host,void 0!==e.protocol&&(this._options.protocol=e.protocol),void 0!==e.debug&&(this._options.debug=e.debug),void 0!==e.imageproxy&&(this._options.imageproxy=e.imageproxy),void 0!==e.proxy&&(this._options.proxy=e.proxy),void 0!==e.smileys&&(this._options.smileys=e.smileys),void 0!==e.assetsUrl&&(this._options.assetsUrl=e.assetsUrl),void 0!==e.vendorPath&&(this._options.vendorPath=e.vendorPath),void 0!==e.audioSync&&(this._options.audioSync=e.audioSync),void 0!==e.serverlist&&(this._options.serverlist=e.serverlist),void 0!==e.preferredServer&&(this._options.preferredServer=e.preferredServer),void 0!==e.allowAuthentication&&(this._options.allowAuthentication=e.allowAuthentication),void 0!==e.audioSyncConfig&&(this.audioSyncConfig=e.audioSyncConfig),void 0!==e.canFullscreen&&(this._options.canFullscreen=e.canFullscreen),void 0!==e.oauth)&&void 0!==e.oauth.redirectUrl&&(this._options.oauth.redirectUrl=e.oauth.redirectUrl)},getAll:function(){return this._options},initialize:function(t){var e;this._initialized?t():null===this._options.serverlist||"http"!==this._options.serverlist.substring(0,4)?(this._initialized=!0,t()):"json"===this._options.serverlist.substring(this._options.serverlist.length-4)?i.loadJSON(this._options.serverlist,function(e){this._initialized=!0,this._options.serverlist=e,t()}.bind(this),function(e,t){alert("Failed to connect to "+this._options.serverlist+". Game cannot start."),console.log(t)}.bind(this)):((e=document.createElement("script")).onload=function(){this._initialized=!0,this._options.serverlist=getCatLabRemoteServers(),t()}.bind(this),e.onerror=function(){alert("Failed to connect to "+this._options.serverlist+". Game cannot start.")}.bind(this),e.src=this._options.serverlist,document.head.appendChild(e))},getProtocol:function(e){var t=this._options.protocol;switch(t=void 0!==e&&e&&""===t?"http":t){case"http":case"https":break;default:t="https"}return t},getSocketURL:function(e){return this._options.host?((e=this.getProtocol(e))&&(e+=":"),e+"//"+this._options.host):"undefined"!=typeof window&&void 0!==window.location?window.location.protocol+"//"+window.location.hostname:""},getAssetsURL:function(e){var t;return this._options.assetsUrl||((t=this.getServerList())?t.getAssetURL():this.getSocketURL(e)+"/assets/")},debug:function(){return this._options.debug},getProxiedImage:function(e){return this._options.imageproxy?this._options.imageproxy+encodeURIComponent(e):e},getProxy:function(){return this._options.proxy},useSmileys:function(){return this._options.smileys},useAudioSync:function(){return this._options.audioSync},all:function(){return this._options},getAudioSyncConfig:function(){return this.audioSyncConfig},getProviderConfig:function(){var e={smileys:this.useSmileys(),audioSync:this.useAudioSync()};return this.useAudioSync()&&(e.audioSyncConfig=this.audioSyncConfig),e},getServerList:function(){return this._options.serverlist?(this.serverCollection||(this.serverCollection=new e(this._options.serverlist,this._options.preferredServer)),this.serverCollection):null},getVendorPath:function(){return this._options.vendorPath},supportsAuthentication:function(){return this._options.allowAuthentication},canFullscreen:function(){return this._options.canFullscreen}}}),define("CatLab/Webremote/Polyfills",[],function(){"use strict";"function"!=typeof Object.assign&&(Object.assign=function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(e),n=1;n<arguments.length;n++){var s=arguments[n];if(null!=s)for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(i[o]=s[o])}return i})}),define("CatLab/Webremote/Tools/Tracker",[],function(){var s=function(e,t,i,n){},t=function(e){s("Page",e,"-",0)};return{setTracker:function(e){s=e},setPageMethod:function(e){t=e},track:function(e,t,i,n){s(e,t,i,n)},page:function(e){t(e)}}}),define("CatLab/Webremote/Tools/Tools",[],function(){var s,o;return{popup:function(e,t){var i=this,n=(t=t||!1,document.createElement("iframe"));n.style.margin=0,n.style.padding=0,n.style.border=0,n.style.position="absolute",n.style.width="100%",n.style.height="100%",n.style.left=0,n.style.top=0,n.src=e,(o=document.createElement("div")).style.margin=0,o.style.padding=0,o.style.border=0,o.style.position="absolute",o.style.width="100%",o.style.height="100%",o.style.left=0,o.style.top=0,o.style.zIndex=9999,o.onclick=function(){i.closePopup()},(s=document.createElement("div")).appendChild(n),s.style.margin=0,s.style.padding=0,s.style.border=0,s.style.position="absolute",s.style.zIndex=1e4,s.style.overflow="auto",s.style.background="white",s.style.boxSizing="border-box",t?(s.style.border="0 none black",s.style.left="0",s.style.top="0",s.style.width="100%",s.style.height="100%"):(s.style.border="5px solid black",s.style.left="10%",s.style.top="10%",s.style.width="80%",s.style.height="80%"),document.body.appendChild(o),document.body.appendChild(s)},oauth2PopupMethod:function(e,t){return window.open(e,"oauth:catlab-remote")},oauth2Popup:function(e,t){return this.oauth2PopupMethod(e,t)},closePopup:function(){s&&s.parentNode.removeChild(s),o&&o.parentNode.removeChild(o)},setOauth2Popup:function(e){return this.oauth2PopupMethod=e,this},sanitize:function(e){var t;return null==e?null:(t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"},String(e).replace(/[&<>"']/g,function(e){return t[e]}))},nl2br:function(e,t){return null==e?"":(e+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+(t||void 0===t?"<br />":"<br>")+"$2")},shuffle:function(e){for(var t,i,n=e.length-1;0<n;n--)t=Math.floor(Math.random()*(n+1)),i=e[n],e[n]=e[t],e[t]=i},getUuid:function(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)},findIndex:function(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return i;return-1},getConnectTokenForDisplay:function(e){return null===e?null:e.length%4==0?this.injectFillerInString(e,4," "):(e.length,this.injectFillerInString(e,3," "))},injectFillerInString:function(e,t,i){return e.match(new RegExp(".{1,"+t+"}","g")).join(i)}}}),define("CatLab/Webremote/Tools/Cookies",[],function(){var t={setCookie:function(e,t,i){return this.setItem(e,t,i)},getCookie:function(e){return this.getItem(e)},eraseCookie:function(e){return this.removeItem(e)},getItem:function(e){if("undefined"!=typeof document)return e&&this.hasOwnProperty(e)?unescape(document.cookie.replace(new RegExp("(?:^|.*;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"),"$1")):null},key:function(e){if("undefined"!=typeof document)return unescape(document.cookie.replace(/\s*\=(?:.(?!;))*$/,"").split(/\s*\=(?:[^;](?!;))*[^;]?;\s*/)[e])},setItem:function(e,t,i){var n,s;e&&"undefined"!=typeof document&&(n="",i&&((s=new Date).setTime(s.getTime()+Math.round(24*i*60*60*1e3)),n="; expires="+s.toUTCString()),document.cookie=escape(e)+"="+escape(t)+"; expires="+n+"; path=/; SameSite=Strict;",this.updateLength())},length:0,removeItem:function(e){e&&this.hasOwnProperty(e)&&"undefined"!=typeof document&&(document.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; SameSite=Strict;",this.length--)},hasOwnProperty:function(e){if("undefined"!=typeof document)return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie)},updateLength:function(){var e;"undefined"!=typeof document&&document.cookie&&(e=document.cookie.match(/\=/g),t.length=e?e.length:0)}};return t.updateLength(),t}),define("CatLab/Webremote/Tools/Smileys",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Tools"],function(i,n){function e(e){this.provider=e,this.smileyKeys=["1f98d","1f61c","1f3b7","1f32e","1f621","1f61b","1f98f","1f34c","1f596","1f34d","2660","1f61a","2602","2665","1f0cf","1f427","1f918","1f98b","1f9df","1f344","1f983","1f338","2618","1f36a","1f383","270c","1f913","1f40d","1f910","1f57a","1f641","1f36c","1f579","1f333","1f40b","1f617","1f42b","1f60d","1f42c","1f339","1f414","1f42d","1f349","1f92e","1f437","1f367","1f62c","1f428","1f994","1f911","1f369","1f9d0","1f378","1f9dd-2640","1f34e","2666","1f47d","1f60a","1f60f","1f43b","1f47b","1f425","1f919","1f346","1f4a8","1f43f","1f37a","1f40c","1f334","1f4a3","1f42e","1f379","1f42f","1f417","1f9c0","1f601","1f41a","1f61d","1f997","26c4","1f34b","1f430","1f47a","1f37c","1f3b1","1f95d","1f433","1f41b","1f37f","1f36d","1f60e","1f354","1f63b","1f680","1f996","1f924","1f341","1f43a","1f922","1f436","1f43c","1f332","1f31a","1f335","1f336","2623","1f31e","1f63d","1f421","1f438","1f63a","1f32d","1f986","1f388","1f41e","1f98c","1f91e","1f64a","1f638","1f3b5","1f43d","1f363","1f373","1f435","1f628","1f635","1f377","1f47e","1f984","1f3a9","1f439","1f925","1f929","1f951","1f4a9","1f921","1f92a","1f96a","1f41f","1f419","1f420","2663","1f40a","1f989","1f91f","1f63c","1f3f3-1f308","1f98a","1f431","1f920","1f41d","1f608","1f612","1f987","1f3ba","1f355","270b","1f98e","1f41c","1f917"],this.taken={},this.takenAmount=0,this.images={},this.playerKnowsAboutNonUniqueSmileys={},this.randomSmileys=this.smileyKeys.slice(0),n.shuffle(this.randomSmileys)}var t=e.prototype;return t.shouldHaveUniqueSmileys=function(){return this.takenAmount<this.smileyKeys.length/3},t.setTakenSmileys=function(e){this.taken=e},t.getTakenSmileys=function(e){if(!this.shouldHaveUniqueSmileys())return{};e=this.identifierToText(e);var t,i={};for(t in this.taken)this.taken.hasOwnProperty(t)&&this.taken[t]!==e&&(i[t]=this.taken[t]);return i},t.getRandom=function(e){for(var t=null;null===t&&this.randomSmileys;)if(t=this.randomSmileys.shift(),this.reserve(t,e)||(t=null),0===this.randomSmileys.length)return this.randomSmileys=this.smileyKeys.slice(0),n.shuffle(this.randomSmileys),this.randomSmileys.shift();return t},t.reserve=function(e,t){return this.isExternalSmiley(e)?(this.unreserve(t),!0):(t=this.identifierToText(t),void 0!==this.taken[e]&&this.taken[e]===t?(this.taken[e]=t,!0):!!this.isAvailable(e)&&(this.unreserve(t),this.taken[e]=t,this.takenAmount++,!0))},t.unreserve=function(e){for(var t in e=this.identifierToText(e),this.taken)this.taken.hasOwnProperty(t)&&this.taken[t]===e&&(this.taken[t]=null,delete this.taken[t],this.takenAmount--)},t.isAvailable=function(e){return!this.shouldHaveUniqueSmileys()||!!this.isExternalSmiley(e)||void 0===this.taken[e]||null===this.taken[e]},t.identifierToText=function(e){return JSON.stringify(e)},t.isExternalSmiley=function(e){return"http"===e.substr(0,4)},t.getUrl=function(e){return null===e?null:this.isExternalSmiley(e)?e:i.getAssetsURL()+"smileys/"+e+".png"},t.getHtml=function(e){return null===e?null:'<span class="smiley" style="width: 64px; height: 64px; display: inline-block; background-image: url(\''+this.getUrl(e)+"');\"></span>"},t.getElement=function(e){var t;return null===e?null:((t=document.createElement("div")).innerHTML=this.getHtml(e),t.firstChild)},t.getImage=function(e){var t;return null===e?null:(void 0===this.images[e]&&((t=new Image).crossOrigin="anonymous",t.src=i.getProxiedImage(this.getUrl(e)),this.images[e]=t),this.images[e])},t.refreshTakenSmileys=function(e){this.shouldHaveUniqueSmileys()?e.emit("smileys:taken",{smileys:this.getTakenSmileys(e.getIdentifier())}):this.playerKnowsAboutNonUniqueSmileys[this.getStringIdentifier(e)]},t.getStringIdentifier=function(e){return e.type+":"+e.id},e}),define("CatLab/Webremote/Tools/Preloader",["../Config","CatLab/Webremote/Tools/Deferred"],function(t,o){function i(e){this.provider=e,this.provider.on("file:preload",function(e){e&&e.url&&this.preloadClientFile(e.url)}.bind(this)),this.urlMap={}}var e=i.prototype;return e.preload=function(t){if(Array.isArray(t)){for(var e=new o,i=[],n=0;n<t.length;n++)i.push(this.preload(t[n]));return o.when.apply(o,i).then(function(){e.resolve(Array.prototype.slice.call(arguments))}),e.promise()}var s=new o;return this.urlMap[t]=t,this.provider.proxyFile(t).then(function(e){this.urlMap[t]=e.url,this.provider.emit("file:preload",{url:e.url}),s.resolve(e)}.bind(this)),s.promise()},e.sendPreloadFileCommandToPlayer=function(e){for(var t in this.urlMap)this.urlMap.hasOwnProperty(t)&&e.emit("file:preload",{url:this.urlMap[t]})},e.getPreloadedUrl=function(e){return this.urlMap[e]},e.preloadClientFile=function(e){void 0===this.urlMap[e]&&(e.toLowerCase().indexOf("http")<0&&(e=t.getProtocol()+":"+e),this.urlMap[e]=document.createElement("img"),this.urlMap[e].src=e)},e.serialize=function(){return{urlMap:this.urlMap}},i.unserialize=function(e,t){e=new i(e);return void 0!==t&&void 0!==t.urlMap&&(e.urlMap=t.urlMap),e},i}),define("CatLab/Webremote/Tools/Eventable",["CatLab/Webremote/Tools/Tools"],function(n){"use strict";function e(){}var s=0,t=e.prototype;return t.initializeEventable=function(){this._eventableEvents=[]},t.trigger=function(e){this.eventableTrigger.apply(this,arguments)},t.eventableTrigger=function(e){if("string"!=typeof e)throw new Error("eventableTrigger must be a string");if(void 0!==this._eventableEvents){var t,i=Array.prototype.slice.call(arguments);for(t in i.push(i.shift()),this._eventableEvents)this._eventableEvents.hasOwnProperty(t)&&this.eventMatches(e,t)&&this._eventableEvents[t].slice().forEach(function(e){try{e.method.apply(e.scope,i)}catch(e){console.error(e)}}.bind(this))}},t.eventMatches=function(e,t){return"*"===t||e===t},t.on=function(e,t,i){void 0===this._eventableEvents&&(this._eventableEvents={}),void 0===this._eventableEvents[e]&&(this._eventableEvents[e]=[]),s++,this._eventableEvents[e].push({id:s,method:t,scope:void 0!==i?i:this});var n=[e,s];return{id:n,name:e,method:t,unbind:function(){this.off(null,{id:n,name:e})}.bind(this)}},t.once=function(e,t,i){var n=this.on(e,function(){n.unbind(),t.apply(i,arguments)});return n},t.off=function(e,t){if(void 0!==e||void 0!==t)if(void 0===e||void 0!==t){if(e=t.name,t=t.id,void 0===this._eventableEvents[e])return null;var i=n.findIndex(this._eventableEvents[e],function(e){return e.id=t});0<=i&&(this._eventableEvents[e]=this._eventableEvents[e].splice(i,1))}else this._eventableEvents[e]=[];else this._eventableEvents=[]},t.clearEvents=function(){this.clearEventableEvents()},t.clearEventableEvents=function(){this._eventableEvents={}},e}),define("CatLab/Webremote/Models/User",["jquery","CatLab/Webremote/Config"],function(e,t){return function(e){this.accessToken=e,this.name=null,this.avatar=null,this.id=null,this.image=null,this.imageCallbacks=[],this.imageLoaded=!1,this.getAccessToken=function(){return this.accessToken},this.setId=function(e){this.id=e},this.getId=function(){return this.id},this.setName=function(e){this.name=e},this.getName=function(){return this.name},this.setAvatar=function(e){this.avatar=e,this.imageLoaded=!1,this.imageCallbacks=[],this.image=null},this.loadAvatar=function(){this.image||(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=function(){this.afterImageLoad()}.bind(this),this.image.src=t.getProxiedImage(this.avatar))},this.getAvatar=function(){return this.avatar},this.getAvatarSmiley=function(e){var t=this.getAvatar();return t?(t=t.split("?")[0],t+="?shape=circle&size=64&borderWidth=4",e&&(t+="&borderColor="+e.substr(1)),t):null},this.afterImageLoad=function(){this.imageLoaded=!0;for(var e=0;e<this.imageCallbacks.length;e++)this.imageCallbacks[e](this.image);this.imageCallbacks=[]},this.getImage=function(e){this.loadAvatar(),this.imageLoaded?e(this.image):this.imageCallbacks.push(e)}}}),define("CatLab/Webremote/Tools/Storage",["CatLab/Webremote/Tools/Cookies"],function(e){"use strict";var t={clean:function(){if(this.isSupported())for(var e=Object.keys(window.localStorage),t=0;t<e.length;t++)this.get(e)},get:function(e,t){if(void 0===t&&(t=function(){}),this.isSupported())try{var i,n=window.localStorage.getItem(e);n?void 0!==(n=JSON.parse(n)).expires?(i=Date.now(),n.expires<i?(this.delete(e),t(null)):t(n.content)):t(n):t(null)}catch(e){t(null),console.log(e)}else t(null)},add:function(t,i,n,s){var o=this;n=n||function(){},this.isSupported()?this.get(t,function(e){(e=null!=e&&""!==e?e:[]).push(i),o.set(t,e,n,s)}):n(null)},set:function(e,t,i,n){if(void 0===i&&(i=function(){}),this.isSupported()){void 0===n&&(n=31536e6);try{var s=Date.now();s+=n,window.localStorage.setItem(e,JSON.stringify({expires:s,content:t}))}catch(e){console.log(e)}i()}else i(null)},delete:function(e){this.isSupported()&&window.localStorage.removeItem(e)},remove:function(n,s){var o;this.isSupported()&&(o=this).get(n,function(e){null!=e&&""!=e||(e=[]);for(var t=JSON.stringify(s),i=0;i<e.length;i++)if(t===JSON.stringify(e[i]))return e.splice(i,1),void o.set(n,e)})},isSupported:function(){if("undefined"==typeof window)return!1;try{if(void 0===window.localStorage)return!1}catch(e){return console.log(e),!1}return!0}};try{t.clean()}catch(e){console.error(e)}return t}),define("CatLab/Webremote/Collections/AuthenticatedUsers",["CatLab/Webremote/Models/User","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Tools/Eventable"],function(i,s,e){function t(){this.initializeEventable()}var o,r,n=[],e=t.prototype=new e;return e.initialize=function(e,t){o=t,r=e;var n=this;s.get("users",function(i){null!==i&&s.get("currentuser",function(t){for(var e=0;e<i.length;e++)n.addFromAccessToken(i[e].access_token,function(e){e&&t&&e.getAccessToken()===t&&void 0!==r.setUser&&r.setUser(e)})})})},e.addFromAccessToken=function(t,i){i=i||function(){};var n=this;o.profile(t,function(e){e?(e=n.add(t,e.user),i(e)):s.remove("users",{access_token:t})})},e.add=function(e,t){e=new i(e);return e.setId(t.id),e.setName(t.username),e.setAvatar(t.avatar),function(e){for(var t=0;t<n.length;t++)if(n[t].getId()==e.getId())return n[t]=e;n.push(e)}(e),this.trigger("update"),e},e.remove=function(e){for(var t=0;t<n.length;t++)if(n[t].getId()==e.getId())return void n.splice(t,1)},e.getFromId=function(e){for(var t=0;t<n.length;t++)if(n[t].getId()==e)return n[t];return null},e.getAll=function(){return n},new t}),define("CatLab/Webremote/Controllers/OAuth2",["jquery","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Config"],function($,Tools,Deferred,Eventable,Users,Storage,Config){var url,client_id,authorization,profile_url,avatar_url,redirect_url,callbacks=[],initialized=!1,afterInit=[],events=[],etPhoneHome=null;function OAuth2(){this.initializeEventable()}var p=OAuth2.prototype=new Eventable;return p.initialize=function(e){url=(e=e||{}).authorization||"https://quizted.catlab.eu/oauth2/authorize",client_id=e.client_id||"none",authorization=e.authorization||"default",profile_url=e.profile||"",avatar_url=e.profile+"/avatar",void 0!==e.redirect_uri&&(Config._options.oauth.redirectUrl=e.redirect_uri),initialized=!0;var t=this;if("undefined"!=typeof window){function i(e){t.onMessage(e)}var n;if(window.addEventListener){for(;n=events.pop();)removeEventListener("message",n);addEventListener("message",i,!1)}else{for(;n=events.pop();)detachEvent("onmessage",n);attachEvent("onmessage",i)}events.push(i)}},p.setRedirectUrl=function(e,t){this.redirectHost=e,this.redirectUrl=e+t},p.getAuthorizeURL=function(){var e="",e=(Config.all().oauth&&Config.all().oauth.redirectUrl&&(e=Config.all().oauth.redirectUrl),url+"?client_id="+encodeURIComponent(client_id)+"&authorization="+encodeURIComponent(authorization)+"&response_type=token&redirect_uri="+encodeURIComponent(e)+"&reset=1&state=login");return void 0!==this.redirectUrl?this.redirectUrl+"?url="+encodeURIComponent(e):e},p.onMessage=function(e){if("I must've called a thousand times"!==e.data){var t;if("string"==typeof e.data&&e.data.match(/^oauth::/))try{t=JSON.parse(e.data.substring(7))}catch(e){return}else if("string"==typeof e.data)try{t=JSON.parse(e.data)}catch(e){return}else t=e.data;void 0!==t.access_token&&this.addAccessToken(t.access_token)}},p.addAccessToken=function(n){var e=function(e){var t,i=Users.add(n,e.user);for(Storage.add("users",{access_token:n}),Tools.closePopup();t=callbacks.shift();)t(i);this.trigger("update")}.bind(this);this.call(profile_url,n,e)},p.call=function(url,accessToken,callback){var parsedurl=url+"?access_token="+accessToken,xmlhttp;"undefined"!=typeof window&&(xmlhttp=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"),xmlhttp.onreadystatechange=function(){4==xmlhttp.readyState&&200!=xmlhttp.status&&callback(null),4==xmlhttp.readyState&&200==xmlhttp.status&&callback(eval("("+xmlhttp.responseText+")"))},xmlhttp.open("GET",parsedurl,!0),xmlhttp.send())},p.profile=function(e,t){this.call(profile_url,e,t)},p.changeAvatar=function(t,e){var i;if(t.getAccessToken())return(i=new FormData).append("avatar",e.files[0]),$.ajax({type:"POST",url:avatar_url,data:i,contentType:!1,processData:!1,headers:{Authorization:"Bearer "+t.getAccessToken()},success:function(e){t.setAvatar(e.url)}})},p.link=function(t){var i=new Deferred,e={},e=("object"==typeof(t=void 0===t?{}:t)&&(t=(e=t).callback||function(){}),e.fullscreen||!1),n=(etPhoneHome&&clearInterval(etPhoneHome),this.getAuthorizeURL()),s=Tools.oauth2Popup(n,e);return s&&(etPhoneHome=setInterval(function(){s.postMessage("Hello from the other side","*")}.bind(this),1e3)),callbacks.push(function(e){t(e),i.resolve(e)}),i.promise()},p.onInit=function(e){afterInit.push(e)},p.onAdds=function(){for(var e=0;e<afterInit.length;e++)afterInit[e]()},p.getParamsFromHash=function(e){if("undefined"!=typeof window)return e=(e=e||window.location.hash).slice(1),(e=decodeURIComponent(e)).split("&").reduce(function(e,t){return e[(t=t.split("="))[0]]=t[1],e},{})},p.finish=function(){var e='oauth::{"catlabremote":1,"event":"user:authenticated","access_token":"'+this.getParamsFromHash().access_token+'"}';setTimeout(function(){window.opener&&window.opener.postMessage(e,"*"),window.parent&&window.parent.postMessage(e,"*"),void 0!==window.dialogArguments&&window.dialogArguments.opener&&window.dialogArguments.opener.postMessage(e,"*"),setTimeout(function(){etPhoneHome&&clearInterval(etPhoneHome),window.close()},1)},1)},new OAuth2}),define("CatLab/Webremote/Views/Popups/BasePopup",["jquery"],function(n){function e(){this.scrollable=!1}var t=e.prototype;return t.render=function(e){this.popupContainer=document.createElement("div"),this.popupContainer.className="catlab-popup-container";var t=document.createElement("div"),t=(t.className="overlay",this.popupContainer.appendChild(t),this.container=document.createElement("div"),this.container.className="popup",this.popupContainer.appendChild(this.container),n(this.container).click(function(e){e.stopPropagation()}),this.content=document.createElement("div"),this.container.appendChild(this.content),document.createElement("p")),i=(t.className="close",document.createElement("a"));i.href="javascript:void(0)",i.innerHTML="<span>Close</span>",i.onclick=function(){this.close()}.bind(this),t.appendChild(i),this.container.appendChild(t),e.appendChild(this.popupContainer),this.scrollable&&n(this.content).addClass("scrollable"),this.renderContent(this.content)},t.renderContent=function(){},t.close=function(){this.popupContainer.parentNode.removeChild(this.popupContainer)},e}),define("CatLab/Webremote/Views/User",["CatLab/Webremote/Controllers/OAuth2","jquery"],function(i,n){return function(d){this.render=function(e,t,i){t=t||[];var n,s=d.getName(),o=document.createElement("div"),r=(o.className="catlab-user",document.createElement("div")),r=((this.avatardiv=r).className="catlab-avatar",o.appendChild(r),this.renderAvatar(),void 0!==i&&(r.onclick=i),document.createElement("div")),a=(r.className="catlab-info",o.appendChild(r),document.createElement("p"));void 0!==i?((n=document.createElement("a")).innerHTML=s,n.onclick=i,a.appendChild(n)):(a.innerHTML=s,r.appendChild(a)),r.appendChild(a);var h,l,c=document.createElement("ul");c.className="catlab-actions";for(var u=0;u<t.length;u++)(h=document.createElement("li")).className=t[u].token,c.appendChild(h),(l=document.createElement("a")).onclick=t[u].click,l.innerHTML=t[u].text,l.href="javascript:void(0)",h.appendChild(l);r.appendChild(c),e.innerHTML="",e.appendChild(o);i=document.createElement("div");i.className="clearer",o.appendChild(i)},this.renderAvatar=function(){var e=d.getAvatar(),t=document.createElement("img");t.src=e,t.alt="User avatar",n(this.avatardiv).html(t)},this.enableAvatarUpload=function(e){var t=document.createElement("input");t.type="file",t.accept="image/*",this.avatarFileInput=t,n(t).on("change",function(){n(this.avatardiv).addClass("loading"),n.when(i.changeAvatar(d,t)).then(function(){n(this.avatardiv).removeClass("loading"),this.renderAvatar(),e.setUser(d)}.bind(this))}.bind(this)),n(this.avatardiv).click(function(){t.click()})},this.uploadAvatar=function(){this.avatarFileInput&&this.avatarFileInput.click()}}}),define("CatLab/Webremote/Views/Popups/AuthenticationPopup",["CatLab/Webremote/Views/Popups/BasePopup","CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Views/User","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Tools/Tracker"],function(e,h,l,c,u,d){return function(t){function e(){h.link(function(e){s.updateUsers(),s.selectUser(e)})}h.on("update",function(){this.updateUsers()}.bind(this));var s=this,i=document.createElement("div"),n=(i.className="catlab-popup-container",document.createElement("div")),n=(n.className="overlay",i.appendChild(n),document.createElement("div")),o=(n.className="popup",i.appendChild(n),n.innerHTML="<h2>Select account</h2>",document.createElement("ul")),r=(o.className="userlist",n.appendChild(o),document.createElement("div")),r=(r.className="clearer",n.appendChild(r),document.createElement("p")),a=(r.className="connect",document.createElement("a")),r=(a.href="javascript:void(0)",a.innerHTML='<span class="new-user">Connect new user</span>',a.onclick=function(){e()},r.appendChild(a),n.appendChild(a),document.createElement("p")),a=(r.className="close",document.createElement("a"));a.href="javascript:void(0)",a.innerHTML="<span>Close</span>",a.onclick=function(){s.close()},r.appendChild(a),n.appendChild(r),this.selectUser=function(e){t.setUser(e),s.close(),d.track("Click","Select user","AuthenticationPopup")},this.updateUsers=function(){o.innerHTML="";for(var e=l.getAll(),t=0;t<e.length;t++)!function(e,t){var i=document.createElement("li"),n=[{token:"select",text:"select",click:function(){s.selectUser(t)}},{token:"logout",text:"logout",click:function(){l.remove(t),u.remove("users",{access_token:t.getAccessToken()}),s.updateUsers(),d.track("Click","Logout","AuthenticationPopup")}}];new c(t).render(i,n,function(){s.selectUser(t)}),e.appendChild(i)}(o,e[t])},this.close=function(){i.parentNode.removeChild(i),d.track("Click","Close popup","AuthenticationPopup")},this.connect=function(){d.track("Click","Connect new","AuthenticationPopup"),e()},this.render=function(e){e.appendChild(i),this.updateUsers()},this.setLoginUrl=function(e){console.log(e)}}}),define("CatLab/Webremote/Views/Popups/SelectSmileyPopup",["CatLab/Webremote/Views/Popups/BasePopup"],function(e){function t(e,t,i){this.Webremote=e,this.callback=t,this.scrollable=!0,this.disableTaken=i}e=t.prototype=new e;return e.renderContent=function(e){$(e).addClass("smileys-popup");var t,i=$('<ul class="smileys"></ul>'),n=($(e).append(i),this.Webremote.smileys.smileyKeys.slice());this.Webremote.getUser()&&this.Webremote.getUser().getAvatar()&&(t=this.Webremote.getUser().getAvatarSmiley(this.Webremote.color))&&n.unshift(t);for(var s=0;s<n.length;s++)this.renderSmiley(i,n[s]);$(e).append('<div class="clearer"></div>')},e.renderSmiley=function(e,t){var i=$("<li>");i.append(this.Webremote.smileys.getElement(t)),this.disableTaken&&!this.Webremote.smileys.isAvailable(t)&&i.addClass("unavailable"),this.Webremote.getSmiley()===t&&i.addClass("selected"),i.click(function(){this.selectSmiley(t),e.find(".selected").removeClass("selected"),i.addClass("selected"),this.close()}.bind(this)),e.append(i)},e.selectSmiley=function(e){this.callback(e)},t}),define("CatLab/Webremote/Views/Blocks/CurrentUser",["CatLab/Webremote/Views/User","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Tools/Tracker"],function(o,r,a,h){return function(s){this.render=function(e){var t,i,n;e.innerHTML="",s.canAuthenticate()&&(n=s.getUser(),(t=document.createElement("div")).className="overlay player-color-background",e.appendChild(t),(t=document.createElement("div")).className="content",t.className+=" player-color-border",e.appendChild(t),n?(e=[{token:"switch",text:"Switch account",click:function(){s.showAuthenticationPopup(),h.track("Click","Switch account","CurrentUser")}},{token:"upload",text:"Upload photo",click:function(){i.uploadAvatar()}},{token:"logout",text:"Logout",click:function(){var e=s.getUser();r.remove(e),s.setUser(null),a.remove("users",{access_token:e.getAccessToken()}),h.track("Click","Logout","CurrentUser")}}],(i=new o(n)).render(t,e),i.enableAvatarUpload(s)):((n=document.createElement("p")).className="catlab-not-loggedin",(e=document.createElement("a")).href="javascript:void(0);",e.innerHTML="Login",e.onclick=function(){s.showAuthenticationPopup(0===r.getAll().length),h.track("Click","Login","CurrentUser")},n.appendChild(e),t.appendChild(n)))}}}),!function(){"use strict";var f={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function g(e){for(var t,i,n,s,o,r,a,h=function(e){if(m[e])return m[e];for(var t,i=e,n=[],s=0;i;){if(null!==(t=f.text.exec(i)))n.push(t[0]);else if(null!==(t=f.modulo.exec(i)))n.push("%");else{if(null===(t=f.placeholder.exec(i)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){s|=1;var o=[],r=t[2],a=[];if(null===(a=f.key.exec(r)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(o.push(a[1]);""!==(r=r.substring(a[0].length));){if(null===(a=f.key_access.exec(r))&&null===(a=f.index_access.exec(r)))throw new SyntaxError("[sprintf] failed to parse named argument key");o.push(a[1])}t[2]=o}else s|=2;if(3===s)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n.push({placeholder:t[0],param_no:t[1],keys:t[2],sign:t[3],pad_char:t[4],align:t[5],width:t[6],precision:t[7],type:t[8]})}i=i.substring(t[0].length)}return m[e]=n}(e),l=arguments,c=1,u=h.length,d="",p=0;p<u;p++)if("string"==typeof h[p])d+=h[p];else if("object"==typeof h[p]){if((n=h[p]).keys)for(t=l[c],i=0;i<n.keys.length;i++){if(null==t)throw new Error(g('[sprintf] Cannot access property "%s" of undefined value "%s"',n.keys[i],n.keys[i-1]));t=t[n.keys[i]]}else t=n.param_no?l[n.param_no]:l[c++];if(f.not_type.test(n.type)&&f.not_primitive.test(n.type)&&t instanceof Function&&(t=t()),f.numeric_arg.test(n.type)&&"number"!=typeof t&&isNaN(t))throw new TypeError(g("[sprintf] expecting number but found %T",t));switch(f.number.test(n.type)&&(r=0<=t),n.type){case"b":t=parseInt(t,10).toString(2);break;case"c":t=String.fromCharCode(parseInt(t,10));break;case"d":case"i":t=parseInt(t,10);break;case"j":t=JSON.stringify(t,null,n.width?parseInt(n.width):0);break;case"e":t=n.precision?parseFloat(t).toExponential(n.precision):parseFloat(t).toExponential();break;case"f":t=n.precision?parseFloat(t).toFixed(n.precision):parseFloat(t);break;case"g":t=n.precision?String(Number(t.toPrecision(n.precision))):parseFloat(t);break;case"o":t=(parseInt(t,10)>>>0).toString(8);break;case"s":t=String(t),t=n.precision?t.substring(0,n.precision):t;break;case"t":t=String(!!t),t=n.precision?t.substring(0,n.precision):t;break;case"T":t=Object.prototype.toString.call(t).slice(8,-1).toLowerCase(),t=n.precision?t.substring(0,n.precision):t;break;case"u":t=parseInt(t,10)>>>0;break;case"v":t=t.valueOf(),t=n.precision?t.substring(0,n.precision):t;break;case"x":t=(parseInt(t,10)>>>0).toString(16);break;case"X":t=(parseInt(t,10)>>>0).toString(16).toUpperCase()}f.json.test(n.type)?d+=t:(!f.number.test(n.type)||r&&!n.sign?a="":(a=r?"+":"-",t=t.toString().replace(f.sign,"")),s=n.pad_char?"0"===n.pad_char?"0":n.pad_char.charAt(1):" ",o=n.width-(a+t).length,o=n.width&&0<o?s.repeat(o):"",d+=n.align?a+t+o:"0"===s?a+o+t:o+a+t)}return d}function e(e,t){return g.apply(null,[e].concat(t||[]))}var m=Object.create(null);"undefined"!=typeof exports&&(exports.sprintf=g,exports.vsprintf=e),"undefined"!=typeof window&&(window.sprintf=g,window.vsprintf=e,"function"==typeof define)&&define.amd&&define("sprintf",[],function(){return{sprintf:g,vsprintf:e}})}(),define("CatLab/Webremote/Tools/Translator",["sprintf"],function(t){function e(){this.translator=null}var i,n,s=e.prototype;return s.setTranslator=function(e){this.translatorScope=this,"function"==typeof e?this.translator=e:("function"==typeof e.t?this.translator=e.t:(e._,this.translator=e._),this.translatorScope=e)},s.t=function(e){if(""===e)return"";if(Array.isArray(e))return this.t.apply(this,e);if(this.translator)return this.translator.apply(this.translatorScope,arguments);for(i=[],n=1;n<arguments.length;n++)i.push(arguments[n]);return t.vsprintf(e,i)},new e}),define("CatLab/Webremote/Views/Blocks/CurrentSmiley",["jquery","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/Deferred"],function(e,t,i){"use strict";function n(e,t,i,n){this.Webremote=e,this.canSwitch=void 0!==t&&!!t,this.canDrag=void 0!==i&&!!i,this.isProfileSmiley=void 0===n||!!n,this.dragDisabled=!1,this.switchVerb="Switch"}n.initialize=function(){return n.isInitialized||(n.isInitialized=new i,require(["jquery-ui","jquery-ui-touch-punch"],function(e,t){n.isInitialized.resolve()})),n.isInitialized.promise()}.bind(this),n.activeSmileys=["1f601","1f60d","1f60e"];var s=n.prototype;return s.setSmiley=function(e){Array.isArray(e)||(e=[e]),this.smileys=e,n.initialize().then(function(){this.selector&&(this.selector.html(""),e.forEach(function(s){var i=$(this.Webremote.smileys.getElement(s));if(this.selector.append(i),this.canDrag)try{var o=null,r=null;i.css({zIndex:10}).draggable({start:function(e,t){if(this.dragDisabled)return!1;o=t.position,r=$(t.helper).offset(),this.disableDrag(),i.toggleClass("flinging",!0)}.bind(this),stop:function(e,t){var i=t.position,n=this.getDistance(o,i);10<n?(i=this.getAngle(o,i),this.slingshot(r,i,n,t.helper,s)):this.Webremote.showSmileyPopup()}.bind(this)})}catch(s){console.log(s)}}.bind(this)),this.canSwitch)&&this.selector.append('<p class="switch"><a href="javascript:void(0)">'+t.t(this.switchVerb)+"</a></p>")}.bind(this))},s.disableDrag=function(){this.dragDisabled=!0,this.selector&&$(this.selector).toggleClass("drag-disabled",!0)},s.enableDrag=function(){this.dragDisabled=!1,this.selector&&$(this.selector).toggleClass("drag-disabled",!1)},s.getMaxDistance=function(){return this.selector?$(window).height()-this.selector.offset().top:200},s.getDistance=function(e,t){var i=e.left-t.left,e=e.top-t.top;return Math.sqrt(i*i+e*e)},s.getAngle=function(e,t){return Math.atan2(t.top-e.top,t.left-e.top)},s.slingshot=function(e,t,i,n,s){var o=Math.min(1,i/this.getMaxDistance());0<Math.sin(t-Math.PI)?n.animate({left:0,top:0,opacity:1},1e3):(i=1.5*Math.max(e.left,e.top),n.animate({left:Math.cos(t-Math.PI)*i,top:Math.sin(t-Math.PI)*i},1e3,"swing",function(){setTimeout(function(){n.css({left:-1*parseInt(n.css("left"))}),n.animate({left:0,top:0},1e3,function(){this.enableDrag(),n.toggleClass("flinging",!1)}.bind(this))}.bind(this),3e3*o)}.bind(this)),setTimeout(function(){this.Webremote.emit("smileys:slingshot",{angle:t,speed:o,smiley:s})}.bind(this),800))},s.render=function(e){n.initialize().then(function(){this.container=$(e),this.canSwitch||this.canDrag?this.selector=$('<div class="smiley-selector"></div>'):this.selector=$('<div class="smiley-view"></div>'),this.selector.html('<div class="placeholder"></div>'),this.container.html(this.selector),this.canSwitch&&($(this.container).off("click"),$(this.container).click(function(){this.isProfileSmiley?this.Webremote.showSmileyPopup():this.Webremote.showSmileyPopup(function(e){if(-1===n.activeSmileys.indexOf(e)){for(;2<n.activeSmileys.length;)n.activeSmileys.shift();n.activeSmileys.push(e),this.setSmiley(n.activeSmileys)}}.bind(this),!1)}.bind(this)),this.isProfileSmiley||this.setSmiley(n.activeSmileys))}.bind(this))},n}),define("CatLab/Webremote/Tools/HashParser",[],function(){return{getParameters:function(){function e(e){return decodeURIComponent(e.replace(n," "))}for(var t,i={},n=/\+/g,s=/([^&;=]+)=?([^&;]*)/g,o=window.location.hash.substring(1);t=s.exec(o);)i[e(t[1])]=e(t[2]);return i},getParameter:function(e){var t=this.getParameters();return void 0!==t[e]?t[e]:null},clear:function(){history.pushState("",document.title,window.location.pathname+window.location.search)}}}),define("CatLab/Webremote/Views/Alert",[],function(){return function(e,t){t=t||function(){},alert(e),t()}}),define("CatLab/Webremote/Views/Welcome",["CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Views/User","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Tools/Tracker"],function(e,t,i,o){return function(e){var t=this,i=document.createElement("div"),n=(i.className="catlab-popup-container",document.createElement("div")),n=(n.className="overlay",i.appendChild(n),document.createElement("div")),e=(n.className="popup thanks",i.appendChild(n),n.innerHTML=e,document.createElement("a")),s=(e.innerHTML="Start playing",e.onclick=function(){t.close()},e.href="javascript:void(0)",document.createElement("p"));s.appendChild(e),s.className="playnow",n.appendChild(s),this.close=function(){i.parentNode.removeChild(i),o.track("Click","Close popup","WelcomePopup")},this.render=function(e){e.appendChild(i)}}}),define("CatLab/Webremote/Views/ConnectionTrouble",["CatLab/Webremote/Tools/Translator"],function(e){function t(){this.visible=!1,this.div=null,this.timeoutTillShow=3e3,this.showTimeout=null,this.message=null}var i=t.prototype;return i.show=function(){this.visible||(this.visible=!0,this.div)||(this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=null),setTimeout(function(){this.div||this.visible&&(this.showTimeout=null,this.div=document.createElement("div"),document.body.appendChild(this.div),this.div.style.position="absolute",this.div.style.right="10px",this.div.style.top="10px",this.div.style.width="350px",this.div.style.padding="10px",this.div.style.border="1px solid red",this.div.style.background="black",this.div.style.zIndex="100000",this.div.style.textAlign="center",this.div.style.color="white",this.div.style.font="Sans-serif",this.div.style.fontSize="15px",this.message?this.text(this.message):this.text(e.t("Connection lost")))}.bind(this),this.timeoutTillShow))},i.text=function(e){this.message=e,this.div&&(this.div.innerHTML="<p>"+e+"</p>")},i.hide=function(){this.visible=!1,this.div&&this.div.parentNode&&this.div.parentNode.removeChild(this.div),this.showTimeout&&clearTimeout(this.showTimeout),this.message=null,this.div=null,this.showTimeout=null},t}),define("CatLab/Webremote/Views/GamePaused",["CatLab/Webremote/Tools/Translator"],function(e){function t(){this.visible=!1,this.div=null,this.timeoutTillShow=1,this.showTimeout=null,this.message=null}var i=t.prototype;return i.show=function(){this.visible||(this.visible=!0,this.div)||(this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=null),setTimeout(function(){this.div||this.visible&&(this.showTimeout=null,this.div=document.createElement("div"),document.body.appendChild(this.div),this.div.style.position="fixed",this.div.style.right="0",this.div.style.top="0",this.div.style.width="100%",this.div.style.height="100%",this.div.style.padding="0",this.div.style.background="black",this.div.style.zIndex="100000",this.div.style.textAlign="center",this.div.style.color="white",this.div.style.font="Sans-serif",this.div.style.fontSize="2em",this.div.style.opacity=.9,this.message?this.text(this.message):this.text(e.t("Please wait, the game is paused.")))}.bind(this),this.timeoutTillShow))},i.text=function(e){this.message=e,this.div&&(this.div.innerHTML='<p style="height: 100%; padding: 20% 0">'+e+"</p>")},i.hide=function(){this.visible=!1,this.div&&this.div.parentNode.removeChild(this.div),this.showTimeout&&clearTimeout(this.showTimeout),this.message=null,this.div=null,this.showTimeout=null},t}),define("CatLab/Webremote/Synchronization/ClientRemoteView",["jquery"],function(n){"use strict";function e(e,t,i,n,s,o){this.controller=e,this.html="<p>Loading</p>",this.context={},this.viewId=t,this.name=i,this.groupId=void 0!==n?n:null,this.synchronizedData=s,this.createdAt=new Date,this.iframe=o,this.currentValues=[],this.buttons=[]}var s={},t=e.prototype;return t.render=function(e){var t;this.iframe?(t=document.createElement("iframe"),$(t).css({width:"100%",height:"100%",border:"none",margin:0,padding:0,position:"absolute",left:0,top:0}),$(e).html(t),this.element=t.contentDocument.body):this.element=e,this.el=e,this.$el=n(e),this.element.innerHTML=this.html,this.update(),this.controller.components.attach(this,n("body")),this.updateEvents(),setTimeout(function(){this.updateEvents(),window.scrollTo(0,1)}.bind(this),10),setTimeout(function(){this.updateEvents()}.bind(this),100),setTimeout(function(){this.updateEvents()}.bind(this),1e3)},t.updateEvents=function(){var c=this;function e(n,t,s){var o,r,a,h,l;c.shouldSetEvents(n,"touch")&&(h=!1,l=null,n.addEventListener("touchstart",function(e){return o=new Date,r={x:e.touches[0].pageX,y:e.touches[0].pageY},a={x:e.touches[0].pageX,y:e.touches[0].pageY},h=!0,l&&clearTimeout(l),t.apply(c,[n])}),n.addEventListener("touchmove",function(e){a={x:e.touches[0].pageX,y:e.touches[0].pageY}}),n.addEventListener("touchend",function(e){var t,i;if(r)return i=Math.abs(a.x-r.x),t=Math.abs(a.y-r.y),r=null,i=(new Date).getTime()-o.getTime()<300&&i<20&&t<20,l=setTimeout(function(){h=!1},1e3),s.apply(c,[n,i])}),n.addEventListener("mousedown",function(e){if(e.preventDefault(),!h)return t.apply(c,[n])}),n.addEventListener("mouseup",function(e){if(e.preventDefault(),!h)return s.apply(c,[n,!0])}))}for(var t=this.element.querySelectorAll("[data-button-id]"),i=0;i<t.length;i++)e(t[i],c.buttonDown,c.buttonUp),this.buttons.push(t[i]);for(t=this.element.querySelectorAll("[data-authentication-button]"),i=0;i<t.length;i++)e(t[i],function(){},c.authenticate);for(t=this.element.querySelectorAll("[data-value-id]"),i=0;i<t.length;i++)!function(t){var i,e;c.shouldSetEvents(t,"change")&&(i=t.getAttribute("data-value-id"),c.currentValues[i]=c.getDataValue(t),t.addEventListener("change",function(e){s[i]=new Date,c.syncValue(t)}),e=null,t.addEventListener("keyup",function(){e&&clearTimeout(e),e=setTimeout(function(){s[i]=new Date,c.syncValue(t)},1e3)}))}(t[i])},t.getDataValue=function(e){return"checkbox"===e.type?e.checked?1:0:e.value},t.syncValues=function(){for(var e=this.element.querySelectorAll("[data-value-id]"),t=0;t<e.length;t++)this.syncValue(e[t])},t.syncValue=function(e){var t=this.getDataValue(e),i=e.getAttribute("data-value-id");void 0!==this.currentValues[i]&&this.currentValues[i]===t||(this.currentValues[i]=t,this.controller.syncValue(i,this.getDataValue(e),this.viewId))},t.update=function(){for(var e=this.element.querySelectorAll("[data-button-decorator]"),t=0;t<e.length;t++)void 0===e[t].dataset.initialClasses&&(e[t].dataset.initialClasses=e[t].className);this.updateBigTextSizes()},t.updateBigTextSizes=function(){var i=$(this.element),e=i.find(".bigtext"),n={};e.each(function(){var e=$(this).attr("data-bigtext-group"),t=e?(void 0===n[e]&&(n[e]=0,i.find('.bigtext[data-bigtext-group="'+e+'"]').each(function(){n[e]=Math.max(n[e],$(this).text().length)})),n[e]):$(this).text().length;$(this).attr("data-bigtext-length",t)})},t.shouldSetEvents=function(e,t){return void 0===e["hasCatlabEventsAlready"+t]&&(e["hasCatlabEventsAlready"+t]=!0)},t.buttonDown=function(e){try{this.syncValues()}catch(e){console.error(e)}return this.controller.buttonDown(e.getAttribute("data-button-id"),this.viewId),!1},t.buttonUp=function(e,t){return this.controller.buttonUp(e.getAttribute("data-button-id"),this.viewId,t),!1},t.setLabel=function(e,t){for(var i=this.element.querySelectorAll("[data-button-label="+e+"]"),n=0;n<i.length;n++)i[n].innerHTML=t;this.update()},t.setClass=function(e,t){for(var i=this.element.querySelectorAll("[data-button-decorator="+e+"]"),n=0;n<i.length;n++){var s=i[n];s.className=s.dataset.initialClasses+" "+t}this.update()},t.domAppend=function(e,t){var i=document.getElementById(e);if(i){for(var n=this.stringToDom(t),s=[];n.firstChild;)s.push(i.appendChild(n.firstChild));try{for(var o=0;o<s.length;o++)this.controller.components.attach(this._currentView,s[o],!1)}catch(e){console.log(e)}5e3<(new Date).getTime()-this.createdAt.getTime()&&0<s.length&&void 0!==s[0].scrollIntoView&&s[0].scrollIntoView(),this.update(),this.updateEvents()}},t.domReplace=function(e,t){e=document.getElementById(e);e&&(e.innerHTML=t,this.controller.components.attach(this._currentView,e,!1),this.update(),this.updateEvents())},t.domAttribute=function(e,t,i){n(e).attr(t,i)},t.changeValue=function(e){if(void 0!==s[e.id]){if((t=Math.abs(s[e.id].getTime()-(new Date).getTime()))<5)return}else var t=9999999999999;for(var i=this.element.querySelectorAll("[data-value-id="+e.id+"]"),n=0;n<i.length;n++)document.activeElement==i[n]&&t<5e3||(this.currentValues[e.id]=e.value,i[n].value=e.value)},t.vibrate=function(e){void 0!==window.navigator.vibrate&&void 0!==e.pattern&&Array.isArray(e.pattern)&&window.navigator.vibrate(e.pattern)},t.stringToDom=function(e){var t;return(t=0<=e.toLowerCase().indexOf("<tr")?document.createElement("tbody"):document.createElement("div")).innerHTML=e,t},t.stringInterpolateDataElements=function(e,s){return e.replace(/{{(.+?)}}/g,function(e,t,i,n){t=this.controller.resolveDataAttribute(t.trim());return t=s?s(t):t}.bind(this))},t.destroy=function(){this.syncValues(),void 0!==this.synchronizedData&&this.synchronizedData.destroy()},e}),define("CatLab/Webremote/Synchronization/DataItem",[],function(){function i(e,t,i){this.key=e,this.shared=t,this.side=i}var e=i.prototype;return e.setValue=function(e){this.value=e},e.canWrite=function(e){return!!this.shared||this.side===e},e.serialize=function(){return{key:this.key,shared:this.shared,side:this.side,value:this.value}},i.unserialize=function(e){var t=new i(e.key,e.shared,e.side);return t.setValue(e.value),t},i}),define("CatLab/Webremote/Synchronization/SynchronizedData",["CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Synchronization/DataItem"],function(e,s){function t(e,t,i){this.initializeEventable(),this.id=e,this.synchronizer=t,this.side=i,this.data={}}e=t.prototype=new e;return e.set=function(e,t,i){if(void 0===this.data[e])this.data[e]=new s(e,i,this.side);else if(!this.data[e].canWrite(this.side))throw"Trying to overwrite a non shared data attribute: "+e;this.data[e].setValue(t),this.emit(this.data[e])},e.processMessage=function(e){var t=e.key,i=e.side,n=e.value,e=e.shared;if(void 0===this.data[t])this.data[t]=new s(t,e,i);else if(!this.data[t].canWrite(i))throw"Trying to overwrite a non shared data attribute: "+t;this.data[t].setValue(n)},e.get=function(e){return void 0===this.data[e]?null:this.data[e].value},e.emit=function(e,t){void 0===t&&(t=this.synchronizer.emit);e=e.serialize();e.namespace=this.synchronizer.namespace,e.container=this.id,t("data:set",e)},e.refreshTarget=function(e){for(var t in this.data)this.data.hasOwnProperty(t)&&this.emit(this.data[t],e)},e.destroy=function(){this.synchronizer.destroy(this)},e.serialize=function(){var e,t={};for(e in this.data)this.data.hasOwnProperty(e)&&(t[e]=this.data[e].serialize());return t},e.unserialize=function(e){for(var t in this.data={},e)e.hasOwnProperty(t)&&(this.data[t]=s.unserialize(e[t]))},t}),define("CatLab/Webremote/Synchronization/DataSynchronizer",["CatLab/Webremote/Synchronization/SynchronizedData"],function(t){function e(e,t,i){this.namespace=e,this.emit=t,this.dataModels={},this.side=i}e.eventsToListenFor=["data:set"];var i=e.prototype;return i.checkNamespace=function(e){return void 0!==e.namespace&&e.namespace===this.namespace},i.processMessage=function(e,t){void 0!==t.container&&this.getFromIdentifier(t.container).processMessage(t)},i.getFromIdentifier=function(e){return void 0===this.dataModels[e]&&(this.dataModels[e]=new t(e,this,this.side)),this.dataModels[e]},i.destroy=function(e){e=e.id;void 0===this.dataModels[e]&&delete this.dataModels[e]},i.refreshTarget=function(e){for(var t in this.dataModels)this.dataModels.hasOwnProperty(t)&&this.dataModels[t].refreshTarget(e)},i.serialize=function(){var e,t={};for(e in this.dataModels)this.dataModels.hasOwnProperty(e)&&(t[e]=this.dataModels[e].serialize());return{dataModels:t}},i.unserialize=function(e){for(var t in e.dataModels)e.dataModels.hasOwnProperty(t)&&this.getFromIdentifier(t).unserialize(e.dataModels[t])},e}),define("CatLab/Webremote/Synchronization/EventHandler",["CatLab/Webremote/Tools/Eventable"],function(e){function t(e,t){this.initializeEventable(),this.namespace=e,this.emit=t}t.eventsToListenFor=["event:trigger"];e=t.prototype=new e;return e.checkNamespace=function(e){return void 0!==e.namespace&&e.namespace===this.namespace},e.processMessage=function(e,t){if("event:trigger"===e)return this.processTriggerEvent(t)},e.processTriggerEvent=function(e){void 0!==e.event&&this.eventableTrigger(e.event,void 0===e.parameters?{}:e.parameters)},e.trigger=function(e,t){this.emit("event:trigger",{namespace:this.namespace,event:e,parameters:t})},e.refreshTarget=function(e){},e.serialize=function(){return{}},e.unserialize=function(e){},t}),define("CatLab/Webremote/Synchronization/CombinedEventHandler",["CatLab/Webremote/Tools/Eventable"],function(e){function t(e,t){this.initializeEventable(),this.handlers=[]}return(t.prototype=new e).addHandler=function(e){this.handlers.push(e),e.on("*",function(e,t){this.trigger(t,e)}.bind(this))},t}),define("CatLab/Webremote/Synchronization/MessageQueue",[],function(){"use strict";function e(){this.queue=[]}var t=e.prototype;return t.add=function(e,t,i){this.queue.push({action:e,data:t,ack:i})},t.flush=function(){var e=this.queue;return this.queue=[],e},t.compactFlush=function(){var n,s,o,r,a=[],e=this.flush();return 0===e.length?e:(s={user:{},group:{}},o=0,r={},e.forEach(function(e){if(o++,this.canCompact(e)){var t=null;void 0!==e.data.user?t="user":void 0!==e.data.group&&(t="group"),void 0===s[t][e.action]&&(s[t][e.action]=[]);for(var i=0;i<s[t][e.action].length;i++)if(n=s[t][e.action][i],this.isSimilarMessage(n.event,e)&&(void 0===r[e.data[t]]||r[e.data[t]]<n.index))return r[e.data[t]]=n.index,n.event.data[t].push(e.data[t]),void n.event.data._d.push(this.getDifference(n.event,e));Array.isArray(e.data[t])||(e.data[t]=[e.data[t]]),e.data._d=[{}],r[e.data[t]]=o,s[t][e.action].push({event:e,index:o})}a.push(e)}.bind(this)),a)},t.moveToEnd=function(e,t){e.push(e.splice(e.indexOf(t),1)[0])},t.isSimilarMessage=function(e,t){return e.action===t.action&&this.getCompareDataString(e)===this.getCompareDataString(t)},t.getDifference=function(e,t){var i,n={};for(i in t.data)if(t.data.hasOwnProperty(i)){switch(i){case"user":case"group":case"_d":case"_i":continue}void 0!==e.data[i]&&e.data[i]===t.data[i]||(n[i]=t.data[i])}return n},t.getCompareDataString=function(e){e=Object.assign({},e.data);return delete e.user,delete e.group,delete e.viewId,delete e._d,delete e._i,JSON.stringify(e)},t.canCompact=function(e){return!(void 0!==e.ack&&null!==e.ack||void 0===e.data||void 0===e.data.user&&void 0===e.data.group)},e.unpack=function(e,t){if(void 0===e[t])return[e];var i=Array.isArray(e[t])?e[t]:[e[t]],n=[];void 0!==e._d&&(n=Array.isArray(e._d)?e._d:[e._d]);for(var s=[],o=0;o<i.length;o++){(r={})[t]=i[o];var r=Object.assign({},e,r,void 0!==n[o]?n[o]:{});delete r._d,s.push(r)}return s},Object.defineProperty(t,"length",{get:function(){return this.queue.length}}),e}),define("CatLab/Webremote/Tools/Proxy",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred"],function(o,r){function e(){}var a=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}];return e.prototype.get=function(e){o.getProxy()&&(e=o.getProxy()+encodeURIComponent(e)),console.log(e);var t,i,n,s=new r;return e=e,t=function(e){s.resolve(e.responseText)},(n=function(){for(var e=!1,t=0;t<a.length;t++){try{e=a[t]()}catch(e){continue}break}return e}())&&(n.open(i?"POST":"GET",e,!0),i&&n.setRequestHeader("Content-type","application/x-www-form-urlencoded"),n.onreadystatechange=function(){4==n.readyState&&(200==n.status||304==n.status?t(n):console.error("CatLab Remote HTTP error "+n.status))},4!=n.readyState)&&n.send(i),s.promise()},new e}),define("CatLab/Webremote/Providers/Provider",["CatLab/Webremote/Synchronization/MessageQueue","CatLab/Webremote/Tools/Proxy","CatLab/Webremote/Tools/Deferred"],function(e,i,o){"use strict";function t(){this.initializeProvider()}var n=t.prototype;return n.initializeProvider=function(){this.queue=new e,this.postInitializeQueue=[],this.scheduled=!1,this.initialized=!1,this.sendBurstDelay=10,this.maxQueueSize=2500,this.messageCounter=null,this.events={}},n.getProviderSettings=function(){var e=new o;return e.resolve({}),e.promise()},n.setMessageCounter=function(e){this.messageCounter=e},n.initMaster=function(e){this.master=e},n.initPlayer=function(e){this.master=e},n.connect=function(){var e=new o;return e.resolve(),e.promise()},n.disconnect=function(){this.off()},n.setOAuthSettings=function(e){this.emit("oauth:set",e)},n.loadViews=function(e,t){(t=void 0===t?!1:t)?i.get(e).then(function(e){this.emit("view:load",{xml:e})}.bind(this)):this.emit("view:load",{url:e})},n.toMaster=function(e,t,i){this.emit(e,t,i)},n.toPlayers=function(e,t,i){this.emit(e,t,i)},n.toPlayer=function(e,t,i,n){i.user=e.getId(),this.emit(t,i,n)},n.toGroup=function(e,t,i,n){i.group=e.getId(),this.emit(t,i,n)},n.emit=function(e,t,i){this.initialized?this.queue?(this.queue.add(e,t,i),this.queue.length>this.maxQueueSize?(clearTimeout(this.scheduled),this.scheduled=null,this.executeQueue()):this.scheduled||(this.scheduled=setTimeout(function(){this.scheduled=null,this.executeQueue()}.bind(this),this.sendBurstDelay))):this.emitOne(e,t,i):this.postInitializeQueue.push({action:e,data:t,ack:i})},n.createGroup=function(e,t,i,n){this.emit("group:create",{externalId:e,globalViews:t,shareColor:i,tags:n=void 0===n?[]:n})},n.executeQueue=function(){this.initialized&&this.emitAll()},n.setInitialized=function(){var e;for(this.initialized=!0;e=this.postInitializeQueue.shift();)this.emit(e.action,e.data,e.ack)},n.setup=function(e){this.emit("master:setup",e)},n.reset=function(e){this.emit("master:reset",null,function(){e()})},n.getStaticUrl=function(e){return e},n.reconnect=function(e,t,i,n){var s=new o;return this.emit("master:reconnect",{token:e,accessToken:t,gameConfig:i},function(){n(),s.resolve()}.bind(this)),s.promise()},n.off=function(){this.events={}},n.on=function(e,t){this._addEvent(e,t,!1),this._touchEvent(e)},n.once=function(e,t){this._addEvent(e,t,!0),this._touchEvent(e)},n._addEvent=function(e,t,i){void 0===this.events[e]&&(this.events[e]=[]),this.events[e].push({callback:t,once:i})},n._touchEvents=function(){for(var e in this.events)this.events.hasOwnProperty(e)&&this._touchEvent(e)},n._touchEvent=function(e){},n._trigger=function(e,i){var n;void 0!==this.events[e]&&(n=[],this.events[e].forEach(function(e){var t=e.callback;e.once&&n.push(e);try{t.apply(this,[i])}catch(e){console.error(e)}}),0<n.length)&&(n.unshift(this.events),function(e){for(var t,i,n=arguments,s=n.length;1<s&&e.length;)for(t=n[--s];-1!==(i=e.indexOf(t));)e.splice(i,1);return e}.apply(this,n))},n.getConnectURL=function(e){return null},n.getConnectToken=function(e){return null},n.tokenConnect=function(e){var t=new o;return t.resolve(),t.promise()},n.noTokenConnect=function(){var e=new o;return e.resolve(),e.promise()},n.restoreProviderSettings=function(e){},n.serializeProviderSettings=function(){return{}},n.proxyFile=function(e){var t=new o;return this.emit("file:proxy",{url:e},function(e){t.resolve({url:e.url})}.bind(this)),t.promise()},t}),define("CatLab/Webremote/Providers/SocketIO",["CatLab/Webremote/Providers/Provider","CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Tools"],function(e,r,a,t){function i(){this.initializeProvider(),this.userId=null,this.randomToken=t.getUuid(),this.loadBalancerSessionToken="connid",this.socket=null,this._registeredEvents={}}var h=null,e=i.prototype=new e;return e.getProviderSettings=function(){var t=new a;return r.getServerList()?r.getServerList().getSelectedServer().done(function(e){t.resolve({host:e})}.bind(this)).fail(function(e){alert(e),t.reject(e)}.bind(this)):t.resolve({}),t.promise()},e.connect=function(n,s){var t,o=new a;return this.log("Loading socket.io"),t=function(){this.log("Connecting to socket.io");var e,t=r.getSocketURL(),i=(void 0!==s.host&&s.host&&(t=(e=r.getProtocol())?e+"://"+s.host:"//"+s.host),this.socket=h(t+"/"+n+"?"+this.loadBalancerSessionToken+"="+this.randomToken,{withCredentials:!1,reconnection:!0}),!1);this.socket.on("connect_error",function(e){i?this._trigger("disconnect"):(this.socket.off(),this.socket.disconnect(),this.socket=null,o.reject())}.bind(this)),this.socket.once("connect",function(){i||(i=!0,this.setInitialized(),this.socket.io.on("reconnect",function(e){this._trigger("reconnect")}.bind(this)),this._touchEvents(),o.resolve())}.bind(this))}.bind(this),require(["socket.io-client"],function(e){h=e,t()}),o.promise()},e.disconnect=function(e){void 0===e&&(e=!0),this.initialized=!1,this.socket&&((e?this:(this._registeredEvents={},this.socket)).off(),this.socket.disconnect(),this.socket=null)},e.off=function(){this._registeredEvents={},this.events={},this.socket.off()},e.setUserId=function(e){return this.userId=e,this},e.emitAll=function(){var e,t=this.queue.compactFlush();if(t.length)for(;e=t.shift();)this.emitOne(e.action,e.data,e.ack)},e.emitOne=function(e,t,i){this.socket.emit(e,t,i),this.messageCounter&&this.messageCounter.outgoing()},e.log=function(){this.master.log.apply(arguments)},e.getStaticUrl=function(e){return e.indexOf("?")<0?e+="?":e+="&",e+(this.loadBalancerSessionToken+"="+this.randomToken)},e._detachEvents=function(e){this.socket&&this.socket.off(e)},e._touchEvent=function(t){this.socket&&void 0===this._registeredEvents[t]&&(this.socket.on(t,function(e){this._trigger(t,e)}.bind(this)),this._registeredEvents[t]=!0)},e._handleSocketIoEvent=function(e,t){switch(e){case"connect":case"disconnect":break;default:return this._trigger(e,t)}},e.getConnectURL=function(e){return r.getServerList()?r.getServerList().getConnectURL():e},e.getConnectToken=function(e){return r.getServerList()?r.getServerList().getConnectToken(e):e},e.tokenConnect=function(e){var t=new a,i={};if(r.getServerList())try{var n=r.getServerList().getFromToken(e);i.host=n.host,e=n.token}catch(e){return t.reject(),t.promise()}return this.connect("remote",i).fail(function(){t.reject()}).then(function(){t.resolve(e)}),t.promise()},e.restoreProviderSettings=function(e){void 0!==e.serverlist&&r.getServerList()&&r.getServerList().unserialize(e.serverlist)},e.serializeProviderSettings=function(){var e={};return r.getServerList()&&(e.serverlist=r.getServerList().serialize()),e},i}),define("CatLab/Webremote/SonicSync/Library/ring-buffer",[],function(){function t(e){this.array=[],this.maxLength=e}return t.prototype.get=function(e){return e>=this.array.length?null:this.array[e]},t.prototype.last=function(){return 0==this.array.length?null:this.array[this.array.length-1]},t.prototype.add=function(e){this.array.push(e),this.array.length>=this.maxLength&&this.array.splice(0,1)},t.prototype.length=function(){return this.array.length},t.prototype.clear=function(){this.array=[]},t.prototype.copy=function(){var e=new t(this.maxLength);return e.array=this.array.slice(0),e},t.prototype.remove=function(e,t){this.array.splice(e,t)},t}),define("CatLab/Webremote/SonicSync/Library/sonic-coder",[],function(){function e(e){this.freqMin=(e=e||{}).freqMin||18500,this.freqMax=e.freqMax||19500,this.freqError=e.freqError||50,this.alphabetString=e.alphabet||"\n abcdefghijklmnopqrstuvwxyz0123456789,.!?@*",this.startChar=e.startChar||"^",this.endChar=e.endChar||"$",this.alphabet=this.startChar+this.alphabetString+this.endChar}return e.prototype.charToFreq=function(e){var t=this.alphabet.indexOf(e),e=(-1==t&&(console.error(e,"is an invalid character."),t=this.alphabet.length-1),this.freqMax-this.freqMin),t=t/this.alphabet.length,e=Math.round(e*t);return this.freqMin+e},e.prototype.freqToChar=function(e){if(!(this.freqMin<e&&e<this.freqMax))if(this.freqMin-e<this.freqError)e=this.freqMin;else{if(!(e-this.freqMax<this.freqError))return console.error(e,"is out of range."),null;e=this.freqMax}var t=this.freqMax-this.freqMin,e=(e-this.freqMin)/t,t=Math.round(this.alphabet.length*e);return this.alphabet[t]},e}),define("CatLab/Webremote/SonicSync/Library/sonic-server",["./ring-buffer","./sonic-coder"],function(t,i){function e(e){this.peakThreshold=(e=e||{}).peakThreshold||-65,this.minRunLength=e.minRunLength||2,this.coder=e.coder||new i(e),this.timeout=e.timeout||300,this.debug=!!e.debug,this.peakHistory=new t(16),this.peakTimes=new t(16),this.callbacks={},this.buffer="",this.state=n,this.isRunning=!1,this.iteration=0}var n=1,s=2;return e.prototype.start=function(){try{navigator.mediaDevices||console.log("No mediadevices found"),navigator.mediaDevices.getUserMedia({audio:{optional:[{echoCancellation:!1}]}}).then(this.onStream_.bind(this)).catch(this.onStreamError_.bind(this))}catch(e){console.log(e)}},e.prototype.stop=function(){this.isRunning=!1,this.track.stop()},e.prototype.on=function(e,t){"message"==e&&(this.callbacks.message=t),"character"==e&&(this.callbacks.character=t)},e.prototype.setDebug=function(e){this.debug=e;e=document.querySelector("canvas");e&&e.parentElement.removeChild(e)},e.prototype.fire_=function(e,t){"function"==typeof e&&e(t)},e.prototype.onStream_=function(e){var t;void 0!==e.getTracks()[0]?(this.track=e.getTracks()[0],t=new AudioContext,e=(this.audioContext=t).createMediaStreamSource(e),t=t.createAnalyser(),e.connect(t),this.freqs=new Float32Array(t.frequencyBinCount),this.analyser=t,this.isRunning=!0,this.raf_(this.loop.bind(this))):console.log("No microphone found.")},e.prototype.onStreamError_=function(e){console.error("Audio input error:",e)},e.prototype.getPeakFrequency=function(){for(var e=-1/0,t=-1,i=this.freqToIndex(this.coder.freqMin);i<this.freqs.length;i++)this.freqs[i]>e&&(e=this.freqs[i],t=i);return e>this.peakThreshold?this.indexToFreq(t):null},e.prototype.loop=function(){this.analyser.getFloatFrequencyData(this.freqs),(this.iteration+1)%300==0&&this.restartServerIfSanityCheckFails();var e=this.getPeakFrequency();e?(e=this.coder.freqToChar(e),this.debug&&console.log("Transcribed char: "+e),this.peakHistory.add(e),this.peakTimes.add(new Date)):(e=this.peakTimes.last())&&new Date-e>this.timeout&&(this.state=n,this.debug&&console.log("Token",this.buffer,"timed out"),this.peakTimes.clear()),this.analysePeaks(),this.debug&&this.debugDraw_(),this.isRunning&&this.raf_(this.loop.bind(this)),this.iteration+=1},e.prototype.indexToFreq=function(e){return this.audioContext.sampleRate/2/this.freqs.length*e},e.prototype.freqToIndex=function(e){var t=this.audioContext.sampleRate/2;return Math.round(e/t*this.freqs.length)},e.prototype.analysePeaks=function(){var e=this.getLastRun();e&&(this.state==n?e==this.coder.startChar&&(this.buffer="",this.state=s):this.state==s&&(e!=this.lastChar&&e!=this.coder.startChar&&e!=this.coder.endChar&&(this.buffer+=e,this.lastChar=e,this.fire_(this.callbacks.character,e)),e==this.coder.endChar)&&(this.state=n,this.fire_(this.callbacks.message,this.buffer),this.buffer=""))},e.prototype.getLastRun=function(){for(var e=this.peakHistory.last(),t=0,i=this.peakHistory.length()-2;0<=i&&this.peakHistory.get(i)==e;i--)t+=1;return t>this.minRunLength?(this.peakHistory.remove(i+1,t+1),e):null},e.prototype.debugDraw_=function(){var e=document.querySelector("canvas");e||(e=document.createElement("canvas"),document.body.appendChild(e)),e.width=document.body.offsetWidth,e.height=480,drawContext=e.getContext("2d");for(var t=0;t<this.freqs.length;t++){var i=this.freqs[t]+400,i=e.height-i-1,n=e.width/this.freqs.length;drawContext.fillStyle="black",drawContext.fillRect(t*n,i,1,1)}},e.prototype.raf_=function(e){"undefined"==typeof window||window.chrome&&chrome.extension?setTimeout(e,1e3/60):requestAnimationFrame(e)},e.prototype.restartServerIfSanityCheckFails=function(){if(this.freqs[0]<-300)console.error("freqs[0] < -300. Restarting."),this.restart();else{for(var e=!0,t=0;t<10;t++)-100==this.freqs[t]&&(e=!1);e||(console.error("freqs[0:10] == -100. Restarting."),this.restart())}},e.prototype.restart=function(){},e}),define("CatLab/Webremote/SonicSync/Library/sonic-socket",["./sonic-coder"],function(t){var i=!1;function e(e){this.coder=(e=e||{}).coder||new t,this.charDuration=e.charDuration||.5,this.coder=e.coder||new t(e),this.rampDuration=e.rampDuration||.001,this.audioContext=new i}return"undefined"!=typeof window&&(i=window.AudioContext||window.webkitAudioContext||!1),e.prototype.send=function(e,t){e=this.coder.startChar+e+this.coder.endChar;for(var i,n=0;n<e.length;n++){var s=e[n],s=this.coder.charToFreq(s),o=this.audioContext.currentTime+this.charDuration*n;this.scheduleToneAt(s,o,this.charDuration)}t&&(i=this.charDuration*e.length,setTimeout(t,1e3*i))},e.prototype.scheduleToneAt=function(e,t,i){var n=this.audioContext.createGain(),i=(n.gain.value=0,n.gain.setValueAtTime(0,t),n.gain.linearRampToValueAtTime(1,t+this.rampDuration),n.gain.setValueAtTime(1,t+i-this.rampDuration),n.gain.linearRampToValueAtTime(0,t+i),n.connect(this.audioContext.destination),this.audioContext.createOscillator());i.frequency.value=e,i.connect(n),i.start(t)},e}),define("CatLab/Webremote/SonicSync/Client",["CatLab/Webremote/Config","CatLab/Webremote/SonicSync/Library/ring-buffer","CatLab/Webremote/SonicSync/Library/sonic-coder","CatLab/Webremote/SonicSync/Library/sonic-server","CatLab/Webremote/SonicSync/Library/sonic-socket","CatLab/Webremote/Tools/Deferred"],function(t,e,i,n,s,o){function r(e){this.options=t.getAudioSyncConfig(),this.alphabet=this.options.alphabet.split(""),this.controller=e}var a=r.prototype;return a.startListener=function(){this.stop();var e=new n(this.options);e.start(),e.on("message",this.onIncomingMessage.bind(this)),this.sonicServer=e},a.startSender=function(){this.sonicSocket=new s(this.options)},a.stop=function(){this.sonicServer&&this.sonicServer.stop()},a.sync=function(){var e=new o,t=this.generateRandomSequence(this.options.length);return this.sonicSocket.send(t+this.getParityLetter(t),function(){this.controller.trigger("sync:audio",{secret:t})}.bind(this)),e.promise()},a.generateRandomSequence=function(e){for(var t,i="",n="",s=0;s<e;s++){for(;t=Math.floor(Math.random()*this.alphabet.length),(n=this.alphabet[t])===i.substr(i.length-1,1););i+=n}return i},a.getParityLetter=function(e){for(var t=0,i=e.split(""),n=0;n<i.length;n++)t+=this.alphabet.indexOf(i[n]);e=t%this.alphabet.length;return i[i.length-1]===this.alphabet[e]&&(e=(e+1)%this.alphabet.length),this.alphabet[e]},a.onIncomingMessage=function(e){var t=e.substr(0,e.length-1),i=this.getParityLetter(t);i===e[e.length-1]?this.onMessage(t):console.log("Parity check failed, expected "+i+", ignoring message")},a.onMessage=function(e){this.controller.emit("sync:audio",{secret:e})},a.generateAlphabet=function(e){for(var t="",i=0;i<Math.min(e.length,9);i++)t+=i.toString();return t},r}),define("CatLab/Webremote/Tools/ClientSniffer",[],function(){"use strict";function e(){this._canPlayWebM=null}var t=e.prototype;return t.isMobileBrowser=function(){var e,t;return!this.isCordova()&&(e=!1,t=navigator.userAgent||navigator.vendor||window.opera,!(!/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)&&!/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))||e)},t.isCordova=function(){return"undefined"!=typeof cordova},t.isInternetExplorer=function(){var e=window.navigator.userAgent,t=e.indexOf("MSIE ");return 0<t?parseInt(e.substring(t+5,e.indexOf(".",t)),10):0<e.indexOf("Trident/")?(t=e.indexOf("rv:"),parseInt(e.substring(t+3,e.indexOf(".",t)),10)):0<(t=e.indexOf("Edge/"))&&parseInt(e.substring(t+5,e.indexOf(".",t)),10)},t.supportsLocalStorage=function(){try{if(window.localStorage)return!0}catch(e){return!1}},t.canPlayWebM=function(){if(null===this._canPlayWebM){this._canPlayWebM=!1;try{var e=document.createElement("video");e.canPlayType&&(this._canPlayWebM=e.canPlayType('video/webm; codecs="vp8, vorbis"'))}catch(e){console.error(e)}}return this._canPlayWebM},new e}),define("CatLab/Webremote/Components/ImagePositionInputComponent",["jquery","CatLab/Webremote/Tools/ClientSniffer"],function(h,e){function t(e,t){this.element=t,this.remotePlayerView=e,this.positions=[],this.canvas=null,this.isLoaded=!1,this.isRotated=!1,this.buttons=null,this.pointCountContainer=null,this.draw()}var i=t.prototype;return i.draw=function(){h(this.element).html(""),this.buttons=null,this.circleRadius=this.element.attr("circleRadius")||2,this.circleStroke=this.element.attr("circleStroke")||Math.max(.5,this.circleRadius/5),this.circleStrokeColor=this.element.attr("circleStrokeColor")||"red",this.circleFillColor=this.element.attr("circleFillColor")||"rgb(255,255,0,0.3)",this.image=this.element.attr("src"),this.image&&(this.element.html('<div class="image"><img /></div>'),this.imageElement=h(this.element).find("img"),this.imageElement.on("load",function(){this.isLoaded=!0,this.resizeImage()}.bind(this)),this.imageElement.attr("src",this.image),this.imageElement.on("dragstart",function(e){e.preventDefault()}),this.svgContainer=h('<div class="pointer-container">'),this.element.find(".image").append(this.svgContainer),this.resizeSvgContainer(),this.svgContainer.click(function(e){this.svgClick(e)}.bind(this)))},i.resizeSvgContainer=function(){var e=this.imageElement;this.isRotated&&this.rotatedImageElement&&(e=this.rotatedImageElement),this.svgContainer.css({position:"absolute","z-index":1,width:e.width(),height:e.height(),left:e.position().left,top:e.position().top})},i.resizeImage=function(){this.isLoaded&&(this.element.width(),this.element.height(),this.imageElement.get(0).naturalWidth,this.imageElement.get(0).naturalHeight,e.isMobileBrowser(),this.isRotated=!1,this.element.toggleClass("rotated",this.isRotated),this.isRotated?(this.generateCanvas(),this.rotatedImageElement.show(),this.imageElement.hide()):(this.rotatedImageElement&&this.rotatedImageElement.hide(),this.imageElement.show()),this.resizeSvgContainer())},i.generateCanvas=function(){var e,t,i,n,s,o,r,a;this.rotatedImageElement||(s=this.imageElement[0],e=this.imageElement.get(0).naturalWidth,t=this.imageElement.get(0).naturalHeight,(i=document.createElement("canvas")).width=t,i.height=e,n=i.getContext("2d"),s=s,o=i.width/2,r=i.height/2,a=0-Math.PI/2,n.setTransform(1,0,0,1,o,r),n.rotate(a),n.drawImage(s,-e/2,-t/2),this.rotatedImageElement=h(i),this.element.find("div.image").append(this.rotatedImageElement))},i.imageClick=function(e){var t=e.offsetX/this.imageElement.width(),e=e.offsetY/this.imageElement.height();this.selectPosition(t,e)},i.svgClick=function(e){var t=e.offsetX/this.svgContainer.width(),e=e.offsetY/this.svgContainer.height();this.isRotated?this.selectPosition(1-e,t):this.selectPosition(t,e)},i.canvasClick=function(e){var t=e.offsetX/this.rotatedImageElement.width(),e=e.offsetY/this.rotatedImageElement.height();this.selectPosition(1-e,t)},i.selectPosition=function(e,t){0<this.getMaxPoints()&&this.positions.length>=this.getMaxPoints()||(this.positions.push({x:e,y:t}),this.drawCircles(),this.shouldConfirmPosition()?this.showSubmitButton():this.submit())},i.shouldConfirmPosition=function(){return"1"==this.element.attr("confirm-position")},i.getMinPoints=function(){return this.element.attr("min-points")&&0<parseInt(this.element.attr("min-points"))?parseInt(this.element.attr("min-points")):1},i.getMaxPoints=function(){return this.element.attr("max-points")&&0<parseInt(this.element.attr("max-points"))?parseInt(this.element.attr("max-points")):1},i.showSubmitButton=function(){this.buttons?this.positionSubmitButton():(this.buttons=h('<div class="imagemap-buttons"><button data-action="submit" class="imagemap-button pulsating">'+(2<this.getMaxPoints()?'<span class="point-counter"></span>':"")+'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 22"><path d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z"/></svg></button><button data-action="reset" class="imagemap-button"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 22"><path d="M24 20.188l-8.315-8.209 8.2-8.282-3.697-3.697-8.212 8.318-8.31-8.203-3.666 3.666 8.321 8.24-8.206 8.313 3.666 3.666 8.237-8.318 8.285 8.203z" /></button></div>'),this.element.append(this.buttons),this.positionSubmitButton(),this.buttons.find("button[data-action=submit]").click(function(){this.submit()}.bind(this)),this.buttons.find("button[data-action=reset]").click(function(){this.reset(),this.hideSubmitButton()}.bind(this)),this.pointCountContainer=this.buttons.find(".point-counter"),this.updatePointCount())},i.updatePointCount=function(){this.pointCountContainer&&(this.pointCountContainer.html(this.positions.length),this.pointCountContainer.toggleClass("insufficient",this.positions.length<this.getMinPoints()),this.buttons.find("button[data-action=submit]").toggleClass("pulsating",this.positions.length>=this.getMinPoints()),this.buttons.find("button[data-action=submit]").toggleClass("disabled",this.positions.length<this.getMinPoints()))},i.hideSubmitButton=function(){this.buttons.hide()},i.positionSubmitButton=function(){this.buttons.show(),.5<this.positions[0].x?(this.buttons.addClass("left"),this.buttons.removeClass("right")):(this.buttons.addClass("right"),this.buttons.removeClass("left"))},i.submit=function(){this.positions.length<this.getMinPoints()||this.remotePlayerView.controller.syncValue("position",{x:0<this.positions.length?this.positions[0].x:null,y:0<this.positions.length?this.positions[0].y:null,p:this.positions},this.remotePlayerView.viewId)},i.cancelSelection=function(){},i.drawCircles=function(){this.updatePointCount(),this.svgContainer.empty(),0!==this.positions.length&&this.positions.forEach(function(t){var e=this.imageElement,i=t.x,n=t.y,s=e.width(),e=e.height(),o=(this.isRotated&&this.rotatedImageElement&&(i=t.y,n=1-t.x,s=this.rotatedImageElement.width(),e=this.rotatedImageElement.height()),this.imageElement.width()/100*this.circleRadius),r=Math.max(1,this.imageElement.width()/100*this.circleStroke),a=$("<svg><circle></circle></svg>");a.click(function(e){e.preventDefault(),e.stopPropagation(),this.removePoint(t),0===this.positions.length&&this.hideSubmitButton()}.bind(this)),this.svgContainer.append(a),a.find("circle").attr({cx:o+r,cy:o+r,r:o,"stroke-width":r,stroke:this.circleStrokeColor,fill:this.circleFillColor}),a.attr({width:2*(o+r),height:2*(o+r)}),a.css({position:"absolute",left:s*i-o-r,top:e*n-o-r})}.bind(this))},i.removePoint=function(e){e=this.positions.indexOf(e);-1<e&&this.positions.splice(e,1),this.drawCircles()},i.resize=function(){this.resizeImage(),this.drawCircles()},i.update=function(){this.draw()},i.destroy=function(){},i.reset=function(){this.positions=[],this.drawCircles()},t.css=" image-position-input { display: flex; justify-content: center; align-content: center; align-items: center; } image-position-input .image { text-align: center; transform-origin: 0 0; } image-position-input .image img, image-position-input .image canvas { display: inline; max-width: 90%; max-height: 90%; max-width: 90vw; max-height: 90vh; height: auto; width: auto; } image-position-input button.imagemap-button svg { height: 48px; width: 48px; } image-position-input button.imagemap-button { margin-left: 10px; position: relative; } image-position-input button.imagemap-button.disabled svg { fill: gray; } image-position-input .imagemap-buttons { position: absolute; right: 10px; bottom: 10px; z-index: 10; } image-position-input .imagemap-buttons.left { left: 10px; right: auto; } image-position-input.rotated .imagemap-buttons { transform: rotate(-90deg); transform-origin: center right; top: 0px; right: 58px; bottom: auto; left: auto; bottom: auto; } image-position-input.rotated .imagemap-buttons.left { bottom: 0px; top: auto; right: -101px; transform-origin: center left; } image-position-input button.pulsating .point-counter { } image-position-input .point-counter { font-size: 1em; vertical-align: middle; position: absolute; top: -1em; left: -1em; border: 1px solid black; border-radius: 100%; padding: 0.5em; background: white; min-width: 1em; } image-position-input .point-counter.insufficient { border-color: red; color: red; } ",t.selector="image-position-input",t}),define("CatLab/Webremote/Components/FullscreenButtonComponent",["jquery","screenfull","CatLab/Webremote/Config"],function(e,t,i){function n(e,t,i){this.element=t,this.remotePlayerView=e,this.position=null,this.componentContainer=i,this.draw()}var s=n.prototype;return s.draw=function(){i.canFullscreen()&&t&&t.isEnabled&&!t.isFullscreen?(e(this.element).html('<svg xmlns="http://www.w3.org/2000/svg" style="display: block" width="100%" height="100%" viewBox="0 0 24 24"><path d="M6.426 10.668l-3.547-3.547-2.879 2.879v-10h10l-2.879 2.879 3.547 3.547-4.242 4.242zm11.148 2.664l3.547 3.547 2.879-2.879v10h-10l2.879-2.879-3.547-3.547 4.242-4.242zm-6.906 4.242l-3.547 3.547 2.879 2.879h-10v-10l2.879 2.879 3.547-3.547 4.242 4.242zm2.664-11.148l3.547-3.547-2.879-2.879h10v10l-2.879-2.879-3.547 3.547-4.242-4.242z"/></svg>'),e(this.element).click(function(){t.request(null,{navigationUI:"hide"})}.bind(this))):e(this.element).html("")},s.resize=function(){this.draw()},s.update=function(){this.draw()},s.destroy=function(){},n.css=" ",n.selector="fullscreen-button",n}),define("CatLab/Webremote/Components/ViewDefinedComponent",["jquery"],function(t){function e(e,t){this.element=t,this.remotePlayerView=e,this.position=null,this.draw()}var i=e.prototype;return i.draw=function(){if(this.element){t(this.element).html("");for(var e=0;e<this.content.childNodes.length;e++)t(this.element).append(this.content.childNodes[e].cloneNode(!0));this.componentContainer.attachComponents(this.remotePlayerView,this.element)}},i.update=function(){this.draw()},i.resize=function(){this.draw()},i.destroy=function(){},e.css=" ",e.selector="view-defined-component",e.content="",e}),define("CatLab/Webremote/Views/Popups/IframePopup",["CatLab/Webremote/Views/Popups/BasePopup"],function(e){function t(e){this.url=e}return(t.prototype=new e).renderContent=function(e){this.container.className+=" iframe";var t=$('<iframe src="'+this.url+'"></iframe>');$(t).css({height:"99%",width:"100%","border-width":0}),$(e).append(t),$(e).css({position:"relative",height:"100%",width:"100%","box-sizing":"border-box",overflow:"auto","-webkit-overflow-scrolling":"touch"})},t}),define("CatLab/Webremote/Components/ModalIframeLink",["jquery","CatLab/Webremote/Views/Popups/IframePopup"],function(t,i){function e(e,t,i){this.element=t,this.remotePlayerView=e,this.position=null,this.componentContainer=i,this.draw()}var n=e.prototype;return n.draw=function(){t(this.element).off("click"),t(this.element).on("click",function(){var e=t(this.element).attr("href"),e=this.remotePlayerView.stringInterpolateDataElements(e,encodeURIComponent);new i(e).render(document.body)}.bind(this))},n.resize=function(){this.draw()},n.update=function(){this.draw()},n.destroy=function(){},e.css=" ",e.selector="modal-iframe-link",e}),define("CatLab/Webremote/Views/Popups/TextPopup",["CatLab/Webremote/Views/Popups/BasePopup"],function(e){function t(e){this.message=e}return(t.prototype=new e).renderContent=function(e){var t=(t=this.message).replace(/(?:\r\n|\r|\n)/g,"<br>");e.innerHTML=t},t}),define("CatLab/Webremote/Components/TooltipComponent",["jquery","CatLab/Webremote/Views/Popups/TextPopup"],function(e,t){function i(e,t,i){this.element=t,this.remotePlayerView=e,this.position=null,this.componentContainer=i,this.draw()}var n=i.prototype;return n.draw=function(){e(this.element).off("click"),e(this.element).on("click",function(){new t(this.element.attr("data-tooltip")).render(document.body)}.bind(this))},n.resize=function(){},n.update=function(){},n.destroy=function(){},i.css=" ",i.selector="[data-tooltip]",i}),define("CatLab/Webremote/Components/VirtualKeyboardComponent",["jquery","SimpleKeyboard","CatLab/Webremote/Config"],function(t,i,n){"use strict";var s,o=null,e=0;function r(){t(".simple-keyboard").addClass("hidden"),o=null}function a(e,t,i){this.element=t,this.remotePlayerView=e,this.position=null,this.componentContainer=i,this.inputType=t.attr("type")?t.attr("type").toLowerCase():"text",this.draw()}var h=a.prototype;return h.draw=function(){(function(){var e=t.Deferred();t("<link>").appendTo("head").attr({type:"text/css",rel:"stylesheet",href:n.getVendorPath()+"simple-keyboard/build/css/index.css"}),t('<div class="simple-keyboard"></div>').appendTo("body"),s=new i.default({onChange:function(e){o&&o.onKeyboardChange(e)}.bind(this),onKeyPress:function(e){switch(e){case"{shift}":case"{lock}":t="default"===s.options.layoutName?"shift":"default",s.setOptions({layoutName:t});break;case"{numbers}":case"{abc}":t="numbers"!==s.options.layoutName?"numbers":"default",s.setOptions({layoutName:t});break;case"{ent}":r();break;case"{arrowup}":o.increaseValue(1);break;case"{arrowdown}":o.increaseValue(-1)}var t}.bind(this),layoutName:"default",layout:{default:["q w e r t y u i o p","a s d f g h j k l","{shift} z x c v b n m {backspace}","{numbers} {space} {ent}"],shift:["Q W E R T Y U I O P","A S D F G H J K L","{shift} Z X C V B N M {backspace}","{numbers} {space} {ent}"],numbers:["1 2 3","4 5 6","7 8 9","{abc} 0 {backspace}"]},physicalKeyboardHighlight:!0,disableCaretPositioning:!1,mergeDisplay:!0,display:{"{numbers}":"123","{ent}":"⇩","{escape}":"esc ⎋","{tab}":"tab ⇥","{backspace}":"⌫","{capslock}":"caps lock ⇪","{shift}":"⇧","{controlleft}":"ctrl ⌃","{controlright}":"ctrl ⌃","{altleft}":"alt ⌥","{altright}":"alt ⌥","{metaleft}":"cmd ⌘","{metaright}":"cmd ⌘","{abc}":"ABC"}}),t(".simple-keyboard").addClass("hidden"),e.promise()})(),this.element.attr("id")||this.element.attr("id","input_"+ ++e),this.element.prop("type","text"),/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&this.element.prop("readonly",!0),this.element.on("input",this.onInputChange.bind(this)),this.element.on("focus",this.onInputFocus.bind(this)),this.element.hasClass("visible")&&this.onInputFocus()},h.hideKeyboard=function(){r()},h.showKeyboard=function(){var e;"number"===(e=this).inputType?s.setOptions({inputName:e.element.attr("id"),layoutName:"numbers",layout:{default:["q w e r t y u i o p","a s d f g h j k l","{shift} z x c v b n m {backspace}","{numbers} {space} {ent}"],numbers:["1 2 3 {arrowup}","4 5 6 {arrowdown}","7 8 9 "+1.1.toLocaleString().substring(1,2),"{backspace} 0 {ent}"]}}):s.setOptions({inputName:e.element.attr("id"),layoutName:"default",layout:{default:["q w e r t y u i o p","a s d f g h j k l","{shift} z x c v b n m {backspace}","{numbers} {space} {ent}"],shift:["Q W E R T Y U I O P","A S D F G H J K L","{shift} Z X C V B N M {backspace}","{numbers} {space} {ent}"],numbers:["1 2 3","4 5 6","7 8 9","{abc} 0 {backspace}"]}}),t(".simple-keyboard").removeClass("hidden"),o=e,s.setInput(e.element.val(),e.element.attr("id"))},h.onKeyboardChange=function(e){var t;this.element.val(e),this.element.trigger("change"),this.element.attr("data-value-realtime")&&(t=this.element.attr("data-value-id"))&&this.remotePlayerView.controller.syncValue(t,e,this.remotePlayerView.viewId)},h.onInputChange=function(){s.setInput(this.element.val(),this.element.attr("id"))},h.onInputFocus=function(){this.showKeyboard()},h.setInputCaretPosition=function(e){this.element[0].setSelectionRange&&(this.element[0].focus(),this.element[0].setSelectionRange(e,e))},h.increaseValue=function(e){var t;"number"===this.inputType&&(t=(t=parseFloat(this.element.val()))||0,this.element.val(t+e))},h.submit=function(){this.hideKeyboard()},h.resize=function(){this.draw()},h.update=function(){this.draw()},h.destroy=function(){this.hideKeyboard()},a.css=" .simple-keyboard { position: fixed; bottom: 0; display: block; } .simple-keyboard.hidden { display: none; } ",a.selector="input.virtual",a}),define("CatLab/Webremote/Components/TimerComponent",["jquery"],function(t){function e(e,t){this.element=t,this.remotePlayerView=e,this.draw(),this.countdownInterval=setInterval(function(){this.tick()}.bind(this),100),this.startDate=Date.now(),this.targetDate=null,this.counterHtml=null,this.progessBar=null}var i=e.prototype;return i.draw=function(){var e;t(this.element).html(""),this.targetDate=this.element.attr("to"),this.targetDate&&(this.element.attr("start")&&(this.startDate=this.element.attr("start")),e=t('<div class="timer-container"></div>'),this.counterHtml=t('<div class="countdown"></div>'),e.append(this.counterHtml),this.progessBar=t('<div class="progress-bar">&nbsp;</div>'),e.append(this.progessBar),t(this.element).append(e))},i.tick=function(){var e,t;this.targetDate&&this.counterHtml&&this.progessBar&&((e=this.targetDate-Date.now())<0?this.counterHtml.html("0"):(t=(Date.now()-this.startDate)/(this.targetDate-this.startDate)*100,this.counterHtml.html(Math.ceil(e/1e3)),this.progessBar.css("width",t+"%")))},i.resize=function(){},i.update=function(){this.draw()},i.clearInterval=function(){this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null)},i.destroy=function(){this.clearInterval()},e.css=" timer-countdown { position: fixed; bottom: 0px; left: 0px; width: 100%; color: white; z-index: 1000; } timer-countdown .progress-bar { position:absolute; height: 3px; bottom: 0; background: #eca93b; } timer-countdown .countdown { display: none; } ",e.selector="timer-countdown",e}),define("CatLab/Webremote/Components/SmileyFlingerComponent",["jquery","CatLab/Webremote/Views/Blocks/CurrentSmiley"],function(e,n){function t(e,t,i){this.element=t,this.remotePlayerView=e,this.position=null,this.componentContainer=i,this.smileySlinger=new n(i.Webremote,!0,!0,!1),this.draw()}var i=t.prototype;return i.draw=function(){this.smileySlinger.render(this.element)},i.resize=function(){this.draw()},i.update=function(){this.draw()},i.destroy=function(){},t.css=" ",t.selector="smiley-flinger",t}),define("CatLab/Webremote/Components/Components",["jquery","./ImagePositionInputComponent","./FullscreenButtonComponent","./ViewDefinedComponent","./ModalIframeLink","./TooltipComponent","./VirtualKeyboardComponent","./TimerComponent","./SmileyFlingerComponent"],function(s,t,i,o,n,r,a,h,l){function e(e){this.components=[t,i,n,r,a,h,l],this.Webremote=e,this.viewDefinedComponents=[],this.existingComponents=[]}var c=e.prototype;return c.initialize=function(){for(var e=0;e<this.components.length;e++)this.initializeComponent(this.components[e])},c.initializeComponent=function(e){e.css;var t=document.createElement("style");t.attributes.type="text/css",t.innerHTML=e.css,document.head.appendChild(t)},c.resetViewDefinedComponents=function(){for(var e=0;e<this.viewDefinedComponents.length;e++)this.removeComponent(this.viewDefinedComponents[e])},c.removeComponent=function(e){for(var t=0;t<this.components.length;t++)if(this.components[t].selector===e)return void this.components.splice(t,1)},c.addComponent=function(e){0<=this.components.indexOf(e)||(this.components.push(e),this.initializeComponent(e))},c.addViewDefinedComponent=function(e,n){for(var t=0;t<this.components.length;t++)if(this.components[t].selector===e)return;function i(e,t,i){this.element=t,this.remotePlayerView=e,this.position=null,this.content=n,this.componentContainer=i,this.draw()}this.viewDefinedComponents.push(e),i.prototype=new o,i.selector=e,i.content=n,this.components.push(i)},c.attach=function(e,t,i){(i=void 0===i?!0:i)&&(this.existingComponents.forEach(function(e){e.destroy()}.bind(this)),this.existingComponents=[]),this.attachComponents(e,t)},c.resize=function(){this.existingComponents.forEach(function(e){e.resize()}.bind(this))},c.update=function(){this.existingComponents.forEach(function(e){e.update()}.bind(this))},c.attachComponents=function(e,t){for(var i=0;i<this.components.length;i++)try{this.attachComponent(e,t,this.components[i])}catch(e){console.log(e)}},c.attachComponent=function(i,e,n){s(e).find(n.selector).each(function(e,t){t=new n(i,s(t),this);this.existingComponents.push(t)}.bind(this))},e}),!function(){!function(e,t){"use strict";"function"==typeof define&&define.amd?define("viewport-units-buggyfill",[],t):"object"==typeof exports?module.exports=t():e.viewportUnitsBuggyfill=t()}(this,function(){"use strict";var a,h,l,i,e,n=!1,t=window.navigator.userAgent,c=/([+-]?[0-9.]+)(vh|vw|vmin|vmax)/g,s=/(https?:)?\/\//,u=[].forEach,d=/MSIE [0-9]\./i.test(t),p=/MSIE [0-8]\./i.test(t),f=-1<t.indexOf("Opera Mini"),g=/(iPhone|iPod|iPad).+AppleWebKit/i.test(t)&&(e=t.match(/OS (\d)/))&&1<e.length&&parseInt(e[1])<10,m=-1<t.indexOf(" Android ")&&-1<t.indexOf("Version/")&&parseFloat((t.match("Android ([0-9.]+)")||[])[1])<=4.4,d=d||!!navigator.userAgent.match(/MSIE 10\.|Trident.*rv[ :]*1[01]\.| Edge\/1\d\./);try{new v("test")}catch(a){var v=function(e,t){var i;return t=t||{bubbles:!1,cancelable:!1,detail:void 0},(i=document.createEvent("CustomEvent")).initCustomEvent(e,t.bubbles,t.cancelable,t.detail),i};v.prototype=window.Event.prototype,window.CustomEvent=v}function b(){n&&(o(),setTimeout(function(){i.textContent=y(),i.parentNode.appendChild(i),window.dispatchEvent(new v("viewport-units-buggyfill-style"))},1))}function o(){return l=[],u.call(document.styleSheets,function(e){var t=function(e){try{if(!e.cssRules)return}catch(e){if("SecurityError"!==e.name)throw e;return}for(var t=[],i=0;i<e.cssRules.length;i++){var n=e.cssRules[i];t.push(n)}return t}(e);!t||"patched-viewport"===e.ownerNode.id||"ignore"===e.ownerNode.getAttribute("data-viewport-units-buggyfill")||e.media&&e.media.mediaText&&window.matchMedia&&!window.matchMedia(e.media.mediaText).matches||u.call(t,r)}),l}function r(i){if(7===i.type){var e;try{e=i.cssText}catch(e){return}c.lastIndex=0,c.test(e)&&!s.test(e)&&(l.push([i,null,e]),a.hacks)&&a.hacks.findDeclarations(l,i,null,e)}else i.style?u.call(i.style,function(e){var t=i.style.getPropertyValue(e);i.style.getPropertyPriority(e)&&(t+=" !important"),c.lastIndex=0,c.test(t)&&(l.push([i,e,t]),a.hacks)&&a.hacks.findDeclarations(l,i,e,t)}):i.cssRules&&u.call(i.cssRules,function(e){r(e)})}function y(){var e=window.innerHeight,t=window.innerWidth;h={vh:e,vw:t,vmax:Math.max(t,e),vmin:Math.min(t,e)};var n,s,o=[],r=[];return l.forEach(function(e){var e=function(e,t,i){var n=[];i=i.replace(c,A),a.hacks&&(i=a.hacks.overwriteDeclaration(e,t,i)),t&&(n.push(e.selectorText),i=t+": "+i+";");for(var s=e.parentRule;s;)s.media?n.unshift("@media "+s.media.mediaText):s.conditionText&&n.unshift("@supports "+s.conditionText),s=s.parentRule;return{selector:n,content:i}}.apply(null,e),t=e.selector.length?e.selector.join(" {\n")+" {\n":"",i=new Array(e.selector.length+1).join("\n}");t&&t===n?(t&&!n&&(n=t,s=i),r.push(e.content)):(r.length&&(o.push(n+r.join("\n")+s),r.length=0),t?(n=t,s=i,r.push(e.content)):(o.push(e.content),s=n=null))}),r.length&&o.push(n+r.join("\n")+s),f&&o.push("* { content: normal !important; }"),o.join("\n\n")}function A(e,t,i){i=h[i];return parseFloat(t)/100*i+"px"}function w(e){return e.slice(0,e.indexOf("/",e.indexOf("://")+3))}return{version:"0.6.1",findProperties:o,getCss:y,init:function(e){if(!n){if((a=(e=!0===e?{force:!0}:e)||{}).isMobileSafari=g,a.isBadStockAndroid=m,!a.ignoreVmax||a.force||p||(d=!1),p||!a.force&&!g&&!d&&!m&&!f&&(!a.hacks||!a.hacks.required(a)))return window.console&&p&&console.info("viewport-units-buggyfill requires a proper CSSOM and basic viewport unit support, which are not available in IE8 and below"),{init:function(){}};var t,o,r;window.dispatchEvent(new v("viewport-units-buggyfill-init")),a.hacks&&a.hacks.initialize(a),n=!0,(i=document.createElement("style")).id="patched-viewport",document[a.appendToBody?"body":"head"].appendChild(i),t=function(){function e(){var e=this,t=arguments;clearTimeout(s),s=setTimeout(function(){i.apply(e,t)},n)}var i,n,s;i=b,n=a.refreshDebounceWait||100;window.addEventListener("orientationchange",e,!0),window.addEventListener("pageshow",e,!0),(a.force||d||function(){try{return window.self!==window.top}catch(e){return 1}}())&&(window.addEventListener("resize",e,!0),a._listeningToResize=!0),a.hacks&&a.hacks.initializeEvents(a,b,e),b()},o=0,r=function(){--o||t()},u.call(document.styleSheets,function(e){if(e.href&&w(e.href)!==w(location.href)&&"ignore"!==e.ownerNode.getAttribute("data-viewport-units-buggyfill")){o++;var t=e.ownerNode,i=r,e=t.href,n=i,s=new XMLHttpRequest;if("withCredentials"in s)s.open("GET",e,!0);else{if("undefined"==typeof XDomainRequest)throw new Error("cross-domain XHR not supported");(s=new XDomainRequest).open("GET",e)}s.onload=function(){var e=document.createElement("style");e.media=t.media,e.setAttribute("data-href",t.href),e.textContent=this.responseText,t.parentNode.replaceChild(e,t),i()},s.onerror=n,s.send()}}),o||t()}},refresh:b}})}(),!function(){!function(e,t){"use strict";"function"==typeof define&&define.amd?define("viewport-units-buggyfill.hacks",[],t):"object"==typeof exports?module.exports=t():e.viewportUnitsBuggyfillHacks=t()}(this,function(){"use strict";var r=/calc\(/g,a=/["']/g,e=window.navigator.userAgent,n=(n=/MSIE [0-9]\./i.test(e))||!!navigator.userAgent.match(/MSIE 10\.|Trident.*rv[ :]*1[01]\.| Edge\/1\d\./);return{required:function(e){return e.isMobileSafari||n},initialize:function(){},initializeEvents:function(e,t,i){e.force||n&&!e._listeningToResize&&(window.addEventListener("resize",i,!0),e._listeningToResize=!0)},findDeclarations:function(e,t,i,n){var s,o;null!==i&&(s=e,o=t,e=n,"content"===i)&&-1<e.indexOf("viewport-units-buggyfill")&&e.replace(a,"").split(";").forEach(function(e){var t,e=e.split(":");2===e.length&&"viewport-units-buggyfill"!==(t=e[0].trim())&&(e=e[1].trim(),s.push([o,t,e]),r.test(e))&&(e=e.replace(r,"-webkit-calc("),s.push([o,t,e]))})},overwriteDeclaration:function(e,t,i){return i=n&&"filter"===t?i.replace(/px/g,""):i}}})}(),define("CatLab/Webremote/Controllers/Webremote",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Tracker","CatLab/Webremote/Tools/Cookies","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Smileys","CatLab/Webremote/Tools/Preloader","CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Views/Popups/AuthenticationPopup","CatLab/Webremote/Views/Popups/SelectSmileyPopup","CatLab/Webremote/Views/Blocks/CurrentUser","CatLab/Webremote/Views/Blocks/CurrentSmiley","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/HashParser","CatLab/Webremote/Views/Alert","CatLab/Webremote/Views/Welcome","CatLab/Webremote/Views/ConnectionTrouble","CatLab/Webremote/Views/GamePaused","CatLab/Webremote/Synchronization/ClientRemoteView","CatLab/Webremote/Synchronization/DataSynchronizer","CatLab/Webremote/Synchronization/EventHandler","CatLab/Webremote/Synchronization/CombinedEventHandler","CatLab/Webremote/Providers/SocketIO","CatLab/Webremote/SonicSync/Client","CatLab/Webremote/Components/Components","viewport-units-buggyfill","viewport-units-buggyfill.hacks","screenfull"],function(Config,Tracker,Cookies,Tools,Deferred,Smileys,Preloader,OAuth2,AuthenticationPopup,SelectSmileyPopup,CurrentUser,CurrentSmiley,UsersCollection,Storage,i18n,HashParser,AlertPopup,WelcomePopup,ConnectionTroubleView,GamePausedView,ClientRemoteView,DataSynchronizer,EventHandler,CombinedEventHandler,SocketIOProvider,SonicSyncClient,Components,ViewportUnitsBuggyFill,ViewportUnitsBuggyFillHacks,screenfull){"use strict";var domelement=null,user,dynamicStylesheet,triggers=[];function addEvent(e,t,i){e.addEventListener?e.addEventListener(t,i,!1):e.attachEvent?e.attachEvent("on"+t,i):e["on"+t]=i}var Webremote=function(){};function getParameterByName(e,t){t=t||window.location.href,e=e.replace(/[\[\]]/g,"\\$&");e=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(t);return e?e[2]?decodeURIComponent(e[2].replace(/\+/g," ")):"":null}return Webremote.prototype={provider:null,element:null,gamedata:null,stylesheets:[],links:[],scripts:[],views:{},userData:null,userEvents:null,groupData:null,groupEvents:null,smiley:null,isOauth2Set:!1,color:null,_currentSmileyViews:[],_currentViewId:null,_currentViewViewId:null,_currentViewGroupId:null,_currentView:null,_connectingDfd:null,_connectedToken:null,_headless:!1,_allowAuthentication:!0,initialize:function(e,t){void 0!==t.token?this.token=t.token:this.token=getParameterByName("token"),void 0===t&&(t={}),this.setContainer(e),this.showLoading(),this.sonicSync=null,this.components=new Components(this),this.components.initialize(),this._initialize(t).then(function(){setTimeout(function(){void 0===this.provider.showTokenForm||this.provider.showTokenForm?(this.showTokenForm(),this.trigger("remote:initialized")):this.provider.noTokenConnect()}.bind(this),2),ViewportUnitsBuggyFill.init({hacks:ViewportUnitsBuggyFillHacks})}.bind(this)),this.setPlayerColor("#000000"),this.setOrientation(),addEvent(window,"resize",this.setOrientation.bind(this))},headless:function(e){return(e=void 0===e?{}:e).headless=!0,this._initialize(e)},_initialize:function(t){var i=new Deferred;return Config.set(t),Config.initialize(function(){Tracker.track("App","Initialize"),void 0===t.provider&&(t.provider=new SocketIOProvider),void 0!==t.headless&&(this._headless=!!t.headless),this.provider=t.provider,this.smileys=new Smileys(this.provider),this.provider.initPlayer(this),this.provider.on("disconnect",function(e){var t=this.getConnectionIssuesView();console.log("Connection lost... reconnecting"),t.show(),t.text(i18n.t("Connection lost... reconnecting"))}.bind(this)),this.provider.on("reconnect",function(e){this.provider.emit("user:reconnect",{id:this.gamedata.id,accessToken:this.gamedata.accessToken}),this.getConnectionIssuesView().hide()}.bind(this)),this.provider.on("user:error",function(e){var t;this._connectingDfd&&(t=this._connectingDfd,this._connectingDfd=null,t.reject(e.message))}.bind(this)),this.provider.on("user:initialize",function(e){this.gamedata=e,this.provider.setUserId(e.id),this._storeGameData(e),this._connectingDfd&&(e=this._connectingDfd,this._connectingDfd=null,e.resolve())}.bind(this)),this.provider.on("view:load",function(e){this.loadViewsXML(e.xml)}.bind(this)),this.provider.on("view:reset",function(e){this.resetViews()}.bind(this)),this.provider.on("config:set",function(e){if(Config.set(e),this.sonicSync&&this.sonicSync.stop(),Config.useAudioSync())try{this.sonicSync=new SonicSyncClient(this),this.sonicSync.startListener()}catch(e){console.error(e)}}.bind(this)),this.provider.on("view:set",function(e){this.showView(e.id,e.viewId,e.group),this.handleCombinedMessages(e)}.bind(this)),this.provider.on("button:label",function(e){this.setLabel(e)}.bind(this)),this.provider.on("button:decorate",function(e){this.setClass(e)}.bind(this)),this.provider.on("oauth:set",function(e){Config.supportsAuthentication()&&(OAuth2.initialize(e),this.isOauth2Set=!0,UsersCollection.initialize(this,OAuth2),HashParser.getParameter("access_token"))&&(e=HashParser.getParameter("access_token"),UsersCollection.addFromAccessToken(e,function(e){e&&this.setUser(e)}.bind(this)),HashParser.clear())}.bind(this)),this.provider.on("color:set",function(e){this.setPlayerColor(e.color)}.bind(this)),this.provider.on("user:smiley",function(e){this.setSmiley(e.smiley)}.bind(this)),this.provider.on("smileys:taken",function(e){this.smileys.setTakenSmileys(e.smileys)}.bind(this)),this.provider.on("game:disconnect",function(e){AlertPopup(i18n.t("You have been disconnected from the game."),function(){window.location.reload()})}.bind(this)),this.provider.on("dom:append",function(e){this.domAppend(e)}.bind(this)),this.provider.on("dom:replace",function(e){this.domReplace(e)}.bind(this)),this.provider.on("dom:attribute",function(e){this.domAttribute(e)}.bind(this)),this.provider.on("dom:alert",function(e){AlertPopup(e.message)}),this.provider.on("dom:open",function(e){void 0!==e.url&&window.open(e.url)}),this.provider.on("value:change",function(e){this.changeValue(e)}.bind(this)),this.provider.on("device:vibrate",function(e){this.vibrate(e)}.bind(this)),this.provider.on("game:pause",function(e){this.pause(e)}.bind(this)),this.provider.on("game:unpause",function(e){this.unpause(e)}.bind(this)),this.preloader=new Preloader(this.provider),this.userData=new DataSynchronizer("user",this.emit.bind(this),"client"),this.groupData=new DataSynchronizer("group",this.emit.bind(this),"client"),this.userEvents=new EventHandler("user",this.emit.bind(this)),this.groupEvents=new EventHandler("group",this.emit.bind(this));var e=[this.userData,this.groupData],n=[this.userEvents,this.groupEvents];DataSynchronizer.eventsToListenFor.forEach(function(i){this.provider.on(i,function(t){e.forEach(function(e){e.checkNamespace(t)&&e.processMessage(i,t)})}.bind(this))}.bind(this)),EventHandler.eventsToListenFor.forEach(function(i){this.provider.on(i,function(t){n.forEach(function(e){e.checkNamespace(t)&&e.processMessage(i,t)})}.bind(this))}.bind(this)),this.events=new CombinedEventHandler,this.events.addHandler(this.userEvents),this.events.addHandler(this.groupEvents),i.resolve()}.bind(this)),i.promise()},reconnect:function(e){this.gamedata?(this.provider.emit("user:reconnect",{id:this.gamedata.id,accessToken:this.gamedata.accessToken}),this.provider.once("user:reconnect",function(){e()})):e()},connectProvider:function(e){return this.provider.tokenConnect(e)},_storeGameData:function(){var e=new Deferred,t=this._connectedToken;return Storage.set("gamestate_"+t,this.gamedata,function(){e.resolve()},864e5),e.promise()},_restoreGameData:function(){var t=new Deferred,e=this._connectedToken;return Storage.get("gamestate_"+e,function(e){e?(this.gamedata=e,t.resolve(!0)):t.resolve(!1)}.bind(this)),t.promise()},handleCombinedMessages:function(e){for(var t=[{name:"button:label",method:this.setLabel.bind(this)},{name:"button:decorate",method:this.setClass.bind(this)}],i=0;i<t.length;i++){var n=t[i].name,s=t[i].method;if(void 0!==e[n])for(var o=0;o<e[n].length;o++)s(e[n][o])}},emit:function(e,t){this.provider.toMaster(e,t)},getConnectionIssuesView:function(){return void 0===this.connectionTrouble&&(this.connectionTrouble=new ConnectionTroubleView),this.connectionTrouble},setGamePausedView:function(e){this.gamePaused=e},getGamePausedView:function(){return void 0===this.gamePaused?new GamePausedView:this.gamePaused},setContainer:function(e){domelement=e,this.element=e,dynamicStylesheet=document.createElement("style"),document.body.appendChild(dynamicStylesheet),document.body.className="catlab-remote"},on:function(e,t){void 0===triggers[e]&&(triggers[e]=[]),triggers[e].push(t)},trigger:function(e){var t=[].slice.apply(arguments);if(t.shift(),void 0!==triggers[e])for(var i=0;i<triggers[e].length;i++)triggers[e][i].apply(this,t)},loadViews:function(e,t){var i;t=t||function(){},this._headless?t():((i=new XMLHttpRequest).open("GET",Config.getProxy()+e,!0),i.onreadystatechange=function(){4==i.readyState&&200==i.status&&(this.loadViewsXML(i.responseText),t())}.bind(this),i.send())},resetViews:function(){this.views={},this.components.resetViewDefinedComponents();for(var e=0;e<this.stylesheets.length;e++)try{var t=this.stylesheets[e];t.parentNode&&t.parentNode.removeChild(t)}catch(e){console.error(e)}for(e=0;e<this.links.length;e++)try{var i=this.links[e];i.parentNode&&i.parentNode.removeChild(i)}catch(e){console.error(e)}this.stylesheets=[]},loadViewsXML:function(e,t){if(t=t||function(){},!this._headless){var i;if(Tracker.track("App","Load Views"),window.DOMParser?i=(new DOMParser).parseFromString(e,"text/xml"):((i=new ActiveXObject("Microsoft.XMLDOM")).async=!1,i.loadXML(e)),0===i.getElementsByTagName("views").length)return!1;for(var n=i.getElementsByTagName("views").item(0).getElementsByTagName("component"),s=0;s<n.length;s++)this.loadComponent(n.item(s));for(var o=i.getElementsByTagName("views").item(0).getElementsByTagName("view"),s=0;s<o.length;s++)this.loadView(o.item(s));var r=i.getElementsByTagName("views").item(0).getElementsByTagName("stylesheet");for(s=0;s<r.length;s++){var a=r.item(s),h=document.createElement("style");this.stylesheets.push(h),h.innerHTML=a.textContent,document.body.appendChild(h)}var l=i.getElementsByTagName("views").item(0).getElementsByTagName("link");for(s=0;s<l.length;s++){var c=l.item(s).getAttribute("href"),u=document.createElement("link");u.rel="stylesheet",u.type="text/css",u.media="all",u.href=c,this.links.push(u),document.getElementsByTagName("head")[0].appendChild(u)}for(r=i.getElementsByTagName("views").item(0).getElementsByTagName("style"),s=0;s<r.length;s++)this.stylesheets.push(r.item(s)),document.body.appendChild(r.item(s));var d=i.getElementsByTagName("views").item(0).getElementsByTagName("script");for(s=0;s<d.length;s++)this.scripts.push(d.item(s)),this.evalScript(d.item(s));return ViewportUnitsBuggyFill.refresh(),t(),!0}t()},evalScript:function(xml){var aWebremote=Webremote;!function(){try{var Webremote=aWebremote;eval(xml.textContent)}catch(e){console.error(e)}}.bind(window)()},loadView:function(e){var t=e.getAttribute("id"),i=document.createElement("div"),n=!1;e.getAttribute("iframe")&&"false"!==e.getAttribute("iframe").toLowerCase()&&(n=!0);for(var s=0;s<e.childNodes.length;s++)i.appendChild(e.childNodes[s].cloneNode(!0));i.id=t,i.className="view "+e.className,this.views[t]={iframe:n,html:(new XMLSerializer).serializeToString(i)},this._currentViewId===t&&this.showView(this._currentViewId,this._currentViewViewId,this._currentViewGroupId)},loadComponent:function(e){for(var t=e.getAttribute("id"),i=document.createElement("div"),n=0;n<e.childNodes.length;n++)i.appendChild(e.childNodes[n].cloneNode(!0));this.components.addViewDefinedComponent(t,i)},showView:function(e,t,i){var n,s;this._headless||(this._currentView&&this._currentView.destroy(),"remote:authenticate"!==e?(this._currentViewId=e,this._currentViewViewId=t,this._currentViewGroupId=i,void 0!==this.views[e]?(n=(i?this.groupData:this.userData).getFromIdentifier("view:"+t),s=this.views[e],this._currentView=new ClientRemoteView(this,t,e,i,n,s.iframe),this._currentView.html=s.html,this._currentView.render(this.element),this.updateUser(),Tracker.track("App","Show View",e),this.trigger("remote:view:show",{id:e,view:this._currentView}),this.trigger("view:set",this._currentView)):this.element.innerHTML='<div class="loading"><p>Please wait, loading...</p><p>(Loading view: '+e+")</div></p>"):this.showAuthenticationView())},updateUser:function(){Tracker.track("App","Set user");var e=document.getElementById("authentication");e&&new CurrentUser(this).render(e),this._currentSmileyViews=[],Config.useSmileys()?(this.setSmileySelectViews(),this.setSmileyViews()):this.removeSmileyViews()},setSmileySelectViews:function(){for(var e=document.getElementsByTagName("smiley-select"),t=0;t<e.length;t++){var i=!e[t].hasAttribute("flingable")||"false"!==e[t].getAttribute("flingable"),i=new CurrentSmiley(this,!0,i);i.render(e[t]),this.smiley&&i.setSmiley(this.smiley),this._currentSmileyViews.push(i)}},setSmileyViews:function(){for(var e=document.getElementsByTagName("smiley"),t=0;t<e.length;t++){var i=e[t].hasAttribute("changeable")&&"false"!==e[t].getAttribute("changeable"),n=e[t].hasAttribute("flingable")&&"false"!==e[t].getAttribute("flingable"),i=new CurrentSmiley(this,i,n);i.render(e[t]),this.smiley&&i.setSmiley(this.smiley),this._currentSmileyViews.push(i)}},removeSmileyViews:function(){for(var e=document.getElementsByTagName("smiley-select"),t=0;t<e.length;t++)e[t].parentNode.removeChild(e[t]);for(e=document.getElementsByTagName("smiley"),t=0;t<e.length;t++)e[t].parentNode.removeChild(e[t]);for(var i=document.getElementsByClassName("if-config-smileys"),t=0;t<i.length;t++)i[t].parentNode.removeChild(i[t])},popup:function(e){new WelcomePopup(e).render(domelement)},showAuthenticationPopup:function(e){e=e||!1;var t=new AuthenticationPopup(this);t.render(domelement),e&&t.connect()},showSmileyPopup:function(e,t){void 0===e&&(e=function(e){this.selectSmiley(e)}.bind(this)),new SelectSmileyPopup(this,e,t=void 0===t?!0:t).render(domelement)},showAuthenticationView:function(){this.element&&(this.element.innerHTML='<p id="catlab-message">Please login.</p>',OAuth2.link({fullscreen:!0}).then(function(e){e?(this.setUser(e),this.element.innerHTML='<p id="catlab-message">Welcome! You may now close this screen.</p>',window.close()):this.showAuthenticationView()}.bind(this)))},buttonDown:function(e,t){this.provider.toMaster("button:down",{id:e})},buttonUp:function(e,t,i){this.provider.toMaster("button:up",{id:e,click:i=void 0!==i&&i}),this.trigger("user:interaction")},syncValue:function(e,t,i){return this.provider.toMaster("value:change",{id:e,value:t,viewId:i}),!1},showLoading:function(){this.element&&(this.element.innerHTML='<p id="catlab-loading">Connecting...</p>')},showTokenForm:function(){function t(e){var t=i.connect(e);e!==Cookies.getItem("last_token")&&Cookies.removeItem("last_token"),t.then(function(){Cookies.setItem("last_token",e,.25)}.bind(this)),t.fail(function(e){i.showTokenForm(),screenfull.enabled&&screenfull.isFullscreen&&screenfull.exit(),AlertPopup(e)}),i.showLoading(),i.trigger("remote:token:submit"),i.trigger("user:interaction")}var e=document.createElement("form"),i=this,n="undefined"!=typeof CONFIG_TOKEN?CONFIG_TOKEN:null,s=(n||(n=this.token,this.token=null),!1),o=(n&&(s=!0),Cookies.getItem("last_token")),o=(!n&&o&&(n=o),document.createElement("div")),r=(o.id="catlab-token-form",e.innerHTML="",e.appendChild(o),document.createElement("input")),r=(r.type="tel",r.pattern="[0-9 ]{6,10}",r.name="token",r.id="token",r.value=n||"",r.placeholder=i18n.t("Enter code"),r.addEventListener("click",function(){this.setSelectionRange(0,this.value.length)}),o.appendChild(r),document.createElement("button"));r.innerHTML=i18n.t("Connect"),o.appendChild(r);s&&t(n),e.onsubmit=function(e){e.preventDefault();e=document.getElementById("token").value;return t(e),!1},this.element.innerHTML="",this.element.appendChild(e)},requestFullScreen:function(){screenfull.enabled&&!screenfull.isFullscreen&&screenfull.request()},connect:function(e){return e=e.replace(" ",""),null!==this._connectingDfd&&(this._connectingDfd.reject(),this._connectingDfd=null),this._connectingDfd=new Deferred,this._connectedToken=e,this._connectingDfd.fail(function(){this.provider.disconnect(!1)}.bind(this)),this.connectProvider(e).fail(function(){setTimeout(function(){this._connectingDfd.reject(i18n.t("Game not found. Please check your token."))}.bind(this),1)}.bind(this)).then(function(t){var i=!0;"0"===getParameterByName("reconnect")&&(i=!1),this._restoreGameData().then(function(e){e&&i?this.reconnect(function(){this._connectingDfd.resolve()}.bind(this)):this.provider.emit("user:join",{token:t})}.bind(this))}.bind(this)),this._connectingDfd.promise()},setLabel:function(e){this._currentView&&this._currentView.setLabel(e.id,Tools.nl2br(Tools.sanitize(e.label)))},setClass:function(e){this._currentView&&this._currentView.setClass(e.id,e.styles)},setPlayerColor:function(e){if(this.color=e,void 0!==dynamicStylesheet&&dynamicStylesheet){var t,i,n="",s=(dynamicStylesheet.innerHTML=(n+=".player-color-border { border-color:"+e+"; }")+(".player-color-background { background-color: "+e+"; }")+(".player-color { color: "+e+"; }"),{"theme-color":e,"msapplication-navbutton-color":e,"apple-mobile-web-app-status-bar-style":e});for(t in s)s.hasOwnProperty(t)&&((i=document.createElement("meta")).httpEquiv=t,i.content=s[t],document.getElementsByTagName("head")[0].appendChild(i))}},setSmiley:function(t){this.smiley=t,this._currentSmileyViews.forEach(function(e){e.setSmiley(t)})},getSmiley:function(){return this.smiley},selectSmiley:function(e){this.provider.toMaster("user:smiley",{smiley:e})},setUser:function(e){user=e,this.updateUser(),user?(this.provider.toMaster("user:login",{access_token:user.getAccessToken()}),Storage.set("currentuser",user.getAccessToken()),this.getSmiley()&&(e=user.getAvatarSmiley())&&this.selectSmiley(e)):(this.provider.toMaster("user:logout"),Storage.set("currentuser",null))},getUser:function(){return user},listViews:function(){var e,t=[];for(e in this.views)this.views.hasOwnProperty(e)&&t.push({name:e});return t},getRandomText:function(e,t){var i="abcdefghijklmnopqrstuvwyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";void 0===t&&(t=40);for(var n="",s=(e=void 0===e?10:e)+Math.random()*t,o=0;o<s;o++)n+=i.charAt(Math.floor(Math.random()*i.length)),.8<Math.random()&&(o++,n+=" ");return n},randomLabels:function(e,t){for(var i=domelement.querySelectorAll("[data-button-label]"),n=0;n<i.length;n++)i[n].innerHTML=this.getRandomText(e,t);this.update()},setOrientation:function(){if(window.innerHeight>=window.innerWidth)try{document.body.classList.remove("landscape"),document.body.classList.add("portrait")}catch(e){document.body.className="portrait"}else try{document.body.classList.add("landscape"),document.body.classList.remove("portrait")}catch(e){document.body.className="landscape"}this.components.resize()},domAppend:function(e){this._currentView&&(this._currentView.domAppend(e.id,e.html),this.components.update())},domReplace:function(e){this._currentView&&(this._currentView.domReplace(e.id,e.html),this.components.update())},domAttribute:function(e){this._currentView&&(this._currentView.domAttribute(e.id,e.name,e.value),this.components.update())},changeValue:function(e){this._currentView&&this._currentView.changeValue(e)},vibrate:function(e){this._currentView&&this._currentView.vibrate(e)},pause:function(e){void 0===this._gamePausedView&&(this._gamePausedView=this.getGamePausedView()),this._gamePausedView.show()},unpause:function(e){void 0!==this._gamePausedView&&this._gamePausedView.hide()},log:function(e){Config.debug()&&console.log(e)},canAuthenticate:function(){return this.isOauth2Set},getGroupIds:function(){return void 0===this.gamedata.groups?[]:this.gamedata.groups},resolveDataAttribute:function(e){if("token"===e)return this._connectedToken;var i,e=(e="data."===e.substring(0,5)?e.substring(5):e).split("."),t=(2!==e.length&&e.unshift("any"),e.shift()),e=e.shift();if(t===user)return this.userData.getFromIdentifier("user").get(e);if("group"===t.substring(0,5)){var n,s=this.getGroupIds();if(0===s.length)return null;if("group"===t)return this.groupData.getFromIdentifier("group:"+s[0]).get(e);if("]"===t.substring(t.length,1))return void 0===s[n=t.substr(t.substring(6,t.length-1))]?null:this.groupData.getFromIdentifier("group:"+s[n]).get(e)}return"any"===t&&(i=["user."+e],this.getGroupIds().forEach(function(e,t){i.push("group["+t+"]")}.bind(this))),null}},Webremote}),define("CatLab/Webremote/Tools/Colorwheel",[],function(){var e={index:0,colors:[{color:"#d84a38",name:"red"},{color:"#4d90fe",name:"blue"},{color:"#35aa47",name:"green"},{color:"#ffb848",name:"yellow"},{color:"#852b99",name:"purple"},{color:"#555555",name:"brown"},{color:"#F87217",name:"orange"},{color:"#FBBBB9",name:"pink"}],initialize:function(){this.index=Math.floor(Math.random()*this.colors.length)},next:function(){var e=this.colors[this.index%this.colors.length];return this.index++,e}};return e.initialize(),e}),define("CatLab/Webremote/Collections/Users",["CatLab/Webremote/Tools/Colorwheel"],function(i){"use strict";return function(){this.users=[],this.userMap={},this.add=function(e){var t;e.isColorSet()||(t=i.next(),e.setColor(t.color,t.name)),e.hasPlayerId()||e.setPlayerId(this.count()+1),this.users.push(e),this.userMap[e.getId()]=e},this.clear=function(){this.users=[],this.userMap={}},this.remove=function(e){this.users.splice(users.indexOf(e),1),void 0!==this.users[e.getId()]&&delete this.users[e.getId()]},this.getFromId=function(e){return void 0!==this.userMap[e]?this.userMap[e]:null},this.getAll=function(){return this.users},this.count=function(){return this.users.length},this.each=function(e){for(var t=0;t<this.users.length;t++)e(this.users[t])},this.not=function(i){var n=[];return this.each(function(e){for(var t=0;t<i.length;t++)if(i[t].getId()===e.getId())return void n.push(i[t])}),n}}}),define("CatLab/Webremote/Collections/Groups",["CatLab/Webremote/Tools/Colorwheel"],function(i){"use strict";return function(){var t;this.groups=[],this.groupMap={},this.add=function(e){var t;e.colorSet||(t=i.next(),e.setColor(t.color,t.name)),this.groupMap[e.getId()]=e,this.groups.push(e)},this.clear=function(){this.groups=[],this.groupMap=[]},this.addUser=function(t){var i=!1;return t.groupIds.forEach(function(e){e=this.getFromId(e);e&&(i=!0,e.addUser(t),e.isShareColor())&&t.setColor(e.getColor(),e.getColorName())}.bind(this)),i},this.remove=function(e){this.groups.splice(this.groups.indexOf(e),1),delete this.groupMap[e.getId()]},this.getFromId=function(e){return void 0!==this.groupMap[e]?this.groupMap[e]:null},this.getAll=function(){return this.groups},this.each=function(e){for(t=0;t<this.groups.length;t++)e(this.groups[t])}}}),define("CatLab/Webremote/Models/Control",[],function(){return function(i,n,e){var s,o,r=0,a={},h=i,l=[];this.id=i,this.decoration="",this.label="",this.isGlobal=e,this.pushed=function(){return 0===r},this.scale=function(){return r},this.update=function(e,t){0<r&&0===e?((t=void 0===t?!0:t)&&this.trigger("click"),this.trigger("up")):0===r&&0<e&&this.trigger("down"),r=e},this.getLabel=function(e){return(e=void 0===e?!0:e)?'<span class="control-label '+o+'">'+h+"</span>":h},this.setStaticLabel=function(e,t){return h=e,o=t,this},this.setLabel=function(e,t){return this.label=e,n.emit("button:label",{id:i,label:e}),this},this.decorate=function(e){return this.decoration=e,n.emit("button:decorate",{id:i,styles:e}),this},this.click=function(e){return this.on("click",e),this},this.on=function(e,t){return this.log("Setting trigger "+e),void 0===a[e]&&(a[e]=[]),a[e].push(t),this},this.trigger=function(e){this.log("Triggering "+e);var t=[];if(void 0!==a[e])for(this.log("Found "+a[e].length+" events"),s=0;s<a[e].length;s++)t.push(a[e][s]);for(s=0;s<t.length;s++)t[s]();return this},this.hasTriggers=function(e){return void 0===e?0<Object.keys(a).length:void 0!==a[e]&&0<a[e].length},this.off=function(e,t){if(void 0===e)a={};else if(void 0===t)a[e]=[];else if(void 0!==a[e])for(s=0;s<a[e].length;s++)a[e][s]===t&&(a[e].splice(s,1),s--);return this},this.clear=function(){return this.clearEvents(),this.decoration=null,this.label=null,this},this.clearEvents=function(){return a={},this},this.addDomElement=function(e){var t=this,i=[];return i.push(e.addEventListener("click",function(){t.trigger("click")})),l.push({element:e,listeners:i}),this},this.clearDomElements=function(){for(var e=0;e<l.length;e++)for(var t=0;t<l[e].listeners.length;t++)l[e].element.removeEventListener("click",l[e].listeners[t]);return l=[],this},this.isLocalAuthentication=function(){return!1},this.refreshTarget=function(e){this.decoration&&e.emit("button:decorate",{id:i,styles:this.decoration}),this.label&&e.emit("button:label",{id:i,label:this.label})},this.log=function(e){n.log("["+this.id+"] "+e)}}}),define("CatLab/Webremote/Synchronization/MultipleTargetControl",[],function(){function e(e,t){this.id=e,this.remoteView=t,this.label=null,this.decoration=null}var t=e.prototype;return t.pushed=function(){var t=[];return this.remoteView.targets.forEach(function(e){t=t||e.control(this.id).pushed()}.bind(this)),t},t.scale=function(){var t,i=0;return this.remoteView.targets.forEach(function(e){(t=e.scale())>i&&(i=t)}.bind(this)),pushed},t.update=function(t){this.remoteView.targets.forEach(function(e){e.control(this.id).update(t)}.bind(this))},t.getLabel=function(){return this.label},t.setLabel=function(t){return this.label=t,this.remoteView.targets.forEach(function(e){e.control(this.id).setLabel(t)}.bind(this)),this},t.decorate=function(t){return this.decoration=t,this.remoteView.targets.forEach(function(e){e.control(this.id).decorate(t)}.bind(this)),this},t.click=function(e){return this.on("click",e),this},t.on=function(t,i){return this.remoteView.targets.forEach(function(e){e.control(this.id).on(t,i)}.bind(this)),this},t.off=function(e){var t=arguments;return this.remoteView.targets.forEach(function(e){e.control(this.id).off.apply(e.control(this.id),t)}.bind(this)),this},t.refreshTarget=function(t){return this.remoteView.targets.forEach(function(e){e.control(this.id).refreshTarget(t)}.bind(this)),this},e}),define("CatLab/Webremote/Synchronization/RemoteView",["CatLab/Webremote/Models/Control","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Synchronization/MultipleTargetControl","CatLab/Webremote/Synchronization/DataSynchronizer"],function(e,t,i,n){function s(e,t,i,n,s){this.initializeEventable(),this.id=t,this.viewId=e,this.targets=[],this.Webcontrol=n,this.groupId=void 0!==s?s:null,this.controls={},this.valueMap={},this.newUserStack=[],this.factory=null,this.listeners=[],i.map(function(e){this.addTarget(e)}.bind(this))}t=s.prototype=new t;return t.clearValues=function(){this.valueMap={}},t.addTarget=function(e){this.targets.push(e),this.refreshTarget(e)},t.refreshTarget=function(t){var e,i={id:this.id,viewId:this.viewId};for(this.tmpid in this.groupId&&(i.group=this.groupId),t.emit("view:set",i),this.newUserStack.map(function(e){t.emit(e.action,e.data)}.bind(this)),t.controls)t.controls.hasOwnProperty(this.tmpid)&&t.controls[this.tmpid].isGlobal&&t.controls[this.tmpid].refreshTarget(t);for(this.tmpid in this.controls)this.controls.hasOwnProperty(this.tmpid)&&(void 0!==this.controls[this.tmpid].refreshTarget?this.controls[this.tmpid].refreshTarget(t):console.error("Unexpected control:",this.controls[this.tmpid]));for(e in this.valueMap)this.valueMap.hasOwnProperty(e)&&t.emit("value:change",{id:e,value:this.valueMap[e]})},t.emit=function(t,i){this.targets.map(function(e){e.emit(t,i)})},t.clearControls=function(){for(var e=this.Webcontrol.getViewLabels(this.currentView),t=0;t<e.length;t++)this.control(e[t].id).setStaticLabel(e[t].label,"mobile")},t.control=function(e){return void 0===this.controls[e]&&(this.controls[e]=new i(e,this)),this.controls[e]},t.trigger=function(e,t){"value:change"==e&&this.changeValue(t.id,t.value)},t.changeValue=function(e,t){this.valueMap[e]=t,this.emit("value:change",{id:e,value:t}),this.eventableTrigger("value:change",e,t)},t.refreshControls=function(){for(this.tmpid in this.controls)this.controls.hasOwnProperty(this.tmpid)&&this.controls[this.tmpid].refreshControl()},t.getValues=function(){return this.valueMap},t.log=function(e){this.Webcontrol.log(e)},t.domAppend=function(e,t){this._stackAndEmit("dom:append",{id:e,html:t})},t.domReplace=function(e,t){this._stackAndEmit("dom:replace",{id:e,html:t})},t.domAttribute=function(e,t,i){this._stackAndEmit("dom:attribute",{id:e,name:t,value:i})},t.vibrate=function(e){Array.isArray(e)?this.emit("device:vibrate",{pattern:e}):console.error("Vibrate pattern must be an array.")},t.listenTo=function(e,t,i){this.listeners.push(e.on(t,i))},t.stopListening=function(){this.listeners.forEach(function(e){e.unbind()})},t._stackAndEmit=function(e,t){this.newUserStack.push({action:e,data:t}),this.emit(e,t)},t.destroy=function(){this.stopListening(),this.factory.destroy(this)},s}),define("CatLab/Webremote/Synchronization/RemoteViewFactory",["CatLab/Webremote/Synchronization/RemoteView"],function(s){function e(){this.viewCounter=0,this.views={}}var t=e.prototype;return t.create=function(e,t,i,n){return this.viewCounter++,this.views[this.viewCounter]=new s(this.viewCounter,e,t,i,n),(this.views[this.viewCounter].factory=this).views[this.viewCounter]},t.createDummy=function(e,t){return this.create(e,[],t)},t.getFromId=function(e){return this.views[e]},t.destroy=function(e){e=e.id;delete this.views[e]},new e}),define("CatLab/Webremote/Models/Users/ControlUser",["CatLab/Webremote/Models/User","CatLab/Webremote/Models/Control","CatLab/Webremote/Synchronization/RemoteViewFactory","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Synchronization/DataSynchronizer","CatLab/Webremote/Synchronization/EventHandler","CatLab/Webremote/Collections/Users"],function(t,i,n,e,s,o,r,a){function h(e,t){this.initializeEventable(),(t=void 0===t?{}:t).id=e,t.playerId=null,this.initialize(t)}e=h.prototype=new e;return e.hasPlayerId=function(){return 0<this.playerId},e.setPlayerId=function(e){return this.playerId=e,this},e.control=function(e,t){return void 0===t&&(t=!1),void 0===this.controls[e]&&(this.controls[e]=new i(e,this,t)),this.controls[e]},e.getAvailableControls=function(){return["a","b","x","y","up","down","right","left","start","back"]},e.hasControl=function(e){return!0},e.setWebcontrol=function(e){this.Webcontrol=e},e.initialize=function(e){this.id=e.id,e.playerId&&(this.playerId=e.playerId),this.groups=[],this.currentView=null,this.color="orange",this.colorName="orange",this.colorSet=!1,this.tmpid=null,this.active=!1,this.smiley=null,this.email=null,this.nickname=null,this.userdata=e,this.profiledata={},this.access_token=null,this.user=null,this.master=!1,this.authenticated=!1,void 0!==e&&void 0!==e.groups?this.groupIds=e.groups:this.groupIds=[],this.controls={},this.dataSynchronizer=new o("user",this.emit.bind(this),"master"),this.data=this.dataSynchronizer.getFromIdentifier("user"),this.events=new r("user",this.emit.bind(this)),this.settings={}},e.setSettings=function(e){return this.settings=e,this},e.trigger=function(t,i){0<=o.eventsToListenFor.indexOf(t)?(this.dataSynchronizer.checkNamespace(i)&&this.dataSynchronizer.processMessage(t,i),this.getGroups().forEach(function(e){e.dataSynchronizer.checkNamespace(i)&&e.dataSynchronizer.processMessage(t,i)}.bind(this))):0<=r.eventsToListenFor.indexOf(t)?(this.events.checkNamespace(i)&&this.events.processMessage(t,i),this.getGroups().forEach(function(e){e.events.checkNamespace(i)&&e.events.processMessage(t,i)}.bind(this))):"button:down"===t?this.control(i.id).update(1):"button:up"===t?this.control(i.id).update(0,i.click):"user:login"===t?this.login(i):"user:logout"===t?this.logout(i):"user:smiley"===t?this.setSmiley(i.smiley):"sync:audio"===t&&this.eventableTrigger("sync:audio",i)},e.setSmiley=function(t){this.smiley=t;var i=null;this.getGroups().forEach(function(e){i=!0,e.setSmiley(t,this)}.bind(this)),i||this.Webcontrol.smileys.reserve(t,this.getIdentifier())?this.emit("user:smiley",{smiley:t}):this.emit("dom:alert",{message:s.t("Smiley is already taken. Please select a different smiley.")})},e.setNickname=function(e){return this.nickname=e,this},e.getNickname=function(){return this.nickname||(this.getData().username?this.getData().username:this.playerId?"Player "+this.playerId:"Player "+this.id)},e.clearSmiley=function(){this.smiley=null,this.getGroups().forEach(function(e){e.clearSmiley(this)}.bind(this)),this.emit("user:smiley",{smiley:null})},e.getSmiley=function(){return this.smiley},e.getSmileyImage=function(){return this.Webcontrol.smileys.getImage(this.getSmiley())},e.getSmileyHtml=function(){return this.Webcontrol.smileys.getHtml(this.getSmiley())},e.getSmileyUrl=function(){return this.Webcontrol.smileys.getUrl(this.getSmiley())},e.login=function(e){},e.logout=function(e){},e.clearControls=function(){for(this.tmpid in null!==this.currentView&&this.currentView.clearControls(),this.controls)!this.controls.hasOwnProperty(this.tmpid)||this.controls[this.tmpid].isGlobal||this.controls[this.tmpid].clear()},e.clearEvents=function(){this.clearControls(),this.clearEventableEvents()},e.emit=function(e,t,i){return this.Webcontrol.provider.toPlayer(this,e,t,i),!0},e.getId=function(){return this.id},e.getName=function(){return"User "+this.getId()},e.getType=function(){return"mobile"},e.getEntityType=function(){return"user"},e.getIcon=function(){return"fa fa-mobile-phone"},e.loginFromAuthUser=function(e,t){e={access_token:e.getAccessToken()};this.login(e,t)},e.login=function(t,i){var n=this;this.Webcontrol.getOAuthClient(function(e){e&&(this.setAccessToken(t.access_token),e.profile(n.access_token,function(e){n.authenticated=!0,this.setProfiledata(e.user),void 0!==i&&i()}.bind(this)))}.bind(this))},e.setAccessToken=function(e){this.access_token=e},e.getAccessToken=function(){return this.access_token},e.setProfiledata=function(e){e=void 0!==(this.profiledata=e).accessToken?e.accessToken:null,e=new t(e);void 0!==this.profiledata.id&&e.setId(this.profiledata.id),void 0!==this.profiledata.username&&e.setName(this.profiledata.username),void 0!==this.profiledata.avatar&&e.setAvatar(this.profiledata.avatar),this.setUser(e),this.eventableTrigger("login",this)},e.isAuthenticated=function(){return this.authenticated},e.getData=function(){return this.profiledata},e.logout=function(e){this.profiledata=null,this.access_token=null,this.authenticated=!1},e.setColor=function(e,t){this.colorSet=!0,this.color=e,this.colorName=t,this.emit("color:set",{color:e,name:t})},e.isColorSet=function(){return this.colorSet},e.getColor=function(){return this.color},e.getColorName=function(){return this.colorName},e.isActive=function(){return this.active},e.toggleActive=function(){this.setActive(!this.active),this.setJoinLabel()},e.setJoinLabel=function(){!0===this.active?this.control("a").setLabel("LEAVE"):this.control("a").setLabel("JOIN")},e.setActive=function(e,t){this.active=e,this.eventableTrigger("active:change",e),this.active&&this.eventableTrigger("active:activate"),void 0!==t&&t&&this.setJoinLabel()},e.setView=function(e){return this.clearView(),this.currentView=n.create(e,[this],this.Webcontrol),this.currentView},e.clearView=function(e){var t;this.currentView&&(t=this.currentView,this.currentView=null,this.clearControls(),void 0!==e?setTimeout(function(){t.destroy()},e):t.destroy())},e.refreshView=function(){this.currentView&&this.currentView.refreshTarget(this)},e.getValues=function(){return this.currentView?this.currentView.getValues():null},e.clearValues=function(){this.currentView&&this.currentView.clearValues()},e.setUser=function(e){return this.usermodel=e,this},e.hasUser=function(){return void 0!==this.usermodel&&this.usermodel},e.getUser=function(){return this.usermodel},e.isLocalAuthentication=function(){return!0},e.log=function(e){this.Webcontrol&&this.Webcontrol.log("[u:"+this.getId()+"] "+e)},e.getGroups=function(){return this.groups},e.hasDisplay=function(){return!0},e.hasKeyboardInput=function(){return!0},e.hasTouchInput=function(){return!0},e.getIdentifier=function(){return{id:this.getId(),type:this.getEntityType()}},e.represents=function(e){if(void 0===e.id||void 0===e.type)throw"Attribute is not an identifier.";var t=this.getIdentifier();return t.type===e.type&&t.id===e.id},e.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"up",authenticate:"y",left:"left",right:"right"}},e.isMainGroup=function(){if(0===this.groups.length)return!0;for(var e=0;e<this.groups.length;e++)if(this.groups[e].isMainGroup())return!0;return!1},e.isMaster=function(){return this.master},e.setMaster=function(e){var t=this.master!==(e=!!(e=void 0===e?!0:e));return this.master=e,t&&this.eventableTrigger("master:change"),this},e.resetViews=function(e){this.emit("view:reset",{},e=void 0===e?function(){}:e)},e.replaceViews=function(e,t){this.resetViews(function(){this.loadViews(e,t)}.bind(this))},e.loadViews=function(e,t){void 0===t&&(t=function(){}),this.log("Loading views for group "+e),this.emit("view:load",{url:e},t)},e.getConnectToken=function(){return this.Webcontrol.getConnectToken()},e.getConnectTokenForDisplay=function(){return this.Webcontrol.getConnectTokenForDisplay()},e.serialize=function(){return{id:this.getId(),playerId:this.playerId,userdata:this.userdata,profiledata:this.profiledata,email:this.email,nickname:this.nickname,access_token:this.access_token,color:this.color,colorName:this.colorName,smiley:this.smiley,data:this.dataSynchronizer.serialize(),events:this.events.serialize()}},e.unserialize=function(e){void 0!==e.profiledata&&this.setProfiledata(e.profiledata),void 0!==e.playerId&&(this.playerId=e.playerId),void 0!==e.access_token&&this.setAccessToken(e.access_token),void 0!==e.color&&(this.color=e.color),void 0!==e.colorName&&(this.colorName=e.colorName),void 0!==e.nickname&&(this.nickname=e.nickname),void 0!==e.email&&(this.email=e.email),void 0!==e.smiley&&(this.smiley=e.smiley),void 0!==e.data&&this.dataSynchronizer.unserialize(e.data),void 0!==e.events&&this.events.unserialize(e.events)},h}),define("CatLab/Webremote/Models/GroupControl",[],function(){return function(e,i,t){var n,s,o,r,a,h,l=e,c={};this.label=null,this.decoration="",this.group=i,this.isGlobal=t,this.pushed=function(){for(o=i.getUsers(),n=0;n<o.length;n++)if(o[n].control(l,this.isGlobal).pushed())return!0;return!1},this.scale=function(){for(o=i.getUsers(),n=r=0;n<o.length;n++)(a=o[n].control(l,this.isGlobal)).value>r&&(r=a.value);return r},this.getLabel=function(e){return o=i.getUsers(),(n=0)<o.length?(a=o[n].control(l,this.isGlobal)).getLabel(e):null},this.setStaticLabel=function(e,t){for(o=i.getUsers(),n=0;n<o.length;n++)o[n].control(l).setStaticLabel(e,t);return null},this.setLabel=function(e,t){return this.label=e,i.emit("button:label",{id:l,label:e}),this},this.decorate=function(e){return this.decoration=e,i.emit("button:decorate",{id:l,styles:e}),this},this.click=function(e){return this.on("click",e),this},this.on=function(e,t){for(void 0===c[e]&&(c[e]=[]),c[e].push(t),this.log("Setting group trigger "+e),o=i.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).on(e,t);return this},this.hasTriggers=function(e){for(o=i.getUsers(),n=0;n<o.length;n++)if(o[n].control(l,this.isGlobal).hasTriggers(e))return!0;return!1},this.off=function(e){for(delete c[e],o=i.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).off(e);return this},this.clearEvents=function(){for(c={},o=i.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).clearEvents();return this},this.clear=function(){for(c={},this.decoration=null,this.label=null,o=i.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).clear();return this},this.isLocalAuthentication=function(){return!1},this.refreshControl=function(){for(o=i.getUsers(),n=0;n<o.length;n++){for(h in o[n].control(l,this.isGlobal).clearEvents(),c)if(c.hasOwnProperty(h))for(s=0;s<c[h].length;s++)o[n].control(l,this.isGlobal).on(h,c[h][s]);this.label&&o[n].control(l,this.isGlobal).setLabel(this.label)}return this},this.refreshTarget=function(e){this.decoration&&e.emit("button:decorate",{id:l,styles:this.decoration}),this.label&&e.emit("button:label",{id:l,label:this.label})},this.log=function(e){i.log("["+l+"] "+e)}}}),define("CatLab/Webremote/Models/ControlGroup",["CatLab/Webremote/Config","CatLab/Webremote/Models/User","CatLab/Webremote/Models/Control","CatLab/Webremote/Models/GroupControl","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Synchronization/RemoteViewFactory","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Synchronization/DataSynchronizer","CatLab/Webremote/Synchronization/EventHandler","CatLab/Webremote/Tools/Tools"],function(e,t,i,n,s,o,r,a,h,l){function c(e,t){this.initializeEventable(),this.id=e,this.initialize(t)}r=c.prototype=new r;return r.setWebcontrol=function(e){this.Webcontrol=e},r.initialize=function(e){this.token=e.token,this.connectURL=e.connectURL,this.currentView=null,this.color="orange",this.colorName="orange",this.colorSet=!1,this.shareColor=!1,this.tmpid=null,this.active=!1,this.smiley=null,this.email=null,this.userdata=e,this.profiledata={},this.access_token=null,this.master=!1,this.users=[],this.controls=[],this.dataSynchronizer=new a("group",this.emit.bind(this),"master"),this.data=this.dataSynchronizer.getFromIdentifier("group:"+this.getId()),this.events=new h("group",this.emit.bind(this)),this.options={}},r.setOptions=function(e){return this.options=e,this},r.getOption=function(e){return void 0!==this.options[e]?this.options[e]:null},r.hasControl=function(e){return!0},r.setAccessToken=function(e){this.access_token=e},r.setProfiledata=function(e){this.profiledata=e},r.clearControls=function(){for(this.tmpid in null!=this.currentView&&this.currentView.clearControls(),this.controls)!this.controls.hasOwnProperty(this.tmpid)||this.controls[this.tmpid].isGlobal||this.controls[this.tmpid].clear()},r.clearEvents=function(){this.clearControls(),this.clearEventableEvents()},r.isMainGroup=function(){return this.Webcontrol.getConnectToken()===this.getConnectToken()},r.emit=function(e,t,i){return this.Webcontrol.provider.toGroup(this,e,t,i),!0},r.getId=function(){return this.id},r.getName=function(){return"Group "+this.getId()},r.setNickname=function(e){return this.nickname=e,this},r.getNickname=function(){return this.nickname||(this.getData().username?this.getData().username:"Group "+this.getId())},r.getType=function(){return"mobile"},r.getEntityType=function(){return"group"},r.getIcon=function(){return"fa fa-mobile-phone"},r.getData=function(){return this.profiledata},r.setColor=function(e,t,i){void 0===i&&(i=this.shareColor),this.colorSet=!0,this.color=e,this.colorName=t,this.shareColor=i,this.emit("color:set",{color:e,name:t,shareColor:i})},r.getColor=function(){return this.color},r.setShareColor=function(e){this.shareColor=e},r.isShareColor=function(){return this.shareColor},r.getColorName=function(){return this.colorName},r.setView=function(e){return this.clearView(),this.currentView=o.create(e,[this],this.Webcontrol,this.getId()),this.currentView},r.clearView=function(t){var e;this.currentView&&(e=this.currentView,this.currentView=null,this.clearControls(),void 0!==t?setTimeout(function(){e.destroy()},t):e.destroy(),this.users.forEach(function(e){e.clearView(t)}))},r.resetViews=function(e){this.emit("view:reset",{},e=void 0===e?function(){}:e)},r.replaceViews=function(e,t){this.resetViews(function(){this.loadViews(e,t)}.bind(this))},r.loadViews=function(e,t){void 0===t&&(t=function(){}),this.log("Loading views for group "+e),this.emit("view:load",{url:e},t)},r.isAuthenticated=function(){return!1},r.isLocalAuthentication=function(){return!0},r.log=function(e){this.Webcontrol.log("[g:"+this.getId()+"] "+e)},r.getConnectToken=function(){return this.Webcontrol.provider.getConnectToken(this.token)},r.getConnectTokenForDisplay=function(){return l.getConnectTokenForDisplay(this.getConnectToken())},r.getConnectURL=function(){return this.Webcontrol.provider.getConnectURL(this.connectURL)},r.addUser=function(t){for(this.tmpid in l.findIndex(this.users,function(e){return e.id===t.id})<0&&this.users.push(t),l.findIndex(t.groups,function(e){return e.id===this.id})<0&&t.groups.push(this),this.currentView&&(this.currentView.refreshTarget(t),t.currentView=this.currentView),this.controls)this.controls.hasOwnProperty(this.tmpid)&&this.controls[this.tmpid].refreshControl();this.events.refreshTarget(t.emit.bind(t)),this.dataSynchronizer.refreshTarget(t.emit.bind(t)),this.smiley&&(t.emit("user:smiley",{smiley:this.smiley}),t.smiley=this.smiley),this.trigger("user:join",t)},r.removeUser=function(t){var e=l.findIndex(this.users,function(e){return e.id===t.id});0<=e&&this.users.splice(e,1)},r.getUsers=function(){return this.users},r.getIdentifier=function(){return{id:this.getId(),type:this.getEntityType()}},r.represents=function(e){if(void 0===e.id||void 0===e.type)throw"Attribute is not an identifier.";var t=this.getIdentifier();return t.type==e.type&&t.id==e.id},r.getValues=function(){return this.currentView?this.currentView.getValues():null},r.clearValues=function(){this.currentView&&this.currentView.clearValues()},r.control=function(e,t){return void 0===t&&(t=!1),void 0===this.controls[e]&&(this.controls[e]=new n(e,this,t)),this.controls[e]},r.isMaster=function(){return this.master},r.setMaster=function(e){return this.master=e=void 0===e?!0:e,this},r.hasDisplay=function(){return!0},r.hasKeyboardInput=function(){return!0},r.hasTouchInput=function(){return!0},r.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"up",authenticate:"y",left:"left",right:"right"}},r.setOAuthSettings=function(e){this.emit("oauth:set",e)},r.setSmiley=function(e,t){this.Webcontrol.smileys.reserve(e,this.getIdentifier())?(this.emit("user:smiley",{smiley:e}),this.smiley=e):t.emit("dom:alert",{message:s.t("Smiley is already taken. Please select a different smiley.")})},r.clearSmiley=function(e){this.Webcontrol.smileys.unreserve(this.getIdentifier()),this.emit("user:smiley",{smiley:null}),this.smiley=null},r.getSmiley=function(){return this.smiley},r.getSmileyImage=function(){return this.Webcontrol.smileys.getImage(this.getSmiley())},r.getSmileyHtml=function(){return this.Webcontrol.smileys.getHtml(this.getSmiley())},r.getSmileyUrl=function(){return this.Webcontrol.smileys.getUrl(this.getSmiley())},r.setMaxUsers=function(e){this.emit("config:set",{maxUsers:e})},r.isActive=function(){return this.active},r.toggleActive=function(){this.active=!this.active,this.setJoinLabel()},r.setJoinLabel=function(){!0===this.active?this.control("a").setLabel("LEAVE"):this.control("a").setLabel("JOIN")},r.setActive=function(e,t){this.active=e,this.eventableTrigger("active:change",e),this.active&&this.eventableTrigger("active:activate")},r.serialize=function(){return{id:this.getId(),token:this.token,userdata:this.userdata,nickname:this.nickname,profiledata:this.profiledata,email:this.email,access_token:this.access_token,shareColor:this.shareColor,color:this.color,colorName:this.colorName,smiley:this.smiley,data:this.dataSynchronizer.serialize(),events:this.events.serialize()}},r.unserialize=function(e){void 0!==e.profiledata&&this.setProfiledata(e.profiledata),void 0!==e.access_token&&this.setAccessToken(e.access_token),void 0!==e.token&&(this.token=e.token),void 0!==e.shareColor&&(this.shareColor=e.shareColor),void 0!==e.color&&(this.color=e.color),void 0!==e.colorName&&(this.colorName=e.colorName),void 0!==e.nickname&&(this.nickname=e.nickname),void 0!==e.email&&(this.email=e.email),void 0!==e.smiley&&(this.smiley=e.smiley,this.emit("user:smiley",{smiley:this.smiley})),void 0!==e.data&&this.dataSynchronizer.unserialize(e.data),void 0!==e.events&&this.events.unserialize(e.events)},c}),define("CatLab/Webremote/Models/State",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Preloader"],function(i,n){function e(e){this.Webcontrol=e}var t=e.prototype;return t.reconnect=function(e,t){void 0!==e.provider&&this.Webcontrol.provider.restoreProviderSettings(e.provider),this.Webcontrol.disconnect(),setTimeout(function(){this.Webcontrol.initialize(i.getAll()).then(function(){this.Webcontrol._reconnect(e.token,e.accessToken,function(){this._setCollectionDetails(e.groups,this.Webcontrol._grouplibrary),this._setCollectionDetails(e.users,this.Webcontrol._userlibrary),this.Webcontrol.preloader=n.unserialize(this.Webcontrol.provider,e.preloader),t()}.bind(this))}.bind(this))}.bind(this),1)},t._setCollectionDetails=function(e,t){var i,n;if(void 0!==e)for(i=0;i<e.length;i++)(n=t.getFromId(e[i].id))?n.unserialize(e[i]):(console.log("Trying to set data for non existing user/group."),console.log(e[i]))},t.getData=function(){var t=[],i=(this.Webcontrol._grouplibrary.each(function(e){t.push(e.serialize())}.bind(this)),[]),e=(this.Webcontrol._userlibrary.each(function(e){i.push(e.serialize())}),{users:i,groups:t,token:this.Webcontrol._gamedata.token,accessToken:this.Webcontrol._gamedata.accessToken,preloader:this.Webcontrol.preloader.serialize()});return e.provider=this.Webcontrol.provider.serializeProviderSettings(),e},t.serialize=function(){var e=this.getData();return JSON.stringify(e)},t.unserialize=function(e){e=JSON.parse(e);this.reconnect(e)},e}),define("CatLab/Webremote/Messages/MessageBus",[],function(){"use strict";function e(){this.controllerListeners=[],this.viewListeners=[]}var t=e.prototype;return t.toController=function(e,t){this.handleControllerMessage(e,t)},t.handleControllerMessage=function(e,t){for(var i=0;i<this.controllerListeners.length;i++)this.controllerListeners[i].handleIncomingMessage(e,t)},t.toView=function(e,t,i){this.handleViewMessage(e,t,i)},t.handleViewMessage=function(e,t,i){if(void 0===i)for(var n=0;n<this.viewListeners.length;n++)this.viewListeners[n].handleIncomingMessage(e,t);else this.viewListeners[i].handleIncomingMessage(e,t)},t.addControllerListener=function(e){if(void 0===e.handleIncomingMessage)throw new Error("Controller listener does not have a handleIncomingMessage");this.controllerListeners.push(e)},t.removeControllerListener=function(e){e=this.controllerListeners.indexOf(e);-1!==e&&this.controllerListeners.splice(e,1)},t.addViewListener=function(e){if(void 0===e.handleIncomingMessage)throw new Error("Controller listener does not have a handleIncomingMessage");e=this.viewListeners.push(e);this.toController("subscribe",{listener:e})},t.removeViewListener=function(e){e=this.viewListeners.indexOf(e);-1!==e&&this.viewListeners.splice(e,1)},t.destroy=function(){this.controllerListeners=[],this.viewListeners=[]},e}),define("CatLab/Webremote/Messages/NavigateableProxy",[],function(){function e(e,t){this.prefix=t||"",this.controls={navigation:["left","right"],toggle:["a"],manipulation:["down","up"],back:["b","back"]},this.views=[],this.keyInputCallbacks={},this.boundCallbacks={},e.addControllerListener(this),this.messageBus=e}var t=e.prototype;return t.handleIncomingMessage=function(e,t){if(e===this.prefix+"nav:controls")return this.controls=t.controls,this.views.forEach(function(e){this.refreshView(e)}.bind(this)),!0},t.addView=function(e){this.views.push(e),this.refreshView(e)},t.refreshView=function(t){this.reattachClick(t.control(this.controls.navigation[0]),this.previous),this.reattachClick(t.control(this.controls.navigation[1]),this.next),this.reattachClick(t.control(this.controls.manipulation[0]),this.down),this.reattachClick(t.control(this.controls.manipulation[1]),this.up),this.controls.toggle.forEach(function(e){void 0===this.keyInputCallbacks[e]&&(this.keyInputCallbacks[e]=function(){this.keyInput(e)}),this.reattachClick(t.control(e),this.keyInputCallbacks[e].bind(this))}.bind(this)),this.controls.back.forEach(function(e){this.reattachClick(t.control(e),this.back)}.bind(this))},t.reattachClick=function(e,t){this.boundCallbacks[t]||(this.boundCallbacks[t]=t.bind(this)),e.off("click",this.boundCallbacks[t]),e.click(this.boundCallbacks[t])},t.keyInput=function(e){this.messageBus.toView(this.prefix+"nav:keyInput",{button:e})},t.previous=function(){this.messageBus.toView(this.prefix+"nav:previous")},t.next=function(){this.messageBus.toView(this.prefix+"nav:next")},t.up=function(){this.keyInput("up")},t.down=function(){this.keyInput("down")},t.back=function(){this.messageBus.toView(this.prefix+"nav:back")},t.destroy=function(){this.messageBus.removeControllerListener(this)},e.handleMessage=function(e,t,i,n){if(e.substring(0,(n=void 0===n?"":n).length)===n){switch(e=e.replace(n,"")){case"nav:previous":return i.previous(),!0;case"nav:next":return i.next(),!0;case"nav:keyInput":return i.keyInput(t.button),!0;case"nav:back":return i.triggerBack(),!0}return!1}},e}),define("CatLab/Webremote/Controllers/Portal",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Messages/MessageBus","CatLab/Webremote/Messages/NavigateableProxy"],function(i,e,t,s,n,o){"use strict";function r(e,t){this.initializeEventable(),this.Webcontrol=e,this.options=t,this.controlDisabled=!1,this.users=[],this.ensureOption("allowChangeNickname",!0),this.ensureOption("customFunctions",{}),this.ensureOption("minPlayers",1),this.ensureOption("maxPlayers",4),this.ensureOption("activePlayersPanel",!1),this.ensureOption("customViews",!1),this.ensureOption("authentication",e.AUTH_NOT_REQUIRED),this.ensureOption("localAuthenticable",!1),this.ensureOption("start",function(){alert("This is where the game would start, if one would have set a 'start' option.")}),this.Webcontrol.getMessageBus().addControllerListener(this),this.messageBus=e.getMessageBus(),this.navigatableProxy=new o(this.messageBus,"portal:"),this.useCatLabViews()&&e.loadViews(i.getSocketURL(!0)+"/webremote/views/default.xml"),this.eventListeners=[],this.initialize()}e=r.prototype=new e;return e.handleIncomingMessage=function(e,t){switch(e){case"subscribe":this.updateUsers();break;case"start":this.startGame();break;case"back":this.back()}},e.initialize=function(){var e=this.Webcontrol.on("user:join",function(e){this.userConnect(e),this.eventListeners.push(e.on("login",function(){this.updateUsers()}.bind(this)))}.bind(this));this.eventListeners.push(e),this.Webcontrol.getUsers().forEach(function(e){this.userConnect(e)}.bind(this))},e.updateUsers=function(){this.updateState();let n=[];this.Webcontrol.getUsers().forEach(function(e){var t=e.getUser(),i=null;t&&(i={image:t.avatar}),n.push({active:e.isActive(),color:e.getColor(),profile:i,type:e.getType()})}),this.messageBus.toView("users:update",{users:n})},e.updateState=function(){var e={activePlayers:this.countActiveUsers(),minPlayers:this.options.minPlayers,maxPlayers:this.options.maxPlayers,connectInstructions:this.getConnectInstructions(),startAndLoginInstructions:this.getStartAndLoginInstructions(),showInactivePlayers:this.supportInactivePlayers()};this.messageBus.toView("state:change",{state:e})},e.ensureOption=function(e,t){void 0===this.options[e]&&(this.options[e]=t)},e.useCatLabViews=function(){return!1===this.options.customViews},e.getToggleView=function(e){var t="",t=this.supportInactivePlayers()?"catlab-portal-toggle":"catlab-portal";return this.isMaster(e)||(t+="-nostart"),t},e.addUser=function(e){e.clearEvents(),this.users.push(e),this.supportInactivePlayers()||this.forceToggleableUser(e)||this.activateUser(e),this.trigger("users:update"),this.updateUsers()},e.activateUser=function(e){this.trigger("user:activate",e),e.setActive(!0,this.supportInactivePlayers()),this.updateUsers()},e.deactivateUser=function(e){this.trigger("user:deactivate",e),e.setActive(!1,this.supportInactivePlayers()),this.updateUsers()},e.toggleActive=function(e){(this.supportInactivePlayers()||this.forceToggleableUser(e))&&(e.isActive()?this.deactivateUser(e):this.activateUser(e),this.trigger("users:update"))},e.forceToggleableUser=function(e){return!e.hasDisplay()},e.hasUsersWithoutDisplay=function(){for(var e=0;e<this.users.length;e++)if(!this.users[e].hasDisplay())return!0;return!1},e.countActiveUsers=function(){return this.getActiveUsers().length},e.getActiveUsers=function(){for(var e=[],t=0;t<this.users.length;t++)this.users[t].isActive()&&e.push(this.users[t]);return e},e.userConnect=function(e){this.eventListeners.push(e.on("master:change",function(){this.updateUserView(e)},this)),this.addUser(e),this.updateUserView(e),this.trigger("user:connect",e)},e.updateUserView=function(e){var t=e.setView(this.getToggleView(e));this.controlDisabled||this.enableControls(e,t),this.enableDefaultPlayerControls(e,t)},e.disableControls=function(){this.controlDisabled=!0;for(var e=0;e<this.users.length;e++)this.users[e].clearEvents()},e.enableControls=function(e,t){var i;void 0!==e?(i=e.getPortalControls(),t.control(i.toggleActive).click(function(){console.log("Toggling active for user "+e.getId()),this.toggleActive(e)}.bind(this)),t.control(i.start).click(function(){this.startGame()}.bind(this)),t.control(i.back).click(function(){this.back()}.bind(this)),this.supportsLocalAuthentication()&&t.control(i.authenticate).click(function(){e.isLocalAuthentication()||this.authenticate(e)}.bind(this)),this.navigatableProxy.addView(t)):(this.controlDisabled=!1,this.users.forEach(function(e){this.updateUserView(e)}.bind(this)))},e.enableDefaultPlayerControls=function(i,n){if(n.control("name").setLabel(i.getNickname()),n.listenTo(i,"login",function(){n.control("name").setLabel(i.getNickname())}),this.options.allowChangeNickname&&n.control("change-nickname").click(function(){this.changeNickname(i).then(function(){this.updateUserView(i)}.bind(this))}.bind(this)),this.options.customFunctions)for(var e in this.options.customFunctions)this.options.customFunctions.hasOwnProperty(e)&&function(e,t){n.control(e).click(function(){t(i).then(function(){this.updateUserView(i)}.bind(this))}.bind(this))}.bind(this)(e,this.options.customFunctions[e])},e.changeNickname=function(t){var i=new s,n=t.setView("catlab-nickname");return n.changeValue("name",t.getNickname()),n.control("a").click(function(){var e=n.getValues().name;!e||32<e.length||(t.setNickname(e),i.resolve())}),i.promise()},e.supportInactivePlayers=function(){return this.options.activePlayersPanel},e.supportsLocalAuthentication=function(){return this.options.localAuthenticable&&this.Webcontrol.canAuthenticate()},e.isMaster=function(e){return e.isMaster()},e.getPortalLabels=function(){var s={start:[],back:[],toggleActive:[],authenticate:[]};return this.Webcontrol._userlibrary.each(function(e){var t,i=e.getPortalControls();for(t in i)if(i.hasOwnProperty(t)){var n=e.control(i[t]).getLabel(!1);if(!n)continue;n="["+n.toUpperCase()+"]",void 0===s[t]&&(s[t]=[]),-1===s[t].indexOf(n)&&s[t].push(n)}}.bind(this)),s},e.authenticate=function(e){this.disableControls();var t=this.Webcontrol.authenticationController(e,{messageBus:this.messageBus});this.messageBus.toView("auth:open",{}),t.controller.setNavigatableUsers([e]),t.controller.on("close",function(){this.enableControls(),this.updateUsers()}.bind(this))},e.countAuthenticated=function(e){void 0===e&&(e=!0);for(var t=0,i=0;i<this.users.length;i++)!this.users[i].isAuthenticated()||e&&!this.users[i].isActive()||t++;return t},e.checkAuthentication=function(){var e=this.countAuthenticated();switch(this.options.authentication){case this.Webcontrol.AUTH_REQUIRED_ALL:return e===this.countActiveUsers();case this.Webcontrol.AUTH_REQUIRED_ONE:return 0<e;case this.Webcontrol.AUTH_REQUIRED_ONE_INACTIVE:return 0<this.countAuthenticated(!1);case this.Webcontrol.AUTH_NOT_REQUIRED:return!0;default:throw"Authentication requirement "+this.options.authentication+" not found."}},e.startGame=function(){var e=this.countActiveUsers();if(e<this.options.minPlayers)this.messageBus.toView("alert",{message:"You need "+this.options.minPlayers+" players to start playing",localized:["You need %s players to start playing",this.options.minPlayers]});else if(e>this.options.maxPlayers)this.messageBus.toView("alert",{message:"Your license is limited to "+this.options.maxPlayers+" players",localized:["Your license is limited to %s players",this.options.maxPlayers]});else if(this.checkAuthentication())this.Webcontrol.setView("catlab-game-already-started",this.Webcontrol._userlibrary.not(this.getActiveUsers())),this.Webcontrol.setView("catlab-game-starting",this.getActiveUsers()),this.destroy(),this.options.start(this.getActiveUsers());else switch(this.options.authentication){case this.Webcontrol.AUTH_REQUIRED_ALL:this.messageBus.toView("alert",{message:"All active players must be authenticated.",localized:["All active players must be authenticated."]});break;case this.Webcontrol.AUTH_REQUIRED_ONE:case this.Webcontrol.AUTH_REQUIRED_ONE_INACTIVE:this.messageBus.toView("alert",{message:"At least one player must be authenticated.",localized:["At least one player must be authenticated."]})}},e.back=function(){void 0!==this.options.back&&(this.destroy(),this.options.back())},e.getConnectURL=function(){return this.Webcontrol.getConnectURL()},e.getConnectToken=function(){return this.Webcontrol.getConnectTokenForDisplay()},e.getUsers=function(){return this.users},e.setMinPlayers=function(e){return this.options.minPlayers=e,this.trigger("options:change"),this.updateState(),this},e.setMaxPlayers=function(e){return this.options.maxPlayers=e,this.trigger("options:change"),this.updateState(),this},e.getMessageBus=function(){return this.messageBus},e.getConnectInstructions=function(){return void 0!==this.Webcontrol.provider.getConnectInstructions?this.Webcontrol.provider.getConnectInstructions():["Use your tablet or smartphone to surf to %s and enter code %s.",this.getConnectURL(),this.getConnectToken()]},e.getStartAndLoginInstructions=function(){var e;return void 0!==this.Webcontrol.provider.getStartAndLoginInstructions?this.Webcontrol.provider.getStartAndLoginInstructions():(e=this.getPortalLabels(),this.supportsLocalAuthentication()&&(this.showInactivePlayers||this.hasUsersWithoutDisplay())?["Press %s to join, %s to login and %s to start.",t(e.toggleActive),t(e.authenticate),t(e.start)]:this.supportsLocalAuthentication()?["Press %s to login and %s to start.",t(e.authenticate),t(e.start)]:this.showInactivePlayers||this.hasUsersWithoutDisplay()?["Press %s to join and %s to start.",t(e.toggleActive),t(e.start)]:["Press %s to start.",t(e.start)]);function t(e){return e.join(" / ")}},e.destroy=function(){this.eventListeners&&this.eventListeners.forEach(function(e){e.unbind()}),this.messageBus.toView("portal:destroy"),this.messageBus.removeControllerListener(this),this.navigatableProxy.destroy()},r}),define("CatLab/Webremote/Controllers/RemoteAuthentication",["CatLab/Webremote/Controllers/OAuth2"],function(t){return function(e){e.setView("remote:authenticate"),e.on("user:join",function(e){e.on("login",function(e){t.addAccessToken(e.getAccessToken())}.bind(this))}.bind(this))}}),define("CatLab/Webremote/Controllers/Authentication",["CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Controllers/RemoteAuthentication","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Cookies","CatLab/Webremote/Messages/MessageBus","CatLab/Webremote/Messages/NavigateableProxy"],function(n,s,o,e,r,i,t,a){"use strict";function h(e,t,i){this.initializeEventable(),this.messageBus=e.getMessageBus(),this.navigatableProxy=new a(this.messageBus,"auth:"),this.Webcontrol=e,this.user=t,o.on("update",this.updateUsers,this),n.on("update",function(){this.updateUsers()},this),this.messageBus.addControllerListener(this)}var l=null,c=null,e=h.prototype=new e;return e.handleIncomingMessage=function(e,t){switch(e){case"subscribe":this.getLoginUrl().then(function(e){this.loginUrl=e,this.messageBus.toView("auth:loginurl",{url:e})}.bind(this)),this.updateUsers();break;case"auth:close":this.trigger("close");break;case"auth:select-user":this.selectUser(t.user)}},e.link=function(){n.link(function(e){this.selectUser(e)}.bind(this))},e.updateUsers=function(){this.messageBus.toView("auth:users:update",{users:o.getAll().map(function(e){return{id:e.getId(),name:e.getName(),image:e.avatar}})})},e.selectUser=function(e){var t;(e=o.getFromId(e.id))&&(t=this).user.loginFromAuthUser(e,function(){i.setCookie("ctlb_ps_"+this.user.id,e.id),t.close()}.bind(this))},e.getUsers=function(){return o},e.close=function(){this.messageBus.toView("auth:close"),this.destroy()},e.getLoginUrl=function(){var t,e,i=new r;return t=this.Webcontrol,(null!==l?((e=new r).resolve(l),e):(null===c&&(c=new r,t.newGroup().then(function(e){new s(l=e),e.setOAuthSettings(t.getOAuthSettings()),c.resolve(e)})),c)).promise().then(function(e){i.resolve(e.getConnectURL()+"/"+e.getConnectToken())}),i.promise()},e.setNavigatableUsers=function(e){e.forEach(function(e){this.navigatableProxy.addView(e)}.bind(this))},e.attemptLastLogin=function(){var e=i.getCookie("ctlb_ps_"+this.user.id);if(e){e=o.getFromId(e);if(e)return this.selectUser(e),!0}return!1},e.destroy=function(){this.messageBus.toView("auth:destroy"),this.messageBus.removeControllerListener(this),this.navigatableProxy.destroy()},h}),define("CatLab/Webremote/Tools/MessageCounter",["CatLab/Webremote/Tools/Eventable"],function(e){"use strict";function t(e){this.interval=e||1e3,this.initializeEventable(),this.countIncoming=0,this.countOutgoing=0;var t,i,n=(new Date).getTime();setInterval(function(){t=(new Date).getTime(),i=t-n,n=t,this.trigger("tick",{in:this.countIncoming,out:this.countOutgoing,dt:i}),this.countIncoming=0,this.countOutgoing=0}.bind(this),this.interval)}e=t.prototype=new e;return e.incoming=function(){this.countIncoming++},e.outgoing=function(){this.countOutgoing++},t}),define("CatLab/Webremote/Views/Portal",["CatLab/Webremote/Config"],function(B,e){return function(e){var s=e.element||document.body,t=s,i=e.countdown||5e3,n=e.done||function(){alert("Game should start now... yet it doesn't.")},o=e["min-players"]||1,r=(o<1&&(o=1),e["max-players"]||1e3);r<o&&(r=o);var a,h,l,c,u,d,p,f,g,m,v,b=!e.customViews,y=[],A=!1,w=!1,C=null,k=this;function T(s){s.setView("catlab-portal-toggle"),s.control("join-game").click(function(){!function(e){if(P(e)){e.control("join-game").setLabel("JOIN");for(var t=e,i=0;i<y.length;i++)if(y[i].getId()==t.getId())return y.splice(i,1)}else e.control("join-game").setLabel("LEAVE"),y.push(e)}(s),M(),x(),U()}),s.control("start-game").click(function(){var e;A?U():y.length<o?V(o+" players are required to start the game. Please gather more friends."):y.length>r?V("This game can have only "+r+" players."):(e=i,U(),A=!0,(p=new Date).setTime((new Date).getTime()+e),u.show(),d=setInterval(D,100))}),s.control("down").click(function(){L(s)}),s.control("right").click(function(){L(s)}),s.control("left").click(function(){S(s)}),s.control("up").click(function(){S(s)}),s.control("a").click(function(){var e,i,t,n;e=s,w&&I(e)?(n=v.find(".available-accounts").find("li.selected"))&&(n=WebcontrolOAuthClient.getFromToken(n.attr("data-accessToken")))&&(t=n.access_token,n=n.user,C.setUserData(t,n),_()):(A&&U(),w||(i=e,Webcontrol.getOAuthClient(function(t){t.onInit(function(){E(t)}),WebcontrolAccessKeyLibrary.init(function(){w=!0,C=i,m.show(),v.show();var e=$('<a href="javascript:void(0);">Link new account</a>');e.click(function(){t.getNewAccessToken(function(){E(t)})}),v.find(".link-new-account").html(e)}),E(t)})))}),s.control("b").click(function(){w&&I(s)&&(C.setUserData(!1),_())}),W(),x()}function S(e){w&&I(e)&&(e=v.find(".available-accounts").find("li.selected"),v.find(".available-accounts").find("li").removeClass("selected").addClass("unselected"),(e.length&&e.prev().length?e.prev():v.find(".available-accounts").find("li").last()).addClass("selected").removeClass("unselected"))}function L(e){w&&I(e)&&(e=v.find(".available-accounts").find("li.selected"),v.find(".available-accounts").find("li").removeClass("selected").addClass("unselected"),(e.length&&e.next().length?e.next():v.find(".available-accounts").find("li").first()).addClass("selected").removeClass("unselected"))}function I(e){return C&&e.getId()==C.getId()}function _(){m.hide(),v.hide(),w=!1,C=null}function E(e){v.find(".available-accounts").html("");for(var t=e.listUsers(),i=0;i<t.length;i++){var n=$("<li>"+t[i].user.username+"</li>");n.addClass("unselected"),n.attr("data-accessToken",t[i].access_token),v.find(".available-accounts").append(n)}}function x(){0<Webcontrol.getControlLabels("join-game").length?($(".buttoninstructions.join-game").show().find(".labels").html(Webcontrol.getControlLabels("join-game").join(", ")),$(".buttoninstructions.start-game").show().find(".labels").html(Webcontrol.getControlLabels("start-game").join(", "))):($(".buttoninstructions.join-game").hide(),c.hide())}function P(e){for(var t=0;t<y.length;t++)if(y[t].getId()==e.getId())return 1}function W(){var e=Webcontrol.getUsers();a.html("");for(var t=[],i=0;i<e.length;i++)P(e[i])||t.push(e[i]);for(0==t.length&&a.append('<li class="empty"><span>More players? Add devices!</span></li>'),i=0;i<t.length;i++)a.append('<li class="user '+t[i].getType()+'" style="background-color: '+t[i].getColor()+'"><i class="'+t[i].getIcon()+'"></i><span>'+t[i].getName()+"</span></li>")}function M(){h.html(""),0==y.length&&h.append('<li class="empty"><span class="buttoninstructions join-game">Press <span class="labels"></span> to join the game.</span></li>');for(var e=0;e<y.length;e++)h.append('<li class="user '+y[e].getType()+'" style="background-color: '+y[e].getColor()+'"><i class="'+y[e].getIcon()+'"></i><span>'+y[e].getName()+"</span></li>");W()}function D(){f=Math.ceil((p.getTime()-(new Date).getTime())/1e3),u.find(".counter").html(f),f<0&&(void 0!==t&&(void 0!==t.hide?t.hide():void 0!==t.style&&(t.style.display="none")),U(),n(y))}function U(){A=!1,d&&(V("Countdown stopped!"),u.hide(),clearInterval(d),d=null)}function V(e){var t=jQuery("<p></p>").html(e).appendTo(g);setTimeout(function(){t.fadeOut(1e3,function(){t.remove()})},3e3)}this.loginInformation="Login into your account and get access to more game features now!",0<s.length?s.addClass("webremote-portal"):s.className=s.className+" webremote-portal",void 0!==e.theme&&(e=B.getSocketURL()+"/webremote/themes/"+e.theme+"/"+e.theme+".css",Webcontrol._loadCSS(e),Webcontrol._loadCSS(B.getSocketURL()+"/webremote/themes/font-awesome/css/font-awesome.min.css")),s.innerHTML='<div class="loading"><p>Please wait, loading socket.io.</p></div>',Webcontrol.initialize(function(){s.innerHTML='<div class="loading"><p>Please wait, loading jQuery.</p></div>',s.innerHTML="";var e=s,e=(s=jQuery('<div class="webremote-portal-inner"></div>').appendTo(e),(s=jQuery(s)).html('<div class="loading"><p>Please wait, connecting to server.</p></div>'),b&&Webcontrol.loadViews(B.getSocketURL(!0)+"/webremote/views/default.xml"),s.html("<h1>Player lobby</h1>"),m=$("<div></div>"),v=$('<div><h2>Select account</h2><div class="information"><p>'+k.loginInformation+'</p></div><ul class="available-accounts"></ul><p class="link-new-account"></p></div>'),m.addClass("accounts-overlay"),v.addClass("accounts"),m.hide(),v.hide(),s.append(m),s.append(v),jQuery('<div class="connected-users"><div class="inner"><h2>Connected devices</h2></div></div>')),t=(a=jQuery('<ul class="connected-users"></ul>').appendTo(e.find(".inner")),jQuery('<div class="active-users"><div class="inner"><h2>Active users</h2></div></div>'));h=jQuery('<ul class="active-users"></ul>').appendTo(t.find(".inner")),s.append(e),s.append(t),(e=jQuery('<div class="connection-information"><div class="inner"><h2>Instructions</h2><p>Take your smartphone, navigate to <span class="url"></span> and use token <span class="token"></span></p></div></div>')).find(".token").html(Webcontrol.getConnectToken()),e.find(".url").html(Webcontrol.getConnectURL()),l=jQuery('<p class="buttoninstructions join-game">Press <span class="labels"></span> to join the game.</p>'),c=jQuery('<p class="buttoninstructions start-game">Press <span class="labels"></span> to start the game.</p>'),g=jQuery('<div class="errors"></div>').appendTo(s),e.append(l),e.append(c),s.append(e),u=jQuery('<div class="countdown-background"></div><div class="countdown"><p>Game will start in <span class="counter">5</span></p></div>').hide().appendTo(s),Webcontrol.on("user:join",function(e){T(e)});for(var i=Webcontrol.getUsers(),n=0;n<i.length;n++)T(i[n]);Webcontrol.on("user:leave",W),W(),M(),x()})}}),define("CatLab/Webremote/ViewFactory/ViewFactory",["CatLab/Webremote/Views/Portal"],function(t){"use strict";function e(){}return e.prototype.getPortal=function(e){return new t(e)},e}),define("CatLab/Webremote/Models/Users/GamepadUser",["CatLab/Webremote/Models/Users/ControlUser"],function(e){function t(e){e=e.id||"1",this.initialize({id:"gamepad_"+e}),this.clearControls()}var i={DPAD_UP:{id:"up",label:"↑",key:""},DPAD_DOWN:{id:"down",label:"↓",key:"DPAD_DOWN"},DPAD_RIGHT:{id:"right",label:"→",key:"DPAD_RIGHT"},DPAD_LEFT:{id:"left",label:"←",key:"DPAD_LEFT"},FACE_1:{id:"a",label:"A",key:"FACE_1"},FACE_2:{id:"b",label:"B",key:"FACE_2"},FACE_3:{id:"x",label:"X",key:"FACE_3"},FACE_4:{id:"y",label:"Y",key:"FACE_4"},SELECT_BACK:{id:"back",label:"SELECT",key:"SELECT_BACK"},START_FORWARD:{id:"start",label:"START",key:"START_FORWARD"}},e=t.prototype=new e;return e.getType=function(){return"gamepad"},e.getIcon=function(){return"fa fa-gamepad"},e.emit=function(){return!1},e.isLocalAuthentication=function(){return!1},e.controlFromKey=function(e){return this.control(i[e].id)},e.hasDisplay=function(){return!1},e.hasKeyboardInput=function(){return!1},e.hasTouchInput=function(){return!1},t}),define("CatLab/Webremote/Gamepads/GamepadAPI",["CatLab/Webremote/Models/Users/GamepadUser"],function(i){function e(){this.gamepads={},this.initialized=!1,this.Webcontrol=null}var n,t,s={12:"DPAD_UP",13:"DPAD_DOWN",15:"DPAD_RIGHT",14:"DPAD_LEFT",0:"FACE_1",1:"FACE_2",2:"FACE_3",3:"FACE_4",8:"SELECT_BACK",9:"START_FORWARD"},o=e.prototype;return o.initialize=function(e){var t;this.Webcontrol=e,this.initialized||(this.initialized=!0,e=function(){var e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads||[];for(n=0;n<e.length;n++)if(e[n]){for(n=0;n<e.length;n++)e[n]&&this.onConnect(e[n]);this.startGamepadPolling(),clearInterval(t)}}.bind(this),"undefined"!=typeof window&&("ongamepadconnected"in window?(window.addEventListener("gamepadconnected",function(e){this.onConnect(e.gamepad)}.bind(this)),window.addEventListener("gamepaddisconnected",function(e){this.onDisconnect(e.gamepad)}.bind(this))):t=setInterval(e,1e3)))},o.startGamepadPolling=function(){setInterval(this.poll.bind(this),50)},o.poll=function(){var e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads||[];for(n=0;n<e.length;n++)if(e[n])for(t=0;t<e[n].buttons.length;t++)this.gamepads[e[n].index].user&&void 0!==s[t]&&this.gamepads[e[n].index].user.controlFromKey(s[t]).update(e[n].buttons[t].pressed?1:0)},o.onConnect=function(e){var t=new i({id:e.id});this.gamepads[e.index]={user:t},this.Webcontrol.addCustomControl(t),this.startGamepadPolling()},o.onDisconnect=function(e){},new e}),define("CatLab/Webremote/Controllers/Webcontrol",["CatLab/Webremote/Config","CatLab/Webremote/Collections/Users","CatLab/Webremote/Collections/Groups","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Models/Users/ControlUser","CatLab/Webremote/Models/ControlGroup","CatLab/Webremote/Models/State","CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Controllers/Portal","CatLab/Webremote/Controllers/Authentication","CatLab/Webremote/Tools/Colorwheel","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/Preloader","CatLab/Webremote/Tools/Smileys","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/MessageCounter","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Synchronization/RemoteViewFactory","CatLab/Webremote/Synchronization/DataSynchronizer","CatLab/Webremote/Synchronization/EventHandler","CatLab/Webremote/ViewFactory/ViewFactory","CatLab/Webremote/Views/ConnectionTrouble","CatLab/Webremote/Providers/SocketIO","CatLab/Webremote/Gamepads/GamepadAPI","CatLab/Webremote/SonicSync/Client","CatLab/Webremote/Messages/MessageBus"],function(a,e,t,i,n,s,h,o,r,l,c,u,d,p,f,g,m,v,b,y,A,w,C,k,T,S,L){"use strict";function I(){this.initializeEventable(),this.provider=null,this._gamedata=null,this._userlibrary=null,this._grouplibrary=null,this._cssloads=[],this._labeldata={},this._initialized=!1,this._oauthsettings=!1,this._oauthClient=null,this._authentication=!1,this._lastView=null,this._options={},this._groupCallbacks={id:1},this._viewFactory=null,this.state=null,this.connected=!1,this._userlibrary=new e,this._grouplibrary=new t,this._messageBus=new L}g=I.prototype=new g;return Object.assign(g,{AUTH_REQUIRED_ALL:"ALL",AUTH_REQUIRED_ONE:"ONE",AUTH_REQUIRED_ONE_INACTIVE:"ONE-INACTIVE",AUTH_NOT_REQUIRED:"NONE",initialize:function(e){function t(){s.resolve(),n()}var i,n=function(){},s=(void 0!==(e=void 0===(e="function"==typeof e?{callback:e}:e)?{}:e).callback&&(n=e.callback),new u);return this._initialized?t():(this.sonicSyncClient=null,delete e.callback,e.headless,(i=!!e.headless)||void 0===e.assets||this.setAssets(e.assets),a.set(e),a.initialize(function(){null===this.provider&&(void 0===e.provider&&(e.provider=new k),this.provider=e.provider),this.smileys=new f(this.provider),void 0!==e.translator&&d.setTranslator(e.translator),this._initialize(i,t)}.bind(this))),s.promise()},disconnect:function(){this._initialized=!1,this.provider.disconnect()},_initialize:function(s,e){var o,r=new u;return(e&&r.then(e),this._initialized)?r.resolve(this.connected):(setTimeout(function(){r.resolve(!1)},3e4),this.state=new h(this),this._initialized=!0,(o=this).provider.initMaster(this),this.getProviderSettings().then(function(e){this.provider.connect("control",e).then(function(){this.connected=!0,this.provider.on("disconnect",function(){var e=this.getConnectionIssuesView();e.show(),e.text(d.t("Connection lost... reconnecting"))}.bind(this)),this.provider.on("reconnect",function(){this.recover(function(){this.getConnectionIssuesView().hide()}.bind(this))}.bind(this)),this.provider.on("master:initialize",function(e){this.log("Initializing"),this._gamedata=e,this.log("Game initialize; URL "+this.getConnectURL()+", token "+this.getConnectToken()),r.resolve(this.connected)}.bind(this)),this.provider.on("master:error",function(e){alert(e.message)}.bind(this)),this.provider.on("user:join",function(e){this._playerJoin(e)}.bind(this)),this.provider.on("user:reconnect",function(e){this._playerReconnect(e)}.bind(this)),this.provider.on("user:leave",function(e){this._playerLeave(e)}.bind(this)),this.provider.on("view:labels",function(e){this._setViewLabels(e)}.bind(this)),this.provider.on("group:create",function(e){this._onNewGroup(e)}.bind(this)),this.provider.on("user:smiley",function(e){this._playerTrigger("user:smiley",e),this._userlibrary.each(function(e){this.smileys.refreshTakenSmileys(e)}.bind(this))}.bind(this)),this.provider.on("smileys:slingshot",function(e){var t=this._userlibrary.getFromId(e.user);t?(t.trigger("smileys:slingshot",e),e.user=t,this.trigger("smileys:slingshot",e)):console.log("User not found: "+e.user)}.bind(this));for(var e=(e=(e=["user:login","user:logout","button:down","button:up","sync:audio"]).concat(y.eventsToListenFor)).concat(A.eventsToListenFor),t=0;t<e.length;t++)!function(t){o.provider.on(t,function(e){o._playerTrigger(t,e)})}(e[t]);var i=["value:change"];for(var n=0;n<i.length;n++)!function(t){o.provider.on(t,function(e){o._viewTrigger(t,e)})}(i[n]);this._oauthsettings&&this.provider.setOAuthSettings(this._oauthsettings),this.provider.setup(a.getProviderConfig()),this.preloader=new p(this.provider),!s&&a.useAudioSync()&&(this.sonicSyncClient=new S(this),this.sonicSyncClient.startSender())}.bind(this))}.bind(this))),r.promise()},setLogger:function(e){var t;"string"==typeof e?(t=document.getElementById(e),this.log=this.getDomLogger(t)):this.log=e},getProviderSettings:function(){return this.provider.getProviderSettings()},setMessageCounter:function(e){e=new m(e);return this.provider.setMessageCounter(e),e},setName:function(e){this.provider.toMaster("master:name",{name:e})},setMaxUsers:function(e){this.provider.toMaster("config:set",{maxUsers:e})},setViewFactory:function(e){return this._viewFactory=e,this._viewFactory.initialize()},getViewFactory:function(){return"undefined"===this._viewFactory&&(this._viewFactory=new w),this._viewFactory},getDomLogger:function(t){return function(e){t.innerHTML=e+"\n"+t.innerHTML}},oAuth:function(e,t){void 0===t&&(t=!1),this._authentication=!0,this._oauthsettings=e,this.provider&&!t&&this.provider.setOAuthSettings(this._oauthsettings),o.initialize(e),i.initialize(this,o)},getOAuthClient:function(e){this._oauthsettings?(null===this._oauthClient&&(this._oauthClient=o,this._oauthClient.initialize(this._oauthsettings)),e(this._oauthClient)):e(null)},getOAuthSettings:function(){return this._oauthsettings},clearEvents:function(e){if(e=void 0===e?!1:e)for(var t=this._userlibrary.getAll(),i=0;i<t.length;i++)t[i].clearEvents()},getConnectURL:function(){return this.provider.getConnectURL(this._gamedata.connectURL)},getConnectToken:function(){return this.provider.getConnectToken(this._gamedata.token)},getConnectTokenForDisplay:function(){return v.getConnectTokenForDisplay(this.getConnectToken())},loadViews:function(e,t){this.provider.loadViews(e,t)},getUsers:function(){return this._userlibrary.getAll()},portal:function(e){var t=this.portalController(e),e=this.portalView(t.messageBus,e);return{controller:t.controller,view:e,promise:t.promise}},portalController:function(e){var t;if(this._initialized)return t=new u,e=new r(this,e),t.resolve(e),{controller:e,messageBus:this.getMessageBus(),promise:t};throw new Error("Please initialize Webcontrol first.")},portalView:function(e,t){var i;if(this._initialized)return i=this.getViewFactory(),e={messageBus:e,Webcontrol:this},void 0!==t.element&&(e.element=t.element),(t=i.portal(e)).loading(),(e=i.getContainer()).easelboneLayer.setView(t),t.render(),e;throw new Error("Please initialize Webcontrol first.")},authentication:function(e,t){var i;if(this._initialized)return i=this.authenticationController(e,t),t=this.authenticationView(i.controller.messageBus,t),i.controller.setNavigatableUsers([e]),{controller:i.controller,view:t,promise:i.promise};throw new Error("Please initialize Webcontrol first.")},authenticationController:function(e,t){var i=new u,e=new l(this,e,t);return i.resolve(e),{controller:e,promise:i.promise()}},authenticationView:function(e){var t=this.getViewFactory(),e=t.authentication({messageBus:e}),t=t.getContainer();return t.easelboneLayer.setView(e),e.render(),t},getConnectionIssuesView:function(){return void 0===this.connectionTrouble&&(this.connectionTrouble=new C),this.connectionTrouble},setView:function(e,t){var i;return void 0===t?(i=b.create(e,[this],this),this._lastView=i):i=b.create(e,t,this),i},beacon:function(e,t){this.provider.toMaster("master:beacon",{beacon:e,token:t})},emit:function(e,t){this.provider.toPlayers(e,t)},getControlLabels:function(e,t){for(var i=[],n={},s=this.getUsers(),o=0;o<s.length;o++){var r=s[o].control(e).getLabel(t);void 0===n[r]&&i.push(n[r]=r)}return i},addCustomControl:function(e){this.log("adding "+e.getType()),e.setWebcontrol(this),this._userlibrary.add(e),this._initializeSmiley(e,{}),this.trigger("user:join",e)},enableGamepads:function(){T.initialize(this)},newGroup:function(e){var t=new u,i={},n=(void 0===e?e={}:"function"==typeof e&&(e={callback:e}),void 0===e.callback&&(e.callback=function(){}),!0),s=(void 0!==e.globalViews&&(n=e.globalViews),!0),o=(void 0!==e.shareColor&&(s=e.shareColor),[]),r=(void 0!==e.tags&&(o=e.tags),!0),r=(void 0!==e.smiley&&(r=!!e.smiley),i.smiley=r,this._groupCallbacks.id);return this._groupCallbacks.id++,this._groupCallbacks[r]={id:r,callback:e.callback,deferred:t,options:i},this.provider.createGroup(r,n,s,o),t.promise()},preload:function(e){return this.preloader.preload(e)},getPreloadedUrl:function(e){return this.preloader.getPreloadedUrl(e)},_reset:function(){this._userlibrary.clear(),this._grouplibrary.clear()},reset:function(){var e=new u;return this._initialized=!1,this.provider.reset(function(){e.resolve()}.bind(this)),e.promise()},_playerJoin:function(e){var t;this._userlibrary.getFromId(e.id)||((t=new n(e.id,e)).setWebcontrol(this),void 0!==e.color&&t.setColor(e.color.color,e.color.name),this._grouplibrary.addUser(t)||(this._lastView&&this._lastView.addTarget(t),this._initializeSmiley(t,e)),this._userlibrary.add(t),this.log(t),t&&this.trigger("user:join",t),this.preloader.sendPreloadFileCommandToPlayer(t))},_playerReconnect:function(e){var t=this._userlibrary.getFromId(e.id);t?(t.getSmiley()&&t.emit("user:smiley",{smiley:t.getSmiley()}),this._refreshPlayerViews(t),this.trigger("user:rejoin",t),t.eventableTrigger("rejoined"),this.smileys.refreshTakenSmileys(t),this.preloader.sendPreloadFileCommandToPlayer(t)):this._playerJoin(e)},_refreshPlayerViews:function(e){this._grouplibrary.addUser(e)||this._lastView&&this._lastView.addTarget(e),e.refreshView()},_playerLeave:function(e){e=this._userlibrary.getFromId(e.id);e&&(this.trigger("user:leave",e),e.eventableTrigger("left"))},_onNewGroup:function(e){var t,i=new s(e.id,e),n=(i.setWebcontrol(this),!1);void 0!==e.shareColor&&(n=e.shareColor),void 0!==e.color?i.setColor(e.color.color,e.color.name):i.setShareColor(n),this._grouplibrary.getFromId(e.id)||(n=function(){},void 0!==(t=e.externalId)&&void 0!==this._groupCallbacks[t]&&(i.setOptions(this._groupCallbacks[t].options),n=function(){this._groupCallbacks[t].callback(i),this._groupCallbacks[t].deferred.resolve(i)}.bind(this)),this._grouplibrary.add(i),i.getOption("smiley")&&this._initializeSmiley(i,e),this.trigger("group:create",i),this.log("New group "+i.getId()+"; URL "+i.getConnectURL()+", token "+i.getConnectToken()),n())},_initializeSmiley:function(e,t){var i;a.useSmileys()?void 0===t.smiley?null!==(i=this.smileys.getRandom(e.getIdentifier()))&&e.setSmiley(i):e.setSmiley(t.smiley):e.clearSmiley(),this.smileys.refreshTakenSmileys(e)},_playerTrigger:function(e,t){var i=this._userlibrary.getFromId(t.user);i?i.trigger(e,t):console.log("User not found: "+t.user)},_viewTrigger:function(e,t){var i=b.getFromId(t.viewId);i&&i.trigger(e,t)},_loadCSS:function(e){for(var t=0;t<this._cssloads.length;t++)if(this._cssloads[t]==e)return;this._cssloads.push(e);var i=document.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("type","text/css"),i.setAttribute("href",e),document.body.appendChild(i)},_setViewLabels:function(e){this._labeldata[e.id]=e.labels;for(var t=this.getUsers(),i=0;i<t.length;i++)for(var n=0;n<e.labels.length;n++)t[i].control(e.id).setStaticLabel(e.labels[n].label,"mobile")},getViewLabels:function(e){return void 0!==this._labeldata[e]?this._labeldata[e]:[]},getFromIdentifier:function(e){switch(e.type){case"user":return this._userlibrary.getFromId(e.id);case"group":return this._grouplibrary.getFromId(e.id)}return null},log:function(e){a.debug()&&(console.log(a),console.log(e))},canAuthenticate:function(){return this._authentication},pause:function(){this._initialized&&this.provider.toPlayers("master:pause",{})},unpause:function(){this._initialized&&this.provider.toPlayers("master:unpause",{})},audioSync:function(){if(this.sonicSyncClient)return this.sonicSyncClient.sync()},getMessageBus:function(){return this._messageBus},recover:function(e){var t=this.state.getData();this._reconnect(t.token,t.accessToken,e).then(function(){this._userlibrary.each(function(e){this._refreshPlayerViews(e)}.bind(this))}.bind(this))},_reconnect:function(e,t,i){return this.provider.reconnect(e,t,a.getProviderConfig(),i)},getIceCredentials:function(){var t=new u;return this.provider.toMaster("webrct:stun+turn",{},function(e){void 0===e.error?t.resolve(e):t.fail(e.error)}),t.promise()}}),I}),define("CatLab/Webremote/Models/Users/KeyboardUser",["CatLab/Webremote/Models/Users/ControlUser"],function(e){"use strict";function t(e,t){var i="keyboard"+ ++n;this.initializeKeyboardUser({id:i,keys:e}),this.exitOnUnassignedBackButton=t}var n=0,e=((t.prototype=Object.create(e.prototype)).constructor=t).prototype;return e.initializeKeyboardUser=function(e){this.initialize({id:e.id}),void 0===e.keys&&(e.keys=this.getDefaultKeys()),this.keys=e.keys,this.attachKeyboardEvents(),"undefined"!=typeof document&&document.addEventListener("fullscreenchange",this.attachKeyboardEvents.bind(this)),this.clearControls=function(){for(var e,t=0;t<this.keys.length;t++)this.control(this.keys[t].id).setStaticLabel(this.keys[t].label,"keyboard");for(e in this.controls)!this.controls.hasOwnProperty(e)||this.controls[e].isGlobal||this.controls[e].clear()},this.on("view:set",function(e){this.clearControls()}.bind(this)),this.getType=function(){return"keyboard"},this.getIcon=function(){return"fa fa-keyboard-o"},this.emit=function(e,t){return!1},this.isLocalAuthentication=function(){return!1},this.clearControls()},e.getAvailableControls=function(){for(var e=[],t=0;t<this.keys.length;t++)e.push(this.keys[t].id);return e},e.getDefaultKeys=function(){return[{id:"up",label:"↑",code:"ArrowUp"},{id:"down",label:"↓",code:"ArrowDown"},{id:"right",label:"→",code:"ArrowRight"},{id:"left",label:"←",code:"ArrowLeft"},{id:"a",label:"A",code:["KeyA","Enter","NumpadEnter"]},{id:"b",label:"B",code:"KeyB"},{id:"x",label:"X",code:"KeyX"},{id:"y",label:"Y",code:"KeyY"},{id:"back",label:"Escape",code:"Escape"},{id:"start",label:"S",code:["KeyS"]}]},e.hasControl=function(e){return-1!==this.getAvailableControls().indexOf(e)},e.hasDisplay=function(){return!1},e.hasKeyboardInput=function(){return!0},e.hasTouchInput=function(){return!0},e.stopListening=function(){try{if("undefined"==typeof window)self.removeEventListener("message",this.messageListener,!1);else{var e=null;try{e=window.document}catch(e){}e&&(this._keydownListener&&window.document.removeEventListener("keydown",this._keydownListener),this._keyupListener)&&window.document.removeEventListener("keyup",this._keyupListener),this.messageListener&&window.removeEventListener("message",this.messageListener,!1);var t=null;try{t=window.parent.document}catch(e){}t&&(t.removeEventListener("keyup",this._keydownListener),t.removeEventListener("keydown",this._keydownListener))}}catch(e){console.log(e)}},e.resumeListening=function(){this.attachKeyboardEvents()},e.attachKeyboardEvents=function(){if(this.stopListening(),"undefined"==typeof window)this.messageListener=this._onMessage.bind(this),self.addEventListener("message",this.messageListener,!1);else try{var e=window.document;if(!document.fullscreenElement&&window.parent&&!(e=window.parent.document))throw new Error("Unaccessible");this._keydownListener=this._keyDown.bind(this),this._keyupListener=this._keyUp.bind(this),e.addEventListener("keydown",this._keydownListener),e.addEventListener("keyup",this._keyupListener)}catch(e){try{this.messageListener=this._onMessage.bind(this),window.addEventListener("message",this.messageListener,!1)}catch(e){console.error(e)}}},e.getConfigFromKey=function(e){for(var t=0;t<this.keys.length;t++){if(void 0!==this.keys[t].code&&this._keyMatches(this.keys[t].code,e.code))return this.keys[t];if(void 0!==this.keys[t].key&&this._keyMatches(this.keys[t].key,e.key))return this.keys[t];if(void 0!==this.keys[t].keyCode&&this._keyMatches(this.keys[t].keyCode,e.keyCode))return this.keys[t]}return null},e._keyMatches=function(e,t){return!!(Array.isArray(e)&&-1<e.indexOf(t))||e==t},e._onMessage=function(e){var t=e.data;if("object"==typeof t&&void 0!==t.type&&"catlab:keyboard"===t.type&&void 0!==t.code&&void 0!==t.action)switch(t.action){case"down":return void this._keyDown(e.data);case"up":return void this._keyUp(e.data)}},e._keyDown=function(e){var t;"Escape"!==e.key||!this.exitOnUnassignedBackButton||this.control("back").hasTriggers("click")||this.control("back").hasTriggers("up")||this.control("back").hasTriggers("down")?(t=this.getConfigFromKey(e))&&(this.control(t.id).update(1),void 0!==t.preventDefault)&&t.preventDefault&&e.preventDefault():this.requestExitApp()},e._keyUp=function(e){var t=this.getConfigFromKey(e);t&&(this.control(t.id).update(0),void 0!==t.preventDefault)&&t.preventDefault&&e.preventDefault()},e.requestExitApp=function(){var e;window.onbeforeunload?(e=window.onbeforeunload({}))&&this.confirm(e,function(e){e&&this.exitApp()}.bind(this)):this.exitApp()},e.exitApp=function(){window.close()},e.confirm=function(e,t){t(window.confirm(e))},t}),define("CatLab/Webremote/Models/Users/CordovaUser",["CatLab/Webremote/Models/Users/KeyboardUser"],function(e){function t(e,t,i){void 0===i&&(i=!0),void 0===t&&(t="back"),this.initializeKeyboardUser({id:"cordova",keys:e}),this.initializeBackButtonExit(t,i)}e=((t.prototype=Object.create(e.prototype)).constructor=t).prototype;return e.initializeBackButtonExit=function(i,n){void 0===n&&(n=!0);var s=new Date;document.addEventListener("backbutton",function(e){var t=new Date;t.getTime()-s.getTime()<300?this.requestExitApp():(s=t,e.preventDefault(),!n||this.control("back").hasTriggers("click")||this.control("back").hasTriggers("up")||this.control("back").hasTriggers("down")?i&&(this.control(i).update(1),setTimeout(function(){this.control(i).update(0)}.bind(this),1)):setTimeout(function(){void 0!==window.plugins.appMinimize?window.plugins.appMinimize.minimize():this.exitApp()},350))}.bind(this),!1)},e.exitApp=function(){navigator.app.exitApp()},e.confirm=function(e,t){navigator.notification.confirm(e,function(e){t(1===e)})},e.getDefaultKeys=function(){return[{id:"up",label:"↑",key:38},{id:"down",label:"↓",key:40},{id:"right",label:"→",key:39},{id:"left",label:"←",key:37},{id:"start",label:"ENTER",key:13},{id:"back",label:"BACK",key:null}]},e.hasDisplay=function(){return!1},e.hasKeyboardInput=function(){return!0},e.hasTouchInput=function(){return!0},t}),define("CatLab/Webremote/Models/Users/AndroidRemoteUser",["CatLab/Webremote/Models/Users/CordovaUser"],function(e){function t(e,t,i){this.initializeKeyboardUser({id:"cordova",keys:e}),this.initializeBackButtonExit(t,i)}e=((t.prototype=Object.create(e.prototype)).constructor=t).prototype;return e.getDefaultKeys=function(){return[{id:"up",label:"↑",keyCode:38,preventDefault:!0},{id:"down",label:"↓",keyCode:40,preventDefault:!0},{id:"right",label:"→",keyCode:39,preventDefault:!0},{id:"left",label:"←",keyCode:37,preventDefault:!0},{id:"a",label:"ENTER",keyCode:13,preventDefault:!0},{id:"back",label:"BACK",keyCode:null},{id:"start",label:"⏯",keyCode:179},{id:"fastforward",label:"⏩",keyCode:228},{id:"fastforward",label:"⏪",keyCode:227}]},e.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"up",authenticate:"menu",left:"left",right:"right"}},e.hasDisplay=function(){return!1},e.hasKeyboardInput=function(){return!1},e.hasTouchInput=function(){return!1},this.getType=function(){return"android-keyboard"},t}),define("CatLab/Webremote/Models/Users/DummyUser",["CatLab/Webremote/Models/Users/ControlUser"],function(e){function t(e){this.initialize({id:e}),this.clearControls=function(){},this.getType=function(){return"dummy"},this.getIcon=function(){return"fa fa-keyboard-o"},this.emit=function(e,t){return!1},this.isLocalAuthentication=function(){return!1},this.log=function(e){this.Webcontrol&&this.Webcontrol.log("[u:"+this.getId()+"] "+e)},this.hasDisplay=function(){return!1},this.hasKeyboardInput=function(){return!0},this.hasTouchInput=function(){return!0},this.clearControls()}return(t.prototype=Object.create(e.prototype)).constructor=t}),define("CatLab/Webremote/Tools/ParseXML",[],function(){function e(){}var t=null;"undefined"!=typeof window&&(void 0!==window.DOMParser?t=function(e){return(new window.DOMParser).parseFromString(e,"text/xml")}:void 0!==window.ActiveXObject&&new window.ActiveXObject("Microsoft.XMLDOM")&&(t=function(e){var t=new window.ActiveXObject("Microsoft.XMLDOM");return t.async="false",t.loadXML(e),t}));return e.prototype.parse=function(e){if(t)return t(e);throw new Error("No XML parser found")},new e}),define("CatLab/Webremote/Providers/Airconsole",["CatLab/Webremote/Providers/Provider","CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Proxy","CatLab/Webremote/Tools/ParseXML","CatLab/Webremote/Synchronization/MessageQueue","CatLab/Webremote/Models/User"],function(e,t,i,n,s,o,r){function a(e){e&&(this.airconsole=e),this.showTokenForm=!1,this.oauth={},this.views=[],this.knownUsers={},this.started=!1,this.userId=null,this.sendBurstDelay=50,this.connectCode=null}e=a.prototype=new e;return e.connect=function(e){return this.log("Airconsole connecting"),this.setInitialized(),this.path=e,this._trigger("connect",null),this.readyState.promise()},e.noTokenConnect=function(){return this.connect("remote")},e.setUserId=function(e){return this.userId=e,this},e.initMaster=function(e){this.master=e,this.airconsole||(this.airconsole=new AirConsole),this.airconsole.onMessage=this.onMessage.bind(this),this.airconsole.onConnect=function(e){this.emitAirConsole(e,"airconsole:well-hello-there",{user:e})}.bind(this),this.readyState=new i,this.airconsole.onReady=function(e){this.connectCode=e,this.readyState.resolve()}.bind(this),this.airconsole.onDeviceProfileChange=function(e){this.updateDeviceProfile(e)}.bind(this),this.on("player:join",function(e){this.onPlayerConnect(e.user)}.bind(this)),this.once("connect",function(){setTimeout(function(){this.started=!0}.bind(this),1)}.bind(this))},e.initPlayer=function(e){this.master=e,this.airconsole=new AirConsole,this.airconsole.onMessage=this.onMessage.bind(this),this.readyState=new i,this.readyState.resolve(),this.once("airconsole:well-hello-there",function(e){this.emitAirConsole(0,"player:join",{})}.bind(this))},e.onMessage=function(t,e){var i;void 0!==(e="string"==typeof e?JSON.parse(e):e).b&&Array.isArray(e.b)?(i=0,e.b.forEach(function(e){setTimeout(function(){this.processMessage(t,e)}.bind(this),i++)}.bind(this))):this.processMessage(t,e)},e.processMessage=function(e,t){var i;t&&t[0]&&(i=t[0],t=t[1],this.isMaster()&&(0<e&&"player:join"!==i&&void 0===this.knownUsers[e]&&this.onPlayerConnect(e),0<e)&&(t.user=e),o.unpack(t,"user").forEach(function(e){this.isRemote()&&void 0!==e.user&&e.user!==this.airconsole.getDeviceId()||this._trigger(i,e)}.bind(this)))},e.onPlayerConnect=function(e){this.log("Welcoming our newest player "+e),this.knownUsers[e]=!0;for(var t=0;t<this.views.length;t++)this.emitAirConsole(e,"view:load",{xml:this.views[t]}),this.emitAirConsole(e,"view:set",{id:"loading"});this._trigger("user:join",{id:e}),this.updateDeviceProfile(e)},e.updateDeviceProfile=function(e){var t,i,n=this.master._userlibrary.getFromId(e);n&&(t={username:this.airconsole.getNickname(e)},(i=this.airconsole.getProfilePicture(e))&&(t.avatar=i),this.airconsole.getMasterControllerDeviceId()===e&&n.setMaster(!0),n.setProfiledata(t))},e.emitAll=function(){this.isMaster()&&this.emitMaster(),this.isRemote()&&this.emitClient()},e.isMaster=function(){return"control"===this.path},e.isRemote=function(){return"remote"===this.path},e.emitClient=function(){this.queue.flush().forEach(function(e){this.emitAirConsole(0,e.action,e.data)}.bind(this))},e.emitMaster=function(){var t,i,e=this.queue.compactFlush();e.length&&(t=5<e.length,i=[],e.forEach(function(e){t||void 0===e.data.user||Array.isArray(e.data.user)&&1<e.data.user.length?i.push(e):this.emitAirConsole(e.user,e.action,e.data)}.bind(this)),0<i.length)&&this.broadcastAirconsole(i)},e.emitAirConsole=function(e,t,i){t=[t,i],delete t[1].action,i=JSON.stringify(t);this.airconsole.message(e,i)},e.broadcastAirconsole=function(e){var t=[],e=(e.forEach(function(e){t.push([e.action,e.data])}),JSON.stringify({b:t}));this.airconsole.broadcast(e)},e.setOAuthSettings=function(e){this.oauth=e,this.toPlayers("oauth:set",e)},e.loadViews=function(e){n.get(e).then(function(e){this.views.push(e),this.toPlayers("view:load",{xml:e})}.bind(this))},e.log=function(){this.master.log.apply(arguments)},e.setup=function(e){this._trigger("master:initialize",{})},e.toMaster=function(e,t){t.user=0,this.emit(e,t)},e.log=function(e){var t=[],i=(Array.prototype.push.apply(t,arguments),"["+this.path+"]");"remote"===this.path&&(i="["+this.path+":"+this.airconsole.getDeviceId()+"]"),t.unshift(i),console.log.apply(console,t)},e.getConnectInstructions=function(){return["Open the Airconsole app on your smartphone and connect with code %s.",this.connectCode]},e.getStartAndLoginInstructions=function(){return["Use the onscreen button to start the game."]},e.proxyFile=function(e){var t=new i;return t.resolve({url:e}),t.promise()},a}),define("CatLab/Webremote/Providers/Dummy",["CatLab/Webremote/Providers/Provider","CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Tools"],function(e,t,n,i){function s(){this.initializeProvider(),this.userId=null,this.randomToken=i.getUuid(),this.loadBalancerSessionToken="connid",this.socket=null,this._registeredEvents={}}e=s.prototype=new e;return e.connect=function(e,t){var i=new n;return this.setInitialized(),i.resolve(),i.promise()},e.setup=function(e){this._trigger("master:initialize",{})},e.emitAll=function(e,t){},s}),define("CatLab/Webremote/CreateJS/LayerContainer",["easeljs","easelbone"],function(n,s){"use strict";function e(e,t){if(!s)throw console.log("When using the createjs module of the remote, you need to have the easelbone module loaded."),console.log("Check https://github.com/catlabinteractive/easelbone"),new Error("easelbone could not be loaded.");this.width=e,this.height=t,this.initialize(),this.easelboneLayer=new s.Views.Layer({container:this});var i=this;this.easelboneLayer.on("all",function(e){e=new n.Event(e);i.dispatchEvent(e)})}var t=e.prototype=new n.Container;return t.Container_initialize=t.initialize,t.initialize=function(){this.Container_initialize(),this.setBounds(0,0,this.width,this.height),this.on("click",function(e){e.stopPropagation()})},t.loading=function(){},t.render=function(){this.easelboneLayer.render()},e}),define("CatLab/Webremote/Tools/ImageLoader",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred"],function(n,s){return{loadedImages:{},loadImage:function(e){var t,i=new s;return this.loadedImages[e]?i.resolve(this.loadedImages[e]):((t=new Image).crossOrigin="anonymous",t.onload=function(){this.loadedImages[e]=t,i.resolve(this.loadedImages[e])}.bind(this),t.src=n.getProxiedImage(e)),i.promise()}}}),define("CatLab/Webremote/CreateJS/Views/PortalView",["easeljs","easelbone","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/ImageLoader","CatLab/Webremote/Messages/NavigateableProxy"],function(e,n,i,s,o){"use strict";return n.Views.Navigatable.extend({initialize:function(e){this.Webcontrol=e.Webcontrol,this.controllerState={activePlayers:0,minPlayers:0,maxPlayers:0,connectInstructions:[""],startAndLoginInstructions:[""],showInactivePlayers:!1},this.initializeNavigatable({orientation:this.ORIENTATION.HORIZONTAL}),this.messageBus=e.messageBus,this.assets=e.assets,this.initialized=!1,this.users=[],this.messageBus.toController("nav:controls",{controls:this._controls}),this.attachMessageBus(this.messageBus),this.on("stage:removed",this.destroy.bind(this))},initializeContent:function(){this.initialized||(this.initialized=!0,this.controllerState.showInactivePlayers?this.setScreen(new this.assets.PortalView):this.setScreen(new this.assets.PortalViewNoInactive),this.showInactivePlayers=this.controllerState.showInactivePlayers||!1,this.showInactivePlayers&&(this.connectedUsersContainer=new n.EaselJS.Placeholder(this.getScreen().connectedUsers),this.connectedUsers=new n.Controls.FloatContainer(function(e){return this.getUserIcon(e)}.bind(this),6),this.connectedUsersContainer.addChild(this.connectedUsers)),this.activeUsersContainer=new n.EaselJS.Placeholder(this.getScreen().activeUsers),this.activeUsers=new n.Controls.FloatContainer(function(e){return this.getUserIcon(e)}.bind(this),this.showInactivePlayers?6:12),this.activeUsersContainer.addChild(this.activeUsers),void 0!==this.getScreen().start&&(this.start=new n.Controls.Button(this.getScreen().start),this.start.setText(i.t("Start")),this.start.on("click",function(){this.messageBus.toController("start")}.bind(this)),this.addControl(this.start)),void 0!==this.getScreen().back&&(this.back=new n.Controls.Button(this.getScreen().back),this.back.setText(i.t("Back")),this.back.on("click",function(){this.messageBus.toController("back")}.bind(this)),this.addControl(this.back)),this.findPlaceholders("instructionHeader").forEach(function(e){e.addChild(new n.EaselJS.BigText(i.t("Instructions")))}),this.findPlaceholders("activePlayersHeader").forEach(function(e){e.addChild(new n.EaselJS.BigText(i.t("Active devices")))}),this.findPlaceholders("connectedPlayersHeader").forEach(function(e){e.addChild(new n.EaselJS.BigText(i.t("Connected devices")))}),this.instructionTexts=[],this.findPlaceholders("instructionText").forEach(function(e){var t=new n.EaselJS.BigText(this.getInstructionText());this.instructionTexts.push(t),e.addChild(t)}.bind(this)),this.activePlayerTexts=[],this.findPlaceholders("activePlayers").forEach(function(e){var t=new n.EaselJS.BigText(this.getActiveUsersText());this.activePlayerTexts.push(t),e.addChild(t)}.bind(this)))},attachMessageBus:function(e){e.addViewListener(this)},handleIncomingMessage:function(e,t){if(!o.handleMessage(e,t,this,"portal:"))switch(e){case"state:change":this.controllerState=t.state,this.initialized||this.initializeContent(),this.showCurrentAndMaxUsers();break;case"alert":this.alert(i.t(t.localized));break;case"users:update":this.users=t.users,this.refreshUsers();break;case"auth:open":this.addAuthenticationView();break;case"portal:destroy":this.destroy()}},getActiveUsersText:function(){return this.controllerState.activePlayers+"/"+this.controllerState.maxPlayers},getInstructionText:function(){return i.t(this.controllerState.connectInstructions)+"\n"+i.t(this.controllerState.startAndLoginInstructions)},getUserIcon:function(e){var t,i;return e?e.profile?(t=new this.assets.UserIconAuthenticated,this.addControllerIcon(t,e)):t=this.getControllerIcon(e):t=this.getControllerIcon(),e&&(i=t.PlayerColor)&&new n.EaselJS.Placeholder(i).addChild(new n.EaselJS.Fill(e.color)),e&&this.setUserDetails(t,e),t},addControllerIcon:function(e,t){var i;e.ControllerIcon&&(e=new n.EaselJS.Placeholder(e.ControllerIcon),i=this.getControllerIcon(t),e.addChild(i),i.scaleX=i.scaleY=.5,t)&&(e=i.PlayerColor)&&new n.EaselJS.Placeholder(e).addChild(new n.EaselJS.Fill(t.color))},getControllerIcon:function(e){if(e)switch(e.type){case"keyboard":return new this.assets.UserIconKeyboard;case"tablet":return new this.assets.UserIconTablet;case"phone":return new this.assets.UserIconPhone;case"gamepad":return new this.assets.UserIconGamepad}return new this.assets.UserIcon},loading:function(){},alert:function(e){alert(e)},refreshUsers:function(){this.showCurrentAndMaxUsers(),this.showInformation(),this.reloadUserIcons()},showCurrentAndMaxUsers:function(){this.getScreen().playercount&&(this.getScreen().playercount.text=this.controllerState.activePlayers+"/"+this.controllerState.maxPlayers),this.activePlayerTexts.forEach(function(e){e.setText(this.controllerState.activePlayers+"/"+this.controllerState.maxPlayers)}.bind(this)),this.getScreen().login&&(this.getScreen().login.text=i.t(this.controllerState.startAndLoginInstructions))},showInformation:function(){var e=i.t(this.controllerState.connectInstructions);this.getScreen().login?this.getScreen().login.text=i.t(this.controllerState.startAndLoginInstructions):e+="\n "+i.t(this.controllerState.startAndLoginInstructions),this.getScreen().token&&(this.getScreen().token.text=e),this.instructionTexts.forEach(function(e){e.setText(this.getInstructionText())}.bind(this))},removeAllUserIcons:function(){this.showInactivePlayers&&this.connectedUsers.removeAllChildren(),this.activeUsers.removeAllChildren()},reloadUserIcons:function(){var t=24,i=24;this.showInactivePlayers||(i=48),this.removeAllUserIcons(),this.users.forEach(function(e){e.active?i<=0||(i--,this.activeUsers.createElement(e)):!this.showInactivePlayers||t<=0||(t--,this.connectedUsers.createElement(e))}.bind(this))},setUserDetails:function(e,t){var i;t.profile&&e.userimage&&(i=new n.EaselJS.Placeholder(e.userimage),s.loadImage(t.profile.image).then(function(e){i.addChild(new n.EaselJS.Fill(e))}))},addAuthenticationView:function(){var e=this.Webcontrol.authenticationView(this.messageBus);this.el.addChild(e),e.on("view:close",function(){e.easelboneLayer.view.trigger("stage:removed"),this.el.removeChild(e),this.messageBus.toController("auth:close")}.bind(this))},render:function(){this.el.addChild(this.getScreen()),this.refreshUsers()},destroy:function(){this.messageBus.removeViewListener(this)}})}),define("CatLab/Webremote/CreateJS/Views/AuthenticationView",["easelbone","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/ImageLoader","CatLab/Webremote/Messages/NavigateableProxy","CatLab/Webremote/Controllers/OAuth2"],function(s,i,o,n,r){"use strict";return s.Views.Navigatable.extend({initialize:function(e){this.initializeNavigatable(),this.assets=e.assets,this.screen=new e.assets.Signin,this.screen.close.on("click",function(){this.close()}.bind(this)),this.linkAccount=new s.Controls.Button(this.screen.linkAccount),this.titlePlaceholder=null,this.explanationPlaceholder=null,s.Helpers.MovieClipHelper.findFromNames(["title"],[this.screen]).forEach(function(e){this.titlePlaceholder=new s.EaselJS.Placeholder(e)}.bind(this)),s.Helpers.MovieClipHelper.findFromNames(["explanation"],[this.screen]).forEach(function(e){this.explanationPlaceholder=new s.EaselJS.Placeholder(e)}.bind(this)),this.titlePlaceholder&&(t=new s.EaselJS.BigText(i.t("Select your profile"),null,null,"left"),this.titlePlaceholder.addChild(t)),this.setLoginUrlText(),this.linkAccount.on("click",function(){r.link(function(e){this.selectUser(e)}.bind(this))}.bind(this));var t=new s.Controls.ScrollArea(this.screen.accounts);this.users=new s.Controls.FloatContainer(function(e){return this.getUserObject(e)}.bind(this),4),t.content.addChild(this.users),this.updateUsers([]),this.on("removed",function(){this.trigger("close")}.bind(this)),this.setBack(function(){this.close()}.bind(this)),this.attachMessageBus(e.messageBus),this.on("stage:removed",this.destroy.bind(this))},attachMessageBus:function(e){(this.messageBus=e).addViewListener(this)},handleIncomingMessage:function(e,t){if(!n.handleMessage(e,t,this,"auth:"))switch(e){case"auth:users:update":this.updateUsers(t.users);break;case"auth:close":this.close();break;case"auth:loginurl":this.setLoginUrl(t.url);break;case"auth:destroy":this.destroy()}},updateUsers:function(e){this.resetOptions(),this.users.removeAllChildren();for(var t=0;t<e.length;t++)this.users.createElement(e[t]);this.addControl(this.linkAccount)},getUserObject:function(e){var t,i=new this.assets.UserModel,n=(i.namePlaceholder?i.text=i.namePlaceholder:i.name&&(i.text=i.name),new s.Controls.Button(i));return e&&(n.setText(e.name),t=new s.EaselJS.Placeholder(i.picture),o.loadImage(e.image).then(function(e){t.addChild(new s.EaselJS.Fill(e))}),n.on("click",function(){this.selectUser(e)}.bind(this)),this.addControl(n)),i},selectUser:function(e){this.messageBus.toController("auth:select-user",{user:{id:e.id}})},close:function(){this.trigger("close"),this.messageBus.toController("auth:close")},render:function(){this.el.addChild(this.screen)},setLoginUrl:function(e){this.loginUrl=e,this.setLoginUrlText()},setLoginUrlText:function(){var e;this.linkAccount&&(this.linkAccount.setText(i.t("Login to add profile")),this.explanationPlaceholder)&&(e=new s.EaselJS.BigText(i.t("Or surf to %s to login from your phone.",this.loginUrl)),this.explanationPlaceholder.removeAllChildren(),this.explanationPlaceholder.addChild(e))},destroy:function(){this.messageBus.removeViewListener(this)}})}),s=i=i||{},h=h||{},t=a=a||{},void 0!==t.Container&&(s.properties={width:720,height:480,fps:24,color:"#FFFFFF",manifest:[]},(s.UserIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#592230").s().p("Al2F2IAArsILsAAIAALsg"),this.shape.setTransform(37.5,37.5),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,75,75),e.frameBounds=[A],(s.TextPlaceholderBackground=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FF00FF").s().p("AnzHzIAAvmIPmAAIAAPmg"),this.shape.setTransform(50,50),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,100,100),e.frameBounds=[A],(s.Marker=function(){this.initialize()}).prototype=e=new t.Container,e.nominalBounds=A=null,e.frameBounds=[A],(s.PointerInactive=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#320B1F").s().p("AjQiRIENALICfCGIiTCHIkkALg"),this.shape.setTransform(-22,0),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-44,-14.7,44.1,29.4),e.frameBounds=[A],(s.PointerActive=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#006633").s().p("AjQiRIENALICfCGIiTCHIkkALg"),this.shape.setTransform(-22,.1),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-44,-14.6,44.1,29.4),e.frameBounds=[A],(s.Checkbox=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{Up:0,Over:1,Down:2,Hit:3}),this.frame_0=function(){this.stop()},this.frame_1=function(){this.stop()},this.frame_2=function(){this.stop()},this.frame_3=function(){this.stop()},this.timeline.addTween(t.Tween.get(this).call(this.frame_0).wait(1).call(this.frame_1).wait(1).call(this.frame_2).wait(1).call(this.frame_3).wait(1)),this.shape=new t.Shape,this.shape.graphics.f("#FF873C").s().p("AizAVQgagpgVgoIgXgsIADgQIADgEQAFgEAJgCQAKAZATAkQANAYASAdQAxBQAOAeQALg8CFhhIAIgGQCGhhA7AVIAGgCQAEACABAPQgmAPg/ApQgpAcgpAiQhQBChRBfQgngxguhPg"),this.shape.setTransform(25,23),this.shape._off=!0,this.timeline.addTween(t.Tween.get(this.shape).wait(2).to({_off:!1},0).wait(2)),this.shape_1=new t.Shape,this.shape_1.graphics.f().s("#8B504F").ss(5).p("ABfheIAAC9Ii9AAIAAi9g"),this.shape_1.setTransform(19.2,19.2,2.023,2.023),this.shape_2=new t.Shape,this.shape_2.graphics.f("#592230").s().p("AheBeIAAi8IC9AAIAAC8g"),this.shape_2.setTransform(19.2,19.2,2.023,2.023),this.shape_3=new t.Shape,this.shape_3.graphics.f("#FFC39F").s().p("AheBeIAAi8IC9AAIAAC8g"),this.shape_3.setTransform(19.2,19.2,2.023,2.023),this.shape_4=new t.Shape,this.shape_4.graphics.f().s("#8B504F").ss(5).p("ADAi/IAAF/Il/AAIAAl/g"),this.shape_4.setTransform(-13.2,12.3,1,1,0,0,0,-32.4,-6.9),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape_2},{t:this.shape_1,p:{x:19.2,y:19.2}}]}).to({state:[{t:this.shape_3,p:{x:19.2,y:19.2}},{t:this.shape_1,p:{x:19.2,y:19.2}}]},1).to({state:[{t:this.shape_2},{t:this.shape_1,p:{x:19.2,y:19.2}}]},1).to({state:[{t:this.shape_4},{t:this.shape_3,p:{x:19.4,y:18.9}},{t:this.shape_1,p:{x:19.4,y:18.9}}]},1).wait(1))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(-2.5,-2.5,43.5,43.4),e.frameBounds=[A,A,new t.Rectangle(-2.5,-2.5,52.5,43.4),new t.Rectangle(-2.5,-2.8,52.5,43.7)],(s.CogVector=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#282A1F").s().p("Ag/MAQgehhgLhlQgbgEgvgOIgkgNQgUgIgOgIQhLBKhXA3QgsgbgwgqQAkhoAvhQQgdgegUgdQgKgLgLgUIgUghQhpAQhlgGQgVg1gNg5QBOg4BhgtQgCgPgBgXIgCglQABgxAEgZQhggzhMg/QAIgiAchLQBoABBhAVQAZgtAQgTQAUgdAdgeQgshWgdhrQA9gwAhgTQBQA8BGBMQAOgIAUgIIAkgNQAvgNAbgFQAShsAlhbQAwgEBBAFQAeBhALBlQAbAFAvANIAkANQAUAIAOAIQBLhKBXg3QAsAbAwAqQgkBogvBQQAdAeAUAdQAQATAZAtQBpgQBlAGQAWA5AMA1QhOA4hhAtQAEAZABAxIgCAlQgBAXgCAPQBgAzBMA/QgHAigdBLQhogBhhgVQgZAtgQATQgUAdgdAeQAsBWAdBrQg9AwghATQhQg8hGhMQgOAIgUAIIgkANQgvAOgbAEQgSBsglBbQgXACgaAAQgdAAgjgDgAhtlTQg3ASgtAhQgvAiggAtQhDBagCB3QACB4BDBaQAgAtAvAiQAtAhA3ASQA1ASA4AAQA5AAA1gSQA3gSAtghQAvgiAggtQBDhaACh4QgCh3hDhaQgggtgvgiQgtghg3gSQg1gRg5AAQg4AAg1ARg"),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-75,-77.1,150.1,154.3),e.frameBounds=[A],(s.ListUsers=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#00CCFF").s().p("A5DK/IAA19MAyHAAAIAAV9g"),this.shape.setTransform(158.5,71),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-2,.6,320.9,140.7),e.frameBounds=[A],(s.lstUsers=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#0066CC").s().p("A5YGoIAAtQMAywAAAIAANQg"),this.shape.setTransform(162.5,42.5),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,325,85),e.frameBounds=[A],(s.SmartphoneIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FFFFFF").s().p("AhNCvQgJAAgHgIQgHgGAAgKIAAksQAAgLAHgGQAHgIAJAAICaAAQAKAAAHAIQAHAGAAALIAAEsQAAAKgHAGQgHAIgKAAgAgHCPQgEADAAAFQAAAFAEADQAEAEADAAQAEAAAEgEQADgDAAgFQAAgFgDgDQgEgDgEAAQgDAAgEADgAhUCDICoAAIAAkLIioAAgAgaiaQAAABAAABQAAAAAAABQABAAAAAAQABABABAAIAwAAQAAAAABgBQAAAAAAAAQABgBAAAAQAAgBAAgBQAAAAAAgBQAAAAgBAAQAAgBAAAAQgBAAAAAAIgwAAQgBAAgBAAQAAAAgBABQAAAAAAAAQAAABAAAAg"),this.shape.setTransform(42.9,42,1.857,1.857),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(24.1,9.5,37.7,65),e.frameBounds=[A],(s.TabletIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FFFFFF").s().p("AhvCeQgKAAgHgHQgGgHAAgJIAAkNQAAgKAGgGQAHgHAKAAIDfAAQAKAAAGAHQAHAHAAAJIAAENQAAAJgHAHQgGAHgKAAgAgeCLIA8AAIAAgHIg8AAgAhvBuIDfAAIAAjvIjfAAg"),this.shape.setTransform(43,43,1.642,1.642),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(20.8,17,44.6,52.1),e.frameBounds=[A],(s.JoystickIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FFFFFF").s().p("AA1BaQgYgagdABQgdgBgYAaQgYAZgNAAQgMAAgIgMQgIgMgBgUQABgqAVggQAUgeAVAAQANAAANAIQAOAJAIACQACgXALgPQASgVAlgBQAYAAALgOQAEgHAAgJQAAgKALAAQADABADACQAEAEAAADQAAASgNAOQgQASgfABQgsAAgGAmQAGgBAQgJQAMgJANABQAUAAAUAeQAXAgAAAqQgBAVgIAMQgJALgMAAQgMAAgZgZgAAzAuQgEAEAAAFQAAAFADAEQAEADAGAAQAFABADgEQAEgEAAgFQAAgFgEgEQgEgEgEgBQgFABgEAEgAhZAtIAVAAIAAAUIAUAAIAAgUIATAAIAAgUIgTAAIAAgVIgUAAIAAAVIgVAAgABGAaQgDADAAAGQAAAFADAEQAFADAEAAQAFAAAEgDQAEgFAAgEQAAgGgEgDQgEgFgFAAQgEAAgFAFgAAeAaQgEADAAAGQAAAFAEAEQAEADAFAAQAGAAADgDQAEgEAAgFQAAgGgDgDQgFgFgEAAQgFAAgFAFgAAyAFQgDAFAAAEQAAAGAEAEQAEAEAFAAQAEAAAEgEQAEgEAAgGQAAgEgEgFQgEgEgEAAQgGAAgEAEg"),this.shape.setTransform(42,42,2.476,2.476),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(12.3,13.5,59.5,57),e.frameBounds=[A],(s.KeyboardIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FFFFFF").s().p("AkMEzQgiAAgXgWQgYgXAAgjIAAjYQAAggAYgXQAXgXAiAAID3AAQAAhLAkgeQAWgTA0gHQApgFAOgLQAUgRAAg1QAAgWAXAAQAXAAABAWQAABOgoAeQgWASg1AHQgpAGgOAKQgUAQAAA0ID2AAQAjAAAWAXQAZAXAAAgIAADYQAAAjgZAXQgWAWgjAAgADWDjIA1AAIAAg1Ig1AAgAi8DjIF3AAIAAg1Il3AAgAkMDjIA1AAIAAg1Ig1AAgACgCTIA2AAIAAg4Ig2AAgABQCTIA1AAIAAg4Ig1AAgAAACTIA1AAIAAg4Ig1AAgAhRCTIA2AAIAAg4Ig2AAgAihCTIA1AAIAAg4Ig1AAgAjyCTIA2AAIAAg4Ig2AAgADWBBIA1AAIAAg2Ig1AAgACFBBIA2AAIAAg2Ig2AAgAA1BBIA1AAIAAg2Ig1AAgAgbBBIA1AAIAAg2Ig1AAgAhsBBIA2AAIAAg2Ig2AAgAi8BBIA2AAIAAg2Ig2AAgAkMBBIA1AAIAAg2Ig1AAg"),this.shape.setTransform(42,41.8,.773,.773),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(15,18,54.1,47.6),e.frameBounds=[A],(s.CloseButton=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f().s("#000000").ss(1,1,1).p("AAPABQAjgvAAgXQAhhJAIgLAhjiQIByCRAiICaIBLAAQAjhXAgg2QAFgGAEgGIB6CZ"),this.shape.setTransform(10,19.5),this.shape_1=new t.Shape,this.shape_1.graphics.f("#666666").s().p("Ai+C/IAAl9IF9AAIAAF9g"),this.shape_1.setTransform(12.6,19.4),this.addChild(this.shape_1,this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-6.6,.3,38.3,38.3),e.frameBounds=[A],(s.btnLink=function(){this.initialize(),this.text=new t.Text("Link a new account","20px 'Times New Roman'","#FF0033"),this.text.lineHeight=22,this.text.lineWidth=235,this.text.setTransform(2.3,-1.7),this.shape=new t.Shape,this.shape.graphics.f("#666666").s("#FFFFFF").ss(1,1,1).dr(-83.5,-13,167,26),this.shape.setTransform(83.5,13),this.addChild(this.shape,this.text)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-1,-1.7,242.5,28.7),e.frameBounds=[A],(s.Placeholder=function(){this.initialize(),this.instance=new s.TextPlaceholderBackground,this.addChild(this.instance)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,100,100),e.frameBounds=[A],(s.Pointer=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{Up:0,Over:1,Down:2,Out:3}),this.instance=new s.PointerInactive("synched",0,!1),this.instance.setTransform(3,5,.639,.774,90,0,0,7.8,-3.9),this.instance_1=new s.PointerActive("synched",0),this.instance_1.setTransform(3,5,.639,.774,90,0,0,7.8,-3.9),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.instance}]}).to({state:[{t:this.instance_1,p:{x:3,y:5}}]},1).to({state:[{t:this.instance_1,p:{x:3,y:5}}]},1).to({state:[{t:this.instance_1,p:{x:3.1,y:5.1}}]},1).wait(1))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(-11.4,-28.1,22.8,28.2),e.frameBounds=[A,A,A,new t.Rectangle(-11.4,-28,22.8,28.2)],(s.Button=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{Over:1,"Over-NoAnim":6,Up:7,"Up-NoAnim":11,Down:12,Hit:13}),this.frame_0=function(){this.stop()},this.frame_6=function(){this.stop()},this.frame_11=function(){this.stop()},this.frame_12=function(){this.stop()},this.frame_13=function(){this.stop()},this.timeline.addTween(t.Tween.get(this).call(this.frame_0).wait(6).call(this.frame_6).wait(5).call(this.frame_11).wait(1).call(this.frame_12).wait(1).call(this.frame_13).wait(1)),this.text=new s.Placeholder,this.text.setTransform(13.7,13.7,1.739,.494,0,.4,.5,.1,.8),this.timeline.addTween(t.Tween.get(this.text).wait(1).to({scaleX:1.89,rotation:.4,skewX:0,skewY:0,x:5.7},0).to({scaleY:.57,rotation:5.4,x:8.7,y:1.7},5).to({scaleY:.54,rotation:5.2,x:8.4,y:2},1).to({scaleY:.49,rotation:.4,x:5.7,y:13.7},4).wait(1).to({rotation:.4},0).wait(2)),this.shape=new t.Shape,this.shape.graphics.f("#0F0609").s().p("A42D+Ii+oDMA3pgAIIkyIbg"),this.shape.setTransform(103.3,39.2,.566,1),this.shape_1=new t.Shape,this.shape_1.graphics.f("#0F0609").s().p("AxBE1IiBp0MAmGgAKIjSKTg"),this.shape_1.setTransform(103.4,39.1,.821,.821),this.shape_2=new t.Shape,this.shape_2.graphics.f("#0F0609").s().p("AuwDkIhboZMAgWABDIjGIog"),this.shape_2.setTransform(104.2,39.3),this.shape_3=new t.Shape,this.shape_3.graphics.f("#0F0609").s().p("AvXDTIhOoqMAhLAB9IjaIyg"),this.shape_3.setTransform(104.8,39),this.shape_4=new t.Shape,this.shape_4.graphics.f("#0F0609").s().p("AvzDHIhFo2MAhxACmIjpI5g"),this.shape_4.setTransform(105.2,38.9),this.shape_5=new t.Shape,this.shape_5.graphics.f("#0F0609").s().p("AwEDAIhAo+MAiJADAIjyI9g"),this.shape_5.setTransform(105.5,38.7),this.shape_6=new t.Shape,this.shape_6.graphics.f("#0F0507").s().p("AvmDNIhKoxMAhhACUIjiI1g"),this.shape_6.setTransform(105,38.9),this.shape_7=new t.Shape,this.shape_7.graphics.f("#0F0305").s().p("AvDDbIhVohMAgxABgIjRItg"),this.shape_7.setTransform(104.5,39.2),this.shape_8=new t.Shape,this.shape_8.graphics.f("#0F0202").s().p("AugDrIhgoTMAgBAAsIi+Ikg"),this.shape_8.setTransform(103.9,39.4),this.shape_9=new t.Shape,this.shape_9.graphics.f("#0F0000").s().p("At9D+IhroDIfRgIIisIbg"),this.shape_9.setTransform(103.4,39.2),this.shape_10=new t.Shape,this.shape_10.graphics.f("#990000").s().p("AxBE1IiBp0MAmGgAKIjSKTg"),this.shape_10.setTransform(103.4,39.1,.821,.821),this.shape_11=new t.Shape,this.shape_11.graphics.f("#0F51B8").s().p("AxBE1IiBp0MAmGgAKIjSKTg"),this.shape_11.setTransform(103.4,39.1,.821,.821),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape}]}).to({state:[{t:this.shape_1,p:{scaleX:.821,scaleY:.821,rotation:0,x:103.4,y:39.1}}]},1).to({state:[{t:this.shape_2}]},1).to({state:[{t:this.shape_3}]},1).to({state:[{t:this.shape_4}]},1).to({state:[{t:this.shape_5}]},1).to({state:[{t:this.shape_1,p:{scaleX:.903,scaleY:.903,rotation:5.4,x:102.8,y:39.2}}]},1).to({state:[{t:this.shape_1,p:{scaleX:.903,scaleY:.903,rotation:5.4,x:102.8,y:39.2}}]},1).to({state:[{t:this.shape_6}]},1).to({state:[{t:this.shape_7}]},1).to({state:[{t:this.shape_8}]},1).to({state:[{t:this.shape_9}]},1).to({state:[{t:this.shape_10}]},1).to({state:[{t:this.shape_11}]},1).wait(1)),this.shape_12=new t.Shape,this.shape_12.graphics.f().s("#0F0609").ss(2).p("ATyluMgnlAAPIB4LOMAi0gAUg"),this.shape_12.setTransform(103.9,39.4,.826,.821,0,0,0,-.2,0),this.shape_13=new t.Shape,this.shape_13.graphics.f().s("#0A6006").ss(2).p("Aw0kaMAhpgAsIiVJgI9lAtg"),this.shape_13.setTransform(103.5,39.3,1,1,0,0,0,.1,0),this.shape_14=new t.Shape,this.shape_14.graphics.f().s("#05A503").ss(2).p("AxSkVMAikgBFIiSJyI+ZBDg"),this.shape_14.setTransform(103.1,39.2,1,1,0,0,0,.1,0),this.shape_15=new t.Shape,this.shape_15.graphics.f().s("#02D701").ss(2).p("AxmkRMAjNgBYIiQKAI+9BTg"),this.shape_15.setTransform(102.7,39.2,1,1,0,0,0,.1,0),this.shape_16=new t.Shape,this.shape_16.graphics.f().s("#01F500").ss(2).p("AxykPMAjlgBiIiOKHI/UBdg"),this.shape_16.setTransform(102.5,39.1,1,1,0,0,0,.1,0),this.shape_17=new t.Shape,this.shape_17.graphics.f().s("#00FF00").ss(2).p("ATyluMgnlAAPIB4LOMAi0gAUg"),this.shape_17.setTransform(103.4,39.4,.903,.903,-2.2,0,0,-.2,0),this.shape_18=new t.Shape,this.shape_18.graphics.f().s("#0FFF00").ss(2).p("ATyluMgnlAAPIB4LOMAi0gAUg"),this.shape_18.setTransform(103.4,39.4,.903,.903,-2.2,0,0,-.2,0),this.shape_19=new t.Shape,this.shape_19.graphics.f().s("#0FC102").ss(2).p("AxdkTMAi6gBPIiQJ6I+uBMg"),this.shape_19.setTransform(102.9,39.2,1,1,0,0,0,.1,0),this.shape_20=new t.Shape,this.shape_20.graphics.f().s("#0F8305").ss(2).p("AxDkXMAiGgA5IiTJpI9/A4g"),this.shape_20.setTransform(103.3,39.3,1,1,0,0,0,.1,0),this.shape_21=new t.Shape,this.shape_21.graphics.f().s("#0F4407").ss(2).p("AwpkbMAhSgAjIiVJZI9SAkg"),this.shape_21.setTransform(103.7,39.3,1,1,0,0,0,.1,0),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape_12}]}).to({state:[{t:this.shape_12}]},1).to({state:[{t:this.shape_13}]},1).to({state:[{t:this.shape_14}]},1).to({state:[{t:this.shape_15}]},1).to({state:[{t:this.shape_16}]},1).to({state:[{t:this.shape_17}]},1).to({state:[{t:this.shape_18}]},1).to({state:[{t:this.shape_19}]},1).to({state:[{t:this.shape_20}]},1).to({state:[{t:this.shape_21}]},1).to({state:[{t:this.shape_12}]},1).to({state:[{t:this.shape_12}]},1).to({state:[{t:this.shape_12}]},1).wait(1)),this.timeline.addTween(t.Tween.get(this.shape_12).wait(1).to({scaleX:.82},0).to({_off:!0},1).wait(9).to({_off:!1},0).wait(3)),this.shape_22=new t.Shape,this.shape_22.graphics.f("#592230").s().p("A0sFHIAysmMAonACoIloMXg"),this.shape_22.setTransform(109.6,39.4,.826,.821),this.shape_23=new t.Shape,this.shape_23.graphics.f("#592230").s().p("AxqECIA4qsMAidAC7Ik/Kag"),this.shape_23.setTransform(109.5,39.1),this.shape_24=new t.Shape,this.shape_24.graphics.f("#592230").s().p("AyMD5IBDq8MAjXADgIlTKng"),this.shape_24.setTransform(109.6,38.9),this.shape_25=new t.Shape,this.shape_25.graphics.f("#592230").s().p("AylD0IBMrKMAj/AD8IlfKxg"),this.shape_25.setTransform(109.5,38.8),this.shape_26=new t.Shape,this.shape_26.graphics.f("#592230").s().p("Ay0DwIBRrRMAkYAEMIlnK3g"),this.shape_26.setTransform(109.5,38.7),this.shape_27=new t.Shape,this.shape_27.graphics.f("#592230").s().p("AyaD2IBIrEMAjtADwIlZKsg"),this.shape_27.setTransform(109.6,38.9),this.shape_28=new t.Shape,this.shape_28.graphics.f("#592230").s().p("Ax7D9IA9q0MAi7ADOIlKKhg"),this.shape_28.setTransform(109.6,39.1),this.shape_29=new t.Shape,this.shape_29.graphics.f("#592230").s().p("AxdEFIA0qlMAiGACsIk3KVg"),this.shape_29.setTransform(109.6,39.2),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape_22}]}).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_23}]},1).to({state:[{t:this.shape_24}]},1).to({state:[{t:this.shape_25}]},1).to({state:[{t:this.shape_26}]},1).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_27}]},1).to({state:[{t:this.shape_28}]},1).to({state:[{t:this.shape_29}]},1).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_22}]},1).wait(1)),this.timeline.addTween(t.Tween.get(this.shape_22).wait(1).to({scaleX:.82,x:109.5},0).to({_off:!0},1).wait(4).to({_off:!1,scaleX:.9,scaleY:.9,rotation:3,x:109.6},0).wait(1).to({_off:!0},1).wait(3).to({_off:!1,scaleX:.82,scaleY:.82,rotation:0,x:109.5},0).wait(3))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(-1.8,0,220.9,78.8),e.frameBounds=[A,new t.Rectangle(-1.1,0,219.5,78.8),new t.Rectangle(-5.5,-3.6,228.3,85.4),new t.Rectangle(-8.9,-6.3,235.1,90.6),new t.Rectangle(-11.3,-8.3,240,94.3),new t.Rectangle(-12.8,-9.5,242.9,96.5),A=new t.Rectangle(-13.3,-9.9,243.9,97.2),A,new t.Rectangle(-10.2,-7.4,237.8,92.6),new t.Rectangle(-7.2,-4.9,231.7,88),new t.Rectangle(-4.1,-2.5,225.5,83.4),A=new t.Rectangle(-1.1,0,219.5,78.8),A,A],(s.Cog=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{}),this.frame_14=function(){this.gotoAndPlay(1)},this.timeline.addTween(t.Tween.get(this).wait(14).call(this.frame_14).wait(1)),this.instance=new s.CogVector("synched",0),this.instance.setTransform(75.1,77.1),this.timeline.addTween(t.Tween.get(this.instance).to({rotation:36},14).wait(1))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(0,0,150.2,154.3),e.frameBounds=[A,new t.Rectangle(-.6,.1,151.6,154.2),new t.Rectangle(-1.2,.1,152.7,154.1),new t.Rectangle(-1.6,.3,153.5,153.8),new t.Rectangle(-1.9,.6,154,153.1),new t.Rectangle(-2,1.1,154.1,152.1),new t.Rectangle(-2,1.7,154.1,151),new t.Rectangle(-2,2.2,154.1,149.9),new t.Rectangle(-2,1.5,154.1,151.3),new t.Rectangle(-2,1,154.1,152.4),new t.Rectangle(-1.8,.6,153.8,153.3),new t.Rectangle(-1.4,.2,153,153.8),new t.Rectangle(-1,.2,152.2,154),new t.Rectangle(-.4,.2,150.9,154),new t.Rectangle(0,.1,150.2,154.1)],(s.Signin=function(){this.initialize(),this.close=new s.CloseButton,this.close.setTransform(526.3,132.5,1,1,0,0,0,10,19.5),this.users=new s.ListUsers,this.users.setTransform(206.7,159.2);var e=new t.Shape;e._off=!0,e.graphics.p("A4tIoIAAsrMAypAAAIAAMrg"),e.setTransform(166.1,55.3),this.btnLinkAccount=new s.btnLink,this.btnLinkAccount.setTransform(367.6,325.3,1,1,0,0,0,83.5,13),this.title=new t.Text("Select your profile","20px 'Times New Roman'","#FFFFFF"),this.title.name="title",this.title.lineHeight=22,this.title.lineWidth=217,this.title.setTransform(202.8,116.1),this.shape=new t.Shape,this.shape.graphics.f("#999999").s().p("A68SPMAAAgkdMA15AAAMAAAAkdg"),this.shape.setTransform(367.5,229.7),this.shape_1=new t.Shape,this.shape_1.graphics.f("rgba(0,0,0,0.498)").s().p("Eg4TAlfMAAAhK9MBwnAAAMAAABK9g"),this.shape_1.setTransform(359.5,240),this.addChild(this.shape_1,this.shape,this.title,this.btnLinkAccount,this.users,this.close)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-1,0,721,480),e.frameBounds=[A],(s.PortalView=function(){this.initialize(),this.ListActiveUsers=new s.lstUsers,this.ListActiveUsers.setTransform(523.3,139.8,1,1,0,0,0,162.2,42),this.ListConnectedDevices=new s.lstUsers,this.ListConnectedDevices.setTransform(190.3,139.8,1,1,0,0,0,163.3,42),this.shape=new t.Shape,this.shape.graphics.f().s("rgba(255,255,255,0)").ss(.1,1,1).p("AvJkmIeTAAIAAJNI+TAAg"),this.shape.setTransform(327,308.5),this.text=new t.Text("Active users","30px 'Times New Roman'","#FFFFFF"),this.text.lineHeight=32,this.text.lineWidth=284,this.text.setTransform(374,25.3),this.text_1=new t.Text("Connected users","30px 'Times New Roman'","#FFFFFF"),this.text_1.lineHeight=32,this.text_1.lineWidth=284,this.text_1.setTransform(27,25.3),this.shape_1=new t.Shape,this.shape_1.graphics.f().s("#666666").ss(1,1,1).p("EgzYAAAMBmyAAA"),this.shape_1.setTransform(357.1,65),this.shape_2=new t.Shape,this.shape_2.graphics.rf(["#333333","#000000","#000000"],[0,.6,1],0,0,0,0,0,432.7).s().p("Eg4PAlfMAAAhK+MBwfAAAMAAABK+gEAy8gbVMhmyAAAg"),this.shape_2.setTransform(360,240),this.addChild(this.shape_2,this.shape_1,this.text_1,this.text,this.shape,this.ListConnectedDevices,this.ListActiveUsers)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,720,480),e.frameBounds=[A],(s.User=function(){this.initialize(),this.boundary=new s.Marker,this.boundary.setTransform(79.4,118.4),this.picture=new s.Placeholder,this.picture.setTransform(37.5,37.5,.75,.75,0,0,0,50,50),this.name=new t.Text("User","15px 'Times New Roman'"),this.name.name="name",this.name.lineHeight=17,this.name.lineWidth=71,this.name.setTransform(0,75),this.shape=new t.Shape,this.shape.graphics.f("rgba(0,0,0,0.498)").s().p("Al2F2IAArsILsAAIAALsg"),this.shape.setTransform(37.5,37.5),this.addChild(this.shape,this.name,this.picture,this.boundary)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,75,114.2),e.frameBounds=[A],(s.Slider=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{Up:0,Over:1,Down:2,Hit:3}),this.frame_0=function(){this.pointer.gotoAndStop("Up"),this.stop()},this.frame_1=function(){this.stop(),this.pointer.gotoAndStop("Over")},this.frame_2=function(){this.stop(),this.pointer.gotoAndStop("Down")},this.frame_3=function(){this.stop(),this.pointer.gotoAndStop("Out")},this.timeline.addTween(t.Tween.get(this).call(this.frame_0).wait(1).call(this.frame_1).wait(1).call(this.frame_2).wait(1).call(this.frame_3).wait(1)),this.pointer=new s.Pointer,this.pointer.setTransform(35,41.1,1,1,0,0,0,0,2),this.maximum=new s.Marker,this.maximum.setTransform(342,35),this.minimum=new s.Marker,this.minimum.setTransform(35,41),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.minimum},{t:this.maximum},{t:this.pointer}]}).wait(4)),this.shape=new t.Shape,this.shape.graphics.f().s("#320B1F").ss(4).p("AgY4mMAAxAxN"),this.shape.setTransform(186,26.5,1.113,1.111,-90,0,0,.1,0),this.shape_1=new t.Shape,this.shape_1.graphics.f("#320B1F").s().p("AgnAoQgQgRAAgXQAAgWAQgRQARgQAWAAQAXAAARAQQAQARAAAWQAAAXgQARQgRAQgXAAQgWAAgRgQg"),this.shape_1.setTransform(9.6,31.4,1.694,1.694,-90),this.shape_2=new t.Shape,this.shape_2.graphics.f("#320B1F").s().p("AgkAlQgQgPAAgWQAAgUAQgQQAPgQAVAAQAVAAAQAQQAQAQAAAUQAAAWgQAPQgQAQgVAAQgVAAgPgQg"),this.shape_2.setTransform(370.1,24,1.694,1.694,-90),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape_2},{t:this.shape_1},{t:this.shape}]}).to({state:[{t:this.shape_2},{t:this.shape_1},{t:this.shape}]},1).to({state:[{t:this.shape_2},{t:this.shape_1},{t:this.shape}]},1).to({state:[{t:this.shape_2},{t:this.shape_1},{t:this.shape}]},1).wait(1))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(0,10.9,379.1,30.1),e.frameBounds=[A,A,A,A],(s.portal=function(){this.initialize(),this.instance=new s.Signin,this.instance.setTransform(172.5,116.7,1,1,0,0,0,172.5,116.7),this.addChild(this.instance)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(359,240,721,480),e.frameBounds=[A]),define("CatLab/Webremote/assets/createjsassets",function(e){return function(){return e.ctlbrmtassets}}(this)),define("CatLab/Webremote/ViewFactory/CreatejsViewFactory",["CatLab/Webremote/Tools/Deferred"],function(t){"use strict";function e(e){void 0!==e&&this.setAssets(e)}var o,r,a,i=e.prototype;return i.initialize=function(){var e=new t;return this.loadAssets().then(function(){this.setAssets(this.assets),e.resolve()}.bind(this)),e},i.loadAssets=function(){var s=new t;return require(["CatLab/Webremote/CreateJS/LayerContainer","CatLab/Webremote/CreateJS/Views/PortalView","CatLab/Webremote/CreateJS/Views/AuthenticationView","CatLab/Webremote/assets/createjsassets"],function(e,t,i,n){o=e,r=t,a=i,s.resolve()}.bind(this)),s.promise()},i.portal=function(e){return e.assets=this.assets,new r(e)},i.authentication=function(e){return e.assets=this.assets,new a(e)},i.setAssets=function(e){void 0!==e&&(this.assets=e)},i.getContainer=function(){var e=new o;return e.setBounds(0,0,this.assets.properties.width,this.assets.properties.height),e.loading(),e},e}),define("CatLab/Webremote/FrontController",["CatLab/Webremote/Config","CatLab/Webremote/Polyfills","CatLab/Webremote/Tools/Tracker","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Controllers/Webremote","CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Controllers/Webcontrol","CatLab/Webremote/Tools/Smileys","CatLab/Webremote/Models/Users/KeyboardUser","CatLab/Webremote/Models/Users/CordovaUser","CatLab/Webremote/Models/Users/AndroidRemoteUser","CatLab/Webremote/Models/Users/DummyUser","CatLab/Webremote/Providers/SocketIO","CatLab/Webremote/Providers/Airconsole","CatLab/Webremote/Providers/Dummy","CatLab/Webremote/ViewFactory/ViewFactory","CatLab/Webremote/ViewFactory/CreatejsViewFactory","CatLab/Webremote/Messages/NavigateableProxy"],function(t,e,i,n,s,o,r,a,h,l,c,u,d,p,f,g,m,v){return{Config:function(e){t.set(e)},Tracker:i,Tools:n,Webremote:new s,Webcontrol:new r,OAuth2:o,Controls:{Keyboard:h,Cordova:l,AndroidRemote:c,Dummy:u},Controllers:{Webcontrol:r,Webremote:s},Models:{User:u},Providers:{SocketIO:d,Airconsole:p,Dummy:f},ViewFactories:{HtmlViewFactory:g,CreatejsViewFactory:m},Smileys:a,NavigateableProxy:v}}),define("catlabremote",["CatLab/Webremote/FrontController"],function(e){return e}),define("CatLab/EaselHacks/AlphaMaskFilter",[],function(e){function t(e){var n=this;this.createjs=e,Object.defineProperty(e.DisplayObject.prototype,"mask",{get:function(){return this.forceMask},set:function(e){var t,i=this;e?(i.originalMask=e,t=n.getFilterFromMask(e,i),i.filters=[t],i.cache(0,0,500,500)):null!==e&&(i.filters=null,i.cache(0,0,500,500))}}),e.DisplayObject.prototype.setMask=function(e){this.forceMask=e}}return t.prototype.getFilterFromMask=function(e,t){var i=this.createjs,n=e.graphics.getInstructions(),s=new i.Graphics;s.beginFill("#000000"),s.beginStroke("#000000");for(var o=0;o<n.length;o++)s.append(n[o]);e.graphics=s;var r=new i.Container,e=(r.addChild(e),r.scaleX=1/t.scaleX,r.scaleY=1/t.scaleY,r.y=-t.y,r.x=-t.x,new i.Container);return e.addChild(r),e.cache(0,0,1e3,1e3),new i.AlphaMaskFilter(e.cacheCanvas)},t}),define("CatLab/EaselHacks/FrontController",["CatLab/EaselHacks/AlphaMaskFilter"],function(e){return{AlphaMaskFilter:e}}),define("easelhacks",["CatLab/EaselHacks/FrontController"],function(e){return e}),define("CatLab/Webremote/Hacks",["easelhacks","easeljs"],function(e,t){new e.AlphaMaskFilter(t)});
1
+ var io,s,t,e,A,i,h,a;define("CatLab/Webremote/Tools/Net",[],function(){"use strict";return{loadJSON:function(e,t,i){var n=new XMLHttpRequest;n.onreadystatechange=function(){n.readyState===XMLHttpRequest.DONE&&200===n.status&&t&&t(JSON.parse(n.responseText))},n.onerror=function(e){e&&i(n,e)},n.open("GET",e,!0),n.send()}}}),define("CatLab/Webremote/Tools/Deferred",[],function(){function l(e){return"[object Array]"===Object.prototype.toString.call(e)}function c(e,t){if(l(e))for(var i=0;i<e.length;i++)t(e[i]);else t(e)}function u(e){var n="pending",s=[],o=[],r=[],a=null,i={done:function(){for(var e=0;e<arguments.length;e++)if(arguments[e])if(l(arguments[e]))for(var t=arguments[e],i=0;i<t.length;i++)"resolved"===n&&t[i].apply(this,a),s.push(t[i]);else"resolved"===n&&arguments[e].apply(this,a),s.push(arguments[e]);return this},fail:function(){for(var e=0;e<arguments.length;e++)if(arguments[e])if(l(arguments[e]))for(var t=arguments[e],i=0;i<t.length;i++)"rejected"===n&&t[i].apply(this,a),o.push(t[i]);else"rejected"===n&&arguments[e].apply(this,a),o.push(arguments[e]);return this},always:function(){return this.done.apply(this,arguments).fail.apply(this,arguments)},progress:function(){for(var e=0;e<arguments.length;e++)if(arguments[e])if(l(arguments[e]))for(var t=arguments[e],i=0;i<t.length;i++)"pending"===n&&r.push(t[i]);else"pending"===n&&r.push(arguments[e]);return this},then:function(){1<arguments.length&&arguments[1]&&this.fail(arguments[1]),0<arguments.length&&arguments[0]&&this.done(arguments[0]),2<arguments.length&&arguments[2]&&this.progress(arguments[2])},promise:function(e){if(null==e)return i;for(var t in i)e[t]=i[t];return e},state:function(){return n},debug:function(){console.log("[debug]",s,o,n)},isRejected:function(){return"rejected"===n},isResolved:function(){return"resolved"===n},pipe:function(e,t,i){return u(function(i){c(e,function(t){"function"==typeof t?h.done(function(){var e=t.apply(this,arguments);e&&"function"==typeof e?e.promise().then(i.resolve,i.reject,i.notify):i.resolve(e)}):h.done(i.resolve)}),c(t,function(t){"function"==typeof t?h.fail(function(){var e=t.apply(this,arguments);e&&"function"==typeof e?e.promise().then(i.resolve,i.reject,i.notify):i.reject(e)}):h.fail(i.reject)})}).promise()}},h={resolveWith:function(e){if("pending"===n){n="resolved";for(var t=a=1<arguments.length?arguments[1]:[],i=0;i<s.length;i++)s[i].apply(e,t)}return this},rejectWith:function(e){if("pending"===n){n="rejected";for(var t=a=1<arguments.length?arguments[1]:[],i=0;i<o.length;i++)o[i].apply(e,t)}return this},notifyWith:function(e){if("pending"===n)for(var t=a=1<arguments.length?arguments[1]:[],i=0;i<r.length;i++)r[i].apply(e,t);return this},resolve:function(){return this.resolveWith(this,arguments)},reject:function(){return this.rejectWith(this,arguments)},notify:function(){return this.notifyWith(this,arguments)}},t=i.promise(h);return e&&e.apply(t,[t]),t}return u.when=function(){var e;if(arguments.length<2)return((e=arguments.length?arguments[0]:void 0)&&"function"==typeof e.isResolved&&"function"==typeof e.isRejected?e:u().resolve(e)).promise();for(var i=arguments,n=u(),s=i.length,o=0,r=new Array(s),t=0;t<i.length;t++)!function(e){var t;i[e].done?i[e].done(function(){r[e]=arguments.length<2?arguments[0]:arguments,++o==s&&n.resolve.apply(n,r)}).fail(function(){n.reject(arguments)}):(t=i[e],i[e]=new Deferred,i[e].done(function(){r[e]=arguments.length<2?arguments[0]:arguments,++o==s&&n.resolve.apply(n,r)}).fail(function(){n.reject(arguments)}).resolve(t))}(t);return n.promise()},u}),define("CatLab/Webremote/Collections/ServerList",["CatLab/Webremote/Tools/Deferred"],function(s){"use strict";function e(e,t){this.defaultId=e.default,this.servers=e.servers,this.connectUrl=e.connectUrl,this.selectedServerId=null,this.preferredServer=t,this.assetsUrl=e.assetsUrl}var t=e.prototype;return t.getFromToken=function(e){if(e.length<8)return{host:this.getDefault().host,token:e};var t=e.substr(0,2);if(t){t=this.getFromId(t);if(t)return{host:t.host,token:e.substr(2)}}throw new Error("Code does not correspondent to any servers.")},t.getSelectedServer=function(){var t=new s;return this.selectedServerId?this.getFromId(this.selectedServerId)?t.resolve(this.getFromId(this.selectedServerId).host):t.reject("Selected remote server not found in server list. Please make sure you are connected to the right network."):this.selectBestServer().then(function(e){this.selectedServerId||(this.selectServer(e.id),t.resolve(e.host))}.bind(this)),t.promise()},t.selectBestServer=function(){var i=new s;if(this.preferredServer)for(var e=0;e<this.servers.length;e++)if(this.servers[e].id==this.preferredServer)return i.resolve(this.servers[e]),i.promise();var n=!1;return this.servers.forEach(function(t){t.discoverable&&this.measureRequestSpeed("https://"+t.host+"/info").then(function(e){console.log("[ServerList] "+t.host+" took "+e+"ms"),n||(n=!0,i.resolve(t))}.bind(this))}.bind(this)),i.promise()},t.selectServer=function(e){this.selectedServerId=e},t.measureRequestSpeed=function(e){var t=new Date,i=new s,n=new XMLHttpRequest;return n.onreadystatechange=function(){var e;4==this.readyState&&200==this.status&&(e=(new Date).getTime()-t.getTime(),i.resolve(e))},n.open("GET",e),n.send(),i.promise()},t.getConnectURL=function(){if(this.selectedServerId){var e=this.getFromId(this.selectedServerId);if(e.connectUrl)return e.connectUrl}return this.connectUrl},t.getAssetURL=function(){var e;return this.assetsUrl||((e=this.getConnectURL())?("http"!==e.substring(0,4)&&(e="https://"+e),this.assetsUrl=e+"/assets/",this.assetsUrl):void 0)},t.getConnectToken=function(e){return this.getFromId(this.selectedServerId).connectUrl?e:this.selectedServerId+e},t.getFromId=function(e){for(var t=0;t<this.servers.length;t++)if(this.servers[t].id==e)return this.servers[t];return null},t.getDefault=function(){return this.getFromId(this.defaultId)},t.serialize=function(){return{server:this.selectedServerId}},t.unserialize=function(e){this.selectServer(e.server)},e}),define("CatLab/Webremote/Config",["CatLab/Webremote/Tools/Net","CatLab/Webremote/Collections/ServerList"],function(i,e){"use strict";var t="http";return{_options:{host:"www.catlab.tv",serverlist:null,preferredServer:null,protocol:t="undefined"!=typeof window&&void 0!==window.location&&void 0!==window.location.protocol?window.location.protocol.substr(0,window.location.protocol.length-1):t,debug:!1,proxy:"",imageproxy:"",smileys:!0,assetsUrl:null,vendorPath:"/vendor/",audioSync:!1,allowAuthentication:!0,canFullscreen:!0,oauth:{redirectUrl:null}},_initialized:!1,audioSyncConfig:{alphabet:"qwertyuiop",length:5,freqMin:524,freqMax:1593,freqError:25,debug:!1},set:function(e){void 0!==e&&(e.host,this._options.host=e.host,void 0!==e.protocol&&(this._options.protocol=e.protocol),void 0!==e.debug&&(this._options.debug=e.debug),void 0!==e.imageproxy&&(this._options.imageproxy=e.imageproxy),void 0!==e.proxy&&(this._options.proxy=e.proxy),void 0!==e.smileys&&(this._options.smileys=e.smileys),void 0!==e.assetsUrl&&(this._options.assetsUrl=e.assetsUrl),void 0!==e.vendorPath&&(this._options.vendorPath=e.vendorPath),void 0!==e.audioSync&&(this._options.audioSync=e.audioSync),void 0!==e.serverlist&&(this._options.serverlist=e.serverlist),void 0!==e.preferredServer&&(this._options.preferredServer=e.preferredServer),void 0!==e.allowAuthentication&&(this._options.allowAuthentication=e.allowAuthentication),void 0!==e.audioSyncConfig&&(this.audioSyncConfig=e.audioSyncConfig),void 0!==e.canFullscreen&&(this._options.canFullscreen=e.canFullscreen),void 0!==e.oauth)&&void 0!==e.oauth.redirectUrl&&(this._options.oauth.redirectUrl=e.oauth.redirectUrl)},getAll:function(){return this._options},initialize:function(t){var e;this._initialized?t():null===this._options.serverlist||"http"!==this._options.serverlist.substring(0,4)?(this._initialized=!0,t()):"json"===this._options.serverlist.substring(this._options.serverlist.length-4)?i.loadJSON(this._options.serverlist,function(e){this._initialized=!0,this._options.serverlist=e,t()}.bind(this),function(e,t){alert("Failed to connect to "+this._options.serverlist+". Game cannot start."),console.log(t)}.bind(this)):((e=document.createElement("script")).onload=function(){this._initialized=!0,this._options.serverlist=getCatLabRemoteServers(),t()}.bind(this),e.onerror=function(){alert("Failed to connect to "+this._options.serverlist+". Game cannot start.")}.bind(this),e.src=this._options.serverlist,document.head.appendChild(e))},getProtocol:function(e){var t=this._options.protocol;switch(t=void 0!==e&&e&&""===t?"http":t){case"http":case"https":break;default:t="https"}return t},getSocketURL:function(e){return this._options.host?((e=this.getProtocol(e))&&(e+=":"),e+"//"+this._options.host):"undefined"!=typeof window&&void 0!==window.location?window.location.protocol+"//"+window.location.hostname:""},getAssetsURL:function(e){var t;return this._options.assetsUrl||((t=this.getServerList())?t.getAssetURL():this.getSocketURL(e)+"/assets/")},debug:function(){return this._options.debug},getProxiedImage:function(e){return this._options.imageproxy?this._options.imageproxy+encodeURIComponent(e):e},getProxy:function(){return this._options.proxy},useSmileys:function(){return this._options.smileys},useAudioSync:function(){return this._options.audioSync},all:function(){return this._options},getAudioSyncConfig:function(){return this.audioSyncConfig},getProviderConfig:function(){var e={smileys:this.useSmileys(),audioSync:this.useAudioSync()};return this.useAudioSync()&&(e.audioSyncConfig=this.audioSyncConfig),e},getServerList:function(){return this._options.serverlist?(this.serverCollection||(this.serverCollection=new e(this._options.serverlist,this._options.preferredServer)),this.serverCollection):null},getVendorPath:function(){return this._options.vendorPath},supportsAuthentication:function(){return this._options.allowAuthentication},canFullscreen:function(){return this._options.canFullscreen}}}),define("CatLab/Webremote/Polyfills",[],function(){"use strict";"function"!=typeof Object.assign&&(Object.assign=function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(e),n=1;n<arguments.length;n++){var s=arguments[n];if(null!=s)for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(i[o]=s[o])}return i})}),define("CatLab/Webremote/Tools/Tracker",[],function(){var s=function(e,t,i,n){},t=function(e){s("Page",e,"-",0)};return{setTracker:function(e){s=e},setPageMethod:function(e){t=e},track:function(e,t,i,n){s(e,t,i,n)},page:function(e){t(e)}}}),define("CatLab/Webremote/Tools/Tools",[],function(){var s,o;return{popup:function(e,t){var i=this,n=(t=t||!1,document.createElement("iframe"));n.style.margin=0,n.style.padding=0,n.style.border=0,n.style.position="absolute",n.style.width="100%",n.style.height="100%",n.style.left=0,n.style.top=0,n.src=e,(o=document.createElement("div")).style.margin=0,o.style.padding=0,o.style.border=0,o.style.position="absolute",o.style.width="100%",o.style.height="100%",o.style.left=0,o.style.top=0,o.style.zIndex=9999,o.onclick=function(){i.closePopup()},(s=document.createElement("div")).appendChild(n),s.style.margin=0,s.style.padding=0,s.style.border=0,s.style.position="absolute",s.style.zIndex=1e4,s.style.overflow="auto",s.style.background="white",s.style.boxSizing="border-box",t?(s.style.border="0 none black",s.style.left="0",s.style.top="0",s.style.width="100%",s.style.height="100%"):(s.style.border="5px solid black",s.style.left="10%",s.style.top="10%",s.style.width="80%",s.style.height="80%"),document.body.appendChild(o),document.body.appendChild(s)},oauth2PopupMethod:function(e,t){return window.open(e,"oauth:catlab-remote")},oauth2Popup:function(e,t){return this.oauth2PopupMethod(e,t)},closePopup:function(){s&&s.parentNode.removeChild(s),o&&o.parentNode.removeChild(o)},setOauth2Popup:function(e){return this.oauth2PopupMethod=e,this},sanitize:function(e){var t;return null==e?null:(t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#039;"},String(e).replace(/[&<>"']/g,function(e){return t[e]}))},nl2br:function(e,t){return null==e?"":(e+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+(t||void 0===t?"<br />":"<br>")+"$2")},shuffle:function(e){for(var t,i,n=e.length-1;0<n;n--)t=Math.floor(Math.random()*(n+1)),i=e[n],e[n]=e[t],e[t]=i},getUuid:function(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)},findIndex:function(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return i;return-1},getConnectTokenForDisplay:function(e){return null===e?null:e.length%4==0?this.injectFillerInString(e,4," "):(e.length,this.injectFillerInString(e,3," "))},injectFillerInString:function(e,t,i){return e.match(new RegExp(".{1,"+t+"}","g")).join(i)}}}),define("CatLab/Webremote/Tools/Cookies",[],function(){var t={setCookie:function(e,t,i){return this.setItem(e,t,i)},getCookie:function(e){return this.getItem(e)},eraseCookie:function(e){return this.removeItem(e)},getItem:function(e){if("undefined"!=typeof document)return e&&this.hasOwnProperty(e)?unescape(document.cookie.replace(new RegExp("(?:^|.*;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"),"$1")):null},key:function(e){if("undefined"!=typeof document)return unescape(document.cookie.replace(/\s*\=(?:.(?!;))*$/,"").split(/\s*\=(?:[^;](?!;))*[^;]?;\s*/)[e])},setItem:function(e,t,i){var n,s;e&&"undefined"!=typeof document&&(n="",i&&((s=new Date).setTime(s.getTime()+Math.round(24*i*60*60*1e3)),n="; expires="+s.toUTCString()),document.cookie=escape(e)+"="+escape(t)+"; expires="+n+"; path=/; SameSite=Strict;",this.updateLength())},length:0,removeItem:function(e){e&&this.hasOwnProperty(e)&&"undefined"!=typeof document&&(document.cookie=escape(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; SameSite=Strict;",this.length--)},hasOwnProperty:function(e){if("undefined"!=typeof document)return new RegExp("(?:^|;\\s*)"+escape(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie)},updateLength:function(){var e;"undefined"!=typeof document&&document.cookie&&(e=document.cookie.match(/\=/g),t.length=e?e.length:0)}};return t.updateLength(),t}),define("CatLab/Webremote/Tools/Smileys",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Tools"],function(i,n){function e(e){this.provider=e,this.smileyKeys=["1f98d","1f61c","1f3b7","1f32e","1f621","1f61b","1f98f","1f34c","1f596","1f34d","2660","1f61a","2602","2665","1f0cf","1f427","1f918","1f98b","1f9df","1f344","1f983","1f338","2618","1f36a","1f383","270c","1f913","1f40d","1f910","1f57a","1f641","1f36c","1f579","1f333","1f40b","1f617","1f42b","1f60d","1f42c","1f339","1f414","1f42d","1f349","1f92e","1f437","1f367","1f62c","1f428","1f994","1f911","1f369","1f9d0","1f378","1f9dd-2640","1f34e","2666","1f47d","1f60a","1f60f","1f43b","1f47b","1f425","1f919","1f346","1f4a8","1f43f","1f37a","1f40c","1f334","1f4a3","1f42e","1f379","1f42f","1f417","1f9c0","1f601","1f41a","1f61d","1f997","26c4","1f34b","1f430","1f47a","1f37c","1f3b1","1f95d","1f433","1f41b","1f37f","1f36d","1f60e","1f354","1f63b","1f680","1f996","1f924","1f341","1f43a","1f922","1f436","1f43c","1f332","1f31a","1f335","1f336","2623","1f31e","1f63d","1f421","1f438","1f63a","1f32d","1f986","1f388","1f41e","1f98c","1f91e","1f64a","1f638","1f3b5","1f43d","1f363","1f373","1f435","1f628","1f635","1f377","1f47e","1f984","1f3a9","1f439","1f925","1f929","1f951","1f4a9","1f921","1f92a","1f96a","1f41f","1f419","1f420","2663","1f40a","1f989","1f91f","1f63c","1f3f3-1f308","1f98a","1f431","1f920","1f41d","1f608","1f612","1f987","1f3ba","1f355","270b","1f98e","1f41c","1f917"],this.taken={},this.takenAmount=0,this.images={},this.playerKnowsAboutNonUniqueSmileys={},this.randomSmileys=this.smileyKeys.slice(0),n.shuffle(this.randomSmileys)}var t=e.prototype;return t.shouldHaveUniqueSmileys=function(){return this.takenAmount<this.smileyKeys.length/3},t.setTakenSmileys=function(e){this.taken=e},t.getTakenSmileys=function(e){if(!this.shouldHaveUniqueSmileys())return{};e=this.identifierToText(e);var t,i={};for(t in this.taken)this.taken.hasOwnProperty(t)&&this.taken[t]!==e&&(i[t]=this.taken[t]);return i},t.getRandom=function(e){for(var t=null;null===t&&this.randomSmileys;)if(t=this.randomSmileys.shift(),this.reserve(t,e)||(t=null),0===this.randomSmileys.length)return this.randomSmileys=this.smileyKeys.slice(0),n.shuffle(this.randomSmileys),this.randomSmileys.shift();return t},t.reserve=function(e,t){return this.isExternalSmiley(e)?(this.unreserve(t),!0):(t=this.identifierToText(t),void 0!==this.taken[e]&&this.taken[e]===t?(this.taken[e]=t,!0):!!this.isAvailable(e)&&(this.unreserve(t),this.taken[e]=t,this.takenAmount++,!0))},t.unreserve=function(e){for(var t in e=this.identifierToText(e),this.taken)this.taken.hasOwnProperty(t)&&this.taken[t]===e&&(this.taken[t]=null,delete this.taken[t],this.takenAmount--)},t.isAvailable=function(e){return!this.shouldHaveUniqueSmileys()||!!this.isExternalSmiley(e)||void 0===this.taken[e]||null===this.taken[e]},t.identifierToText=function(e){return JSON.stringify(e)},t.isExternalSmiley=function(e){return"http"===e.substr(0,4)},t.getUrl=function(e){return null===e?null:this.isExternalSmiley(e)?e:i.getAssetsURL()+"smileys/"+e+".png"},t.getHtml=function(e){return null===e?null:'<span class="smiley" style="width: 64px; height: 64px; display: inline-block; background-image: url(\''+this.getUrl(e)+"');\"></span>"},t.getElement=function(e){var t;return null===e?null:((t=document.createElement("div")).innerHTML=this.getHtml(e),t.firstChild)},t.getImage=function(e){var t;return null===e?null:(void 0===this.images[e]&&((t=new Image).crossOrigin="anonymous",t.src=i.getProxiedImage(this.getUrl(e)),this.images[e]=t),this.images[e])},t.refreshTakenSmileys=function(e){this.shouldHaveUniqueSmileys()?e.emit("smileys:taken",{smileys:this.getTakenSmileys(e.getIdentifier())}):this.playerKnowsAboutNonUniqueSmileys[this.getStringIdentifier(e)]},t.getStringIdentifier=function(e){return e.type+":"+e.id},e}),define("CatLab/Webremote/Tools/Preloader",["../Config","CatLab/Webremote/Tools/Deferred"],function(t,o){function i(e){this.provider=e,this.provider.on("file:preload",function(e){e&&e.url&&this.preloadClientFile(e.url)}.bind(this)),this.urlMap={}}var e=i.prototype;return e.preload=function(t){if(Array.isArray(t)){for(var e=new o,i=[],n=0;n<t.length;n++)i.push(this.preload(t[n]));return o.when.apply(o,i).then(function(){e.resolve(Array.prototype.slice.call(arguments))}),e.promise()}var s=new o;return this.urlMap[t]=t,this.provider.proxyFile(t).then(function(e){this.urlMap[t]=e.url,this.provider.emit("file:preload",{url:e.url}),s.resolve(e)}.bind(this)),s.promise()},e.sendPreloadFileCommandToPlayer=function(e){for(var t in this.urlMap)this.urlMap.hasOwnProperty(t)&&e.emit("file:preload",{url:this.urlMap[t]})},e.getPreloadedUrl=function(e){return this.urlMap[e]},e.preloadClientFile=function(e){void 0===this.urlMap[e]&&(e.toLowerCase().indexOf("http")<0&&(e=t.getProtocol()+":"+e),this.urlMap[e]=document.createElement("img"),this.urlMap[e].src=e)},e.serialize=function(){return{urlMap:this.urlMap}},i.unserialize=function(e,t){e=new i(e);return void 0!==t&&void 0!==t.urlMap&&(e.urlMap=t.urlMap),e},i}),define("CatLab/Webremote/Tools/Eventable",["CatLab/Webremote/Tools/Tools"],function(n){"use strict";function e(){}var s=0,t=e.prototype;return t.initializeEventable=function(){this._eventableEvents=[]},t.trigger=function(e){this.eventableTrigger.apply(this,arguments)},t.eventableTrigger=function(e){if("string"!=typeof e)throw new Error("eventableTrigger must be a string");if(void 0!==this._eventableEvents){var t,i=Array.prototype.slice.call(arguments);for(t in i.push(i.shift()),this._eventableEvents)this._eventableEvents.hasOwnProperty(t)&&this.eventMatches(e,t)&&this._eventableEvents[t].slice().forEach(function(e){try{e.method.apply(e.scope,i)}catch(e){console.error(e)}}.bind(this))}},t.eventMatches=function(e,t){return"*"===t||e===t},t.on=function(e,t,i){void 0===this._eventableEvents&&(this._eventableEvents={}),void 0===this._eventableEvents[e]&&(this._eventableEvents[e]=[]),s++,this._eventableEvents[e].push({id:s,method:t,scope:void 0!==i?i:this});var n=[e,s];return{id:n,name:e,method:t,unbind:function(){this.off(null,{id:n,name:e})}.bind(this)}},t.once=function(e,t,i){var n=this.on(e,function(){n.unbind(),t.apply(i,arguments)});return n},t.off=function(e,t){if(void 0!==e||void 0!==t)if(void 0===e||void 0!==t){if(e=t.name,t=t.id,void 0===this._eventableEvents[e])return null;var i=n.findIndex(this._eventableEvents[e],function(e){return e.id=t});0<=i&&(this._eventableEvents[e]=this._eventableEvents[e].splice(i,1))}else this._eventableEvents[e]=[];else this._eventableEvents=[]},t.clearEvents=function(){this.clearEventableEvents()},t.clearEventableEvents=function(){this._eventableEvents={}},e}),define("CatLab/Webremote/Models/User",["jquery","CatLab/Webremote/Config"],function(e,t){return function(e){this.accessToken=e,this.name=null,this.avatar=null,this.id=null,this.image=null,this.imageCallbacks=[],this.imageLoaded=!1,this.getAccessToken=function(){return this.accessToken},this.setId=function(e){this.id=e},this.getId=function(){return this.id},this.setName=function(e){this.name=e},this.getName=function(){return this.name},this.setAvatar=function(e){this.avatar=e,this.imageLoaded=!1,this.imageCallbacks=[],this.image=null},this.loadAvatar=function(){this.image||(this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=function(){this.afterImageLoad()}.bind(this),this.image.src=t.getProxiedImage(this.avatar))},this.getAvatar=function(){return this.avatar},this.getAvatarSmiley=function(e){var t=this.getAvatar();return t?(t=t.split("?")[0],t+="?shape=circle&size=64&borderWidth=4",e&&(t+="&borderColor="+e.substr(1)),t):null},this.afterImageLoad=function(){this.imageLoaded=!0;for(var e=0;e<this.imageCallbacks.length;e++)this.imageCallbacks[e](this.image);this.imageCallbacks=[]},this.getImage=function(e){this.loadAvatar(),this.imageLoaded?e(this.image):this.imageCallbacks.push(e)}}}),define("CatLab/Webremote/Tools/Storage",["CatLab/Webremote/Tools/Cookies"],function(e){"use strict";var t={clean:function(){if(this.isSupported())for(var e=Object.keys(window.localStorage),t=0;t<e.length;t++)this.get(e)},get:function(e,t){if(void 0===t&&(t=function(){}),this.isSupported())try{var i,n=window.localStorage.getItem(e);n?void 0!==(n=JSON.parse(n)).expires?(i=Date.now(),n.expires<i?(this.delete(e),t(null)):t(n.content)):t(n):t(null)}catch(e){t(null),console.log(e)}else t(null)},add:function(t,i,n,s){var o=this;n=n||function(){},this.isSupported()?this.get(t,function(e){(e=null!=e&&""!==e?e:[]).push(i),o.set(t,e,n,s)}):n(null)},set:function(e,t,i,n){if(void 0===i&&(i=function(){}),this.isSupported()){void 0===n&&(n=31536e6);try{var s=Date.now();s+=n,window.localStorage.setItem(e,JSON.stringify({expires:s,content:t}))}catch(e){console.log(e)}i()}else i(null)},delete:function(e){this.isSupported()&&window.localStorage.removeItem(e)},remove:function(n,s){var o;this.isSupported()&&(o=this).get(n,function(e){null!=e&&""!=e||(e=[]);for(var t=JSON.stringify(s),i=0;i<e.length;i++)if(t===JSON.stringify(e[i]))return e.splice(i,1),void o.set(n,e)})},isSupported:function(){if("undefined"==typeof window)return!1;try{if(void 0===window.localStorage)return!1}catch(e){return console.log(e),!1}return!0}};try{t.clean()}catch(e){console.error(e)}return t}),define("CatLab/Webremote/Collections/AuthenticatedUsers",["CatLab/Webremote/Models/User","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Tools/Eventable"],function(i,s,e){function t(){this.initializeEventable()}var o,r,n=[],e=t.prototype=new e;return e.initialize=function(e,t){o=t,r=e;var n=this;s.get("users",function(i){null!==i&&s.get("currentuser",function(t){for(var e=0;e<i.length;e++)n.addFromAccessToken(i[e].access_token,function(e){e&&t&&e.getAccessToken()===t&&void 0!==r.setUser&&r.setUser(e)})})})},e.addFromAccessToken=function(t,i){i=i||function(){};var n=this;o.profile(t,function(e){e?(e=n.add(t,e.user),i(e)):s.remove("users",{access_token:t})})},e.add=function(e,t){e=new i(e);return e.setId(t.id),e.setName(t.username),e.setAvatar(t.avatar),function(e){for(var t=0;t<n.length;t++)if(n[t].getId()==e.getId())return n[t]=e;n.push(e)}(e),this.trigger("update"),e},e.remove=function(e){for(var t=0;t<n.length;t++)if(n[t].getId()==e.getId())return void n.splice(t,1)},e.getFromId=function(e){for(var t=0;t<n.length;t++)if(n[t].getId()==e)return n[t];return null},e.getAll=function(){return n},new t}),define("CatLab/Webremote/Controllers/OAuth2",["jquery","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Config"],function($,Tools,Deferred,Eventable,Users,Storage,Config){var url,client_id,authorization,profile_url,avatar_url,redirect_url,callbacks=[],initialized=!1,afterInit=[],events=[],etPhoneHome=null;function OAuth2(){this.initializeEventable()}var p=OAuth2.prototype=new Eventable;return p.initialize=function(e){url=(e=e||{}).authorization||"https://quizted.catlab.eu/oauth2/authorize",client_id=e.client_id||"none",authorization=e.authorization||"default",profile_url=e.profile||"",avatar_url=e.profile+"/avatar",void 0!==e.redirect_uri&&(Config._options.oauth.redirectUrl=e.redirect_uri),initialized=!0;var t=this;if("undefined"!=typeof window){function i(e){t.onMessage(e)}var n;if(window.addEventListener){for(;n=events.pop();)removeEventListener("message",n);addEventListener("message",i,!1)}else{for(;n=events.pop();)detachEvent("onmessage",n);attachEvent("onmessage",i)}events.push(i)}},p.setRedirectUrl=function(e,t){this.redirectHost=e,this.redirectUrl=e+t},p.getAuthorizeURL=function(){var e="",e=(Config.all().oauth&&Config.all().oauth.redirectUrl&&(e=Config.all().oauth.redirectUrl),url+"?client_id="+encodeURIComponent(client_id)+"&authorization="+encodeURIComponent(authorization)+"&response_type=token&redirect_uri="+encodeURIComponent(e)+"&reset=1&state=login");return void 0!==this.redirectUrl?this.redirectUrl+"?url="+encodeURIComponent(e):e},p.onMessage=function(e){if("I must've called a thousand times"!==e.data){var t;if("string"==typeof e.data&&e.data.match(/^oauth::/))try{t=JSON.parse(e.data.substring(7))}catch(e){return}else if("string"==typeof e.data)try{t=JSON.parse(e.data)}catch(e){return}else t=e.data;void 0!==t.access_token&&this.addAccessToken(t.access_token)}},p.addAccessToken=function(n){var e=function(e){var t,i=Users.add(n,e.user);for(Storage.add("users",{access_token:n}),Tools.closePopup();t=callbacks.shift();)t(i);this.trigger("update")}.bind(this);this.call(profile_url,n,e)},p.call=function(url,accessToken,callback){var parsedurl=url+"?access_token="+accessToken,xmlhttp;"undefined"!=typeof window&&(xmlhttp=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"),xmlhttp.onreadystatechange=function(){4==xmlhttp.readyState&&200!=xmlhttp.status&&callback(null),4==xmlhttp.readyState&&200==xmlhttp.status&&callback(eval("("+xmlhttp.responseText+")"))},xmlhttp.open("GET",parsedurl,!0),xmlhttp.send())},p.profile=function(e,t){this.call(profile_url,e,t)},p.changeAvatar=function(t,e){var i;if(t.getAccessToken())return(i=new FormData).append("avatar",e.files[0]),$.ajax({type:"POST",url:avatar_url,data:i,contentType:!1,processData:!1,headers:{Authorization:"Bearer "+t.getAccessToken()},success:function(e){t.setAvatar(e.url)}})},p.link=function(t){var i=new Deferred,e={},e=("object"==typeof(t=void 0===t?{}:t)&&(t=(e=t).callback||function(){}),e.fullscreen||!1),n=(etPhoneHome&&clearInterval(etPhoneHome),this.getAuthorizeURL()),s=Tools.oauth2Popup(n,e);return s&&(etPhoneHome=setInterval(function(){s.postMessage("Hello from the other side","*")}.bind(this),1e3)),callbacks.push(function(e){t(e),i.resolve(e)}),i.promise()},p.onInit=function(e){afterInit.push(e)},p.onAdds=function(){for(var e=0;e<afterInit.length;e++)afterInit[e]()},p.getParamsFromHash=function(e){if("undefined"!=typeof window)return e=(e=e||window.location.hash).slice(1),(e=decodeURIComponent(e)).split("&").reduce(function(e,t){return e[(t=t.split("="))[0]]=t[1],e},{})},p.finish=function(){var e='oauth::{"catlabremote":1,"event":"user:authenticated","access_token":"'+this.getParamsFromHash().access_token+'"}';setTimeout(function(){window.opener&&window.opener.postMessage(e,"*"),window.parent&&window.parent.postMessage(e,"*"),void 0!==window.dialogArguments&&window.dialogArguments.opener&&window.dialogArguments.opener.postMessage(e,"*"),setTimeout(function(){etPhoneHome&&clearInterval(etPhoneHome),window.close()},1)},1)},new OAuth2}),define("CatLab/Webremote/Views/Popups/BasePopup",["jquery"],function(n){function e(){this.scrollable=!1}var t=e.prototype;return t.render=function(e){this.popupContainer=document.createElement("div"),this.popupContainer.className="catlab-popup-container";var t=document.createElement("div"),t=(t.className="overlay",this.popupContainer.appendChild(t),this.container=document.createElement("div"),this.container.className="popup",this.popupContainer.appendChild(this.container),n(this.container).click(function(e){e.stopPropagation()}),this.content=document.createElement("div"),this.container.appendChild(this.content),document.createElement("p")),i=(t.className="close",document.createElement("a"));i.href="javascript:void(0)",i.innerHTML="<span>Close</span>",i.onclick=function(){this.close()}.bind(this),t.appendChild(i),this.container.appendChild(t),e.appendChild(this.popupContainer),this.scrollable&&n(this.content).addClass("scrollable"),this.renderContent(this.content)},t.renderContent=function(){},t.close=function(){this.popupContainer.parentNode.removeChild(this.popupContainer)},e}),define("CatLab/Webremote/Views/User",["CatLab/Webremote/Controllers/OAuth2","jquery"],function(i,n){return function(d){this.render=function(e,t,i){t=t||[];var n,s=d.getName(),o=document.createElement("div"),r=(o.className="catlab-user",document.createElement("div")),r=((this.avatardiv=r).className="catlab-avatar",o.appendChild(r),this.renderAvatar(),void 0!==i&&(r.onclick=i),document.createElement("div")),a=(r.className="catlab-info",o.appendChild(r),document.createElement("p"));void 0!==i?((n=document.createElement("a")).innerHTML=s,n.onclick=i,a.appendChild(n)):(a.innerHTML=s,r.appendChild(a)),r.appendChild(a);var h,l,c=document.createElement("ul");c.className="catlab-actions";for(var u=0;u<t.length;u++)(h=document.createElement("li")).className=t[u].token,c.appendChild(h),(l=document.createElement("a")).onclick=t[u].click,l.innerHTML=t[u].text,l.href="javascript:void(0)",h.appendChild(l);r.appendChild(c),e.innerHTML="",e.appendChild(o);i=document.createElement("div");i.className="clearer",o.appendChild(i)},this.renderAvatar=function(){var e=d.getAvatar(),t=document.createElement("img");t.src=e,t.alt="User avatar",n(this.avatardiv).html(t)},this.enableAvatarUpload=function(e){var t=document.createElement("input");t.type="file",t.accept="image/*",this.avatarFileInput=t,n(t).on("change",function(){n(this.avatardiv).addClass("loading"),n.when(i.changeAvatar(d,t)).then(function(){n(this.avatardiv).removeClass("loading"),this.renderAvatar(),e.setUser(d)}.bind(this))}.bind(this)),n(this.avatardiv).click(function(){t.click()})},this.uploadAvatar=function(){this.avatarFileInput&&this.avatarFileInput.click()}}}),define("CatLab/Webremote/Views/Popups/AuthenticationPopup",["CatLab/Webremote/Views/Popups/BasePopup","CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Views/User","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Tools/Tracker"],function(e,h,l,c,u,d){return function(t){function e(){h.link(function(e){s.updateUsers(),s.selectUser(e)})}h.on("update",function(){this.updateUsers()}.bind(this));var s=this,i=document.createElement("div"),n=(i.className="catlab-popup-container",document.createElement("div")),n=(n.className="overlay",i.appendChild(n),document.createElement("div")),o=(n.className="popup",i.appendChild(n),n.innerHTML="<h2>Select account</h2>",document.createElement("ul")),r=(o.className="userlist",n.appendChild(o),document.createElement("div")),r=(r.className="clearer",n.appendChild(r),document.createElement("p")),a=(r.className="connect",document.createElement("a")),r=(a.href="javascript:void(0)",a.innerHTML='<span class="new-user">Connect new user</span>',a.onclick=function(){e()},r.appendChild(a),n.appendChild(a),document.createElement("p")),a=(r.className="close",document.createElement("a"));a.href="javascript:void(0)",a.innerHTML="<span>Close</span>",a.onclick=function(){s.close()},r.appendChild(a),n.appendChild(r),this.selectUser=function(e){t.setUser(e),s.close(),d.track("Click","Select user","AuthenticationPopup")},this.updateUsers=function(){o.innerHTML="";for(var e=l.getAll(),t=0;t<e.length;t++)!function(e,t){var i=document.createElement("li"),n=[{token:"select",text:"select",click:function(){s.selectUser(t)}},{token:"logout",text:"logout",click:function(){l.remove(t),u.remove("users",{access_token:t.getAccessToken()}),s.updateUsers(),d.track("Click","Logout","AuthenticationPopup")}}];new c(t).render(i,n,function(){s.selectUser(t)}),e.appendChild(i)}(o,e[t])},this.close=function(){i.parentNode.removeChild(i),d.track("Click","Close popup","AuthenticationPopup")},this.connect=function(){d.track("Click","Connect new","AuthenticationPopup"),e()},this.render=function(e){e.appendChild(i),this.updateUsers()},this.setLoginUrl=function(e){console.log(e)}}}),define("CatLab/Webremote/Views/Popups/SelectSmileyPopup",["CatLab/Webremote/Views/Popups/BasePopup"],function(e){function t(e,t,i){this.Webremote=e,this.callback=t,this.scrollable=!0,this.disableTaken=i}e=t.prototype=new e;return e.renderContent=function(e){$(e).addClass("smileys-popup");var t,i=$('<ul class="smileys"></ul>'),n=($(e).append(i),this.Webremote.smileys.smileyKeys.slice());this.Webremote.getUser()&&this.Webremote.getUser().getAvatar()&&(t=this.Webremote.getUser().getAvatarSmiley(this.Webremote.color))&&n.unshift(t);for(var s=0;s<n.length;s++)this.renderSmiley(i,n[s]);$(e).append('<div class="clearer"></div>')},e.renderSmiley=function(e,t){var i=$("<li>");i.append(this.Webremote.smileys.getElement(t)),this.disableTaken&&!this.Webremote.smileys.isAvailable(t)&&i.addClass("unavailable"),this.Webremote.getSmiley()===t&&i.addClass("selected"),i.click(function(){this.selectSmiley(t),e.find(".selected").removeClass("selected"),i.addClass("selected"),this.close()}.bind(this)),e.append(i)},e.selectSmiley=function(e){this.callback(e)},t}),define("CatLab/Webremote/Views/Blocks/CurrentUser",["CatLab/Webremote/Views/User","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Tools/Tracker"],function(o,r,a,h){return function(s){this.render=function(e){var t,i,n;e.innerHTML="",s.canAuthenticate()&&(n=s.getUser(),(t=document.createElement("div")).className="overlay player-color-background",e.appendChild(t),(t=document.createElement("div")).className="content",t.className+=" player-color-border",e.appendChild(t),n?(e=[{token:"switch",text:"Switch account",click:function(){s.showAuthenticationPopup(),h.track("Click","Switch account","CurrentUser")}},{token:"upload",text:"Upload photo",click:function(){i.uploadAvatar()}},{token:"logout",text:"Logout",click:function(){var e=s.getUser();r.remove(e),s.setUser(null),a.remove("users",{access_token:e.getAccessToken()}),h.track("Click","Logout","CurrentUser")}}],(i=new o(n)).render(t,e),i.enableAvatarUpload(s)):((n=document.createElement("p")).className="catlab-not-loggedin",(e=document.createElement("a")).href="javascript:void(0);",e.innerHTML="Login",e.onclick=function(){s.showAuthenticationPopup(0===r.getAll().length),h.track("Click","Login","CurrentUser")},n.appendChild(e),t.appendChild(n)))}}}),!function(){"use strict";var f={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function g(e){for(var t,i,n,s,o,r,a,h=function(e){if(m[e])return m[e];for(var t,i=e,n=[],s=0;i;){if(null!==(t=f.text.exec(i)))n.push(t[0]);else if(null!==(t=f.modulo.exec(i)))n.push("%");else{if(null===(t=f.placeholder.exec(i)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){s|=1;var o=[],r=t[2],a=[];if(null===(a=f.key.exec(r)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(o.push(a[1]);""!==(r=r.substring(a[0].length));){if(null===(a=f.key_access.exec(r))&&null===(a=f.index_access.exec(r)))throw new SyntaxError("[sprintf] failed to parse named argument key");o.push(a[1])}t[2]=o}else s|=2;if(3===s)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n.push({placeholder:t[0],param_no:t[1],keys:t[2],sign:t[3],pad_char:t[4],align:t[5],width:t[6],precision:t[7],type:t[8]})}i=i.substring(t[0].length)}return m[e]=n}(e),l=arguments,c=1,u=h.length,d="",p=0;p<u;p++)if("string"==typeof h[p])d+=h[p];else if("object"==typeof h[p]){if((n=h[p]).keys)for(t=l[c],i=0;i<n.keys.length;i++){if(null==t)throw new Error(g('[sprintf] Cannot access property "%s" of undefined value "%s"',n.keys[i],n.keys[i-1]));t=t[n.keys[i]]}else t=n.param_no?l[n.param_no]:l[c++];if(f.not_type.test(n.type)&&f.not_primitive.test(n.type)&&t instanceof Function&&(t=t()),f.numeric_arg.test(n.type)&&"number"!=typeof t&&isNaN(t))throw new TypeError(g("[sprintf] expecting number but found %T",t));switch(f.number.test(n.type)&&(r=0<=t),n.type){case"b":t=parseInt(t,10).toString(2);break;case"c":t=String.fromCharCode(parseInt(t,10));break;case"d":case"i":t=parseInt(t,10);break;case"j":t=JSON.stringify(t,null,n.width?parseInt(n.width):0);break;case"e":t=n.precision?parseFloat(t).toExponential(n.precision):parseFloat(t).toExponential();break;case"f":t=n.precision?parseFloat(t).toFixed(n.precision):parseFloat(t);break;case"g":t=n.precision?String(Number(t.toPrecision(n.precision))):parseFloat(t);break;case"o":t=(parseInt(t,10)>>>0).toString(8);break;case"s":t=String(t),t=n.precision?t.substring(0,n.precision):t;break;case"t":t=String(!!t),t=n.precision?t.substring(0,n.precision):t;break;case"T":t=Object.prototype.toString.call(t).slice(8,-1).toLowerCase(),t=n.precision?t.substring(0,n.precision):t;break;case"u":t=parseInt(t,10)>>>0;break;case"v":t=t.valueOf(),t=n.precision?t.substring(0,n.precision):t;break;case"x":t=(parseInt(t,10)>>>0).toString(16);break;case"X":t=(parseInt(t,10)>>>0).toString(16).toUpperCase()}f.json.test(n.type)?d+=t:(!f.number.test(n.type)||r&&!n.sign?a="":(a=r?"+":"-",t=t.toString().replace(f.sign,"")),s=n.pad_char?"0"===n.pad_char?"0":n.pad_char.charAt(1):" ",o=n.width-(a+t).length,o=n.width&&0<o?s.repeat(o):"",d+=n.align?a+t+o:"0"===s?a+o+t:o+a+t)}return d}function e(e,t){return g.apply(null,[e].concat(t||[]))}var m=Object.create(null);"undefined"!=typeof exports&&(exports.sprintf=g,exports.vsprintf=e),"undefined"!=typeof window&&(window.sprintf=g,window.vsprintf=e,"function"==typeof define)&&define.amd&&define("sprintf",[],function(){return{sprintf:g,vsprintf:e}})}(),define("CatLab/Webremote/Tools/Translator",["sprintf"],function(t){function e(){this.translator=null}var i,n,s=e.prototype;return s.setTranslator=function(e){this.translatorScope=this,"function"==typeof e?this.translator=e:("function"==typeof e.t?this.translator=e.t:(e._,this.translator=e._),this.translatorScope=e)},s.t=function(e){if(""===e)return"";if(Array.isArray(e))return this.t.apply(this,e);if(this.translator)return this.translator.apply(this.translatorScope,arguments);for(i=[],n=1;n<arguments.length;n++)i.push(arguments[n]);return t.vsprintf(e,i)},new e}),define("CatLab/Webremote/Views/Blocks/CurrentSmiley",["jquery","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/Deferred"],function(e,t,i){"use strict";function n(e,t,i,n){this.Webremote=e,this.canSwitch=void 0!==t&&!!t,this.canDrag=void 0!==i&&!!i,this.isProfileSmiley=void 0===n||!!n,this.dragDisabled=!1,this.switchVerb="Switch"}n.initialize=function(){return n.isInitialized||(n.isInitialized=new i,require(["jquery-ui","jquery-ui-touch-punch"],function(e,t){n.isInitialized.resolve()})),n.isInitialized.promise()}.bind(this),n.activeSmileys=["1f601","1f60d","1f60e"];var s=n.prototype;return s.setSmiley=function(e){Array.isArray(e)||(e=[e]),this.smileys=e,n.initialize().then(function(){this.selector&&(this.selector.html(""),e.forEach(function(s){var i=$(this.Webremote.smileys.getElement(s));if(this.selector.append(i),this.canDrag)try{var o=null,r=null;i.css({zIndex:10}).draggable({start:function(e,t){if(this.dragDisabled)return!1;o=t.position,r=$(t.helper).offset(),this.disableDrag(),i.toggleClass("flinging",!0)}.bind(this),stop:function(e,t){var i=t.position,n=this.getDistance(o,i);10<n?(i=this.getAngle(o,i),this.slingshot(r,i,n,t.helper,s)):this.Webremote.showSmileyPopup()}.bind(this)})}catch(s){console.log(s)}}.bind(this)),this.canSwitch)&&this.selector.append('<p class="switch"><a href="javascript:void(0)">'+t.t(this.switchVerb)+"</a></p>")}.bind(this))},s.disableDrag=function(){this.dragDisabled=!0,this.selector&&$(this.selector).toggleClass("drag-disabled",!0)},s.enableDrag=function(){this.dragDisabled=!1,this.selector&&$(this.selector).toggleClass("drag-disabled",!1)},s.getMaxDistance=function(){return this.selector?$(window).height()-this.selector.offset().top:200},s.getDistance=function(e,t){var i=e.left-t.left,e=e.top-t.top;return Math.sqrt(i*i+e*e)},s.getAngle=function(e,t){return Math.atan2(t.top-e.top,t.left-e.top)},s.slingshot=function(e,t,i,n,s){var o=Math.min(1,i/this.getMaxDistance());0<Math.sin(t-Math.PI)?n.animate({left:0,top:0,opacity:1},1e3):(i=1.5*Math.max(e.left,e.top),n.animate({left:Math.cos(t-Math.PI)*i,top:Math.sin(t-Math.PI)*i},1e3,"swing",function(){setTimeout(function(){n.css({left:-1*parseInt(n.css("left"))}),n.animate({left:0,top:0},1e3,function(){this.enableDrag(),n.toggleClass("flinging",!1)}.bind(this))}.bind(this),3e3*o)}.bind(this)),setTimeout(function(){this.Webremote.emit("smileys:slingshot",{angle:t,speed:o,smiley:s})}.bind(this),800))},s.render=function(e){n.initialize().then(function(){this.container=$(e),this.canSwitch||this.canDrag?this.selector=$('<div class="smiley-selector"></div>'):this.selector=$('<div class="smiley-view"></div>'),this.selector.html('<div class="placeholder"></div>'),this.container.html(this.selector),this.canSwitch&&($(this.container).off("click"),$(this.container).click(function(){this.isProfileSmiley?this.Webremote.showSmileyPopup():this.Webremote.showSmileyPopup(function(e){if(-1===n.activeSmileys.indexOf(e)){for(;2<n.activeSmileys.length;)n.activeSmileys.shift();n.activeSmileys.push(e),this.setSmiley(n.activeSmileys)}}.bind(this),!1)}.bind(this)),this.isProfileSmiley||this.setSmiley(n.activeSmileys))}.bind(this))},n}),define("CatLab/Webremote/Tools/HashParser",[],function(){return{getParameters:function(){function e(e){return decodeURIComponent(e.replace(n," "))}for(var t,i={},n=/\+/g,s=/([^&;=]+)=?([^&;]*)/g,o=window.location.hash.substring(1);t=s.exec(o);)i[e(t[1])]=e(t[2]);return i},getParameter:function(e){var t=this.getParameters();return void 0!==t[e]?t[e]:null},clear:function(){history.pushState("",document.title,window.location.pathname+window.location.search)}}}),define("CatLab/Webremote/Views/Alert",[],function(){return function(e,t){t=t||function(){},alert(e),t()}}),define("CatLab/Webremote/Views/Welcome",["CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Views/User","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Tools/Tracker"],function(e,t,i,o){return function(e){var t=this,i=document.createElement("div"),n=(i.className="catlab-popup-container",document.createElement("div")),n=(n.className="overlay",i.appendChild(n),document.createElement("div")),e=(n.className="popup thanks",i.appendChild(n),n.innerHTML=e,document.createElement("a")),s=(e.innerHTML="Start playing",e.onclick=function(){t.close()},e.href="javascript:void(0)",document.createElement("p"));s.appendChild(e),s.className="playnow",n.appendChild(s),this.close=function(){i.parentNode.removeChild(i),o.track("Click","Close popup","WelcomePopup")},this.render=function(e){e.appendChild(i)}}}),define("CatLab/Webremote/Views/ConnectionTrouble",["CatLab/Webremote/Tools/Translator"],function(e){function t(){this.visible=!1,this.div=null,this.timeoutTillShow=3e3,this.showTimeout=null,this.message=null}var i=t.prototype;return i.show=function(){this.visible||(this.visible=!0,this.div)||(this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=null),setTimeout(function(){this.div||this.visible&&(this.showTimeout=null,this.div=document.createElement("div"),document.body.appendChild(this.div),this.div.style.position="absolute",this.div.style.right="10px",this.div.style.top="10px",this.div.style.width="350px",this.div.style.padding="10px",this.div.style.border="1px solid red",this.div.style.background="black",this.div.style.zIndex="100000",this.div.style.textAlign="center",this.div.style.color="white",this.div.style.font="Sans-serif",this.div.style.fontSize="15px",this.message?this.text(this.message):this.text(e.t("Connection lost")))}.bind(this),this.timeoutTillShow))},i.text=function(e){this.message=e,this.div&&(this.div.innerHTML="<p>"+e+"</p>")},i.hide=function(){this.visible=!1,this.div&&this.div.parentNode&&this.div.parentNode.removeChild(this.div),this.showTimeout&&clearTimeout(this.showTimeout),this.message=null,this.div=null,this.showTimeout=null},t}),define("CatLab/Webremote/Views/GamePaused",["CatLab/Webremote/Tools/Translator"],function(e){function t(){this.visible=!1,this.div=null,this.timeoutTillShow=1,this.showTimeout=null,this.message=null}var i=t.prototype;return i.show=function(){this.visible||(this.visible=!0,this.div)||(this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=null),setTimeout(function(){this.div||this.visible&&(this.showTimeout=null,this.div=document.createElement("div"),document.body.appendChild(this.div),this.div.style.position="fixed",this.div.style.right="0",this.div.style.top="0",this.div.style.width="100%",this.div.style.height="100%",this.div.style.padding="0",this.div.style.background="black",this.div.style.zIndex="100000",this.div.style.textAlign="center",this.div.style.color="white",this.div.style.font="Sans-serif",this.div.style.fontSize="2em",this.div.style.opacity=.9,this.message?this.text(this.message):this.text(e.t("Please wait, the game is paused.")))}.bind(this),this.timeoutTillShow))},i.text=function(e){this.message=e,this.div&&(this.div.innerHTML='<p style="height: 100%; padding: 20% 0">'+e+"</p>")},i.hide=function(){this.visible=!1,this.div&&this.div.parentNode.removeChild(this.div),this.showTimeout&&clearTimeout(this.showTimeout),this.message=null,this.div=null,this.showTimeout=null},t}),define("CatLab/Webremote/Synchronization/ClientRemoteView",["jquery"],function(n){"use strict";function e(e,t,i,n,s,o){this.controller=e,this.html="<p>Loading</p>",this.context={},this.viewId=t,this.name=i,this.groupId=void 0!==n?n:null,this.synchronizedData=s,this.createdAt=new Date,this.iframe=o,this.currentValues=[],this.buttons=[]}var s={},t=e.prototype;return t.render=function(e){var t;this.iframe?(t=document.createElement("iframe"),$(t).css({width:"100%",height:"100%",border:"none",margin:0,padding:0,position:"absolute",left:0,top:0}),$(e).html(t),this.element=t.contentDocument.body):this.element=e,this.el=e,this.$el=n(e),this.element.innerHTML=this.html,this.update(),this.controller.components.attach(this,n("body")),this.updateEvents(),setTimeout(function(){this.updateEvents(),window.scrollTo(0,1)}.bind(this),10),setTimeout(function(){this.updateEvents()}.bind(this),100),setTimeout(function(){this.updateEvents()}.bind(this),1e3)},t.updateEvents=function(){var c=this;function e(n,t,s){var o,r,a,h,l;c.shouldSetEvents(n,"touch")&&(h=!1,l=null,n.addEventListener("touchstart",function(e){return o=new Date,r={x:e.touches[0].pageX,y:e.touches[0].pageY},a={x:e.touches[0].pageX,y:e.touches[0].pageY},h=!0,l&&clearTimeout(l),t.apply(c,[n])}),n.addEventListener("touchmove",function(e){a={x:e.touches[0].pageX,y:e.touches[0].pageY}}),n.addEventListener("touchend",function(e){var t,i;if(r)return i=Math.abs(a.x-r.x),t=Math.abs(a.y-r.y),r=null,i=(new Date).getTime()-o.getTime()<300&&i<20&&t<20,l=setTimeout(function(){h=!1},1e3),s.apply(c,[n,i])}),n.addEventListener("mousedown",function(e){if(e.preventDefault(),!h)return t.apply(c,[n])}),n.addEventListener("mouseup",function(e){if(e.preventDefault(),!h)return s.apply(c,[n,!0])}))}for(var t=this.element.querySelectorAll("[data-button-id]"),i=0;i<t.length;i++)e(t[i],c.buttonDown,c.buttonUp),this.buttons.push(t[i]);for(t=this.element.querySelectorAll("[data-authentication-button]"),i=0;i<t.length;i++)e(t[i],function(){},c.authenticate);for(t=this.element.querySelectorAll("[data-value-id]"),i=0;i<t.length;i++)!function(t){var i,e;c.shouldSetEvents(t,"change")&&(i=t.getAttribute("data-value-id"),c.currentValues[i]=c.getDataValue(t),t.addEventListener("change",function(e){s[i]=new Date,c.syncValue(t)}),e=null,t.addEventListener("keyup",function(){e&&clearTimeout(e),e=setTimeout(function(){s[i]=new Date,c.syncValue(t)},1e3)}))}(t[i])},t.getDataValue=function(e){return"checkbox"===e.type?e.checked?1:0:e.value},t.syncValues=function(){for(var e=this.element.querySelectorAll("[data-value-id]"),t=0;t<e.length;t++)this.syncValue(e[t])},t.syncValue=function(e){var t=this.getDataValue(e),i=e.getAttribute("data-value-id");void 0!==this.currentValues[i]&&this.currentValues[i]===t||(this.currentValues[i]=t,this.controller.syncValue(i,this.getDataValue(e),this.viewId))},t.update=function(){for(var e=this.element.querySelectorAll("[data-button-decorator]"),t=0;t<e.length;t++)void 0===e[t].dataset.initialClasses&&(e[t].dataset.initialClasses=e[t].className);this.updateBigTextSizes()},t.updateBigTextSizes=function(){var i=$(this.element),e=i.find(".bigtext"),n={};e.each(function(){var e=$(this).attr("data-bigtext-group"),t=e?(void 0===n[e]&&(n[e]=0,i.find('.bigtext[data-bigtext-group="'+e+'"]').each(function(){n[e]=Math.max(n[e],$(this).text().length)})),n[e]):$(this).text().length;$(this).attr("data-bigtext-length",t)})},t.shouldSetEvents=function(e,t){return void 0===e["hasCatlabEventsAlready"+t]&&(e["hasCatlabEventsAlready"+t]=!0)},t.buttonDown=function(e){try{this.syncValues()}catch(e){console.error(e)}return this.controller.buttonDown(e.getAttribute("data-button-id"),this.viewId),!1},t.buttonUp=function(e,t){return this.controller.buttonUp(e.getAttribute("data-button-id"),this.viewId,t),!1},t.setLabel=function(e,t){for(var i=this.element.querySelectorAll("[data-button-label="+e+"]"),n=0;n<i.length;n++)i[n].innerHTML=t;this.update()},t.setClass=function(e,t){for(var i=this.element.querySelectorAll("[data-button-decorator="+e+"]"),n=0;n<i.length;n++){var s=i[n];s.className=s.dataset.initialClasses+" "+t}this.update()},t.domAppend=function(e,t){var i=document.getElementById(e);if(i){for(var n=this.stringToDom(t),s=[];n.firstChild;)s.push(i.appendChild(n.firstChild));try{for(var o=0;o<s.length;o++)this.controller.components.attach(this._currentView,s[o],!1)}catch(e){console.log(e)}5e3<(new Date).getTime()-this.createdAt.getTime()&&0<s.length&&void 0!==s[0].scrollIntoView&&s[0].scrollIntoView(),this.update(),this.updateEvents()}},t.domReplace=function(e,t){e=document.getElementById(e);e&&(e.innerHTML=t,this.controller.components.attach(this._currentView,e,!1),this.update(),this.updateEvents())},t.domAttribute=function(e,t,i){n(e).attr(t,i)},t.changeValue=function(e){if(void 0!==s[e.id]){if((t=Math.abs(s[e.id].getTime()-(new Date).getTime()))<5)return}else var t=9999999999999;for(var i=this.element.querySelectorAll("[data-value-id="+e.id+"]"),n=0;n<i.length;n++)document.activeElement==i[n]&&t<5e3||(this.currentValues[e.id]=e.value,i[n].value=e.value)},t.vibrate=function(e){void 0!==window.navigator.vibrate&&void 0!==e.pattern&&Array.isArray(e.pattern)&&window.navigator.vibrate(e.pattern)},t.stringToDom=function(e){var t;return(t=0<=e.toLowerCase().indexOf("<tr")?document.createElement("tbody"):document.createElement("div")).innerHTML=e,t},t.stringInterpolateDataElements=function(e,s){return e.replace(/{{(.+?)}}/g,function(e,t,i,n){t=this.controller.resolveDataAttribute(t.trim());return t=s?s(t):t}.bind(this))},t.destroy=function(){this.syncValues(),void 0!==this.synchronizedData&&this.synchronizedData.destroy()},e}),define("CatLab/Webremote/Synchronization/DataItem",[],function(){function i(e,t,i){this.key=e,this.shared=t,this.side=i}var e=i.prototype;return e.setValue=function(e){this.value=e},e.canWrite=function(e){return!!this.shared||this.side===e},e.serialize=function(){return{key:this.key,shared:this.shared,side:this.side,value:this.value}},i.unserialize=function(e){var t=new i(e.key,e.shared,e.side);return t.setValue(e.value),t},i}),define("CatLab/Webremote/Synchronization/SynchronizedData",["CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Synchronization/DataItem"],function(e,s){function t(e,t,i){this.initializeEventable(),this.id=e,this.synchronizer=t,this.side=i,this.data={}}e=t.prototype=new e;return e.set=function(e,t,i){if(void 0===this.data[e])this.data[e]=new s(e,i,this.side);else if(!this.data[e].canWrite(this.side))throw"Trying to overwrite a non shared data attribute: "+e;this.data[e].setValue(t),this.emit(this.data[e])},e.processMessage=function(e){var t=e.key,i=e.side,n=e.value,e=e.shared;if(void 0===this.data[t])this.data[t]=new s(t,e,i);else if(!this.data[t].canWrite(i))throw"Trying to overwrite a non shared data attribute: "+t;this.data[t].setValue(n)},e.get=function(e){return void 0===this.data[e]?null:this.data[e].value},e.emit=function(e,t){void 0===t&&(t=this.synchronizer.emit);e=e.serialize();e.namespace=this.synchronizer.namespace,e.container=this.id,t("data:set",e)},e.refreshTarget=function(e){for(var t in this.data)this.data.hasOwnProperty(t)&&this.emit(this.data[t],e)},e.destroy=function(){this.synchronizer.destroy(this)},e.serialize=function(){var e,t={};for(e in this.data)this.data.hasOwnProperty(e)&&(t[e]=this.data[e].serialize());return t},e.unserialize=function(e){for(var t in this.data={},e)e.hasOwnProperty(t)&&(this.data[t]=s.unserialize(e[t]))},t}),define("CatLab/Webremote/Synchronization/DataSynchronizer",["CatLab/Webremote/Synchronization/SynchronizedData"],function(t){function e(e,t,i){this.namespace=e,this.emit=t,this.dataModels={},this.side=i}e.eventsToListenFor=["data:set"];var i=e.prototype;return i.checkNamespace=function(e){return void 0!==e.namespace&&e.namespace===this.namespace},i.processMessage=function(e,t){void 0!==t.container&&this.getFromIdentifier(t.container).processMessage(t)},i.getFromIdentifier=function(e){return void 0===this.dataModels[e]&&(this.dataModels[e]=new t(e,this,this.side)),this.dataModels[e]},i.destroy=function(e){e=e.id;void 0===this.dataModels[e]&&delete this.dataModels[e]},i.refreshTarget=function(e){for(var t in this.dataModels)this.dataModels.hasOwnProperty(t)&&this.dataModels[t].refreshTarget(e)},i.serialize=function(){var e,t={};for(e in this.dataModels)this.dataModels.hasOwnProperty(e)&&(t[e]=this.dataModels[e].serialize());return{dataModels:t}},i.unserialize=function(e){for(var t in e.dataModels)e.dataModels.hasOwnProperty(t)&&this.getFromIdentifier(t).unserialize(e.dataModels[t])},e}),define("CatLab/Webremote/Synchronization/EventHandler",["CatLab/Webremote/Tools/Eventable"],function(e){function t(e,t){this.initializeEventable(),this.namespace=e,this.emit=t}t.eventsToListenFor=["event:trigger"];e=t.prototype=new e;return e.checkNamespace=function(e){return void 0!==e.namespace&&e.namespace===this.namespace},e.processMessage=function(e,t){if("event:trigger"===e)return this.processTriggerEvent(t)},e.processTriggerEvent=function(e){void 0!==e.event&&this.eventableTrigger(e.event,void 0===e.parameters?{}:e.parameters)},e.trigger=function(e,t){this.emit("event:trigger",{namespace:this.namespace,event:e,parameters:t})},e.refreshTarget=function(e){},e.serialize=function(){return{}},e.unserialize=function(e){},t}),define("CatLab/Webremote/Synchronization/CombinedEventHandler",["CatLab/Webremote/Tools/Eventable"],function(e){function t(e,t){this.initializeEventable(),this.handlers=[]}return(t.prototype=new e).addHandler=function(e){this.handlers.push(e),e.on("*",function(e,t){this.trigger(t,e)}.bind(this))},t}),define("CatLab/Webremote/Synchronization/MessageQueue",[],function(){"use strict";function e(){this.queue=[]}var t=e.prototype;return t.add=function(e,t,i){this.queue.push({action:e,data:t,ack:i})},t.flush=function(){var e=this.queue;return this.queue=[],e},t.compactFlush=function(){var n,s,o,r,a=[],e=this.flush();return 0===e.length?e:(s={user:{},group:{}},o=0,r={},e.forEach(function(e){if(o++,this.canCompact(e)){var t=null;void 0!==e.data.user?t="user":void 0!==e.data.group&&(t="group"),void 0===s[t][e.action]&&(s[t][e.action]=[]);for(var i=0;i<s[t][e.action].length;i++)if(n=s[t][e.action][i],this.isSimilarMessage(n.event,e)&&(void 0===r[e.data[t]]||r[e.data[t]]<n.index))return r[e.data[t]]=n.index,n.event.data[t].push(e.data[t]),void n.event.data._d.push(this.getDifference(n.event,e));Array.isArray(e.data[t])||(e.data[t]=[e.data[t]]),e.data._d=[{}],r[e.data[t]]=o,s[t][e.action].push({event:e,index:o})}a.push(e)}.bind(this)),a)},t.moveToEnd=function(e,t){e.push(e.splice(e.indexOf(t),1)[0])},t.isSimilarMessage=function(e,t){return e.action===t.action&&this.getCompareDataString(e)===this.getCompareDataString(t)},t.getDifference=function(e,t){var i,n={};for(i in t.data)if(t.data.hasOwnProperty(i)){switch(i){case"user":case"group":case"_d":case"_i":continue}void 0!==e.data[i]&&e.data[i]===t.data[i]||(n[i]=t.data[i])}return n},t.getCompareDataString=function(e){e=Object.assign({},e.data);return delete e.user,delete e.group,delete e.viewId,delete e._d,delete e._i,JSON.stringify(e)},t.canCompact=function(e){return!(void 0!==e.ack&&null!==e.ack||void 0===e.data||void 0===e.data.user&&void 0===e.data.group)},e.unpack=function(e,t){if(void 0===e[t])return[e];var i=Array.isArray(e[t])?e[t]:[e[t]],n=[];void 0!==e._d&&(n=Array.isArray(e._d)?e._d:[e._d]);for(var s=[],o=0;o<i.length;o++){(r={})[t]=i[o];var r=Object.assign({},e,r,void 0!==n[o]?n[o]:{});delete r._d,s.push(r)}return s},Object.defineProperty(t,"length",{get:function(){return this.queue.length}}),e}),define("CatLab/Webremote/Tools/Proxy",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred"],function(o,r){function e(){}var a=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}];return e.prototype.get=function(e){o.getProxy()&&(e=o.getProxy()+encodeURIComponent(e)),console.log(e);var t,i,n,s=new r;return e=e,t=function(e){s.resolve(e.responseText)},(n=function(){for(var e=!1,t=0;t<a.length;t++){try{e=a[t]()}catch(e){continue}break}return e}())&&(n.open(i?"POST":"GET",e,!0),i&&n.setRequestHeader("Content-type","application/x-www-form-urlencoded"),n.onreadystatechange=function(){4==n.readyState&&(200==n.status||304==n.status?t(n):console.error("CatLab Remote HTTP error "+n.status))},4!=n.readyState)&&n.send(i),s.promise()},new e}),define("CatLab/Webremote/Providers/Provider",["CatLab/Webremote/Synchronization/MessageQueue","CatLab/Webremote/Tools/Proxy","CatLab/Webremote/Tools/Deferred"],function(e,i,o){"use strict";function t(){this.initializeProvider()}var n=t.prototype;return n.initializeProvider=function(){this.queue=new e,this.postInitializeQueue=[],this.scheduled=!1,this.initialized=!1,this.sendBurstDelay=10,this.maxQueueSize=2500,this.messageCounter=null,this.events={}},n.getProviderSettings=function(){var e=new o;return e.resolve({}),e.promise()},n.setMessageCounter=function(e){this.messageCounter=e},n.initMaster=function(e){this.master=e},n.initPlayer=function(e){this.master=e},n.connect=function(){var e=new o;return e.resolve(),e.promise()},n.disconnect=function(){this.off()},n.setOAuthSettings=function(e){this.emit("oauth:set",e)},n.loadViews=function(e,t){(t=void 0===t?!1:t)?i.get(e).then(function(e){this.emit("view:load",{xml:e})}.bind(this)):this.emit("view:load",{url:e})},n.toMaster=function(e,t,i){this.emit(e,t,i)},n.toPlayers=function(e,t,i){this.emit(e,t,i)},n.toPlayer=function(e,t,i,n){i.user=e.getId(),this.emit(t,i,n)},n.toGroup=function(e,t,i,n){i.group=e.getId(),this.emit(t,i,n)},n.emit=function(e,t,i){this.initialized?this.queue?(this.queue.add(e,t,i),this.queue.length>this.maxQueueSize?(clearTimeout(this.scheduled),this.scheduled=null,this.executeQueue()):this.scheduled||(this.scheduled=setTimeout(function(){this.scheduled=null,this.executeQueue()}.bind(this),this.sendBurstDelay))):this.emitOne(e,t,i):this.postInitializeQueue.push({action:e,data:t,ack:i})},n.createGroup=function(e,t,i,n){this.emit("group:create",{externalId:e,globalViews:t,shareColor:i,tags:n=void 0===n?[]:n})},n.executeQueue=function(){this.initialized&&this.emitAll()},n.setInitialized=function(){var e;for(this.initialized=!0;e=this.postInitializeQueue.shift();)this.emit(e.action,e.data,e.ack)},n.setup=function(e){this.emit("master:setup",e)},n.reset=function(e){this.emit("master:reset",null,function(){e()})},n.getStaticUrl=function(e){return e},n.reconnect=function(e,t,i,n){var s=new o;return this.emit("master:reconnect",{token:e,accessToken:t,gameConfig:i},function(){n(),s.resolve()}.bind(this)),s.promise()},n.off=function(){this.events={}},n.on=function(e,t){this._addEvent(e,t,!1),this._touchEvent(e)},n.once=function(e,t){this._addEvent(e,t,!0),this._touchEvent(e)},n._addEvent=function(e,t,i){void 0===this.events[e]&&(this.events[e]=[]),this.events[e].push({callback:t,once:i})},n._touchEvents=function(){for(var e in this.events)this.events.hasOwnProperty(e)&&this._touchEvent(e)},n._touchEvent=function(e){},n._trigger=function(e,i){var n;void 0!==this.events[e]&&(n=[],this.events[e].forEach(function(e){var t=e.callback;e.once&&n.push(e);try{t.apply(this,[i])}catch(e){console.error(e)}}),0<n.length)&&(n.unshift(this.events),function(e){for(var t,i,n=arguments,s=n.length;1<s&&e.length;)for(t=n[--s];-1!==(i=e.indexOf(t));)e.splice(i,1);return e}.apply(this,n))},n.getConnectURL=function(e){return null},n.getConnectToken=function(e){return null},n.tokenConnect=function(e){var t=new o;return t.resolve(),t.promise()},n.noTokenConnect=function(){var e=new o;return e.resolve(),e.promise()},n.restoreProviderSettings=function(e){},n.serializeProviderSettings=function(){return{}},n.proxyFile=function(e){var t=new o;return this.emit("file:proxy",{url:e},function(e){t.resolve({url:e.url})}.bind(this)),t.promise()},t}),define("CatLab/Webremote/Providers/SocketIO",["CatLab/Webremote/Providers/Provider","CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Tools"],function(e,r,a,t){function i(){this.initializeProvider(),this.userId=null,this.randomToken=t.getUuid(),this.loadBalancerSessionToken="connid",this.socket=null,this._registeredEvents={}}var h=null,e=i.prototype=new e;return e.getProviderSettings=function(){var t=new a;return r.getServerList()?r.getServerList().getSelectedServer().done(function(e){t.resolve({host:e})}.bind(this)).fail(function(e){alert(e),t.reject(e)}.bind(this)):t.resolve({}),t.promise()},e.connect=function(n,s){var t,o=new a;return this.log("Loading socket.io"),t=function(){this.log("Connecting to socket.io");var e,t=r.getSocketURL(),i=(void 0!==s.host&&s.host&&(t=(e=r.getProtocol())?e+"://"+s.host:"//"+s.host),this.socket=h(t+"/"+n+"?"+this.loadBalancerSessionToken+"="+this.randomToken,{withCredentials:!1,reconnection:!0}),!1);this.socket.on("connect_error",function(e){i?this._trigger("disconnect"):(this.socket.off(),this.socket.disconnect(),this.socket=null,o.reject())}.bind(this)),this.socket.once("connect",function(){i||(i=!0,this.setInitialized(),this.socket.io.on("reconnect",function(e){this._trigger("reconnect")}.bind(this)),this._touchEvents(),o.resolve())}.bind(this))}.bind(this),require(["socket.io-client"],function(e){h=e,t()}),o.promise()},e.disconnect=function(e){void 0===e&&(e=!0),this.initialized=!1,this.socket&&((e?this:(this._registeredEvents={},this.socket)).off(),this.socket.disconnect(),this.socket=null)},e.off=function(){this._registeredEvents={},this.events={},this.socket.off()},e.setUserId=function(e){return this.userId=e,this},e.emitAll=function(){var e,t=this.queue.compactFlush();if(t.length)for(;e=t.shift();)this.emitOne(e.action,e.data,e.ack)},e.emitOne=function(e,t,i){this.socket.emit(e,t,i),this.messageCounter&&this.messageCounter.outgoing()},e.log=function(){this.master.log.apply(arguments)},e.getStaticUrl=function(e){return e.indexOf("?")<0?e+="?":e+="&",e+(this.loadBalancerSessionToken+"="+this.randomToken)},e._detachEvents=function(e){this.socket&&this.socket.off(e)},e._touchEvent=function(t){this.socket&&void 0===this._registeredEvents[t]&&(this.socket.on(t,function(e){this._trigger(t,e)}.bind(this)),this._registeredEvents[t]=!0)},e._handleSocketIoEvent=function(e,t){switch(e){case"connect":case"disconnect":break;default:return this._trigger(e,t)}},e.getConnectURL=function(e){return r.getServerList()?r.getServerList().getConnectURL():e},e.getConnectToken=function(e){return r.getServerList()?r.getServerList().getConnectToken(e):e},e.tokenConnect=function(e){var t=new a,i={};if(r.getServerList())try{var n=r.getServerList().getFromToken(e);i.host=n.host,e=n.token}catch(e){return t.reject(),t.promise()}return this.connect("remote",i).fail(function(){t.reject()}).then(function(){t.resolve(e)}),t.promise()},e.restoreProviderSettings=function(e){void 0!==e.serverlist&&r.getServerList()&&r.getServerList().unserialize(e.serverlist)},e.serializeProviderSettings=function(){var e={};return r.getServerList()&&(e.serverlist=r.getServerList().serialize()),e},i}),define("CatLab/Webremote/SonicSync/Library/ring-buffer",[],function(){function t(e){this.array=[],this.maxLength=e}return t.prototype.get=function(e){return e>=this.array.length?null:this.array[e]},t.prototype.last=function(){return 0==this.array.length?null:this.array[this.array.length-1]},t.prototype.add=function(e){this.array.push(e),this.array.length>=this.maxLength&&this.array.splice(0,1)},t.prototype.length=function(){return this.array.length},t.prototype.clear=function(){this.array=[]},t.prototype.copy=function(){var e=new t(this.maxLength);return e.array=this.array.slice(0),e},t.prototype.remove=function(e,t){this.array.splice(e,t)},t}),define("CatLab/Webremote/SonicSync/Library/sonic-coder",[],function(){function e(e){this.freqMin=(e=e||{}).freqMin||18500,this.freqMax=e.freqMax||19500,this.freqError=e.freqError||50,this.alphabetString=e.alphabet||"\n abcdefghijklmnopqrstuvwxyz0123456789,.!?@*",this.startChar=e.startChar||"^",this.endChar=e.endChar||"$",this.alphabet=this.startChar+this.alphabetString+this.endChar}return e.prototype.charToFreq=function(e){var t=this.alphabet.indexOf(e),e=(-1==t&&(console.error(e,"is an invalid character."),t=this.alphabet.length-1),this.freqMax-this.freqMin),t=t/this.alphabet.length,e=Math.round(e*t);return this.freqMin+e},e.prototype.freqToChar=function(e){if(!(this.freqMin<e&&e<this.freqMax))if(this.freqMin-e<this.freqError)e=this.freqMin;else{if(!(e-this.freqMax<this.freqError))return console.error(e,"is out of range."),null;e=this.freqMax}var t=this.freqMax-this.freqMin,e=(e-this.freqMin)/t,t=Math.round(this.alphabet.length*e);return this.alphabet[t]},e}),define("CatLab/Webremote/SonicSync/Library/sonic-server",["./ring-buffer","./sonic-coder"],function(t,i){function e(e){this.peakThreshold=(e=e||{}).peakThreshold||-65,this.minRunLength=e.minRunLength||2,this.coder=e.coder||new i(e),this.timeout=e.timeout||300,this.debug=!!e.debug,this.peakHistory=new t(16),this.peakTimes=new t(16),this.callbacks={},this.buffer="",this.state=n,this.isRunning=!1,this.iteration=0}var n=1,s=2;return e.prototype.start=function(){try{navigator.mediaDevices||console.log("No mediadevices found"),navigator.mediaDevices.getUserMedia({audio:{optional:[{echoCancellation:!1}]}}).then(this.onStream_.bind(this)).catch(this.onStreamError_.bind(this))}catch(e){console.log(e)}},e.prototype.stop=function(){this.isRunning=!1,this.track.stop()},e.prototype.on=function(e,t){"message"==e&&(this.callbacks.message=t),"character"==e&&(this.callbacks.character=t)},e.prototype.setDebug=function(e){this.debug=e;e=document.querySelector("canvas");e&&e.parentElement.removeChild(e)},e.prototype.fire_=function(e,t){"function"==typeof e&&e(t)},e.prototype.onStream_=function(e){var t;void 0!==e.getTracks()[0]?(this.track=e.getTracks()[0],t=new AudioContext,e=(this.audioContext=t).createMediaStreamSource(e),t=t.createAnalyser(),e.connect(t),this.freqs=new Float32Array(t.frequencyBinCount),this.analyser=t,this.isRunning=!0,this.raf_(this.loop.bind(this))):console.log("No microphone found.")},e.prototype.onStreamError_=function(e){console.error("Audio input error:",e)},e.prototype.getPeakFrequency=function(){for(var e=-1/0,t=-1,i=this.freqToIndex(this.coder.freqMin);i<this.freqs.length;i++)this.freqs[i]>e&&(e=this.freqs[i],t=i);return e>this.peakThreshold?this.indexToFreq(t):null},e.prototype.loop=function(){this.analyser.getFloatFrequencyData(this.freqs),(this.iteration+1)%300==0&&this.restartServerIfSanityCheckFails();var e=this.getPeakFrequency();e?(e=this.coder.freqToChar(e),this.debug&&console.log("Transcribed char: "+e),this.peakHistory.add(e),this.peakTimes.add(new Date)):(e=this.peakTimes.last())&&new Date-e>this.timeout&&(this.state=n,this.debug&&console.log("Token",this.buffer,"timed out"),this.peakTimes.clear()),this.analysePeaks(),this.debug&&this.debugDraw_(),this.isRunning&&this.raf_(this.loop.bind(this)),this.iteration+=1},e.prototype.indexToFreq=function(e){return this.audioContext.sampleRate/2/this.freqs.length*e},e.prototype.freqToIndex=function(e){var t=this.audioContext.sampleRate/2;return Math.round(e/t*this.freqs.length)},e.prototype.analysePeaks=function(){var e=this.getLastRun();e&&(this.state==n?e==this.coder.startChar&&(this.buffer="",this.state=s):this.state==s&&(e!=this.lastChar&&e!=this.coder.startChar&&e!=this.coder.endChar&&(this.buffer+=e,this.lastChar=e,this.fire_(this.callbacks.character,e)),e==this.coder.endChar)&&(this.state=n,this.fire_(this.callbacks.message,this.buffer),this.buffer=""))},e.prototype.getLastRun=function(){for(var e=this.peakHistory.last(),t=0,i=this.peakHistory.length()-2;0<=i&&this.peakHistory.get(i)==e;i--)t+=1;return t>this.minRunLength?(this.peakHistory.remove(i+1,t+1),e):null},e.prototype.debugDraw_=function(){var e=document.querySelector("canvas");e||(e=document.createElement("canvas"),document.body.appendChild(e)),e.width=document.body.offsetWidth,e.height=480,drawContext=e.getContext("2d");for(var t=0;t<this.freqs.length;t++){var i=this.freqs[t]+400,i=e.height-i-1,n=e.width/this.freqs.length;drawContext.fillStyle="black",drawContext.fillRect(t*n,i,1,1)}},e.prototype.raf_=function(e){"undefined"==typeof window||window.chrome&&chrome.extension?setTimeout(e,1e3/60):requestAnimationFrame(e)},e.prototype.restartServerIfSanityCheckFails=function(){if(this.freqs[0]<-300)console.error("freqs[0] < -300. Restarting."),this.restart();else{for(var e=!0,t=0;t<10;t++)-100==this.freqs[t]&&(e=!1);e||(console.error("freqs[0:10] == -100. Restarting."),this.restart())}},e.prototype.restart=function(){},e}),define("CatLab/Webremote/SonicSync/Library/sonic-socket",["./sonic-coder"],function(t){var i=!1;function e(e){this.coder=(e=e||{}).coder||new t,this.charDuration=e.charDuration||.5,this.coder=e.coder||new t(e),this.rampDuration=e.rampDuration||.001,this.audioContext=new i}return"undefined"!=typeof window&&(i=window.AudioContext||window.webkitAudioContext||!1),e.prototype.send=function(e,t){e=this.coder.startChar+e+this.coder.endChar;for(var i,n=0;n<e.length;n++){var s=e[n],s=this.coder.charToFreq(s),o=this.audioContext.currentTime+this.charDuration*n;this.scheduleToneAt(s,o,this.charDuration)}t&&(i=this.charDuration*e.length,setTimeout(t,1e3*i))},e.prototype.scheduleToneAt=function(e,t,i){var n=this.audioContext.createGain(),i=(n.gain.value=0,n.gain.setValueAtTime(0,t),n.gain.linearRampToValueAtTime(1,t+this.rampDuration),n.gain.setValueAtTime(1,t+i-this.rampDuration),n.gain.linearRampToValueAtTime(0,t+i),n.connect(this.audioContext.destination),this.audioContext.createOscillator());i.frequency.value=e,i.connect(n),i.start(t)},e}),define("CatLab/Webremote/SonicSync/Client",["CatLab/Webremote/Config","CatLab/Webremote/SonicSync/Library/ring-buffer","CatLab/Webremote/SonicSync/Library/sonic-coder","CatLab/Webremote/SonicSync/Library/sonic-server","CatLab/Webremote/SonicSync/Library/sonic-socket","CatLab/Webremote/Tools/Deferred"],function(t,e,i,n,s,o){function r(e){this.options=t.getAudioSyncConfig(),this.alphabet=this.options.alphabet.split(""),this.controller=e}var a=r.prototype;return a.startListener=function(){this.stop();var e=new n(this.options);e.start(),e.on("message",this.onIncomingMessage.bind(this)),this.sonicServer=e},a.startSender=function(){this.sonicSocket=new s(this.options)},a.stop=function(){this.sonicServer&&this.sonicServer.stop()},a.sync=function(){var e=new o,t=this.generateRandomSequence(this.options.length);return this.sonicSocket.send(t+this.getParityLetter(t),function(){this.controller.trigger("sync:audio",{secret:t})}.bind(this)),e.promise()},a.generateRandomSequence=function(e){for(var t,i="",n="",s=0;s<e;s++){for(;t=Math.floor(Math.random()*this.alphabet.length),(n=this.alphabet[t])===i.substr(i.length-1,1););i+=n}return i},a.getParityLetter=function(e){for(var t=0,i=e.split(""),n=0;n<i.length;n++)t+=this.alphabet.indexOf(i[n]);e=t%this.alphabet.length;return i[i.length-1]===this.alphabet[e]&&(e=(e+1)%this.alphabet.length),this.alphabet[e]},a.onIncomingMessage=function(e){var t=e.substr(0,e.length-1),i=this.getParityLetter(t);i===e[e.length-1]?this.onMessage(t):console.log("Parity check failed, expected "+i+", ignoring message")},a.onMessage=function(e){this.controller.emit("sync:audio",{secret:e})},a.generateAlphabet=function(e){for(var t="",i=0;i<Math.min(e.length,9);i++)t+=i.toString();return t},r}),define("CatLab/Webremote/Tools/ClientSniffer",[],function(){"use strict";function e(){this._canPlayWebM=null}var t=e.prototype;return t.isMobileBrowser=function(){var e,t;return!this.isCordova()&&(e=!1,t=navigator.userAgent||navigator.vendor||window.opera,!(!/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)&&!/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))||e)},t.isCordova=function(){return"undefined"!=typeof cordova},t.isInternetExplorer=function(){var e=window.navigator.userAgent,t=e.indexOf("MSIE ");return 0<t?parseInt(e.substring(t+5,e.indexOf(".",t)),10):0<e.indexOf("Trident/")?(t=e.indexOf("rv:"),parseInt(e.substring(t+3,e.indexOf(".",t)),10)):0<(t=e.indexOf("Edge/"))&&parseInt(e.substring(t+5,e.indexOf(".",t)),10)},t.supportsLocalStorage=function(){try{if(window.localStorage)return!0}catch(e){return!1}},t.canPlayWebM=function(){if(null===this._canPlayWebM){this._canPlayWebM=!1;try{var e=document.createElement("video");e.canPlayType&&(this._canPlayWebM=e.canPlayType('video/webm; codecs="vp8, vorbis"'))}catch(e){console.error(e)}}return this._canPlayWebM},new e}),define("CatLab/Webremote/Components/ImagePositionInputComponent",["jquery","CatLab/Webremote/Tools/ClientSniffer"],function(h,e){function t(e,t){this.element=t,this.remotePlayerView=e,this.positions=[],this.canvas=null,this.isLoaded=!1,this.isRotated=!1,this.buttons=null,this.pointCountContainer=null,this.draw()}var i=t.prototype;return i.draw=function(){h(this.element).html(""),this.buttons=null,this.circleRadius=this.element.attr("circleRadius")||2,this.circleStroke=this.element.attr("circleStroke")||Math.max(.5,this.circleRadius/5),this.circleStrokeColor=this.element.attr("circleStrokeColor")||"red",this.circleFillColor=this.element.attr("circleFillColor")||"rgb(255,255,0,0.3)",this.image=this.element.attr("src"),this.image&&(this.element.html('<div class="image"><img /></div>'),this.imageElement=h(this.element).find("img"),this.imageElement.on("load",function(){this.isLoaded=!0,this.resizeImage()}.bind(this)),this.imageElement.attr("src",this.image),this.imageElement.on("dragstart",function(e){e.preventDefault()}),this.svgContainer=h('<div class="pointer-container">'),this.element.find(".image").append(this.svgContainer),this.resizeSvgContainer(),this.svgContainer.click(function(e){this.svgClick(e)}.bind(this)))},i.resizeSvgContainer=function(){var e=this.imageElement;this.isRotated&&this.rotatedImageElement&&(e=this.rotatedImageElement),this.svgContainer.css({position:"absolute","z-index":1,width:e.width(),height:e.height(),left:e.position().left,top:e.position().top})},i.resizeImage=function(){this.isLoaded&&(this.element.width(),this.element.height(),this.imageElement.get(0).naturalWidth,this.imageElement.get(0).naturalHeight,e.isMobileBrowser(),this.isRotated=!1,this.element.toggleClass("rotated",this.isRotated),this.isRotated?(this.generateCanvas(),this.rotatedImageElement.show(),this.imageElement.hide()):(this.rotatedImageElement&&this.rotatedImageElement.hide(),this.imageElement.show()),this.resizeSvgContainer())},i.generateCanvas=function(){var e,t,i,n,s,o,r,a;this.rotatedImageElement||(s=this.imageElement[0],e=this.imageElement.get(0).naturalWidth,t=this.imageElement.get(0).naturalHeight,(i=document.createElement("canvas")).width=t,i.height=e,n=i.getContext("2d"),s=s,o=i.width/2,r=i.height/2,a=0-Math.PI/2,n.setTransform(1,0,0,1,o,r),n.rotate(a),n.drawImage(s,-e/2,-t/2),this.rotatedImageElement=h(i),this.element.find("div.image").append(this.rotatedImageElement))},i.imageClick=function(e){var t=e.offsetX/this.imageElement.width(),e=e.offsetY/this.imageElement.height();this.selectPosition(t,e)},i.svgClick=function(e){var t=e.offsetX/this.svgContainer.width(),e=e.offsetY/this.svgContainer.height();this.isRotated?this.selectPosition(1-e,t):this.selectPosition(t,e)},i.canvasClick=function(e){var t=e.offsetX/this.rotatedImageElement.width(),e=e.offsetY/this.rotatedImageElement.height();this.selectPosition(1-e,t)},i.selectPosition=function(e,t){0<this.getMaxPoints()&&this.positions.length>=this.getMaxPoints()||(this.positions.push({x:e,y:t}),this.drawCircles(),this.shouldConfirmPosition()?this.showSubmitButton():this.submit())},i.shouldConfirmPosition=function(){return"1"==this.element.attr("confirm-position")},i.getMinPoints=function(){return this.element.attr("min-points")&&0<parseInt(this.element.attr("min-points"))?parseInt(this.element.attr("min-points")):1},i.getMaxPoints=function(){return this.element.attr("max-points")&&0<parseInt(this.element.attr("max-points"))?parseInt(this.element.attr("max-points")):1},i.showSubmitButton=function(){this.buttons?this.positionSubmitButton():(this.buttons=h('<div class="imagemap-buttons"><button data-action="submit" class="imagemap-button pulsating">'+(2<this.getMaxPoints()?'<span class="point-counter"></span>':"")+'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 22"><path d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z"/></svg></button><button data-action="reset" class="imagemap-button"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 22"><path d="M24 20.188l-8.315-8.209 8.2-8.282-3.697-3.697-8.212 8.318-8.31-8.203-3.666 3.666 8.321 8.24-8.206 8.313 3.666 3.666 8.237-8.318 8.285 8.203z" /></button></div>'),this.element.append(this.buttons),this.positionSubmitButton(),this.buttons.find("button[data-action=submit]").click(function(){this.submit()}.bind(this)),this.buttons.find("button[data-action=reset]").click(function(){this.reset(),this.hideSubmitButton()}.bind(this)),this.pointCountContainer=this.buttons.find(".point-counter"),this.updatePointCount())},i.updatePointCount=function(){this.pointCountContainer&&(this.pointCountContainer.html(this.positions.length),this.pointCountContainer.toggleClass("insufficient",this.positions.length<this.getMinPoints()),this.buttons.find("button[data-action=submit]").toggleClass("pulsating",this.positions.length>=this.getMinPoints()),this.buttons.find("button[data-action=submit]").toggleClass("disabled",this.positions.length<this.getMinPoints()))},i.hideSubmitButton=function(){this.buttons.hide()},i.positionSubmitButton=function(){this.buttons.show(),.5<this.positions[0].x?(this.buttons.addClass("left"),this.buttons.removeClass("right")):(this.buttons.addClass("right"),this.buttons.removeClass("left"))},i.submit=function(){this.positions.length<this.getMinPoints()||this.remotePlayerView.controller.syncValue("position",{x:0<this.positions.length?this.positions[0].x:null,y:0<this.positions.length?this.positions[0].y:null,p:this.positions},this.remotePlayerView.viewId)},i.cancelSelection=function(){},i.drawCircles=function(){this.updatePointCount(),this.svgContainer.empty(),0!==this.positions.length&&this.positions.forEach(function(t){var e=this.imageElement,i=t.x,n=t.y,s=e.width(),e=e.height(),o=(this.isRotated&&this.rotatedImageElement&&(i=t.y,n=1-t.x,s=this.rotatedImageElement.width(),e=this.rotatedImageElement.height()),this.imageElement.width()/100*this.circleRadius),r=Math.max(1,this.imageElement.width()/100*this.circleStroke),a=$("<svg><circle></circle></svg>");a.click(function(e){e.preventDefault(),e.stopPropagation(),this.removePoint(t),0===this.positions.length&&this.hideSubmitButton()}.bind(this)),this.svgContainer.append(a),a.find("circle").attr({cx:o+r,cy:o+r,r:o,"stroke-width":r,stroke:this.circleStrokeColor,fill:this.circleFillColor}),a.attr({width:2*(o+r),height:2*(o+r)}),a.css({position:"absolute",left:s*i-o-r,top:e*n-o-r})}.bind(this))},i.removePoint=function(e){e=this.positions.indexOf(e);-1<e&&this.positions.splice(e,1),this.drawCircles()},i.resize=function(){this.resizeImage(),this.drawCircles()},i.update=function(){this.draw()},i.destroy=function(){},i.reset=function(){this.positions=[],this.drawCircles()},t.css=" image-position-input { display: flex; justify-content: center; align-content: center; align-items: center; } image-position-input .image { text-align: center; transform-origin: 0 0; } image-position-input .image img, image-position-input .image canvas { display: inline; max-width: 90%; max-height: 90%; max-width: 90vw; max-height: 90vh; height: auto; width: auto; } image-position-input button.imagemap-button svg { height: 48px; width: 48px; } image-position-input button.imagemap-button { margin-left: 10px; position: relative; } image-position-input button.imagemap-button.disabled svg { fill: gray; } image-position-input .imagemap-buttons { position: absolute; right: 10px; bottom: 10px; z-index: 10; } image-position-input .imagemap-buttons.left { left: 10px; right: auto; } image-position-input.rotated .imagemap-buttons { transform: rotate(-90deg); transform-origin: center right; top: 0px; right: 58px; bottom: auto; left: auto; bottom: auto; } image-position-input.rotated .imagemap-buttons.left { bottom: 0px; top: auto; right: -101px; transform-origin: center left; } image-position-input button.pulsating .point-counter { } image-position-input .point-counter { font-size: 1em; vertical-align: middle; position: absolute; top: -1em; left: -1em; border: 1px solid black; border-radius: 100%; padding: 0.5em; background: white; min-width: 1em; } image-position-input .point-counter.insufficient { border-color: red; color: red; } ",t.selector="image-position-input",t}),define("CatLab/Webremote/Components/FullscreenButtonComponent",["jquery","screenfull","CatLab/Webremote/Config"],function(e,t,i){function n(e,t,i){this.element=t,this.remotePlayerView=e,this.position=null,this.componentContainer=i,this.draw()}var s=n.prototype;return s.draw=function(){i.canFullscreen()&&t&&t.isEnabled&&!t.isFullscreen?(e(this.element).html('<svg xmlns="http://www.w3.org/2000/svg" style="display: block" width="100%" height="100%" viewBox="0 0 24 24"><path d="M6.426 10.668l-3.547-3.547-2.879 2.879v-10h10l-2.879 2.879 3.547 3.547-4.242 4.242zm11.148 2.664l3.547 3.547 2.879-2.879v10h-10l2.879-2.879-3.547-3.547 4.242-4.242zm-6.906 4.242l-3.547 3.547 2.879 2.879h-10v-10l2.879 2.879 3.547-3.547 4.242 4.242zm2.664-11.148l3.547-3.547-2.879-2.879h10v10l-2.879-2.879-3.547 3.547-4.242-4.242z"/></svg>'),e(this.element).click(function(){t.request(null,{navigationUI:"hide"})}.bind(this))):e(this.element).html("")},s.resize=function(){this.draw()},s.update=function(){this.draw()},s.destroy=function(){},n.css=" ",n.selector="fullscreen-button",n}),define("CatLab/Webremote/Components/ViewDefinedComponent",["jquery"],function(t){function e(e,t){this.element=t,this.remotePlayerView=e,this.position=null,this.draw()}var i=e.prototype;return i.draw=function(){if(this.element){t(this.element).html("");for(var e=0;e<this.content.childNodes.length;e++)t(this.element).append(this.content.childNodes[e].cloneNode(!0));this.componentContainer.attachComponents(this.remotePlayerView,this.element)}},i.update=function(){this.draw()},i.resize=function(){this.draw()},i.destroy=function(){},e.css=" ",e.selector="view-defined-component",e.content="",e}),define("CatLab/Webremote/Views/Popups/IframePopup",["CatLab/Webremote/Views/Popups/BasePopup"],function(e){function t(e){this.url=e}return(t.prototype=new e).renderContent=function(e){this.container.className+=" iframe";var t=$('<iframe src="'+this.url+'"></iframe>');$(t).css({height:"99%",width:"100%","border-width":0}),$(e).append(t),$(e).css({position:"relative",height:"100%",width:"100%","box-sizing":"border-box",overflow:"auto","-webkit-overflow-scrolling":"touch"})},t}),define("CatLab/Webremote/Components/ModalIframeLink",["jquery","CatLab/Webremote/Views/Popups/IframePopup"],function(t,i){function e(e,t,i){this.element=t,this.remotePlayerView=e,this.position=null,this.componentContainer=i,this.draw()}var n=e.prototype;return n.draw=function(){t(this.element).off("click"),t(this.element).on("click",function(){var e=t(this.element).attr("href"),e=this.remotePlayerView.stringInterpolateDataElements(e,encodeURIComponent);new i(e).render(document.body)}.bind(this))},n.resize=function(){this.draw()},n.update=function(){this.draw()},n.destroy=function(){},e.css=" ",e.selector="modal-iframe-link",e}),define("CatLab/Webremote/Views/Popups/TextPopup",["CatLab/Webremote/Views/Popups/BasePopup"],function(e){function t(e){this.message=e}return(t.prototype=new e).renderContent=function(e){var t=(t=this.message).replace(/(?:\r\n|\r|\n)/g,"<br>");e.innerHTML=t},t}),define("CatLab/Webremote/Components/TooltipComponent",["jquery","CatLab/Webremote/Views/Popups/TextPopup"],function(e,t){function i(e,t,i){this.element=t,this.remotePlayerView=e,this.position=null,this.componentContainer=i,this.draw()}var n=i.prototype;return n.draw=function(){e(this.element).off("click"),e(this.element).on("click",function(){new t(this.element.attr("data-tooltip")).render(document.body)}.bind(this))},n.resize=function(){},n.update=function(){},n.destroy=function(){},i.css=" ",i.selector="[data-tooltip]",i}),define("CatLab/Webremote/Components/VirtualKeyboardComponent",["jquery","SimpleKeyboard","CatLab/Webremote/Config"],function(t,i,n){"use strict";var s,o=null,e=0;function r(){t(".simple-keyboard").addClass("hidden"),o=null}function a(e,t,i){this.element=t,this.remotePlayerView=e,this.position=null,this.componentContainer=i,this.inputType=t.attr("type")?t.attr("type").toLowerCase():"text",this.draw()}var h=a.prototype;return h.draw=function(){(function(){var e=t.Deferred();t("<link>").appendTo("head").attr({type:"text/css",rel:"stylesheet",href:n.getVendorPath()+"simple-keyboard/build/css/index.css"}),t('<div class="simple-keyboard"></div>').appendTo("body"),s=new i.default({onChange:function(e){o&&o.onKeyboardChange(e)}.bind(this),onKeyPress:function(e){switch(e){case"{shift}":case"{lock}":t="default"===s.options.layoutName?"shift":"default",s.setOptions({layoutName:t});break;case"{numbers}":case"{abc}":t="numbers"!==s.options.layoutName?"numbers":"default",s.setOptions({layoutName:t});break;case"{ent}":r();break;case"{arrowup}":o.increaseValue(1);break;case"{arrowdown}":o.increaseValue(-1)}var t}.bind(this),layoutName:"default",layout:{default:["q w e r t y u i o p","a s d f g h j k l","{shift} z x c v b n m {backspace}","{numbers} {space} {ent}"],shift:["Q W E R T Y U I O P","A S D F G H J K L","{shift} Z X C V B N M {backspace}","{numbers} {space} {ent}"],numbers:["1 2 3","4 5 6","7 8 9","{abc} 0 {backspace}"]},physicalKeyboardHighlight:!0,disableCaretPositioning:!1,mergeDisplay:!0,display:{"{numbers}":"123","{ent}":"⇩","{escape}":"esc ⎋","{tab}":"tab ⇥","{backspace}":"⌫","{capslock}":"caps lock ⇪","{shift}":"⇧","{controlleft}":"ctrl ⌃","{controlright}":"ctrl ⌃","{altleft}":"alt ⌥","{altright}":"alt ⌥","{metaleft}":"cmd ⌘","{metaright}":"cmd ⌘","{abc}":"ABC"}}),t(".simple-keyboard").addClass("hidden"),e.promise()})(),this.element.attr("id")||this.element.attr("id","input_"+ ++e),this.element.prop("type","text"),/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&this.element.prop("readonly",!0),this.element.on("input",this.onInputChange.bind(this)),this.element.on("focus",this.onInputFocus.bind(this)),this.element.hasClass("visible")&&this.onInputFocus()},h.hideKeyboard=function(){r()},h.showKeyboard=function(){var e;"number"===(e=this).inputType?s.setOptions({inputName:e.element.attr("id"),layoutName:"numbers",layout:{default:["q w e r t y u i o p","a s d f g h j k l","{shift} z x c v b n m {backspace}","{numbers} {space} {ent}"],numbers:["1 2 3 {arrowup}","4 5 6 {arrowdown}","7 8 9 "+1.1.toLocaleString().substring(1,2),"{backspace} 0 {ent}"]}}):s.setOptions({inputName:e.element.attr("id"),layoutName:"default",layout:{default:["q w e r t y u i o p","a s d f g h j k l","{shift} z x c v b n m {backspace}","{numbers} {space} {ent}"],shift:["Q W E R T Y U I O P","A S D F G H J K L","{shift} Z X C V B N M {backspace}","{numbers} {space} {ent}"],numbers:["1 2 3","4 5 6","7 8 9","{abc} 0 {backspace}"]}}),t(".simple-keyboard").removeClass("hidden"),o=e,s.setInput(e.element.val(),e.element.attr("id"))},h.onKeyboardChange=function(e){var t;this.element.val(e),this.element.trigger("change"),this.element.attr("data-value-realtime")&&(t=this.element.attr("data-value-id"))&&this.remotePlayerView.controller.syncValue(t,e,this.remotePlayerView.viewId)},h.onInputChange=function(){s.setInput(this.element.val(),this.element.attr("id"))},h.onInputFocus=function(){this.showKeyboard()},h.setInputCaretPosition=function(e){this.element[0].setSelectionRange&&(this.element[0].focus(),this.element[0].setSelectionRange(e,e))},h.increaseValue=function(e){var t;"number"===this.inputType&&(t=(t=parseFloat(this.element.val()))||0,this.element.val(t+e))},h.submit=function(){this.hideKeyboard()},h.resize=function(){this.draw()},h.update=function(){this.draw()},h.destroy=function(){this.hideKeyboard()},a.css=" .simple-keyboard { position: fixed; bottom: 0; display: block; } .simple-keyboard.hidden { display: none; } ",a.selector="input.virtual",a}),define("CatLab/Webremote/Components/TimerComponent",["jquery"],function(t){function e(e,t){this.element=t,this.remotePlayerView=e,this.draw(),this.countdownInterval=setInterval(function(){this.tick()}.bind(this),100),this.startDate=Date.now(),this.targetDate=null,this.counterHtml=null,this.progessBar=null}var i=e.prototype;return i.draw=function(){var e;t(this.element).html(""),this.targetDate=this.element.attr("to"),this.targetDate&&(this.element.attr("start")&&(this.startDate=this.element.attr("start")),e=t('<div class="timer-container"></div>'),this.counterHtml=t('<div class="countdown"></div>'),e.append(this.counterHtml),this.progessBar=t('<div class="progress-bar">&nbsp;</div>'),e.append(this.progessBar),t(this.element).append(e))},i.tick=function(){var e,t;this.targetDate&&this.counterHtml&&this.progessBar&&((e=this.targetDate-Date.now())<0?this.counterHtml.html("0"):(t=(Date.now()-this.startDate)/(this.targetDate-this.startDate)*100,this.counterHtml.html(Math.ceil(e/1e3)),this.progessBar.css("width",t+"%")))},i.resize=function(){},i.update=function(){this.draw()},i.clearInterval=function(){this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null)},i.destroy=function(){this.clearInterval()},e.css=" timer-countdown { position: fixed; bottom: 0px; left: 0px; width: 100%; color: white; z-index: 1000; } timer-countdown .progress-bar { position:absolute; height: 3px; bottom: 0; background: #eca93b; } timer-countdown .countdown { display: none; } ",e.selector="timer-countdown",e}),define("CatLab/Webremote/Components/SmileyFlingerComponent",["jquery","CatLab/Webremote/Views/Blocks/CurrentSmiley"],function(e,n){function t(e,t,i){this.element=t,this.remotePlayerView=e,this.position=null,this.componentContainer=i,this.smileySlinger=new n(i.Webremote,!0,!0,!1),this.draw()}var i=t.prototype;return i.draw=function(){this.smileySlinger.render(this.element)},i.resize=function(){this.draw()},i.update=function(){this.draw()},i.destroy=function(){},t.css=" ",t.selector="smiley-flinger",t}),define("CatLab/Webremote/Components/Components",["jquery","./ImagePositionInputComponent","./FullscreenButtonComponent","./ViewDefinedComponent","./ModalIframeLink","./TooltipComponent","./VirtualKeyboardComponent","./TimerComponent","./SmileyFlingerComponent"],function(s,t,i,o,n,r,a,h,l){function e(e){this.components=[t,i,n,r,a,h,l],this.Webremote=e,this.viewDefinedComponents=[],this.existingComponents=[]}var c=e.prototype;return c.initialize=function(){for(var e=0;e<this.components.length;e++)this.initializeComponent(this.components[e])},c.initializeComponent=function(e){e.css;var t=document.createElement("style");t.attributes.type="text/css",t.innerHTML=e.css,document.head.appendChild(t)},c.resetViewDefinedComponents=function(){for(var e=0;e<this.viewDefinedComponents.length;e++)this.removeComponent(this.viewDefinedComponents[e])},c.removeComponent=function(e){for(var t=0;t<this.components.length;t++)if(this.components[t].selector===e)return void this.components.splice(t,1)},c.addComponent=function(e){0<=this.components.indexOf(e)||(this.components.push(e),this.initializeComponent(e))},c.addViewDefinedComponent=function(e,n){for(var t=0;t<this.components.length;t++)if(this.components[t].selector===e)return;function i(e,t,i){this.element=t,this.remotePlayerView=e,this.position=null,this.content=n,this.componentContainer=i,this.draw()}this.viewDefinedComponents.push(e),i.prototype=new o,i.selector=e,i.content=n,this.components.push(i)},c.attach=function(e,t,i){(i=void 0===i?!0:i)&&(this.existingComponents.forEach(function(e){e.destroy()}.bind(this)),this.existingComponents=[]),this.attachComponents(e,t)},c.resize=function(){this.existingComponents.forEach(function(e){e.resize()}.bind(this))},c.update=function(){this.existingComponents.forEach(function(e){e.update()}.bind(this))},c.attachComponents=function(e,t){for(var i=0;i<this.components.length;i++)try{this.attachComponent(e,t,this.components[i])}catch(e){console.log(e)}},c.attachComponent=function(i,e,n){s(e).find(n.selector).each(function(e,t){t=new n(i,s(t),this);this.existingComponents.push(t)}.bind(this))},e}),!function(){!function(e,t){"use strict";"function"==typeof define&&define.amd?define("viewport-units-buggyfill",[],t):"object"==typeof exports?module.exports=t():e.viewportUnitsBuggyfill=t()}(this,function(){"use strict";var a,h,l,i,e,n=!1,t=window.navigator.userAgent,c=/([+-]?[0-9.]+)(vh|vw|vmin|vmax)/g,s=/(https?:)?\/\//,u=[].forEach,d=/MSIE [0-9]\./i.test(t),p=/MSIE [0-8]\./i.test(t),f=-1<t.indexOf("Opera Mini"),g=/(iPhone|iPod|iPad).+AppleWebKit/i.test(t)&&(e=t.match(/OS (\d)/))&&1<e.length&&parseInt(e[1])<10,m=-1<t.indexOf(" Android ")&&-1<t.indexOf("Version/")&&parseFloat((t.match("Android ([0-9.]+)")||[])[1])<=4.4,d=d||!!navigator.userAgent.match(/MSIE 10\.|Trident.*rv[ :]*1[01]\.| Edge\/1\d\./);try{new v("test")}catch(a){var v=function(e,t){var i;return t=t||{bubbles:!1,cancelable:!1,detail:void 0},(i=document.createEvent("CustomEvent")).initCustomEvent(e,t.bubbles,t.cancelable,t.detail),i};v.prototype=window.Event.prototype,window.CustomEvent=v}function b(){n&&(o(),setTimeout(function(){i.textContent=y(),i.parentNode.appendChild(i),window.dispatchEvent(new v("viewport-units-buggyfill-style"))},1))}function o(){return l=[],u.call(document.styleSheets,function(e){var t=function(e){try{if(!e.cssRules)return}catch(e){if("SecurityError"!==e.name)throw e;return}for(var t=[],i=0;i<e.cssRules.length;i++){var n=e.cssRules[i];t.push(n)}return t}(e);!t||"patched-viewport"===e.ownerNode.id||"ignore"===e.ownerNode.getAttribute("data-viewport-units-buggyfill")||e.media&&e.media.mediaText&&window.matchMedia&&!window.matchMedia(e.media.mediaText).matches||u.call(t,r)}),l}function r(i){if(7===i.type){var e;try{e=i.cssText}catch(e){return}c.lastIndex=0,c.test(e)&&!s.test(e)&&(l.push([i,null,e]),a.hacks)&&a.hacks.findDeclarations(l,i,null,e)}else i.style?u.call(i.style,function(e){var t=i.style.getPropertyValue(e);i.style.getPropertyPriority(e)&&(t+=" !important"),c.lastIndex=0,c.test(t)&&(l.push([i,e,t]),a.hacks)&&a.hacks.findDeclarations(l,i,e,t)}):i.cssRules&&u.call(i.cssRules,function(e){r(e)})}function y(){var e=window.innerHeight,t=window.innerWidth;h={vh:e,vw:t,vmax:Math.max(t,e),vmin:Math.min(t,e)};var n,s,o=[],r=[];return l.forEach(function(e){var e=function(e,t,i){var n=[];i=i.replace(c,A),a.hacks&&(i=a.hacks.overwriteDeclaration(e,t,i)),t&&(n.push(e.selectorText),i=t+": "+i+";");for(var s=e.parentRule;s;)s.media?n.unshift("@media "+s.media.mediaText):s.conditionText&&n.unshift("@supports "+s.conditionText),s=s.parentRule;return{selector:n,content:i}}.apply(null,e),t=e.selector.length?e.selector.join(" {\n")+" {\n":"",i=new Array(e.selector.length+1).join("\n}");t&&t===n?(t&&!n&&(n=t,s=i),r.push(e.content)):(r.length&&(o.push(n+r.join("\n")+s),r.length=0),t?(n=t,s=i,r.push(e.content)):(o.push(e.content),s=n=null))}),r.length&&o.push(n+r.join("\n")+s),f&&o.push("* { content: normal !important; }"),o.join("\n\n")}function A(e,t,i){i=h[i];return parseFloat(t)/100*i+"px"}function w(e){return e.slice(0,e.indexOf("/",e.indexOf("://")+3))}return{version:"0.6.1",findProperties:o,getCss:y,init:function(e){if(!n){if((a=(e=!0===e?{force:!0}:e)||{}).isMobileSafari=g,a.isBadStockAndroid=m,!a.ignoreVmax||a.force||p||(d=!1),p||!a.force&&!g&&!d&&!m&&!f&&(!a.hacks||!a.hacks.required(a)))return window.console&&p&&console.info("viewport-units-buggyfill requires a proper CSSOM and basic viewport unit support, which are not available in IE8 and below"),{init:function(){}};var t,o,r;window.dispatchEvent(new v("viewport-units-buggyfill-init")),a.hacks&&a.hacks.initialize(a),n=!0,(i=document.createElement("style")).id="patched-viewport",document[a.appendToBody?"body":"head"].appendChild(i),t=function(){function e(){var e=this,t=arguments;clearTimeout(s),s=setTimeout(function(){i.apply(e,t)},n)}var i,n,s;i=b,n=a.refreshDebounceWait||100;window.addEventListener("orientationchange",e,!0),window.addEventListener("pageshow",e,!0),(a.force||d||function(){try{return window.self!==window.top}catch(e){return 1}}())&&(window.addEventListener("resize",e,!0),a._listeningToResize=!0),a.hacks&&a.hacks.initializeEvents(a,b,e),b()},o=0,r=function(){--o||t()},u.call(document.styleSheets,function(e){if(e.href&&w(e.href)!==w(location.href)&&"ignore"!==e.ownerNode.getAttribute("data-viewport-units-buggyfill")){o++;var t=e.ownerNode,i=r,e=t.href,n=i,s=new XMLHttpRequest;if("withCredentials"in s)s.open("GET",e,!0);else{if("undefined"==typeof XDomainRequest)throw new Error("cross-domain XHR not supported");(s=new XDomainRequest).open("GET",e)}s.onload=function(){var e=document.createElement("style");e.media=t.media,e.setAttribute("data-href",t.href),e.textContent=this.responseText,t.parentNode.replaceChild(e,t),i()},s.onerror=n,s.send()}}),o||t()}},refresh:b}})}(),!function(){!function(e,t){"use strict";"function"==typeof define&&define.amd?define("viewport-units-buggyfill.hacks",[],t):"object"==typeof exports?module.exports=t():e.viewportUnitsBuggyfillHacks=t()}(this,function(){"use strict";var r=/calc\(/g,a=/["']/g,e=window.navigator.userAgent,n=(n=/MSIE [0-9]\./i.test(e))||!!navigator.userAgent.match(/MSIE 10\.|Trident.*rv[ :]*1[01]\.| Edge\/1\d\./);return{required:function(e){return e.isMobileSafari||n},initialize:function(){},initializeEvents:function(e,t,i){e.force||n&&!e._listeningToResize&&(window.addEventListener("resize",i,!0),e._listeningToResize=!0)},findDeclarations:function(e,t,i,n){var s,o;null!==i&&(s=e,o=t,e=n,"content"===i)&&-1<e.indexOf("viewport-units-buggyfill")&&e.replace(a,"").split(";").forEach(function(e){var t,e=e.split(":");2===e.length&&"viewport-units-buggyfill"!==(t=e[0].trim())&&(e=e[1].trim(),s.push([o,t,e]),r.test(e))&&(e=e.replace(r,"-webkit-calc("),s.push([o,t,e]))})},overwriteDeclaration:function(e,t,i){return i=n&&"filter"===t?i.replace(/px/g,""):i}}})}(),define("CatLab/Webremote/Controllers/Webremote",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Tracker","CatLab/Webremote/Tools/Cookies","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Smileys","CatLab/Webremote/Tools/Preloader","CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Views/Popups/AuthenticationPopup","CatLab/Webremote/Views/Popups/SelectSmileyPopup","CatLab/Webremote/Views/Blocks/CurrentUser","CatLab/Webremote/Views/Blocks/CurrentSmiley","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/HashParser","CatLab/Webremote/Views/Alert","CatLab/Webremote/Views/Welcome","CatLab/Webremote/Views/ConnectionTrouble","CatLab/Webremote/Views/GamePaused","CatLab/Webremote/Synchronization/ClientRemoteView","CatLab/Webremote/Synchronization/DataSynchronizer","CatLab/Webremote/Synchronization/EventHandler","CatLab/Webremote/Synchronization/CombinedEventHandler","CatLab/Webremote/Providers/SocketIO","CatLab/Webremote/SonicSync/Client","CatLab/Webremote/Components/Components","viewport-units-buggyfill","viewport-units-buggyfill.hacks","screenfull"],function(Config,Tracker,Cookies,Tools,Deferred,Smileys,Preloader,OAuth2,AuthenticationPopup,SelectSmileyPopup,CurrentUser,CurrentSmiley,UsersCollection,Storage,i18n,HashParser,AlertPopup,WelcomePopup,ConnectionTroubleView,GamePausedView,ClientRemoteView,DataSynchronizer,EventHandler,CombinedEventHandler,SocketIOProvider,SonicSyncClient,Components,ViewportUnitsBuggyFill,ViewportUnitsBuggyFillHacks,screenfull){"use strict";var domelement=null,user,dynamicStylesheet,triggers=[];function addEvent(e,t,i){e.addEventListener?e.addEventListener(t,i,!1):e.attachEvent?e.attachEvent("on"+t,i):e["on"+t]=i}var Webremote=function(){};function getParameterByName(e,t){t=t||window.location.href,e=e.replace(/[\[\]]/g,"\\$&");e=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(t);return e?e[2]?decodeURIComponent(e[2].replace(/\+/g," ")):"":null}return Webremote.prototype={provider:null,element:null,gamedata:null,stylesheets:[],links:[],scripts:[],views:{},userData:null,userEvents:null,groupData:null,groupEvents:null,smiley:null,isOauth2Set:!1,color:null,_currentSmileyViews:[],_currentViewId:null,_currentViewViewId:null,_currentViewGroupId:null,_currentView:null,_connectingDfd:null,_connectedToken:null,_headless:!1,_allowAuthentication:!0,initialize:function(e,t){void 0!==t.token?this.token=t.token:this.token=getParameterByName("token"),void 0===t&&(t={}),this.setContainer(e),this.showLoading(),this.sonicSync=null,this.components=new Components(this),this.components.initialize(),this._initialize(t).then(function(){setTimeout(function(){void 0===this.provider.showTokenForm||this.provider.showTokenForm?(this.showTokenForm(),this.trigger("remote:initialized")):this.provider.noTokenConnect()}.bind(this),2),ViewportUnitsBuggyFill.init({hacks:ViewportUnitsBuggyFillHacks})}.bind(this)),this.setPlayerColor("#000000"),this.setOrientation(),addEvent(window,"resize",this.setOrientation.bind(this))},headless:function(e){return(e=void 0===e?{}:e).headless=!0,this._initialize(e)},_initialize:function(t){var i=new Deferred;return Config.set(t),Config.initialize(function(){Tracker.track("App","Initialize"),void 0===t.provider&&(t.provider=new SocketIOProvider),void 0!==t.headless&&(this._headless=!!t.headless),this.provider=t.provider,this.smileys=new Smileys(this.provider),this.provider.initPlayer(this),this.provider.on("disconnect",function(e){var t=this.getConnectionIssuesView();console.log("Connection lost... reconnecting"),t.show(),t.text(i18n.t("Connection lost... reconnecting"))}.bind(this)),this.provider.on("reconnect",function(e){this.provider.emit("user:reconnect",{id:this.gamedata.id,accessToken:this.gamedata.accessToken}),this.getConnectionIssuesView().hide()}.bind(this)),this.provider.on("user:error",function(e){var t;this._connectingDfd&&(t=this._connectingDfd,this._connectingDfd=null,t.reject(e.message))}.bind(this)),this.provider.on("user:initialize",function(e){this.gamedata=e,this.provider.setUserId(e.id),this._storeGameData(e),this._connectingDfd&&(e=this._connectingDfd,this._connectingDfd=null,e.resolve())}.bind(this)),this.provider.on("view:load",function(e){this.loadViewsXML(e.xml)}.bind(this)),this.provider.on("view:reset",function(e){this.resetViews()}.bind(this)),this.provider.on("config:set",function(e){if(Config.set(e),this.sonicSync&&this.sonicSync.stop(),Config.useAudioSync())try{this.sonicSync=new SonicSyncClient(this),this.sonicSync.startListener()}catch(e){console.error(e)}}.bind(this)),this.provider.on("view:set",function(e){this.showView(e.id,e.viewId,e.group),this.handleCombinedMessages(e)}.bind(this)),this.provider.on("button:label",function(e){this.setLabel(e)}.bind(this)),this.provider.on("button:decorate",function(e){this.setClass(e)}.bind(this)),this.provider.on("oauth:set",function(e){Config.supportsAuthentication()&&(OAuth2.initialize(e),this.isOauth2Set=!0,UsersCollection.initialize(this,OAuth2),HashParser.getParameter("access_token"))&&(e=HashParser.getParameter("access_token"),UsersCollection.addFromAccessToken(e,function(e){e&&this.setUser(e)}.bind(this)),HashParser.clear())}.bind(this)),this.provider.on("color:set",function(e){this.setPlayerColor(e.color)}.bind(this)),this.provider.on("user:smiley",function(e){this.setSmiley(e.smiley)}.bind(this)),this.provider.on("smileys:taken",function(e){this.smileys.setTakenSmileys(e.smileys)}.bind(this)),this.provider.on("game:disconnect",function(e){AlertPopup(i18n.t("You have been disconnected from the game."),function(){window.location.reload()})}.bind(this)),this.provider.on("dom:append",function(e){this.domAppend(e)}.bind(this)),this.provider.on("dom:replace",function(e){this.domReplace(e)}.bind(this)),this.provider.on("dom:attribute",function(e){this.domAttribute(e)}.bind(this)),this.provider.on("dom:alert",function(e){AlertPopup(e.message)}),this.provider.on("dom:open",function(e){void 0!==e.url&&window.open(e.url)}),this.provider.on("value:change",function(e){this.changeValue(e)}.bind(this)),this.provider.on("device:vibrate",function(e){this.vibrate(e)}.bind(this)),this.provider.on("game:pause",function(e){this.pause(e)}.bind(this)),this.provider.on("game:unpause",function(e){this.unpause(e)}.bind(this)),this.preloader=new Preloader(this.provider),this.userData=new DataSynchronizer("user",this.emit.bind(this),"client"),this.groupData=new DataSynchronizer("group",this.emit.bind(this),"client"),this.userEvents=new EventHandler("user",this.emit.bind(this)),this.groupEvents=new EventHandler("group",this.emit.bind(this));var e=[this.userData,this.groupData],n=[this.userEvents,this.groupEvents];DataSynchronizer.eventsToListenFor.forEach(function(i){this.provider.on(i,function(t){e.forEach(function(e){e.checkNamespace(t)&&e.processMessage(i,t)})}.bind(this))}.bind(this)),EventHandler.eventsToListenFor.forEach(function(i){this.provider.on(i,function(t){n.forEach(function(e){e.checkNamespace(t)&&e.processMessage(i,t)})}.bind(this))}.bind(this)),this.events=new CombinedEventHandler,this.events.addHandler(this.userEvents),this.events.addHandler(this.groupEvents),i.resolve()}.bind(this)),i.promise()},reconnect:function(e){this.gamedata?(this.provider.emit("user:reconnect",{id:this.gamedata.id,accessToken:this.gamedata.accessToken}),this.provider.once("user:reconnect",function(){e()})):e()},connectProvider:function(e){return this.provider.tokenConnect(e)},_storeGameData:function(){var e=new Deferred,t=this._connectedToken;return Storage.set("gamestate_"+t,this.gamedata,function(){e.resolve()},864e5),e.promise()},_restoreGameData:function(){var t=new Deferred,e=this._connectedToken;return Storage.get("gamestate_"+e,function(e){e?(this.gamedata=e,t.resolve(!0)):t.resolve(!1)}.bind(this)),t.promise()},handleCombinedMessages:function(e){for(var t=[{name:"button:label",method:this.setLabel.bind(this)},{name:"button:decorate",method:this.setClass.bind(this)}],i=0;i<t.length;i++){var n=t[i].name,s=t[i].method;if(void 0!==e[n])for(var o=0;o<e[n].length;o++)s(e[n][o])}},emit:function(e,t){this.provider.toMaster(e,t)},getConnectionIssuesView:function(){return void 0===this.connectionTrouble&&(this.connectionTrouble=new ConnectionTroubleView),this.connectionTrouble},setGamePausedView:function(e){this.gamePaused=e},getGamePausedView:function(){return void 0===this.gamePaused?new GamePausedView:this.gamePaused},setContainer:function(e){domelement=e,this.element=e,dynamicStylesheet=document.createElement("style"),document.body.appendChild(dynamicStylesheet),document.body.className="catlab-remote"},on:function(e,t){void 0===triggers[e]&&(triggers[e]=[]),triggers[e].push(t)},trigger:function(e){var t=[].slice.apply(arguments);if(t.shift(),void 0!==triggers[e])for(var i=0;i<triggers[e].length;i++)triggers[e][i].apply(this,t)},loadViews:function(e,t){var i;t=t||function(){},this._headless?t():((i=new XMLHttpRequest).open("GET",Config.getProxy()+e,!0),i.onreadystatechange=function(){4==i.readyState&&200==i.status&&(this.loadViewsXML(i.responseText),t())}.bind(this),i.send())},resetViews:function(){this.views={},this.components.resetViewDefinedComponents();for(var e=0;e<this.stylesheets.length;e++)try{var t=this.stylesheets[e];t.parentNode&&t.parentNode.removeChild(t)}catch(e){console.error(e)}for(e=0;e<this.links.length;e++)try{var i=this.links[e];i.parentNode&&i.parentNode.removeChild(i)}catch(e){console.error(e)}this.stylesheets=[]},loadViewsXML:function(e,t){if(t=t||function(){},!this._headless){var i;if(Tracker.track("App","Load Views"),window.DOMParser?i=(new DOMParser).parseFromString(e,"text/xml"):((i=new ActiveXObject("Microsoft.XMLDOM")).async=!1,i.loadXML(e)),0===i.getElementsByTagName("views").length)return!1;for(var n=i.getElementsByTagName("views").item(0).getElementsByTagName("component"),s=0;s<n.length;s++)this.loadComponent(n.item(s));for(var o=i.getElementsByTagName("views").item(0).getElementsByTagName("view"),s=0;s<o.length;s++)this.loadView(o.item(s));var r=i.getElementsByTagName("views").item(0).getElementsByTagName("stylesheet");for(s=0;s<r.length;s++){var a=r.item(s),h=document.createElement("style");this.stylesheets.push(h),h.innerHTML=a.textContent,document.body.appendChild(h)}var l=i.getElementsByTagName("views").item(0).getElementsByTagName("link");for(s=0;s<l.length;s++){var c=l.item(s).getAttribute("href"),u=document.createElement("link");u.rel="stylesheet",u.type="text/css",u.media="all",u.href=c,this.links.push(u),document.getElementsByTagName("head")[0].appendChild(u)}for(r=i.getElementsByTagName("views").item(0).getElementsByTagName("style"),s=0;s<r.length;s++)this.stylesheets.push(r.item(s)),document.body.appendChild(r.item(s));var d=i.getElementsByTagName("views").item(0).getElementsByTagName("script");for(s=0;s<d.length;s++)this.scripts.push(d.item(s)),this.evalScript(d.item(s));return ViewportUnitsBuggyFill.refresh(),t(),!0}t()},evalScript:function(xml){var aWebremote=Webremote;!function(){try{var Webremote=aWebremote;eval(xml.textContent)}catch(e){console.error(e)}}.bind(window)()},loadView:function(e){var t=e.getAttribute("id"),i=document.createElement("div"),n=!1;e.getAttribute("iframe")&&"false"!==e.getAttribute("iframe").toLowerCase()&&(n=!0);for(var s=0;s<e.childNodes.length;s++)i.appendChild(e.childNodes[s].cloneNode(!0));i.id=t,i.className="view "+e.className,this.views[t]={iframe:n,html:(new XMLSerializer).serializeToString(i)},this._currentViewId===t&&this.showView(this._currentViewId,this._currentViewViewId,this._currentViewGroupId)},loadComponent:function(e){for(var t=e.getAttribute("id"),i=document.createElement("div"),n=0;n<e.childNodes.length;n++)i.appendChild(e.childNodes[n].cloneNode(!0));this.components.addViewDefinedComponent(t,i)},showView:function(e,t,i){var n,s;this._headless||(this._currentView&&this._currentView.destroy(),"remote:authenticate"!==e?(this._currentViewId=e,this._currentViewViewId=t,this._currentViewGroupId=i,void 0!==this.views[e]?(n=(i?this.groupData:this.userData).getFromIdentifier("view:"+t),s=this.views[e],this._currentView=new ClientRemoteView(this,t,e,i,n,s.iframe),this._currentView.html=s.html,this._currentView.render(this.element),this.updateUser(),Tracker.track("App","Show View",e),this.trigger("remote:view:show",{id:e,view:this._currentView}),this.trigger("view:set",this._currentView)):this.element.innerHTML='<div class="loading"><p>Please wait, loading...</p><p>(Loading view: '+e+")</div></p>"):this.showAuthenticationView())},updateUser:function(){Tracker.track("App","Set user");var e=document.getElementById("authentication");e&&new CurrentUser(this).render(e),this._currentSmileyViews=[],Config.useSmileys()?(this.setSmileySelectViews(),this.setSmileyViews()):this.removeSmileyViews()},setSmileySelectViews:function(){for(var e=document.getElementsByTagName("smiley-select"),t=0;t<e.length;t++){var i=!e[t].hasAttribute("flingable")||"false"!==e[t].getAttribute("flingable"),i=new CurrentSmiley(this,!0,i);i.render(e[t]),this.smiley&&i.setSmiley(this.smiley),this._currentSmileyViews.push(i)}},setSmileyViews:function(){for(var e=document.getElementsByTagName("smiley"),t=0;t<e.length;t++){var i=e[t].hasAttribute("changeable")&&"false"!==e[t].getAttribute("changeable"),n=e[t].hasAttribute("flingable")&&"false"!==e[t].getAttribute("flingable"),i=new CurrentSmiley(this,i,n);i.render(e[t]),this.smiley&&i.setSmiley(this.smiley),this._currentSmileyViews.push(i)}},removeSmileyViews:function(){for(var e=document.getElementsByTagName("smiley-select"),t=0;t<e.length;t++)e[t].parentNode.removeChild(e[t]);for(e=document.getElementsByTagName("smiley"),t=0;t<e.length;t++)e[t].parentNode.removeChild(e[t]);for(var i=document.getElementsByClassName("if-config-smileys"),t=0;t<i.length;t++)i[t].parentNode.removeChild(i[t])},popup:function(e){new WelcomePopup(e).render(domelement)},showAuthenticationPopup:function(e){e=e||!1;var t=new AuthenticationPopup(this);t.render(domelement),e&&t.connect()},showSmileyPopup:function(e,t){void 0===e&&(e=function(e){this.selectSmiley(e)}.bind(this)),new SelectSmileyPopup(this,e,t=void 0===t?!0:t).render(domelement)},showAuthenticationView:function(){this.element&&(this.element.innerHTML='<p id="catlab-message">Please login.</p>',OAuth2.link({fullscreen:!0}).then(function(e){e?(this.setUser(e),this.element.innerHTML='<p id="catlab-message">Welcome! You may now close this screen.</p>',window.close()):this.showAuthenticationView()}.bind(this)))},buttonDown:function(e,t){this.provider.toMaster("button:down",{id:e})},buttonUp:function(e,t,i){this.provider.toMaster("button:up",{id:e,click:i=void 0!==i&&i}),this.trigger("user:interaction")},syncValue:function(e,t,i){return this.provider.toMaster("value:change",{id:e,value:t,viewId:i}),!1},showLoading:function(){this.element&&(this.element.innerHTML='<p id="catlab-loading">Connecting...</p>')},showTokenForm:function(){function t(e){var t=i.connect(e);e!==Cookies.getItem("last_token")&&Cookies.removeItem("last_token"),t.then(function(){Cookies.setItem("last_token",e,.25)}.bind(this)),t.fail(function(e){i.showTokenForm(),screenfull.enabled&&screenfull.isFullscreen&&screenfull.exit(),AlertPopup(e)}),i.showLoading(),i.trigger("remote:token:submit"),i.trigger("user:interaction")}var e=document.createElement("form"),i=this,n="undefined"!=typeof CONFIG_TOKEN?CONFIG_TOKEN:null,s=(n||(n=this.token,this.token=null),!1),o=(n&&(s=!0),Cookies.getItem("last_token")),o=(!n&&o&&(n=o),document.createElement("div")),r=(o.id="catlab-token-form",e.innerHTML="",e.appendChild(o),document.createElement("input")),r=(r.type="tel",r.pattern="[0-9 ]{6,10}",r.name="token",r.id="token",r.value=n||"",r.placeholder=i18n.t("Enter code"),r.addEventListener("click",function(){this.setSelectionRange(0,this.value.length)}),o.appendChild(r),document.createElement("button"));r.innerHTML=i18n.t("Connect"),o.appendChild(r);s&&t(n),e.onsubmit=function(e){e.preventDefault();e=document.getElementById("token").value;return t(e),!1},this.element.innerHTML="",this.element.appendChild(e)},requestFullScreen:function(){screenfull.enabled&&!screenfull.isFullscreen&&screenfull.request()},connect:function(e){return e=e.replace(" ",""),null!==this._connectingDfd&&(this._connectingDfd.reject(),this._connectingDfd=null),this._connectingDfd=new Deferred,this._connectedToken=e,this._connectingDfd.fail(function(){this.provider.disconnect(!1)}.bind(this)),this.connectProvider(e).fail(function(){setTimeout(function(){this._connectingDfd.reject(i18n.t("Game not found. Please check your token."))}.bind(this),1)}.bind(this)).then(function(t){var i=!0;"0"===getParameterByName("reconnect")&&(i=!1),this._restoreGameData().then(function(e){e&&i?this.reconnect(function(){this._connectingDfd.resolve()}.bind(this)):this.provider.emit("user:join",{token:t})}.bind(this))}.bind(this)),this._connectingDfd.promise()},setLabel:function(e){this._currentView&&this._currentView.setLabel(e.id,Tools.nl2br(Tools.sanitize(e.label)))},setClass:function(e){this._currentView&&this._currentView.setClass(e.id,e.styles)},setPlayerColor:function(e){if(this.color=e,void 0!==dynamicStylesheet&&dynamicStylesheet){var t,i,n="",s=(dynamicStylesheet.innerHTML=(n+=".player-color-border { border-color:"+e+"; }")+(".player-color-background { background-color: "+e+"; }")+(".player-color { color: "+e+"; }"),{"theme-color":e,"msapplication-navbutton-color":e,"apple-mobile-web-app-status-bar-style":e});for(t in s)s.hasOwnProperty(t)&&((i=document.createElement("meta")).httpEquiv=t,i.content=s[t],document.getElementsByTagName("head")[0].appendChild(i))}},setSmiley:function(t){this.smiley=t,this._currentSmileyViews.forEach(function(e){e.setSmiley(t)})},getSmiley:function(){return this.smiley},selectSmiley:function(e){this.provider.toMaster("user:smiley",{smiley:e})},setUser:function(e){user=e,this.updateUser(),user?(this.provider.toMaster("user:login",{access_token:user.getAccessToken()}),Storage.set("currentuser",user.getAccessToken()),this.getSmiley()&&(e=user.getAvatarSmiley())&&this.selectSmiley(e)):(this.provider.toMaster("user:logout"),Storage.set("currentuser",null))},getUser:function(){return user},listViews:function(){var e,t=[];for(e in this.views)this.views.hasOwnProperty(e)&&t.push({name:e});return t},getRandomText:function(e,t){var i="abcdefghijklmnopqrstuvwyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";void 0===t&&(t=40);for(var n="",s=(e=void 0===e?10:e)+Math.random()*t,o=0;o<s;o++)n+=i.charAt(Math.floor(Math.random()*i.length)),.8<Math.random()&&(o++,n+=" ");return n},randomLabels:function(e,t){for(var i=domelement.querySelectorAll("[data-button-label]"),n=0;n<i.length;n++)i[n].innerHTML=this.getRandomText(e,t);this.update()},setOrientation:function(){if(window.innerHeight>=window.innerWidth)try{document.body.classList.remove("landscape"),document.body.classList.add("portrait")}catch(e){document.body.className="portrait"}else try{document.body.classList.add("landscape"),document.body.classList.remove("portrait")}catch(e){document.body.className="landscape"}this.components.resize()},domAppend:function(e){this._currentView&&(this._currentView.domAppend(e.id,e.html),this.components.update())},domReplace:function(e){this._currentView&&(this._currentView.domReplace(e.id,e.html),this.components.update())},domAttribute:function(e){this._currentView&&(this._currentView.domAttribute(e.id,e.name,e.value),this.components.update())},changeValue:function(e){this._currentView&&this._currentView.changeValue(e)},vibrate:function(e){this._currentView&&this._currentView.vibrate(e)},pause:function(e){void 0===this._gamePausedView&&(this._gamePausedView=this.getGamePausedView()),this._gamePausedView.show()},unpause:function(e){void 0!==this._gamePausedView&&this._gamePausedView.hide()},log:function(e){Config.debug()&&console.log(e)},canAuthenticate:function(){return this.isOauth2Set},getGroupIds:function(){return void 0===this.gamedata.groups?[]:this.gamedata.groups},resolveDataAttribute:function(e){if("token"===e)return this._connectedToken;var i,e=(e="data."===e.substring(0,5)?e.substring(5):e).split("."),t=(2!==e.length&&e.unshift("any"),e.shift()),e=e.shift();if(t===user)return this.userData.getFromIdentifier("user").get(e);if("group"===t.substring(0,5)){var n,s=this.getGroupIds();if(0===s.length)return null;if("group"===t)return this.groupData.getFromIdentifier("group:"+s[0]).get(e);if("]"===t.substring(t.length,1))return void 0===s[n=t.substr(t.substring(6,t.length-1))]?null:this.groupData.getFromIdentifier("group:"+s[n]).get(e)}return"any"===t&&(i=["user."+e],this.getGroupIds().forEach(function(e,t){i.push("group["+t+"]")}.bind(this))),null}},Webremote}),define("CatLab/Webremote/Tools/Colorwheel",[],function(){var e={index:0,colors:[{color:"#d84a38",name:"red"},{color:"#4d90fe",name:"blue"},{color:"#35aa47",name:"green"},{color:"#ffb848",name:"yellow"},{color:"#852b99",name:"purple"},{color:"#555555",name:"brown"},{color:"#F87217",name:"orange"},{color:"#FBBBB9",name:"pink"}],initialize:function(){this.index=Math.floor(Math.random()*this.colors.length)},next:function(){var e=this.colors[this.index%this.colors.length];return this.index++,e}};return e.initialize(),e}),define("CatLab/Webremote/Collections/Users",["CatLab/Webremote/Tools/Colorwheel"],function(i){"use strict";return function(){this.users=[],this.userMap={},this.add=function(e){var t;e.isColorSet()||(t=i.next(),e.setColor(t.color,t.name)),e.hasPlayerId()||e.setPlayerId(this.count()+1),this.users.push(e),this.userMap[e.getId()]=e},this.clear=function(){this.users=[],this.userMap={}},this.remove=function(e){this.users.splice(users.indexOf(e),1),void 0!==this.users[e.getId()]&&delete this.users[e.getId()]},this.getFromId=function(e){return void 0!==this.userMap[e]?this.userMap[e]:null},this.getAll=function(){return this.users},this.count=function(){return this.users.length},this.each=function(e){for(var t=0;t<this.users.length;t++)e(this.users[t])},this.not=function(i){var n=[];return this.each(function(e){for(var t=0;t<i.length;t++)if(i[t].getId()===e.getId())return void n.push(i[t])}),n}}}),define("CatLab/Webremote/Collections/Groups",["CatLab/Webremote/Tools/Colorwheel"],function(i){"use strict";return function(){var t;this.groups=[],this.groupMap={},this.add=function(e){var t;e.colorSet||(t=i.next(),e.setColor(t.color,t.name)),this.groupMap[e.getId()]=e,this.groups.push(e)},this.clear=function(){this.groups=[],this.groupMap=[]},this.addUser=function(t){var i=!1;return t.groupIds.forEach(function(e){e=this.getFromId(e);e&&(i=!0,e.addUser(t),e.isShareColor())&&t.setColor(e.getColor(),e.getColorName())}.bind(this)),i},this.remove=function(e){this.groups.splice(this.groups.indexOf(e),1),delete this.groupMap[e.getId()]},this.getFromId=function(e){return void 0!==this.groupMap[e]?this.groupMap[e]:null},this.getAll=function(){return this.groups},this.each=function(e){for(t=0;t<this.groups.length;t++)e(this.groups[t])}}}),define("CatLab/Webremote/Models/Control",[],function(){return function(i,n,e){var s,o,r=0,a={},h=i,l=[];this.id=i,this.decoration="",this.label="",this.isGlobal=e,this.pushed=function(){return 0===r},this.scale=function(){return r},this.update=function(e,t){0<r&&0===e?((t=void 0===t?!0:t)&&this.trigger("click"),this.trigger("up")):0===r&&0<e&&this.trigger("down"),r=e},this.getLabel=function(e){return(e=void 0===e?!0:e)?'<span class="control-label '+o+'">'+h+"</span>":h},this.setStaticLabel=function(e,t){return h=e,o=t,this},this.setLabel=function(e,t){return this.label=e,n.emit("button:label",{id:i,label:e}),this},this.decorate=function(e){return this.decoration=e,n.emit("button:decorate",{id:i,styles:e}),this},this.click=function(e){return this.on("click",e),this},this.on=function(e,t){return this.log("Setting trigger "+e),void 0===a[e]&&(a[e]=[]),a[e].push(t),this},this.trigger=function(e){this.log("Triggering "+e);var t=[];if(void 0!==a[e])for(this.log("Found "+a[e].length+" events"),s=0;s<a[e].length;s++)t.push(a[e][s]);for(s=0;s<t.length;s++)t[s]();return this},this.hasTriggers=function(e){return void 0===e?0<Object.keys(a).length:void 0!==a[e]&&0<a[e].length},this.off=function(e,t){if(void 0===e)a={};else if(void 0===t)a[e]=[];else if(void 0!==a[e])for(s=0;s<a[e].length;s++)a[e][s]===t&&(a[e].splice(s,1),s--);return this},this.clear=function(){return this.clearEvents(),this.decoration=null,this.label=null,this},this.clearEvents=function(){return a={},this},this.addDomElement=function(e){var t=this,i=[];return i.push(e.addEventListener("click",function(){t.trigger("click")})),l.push({element:e,listeners:i}),this},this.clearDomElements=function(){for(var e=0;e<l.length;e++)for(var t=0;t<l[e].listeners.length;t++)l[e].element.removeEventListener("click",l[e].listeners[t]);return l=[],this},this.isLocalAuthentication=function(){return!1},this.refreshTarget=function(e){this.decoration&&e.emit("button:decorate",{id:i,styles:this.decoration}),this.label&&e.emit("button:label",{id:i,label:this.label})},this.log=function(e){n.log("["+this.id+"] "+e)}}}),define("CatLab/Webremote/Synchronization/MultipleTargetControl",[],function(){function e(e,t){this.id=e,this.remoteView=t,this.label=null,this.decoration=null}var t=e.prototype;return t.pushed=function(){var t=[];return this.remoteView.targets.forEach(function(e){t=t||e.control(this.id).pushed()}.bind(this)),t},t.scale=function(){var t,i=0;return this.remoteView.targets.forEach(function(e){(t=e.scale())>i&&(i=t)}.bind(this)),pushed},t.update=function(t){this.remoteView.targets.forEach(function(e){e.control(this.id).update(t)}.bind(this))},t.getLabel=function(){return this.label},t.setLabel=function(t){return this.label=t,this.remoteView.targets.forEach(function(e){e.control(this.id).setLabel(t)}.bind(this)),this},t.decorate=function(t){return this.decoration=t,this.remoteView.targets.forEach(function(e){e.control(this.id).decorate(t)}.bind(this)),this},t.click=function(e){return this.on("click",e),this},t.on=function(t,i){return this.remoteView.targets.forEach(function(e){e.control(this.id).on(t,i)}.bind(this)),this},t.off=function(e){var t=arguments;return this.remoteView.targets.forEach(function(e){e.control(this.id).off.apply(e.control(this.id),t)}.bind(this)),this},t.refreshTarget=function(t){return this.remoteView.targets.forEach(function(e){e.control(this.id).refreshTarget(t)}.bind(this)),this},e}),define("CatLab/Webremote/Synchronization/RemoteView",["CatLab/Webremote/Models/Control","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Synchronization/MultipleTargetControl","CatLab/Webremote/Synchronization/DataSynchronizer"],function(e,t,i,n){function s(e,t,i,n,s){this.initializeEventable(),this.id=t,this.viewId=e,this.targets=[],this.Webcontrol=n,this.groupId=void 0!==s?s:null,this.controls={},this.valueMap={},this.newUserStack=[],this.factory=null,this.listeners=[],i.map(function(e){this.addTarget(e)}.bind(this))}t=s.prototype=new t;return t.clearValues=function(){this.valueMap={}},t.addTarget=function(e){this.targets.push(e),this.refreshTarget(e)},t.refreshTarget=function(t){var e,i={id:this.id,viewId:this.viewId};for(this.tmpid in this.groupId&&(i.group=this.groupId),t.emit("view:set",i),this.newUserStack.map(function(e){t.emit(e.action,e.data)}.bind(this)),t.controls)t.controls.hasOwnProperty(this.tmpid)&&t.controls[this.tmpid].isGlobal&&t.controls[this.tmpid].refreshTarget(t);for(this.tmpid in this.controls)this.controls.hasOwnProperty(this.tmpid)&&(void 0!==this.controls[this.tmpid].refreshTarget?this.controls[this.tmpid].refreshTarget(t):console.error("Unexpected control:",this.controls[this.tmpid]));for(e in this.valueMap)this.valueMap.hasOwnProperty(e)&&t.emit("value:change",{id:e,value:this.valueMap[e]})},t.emit=function(t,i){this.targets.map(function(e){e.emit(t,i)})},t.clearControls=function(){for(var e=this.Webcontrol.getViewLabels(this.currentView),t=0;t<e.length;t++)this.control(e[t].id).setStaticLabel(e[t].label,"mobile")},t.control=function(e){return void 0===this.controls[e]&&(this.controls[e]=new i(e,this)),this.controls[e]},t.trigger=function(e,t){"value:change"==e&&this.changeValue(t.id,t.value)},t.changeValue=function(e,t){this.valueMap[e]=t,this.emit("value:change",{id:e,value:t}),this.eventableTrigger("value:change",e,t)},t.refreshControls=function(){for(this.tmpid in this.controls)this.controls.hasOwnProperty(this.tmpid)&&this.controls[this.tmpid].refreshControl()},t.getValues=function(){return this.valueMap},t.log=function(e){this.Webcontrol.log(e)},t.domAppend=function(e,t){this._stackAndEmit("dom:append",{id:e,html:t})},t.domReplace=function(e,t){this._stackAndEmit("dom:replace",{id:e,html:t})},t.domAttribute=function(e,t,i){this._stackAndEmit("dom:attribute",{id:e,name:t,value:i})},t.vibrate=function(e){Array.isArray(e)?this.emit("device:vibrate",{pattern:e}):console.error("Vibrate pattern must be an array.")},t.listenTo=function(e,t,i){this.listeners.push(e.on(t,i))},t.stopListening=function(){this.listeners.forEach(function(e){e.unbind()})},t._stackAndEmit=function(e,t){this.newUserStack.push({action:e,data:t}),this.emit(e,t)},t.destroy=function(){this.stopListening(),this.factory.destroy(this)},s}),define("CatLab/Webremote/Synchronization/RemoteViewFactory",["CatLab/Webremote/Synchronization/RemoteView"],function(s){function e(){this.viewCounter=0,this.views={}}var t=e.prototype;return t.create=function(e,t,i,n){return this.viewCounter++,this.views[this.viewCounter]=new s(this.viewCounter,e,t,i,n),(this.views[this.viewCounter].factory=this).views[this.viewCounter]},t.createDummy=function(e,t){return this.create(e,[],t)},t.getFromId=function(e){return this.views[e]},t.destroy=function(e){e=e.id;delete this.views[e]},new e}),define("CatLab/Webremote/Models/Users/ControlUser",["CatLab/Webremote/Models/User","CatLab/Webremote/Models/Control","CatLab/Webremote/Synchronization/RemoteViewFactory","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Synchronization/DataSynchronizer","CatLab/Webremote/Synchronization/EventHandler","CatLab/Webremote/Collections/Users"],function(t,i,n,e,s,o,r,a){function h(e,t){this.initializeEventable(),(t=void 0===t?{}:t).id=e,t.playerId=null,this.initialize(t)}e=h.prototype=new e;return e.hasPlayerId=function(){return 0<this.playerId},e.setPlayerId=function(e){return this.playerId=e,this},e.control=function(e,t){return void 0===t&&(t=!1),void 0===this.controls[e]&&(this.controls[e]=new i(e,this,t)),this.controls[e]},e.getAvailableControls=function(){return["a","b","x","y","up","down","right","left","start","back"]},e.hasControl=function(e){return!0},e.setWebcontrol=function(e){this.Webcontrol=e},e.initialize=function(e){this.id=e.id,e.playerId&&(this.playerId=e.playerId),this.groups=[],this.currentView=null,this.color="orange",this.colorName="orange",this.colorSet=!1,this.tmpid=null,this.active=!1,this.smiley=null,this.email=null,this.nickname=null,this.userdata=e,this.profiledata={},this.access_token=null,this.user=null,this.master=!1,this.authenticated=!1,void 0!==e&&void 0!==e.groups?this.groupIds=e.groups:this.groupIds=[],this.controls={},this.dataSynchronizer=new o("user",this.emit.bind(this),"master"),this.data=this.dataSynchronizer.getFromIdentifier("user"),this.events=new r("user",this.emit.bind(this)),this.settings={}},e.setSettings=function(e){return this.settings=e,this},e.trigger=function(t,i){0<=o.eventsToListenFor.indexOf(t)?(this.dataSynchronizer.checkNamespace(i)&&this.dataSynchronizer.processMessage(t,i),this.getGroups().forEach(function(e){e.dataSynchronizer.checkNamespace(i)&&e.dataSynchronizer.processMessage(t,i)}.bind(this))):0<=r.eventsToListenFor.indexOf(t)?(this.events.checkNamespace(i)&&this.events.processMessage(t,i),this.getGroups().forEach(function(e){e.events.checkNamespace(i)&&e.events.processMessage(t,i)}.bind(this))):"button:down"===t?this.control(i.id).update(1):"button:up"===t?this.control(i.id).update(0,i.click):"user:login"===t?this.login(i):"user:logout"===t?this.logout(i):"user:smiley"===t?this.setSmiley(i.smiley):"sync:audio"===t&&this.eventableTrigger("sync:audio",i)},e.setSmiley=function(t){this.smiley=t;var i=null;this.getGroups().forEach(function(e){i=!0,e.setSmiley(t,this)}.bind(this)),i||this.Webcontrol.smileys.reserve(t,this.getIdentifier())?this.emit("user:smiley",{smiley:t}):this.emit("dom:alert",{message:s.t("Smiley is already taken. Please select a different smiley.")})},e.setNickname=function(e){return this.nickname=e,this},e.getNickname=function(){return this.nickname||(this.getData().username?this.getData().username:this.playerId?"Player "+this.playerId:"Player "+this.id)},e.clearSmiley=function(){this.smiley=null,this.getGroups().forEach(function(e){e.clearSmiley(this)}.bind(this)),this.emit("user:smiley",{smiley:null})},e.getSmiley=function(){return this.smiley},e.getSmileyImage=function(){return this.Webcontrol.smileys.getImage(this.getSmiley())},e.getSmileyHtml=function(){return this.Webcontrol.smileys.getHtml(this.getSmiley())},e.getSmileyUrl=function(){return this.Webcontrol.smileys.getUrl(this.getSmiley())},e.login=function(e){},e.logout=function(e){},e.clearControls=function(){for(this.tmpid in null!==this.currentView&&this.currentView.clearControls(),this.controls)!this.controls.hasOwnProperty(this.tmpid)||this.controls[this.tmpid].isGlobal||this.controls[this.tmpid].clear()},e.clearEvents=function(){this.clearControls(),this.clearEventableEvents()},e.emit=function(e,t,i){return this.Webcontrol.provider.toPlayer(this,e,t,i),!0},e.getId=function(){return this.id},e.getName=function(){return"User "+this.getId()},e.getType=function(){return"mobile"},e.getEntityType=function(){return"user"},e.getIcon=function(){return"fa fa-mobile-phone"},e.loginFromAuthUser=function(e,t){e={access_token:e.getAccessToken()};this.login(e,t)},e.login=function(t,i){var n=this;this.Webcontrol.getOAuthClient(function(e){e&&(this.setAccessToken(t.access_token),e.profile(n.access_token,function(e){n.authenticated=!0,this.setProfiledata(e.user),void 0!==i&&i()}.bind(this)))}.bind(this))},e.setAccessToken=function(e){this.access_token=e},e.getAccessToken=function(){return this.access_token},e.setProfiledata=function(e){e=void 0!==(this.profiledata=e).accessToken?e.accessToken:null,e=new t(e);void 0!==this.profiledata.id&&e.setId(this.profiledata.id),void 0!==this.profiledata.username&&e.setName(this.profiledata.username),void 0!==this.profiledata.avatar&&e.setAvatar(this.profiledata.avatar),this.setUser(e),this.eventableTrigger("login",this)},e.isAuthenticated=function(){return this.authenticated},e.getData=function(){return this.profiledata},e.logout=function(e){this.profiledata=null,this.access_token=null,this.authenticated=!1},e.setColor=function(e,t){this.colorSet=!0,this.color=e,this.colorName=t,this.emit("color:set",{color:e,name:t})},e.isColorSet=function(){return this.colorSet},e.getColor=function(){return this.color},e.getColorName=function(){return this.colorName},e.isActive=function(){return this.active},e.toggleActive=function(){this.setActive(!this.active),this.setJoinLabel()},e.setJoinLabel=function(){!0===this.active?this.control("a").setLabel("LEAVE"):this.control("a").setLabel("JOIN")},e.setActive=function(e,t){this.active=e,this.eventableTrigger("active:change",e),this.active&&this.eventableTrigger("active:activate"),void 0!==t&&t&&this.setJoinLabel()},e.setView=function(e){return this.clearView(),this.currentView=n.create(e,[this],this.Webcontrol),this.currentView},e.clearView=function(e){var t;this.currentView&&(t=this.currentView,this.currentView=null,this.clearControls(),void 0!==e?setTimeout(function(){t.destroy()},e):t.destroy())},e.refreshView=function(){this.currentView&&this.currentView.refreshTarget(this)},e.getValues=function(){return this.currentView?this.currentView.getValues():null},e.clearValues=function(){this.currentView&&this.currentView.clearValues()},e.setUser=function(e){return this.usermodel=e,this},e.hasUser=function(){return void 0!==this.usermodel&&this.usermodel},e.getUser=function(){return this.usermodel},e.isLocalAuthentication=function(){return!0},e.log=function(e){this.Webcontrol&&this.Webcontrol.log("[u:"+this.getId()+"] "+e)},e.getGroups=function(){return this.groups},e.hasDisplay=function(){return!0},e.hasKeyboardInput=function(){return!0},e.hasTouchInput=function(){return!0},e.getIdentifier=function(){return{id:this.getId(),type:this.getEntityType()}},e.represents=function(e){if(void 0===e.id||void 0===e.type)throw"Attribute is not an identifier.";var t=this.getIdentifier();return t.type===e.type&&t.id===e.id},e.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"up",authenticate:"y",left:"left",right:"right"}},e.isMainGroup=function(){if(0===this.groups.length)return!0;for(var e=0;e<this.groups.length;e++)if(this.groups[e].isMainGroup())return!0;return!1},e.isMaster=function(){return this.master},e.setMaster=function(e){var t=this.master!==(e=!!(e=void 0===e?!0:e));return this.master=e,t&&this.eventableTrigger("master:change"),this},e.resetViews=function(e){this.emit("view:reset",{},e=void 0===e?function(){}:e)},e.replaceViews=function(e,t){this.resetViews(function(){this.loadViews(e,t)}.bind(this))},e.loadViews=function(e,t){void 0===t&&(t=function(){}),this.log("Loading views for group "+e),this.emit("view:load",{url:e},t)},e.getConnectToken=function(){return this.Webcontrol.getConnectToken()},e.getConnectTokenForDisplay=function(){return this.Webcontrol.getConnectTokenForDisplay()},e.serialize=function(){return{id:this.getId(),playerId:this.playerId,userdata:this.userdata,profiledata:this.profiledata,email:this.email,nickname:this.nickname,access_token:this.access_token,color:this.color,colorName:this.colorName,smiley:this.smiley,data:this.dataSynchronizer.serialize(),events:this.events.serialize()}},e.unserialize=function(e){void 0!==e.profiledata&&this.setProfiledata(e.profiledata),void 0!==e.playerId&&(this.playerId=e.playerId),void 0!==e.access_token&&this.setAccessToken(e.access_token),void 0!==e.color&&(this.color=e.color),void 0!==e.colorName&&(this.colorName=e.colorName),void 0!==e.nickname&&(this.nickname=e.nickname),void 0!==e.email&&(this.email=e.email),void 0!==e.smiley&&(this.smiley=e.smiley),void 0!==e.data&&this.dataSynchronizer.unserialize(e.data),void 0!==e.events&&this.events.unserialize(e.events)},h}),define("CatLab/Webremote/Models/GroupControl",[],function(){return function(e,i,t){var n,s,o,r,a,h,l=e,c={};this.label=null,this.decoration="",this.group=i,this.isGlobal=t,this.pushed=function(){for(o=i.getUsers(),n=0;n<o.length;n++)if(o[n].control(l,this.isGlobal).pushed())return!0;return!1},this.scale=function(){for(o=i.getUsers(),n=r=0;n<o.length;n++)(a=o[n].control(l,this.isGlobal)).value>r&&(r=a.value);return r},this.getLabel=function(e){return o=i.getUsers(),(n=0)<o.length?(a=o[n].control(l,this.isGlobal)).getLabel(e):null},this.setStaticLabel=function(e,t){for(o=i.getUsers(),n=0;n<o.length;n++)o[n].control(l).setStaticLabel(e,t);return null},this.setLabel=function(e,t){return this.label=e,i.emit("button:label",{id:l,label:e}),this},this.decorate=function(e){return this.decoration=e,i.emit("button:decorate",{id:l,styles:e}),this},this.click=function(e){return this.on("click",e),this},this.on=function(e,t){for(void 0===c[e]&&(c[e]=[]),c[e].push(t),this.log("Setting group trigger "+e),o=i.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).on(e,t);return this},this.hasTriggers=function(e){for(o=i.getUsers(),n=0;n<o.length;n++)if(o[n].control(l,this.isGlobal).hasTriggers(e))return!0;return!1},this.off=function(e){for(delete c[e],o=i.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).off(e);return this},this.clearEvents=function(){for(c={},o=i.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).clearEvents();return this},this.clear=function(){for(c={},this.decoration=null,this.label=null,o=i.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).clear();return this},this.isLocalAuthentication=function(){return!1},this.refreshControl=function(){for(o=i.getUsers(),n=0;n<o.length;n++){for(h in o[n].control(l,this.isGlobal).clearEvents(),c)if(c.hasOwnProperty(h))for(s=0;s<c[h].length;s++)o[n].control(l,this.isGlobal).on(h,c[h][s]);this.label&&o[n].control(l,this.isGlobal).setLabel(this.label)}return this},this.refreshTarget=function(e){this.decoration&&e.emit("button:decorate",{id:l,styles:this.decoration}),this.label&&e.emit("button:label",{id:l,label:this.label})},this.log=function(e){i.log("["+l+"] "+e)}}}),define("CatLab/Webremote/Models/ControlGroup",["CatLab/Webremote/Config","CatLab/Webremote/Models/User","CatLab/Webremote/Models/Control","CatLab/Webremote/Models/GroupControl","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Synchronization/RemoteViewFactory","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Synchronization/DataSynchronizer","CatLab/Webremote/Synchronization/EventHandler","CatLab/Webremote/Tools/Tools"],function(e,t,i,n,s,o,r,a,h,l){function c(e,t){this.initializeEventable(),this.id=e,this.initialize(t)}r=c.prototype=new r;return r.setWebcontrol=function(e){this.Webcontrol=e},r.initialize=function(e){this.token=e.token,this.connectURL=e.connectURL,this.currentView=null,this.color="orange",this.colorName="orange",this.colorSet=!1,this.shareColor=!1,this.tmpid=null,this.active=!1,this.smiley=null,this.email=null,this.userdata=e,this.profiledata={},this.access_token=null,this.master=!1,this.users=[],this.controls=[],this.dataSynchronizer=new a("group",this.emit.bind(this),"master"),this.data=this.dataSynchronizer.getFromIdentifier("group:"+this.getId()),this.events=new h("group",this.emit.bind(this)),this.options={}},r.setOptions=function(e){return this.options=e,this},r.getOption=function(e){return void 0!==this.options[e]?this.options[e]:null},r.hasControl=function(e){return!0},r.setAccessToken=function(e){this.access_token=e},r.setProfiledata=function(e){this.profiledata=e},r.clearControls=function(){for(this.tmpid in null!=this.currentView&&this.currentView.clearControls(),this.controls)!this.controls.hasOwnProperty(this.tmpid)||this.controls[this.tmpid].isGlobal||this.controls[this.tmpid].clear()},r.clearEvents=function(){this.clearControls(),this.clearEventableEvents()},r.isMainGroup=function(){return this.Webcontrol.getConnectToken()===this.getConnectToken()},r.emit=function(e,t,i){return this.Webcontrol.provider.toGroup(this,e,t,i),!0},r.getId=function(){return this.id},r.getName=function(){return"Group "+this.getId()},r.setNickname=function(e){return this.nickname=e,this},r.getNickname=function(){return this.nickname||(this.getData().username?this.getData().username:"Group "+this.getId())},r.getType=function(){return"mobile"},r.getEntityType=function(){return"group"},r.getIcon=function(){return"fa fa-mobile-phone"},r.getData=function(){return this.profiledata},r.setColor=function(e,t,i){void 0===i&&(i=this.shareColor),this.colorSet=!0,this.color=e,this.colorName=t,this.shareColor=i,this.emit("color:set",{color:e,name:t,shareColor:i})},r.getColor=function(){return this.color},r.setShareColor=function(e){this.shareColor=e},r.isShareColor=function(){return this.shareColor},r.getColorName=function(){return this.colorName},r.setView=function(e){return this.clearView(),this.currentView=o.create(e,[this],this.Webcontrol,this.getId()),this.currentView},r.clearView=function(t){var e;this.currentView&&(e=this.currentView,this.currentView=null,this.clearControls(),void 0!==t?setTimeout(function(){e.destroy()},t):e.destroy(),this.users.forEach(function(e){e.clearView(t)}))},r.resetViews=function(e){this.emit("view:reset",{},e=void 0===e?function(){}:e)},r.replaceViews=function(e,t){this.resetViews(function(){this.loadViews(e,t)}.bind(this))},r.loadViews=function(e,t){void 0===t&&(t=function(){}),this.log("Loading views for group "+e),this.emit("view:load",{url:e},t)},r.isAuthenticated=function(){return!1},r.isLocalAuthentication=function(){return!0},r.log=function(e){this.Webcontrol.log("[g:"+this.getId()+"] "+e)},r.getConnectToken=function(){return this.Webcontrol.provider.getConnectToken(this.token)},r.getConnectTokenForDisplay=function(){return l.getConnectTokenForDisplay(this.getConnectToken())},r.getConnectURL=function(){return this.Webcontrol.provider.getConnectURL(this.connectURL)},r.addUser=function(t){for(this.tmpid in l.findIndex(this.users,function(e){return e.id===t.id})<0&&this.users.push(t),l.findIndex(t.groups,function(e){return e.id===this.id})<0&&t.groups.push(this),this.currentView&&(this.currentView.refreshTarget(t),t.currentView=this.currentView),this.controls)this.controls.hasOwnProperty(this.tmpid)&&this.controls[this.tmpid].refreshControl();this.events.refreshTarget(t.emit.bind(t)),this.dataSynchronizer.refreshTarget(t.emit.bind(t)),this.smiley&&(t.emit("user:smiley",{smiley:this.smiley}),t.smiley=this.smiley),this.trigger("user:join",t)},r.removeUser=function(t){var e=l.findIndex(this.users,function(e){return e.id===t.id});0<=e&&this.users.splice(e,1)},r.getUsers=function(){return this.users},r.getIdentifier=function(){return{id:this.getId(),type:this.getEntityType()}},r.represents=function(e){if(void 0===e.id||void 0===e.type)throw"Attribute is not an identifier.";var t=this.getIdentifier();return t.type==e.type&&t.id==e.id},r.getValues=function(){return this.currentView?this.currentView.getValues():null},r.clearValues=function(){this.currentView&&this.currentView.clearValues()},r.control=function(e,t){return void 0===t&&(t=!1),void 0===this.controls[e]&&(this.controls[e]=new n(e,this,t)),this.controls[e]},r.isMaster=function(){return this.master},r.setMaster=function(e){return this.master=e=void 0===e?!0:e,this},r.hasDisplay=function(){return!0},r.hasKeyboardInput=function(){return!0},r.hasTouchInput=function(){return!0},r.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"up",authenticate:"y",left:"left",right:"right"}},r.setOAuthSettings=function(e){this.emit("oauth:set",e)},r.setSmiley=function(e,t){this.Webcontrol.smileys.reserve(e,this.getIdentifier())?(this.emit("user:smiley",{smiley:e}),this.smiley=e):t.emit("dom:alert",{message:s.t("Smiley is already taken. Please select a different smiley.")})},r.clearSmiley=function(e){this.Webcontrol.smileys.unreserve(this.getIdentifier()),this.emit("user:smiley",{smiley:null}),this.smiley=null},r.getSmiley=function(){return this.smiley},r.getSmileyImage=function(){return this.Webcontrol.smileys.getImage(this.getSmiley())},r.getSmileyHtml=function(){return this.Webcontrol.smileys.getHtml(this.getSmiley())},r.getSmileyUrl=function(){return this.Webcontrol.smileys.getUrl(this.getSmiley())},r.setMaxUsers=function(e){this.emit("config:set",{maxUsers:e})},r.isActive=function(){return this.active},r.toggleActive=function(){this.active=!this.active,this.setJoinLabel()},r.setJoinLabel=function(){!0===this.active?this.control("a").setLabel("LEAVE"):this.control("a").setLabel("JOIN")},r.setActive=function(e,t){this.active=e,this.eventableTrigger("active:change",e),this.active&&this.eventableTrigger("active:activate")},r.serialize=function(){return{id:this.getId(),token:this.token,userdata:this.userdata,nickname:this.nickname,profiledata:this.profiledata,email:this.email,access_token:this.access_token,shareColor:this.shareColor,color:this.color,colorName:this.colorName,smiley:this.smiley,data:this.dataSynchronizer.serialize(),events:this.events.serialize()}},r.unserialize=function(e){void 0!==e.profiledata&&this.setProfiledata(e.profiledata),void 0!==e.access_token&&this.setAccessToken(e.access_token),void 0!==e.token&&(this.token=e.token),void 0!==e.shareColor&&(this.shareColor=e.shareColor),void 0!==e.color&&(this.color=e.color),void 0!==e.colorName&&(this.colorName=e.colorName),void 0!==e.nickname&&(this.nickname=e.nickname),void 0!==e.email&&(this.email=e.email),void 0!==e.smiley&&(this.smiley=e.smiley,this.emit("user:smiley",{smiley:this.smiley})),void 0!==e.data&&this.dataSynchronizer.unserialize(e.data),void 0!==e.events&&this.events.unserialize(e.events)},c}),define("CatLab/Webremote/Models/State",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Preloader"],function(i,n){function e(e){this.Webcontrol=e}var t=e.prototype;return t.reconnect=function(e,t){void 0!==e.provider&&this.Webcontrol.provider.restoreProviderSettings(e.provider),this.Webcontrol.disconnect(),setTimeout(function(){this.Webcontrol.initialize(i.getAll()).then(function(){this.Webcontrol._reconnect(e.token,e.accessToken,function(){this._setCollectionDetails(e.groups,this.Webcontrol._grouplibrary),this._setCollectionDetails(e.users,this.Webcontrol._userlibrary),this.Webcontrol.preloader=n.unserialize(this.Webcontrol.provider,e.preloader),t()}.bind(this))}.bind(this))}.bind(this),1)},t._setCollectionDetails=function(e,t){var i,n;if(void 0!==e)for(i=0;i<e.length;i++)(n=t.getFromId(e[i].id))?n.unserialize(e[i]):(console.log("Trying to set data for non existing user/group."),console.log(e[i]))},t.getData=function(){var t=[],i=(this.Webcontrol._grouplibrary.each(function(e){t.push(e.serialize())}.bind(this)),[]),e=(this.Webcontrol._userlibrary.each(function(e){i.push(e.serialize())}),{users:i,groups:t,token:this.Webcontrol._gamedata.token,accessToken:this.Webcontrol._gamedata.accessToken,preloader:this.Webcontrol.preloader.serialize()});return e.provider=this.Webcontrol.provider.serializeProviderSettings(),e},t.serialize=function(){var e=this.getData();return JSON.stringify(e)},t.unserialize=function(e){e=JSON.parse(e);this.reconnect(e)},e}),define("CatLab/Webremote/Messages/MessageBus",[],function(){"use strict";function e(){this.controllerListeners=[],this.viewListeners=[]}var t=e.prototype;return t.toController=function(e,t){this.handleControllerMessage(e,t)},t.handleControllerMessage=function(e,t){for(var i=0;i<this.controllerListeners.length;i++)this.controllerListeners[i].handleIncomingMessage(e,t)},t.toView=function(e,t,i){this.handleViewMessage(e,t,i)},t.handleViewMessage=function(e,t,i){if(void 0===i)for(var n=0;n<this.viewListeners.length;n++)this.viewListeners[n].handleIncomingMessage(e,t);else this.viewListeners[i].handleIncomingMessage(e,t)},t.addControllerListener=function(e){if(void 0===e.handleIncomingMessage)throw new Error("Controller listener does not have a handleIncomingMessage");this.controllerListeners.push(e)},t.removeControllerListener=function(e){e=this.controllerListeners.indexOf(e);-1!==e&&this.controllerListeners.splice(e,1)},t.addViewListener=function(e){if(void 0===e.handleIncomingMessage)throw new Error("Controller listener does not have a handleIncomingMessage");e=this.viewListeners.push(e);this.toController("subscribe",{listener:e})},t.removeViewListener=function(e){e=this.viewListeners.indexOf(e);-1!==e&&this.viewListeners.splice(e,1)},t.destroy=function(){this.controllerListeners=[],this.viewListeners=[]},e}),define("CatLab/Webremote/Messages/NavigateableProxy",[],function(){function e(e,t){this.prefix=t||"",this.controls={navigation:["left","right"],toggle:["a"],manipulation:["down","up"],back:["b","back"]},this.views=[],this.keyInputCallbacks={},this.boundCallbacks={},e.addControllerListener(this),this.messageBus=e}var t=e.prototype;return t.handleIncomingMessage=function(e,t){if(e===this.prefix+"nav:controls")return this.controls=t.controls,this.views.forEach(function(e){this.refreshView(e)}.bind(this)),!0},t.addView=function(e){this.views.push(e),this.refreshView(e)},t.refreshView=function(t){this.reattachClick(t.control(this.controls.navigation[0]),this.previous),this.reattachClick(t.control(this.controls.navigation[1]),this.next),this.reattachClick(t.control(this.controls.manipulation[0]),this.down),this.reattachClick(t.control(this.controls.manipulation[1]),this.up),this.controls.toggle.forEach(function(e){void 0===this.keyInputCallbacks[e]&&(this.keyInputCallbacks[e]=function(){this.keyInput(e)}),this.reattachClick(t.control(e),this.keyInputCallbacks[e].bind(this))}.bind(this)),this.controls.back.forEach(function(e){this.reattachClick(t.control(e),this.back)}.bind(this))},t.reattachClick=function(e,t){this.boundCallbacks[t]||(this.boundCallbacks[t]=t.bind(this)),e.off("click",this.boundCallbacks[t]),e.click(this.boundCallbacks[t])},t.keyInput=function(e){this.messageBus.toView(this.prefix+"nav:keyInput",{button:e})},t.previous=function(){this.messageBus.toView(this.prefix+"nav:previous")},t.next=function(){this.messageBus.toView(this.prefix+"nav:next")},t.up=function(){this.keyInput("up")},t.down=function(){this.keyInput("down")},t.back=function(){this.messageBus.toView(this.prefix+"nav:back")},t.destroy=function(){this.messageBus.removeControllerListener(this)},e.handleMessage=function(e,t,i,n){if(e.substring(0,(n=void 0===n?"":n).length)===n){switch(e=e.replace(n,"")){case"nav:previous":return i.previous(),!0;case"nav:next":return i.next(),!0;case"nav:keyInput":return i.keyInput(t.button),!0;case"nav:back":return i.triggerBack(),!0}return!1}},e}),define("CatLab/Webremote/Controllers/Portal",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Messages/MessageBus","CatLab/Webremote/Messages/NavigateableProxy"],function(i,e,t,s,n,o){"use strict";function r(e,t){this.initializeEventable(),this.Webcontrol=e,this.options=t,this.controlDisabled=!1,this.users=[],this.ensureOption("allowChangeNickname",!0),this.ensureOption("customFunctions",{}),this.ensureOption("minPlayers",1),this.ensureOption("maxPlayers",4),this.ensureOption("activePlayersPanel",!1),this.ensureOption("customViews",!1),this.ensureOption("authentication",e.AUTH_NOT_REQUIRED),this.ensureOption("localAuthenticable",!1),this.ensureOption("start",function(){alert("This is where the game would start, if one would have set a 'start' option.")}),this.Webcontrol.getMessageBus().addControllerListener(this),this.messageBus=e.getMessageBus(),this.navigatableProxy=new o(this.messageBus,"portal:"),this.useCatLabViews()&&e.loadViews(i.getSocketURL(!0)+"/webremote/views/default.xml"),this.eventListeners=[],this.initialize()}e=r.prototype=new e;return e.handleIncomingMessage=function(e,t){switch(e){case"subscribe":this.updateUsers();break;case"start":this.startGame();break;case"back":this.back()}},e.initialize=function(){var e=this.Webcontrol.on("user:join",function(e){this.userConnect(e),this.eventListeners.push(e.on("login",function(){this.updateUsers()}.bind(this)))}.bind(this));this.eventListeners.push(e),this.Webcontrol.getUsers().forEach(function(e){this.userConnect(e)}.bind(this))},e.updateUsers=function(){this.updateState();let n=[];this.Webcontrol.getUsers().forEach(function(e){var t=e.getUser(),i=null;t&&(i={image:t.avatar}),n.push({active:e.isActive(),color:e.getColor(),profile:i,type:e.getType()})}),this.messageBus.toView("users:update",{users:n})},e.updateState=function(){var e={activePlayers:this.countActiveUsers(),minPlayers:this.options.minPlayers,maxPlayers:this.options.maxPlayers,connectInstructions:this.getConnectInstructions(),startAndLoginInstructions:this.getStartAndLoginInstructions(),showInactivePlayers:this.supportInactivePlayers()};this.messageBus.toView("state:change",{state:e})},e.ensureOption=function(e,t){void 0===this.options[e]&&(this.options[e]=t)},e.useCatLabViews=function(){return!1===this.options.customViews},e.getToggleView=function(e){var t="",t=this.supportInactivePlayers()?"catlab-portal-toggle":"catlab-portal";return this.isMaster(e)||(t+="-nostart"),t},e.addUser=function(e){e.clearEvents(),this.users.push(e),this.supportInactivePlayers()||this.forceToggleableUser(e)||this.activateUser(e),this.trigger("users:update"),this.updateUsers()},e.activateUser=function(e){e.isActive()||(this.trigger("user:activate",e),e.setActive(!0,this.supportInactivePlayers()),this.updateUsers())},e.deactivateUser=function(e){e.isActive()&&(this.trigger("user:deactivate",e),e.setActive(!1,this.supportInactivePlayers()),this.updateUsers())},e.toggleActive=function(e){(this.supportInactivePlayers()||this.forceToggleableUser(e))&&(e.isActive()?this.deactivateUser(e):this.activateUser(e),this.trigger("users:update"))},e.forceToggleableUser=function(e){return!e.hasDisplay()},e.hasUsersWithoutDisplay=function(){for(var e=0;e<this.users.length;e++)if(!this.users[e].hasDisplay())return!0;return!1},e.countActiveUsers=function(){return this.getActiveUsers().length},e.getActiveUsers=function(){for(var e=[],t=0;t<this.users.length;t++)this.users[t].isActive()&&e.push(this.users[t]);return e},e.userConnect=function(e){this.eventListeners.push(e.on("master:change",function(){this.updateUserView(e)},this)),this.addUser(e),this.updateUserView(e),this.trigger("user:connect",e)},e.updateUserView=function(e){var t=e.setView(this.getToggleView(e));this.controlDisabled||this.enableControls(e,t),this.enableDefaultPlayerControls(e,t)},e.disableControls=function(){this.controlDisabled=!0;for(var e=0;e<this.users.length;e++)this.users[e].clearEvents()},e.enableControls=function(e,t){var i;void 0!==e?(i=e.getPortalControls(),t.control(i.toggleActive).click(function(){this.toggleActive(e)}.bind(this)),t.control(i.start).click(function(){this.startGame()}.bind(this)),t.control(i.back).click(function(){this.back()}.bind(this)),this.supportsLocalAuthentication()&&t.control(i.authenticate).click(function(){e.isLocalAuthentication()||this.authenticate(e)}.bind(this)),this.navigatableProxy.addView(t)):(this.controlDisabled=!1,this.users.forEach(function(e){this.updateUserView(e)}.bind(this)))},e.enableDefaultPlayerControls=function(i,n){if(n.control("name").setLabel(i.getNickname()),n.listenTo(i,"login",function(){n.control("name").setLabel(i.getNickname())}),this.options.allowChangeNickname&&n.control("change-nickname").click(function(){this.changeNickname(i).then(function(){this.updateUserView(i)}.bind(this))}.bind(this)),this.options.customFunctions)for(var e in this.options.customFunctions)this.options.customFunctions.hasOwnProperty(e)&&function(e,t){n.control(e).click(function(){t(i).then(function(){this.updateUserView(i)}.bind(this))}.bind(this))}.bind(this)(e,this.options.customFunctions[e])},e.changeNickname=function(t){var i=new s,n=t.setView("catlab-nickname");return n.changeValue("name",t.getNickname()),n.control("a").click(function(){var e=n.getValues().name;!e||32<e.length||(t.setNickname(e),i.resolve())}),i.promise()},e.supportInactivePlayers=function(){return this.options.activePlayersPanel},e.supportsLocalAuthentication=function(){return this.options.localAuthenticable&&this.Webcontrol.canAuthenticate()},e.isMaster=function(e){return e.isMaster()},e.getPortalLabels=function(){var s={start:[],back:[],toggleActive:[],authenticate:[]};return this.Webcontrol._userlibrary.each(function(e){var t,i=e.getPortalControls();for(t in i)if(i.hasOwnProperty(t)){var n=e.control(i[t]).getLabel(!1);if(!n)continue;n="["+n.toUpperCase()+"]",void 0===s[t]&&(s[t]=[]),-1===s[t].indexOf(n)&&s[t].push(n)}}.bind(this)),s},e.authenticate=function(e){this.activateUser(e),this.disableControls();var t=this.Webcontrol.authenticationController(e,{messageBus:this.messageBus});this.messageBus.toView("auth:open",{}),t.controller.setNavigatableUsers([e]),t.controller.on("close",function(){this.enableControls(),this.updateUsers()}.bind(this))},e.countAuthenticated=function(e){void 0===e&&(e=!0);for(var t=0,i=0;i<this.users.length;i++)!this.users[i].isAuthenticated()||e&&!this.users[i].isActive()||t++;return t},e.checkAuthentication=function(){var e=this.countAuthenticated();switch(this.options.authentication){case this.Webcontrol.AUTH_REQUIRED_ALL:return e===this.countActiveUsers();case this.Webcontrol.AUTH_REQUIRED_ONE:return 0<e;case this.Webcontrol.AUTH_REQUIRED_ONE_INACTIVE:return 0<this.countAuthenticated(!1);case this.Webcontrol.AUTH_NOT_REQUIRED:return!0;default:throw"Authentication requirement "+this.options.authentication+" not found."}},e.startGame=function(){var e=this.countActiveUsers();if(e<this.options.minPlayers)this.messageBus.toView("alert",{message:"You need "+this.options.minPlayers+" players to start playing",localized:["You need %s players to start playing",this.options.minPlayers]});else if(e>this.options.maxPlayers)this.messageBus.toView("alert",{message:"Your license is limited to "+this.options.maxPlayers+" players",localized:["Your license is limited to %s players",this.options.maxPlayers]});else if(this.checkAuthentication())this.Webcontrol.setView("catlab-game-already-started",this.Webcontrol._userlibrary.not(this.getActiveUsers())),this.Webcontrol.setView("catlab-game-starting",this.getActiveUsers()),this.destroy(),this.options.start(this.getActiveUsers());else switch(this.options.authentication){case this.Webcontrol.AUTH_REQUIRED_ALL:this.messageBus.toView("alert",{message:"All active players must be authenticated.",localized:["All active players must be authenticated."]});break;case this.Webcontrol.AUTH_REQUIRED_ONE:case this.Webcontrol.AUTH_REQUIRED_ONE_INACTIVE:this.messageBus.toView("alert",{message:"At least one player must be authenticated.",localized:["At least one player must be authenticated."]})}},e.back=function(){void 0!==this.options.back&&(this.destroy(),this.options.back())},e.getConnectURL=function(){return this.Webcontrol.getConnectURL()},e.getConnectToken=function(){return this.Webcontrol.getConnectTokenForDisplay()},e.getUsers=function(){return this.users},e.setMinPlayers=function(e){return this.options.minPlayers=e,this.trigger("options:change"),this.updateState(),this},e.setMaxPlayers=function(e){return this.options.maxPlayers=e,this.trigger("options:change"),this.updateState(),this},e.getMessageBus=function(){return this.messageBus},e.getConnectInstructions=function(){return void 0!==this.Webcontrol.provider.getConnectInstructions?this.Webcontrol.provider.getConnectInstructions():["Use your tablet or smartphone to surf to %s and enter code %s.",this.getConnectURL(),this.getConnectToken()]},e.getStartAndLoginInstructions=function(){var e;return void 0!==this.Webcontrol.provider.getStartAndLoginInstructions?this.Webcontrol.provider.getStartAndLoginInstructions():(e=this.getPortalLabels(),this.supportsLocalAuthentication()&&(this.showInactivePlayers||this.hasUsersWithoutDisplay())?["Press %s to join, %s to login and %s to start.",t(e.toggleActive),t(e.authenticate),t(e.start)]:this.supportsLocalAuthentication()?["Press %s to login and %s to start.",t(e.authenticate),t(e.start)]:this.showInactivePlayers||this.hasUsersWithoutDisplay()?["Press %s to join and %s to start.",t(e.toggleActive),t(e.start)]:["Press %s to start.",t(e.start)]);function t(e){return e.join(" / ")}},e.destroy=function(){this.eventListeners&&this.eventListeners.forEach(function(e){e.unbind()}),this.messageBus.toView("portal:destroy"),this.messageBus.removeControllerListener(this),this.navigatableProxy.destroy()},r}),define("CatLab/Webremote/Controllers/RemoteAuthentication",["CatLab/Webremote/Controllers/OAuth2"],function(t){return function(e){e.setView("remote:authenticate"),e.on("user:join",function(e){e.on("login",function(e){t.addAccessToken(e.getAccessToken())}.bind(this))}.bind(this))}}),define("CatLab/Webremote/Controllers/Authentication",["CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Controllers/RemoteAuthentication","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Cookies","CatLab/Webremote/Messages/MessageBus","CatLab/Webremote/Messages/NavigateableProxy"],function(n,s,o,e,r,i,t,a){"use strict";function h(e,t,i){this.initializeEventable(),this.messageBus=e.getMessageBus(),this.navigatableProxy=new a(this.messageBus,"auth:"),this.Webcontrol=e,this.user=t,o.on("update",this.updateUsers,this),n.on("update",function(){this.updateUsers()},this),this.messageBus.addControllerListener(this)}var l=null,c=null,e=h.prototype=new e;return e.handleIncomingMessage=function(e,t){switch(e){case"subscribe":this.getLoginUrl().then(function(e){this.loginUrl=e,this.messageBus.toView("auth:loginurl",{url:e})}.bind(this)),this.updateUsers();break;case"auth:close":this.trigger("close");break;case"auth:select-user":this.selectUser(t.user)}},e.link=function(){n.link(function(e){this.selectUser(e)}.bind(this))},e.updateUsers=function(){this.messageBus.toView("auth:users:update",{users:o.getAll().map(function(e){return{id:e.getId(),name:e.getName(),image:e.avatar}})})},e.selectUser=function(e){var t;(e=o.getFromId(e.id))&&(t=this).user.loginFromAuthUser(e,function(){i.setCookie("ctlb_ps_"+this.user.id,e.id),t.close()}.bind(this))},e.getUsers=function(){return o},e.close=function(){this.messageBus.toView("auth:close"),this.destroy()},e.getLoginUrl=function(){var t,e,i=new r;return t=this.Webcontrol,(null!==l?((e=new r).resolve(l),e):(null===c&&(c=new r,t.newGroup().then(function(e){new s(l=e),e.setOAuthSettings(t.getOAuthSettings()),c.resolve(e)})),c)).promise().then(function(e){i.resolve(e.getConnectURL()+"/"+e.getConnectToken())}),i.promise()},e.setNavigatableUsers=function(e){e.forEach(function(e){this.navigatableProxy.addView(e)}.bind(this))},e.attemptLastLogin=function(){var e=i.getCookie("ctlb_ps_"+this.user.id);if(e){e=o.getFromId(e);if(e)return this.selectUser(e),!0}return!1},e.destroy=function(){this.messageBus.toView("auth:destroy"),this.messageBus.removeControllerListener(this),this.navigatableProxy.destroy()},h}),define("CatLab/Webremote/Tools/MessageCounter",["CatLab/Webremote/Tools/Eventable"],function(e){"use strict";function t(e){this.interval=e||1e3,this.initializeEventable(),this.countIncoming=0,this.countOutgoing=0;var t,i,n=(new Date).getTime();setInterval(function(){t=(new Date).getTime(),i=t-n,n=t,this.trigger("tick",{in:this.countIncoming,out:this.countOutgoing,dt:i}),this.countIncoming=0,this.countOutgoing=0}.bind(this),this.interval)}e=t.prototype=new e;return e.incoming=function(){this.countIncoming++},e.outgoing=function(){this.countOutgoing++},t}),define("CatLab/Webremote/Views/Portal",["CatLab/Webremote/Config"],function(B,e){return function(e){var s=e.element||document.body,t=s,i=e.countdown||5e3,n=e.done||function(){alert("Game should start now... yet it doesn't.")},o=e["min-players"]||1,r=(o<1&&(o=1),e["max-players"]||1e3);r<o&&(r=o);var a,h,l,c,u,d,p,f,g,m,v,b=!e.customViews,y=[],A=!1,w=!1,C=null,k=this;function T(s){s.setView("catlab-portal-toggle"),s.control("join-game").click(function(){!function(e){if(P(e)){e.control("join-game").setLabel("JOIN");for(var t=e,i=0;i<y.length;i++)if(y[i].getId()==t.getId())return y.splice(i,1)}else e.control("join-game").setLabel("LEAVE"),y.push(e)}(s),M(),x(),U()}),s.control("start-game").click(function(){var e;A?U():y.length<o?V(o+" players are required to start the game. Please gather more friends."):y.length>r?V("This game can have only "+r+" players."):(e=i,U(),A=!0,(p=new Date).setTime((new Date).getTime()+e),u.show(),d=setInterval(D,100))}),s.control("down").click(function(){L(s)}),s.control("right").click(function(){L(s)}),s.control("left").click(function(){S(s)}),s.control("up").click(function(){S(s)}),s.control("a").click(function(){var e,i,t,n;e=s,w&&I(e)?(n=v.find(".available-accounts").find("li.selected"))&&(n=WebcontrolOAuthClient.getFromToken(n.attr("data-accessToken")))&&(t=n.access_token,n=n.user,C.setUserData(t,n),_()):(A&&U(),w||(i=e,Webcontrol.getOAuthClient(function(t){t.onInit(function(){E(t)}),WebcontrolAccessKeyLibrary.init(function(){w=!0,C=i,m.show(),v.show();var e=$('<a href="javascript:void(0);">Link new account</a>');e.click(function(){t.getNewAccessToken(function(){E(t)})}),v.find(".link-new-account").html(e)}),E(t)})))}),s.control("b").click(function(){w&&I(s)&&(C.setUserData(!1),_())}),W(),x()}function S(e){w&&I(e)&&(e=v.find(".available-accounts").find("li.selected"),v.find(".available-accounts").find("li").removeClass("selected").addClass("unselected"),(e.length&&e.prev().length?e.prev():v.find(".available-accounts").find("li").last()).addClass("selected").removeClass("unselected"))}function L(e){w&&I(e)&&(e=v.find(".available-accounts").find("li.selected"),v.find(".available-accounts").find("li").removeClass("selected").addClass("unselected"),(e.length&&e.next().length?e.next():v.find(".available-accounts").find("li").first()).addClass("selected").removeClass("unselected"))}function I(e){return C&&e.getId()==C.getId()}function _(){m.hide(),v.hide(),w=!1,C=null}function E(e){v.find(".available-accounts").html("");for(var t=e.listUsers(),i=0;i<t.length;i++){var n=$("<li>"+t[i].user.username+"</li>");n.addClass("unselected"),n.attr("data-accessToken",t[i].access_token),v.find(".available-accounts").append(n)}}function x(){0<Webcontrol.getControlLabels("join-game").length?($(".buttoninstructions.join-game").show().find(".labels").html(Webcontrol.getControlLabels("join-game").join(", ")),$(".buttoninstructions.start-game").show().find(".labels").html(Webcontrol.getControlLabels("start-game").join(", "))):($(".buttoninstructions.join-game").hide(),c.hide())}function P(e){for(var t=0;t<y.length;t++)if(y[t].getId()==e.getId())return 1}function W(){var e=Webcontrol.getUsers();a.html("");for(var t=[],i=0;i<e.length;i++)P(e[i])||t.push(e[i]);for(0==t.length&&a.append('<li class="empty"><span>More players? Add devices!</span></li>'),i=0;i<t.length;i++)a.append('<li class="user '+t[i].getType()+'" style="background-color: '+t[i].getColor()+'"><i class="'+t[i].getIcon()+'"></i><span>'+t[i].getName()+"</span></li>")}function M(){h.html(""),0==y.length&&h.append('<li class="empty"><span class="buttoninstructions join-game">Press <span class="labels"></span> to join the game.</span></li>');for(var e=0;e<y.length;e++)h.append('<li class="user '+y[e].getType()+'" style="background-color: '+y[e].getColor()+'"><i class="'+y[e].getIcon()+'"></i><span>'+y[e].getName()+"</span></li>");W()}function D(){f=Math.ceil((p.getTime()-(new Date).getTime())/1e3),u.find(".counter").html(f),f<0&&(void 0!==t&&(void 0!==t.hide?t.hide():void 0!==t.style&&(t.style.display="none")),U(),n(y))}function U(){A=!1,d&&(V("Countdown stopped!"),u.hide(),clearInterval(d),d=null)}function V(e){var t=jQuery("<p></p>").html(e).appendTo(g);setTimeout(function(){t.fadeOut(1e3,function(){t.remove()})},3e3)}this.loginInformation="Login into your account and get access to more game features now!",0<s.length?s.addClass("webremote-portal"):s.className=s.className+" webremote-portal",void 0!==e.theme&&(e=B.getSocketURL()+"/webremote/themes/"+e.theme+"/"+e.theme+".css",Webcontrol._loadCSS(e),Webcontrol._loadCSS(B.getSocketURL()+"/webremote/themes/font-awesome/css/font-awesome.min.css")),s.innerHTML='<div class="loading"><p>Please wait, loading socket.io.</p></div>',Webcontrol.initialize(function(){s.innerHTML='<div class="loading"><p>Please wait, loading jQuery.</p></div>',s.innerHTML="";var e=s,e=(s=jQuery('<div class="webremote-portal-inner"></div>').appendTo(e),(s=jQuery(s)).html('<div class="loading"><p>Please wait, connecting to server.</p></div>'),b&&Webcontrol.loadViews(B.getSocketURL(!0)+"/webremote/views/default.xml"),s.html("<h1>Player lobby</h1>"),m=$("<div></div>"),v=$('<div><h2>Select account</h2><div class="information"><p>'+k.loginInformation+'</p></div><ul class="available-accounts"></ul><p class="link-new-account"></p></div>'),m.addClass("accounts-overlay"),v.addClass("accounts"),m.hide(),v.hide(),s.append(m),s.append(v),jQuery('<div class="connected-users"><div class="inner"><h2>Connected devices</h2></div></div>')),t=(a=jQuery('<ul class="connected-users"></ul>').appendTo(e.find(".inner")),jQuery('<div class="active-users"><div class="inner"><h2>Active users</h2></div></div>'));h=jQuery('<ul class="active-users"></ul>').appendTo(t.find(".inner")),s.append(e),s.append(t),(e=jQuery('<div class="connection-information"><div class="inner"><h2>Instructions</h2><p>Take your smartphone, navigate to <span class="url"></span> and use token <span class="token"></span></p></div></div>')).find(".token").html(Webcontrol.getConnectToken()),e.find(".url").html(Webcontrol.getConnectURL()),l=jQuery('<p class="buttoninstructions join-game">Press <span class="labels"></span> to join the game.</p>'),c=jQuery('<p class="buttoninstructions start-game">Press <span class="labels"></span> to start the game.</p>'),g=jQuery('<div class="errors"></div>').appendTo(s),e.append(l),e.append(c),s.append(e),u=jQuery('<div class="countdown-background"></div><div class="countdown"><p>Game will start in <span class="counter">5</span></p></div>').hide().appendTo(s),Webcontrol.on("user:join",function(e){T(e)});for(var i=Webcontrol.getUsers(),n=0;n<i.length;n++)T(i[n]);Webcontrol.on("user:leave",W),W(),M(),x()})}}),define("CatLab/Webremote/ViewFactory/ViewFactory",["CatLab/Webremote/Views/Portal"],function(t){"use strict";function e(){}return e.prototype.getPortal=function(e){return new t(e)},e}),define("CatLab/Webremote/Models/Users/GamepadUser",["CatLab/Webremote/Models/Users/ControlUser"],function(e){function t(e){e=e.id||"1",this.initialize({id:"gamepad_"+e}),this.clearControls()}var i={DPAD_UP:{id:"up",label:"↑",key:""},DPAD_DOWN:{id:"down",label:"↓",key:"DPAD_DOWN"},DPAD_RIGHT:{id:"right",label:"→",key:"DPAD_RIGHT"},DPAD_LEFT:{id:"left",label:"←",key:"DPAD_LEFT"},FACE_1:{id:"a",label:"A",key:"FACE_1"},FACE_2:{id:"b",label:"B",key:"FACE_2"},FACE_3:{id:"x",label:"X",key:"FACE_3"},FACE_4:{id:"y",label:"Y",key:"FACE_4"},SELECT_BACK:{id:"back",label:"SELECT",key:"SELECT_BACK"},START_FORWARD:{id:"start",label:"START",key:"START_FORWARD"}},e=t.prototype=new e;return e.getType=function(){return"gamepad"},e.getIcon=function(){return"fa fa-gamepad"},e.emit=function(){return!1},e.isLocalAuthentication=function(){return!1},e.controlFromKey=function(e){return this.control(i[e].id)},e.hasDisplay=function(){return!1},e.hasKeyboardInput=function(){return!1},e.hasTouchInput=function(){return!1},t}),define("CatLab/Webremote/Gamepads/GamepadAPI",["CatLab/Webremote/Models/Users/GamepadUser"],function(i){function e(){this.gamepads={},this.initialized=!1,this.Webcontrol=null}var n,t,s={12:"DPAD_UP",13:"DPAD_DOWN",15:"DPAD_RIGHT",14:"DPAD_LEFT",0:"FACE_1",1:"FACE_2",2:"FACE_3",3:"FACE_4",8:"SELECT_BACK",9:"START_FORWARD"},o=e.prototype;return o.initialize=function(e){var t;this.Webcontrol=e,this.initialized||(this.initialized=!0,e=function(){var e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads||[];for(n=0;n<e.length;n++)if(e[n]){for(n=0;n<e.length;n++)e[n]&&this.onConnect(e[n]);this.startGamepadPolling(),clearInterval(t)}}.bind(this),"undefined"!=typeof window&&("ongamepadconnected"in window?(window.addEventListener("gamepadconnected",function(e){this.onConnect(e.gamepad)}.bind(this)),window.addEventListener("gamepaddisconnected",function(e){this.onDisconnect(e.gamepad)}.bind(this))):t=setInterval(e,1e3)))},o.startGamepadPolling=function(){setInterval(this.poll.bind(this),50)},o.poll=function(){var e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads||[];for(n=0;n<e.length;n++)if(e[n])for(t=0;t<e[n].buttons.length;t++)this.gamepads[e[n].index].user&&void 0!==s[t]&&this.gamepads[e[n].index].user.controlFromKey(s[t]).update(e[n].buttons[t].pressed?1:0)},o.onConnect=function(e){var t=new i({id:e.id});this.gamepads[e.index]={user:t},this.Webcontrol.addCustomControl(t),this.startGamepadPolling()},o.onDisconnect=function(e){},new e}),define("CatLab/Webremote/Controllers/Webcontrol",["CatLab/Webremote/Config","CatLab/Webremote/Collections/Users","CatLab/Webremote/Collections/Groups","CatLab/Webremote/Collections/AuthenticatedUsers","CatLab/Webremote/Models/Users/ControlUser","CatLab/Webremote/Models/ControlGroup","CatLab/Webremote/Models/State","CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Controllers/Portal","CatLab/Webremote/Controllers/Authentication","CatLab/Webremote/Tools/Colorwheel","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/Preloader","CatLab/Webremote/Tools/Smileys","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/MessageCounter","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Synchronization/RemoteViewFactory","CatLab/Webremote/Synchronization/DataSynchronizer","CatLab/Webremote/Synchronization/EventHandler","CatLab/Webremote/ViewFactory/ViewFactory","CatLab/Webremote/Views/ConnectionTrouble","CatLab/Webremote/Providers/SocketIO","CatLab/Webremote/Gamepads/GamepadAPI","CatLab/Webremote/SonicSync/Client","CatLab/Webremote/Messages/MessageBus"],function(a,e,t,i,n,s,h,o,r,l,c,u,d,p,f,g,m,v,b,y,A,w,C,k,T,S,L){"use strict";function I(){this.initializeEventable(),this.provider=null,this._gamedata=null,this._userlibrary=null,this._grouplibrary=null,this._cssloads=[],this._labeldata={},this._initialized=!1,this._oauthsettings=!1,this._oauthClient=null,this._authentication=!1,this._lastView=null,this._options={},this._groupCallbacks={id:1},this._viewFactory=null,this.state=null,this.connected=!1,this._userlibrary=new e,this._grouplibrary=new t,this._messageBus=new L}g=I.prototype=new g;return Object.assign(g,{AUTH_REQUIRED_ALL:"ALL",AUTH_REQUIRED_ONE:"ONE",AUTH_REQUIRED_ONE_INACTIVE:"ONE-INACTIVE",AUTH_NOT_REQUIRED:"NONE",initialize:function(e){function t(){s.resolve(),n()}var i,n=function(){},s=(void 0!==(e=void 0===(e="function"==typeof e?{callback:e}:e)?{}:e).callback&&(n=e.callback),new u);return this._initialized?t():(this.sonicSyncClient=null,delete e.callback,e.headless,(i=!!e.headless)||void 0===e.assets||this.setAssets(e.assets),a.set(e),a.initialize(function(){null===this.provider&&(void 0===e.provider&&(e.provider=new k),this.provider=e.provider),this.smileys=new f(this.provider),void 0!==e.translator&&d.setTranslator(e.translator),this._initialize(i,t)}.bind(this))),s.promise()},disconnect:function(){this._initialized=!1,this.provider.disconnect()},_initialize:function(s,e){var o,r=new u;return(e&&r.then(e),this._initialized)?r.resolve(this.connected):(setTimeout(function(){r.resolve(!1)},3e4),this.state=new h(this),this._initialized=!0,(o=this).provider.initMaster(this),this.getProviderSettings().then(function(e){this.provider.connect("control",e).then(function(){this.connected=!0,this.provider.on("disconnect",function(){var e=this.getConnectionIssuesView();e.show(),e.text(d.t("Connection lost... reconnecting"))}.bind(this)),this.provider.on("reconnect",function(){this.recover(function(){this.getConnectionIssuesView().hide()}.bind(this))}.bind(this)),this.provider.on("master:initialize",function(e){this.log("Initializing"),this._gamedata=e,this.log("Game initialize; URL "+this.getConnectURL()+", token "+this.getConnectToken()),r.resolve(this.connected)}.bind(this)),this.provider.on("master:error",function(e){alert(e.message)}.bind(this)),this.provider.on("user:join",function(e){this._playerJoin(e)}.bind(this)),this.provider.on("user:reconnect",function(e){this._playerReconnect(e)}.bind(this)),this.provider.on("user:leave",function(e){this._playerLeave(e)}.bind(this)),this.provider.on("view:labels",function(e){this._setViewLabels(e)}.bind(this)),this.provider.on("group:create",function(e){this._onNewGroup(e)}.bind(this)),this.provider.on("user:smiley",function(e){this._playerTrigger("user:smiley",e),this._userlibrary.each(function(e){this.smileys.refreshTakenSmileys(e)}.bind(this))}.bind(this)),this.provider.on("smileys:slingshot",function(e){var t=this._userlibrary.getFromId(e.user);t?(t.trigger("smileys:slingshot",e),e.user=t,this.trigger("smileys:slingshot",e)):console.log("User not found: "+e.user)}.bind(this));for(var e=(e=(e=["user:login","user:logout","button:down","button:up","sync:audio"]).concat(y.eventsToListenFor)).concat(A.eventsToListenFor),t=0;t<e.length;t++)!function(t){o.provider.on(t,function(e){o._playerTrigger(t,e)})}(e[t]);var i=["value:change"];for(var n=0;n<i.length;n++)!function(t){o.provider.on(t,function(e){o._viewTrigger(t,e)})}(i[n]);this._oauthsettings&&this.provider.setOAuthSettings(this._oauthsettings),this.provider.setup(a.getProviderConfig()),this.preloader=new p(this.provider),!s&&a.useAudioSync()&&(this.sonicSyncClient=new S(this),this.sonicSyncClient.startSender())}.bind(this))}.bind(this))),r.promise()},setLogger:function(e){var t;"string"==typeof e?(t=document.getElementById(e),this.log=this.getDomLogger(t)):this.log=e},getProviderSettings:function(){return this.provider.getProviderSettings()},setMessageCounter:function(e){e=new m(e);return this.provider.setMessageCounter(e),e},setName:function(e){this.provider.toMaster("master:name",{name:e})},setMaxUsers:function(e){this.provider.toMaster("config:set",{maxUsers:e})},setViewFactory:function(e){return this._viewFactory=e,this._viewFactory.initialize()},getViewFactory:function(){return"undefined"===this._viewFactory&&(this._viewFactory=new w),this._viewFactory},getDomLogger:function(t){return function(e){t.innerHTML=e+"\n"+t.innerHTML}},oAuth:function(e,t){void 0===t&&(t=!1),this._authentication=!0,this._oauthsettings=e,this.provider&&!t&&this.provider.setOAuthSettings(this._oauthsettings),o.initialize(e),i.initialize(this,o)},getOAuthClient:function(e){this._oauthsettings?(null===this._oauthClient&&(this._oauthClient=o,this._oauthClient.initialize(this._oauthsettings)),e(this._oauthClient)):e(null)},getOAuthSettings:function(){return this._oauthsettings},clearEvents:function(e){if(e=void 0===e?!1:e)for(var t=this._userlibrary.getAll(),i=0;i<t.length;i++)t[i].clearEvents()},getConnectURL:function(){return this.provider.getConnectURL(this._gamedata.connectURL)},getConnectToken:function(){return this.provider.getConnectToken(this._gamedata.token)},getConnectTokenForDisplay:function(){return v.getConnectTokenForDisplay(this.getConnectToken())},loadViews:function(e,t){this.provider.loadViews(e,t)},getUsers:function(){return this._userlibrary.getAll()},portal:function(e){var t=this.portalController(e),e=this.portalView(t.messageBus,e);return{controller:t.controller,view:e,promise:t.promise}},portalController:function(e){var t;if(this._initialized)return t=new u,e=new r(this,e),t.resolve(e),{controller:e,messageBus:this.getMessageBus(),promise:t};throw new Error("Please initialize Webcontrol first.")},portalView:function(e,t){var i;if(this._initialized)return i=this.getViewFactory(),e={messageBus:e,Webcontrol:this},void 0!==t.element&&(e.element=t.element),(t=i.portal(e)).loading(),(e=i.getContainer()).easelboneLayer.setView(t),t.render(),e;throw new Error("Please initialize Webcontrol first.")},authentication:function(e,t){var i;if(this._initialized)return i=this.authenticationController(e,t),t=this.authenticationView(i.controller.messageBus,t),i.controller.setNavigatableUsers([e]),{controller:i.controller,view:t,promise:i.promise};throw new Error("Please initialize Webcontrol first.")},authenticationController:function(e,t){var i=new u,e=new l(this,e,t);return i.resolve(e),{controller:e,promise:i.promise()}},authenticationView:function(e){var t=this.getViewFactory(),e=t.authentication({messageBus:e}),t=t.getContainer();return t.easelboneLayer.setView(e),e.render(),t},getConnectionIssuesView:function(){return void 0===this.connectionTrouble&&(this.connectionTrouble=new C),this.connectionTrouble},setView:function(e,t){var i;return void 0===t?(i=b.create(e,[this],this),this._lastView=i):i=b.create(e,t,this),i},beacon:function(e,t){this.provider.toMaster("master:beacon",{beacon:e,token:t})},emit:function(e,t){this.provider.toPlayers(e,t)},getControlLabels:function(e,t){for(var i=[],n={},s=this.getUsers(),o=0;o<s.length;o++){var r=s[o].control(e).getLabel(t);void 0===n[r]&&i.push(n[r]=r)}return i},addCustomControl:function(e){this.log("adding "+e.getType()),e.setWebcontrol(this),this._userlibrary.add(e),this._initializeSmiley(e,{}),this.trigger("user:join",e)},enableGamepads:function(){T.initialize(this)},newGroup:function(e){var t=new u,i={},n=(void 0===e?e={}:"function"==typeof e&&(e={callback:e}),void 0===e.callback&&(e.callback=function(){}),!0),s=(void 0!==e.globalViews&&(n=e.globalViews),!0),o=(void 0!==e.shareColor&&(s=e.shareColor),[]),r=(void 0!==e.tags&&(o=e.tags),!0),r=(void 0!==e.smiley&&(r=!!e.smiley),i.smiley=r,this._groupCallbacks.id);return this._groupCallbacks.id++,this._groupCallbacks[r]={id:r,callback:e.callback,deferred:t,options:i},this.provider.createGroup(r,n,s,o),t.promise()},preload:function(e){return this.preloader.preload(e)},getPreloadedUrl:function(e){return this.preloader.getPreloadedUrl(e)},_reset:function(){this._userlibrary.clear(),this._grouplibrary.clear()},reset:function(){var e=new u;return this._initialized=!1,this.provider.reset(function(){e.resolve()}.bind(this)),e.promise()},_playerJoin:function(e){var t;this._userlibrary.getFromId(e.id)||((t=new n(e.id,e)).setWebcontrol(this),void 0!==e.color&&t.setColor(e.color.color,e.color.name),this._grouplibrary.addUser(t)||(this._lastView&&this._lastView.addTarget(t),this._initializeSmiley(t,e)),this._userlibrary.add(t),this.log(t),t&&this.trigger("user:join",t),this.preloader.sendPreloadFileCommandToPlayer(t))},_playerReconnect:function(e){var t=this._userlibrary.getFromId(e.id);t?(t.getSmiley()&&t.emit("user:smiley",{smiley:t.getSmiley()}),this._refreshPlayerViews(t),this.trigger("user:rejoin",t),t.eventableTrigger("rejoined"),this.smileys.refreshTakenSmileys(t),this.preloader.sendPreloadFileCommandToPlayer(t)):this._playerJoin(e)},_refreshPlayerViews:function(e){this._grouplibrary.addUser(e)||this._lastView&&this._lastView.addTarget(e),e.refreshView()},_playerLeave:function(e){e=this._userlibrary.getFromId(e.id);e&&(this.trigger("user:leave",e),e.eventableTrigger("left"))},_onNewGroup:function(e){var t,i=new s(e.id,e),n=(i.setWebcontrol(this),!1);void 0!==e.shareColor&&(n=e.shareColor),void 0!==e.color?i.setColor(e.color.color,e.color.name):i.setShareColor(n),this._grouplibrary.getFromId(e.id)||(n=function(){},void 0!==(t=e.externalId)&&void 0!==this._groupCallbacks[t]&&(i.setOptions(this._groupCallbacks[t].options),n=function(){this._groupCallbacks[t].callback(i),this._groupCallbacks[t].deferred.resolve(i)}.bind(this)),this._grouplibrary.add(i),i.getOption("smiley")&&this._initializeSmiley(i,e),this.trigger("group:create",i),this.log("New group "+i.getId()+"; URL "+i.getConnectURL()+", token "+i.getConnectToken()),n())},_initializeSmiley:function(e,t){var i;a.useSmileys()?void 0===t.smiley?null!==(i=this.smileys.getRandom(e.getIdentifier()))&&e.setSmiley(i):e.setSmiley(t.smiley):e.clearSmiley(),this.smileys.refreshTakenSmileys(e)},_playerTrigger:function(e,t){var i=this._userlibrary.getFromId(t.user);i?i.trigger(e,t):console.log("User not found: "+t.user)},_viewTrigger:function(e,t){var i=b.getFromId(t.viewId);i&&i.trigger(e,t)},_loadCSS:function(e){for(var t=0;t<this._cssloads.length;t++)if(this._cssloads[t]==e)return;this._cssloads.push(e);var i=document.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("type","text/css"),i.setAttribute("href",e),document.body.appendChild(i)},_setViewLabels:function(e){this._labeldata[e.id]=e.labels;for(var t=this.getUsers(),i=0;i<t.length;i++)for(var n=0;n<e.labels.length;n++)t[i].control(e.id).setStaticLabel(e.labels[n].label,"mobile")},getViewLabels:function(e){return void 0!==this._labeldata[e]?this._labeldata[e]:[]},getFromIdentifier:function(e){switch(e.type){case"user":return this._userlibrary.getFromId(e.id);case"group":return this._grouplibrary.getFromId(e.id)}return null},log:function(e){a.debug()&&(console.log(a),console.log(e))},canAuthenticate:function(){return this._authentication},pause:function(){this._initialized&&this.provider.toPlayers("master:pause",{})},unpause:function(){this._initialized&&this.provider.toPlayers("master:unpause",{})},audioSync:function(){if(this.sonicSyncClient)return this.sonicSyncClient.sync()},getMessageBus:function(){return this._messageBus},recover:function(e){var t=this.state.getData();this._reconnect(t.token,t.accessToken,e).then(function(){this._userlibrary.each(function(e){this._refreshPlayerViews(e)}.bind(this))}.bind(this))},_reconnect:function(e,t,i){return this.provider.reconnect(e,t,a.getProviderConfig(),i)},getIceCredentials:function(){var t=new u;return this.provider.toMaster("webrct:stun+turn",{},function(e){void 0===e.error?t.resolve(e):t.fail(e.error)}),t.promise()}}),I}),define("CatLab/Webremote/Models/Users/KeyboardUser",["CatLab/Webremote/Models/Users/ControlUser"],function(e){"use strict";function t(e,t){var i="keyboard"+ ++n;this.initializeKeyboardUser({id:i,keys:e}),this.exitOnUnassignedBackButton=t}var n=0,e=((t.prototype=Object.create(e.prototype)).constructor=t).prototype;return e.initializeKeyboardUser=function(e){this.initialize({id:e.id}),void 0===e.keys&&(e.keys=this.getDefaultKeys()),this.keys=e.keys,this.attachKeyboardEvents(),"undefined"!=typeof document&&document.addEventListener("fullscreenchange",this.attachKeyboardEvents.bind(this)),this.clearControls=function(){for(var e,t=0;t<this.keys.length;t++)this.control(this.keys[t].id).setStaticLabel(this.keys[t].label,"keyboard");for(e in this.controls)!this.controls.hasOwnProperty(e)||this.controls[e].isGlobal||this.controls[e].clear()},this.on("view:set",function(e){this.clearControls()}.bind(this)),this.getType=function(){return"keyboard"},this.getIcon=function(){return"fa fa-keyboard-o"},this.emit=function(e,t){return!1},this.isLocalAuthentication=function(){return!1},this.clearControls()},e.getAvailableControls=function(){for(var e=[],t=0;t<this.keys.length;t++)e.push(this.keys[t].id);return e},e.getDefaultKeys=function(){return[{id:"up",label:"↑",code:"ArrowUp"},{id:"down",label:"↓",code:"ArrowDown"},{id:"right",label:"→",code:"ArrowRight"},{id:"left",label:"←",code:"ArrowLeft"},{id:"a",label:"A",code:["KeyA","Enter","NumpadEnter"]},{id:"b",label:"B",code:"KeyB"},{id:"x",label:"X",code:"KeyX"},{id:"y",label:"Y",code:"KeyY"},{id:"back",label:"Escape",code:"Escape"},{id:"start",label:"S",code:["KeyS"]}]},e.hasControl=function(e){return-1!==this.getAvailableControls().indexOf(e)},e.hasDisplay=function(){return!1},e.hasKeyboardInput=function(){return!0},e.hasTouchInput=function(){return!0},e.stopListening=function(){try{if("undefined"==typeof window)self.removeEventListener("message",this.messageListener,!1);else{var e=null;try{e=window.document}catch(e){}e&&(this._keydownListener&&window.document.removeEventListener("keydown",this._keydownListener),this._keyupListener)&&window.document.removeEventListener("keyup",this._keyupListener),this.messageListener&&window.removeEventListener("message",this.messageListener,!1);var t=null;try{t=window.parent.document}catch(e){}t&&(t.removeEventListener("keyup",this._keydownListener),t.removeEventListener("keydown",this._keydownListener))}}catch(e){console.log(e)}},e.resumeListening=function(){this.attachKeyboardEvents()},e.attachKeyboardEvents=function(){if(this.stopListening(),"undefined"==typeof window)this.messageListener=this._onMessage.bind(this),self.addEventListener("message",this.messageListener,!1);else try{var e=window.document;if(!document.fullscreenElement&&window.parent&&!(e=window.parent.document))throw new Error("Unaccessible");this._keydownListener=this._keyDown.bind(this),this._keyupListener=this._keyUp.bind(this),e.addEventListener("keydown",this._keydownListener),e.addEventListener("keyup",this._keyupListener)}catch(e){try{this.messageListener=this._onMessage.bind(this),window.addEventListener("message",this.messageListener,!1)}catch(e){console.error(e)}}},e.getConfigFromKey=function(e){for(var t=0;t<this.keys.length;t++){if(void 0!==this.keys[t].code&&this._keyMatches(this.keys[t].code,e.code))return this.keys[t];if(void 0!==this.keys[t].key&&this._keyMatches(this.keys[t].key,e.key))return this.keys[t];if(void 0!==this.keys[t].keyCode&&this._keyMatches(this.keys[t].keyCode,e.keyCode))return this.keys[t]}return null},e._keyMatches=function(e,t){return!!(Array.isArray(e)&&-1<e.indexOf(t))||e==t},e._onMessage=function(e){var t=e.data;if("object"==typeof t&&void 0!==t.type&&"catlab:keyboard"===t.type&&void 0!==t.code&&void 0!==t.action)switch(t.action){case"down":return void this._keyDown(e.data);case"up":return void this._keyUp(e.data)}},e._keyDown=function(e){var t;"Escape"!==e.key||!this.exitOnUnassignedBackButton||this.control("back").hasTriggers("click")||this.control("back").hasTriggers("up")||this.control("back").hasTriggers("down")?(t=this.getConfigFromKey(e))&&(this.control(t.id).update(1),void 0!==t.preventDefault)&&t.preventDefault&&e.preventDefault():this.requestExitApp()},e._keyUp=function(e){var t=this.getConfigFromKey(e);t&&(this.control(t.id).update(0),void 0!==t.preventDefault)&&t.preventDefault&&e.preventDefault()},e.requestExitApp=function(){var e;window.onbeforeunload?(e=window.onbeforeunload({}))&&this.confirm(e,function(e){e&&this.exitApp()}.bind(this)):this.exitApp()},e.exitApp=function(){window.close()},e.confirm=function(e,t){t(window.confirm(e))},t}),define("CatLab/Webremote/Models/Users/CordovaUser",["CatLab/Webremote/Models/Users/KeyboardUser"],function(e){function t(e,t,i){void 0===i&&(i=!0),void 0===t&&(t="back"),this.initializeKeyboardUser({id:"cordova",keys:e}),this.initializeBackButtonExit(t,i)}e=((t.prototype=Object.create(e.prototype)).constructor=t).prototype;return e.initializeBackButtonExit=function(i,n){void 0===n&&(n=!0);var s=new Date;document.addEventListener("backbutton",function(e){var t=new Date;t.getTime()-s.getTime()<300?this.requestExitApp():(s=t,e.preventDefault(),!n||this.control("back").hasTriggers("click")||this.control("back").hasTriggers("up")||this.control("back").hasTriggers("down")?i&&(this.control(i).update(1),setTimeout(function(){this.control(i).update(0)}.bind(this),1)):setTimeout(function(){void 0!==window.plugins.appMinimize?window.plugins.appMinimize.minimize():this.exitApp()},350))}.bind(this),!1)},e.exitApp=function(){navigator.app.exitApp()},e.confirm=function(e,t){navigator.notification.confirm(e,function(e){t(1===e)})},e.getDefaultKeys=function(){return[{id:"up",label:"↑",key:38},{id:"down",label:"↓",key:40},{id:"right",label:"→",key:39},{id:"left",label:"←",key:37},{id:"start",label:"ENTER",key:13},{id:"back",label:"BACK",key:null}]},e.hasDisplay=function(){return!1},e.hasKeyboardInput=function(){return!0},e.hasTouchInput=function(){return!0},t}),define("CatLab/Webremote/Models/Users/AndroidRemoteUser",["CatLab/Webremote/Models/Users/CordovaUser"],function(e){function t(e,t,i){this.initializeKeyboardUser({id:"cordova",keys:e}),this.initializeBackButtonExit(t,i)}e=((t.prototype=Object.create(e.prototype)).constructor=t).prototype;return e.getDefaultKeys=function(){return[{id:"up",label:"↑",keyCode:38,preventDefault:!0},{id:"down",label:"↓",keyCode:40,preventDefault:!0},{id:"right",label:"→",keyCode:39,preventDefault:!0},{id:"left",label:"←",keyCode:37,preventDefault:!0},{id:"a",label:"ENTER",keyCode:13,preventDefault:!0},{id:"back",label:"BACK",keyCode:null},{id:"start",label:"⏯",keyCode:179},{id:"fastforward",label:"⏩",keyCode:228},{id:"fastforward",label:"⏪",keyCode:227}]},e.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"up",authenticate:"menu",left:"left",right:"right"}},e.hasDisplay=function(){return!1},e.hasKeyboardInput=function(){return!1},e.hasTouchInput=function(){return!1},this.getType=function(){return"android-keyboard"},t}),define("CatLab/Webremote/Models/Users/DummyUser",["CatLab/Webremote/Models/Users/ControlUser"],function(e){function t(e){this.initialize({id:e}),this.clearControls=function(){},this.getType=function(){return"dummy"},this.getIcon=function(){return"fa fa-keyboard-o"},this.emit=function(e,t){return!1},this.isLocalAuthentication=function(){return!1},this.log=function(e){this.Webcontrol&&this.Webcontrol.log("[u:"+this.getId()+"] "+e)},this.hasDisplay=function(){return!1},this.hasKeyboardInput=function(){return!0},this.hasTouchInput=function(){return!0},this.clearControls()}return(t.prototype=Object.create(e.prototype)).constructor=t}),define("CatLab/Webremote/Tools/ParseXML",[],function(){function e(){}var t=null;"undefined"!=typeof window&&(void 0!==window.DOMParser?t=function(e){return(new window.DOMParser).parseFromString(e,"text/xml")}:void 0!==window.ActiveXObject&&new window.ActiveXObject("Microsoft.XMLDOM")&&(t=function(e){var t=new window.ActiveXObject("Microsoft.XMLDOM");return t.async="false",t.loadXML(e),t}));return e.prototype.parse=function(e){if(t)return t(e);throw new Error("No XML parser found")},new e}),define("CatLab/Webremote/Providers/Airconsole",["CatLab/Webremote/Providers/Provider","CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Proxy","CatLab/Webremote/Tools/ParseXML","CatLab/Webremote/Synchronization/MessageQueue","CatLab/Webremote/Models/User"],function(e,t,i,n,s,o,r){function a(e){e&&(this.airconsole=e),this.showTokenForm=!1,this.oauth={},this.views=[],this.knownUsers={},this.started=!1,this.userId=null,this.sendBurstDelay=50,this.connectCode=null}e=a.prototype=new e;return e.connect=function(e){return this.log("Airconsole connecting"),this.setInitialized(),this.path=e,this._trigger("connect",null),this.readyState.promise()},e.noTokenConnect=function(){return this.connect("remote")},e.setUserId=function(e){return this.userId=e,this},e.initMaster=function(e){this.master=e,this.airconsole||(this.airconsole=new AirConsole),this.airconsole.onMessage=this.onMessage.bind(this),this.airconsole.onConnect=function(e){this.emitAirConsole(e,"airconsole:well-hello-there",{user:e})}.bind(this),this.readyState=new i,this.airconsole.onReady=function(e){this.connectCode=e,this.readyState.resolve()}.bind(this),this.airconsole.onDeviceProfileChange=function(e){this.updateDeviceProfile(e)}.bind(this),this.on("player:join",function(e){this.onPlayerConnect(e.user)}.bind(this)),this.once("connect",function(){setTimeout(function(){this.started=!0}.bind(this),1)}.bind(this))},e.initPlayer=function(e){this.master=e,this.airconsole=new AirConsole,this.airconsole.onMessage=this.onMessage.bind(this),this.readyState=new i,this.readyState.resolve(),this.once("airconsole:well-hello-there",function(e){this.emitAirConsole(0,"player:join",{})}.bind(this))},e.onMessage=function(t,e){var i;void 0!==(e="string"==typeof e?JSON.parse(e):e).b&&Array.isArray(e.b)?(i=0,e.b.forEach(function(e){setTimeout(function(){this.processMessage(t,e)}.bind(this),i++)}.bind(this))):this.processMessage(t,e)},e.processMessage=function(e,t){var i;t&&t[0]&&(i=t[0],t=t[1],this.isMaster()&&(0<e&&"player:join"!==i&&void 0===this.knownUsers[e]&&this.onPlayerConnect(e),0<e)&&(t.user=e),o.unpack(t,"user").forEach(function(e){this.isRemote()&&void 0!==e.user&&e.user!==this.airconsole.getDeviceId()||this._trigger(i,e)}.bind(this)))},e.onPlayerConnect=function(e){this.log("Welcoming our newest player "+e),this.knownUsers[e]=!0;for(var t=0;t<this.views.length;t++)this.emitAirConsole(e,"view:load",{xml:this.views[t]}),this.emitAirConsole(e,"view:set",{id:"loading"});this._trigger("user:join",{id:e}),this.updateDeviceProfile(e)},e.updateDeviceProfile=function(e){var t,i,n=this.master._userlibrary.getFromId(e);n&&(t={username:this.airconsole.getNickname(e)},(i=this.airconsole.getProfilePicture(e))&&(t.avatar=i),this.airconsole.getMasterControllerDeviceId()===e&&n.setMaster(!0),n.setProfiledata(t))},e.emitAll=function(){this.isMaster()&&this.emitMaster(),this.isRemote()&&this.emitClient()},e.isMaster=function(){return"control"===this.path},e.isRemote=function(){return"remote"===this.path},e.emitClient=function(){this.queue.flush().forEach(function(e){this.emitAirConsole(0,e.action,e.data)}.bind(this))},e.emitMaster=function(){var t,i,e=this.queue.compactFlush();e.length&&(t=5<e.length,i=[],e.forEach(function(e){t||void 0===e.data.user||Array.isArray(e.data.user)&&1<e.data.user.length?i.push(e):this.emitAirConsole(e.user,e.action,e.data)}.bind(this)),0<i.length)&&this.broadcastAirconsole(i)},e.emitAirConsole=function(e,t,i){t=[t,i],delete t[1].action,i=JSON.stringify(t);this.airconsole.message(e,i)},e.broadcastAirconsole=function(e){var t=[],e=(e.forEach(function(e){t.push([e.action,e.data])}),JSON.stringify({b:t}));this.airconsole.broadcast(e)},e.setOAuthSettings=function(e){this.oauth=e,this.toPlayers("oauth:set",e)},e.loadViews=function(e){n.get(e).then(function(e){this.views.push(e),this.toPlayers("view:load",{xml:e})}.bind(this))},e.log=function(){this.master.log.apply(arguments)},e.setup=function(e){this._trigger("master:initialize",{})},e.toMaster=function(e,t){t.user=0,this.emit(e,t)},e.log=function(e){var t=[],i=(Array.prototype.push.apply(t,arguments),"["+this.path+"]");"remote"===this.path&&(i="["+this.path+":"+this.airconsole.getDeviceId()+"]"),t.unshift(i),console.log.apply(console,t)},e.getConnectInstructions=function(){return["Open the Airconsole app on your smartphone and connect with code %s.",this.connectCode]},e.getStartAndLoginInstructions=function(){return["Use the onscreen button to start the game."]},e.proxyFile=function(e){var t=new i;return t.resolve({url:e}),t.promise()},a}),define("CatLab/Webremote/Providers/Dummy",["CatLab/Webremote/Providers/Provider","CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Tools"],function(e,t,n,i){function s(){this.initializeProvider(),this.userId=null,this.randomToken=i.getUuid(),this.loadBalancerSessionToken="connid",this.socket=null,this._registeredEvents={}}e=s.prototype=new e;return e.connect=function(e,t){var i=new n;return this.setInitialized(),i.resolve(),i.promise()},e.setup=function(e){this._trigger("master:initialize",{})},e.emitAll=function(e,t){},s}),define("CatLab/Webremote/CreateJS/LayerContainer",["easeljs","easelbone"],function(n,s){"use strict";function e(e,t){if(!s)throw console.log("When using the createjs module of the remote, you need to have the easelbone module loaded."),console.log("Check https://github.com/catlabinteractive/easelbone"),new Error("easelbone could not be loaded.");this.width=e,this.height=t,this.initialize(),this.easelboneLayer=new s.Views.Layer({container:this});var i=this;this.easelboneLayer.on("all",function(e){e=new n.Event(e);i.dispatchEvent(e)})}var t=e.prototype=new n.Container;return t.Container_initialize=t.initialize,t.initialize=function(){this.Container_initialize(),this.setBounds(0,0,this.width,this.height),this.on("click",function(e){e.stopPropagation()})},t.loading=function(){},t.render=function(){this.easelboneLayer.render()},e}),define("CatLab/Webremote/Tools/ImageLoader",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred"],function(n,s){return{loadedImages:{},loadImage:function(e){var t,i=new s;return this.loadedImages[e]?i.resolve(this.loadedImages[e]):((t=new Image).crossOrigin="anonymous",t.onload=function(){this.loadedImages[e]=t,i.resolve(this.loadedImages[e])}.bind(this),t.src=n.getProxiedImage(e)),i.promise()}}}),define("CatLab/Webremote/CreateJS/Views/PortalView",["easeljs","easelbone","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/ImageLoader","CatLab/Webremote/Messages/NavigateableProxy"],function(e,n,i,s,o){"use strict";return n.Views.Navigatable.extend({initialize:function(e){this.Webcontrol=e.Webcontrol,this.controllerState={activePlayers:0,minPlayers:0,maxPlayers:0,connectInstructions:[""],startAndLoginInstructions:[""],showInactivePlayers:!1},this.initializeNavigatable({orientation:this.ORIENTATION.HORIZONTAL}),this.messageBus=e.messageBus,this.assets=e.assets,this.initialized=!1,this.users=[],this.messageBus.toController("nav:controls",{controls:this._controls}),this.attachMessageBus(this.messageBus),this.on("stage:removed",this.destroy.bind(this))},initializeContent:function(){this.initialized||(this.initialized=!0,this.controllerState.showInactivePlayers?this.setScreen(new this.assets.PortalView):this.setScreen(new this.assets.PortalViewNoInactive),this.showInactivePlayers=this.controllerState.showInactivePlayers||!1,this.showInactivePlayers&&(this.connectedUsersContainer=new n.EaselJS.Placeholder(this.getScreen().connectedUsers),this.connectedUsers=new n.Controls.FloatContainer(function(e){return this.getUserIcon(e)}.bind(this),6),this.connectedUsersContainer.addChild(this.connectedUsers)),this.activeUsersContainer=new n.EaselJS.Placeholder(this.getScreen().activeUsers),this.activeUsers=new n.Controls.FloatContainer(function(e){return this.getUserIcon(e)}.bind(this),this.showInactivePlayers?6:12),this.activeUsersContainer.addChild(this.activeUsers),void 0!==this.getScreen().start&&(this.start=new n.Controls.Button(this.getScreen().start),this.start.setText(i.t("Start")),this.start.on("click",function(){this.messageBus.toController("start")}.bind(this)),this.addControl(this.start)),void 0!==this.getScreen().back&&(this.back=new n.Controls.Button(this.getScreen().back),this.back.setText(i.t("Back")),this.back.on("click",function(){this.messageBus.toController("back")}.bind(this)),this.addControl(this.back)),this.findPlaceholders("instructionHeader").forEach(function(e){e.addChild(new n.EaselJS.BigText(i.t("Instructions")))}),this.findPlaceholders("activePlayersHeader").forEach(function(e){e.addChild(new n.EaselJS.BigText(i.t("Active devices")))}),this.findPlaceholders("connectedPlayersHeader").forEach(function(e){e.addChild(new n.EaselJS.BigText(i.t("Connected devices")))}),this.instructionTexts=[],this.findPlaceholders("instructionText").forEach(function(e){var t=new n.EaselJS.BigText(this.getInstructionText());this.instructionTexts.push(t),e.addChild(t)}.bind(this)),this.activePlayerTexts=[],this.findPlaceholders("activePlayers").forEach(function(e){var t=new n.EaselJS.BigText(this.getActiveUsersText());this.activePlayerTexts.push(t),e.addChild(t)}.bind(this)))},attachMessageBus:function(e){e.addViewListener(this)},handleIncomingMessage:function(e,t){if(!o.handleMessage(e,t,this,"portal:"))switch(e){case"state:change":this.controllerState=t.state,this.initialized||this.initializeContent(),this.showCurrentAndMaxUsers();break;case"alert":this.alert(i.t(t.localized));break;case"users:update":this.users=t.users,this.refreshUsers();break;case"auth:open":this.addAuthenticationView();break;case"portal:destroy":this.destroy()}},getActiveUsersText:function(){return this.controllerState.activePlayers+"/"+this.controllerState.maxPlayers},getInstructionText:function(){return i.t(this.controllerState.connectInstructions)+"\n"+i.t(this.controllerState.startAndLoginInstructions)},getUserIcon:function(e){var t,i;return e?e.profile?(t=new this.assets.UserIconAuthenticated,this.addControllerIcon(t,e)):t=this.getControllerIcon(e):t=this.getControllerIcon(),e&&(i=t.PlayerColor)&&new n.EaselJS.Placeholder(i).addChild(new n.EaselJS.Fill(e.color)),e&&this.setUserDetails(t,e),t},addControllerIcon:function(e,t){var i;e.ControllerIcon&&(e=new n.EaselJS.Placeholder(e.ControllerIcon),i=this.getControllerIcon(t),e.addChild(i),i.scaleX=i.scaleY=.5,t)&&(e=i.PlayerColor)&&new n.EaselJS.Placeholder(e).addChild(new n.EaselJS.Fill(t.color))},getControllerIcon:function(e){if(e)switch(e.type){case"keyboard":return new this.assets.UserIconKeyboard;case"tablet":return new this.assets.UserIconTablet;case"phone":return new this.assets.UserIconPhone;case"gamepad":return new this.assets.UserIconGamepad}return new this.assets.UserIcon},loading:function(){},alert:function(e){alert(e)},refreshUsers:function(){this.showCurrentAndMaxUsers(),this.showInformation(),this.reloadUserIcons()},showCurrentAndMaxUsers:function(){this.getScreen().playercount&&(this.getScreen().playercount.text=this.controllerState.activePlayers+"/"+this.controllerState.maxPlayers),this.activePlayerTexts.forEach(function(e){e.setText(this.controllerState.activePlayers+"/"+this.controllerState.maxPlayers)}.bind(this)),this.getScreen().login&&(this.getScreen().login.text=i.t(this.controllerState.startAndLoginInstructions))},showInformation:function(){var e=i.t(this.controllerState.connectInstructions);this.getScreen().login?this.getScreen().login.text=i.t(this.controllerState.startAndLoginInstructions):e+="\n "+i.t(this.controllerState.startAndLoginInstructions),this.getScreen().token&&(this.getScreen().token.text=e),this.instructionTexts.forEach(function(e){e.setText(this.getInstructionText())}.bind(this))},removeAllUserIcons:function(){this.showInactivePlayers&&this.connectedUsers.removeAllChildren(),this.activeUsers.removeAllChildren()},reloadUserIcons:function(){var t=24,i=24;this.showInactivePlayers||(i=48),this.removeAllUserIcons(),this.users.forEach(function(e){e.active?i<=0||(i--,this.activeUsers.createElement(e)):!this.showInactivePlayers||t<=0||(t--,this.connectedUsers.createElement(e))}.bind(this))},setUserDetails:function(e,t){var i;t.profile&&e.userimage&&(i=new n.EaselJS.Placeholder(e.userimage),s.loadImage(t.profile.image).then(function(e){i.addChild(new n.EaselJS.Fill(e))}))},addAuthenticationView:function(){var e=this.Webcontrol.authenticationView(this.messageBus);this.el.addChild(e),e.on("view:close",function(){e.easelboneLayer.view.trigger("stage:removed"),this.el.removeChild(e),this.messageBus.toController("auth:close")}.bind(this))},render:function(){this.el.addChild(this.getScreen()),this.refreshUsers()},destroy:function(){this.messageBus.removeViewListener(this)}})}),define("CatLab/Webremote/CreateJS/Views/AuthenticationView",["easelbone","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/ImageLoader","CatLab/Webremote/Messages/NavigateableProxy","CatLab/Webremote/Controllers/OAuth2"],function(s,i,o,n,r){"use strict";return s.Views.Navigatable.extend({initialize:function(e){this.initializeNavigatable(),this.assets=e.assets,this.screen=new e.assets.Signin,this.screen.close.on("click",function(){this.close()}.bind(this)),this.linkAccount=new s.Controls.Button(this.screen.linkAccount),this.titlePlaceholder=null,this.explanationPlaceholder=null,s.Helpers.MovieClipHelper.findFromNames(["title"],[this.screen]).forEach(function(e){this.titlePlaceholder=new s.EaselJS.Placeholder(e)}.bind(this)),s.Helpers.MovieClipHelper.findFromNames(["explanation"],[this.screen]).forEach(function(e){this.explanationPlaceholder=new s.EaselJS.Placeholder(e)}.bind(this)),this.titlePlaceholder&&(t=new s.EaselJS.BigText(i.t("Select your profile"),null,null,"left"),this.titlePlaceholder.addChild(t)),this.setLoginUrlText(),this.linkAccount.on("click",function(){r.link(function(e){this.selectUser(e)}.bind(this))}.bind(this));var t=new s.Controls.ScrollArea(this.screen.accounts);this.users=new s.Controls.FloatContainer(function(e){return this.getUserObject(e)}.bind(this),4),t.content.addChild(this.users),this.updateUsers([]),this.on("removed",function(){this.trigger("close")}.bind(this)),this.setBack(function(){this.close()}.bind(this)),this.attachMessageBus(e.messageBus),this.on("stage:removed",this.destroy.bind(this))},attachMessageBus:function(e){(this.messageBus=e).addViewListener(this)},handleIncomingMessage:function(e,t){if(!n.handleMessage(e,t,this,"auth:"))switch(e){case"auth:users:update":this.updateUsers(t.users);break;case"auth:close":this.close();break;case"auth:loginurl":this.setLoginUrl(t.url);break;case"auth:destroy":this.destroy()}},updateUsers:function(e){this.resetOptions(),this.users.removeAllChildren();for(var t=0;t<e.length;t++)this.users.createElement(e[t]);this.addControl(this.linkAccount)},getUserObject:function(e){var t,i=new this.assets.UserModel,n=(i.namePlaceholder?i.text=i.namePlaceholder:i.name&&(i.text=i.name),new s.Controls.Button(i));return e&&(n.setText(e.name),t=new s.EaselJS.Placeholder(i.picture),o.loadImage(e.image).then(function(e){t.addChild(new s.EaselJS.Fill(e))}),n.on("click",function(){this.selectUser(e)}.bind(this)),this.addControl(n)),i},selectUser:function(e){this.messageBus.toController("auth:select-user",{user:{id:e.id}})},close:function(){this.trigger("close"),this.messageBus.toController("auth:close")},render:function(){this.el.addChild(this.screen)},setLoginUrl:function(e){this.loginUrl=e,this.setLoginUrlText()},setLoginUrlText:function(){var e;this.linkAccount&&(this.linkAccount.setText(i.t("Login to add profile")),this.explanationPlaceholder)&&(e=new s.EaselJS.BigText(i.t("Or surf to %s to login from your phone.",this.loginUrl)),this.explanationPlaceholder.removeAllChildren(),this.explanationPlaceholder.addChild(e))},destroy:function(){this.messageBus.removeViewListener(this)}})}),s=i=i||{},h=h||{},t=a=a||{},void 0!==t.Container&&(s.properties={width:720,height:480,fps:24,color:"#FFFFFF",manifest:[]},(s.UserIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#592230").s().p("Al2F2IAArsILsAAIAALsg"),this.shape.setTransform(37.5,37.5),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,75,75),e.frameBounds=[A],(s.TextPlaceholderBackground=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FF00FF").s().p("AnzHzIAAvmIPmAAIAAPmg"),this.shape.setTransform(50,50),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,100,100),e.frameBounds=[A],(s.Marker=function(){this.initialize()}).prototype=e=new t.Container,e.nominalBounds=A=null,e.frameBounds=[A],(s.PointerInactive=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#320B1F").s().p("AjQiRIENALICfCGIiTCHIkkALg"),this.shape.setTransform(-22,0),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-44,-14.7,44.1,29.4),e.frameBounds=[A],(s.PointerActive=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#006633").s().p("AjQiRIENALICfCGIiTCHIkkALg"),this.shape.setTransform(-22,.1),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-44,-14.6,44.1,29.4),e.frameBounds=[A],(s.Checkbox=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{Up:0,Over:1,Down:2,Hit:3}),this.frame_0=function(){this.stop()},this.frame_1=function(){this.stop()},this.frame_2=function(){this.stop()},this.frame_3=function(){this.stop()},this.timeline.addTween(t.Tween.get(this).call(this.frame_0).wait(1).call(this.frame_1).wait(1).call(this.frame_2).wait(1).call(this.frame_3).wait(1)),this.shape=new t.Shape,this.shape.graphics.f("#FF873C").s().p("AizAVQgagpgVgoIgXgsIADgQIADgEQAFgEAJgCQAKAZATAkQANAYASAdQAxBQAOAeQALg8CFhhIAIgGQCGhhA7AVIAGgCQAEACABAPQgmAPg/ApQgpAcgpAiQhQBChRBfQgngxguhPg"),this.shape.setTransform(25,23),this.shape._off=!0,this.timeline.addTween(t.Tween.get(this.shape).wait(2).to({_off:!1},0).wait(2)),this.shape_1=new t.Shape,this.shape_1.graphics.f().s("#8B504F").ss(5).p("ABfheIAAC9Ii9AAIAAi9g"),this.shape_1.setTransform(19.2,19.2,2.023,2.023),this.shape_2=new t.Shape,this.shape_2.graphics.f("#592230").s().p("AheBeIAAi8IC9AAIAAC8g"),this.shape_2.setTransform(19.2,19.2,2.023,2.023),this.shape_3=new t.Shape,this.shape_3.graphics.f("#FFC39F").s().p("AheBeIAAi8IC9AAIAAC8g"),this.shape_3.setTransform(19.2,19.2,2.023,2.023),this.shape_4=new t.Shape,this.shape_4.graphics.f().s("#8B504F").ss(5).p("ADAi/IAAF/Il/AAIAAl/g"),this.shape_4.setTransform(-13.2,12.3,1,1,0,0,0,-32.4,-6.9),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape_2},{t:this.shape_1,p:{x:19.2,y:19.2}}]}).to({state:[{t:this.shape_3,p:{x:19.2,y:19.2}},{t:this.shape_1,p:{x:19.2,y:19.2}}]},1).to({state:[{t:this.shape_2},{t:this.shape_1,p:{x:19.2,y:19.2}}]},1).to({state:[{t:this.shape_4},{t:this.shape_3,p:{x:19.4,y:18.9}},{t:this.shape_1,p:{x:19.4,y:18.9}}]},1).wait(1))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(-2.5,-2.5,43.5,43.4),e.frameBounds=[A,A,new t.Rectangle(-2.5,-2.5,52.5,43.4),new t.Rectangle(-2.5,-2.8,52.5,43.7)],(s.CogVector=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#282A1F").s().p("Ag/MAQgehhgLhlQgbgEgvgOIgkgNQgUgIgOgIQhLBKhXA3QgsgbgwgqQAkhoAvhQQgdgegUgdQgKgLgLgUIgUghQhpAQhlgGQgVg1gNg5QBOg4BhgtQgCgPgBgXIgCglQABgxAEgZQhggzhMg/QAIgiAchLQBoABBhAVQAZgtAQgTQAUgdAdgeQgshWgdhrQA9gwAhgTQBQA8BGBMQAOgIAUgIIAkgNQAvgNAbgFQAShsAlhbQAwgEBBAFQAeBhALBlQAbAFAvANIAkANQAUAIAOAIQBLhKBXg3QAsAbAwAqQgkBogvBQQAdAeAUAdQAQATAZAtQBpgQBlAGQAWA5AMA1QhOA4hhAtQAEAZABAxIgCAlQgBAXgCAPQBgAzBMA/QgHAigdBLQhogBhhgVQgZAtgQATQgUAdgdAeQAsBWAdBrQg9AwghATQhQg8hGhMQgOAIgUAIIgkANQgvAOgbAEQgSBsglBbQgXACgaAAQgdAAgjgDgAhtlTQg3ASgtAhQgvAiggAtQhDBagCB3QACB4BDBaQAgAtAvAiQAtAhA3ASQA1ASA4AAQA5AAA1gSQA3gSAtghQAvgiAggtQBDhaACh4QgCh3hDhaQgggtgvgiQgtghg3gSQg1gRg5AAQg4AAg1ARg"),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-75,-77.1,150.1,154.3),e.frameBounds=[A],(s.ListUsers=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#00CCFF").s().p("A5DK/IAA19MAyHAAAIAAV9g"),this.shape.setTransform(158.5,71),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-2,.6,320.9,140.7),e.frameBounds=[A],(s.lstUsers=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#0066CC").s().p("A5YGoIAAtQMAywAAAIAANQg"),this.shape.setTransform(162.5,42.5),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,325,85),e.frameBounds=[A],(s.SmartphoneIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FFFFFF").s().p("AhNCvQgJAAgHgIQgHgGAAgKIAAksQAAgLAHgGQAHgIAJAAICaAAQAKAAAHAIQAHAGAAALIAAEsQAAAKgHAGQgHAIgKAAgAgHCPQgEADAAAFQAAAFAEADQAEAEADAAQAEAAAEgEQADgDAAgFQAAgFgDgDQgEgDgEAAQgDAAgEADgAhUCDICoAAIAAkLIioAAgAgaiaQAAABAAABQAAAAAAABQABAAAAAAQABABABAAIAwAAQAAAAABgBQAAAAAAAAQABgBAAAAQAAgBAAgBQAAAAAAgBQAAAAgBAAQAAgBAAAAQgBAAAAAAIgwAAQgBAAgBAAQAAAAgBABQAAAAAAAAQAAABAAAAg"),this.shape.setTransform(42.9,42,1.857,1.857),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(24.1,9.5,37.7,65),e.frameBounds=[A],(s.TabletIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FFFFFF").s().p("AhvCeQgKAAgHgHQgGgHAAgJIAAkNQAAgKAGgGQAHgHAKAAIDfAAQAKAAAGAHQAHAHAAAJIAAENQAAAJgHAHQgGAHgKAAgAgeCLIA8AAIAAgHIg8AAgAhvBuIDfAAIAAjvIjfAAg"),this.shape.setTransform(43,43,1.642,1.642),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(20.8,17,44.6,52.1),e.frameBounds=[A],(s.JoystickIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FFFFFF").s().p("AA1BaQgYgagdABQgdgBgYAaQgYAZgNAAQgMAAgIgMQgIgMgBgUQABgqAVggQAUgeAVAAQANAAANAIQAOAJAIACQACgXALgPQASgVAlgBQAYAAALgOQAEgHAAgJQAAgKALAAQADABADACQAEAEAAADQAAASgNAOQgQASgfABQgsAAgGAmQAGgBAQgJQAMgJANABQAUAAAUAeQAXAgAAAqQgBAVgIAMQgJALgMAAQgMAAgZgZgAAzAuQgEAEAAAFQAAAFADAEQAEADAGAAQAFABADgEQAEgEAAgFQAAgFgEgEQgEgEgEgBQgFABgEAEgAhZAtIAVAAIAAAUIAUAAIAAgUIATAAIAAgUIgTAAIAAgVIgUAAIAAAVIgVAAgABGAaQgDADAAAGQAAAFADAEQAFADAEAAQAFAAAEgDQAEgFAAgEQAAgGgEgDQgEgFgFAAQgEAAgFAFgAAeAaQgEADAAAGQAAAFAEAEQAEADAFAAQAGAAADgDQAEgEAAgFQAAgGgDgDQgFgFgEAAQgFAAgFAFgAAyAFQgDAFAAAEQAAAGAEAEQAEAEAFAAQAEAAAEgEQAEgEAAgGQAAgEgEgFQgEgEgEAAQgGAAgEAEg"),this.shape.setTransform(42,42,2.476,2.476),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(12.3,13.5,59.5,57),e.frameBounds=[A],(s.KeyboardIcon=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f("#FFFFFF").s().p("AkMEzQgiAAgXgWQgYgXAAgjIAAjYQAAggAYgXQAXgXAiAAID3AAQAAhLAkgeQAWgTA0gHQApgFAOgLQAUgRAAg1QAAgWAXAAQAXAAABAWQAABOgoAeQgWASg1AHQgpAGgOAKQgUAQAAA0ID2AAQAjAAAWAXQAZAXAAAgIAADYQAAAjgZAXQgWAWgjAAgADWDjIA1AAIAAg1Ig1AAgAi8DjIF3AAIAAg1Il3AAgAkMDjIA1AAIAAg1Ig1AAgACgCTIA2AAIAAg4Ig2AAgABQCTIA1AAIAAg4Ig1AAgAAACTIA1AAIAAg4Ig1AAgAhRCTIA2AAIAAg4Ig2AAgAihCTIA1AAIAAg4Ig1AAgAjyCTIA2AAIAAg4Ig2AAgADWBBIA1AAIAAg2Ig1AAgACFBBIA2AAIAAg2Ig2AAgAA1BBIA1AAIAAg2Ig1AAgAgbBBIA1AAIAAg2Ig1AAgAhsBBIA2AAIAAg2Ig2AAgAi8BBIA2AAIAAg2Ig2AAgAkMBBIA1AAIAAg2Ig1AAg"),this.shape.setTransform(42,41.8,.773,.773),this.addChild(this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(15,18,54.1,47.6),e.frameBounds=[A],(s.CloseButton=function(){this.initialize(),this.shape=new t.Shape,this.shape.graphics.f().s("#000000").ss(1,1,1).p("AAPABQAjgvAAgXQAhhJAIgLAhjiQIByCRAiICaIBLAAQAjhXAgg2QAFgGAEgGIB6CZ"),this.shape.setTransform(10,19.5),this.shape_1=new t.Shape,this.shape_1.graphics.f("#666666").s().p("Ai+C/IAAl9IF9AAIAAF9g"),this.shape_1.setTransform(12.6,19.4),this.addChild(this.shape_1,this.shape)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-6.6,.3,38.3,38.3),e.frameBounds=[A],(s.btnLink=function(){this.initialize(),this.text=new t.Text("Link a new account","20px 'Times New Roman'","#FF0033"),this.text.lineHeight=22,this.text.lineWidth=235,this.text.setTransform(2.3,-1.7),this.shape=new t.Shape,this.shape.graphics.f("#666666").s("#FFFFFF").ss(1,1,1).dr(-83.5,-13,167,26),this.shape.setTransform(83.5,13),this.addChild(this.shape,this.text)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-1,-1.7,242.5,28.7),e.frameBounds=[A],(s.Placeholder=function(){this.initialize(),this.instance=new s.TextPlaceholderBackground,this.addChild(this.instance)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,100,100),e.frameBounds=[A],(s.Pointer=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{Up:0,Over:1,Down:2,Out:3}),this.instance=new s.PointerInactive("synched",0,!1),this.instance.setTransform(3,5,.639,.774,90,0,0,7.8,-3.9),this.instance_1=new s.PointerActive("synched",0),this.instance_1.setTransform(3,5,.639,.774,90,0,0,7.8,-3.9),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.instance}]}).to({state:[{t:this.instance_1,p:{x:3,y:5}}]},1).to({state:[{t:this.instance_1,p:{x:3,y:5}}]},1).to({state:[{t:this.instance_1,p:{x:3.1,y:5.1}}]},1).wait(1))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(-11.4,-28.1,22.8,28.2),e.frameBounds=[A,A,A,new t.Rectangle(-11.4,-28,22.8,28.2)],(s.Button=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{Over:1,"Over-NoAnim":6,Up:7,"Up-NoAnim":11,Down:12,Hit:13}),this.frame_0=function(){this.stop()},this.frame_6=function(){this.stop()},this.frame_11=function(){this.stop()},this.frame_12=function(){this.stop()},this.frame_13=function(){this.stop()},this.timeline.addTween(t.Tween.get(this).call(this.frame_0).wait(6).call(this.frame_6).wait(5).call(this.frame_11).wait(1).call(this.frame_12).wait(1).call(this.frame_13).wait(1)),this.text=new s.Placeholder,this.text.setTransform(13.7,13.7,1.739,.494,0,.4,.5,.1,.8),this.timeline.addTween(t.Tween.get(this.text).wait(1).to({scaleX:1.89,rotation:.4,skewX:0,skewY:0,x:5.7},0).to({scaleY:.57,rotation:5.4,x:8.7,y:1.7},5).to({scaleY:.54,rotation:5.2,x:8.4,y:2},1).to({scaleY:.49,rotation:.4,x:5.7,y:13.7},4).wait(1).to({rotation:.4},0).wait(2)),this.shape=new t.Shape,this.shape.graphics.f("#0F0609").s().p("A42D+Ii+oDMA3pgAIIkyIbg"),this.shape.setTransform(103.3,39.2,.566,1),this.shape_1=new t.Shape,this.shape_1.graphics.f("#0F0609").s().p("AxBE1IiBp0MAmGgAKIjSKTg"),this.shape_1.setTransform(103.4,39.1,.821,.821),this.shape_2=new t.Shape,this.shape_2.graphics.f("#0F0609").s().p("AuwDkIhboZMAgWABDIjGIog"),this.shape_2.setTransform(104.2,39.3),this.shape_3=new t.Shape,this.shape_3.graphics.f("#0F0609").s().p("AvXDTIhOoqMAhLAB9IjaIyg"),this.shape_3.setTransform(104.8,39),this.shape_4=new t.Shape,this.shape_4.graphics.f("#0F0609").s().p("AvzDHIhFo2MAhxACmIjpI5g"),this.shape_4.setTransform(105.2,38.9),this.shape_5=new t.Shape,this.shape_5.graphics.f("#0F0609").s().p("AwEDAIhAo+MAiJADAIjyI9g"),this.shape_5.setTransform(105.5,38.7),this.shape_6=new t.Shape,this.shape_6.graphics.f("#0F0507").s().p("AvmDNIhKoxMAhhACUIjiI1g"),this.shape_6.setTransform(105,38.9),this.shape_7=new t.Shape,this.shape_7.graphics.f("#0F0305").s().p("AvDDbIhVohMAgxABgIjRItg"),this.shape_7.setTransform(104.5,39.2),this.shape_8=new t.Shape,this.shape_8.graphics.f("#0F0202").s().p("AugDrIhgoTMAgBAAsIi+Ikg"),this.shape_8.setTransform(103.9,39.4),this.shape_9=new t.Shape,this.shape_9.graphics.f("#0F0000").s().p("At9D+IhroDIfRgIIisIbg"),this.shape_9.setTransform(103.4,39.2),this.shape_10=new t.Shape,this.shape_10.graphics.f("#990000").s().p("AxBE1IiBp0MAmGgAKIjSKTg"),this.shape_10.setTransform(103.4,39.1,.821,.821),this.shape_11=new t.Shape,this.shape_11.graphics.f("#0F51B8").s().p("AxBE1IiBp0MAmGgAKIjSKTg"),this.shape_11.setTransform(103.4,39.1,.821,.821),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape}]}).to({state:[{t:this.shape_1,p:{scaleX:.821,scaleY:.821,rotation:0,x:103.4,y:39.1}}]},1).to({state:[{t:this.shape_2}]},1).to({state:[{t:this.shape_3}]},1).to({state:[{t:this.shape_4}]},1).to({state:[{t:this.shape_5}]},1).to({state:[{t:this.shape_1,p:{scaleX:.903,scaleY:.903,rotation:5.4,x:102.8,y:39.2}}]},1).to({state:[{t:this.shape_1,p:{scaleX:.903,scaleY:.903,rotation:5.4,x:102.8,y:39.2}}]},1).to({state:[{t:this.shape_6}]},1).to({state:[{t:this.shape_7}]},1).to({state:[{t:this.shape_8}]},1).to({state:[{t:this.shape_9}]},1).to({state:[{t:this.shape_10}]},1).to({state:[{t:this.shape_11}]},1).wait(1)),this.shape_12=new t.Shape,this.shape_12.graphics.f().s("#0F0609").ss(2).p("ATyluMgnlAAPIB4LOMAi0gAUg"),this.shape_12.setTransform(103.9,39.4,.826,.821,0,0,0,-.2,0),this.shape_13=new t.Shape,this.shape_13.graphics.f().s("#0A6006").ss(2).p("Aw0kaMAhpgAsIiVJgI9lAtg"),this.shape_13.setTransform(103.5,39.3,1,1,0,0,0,.1,0),this.shape_14=new t.Shape,this.shape_14.graphics.f().s("#05A503").ss(2).p("AxSkVMAikgBFIiSJyI+ZBDg"),this.shape_14.setTransform(103.1,39.2,1,1,0,0,0,.1,0),this.shape_15=new t.Shape,this.shape_15.graphics.f().s("#02D701").ss(2).p("AxmkRMAjNgBYIiQKAI+9BTg"),this.shape_15.setTransform(102.7,39.2,1,1,0,0,0,.1,0),this.shape_16=new t.Shape,this.shape_16.graphics.f().s("#01F500").ss(2).p("AxykPMAjlgBiIiOKHI/UBdg"),this.shape_16.setTransform(102.5,39.1,1,1,0,0,0,.1,0),this.shape_17=new t.Shape,this.shape_17.graphics.f().s("#00FF00").ss(2).p("ATyluMgnlAAPIB4LOMAi0gAUg"),this.shape_17.setTransform(103.4,39.4,.903,.903,-2.2,0,0,-.2,0),this.shape_18=new t.Shape,this.shape_18.graphics.f().s("#0FFF00").ss(2).p("ATyluMgnlAAPIB4LOMAi0gAUg"),this.shape_18.setTransform(103.4,39.4,.903,.903,-2.2,0,0,-.2,0),this.shape_19=new t.Shape,this.shape_19.graphics.f().s("#0FC102").ss(2).p("AxdkTMAi6gBPIiQJ6I+uBMg"),this.shape_19.setTransform(102.9,39.2,1,1,0,0,0,.1,0),this.shape_20=new t.Shape,this.shape_20.graphics.f().s("#0F8305").ss(2).p("AxDkXMAiGgA5IiTJpI9/A4g"),this.shape_20.setTransform(103.3,39.3,1,1,0,0,0,.1,0),this.shape_21=new t.Shape,this.shape_21.graphics.f().s("#0F4407").ss(2).p("AwpkbMAhSgAjIiVJZI9SAkg"),this.shape_21.setTransform(103.7,39.3,1,1,0,0,0,.1,0),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape_12}]}).to({state:[{t:this.shape_12}]},1).to({state:[{t:this.shape_13}]},1).to({state:[{t:this.shape_14}]},1).to({state:[{t:this.shape_15}]},1).to({state:[{t:this.shape_16}]},1).to({state:[{t:this.shape_17}]},1).to({state:[{t:this.shape_18}]},1).to({state:[{t:this.shape_19}]},1).to({state:[{t:this.shape_20}]},1).to({state:[{t:this.shape_21}]},1).to({state:[{t:this.shape_12}]},1).to({state:[{t:this.shape_12}]},1).to({state:[{t:this.shape_12}]},1).wait(1)),this.timeline.addTween(t.Tween.get(this.shape_12).wait(1).to({scaleX:.82},0).to({_off:!0},1).wait(9).to({_off:!1},0).wait(3)),this.shape_22=new t.Shape,this.shape_22.graphics.f("#592230").s().p("A0sFHIAysmMAonACoIloMXg"),this.shape_22.setTransform(109.6,39.4,.826,.821),this.shape_23=new t.Shape,this.shape_23.graphics.f("#592230").s().p("AxqECIA4qsMAidAC7Ik/Kag"),this.shape_23.setTransform(109.5,39.1),this.shape_24=new t.Shape,this.shape_24.graphics.f("#592230").s().p("AyMD5IBDq8MAjXADgIlTKng"),this.shape_24.setTransform(109.6,38.9),this.shape_25=new t.Shape,this.shape_25.graphics.f("#592230").s().p("AylD0IBMrKMAj/AD8IlfKxg"),this.shape_25.setTransform(109.5,38.8),this.shape_26=new t.Shape,this.shape_26.graphics.f("#592230").s().p("Ay0DwIBRrRMAkYAEMIlnK3g"),this.shape_26.setTransform(109.5,38.7),this.shape_27=new t.Shape,this.shape_27.graphics.f("#592230").s().p("AyaD2IBIrEMAjtADwIlZKsg"),this.shape_27.setTransform(109.6,38.9),this.shape_28=new t.Shape,this.shape_28.graphics.f("#592230").s().p("Ax7D9IA9q0MAi7ADOIlKKhg"),this.shape_28.setTransform(109.6,39.1),this.shape_29=new t.Shape,this.shape_29.graphics.f("#592230").s().p("AxdEFIA0qlMAiGACsIk3KVg"),this.shape_29.setTransform(109.6,39.2),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape_22}]}).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_23}]},1).to({state:[{t:this.shape_24}]},1).to({state:[{t:this.shape_25}]},1).to({state:[{t:this.shape_26}]},1).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_27}]},1).to({state:[{t:this.shape_28}]},1).to({state:[{t:this.shape_29}]},1).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_22}]},1).to({state:[{t:this.shape_22}]},1).wait(1)),this.timeline.addTween(t.Tween.get(this.shape_22).wait(1).to({scaleX:.82,x:109.5},0).to({_off:!0},1).wait(4).to({_off:!1,scaleX:.9,scaleY:.9,rotation:3,x:109.6},0).wait(1).to({_off:!0},1).wait(3).to({_off:!1,scaleX:.82,scaleY:.82,rotation:0,x:109.5},0).wait(3))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(-1.8,0,220.9,78.8),e.frameBounds=[A,new t.Rectangle(-1.1,0,219.5,78.8),new t.Rectangle(-5.5,-3.6,228.3,85.4),new t.Rectangle(-8.9,-6.3,235.1,90.6),new t.Rectangle(-11.3,-8.3,240,94.3),new t.Rectangle(-12.8,-9.5,242.9,96.5),A=new t.Rectangle(-13.3,-9.9,243.9,97.2),A,new t.Rectangle(-10.2,-7.4,237.8,92.6),new t.Rectangle(-7.2,-4.9,231.7,88),new t.Rectangle(-4.1,-2.5,225.5,83.4),A=new t.Rectangle(-1.1,0,219.5,78.8),A,A],(s.Cog=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{}),this.frame_14=function(){this.gotoAndPlay(1)},this.timeline.addTween(t.Tween.get(this).wait(14).call(this.frame_14).wait(1)),this.instance=new s.CogVector("synched",0),this.instance.setTransform(75.1,77.1),this.timeline.addTween(t.Tween.get(this.instance).to({rotation:36},14).wait(1))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(0,0,150.2,154.3),e.frameBounds=[A,new t.Rectangle(-.6,.1,151.6,154.2),new t.Rectangle(-1.2,.1,152.7,154.1),new t.Rectangle(-1.6,.3,153.5,153.8),new t.Rectangle(-1.9,.6,154,153.1),new t.Rectangle(-2,1.1,154.1,152.1),new t.Rectangle(-2,1.7,154.1,151),new t.Rectangle(-2,2.2,154.1,149.9),new t.Rectangle(-2,1.5,154.1,151.3),new t.Rectangle(-2,1,154.1,152.4),new t.Rectangle(-1.8,.6,153.8,153.3),new t.Rectangle(-1.4,.2,153,153.8),new t.Rectangle(-1,.2,152.2,154),new t.Rectangle(-.4,.2,150.9,154),new t.Rectangle(0,.1,150.2,154.1)],(s.Signin=function(){this.initialize(),this.close=new s.CloseButton,this.close.setTransform(526.3,132.5,1,1,0,0,0,10,19.5),this.users=new s.ListUsers,this.users.setTransform(206.7,159.2);var e=new t.Shape;e._off=!0,e.graphics.p("A4tIoIAAsrMAypAAAIAAMrg"),e.setTransform(166.1,55.3),this.btnLinkAccount=new s.btnLink,this.btnLinkAccount.setTransform(367.6,325.3,1,1,0,0,0,83.5,13),this.title=new t.Text("Select your profile","20px 'Times New Roman'","#FFFFFF"),this.title.name="title",this.title.lineHeight=22,this.title.lineWidth=217,this.title.setTransform(202.8,116.1),this.shape=new t.Shape,this.shape.graphics.f("#999999").s().p("A68SPMAAAgkdMA15AAAMAAAAkdg"),this.shape.setTransform(367.5,229.7),this.shape_1=new t.Shape,this.shape_1.graphics.f("rgba(0,0,0,0.498)").s().p("Eg4TAlfMAAAhK9MBwnAAAMAAABK9g"),this.shape_1.setTransform(359.5,240),this.addChild(this.shape_1,this.shape,this.title,this.btnLinkAccount,this.users,this.close)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(-1,0,721,480),e.frameBounds=[A],(s.PortalView=function(){this.initialize(),this.ListActiveUsers=new s.lstUsers,this.ListActiveUsers.setTransform(523.3,139.8,1,1,0,0,0,162.2,42),this.ListConnectedDevices=new s.lstUsers,this.ListConnectedDevices.setTransform(190.3,139.8,1,1,0,0,0,163.3,42),this.shape=new t.Shape,this.shape.graphics.f().s("rgba(255,255,255,0)").ss(.1,1,1).p("AvJkmIeTAAIAAJNI+TAAg"),this.shape.setTransform(327,308.5),this.text=new t.Text("Active users","30px 'Times New Roman'","#FFFFFF"),this.text.lineHeight=32,this.text.lineWidth=284,this.text.setTransform(374,25.3),this.text_1=new t.Text("Connected users","30px 'Times New Roman'","#FFFFFF"),this.text_1.lineHeight=32,this.text_1.lineWidth=284,this.text_1.setTransform(27,25.3),this.shape_1=new t.Shape,this.shape_1.graphics.f().s("#666666").ss(1,1,1).p("EgzYAAAMBmyAAA"),this.shape_1.setTransform(357.1,65),this.shape_2=new t.Shape,this.shape_2.graphics.rf(["#333333","#000000","#000000"],[0,.6,1],0,0,0,0,0,432.7).s().p("Eg4PAlfMAAAhK+MBwfAAAMAAABK+gEAy8gbVMhmyAAAg"),this.shape_2.setTransform(360,240),this.addChild(this.shape_2,this.shape_1,this.text_1,this.text,this.shape,this.ListConnectedDevices,this.ListActiveUsers)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,720,480),e.frameBounds=[A],(s.User=function(){this.initialize(),this.boundary=new s.Marker,this.boundary.setTransform(79.4,118.4),this.picture=new s.Placeholder,this.picture.setTransform(37.5,37.5,.75,.75,0,0,0,50,50),this.name=new t.Text("User","15px 'Times New Roman'"),this.name.name="name",this.name.lineHeight=17,this.name.lineWidth=71,this.name.setTransform(0,75),this.shape=new t.Shape,this.shape.graphics.f("rgba(0,0,0,0.498)").s().p("Al2F2IAArsILsAAIAALsg"),this.shape.setTransform(37.5,37.5),this.addChild(this.shape,this.name,this.picture,this.boundary)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(0,0,75,114.2),e.frameBounds=[A],(s.Slider=function(e,i,n){this.initialize(e,i,n=null==n?!1:n,{Up:0,Over:1,Down:2,Hit:3}),this.frame_0=function(){this.pointer.gotoAndStop("Up"),this.stop()},this.frame_1=function(){this.stop(),this.pointer.gotoAndStop("Over")},this.frame_2=function(){this.stop(),this.pointer.gotoAndStop("Down")},this.frame_3=function(){this.stop(),this.pointer.gotoAndStop("Out")},this.timeline.addTween(t.Tween.get(this).call(this.frame_0).wait(1).call(this.frame_1).wait(1).call(this.frame_2).wait(1).call(this.frame_3).wait(1)),this.pointer=new s.Pointer,this.pointer.setTransform(35,41.1,1,1,0,0,0,0,2),this.maximum=new s.Marker,this.maximum.setTransform(342,35),this.minimum=new s.Marker,this.minimum.setTransform(35,41),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.minimum},{t:this.maximum},{t:this.pointer}]}).wait(4)),this.shape=new t.Shape,this.shape.graphics.f().s("#320B1F").ss(4).p("AgY4mMAAxAxN"),this.shape.setTransform(186,26.5,1.113,1.111,-90,0,0,.1,0),this.shape_1=new t.Shape,this.shape_1.graphics.f("#320B1F").s().p("AgnAoQgQgRAAgXQAAgWAQgRQARgQAWAAQAXAAARAQQAQARAAAWQAAAXgQARQgRAQgXAAQgWAAgRgQg"),this.shape_1.setTransform(9.6,31.4,1.694,1.694,-90),this.shape_2=new t.Shape,this.shape_2.graphics.f("#320B1F").s().p("AgkAlQgQgPAAgWQAAgUAQgQQAPgQAVAAQAVAAAQAQQAQAQAAAUQAAAWgQAPQgQAQgVAAQgVAAgPgQg"),this.shape_2.setTransform(370.1,24,1.694,1.694,-90),this.timeline.addTween(t.Tween.get({}).to({state:[{t:this.shape_2},{t:this.shape_1},{t:this.shape}]}).to({state:[{t:this.shape_2},{t:this.shape_1},{t:this.shape}]},1).to({state:[{t:this.shape_2},{t:this.shape_1},{t:this.shape}]},1).to({state:[{t:this.shape_2},{t:this.shape_1},{t:this.shape}]},1).wait(1))}).prototype=e=new t.MovieClip,e.nominalBounds=A=new t.Rectangle(0,10.9,379.1,30.1),e.frameBounds=[A,A,A,A],(s.portal=function(){this.initialize(),this.instance=new s.Signin,this.instance.setTransform(172.5,116.7,1,1,0,0,0,172.5,116.7),this.addChild(this.instance)}).prototype=e=new t.Container,e.nominalBounds=A=new t.Rectangle(359,240,721,480),e.frameBounds=[A]),define("CatLab/Webremote/assets/createjsassets",function(e){return function(){return e.ctlbrmtassets}}(this)),define("CatLab/Webremote/ViewFactory/CreatejsViewFactory",["CatLab/Webremote/Tools/Deferred"],function(t){"use strict";function e(e){void 0!==e&&this.setAssets(e)}var o,r,a,i=e.prototype;return i.initialize=function(){var e=new t;return this.loadAssets().then(function(){this.setAssets(this.assets),e.resolve()}.bind(this)),e},i.loadAssets=function(){var s=new t;return require(["CatLab/Webremote/CreateJS/LayerContainer","CatLab/Webremote/CreateJS/Views/PortalView","CatLab/Webremote/CreateJS/Views/AuthenticationView","CatLab/Webremote/assets/createjsassets"],function(e,t,i,n){o=e,r=t,a=i,s.resolve()}.bind(this)),s.promise()},i.portal=function(e){return e.assets=this.assets,new r(e)},i.authentication=function(e){return e.assets=this.assets,new a(e)},i.setAssets=function(e){void 0!==e&&(this.assets=e)},i.getContainer=function(){var e=new o;return e.setBounds(0,0,this.assets.properties.width,this.assets.properties.height),e.loading(),e},e}),define("CatLab/Webremote/FrontController",["CatLab/Webremote/Config","CatLab/Webremote/Polyfills","CatLab/Webremote/Tools/Tracker","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Controllers/Webremote","CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Controllers/Webcontrol","CatLab/Webremote/Tools/Smileys","CatLab/Webremote/Models/Users/KeyboardUser","CatLab/Webremote/Models/Users/CordovaUser","CatLab/Webremote/Models/Users/AndroidRemoteUser","CatLab/Webremote/Models/Users/DummyUser","CatLab/Webremote/Providers/SocketIO","CatLab/Webremote/Providers/Airconsole","CatLab/Webremote/Providers/Dummy","CatLab/Webremote/ViewFactory/ViewFactory","CatLab/Webremote/ViewFactory/CreatejsViewFactory","CatLab/Webremote/Messages/NavigateableProxy"],function(t,e,i,n,s,o,r,a,h,l,c,u,d,p,f,g,m,v){return{Config:function(e){t.set(e)},Tracker:i,Tools:n,Webremote:new s,Webcontrol:new r,OAuth2:o,Controls:{Keyboard:h,Cordova:l,AndroidRemote:c,Dummy:u},Controllers:{Webcontrol:r,Webremote:s},Models:{User:u},Providers:{SocketIO:d,Airconsole:p,Dummy:f},ViewFactories:{HtmlViewFactory:g,CreatejsViewFactory:m},Smileys:a,NavigateableProxy:v}}),define("catlabremote",["CatLab/Webremote/FrontController"],function(e){return e}),define("CatLab/EaselHacks/AlphaMaskFilter",[],function(e){function t(e){var n=this;this.createjs=e,Object.defineProperty(e.DisplayObject.prototype,"mask",{get:function(){return this.forceMask},set:function(e){var t,i=this;e?(i.originalMask=e,t=n.getFilterFromMask(e,i),i.filters=[t],i.cache(0,0,500,500)):null!==e&&(i.filters=null,i.cache(0,0,500,500))}}),e.DisplayObject.prototype.setMask=function(e){this.forceMask=e}}return t.prototype.getFilterFromMask=function(e,t){var i=this.createjs,n=e.graphics.getInstructions(),s=new i.Graphics;s.beginFill("#000000"),s.beginStroke("#000000");for(var o=0;o<n.length;o++)s.append(n[o]);e.graphics=s;var r=new i.Container,e=(r.addChild(e),r.scaleX=1/t.scaleX,r.scaleY=1/t.scaleY,r.y=-t.y,r.x=-t.x,new i.Container);return e.addChild(r),e.cache(0,0,1e3,1e3),new i.AlphaMaskFilter(e.cacheCanvas)},t}),define("CatLab/EaselHacks/FrontController",["CatLab/EaselHacks/AlphaMaskFilter"],function(e){return{AlphaMaskFilter:e}}),define("easelhacks",["CatLab/EaselHacks/FrontController"],function(e){return e}),define("CatLab/Webremote/Hacks",["easelhacks","easeljs"],function(e,t){new e.AlphaMaskFilter(t)});