catlab-remote-client 1.0.52 → 1.0.54
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(t,e,i){var n=new XMLHttpRequest;n.onreadystatechange=function(){n.readyState===XMLHttpRequest.DONE&&200===n.status&&e&&e(JSON.parse(n.responseText))},n.onerror=function(t){t&&i(n,t)},n.open("GET",t,!0),n.send()}}}),define("CatLab/Webremote/Tools/Deferred",[],function(){function l(t){return"[object Array]"===Object.prototype.toString.call(t)}function c(t,e){if(l(t))for(var i=0;i<t.length;i++)e(t[i]);else e(t)}function u(t){var n="pending",s=[],o=[],r=[],a=null,i={done:function(){for(var t=0;t<arguments.length;t++)if(arguments[t])if(l(arguments[t]))for(var e=arguments[t],i=0;i<e.length;i++)"resolved"===n&&e[i].apply(this,a),s.push(e[i]);else"resolved"===n&&arguments[t].apply(this,a),s.push(arguments[t]);return this},fail:function(){for(var t=0;t<arguments.length;t++)if(arguments[t])if(l(arguments[t]))for(var e=arguments[t],i=0;i<e.length;i++)"rejected"===n&&e[i].apply(this,a),o.push(e[i]);else"rejected"===n&&arguments[t].apply(this,a),o.push(arguments[t]);return this},always:function(){return this.done.apply(this,arguments).fail.apply(this,arguments)},progress:function(){for(var t=0;t<arguments.length;t++)if(arguments[t])if(l(arguments[t]))for(var e=arguments[t],i=0;i<e.length;i++)"pending"===n&&r.push(e[i]);else"pending"===n&&r.push(arguments[t]);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(t){if(null==t)return i;for(var e in i)t[e]=i[e];return t},state:function(){return n},debug:function(){console.log("[debug]",s,o,n)},isRejected:function(){return"rejected"===n},isResolved:function(){return"resolved"===n},pipe:function(t,e,i){return u(function(i){c(t,function(e){"function"==typeof e?h.done(function(){var t=e.apply(this,arguments);t&&"function"==typeof t?t.promise().then(i.resolve,i.reject,i.notify):i.resolve(t)}):h.done(i.resolve)}),c(e,function(e){"function"==typeof e?h.fail(function(){var t=e.apply(this,arguments);t&&"function"==typeof t?t.promise().then(i.resolve,i.reject,i.notify):i.reject(t)}):h.fail(i.reject)})}).promise()}},h={resolveWith:function(t){if("pending"===n){n="resolved";for(var e=a=1<arguments.length?arguments[1]:[],i=0;i<s.length;i++)s[i].apply(t,e)}return this},rejectWith:function(t){if("pending"===n){n="rejected";for(var e=a=1<arguments.length?arguments[1]:[],i=0;i<o.length;i++)o[i].apply(t,e)}return this},notifyWith:function(t){if("pending"===n)for(var e=a=1<arguments.length?arguments[1]:[],i=0;i<r.length;i++)r[i].apply(t,e);return this},resolve:function(){return this.resolveWith(this,arguments)},reject:function(){return this.rejectWith(this,arguments)},notify:function(){return this.notifyWith(this,arguments)}},e=i.promise(h);return t&&t.apply(e,[e]),e}return u.when=function(){var t;if(arguments.length<2)return((t=arguments.length?arguments[0]:void 0)&&"function"==typeof t.isResolved&&"function"==typeof t.isRejected?t:u().resolve(t)).promise();for(var i=arguments,n=u(),s=i.length,o=0,r=new Array(s),e=0;e<i.length;e++)!function(t){var e;i[t].done?i[t].done(function(){r[t]=arguments.length<2?arguments[0]:arguments,++o==s&&n.resolve.apply(n,r)}).fail(function(){n.reject(arguments)}):(e=i[t],i[t]=new Deferred,i[t].done(function(){r[t]=arguments.length<2?arguments[0]:arguments,++o==s&&n.resolve.apply(n,r)}).fail(function(){n.reject(arguments)}).resolve(e))}(e);return n.promise()},u}),define("CatLab/Webremote/Collections/ServerList",["CatLab/Webremote/Tools/Deferred"],function(s){"use strict";function t(t,e){this.defaultId=t.default,this.servers=t.servers,this.connectUrl=t.connectUrl,this.selectedServerId=null,this.preferredServer=e,this.assetsUrl=t.assetsUrl}var e=t.prototype;return e.getFromToken=function(t){if(t.length<8)return{host:this.getDefault().host,token:t};var e=t.substr(0,2);if(e){e=this.getFromId(e);if(e)return{host:e.host,token:t.substr(2)}}throw new Error("Code does not correspondent to any servers.")},e.getSelectedServer=function(){var e=new s;return this.selectedServerId?this.getFromId(this.selectedServerId)?e.resolve(this.getFromId(this.selectedServerId).host):e.reject("Selected remote server not found in server list. Please make sure you are connected to the right network."):this.selectBestServer().then(function(t){this.selectedServerId||(this.selectServer(t.id),e.resolve(t.host))}.bind(this)),e.promise()},e.selectBestServer=function(){var i=new s;if(this.preferredServer)for(var t=0;t<this.servers.length;t++)if(this.servers[t].id==this.preferredServer)return i.resolve(this.servers[t]),i.promise();var n=!1;return this.servers.forEach(function(e){e.discoverable&&this.measureRequestSpeed("https://"+e.host+"/info").then(function(t){console.log("[ServerList] "+e.host+" took "+t+"ms"),n||(n=!0,i.resolve(e))}.bind(this))}.bind(this)),i.promise()},e.selectServer=function(t){this.selectedServerId=t},e.measureRequestSpeed=function(t){var e=new Date,i=new s,n=new XMLHttpRequest;return n.onreadystatechange=function(){var t;4==this.readyState&&200==this.status&&(t=(new Date).getTime()-e.getTime(),i.resolve(t))},n.open("GET",t),n.send(),i.promise()},e.getConnectURL=function(){if(this.selectedServerId){var t=this.getFromId(this.selectedServerId);if(t.connectUrl)return t.connectUrl}return this.connectUrl},e.getAssetURL=function(){var t;return this.assetsUrl||((t=this.getConnectURL())?("http"!==t.substring(0,4)&&(t="https://"+t),this.assetsUrl=t+"/assets/",this.assetsUrl):void 0)},e.getConnectToken=function(t){return this.getFromId(this.selectedServerId).connectUrl?t:this.selectedServerId+t},e.getFromId=function(t){for(var e=0;e<this.servers.length;e++)if(this.servers[e].id==t)return this.servers[e];return null},e.getDefault=function(){return this.getFromId(this.defaultId)},e.serialize=function(){return{server:this.selectedServerId}},e.unserialize=function(t){this.selectServer(t.server)},t}),define("CatLab/Webremote/Config",["CatLab/Webremote/Tools/Net","CatLab/Webremote/Collections/ServerList"],function(i,t){"use strict";var e="http";return{_options:{host:"www.catlab.tv",serverlist:null,preferredServer:null,protocol:e="undefined"!=typeof window&&void 0!==window.location&&void 0!==window.location.protocol?window.location.protocol.substr(0,window.location.protocol.length-1):e,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(t){void 0!==t&&(t.host,this._options.host=t.host,void 0!==t.protocol&&(this._options.protocol=t.protocol),void 0!==t.debug&&(this._options.debug=t.debug),void 0!==t.imageproxy&&(this._options.imageproxy=t.imageproxy),void 0!==t.proxy&&(this._options.proxy=t.proxy),void 0!==t.smileys&&(this._options.smileys=t.smileys),void 0!==t.assetsUrl&&(this._options.assetsUrl=t.assetsUrl),void 0!==t.vendorPath&&(this._options.vendorPath=t.vendorPath),void 0!==t.audioSync&&(this._options.audioSync=t.audioSync),void 0!==t.serverlist&&(this._options.serverlist=t.serverlist),void 0!==t.preferredServer&&(this._options.preferredServer=t.preferredServer),void 0!==t.allowAuthentication&&(this._options.allowAuthentication=t.allowAuthentication),void 0!==t.audioSyncConfig&&(this.audioSyncConfig=t.audioSyncConfig),void 0!==t.canFullscreen&&(this._options.canFullscreen=t.canFullscreen),void 0!==t.oauth)&&void 0!==t.oauth.redirectUrl&&(this._options.oauth.redirectUrl=t.oauth.redirectUrl)},getAll:function(){return this._options},initialize:function(e){var t;this._initialized?e():null===this._options.serverlist||"http"!==this._options.serverlist.substring(0,4)?(this._initialized=!0,e()):"json"===this._options.serverlist.substring(this._options.serverlist.length-4)?i.loadJSON(this._options.serverlist,function(t){this._initialized=!0,this._options.serverlist=t,e()}.bind(this),function(t,e){alert("Failed to connect to "+this._options.serverlist+". Game cannot start."),console.log(e)}.bind(this)):((t=document.createElement("script")).onload=function(){this._initialized=!0,this._options.serverlist=getCatLabRemoteServers(),e()}.bind(this),t.onerror=function(){alert("Failed to connect to "+this._options.serverlist+". Game cannot start.")}.bind(this),t.src=this._options.serverlist,document.head.appendChild(t))},getProtocol:function(t){var e=this._options.protocol;switch(e=void 0!==t&&t&&""===e?"http":e){case"http":case"https":break;default:e="https"}return e},getSocketURL:function(t){return this._options.host?((t=this.getProtocol(t))&&(t+=":"),t+"//"+this._options.host):"undefined"!=typeof window&&void 0!==window.location?window.location.protocol+"//"+window.location.hostname:""},getAssetsURL:function(t){var e;return this._options.assetsUrl||((e=this.getServerList())?e.getAssetURL():this.getSocketURL(t)+"/assets/")},debug:function(){return this._options.debug},getProxiedImage:function(t){return this._options.imageproxy?this._options.imageproxy+encodeURIComponent(t):t},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 t={smileys:this.useSmileys(),audioSync:this.useAudioSync()};return this.useAudioSync()&&(t.audioSyncConfig=this.audioSyncConfig),t},getServerList:function(){return this._options.serverlist?(this.serverCollection||(this.serverCollection=new t(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(t,e){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(t),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(t,e,i,n){},e=function(t){s("Page",t,"-",0)};return{setTracker:function(t){s=t},setPageMethod:function(t){e=t},track:function(t,e,i,n){s(t,e,i,n)},page:function(t){e(t)}}}),define("CatLab/Webremote/Tools/Tools",[],function(){var s,o;return{popup:function(t,e){var i=this,n=(e=e||!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=t,(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",e?(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(t,e){return window.open(t,"oauth:catlab-remote")},oauth2Popup:function(t,e){return this.oauth2PopupMethod(t,e)},closePopup:function(){s&&s.parentNode.removeChild(s),o&&o.parentNode.removeChild(o)},setOauth2Popup:function(t){return this.oauth2PopupMethod=t,this},sanitize:function(t){var e;return null==t?null:(e={"&":"&","<":"<",">":">",'"':""","'":"'"},String(t).replace(/[&<>"']/g,function(t){return e[t]}))},nl2br:function(t,e){return null==t?"":(t+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+(e||void 0===e?"<br />":"<br>")+"$2")},shuffle:function(t){for(var e,i,n=t.length-1;0<n;n--)e=Math.floor(Math.random()*(n+1)),i=t[n],t[n]=t[e],t[e]=i},getUuid:function(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)},findIndex:function(t,e){for(var i=0;i<t.length;i++)if(e(t[i]))return i;return-1},getConnectTokenForDisplay:function(t){return null===t?null:t.length%4==0?this.injectFillerInString(t,4," "):(t.length,this.injectFillerInString(t,3," "))},injectFillerInString:function(t,e,i){return t.match(new RegExp(".{1,"+e+"}","g")).join(i)}}}),define("CatLab/Webremote/Tools/Cookies",[],function(){var e={setCookie:function(t,e,i){return this.setItem(t,e,i)},getCookie:function(t){return this.getItem(t)},eraseCookie:function(t){return this.removeItem(t)},getItem:function(t){if("undefined"!=typeof document)return t&&this.hasOwnProperty(t)?unescape(document.cookie.replace(new RegExp("(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"),"$1")):null},key:function(t){if("undefined"!=typeof document)return unescape(document.cookie.replace(/\s*\=(?:.(?!;))*$/,"").split(/\s*\=(?:[^;](?!;))*[^;]?;\s*/)[t])},setItem:function(t,e,i){var n,s;t&&"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(t)+"="+escape(e)+"; expires="+n+"; path=/; SameSite=Strict;",this.updateLength())},length:0,removeItem:function(t){t&&this.hasOwnProperty(t)&&"undefined"!=typeof document&&(document.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; SameSite=Strict;",this.length--)},hasOwnProperty:function(t){if("undefined"!=typeof document)return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie)},updateLength:function(){var t;"undefined"!=typeof document&&document.cookie&&(t=document.cookie.match(/\=/g),e.length=t?t.length:0)}};return e.updateLength(),e}),define("CatLab/Webremote/Tools/Smileys",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Tools"],function(i,n){function t(t){this.provider=t,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 e=t.prototype;return e.shouldHaveUniqueSmileys=function(){return this.takenAmount<this.smileyKeys.length/3},e.setTakenSmileys=function(t){this.taken=t},e.getTakenSmileys=function(t){if(!this.shouldHaveUniqueSmileys())return{};t=this.identifierToText(t);var e,i={};for(e in this.taken)this.taken.hasOwnProperty(e)&&this.taken[e]!==t&&(i[e]=this.taken[e]);return i},e.getRandom=function(t){for(var e=null;null===e&&this.randomSmileys;)if(e=this.randomSmileys.shift(),this.reserve(e,t)||(e=null),0===this.randomSmileys.length)return this.randomSmileys=this.smileyKeys.slice(0),n.shuffle(this.randomSmileys),this.randomSmileys.shift();return e},e.reserve=function(t,e){return this.isExternalSmiley(t)?(this.unreserve(e),!0):(e=this.identifierToText(e),void 0!==this.taken[t]&&this.taken[t]===e?(this.taken[t]=e,!0):!!this.isAvailable(t)&&(this.unreserve(e),this.taken[t]=e,this.takenAmount++,!0))},e.unreserve=function(t){for(var e in t=this.identifierToText(t),this.taken)this.taken.hasOwnProperty(e)&&this.taken[e]===t&&(this.taken[e]=null,delete this.taken[e],this.takenAmount--)},e.isAvailable=function(t){return!this.shouldHaveUniqueSmileys()||!!this.isExternalSmiley(t)||void 0===this.taken[t]||null===this.taken[t]},e.identifierToText=function(t){return JSON.stringify(t)},e.isExternalSmiley=function(t){return"http"===t.substr(0,4)},e.getUrl=function(t){return null===t?null:this.isExternalSmiley(t)?t:i.getAssetsURL()+"smileys/"+t+".png"},e.getHtml=function(t){return null===t?null:'<span class="smiley" style="width: 64px; height: 64px; display: inline-block; background-image: url(\''+this.getUrl(t)+"');\"></span>"},e.getElement=function(t){var e;return null===t?null:((e=document.createElement("div")).innerHTML=this.getHtml(t),e.firstChild)},e.getImage=function(t){var e;return null===t?null:(void 0===this.images[t]&&((e=new Image).crossOrigin="anonymous",e.src=i.getProxiedImage(this.getUrl(t)),this.images[t]=e),this.images[t])},e.refreshTakenSmileys=function(t){this.shouldHaveUniqueSmileys()?t.emit("smileys:taken",{smileys:this.getTakenSmileys(t.getIdentifier())}):this.playerKnowsAboutNonUniqueSmileys[this.getStringIdentifier(t)]},e.getStringIdentifier=function(t){return t.type+":"+t.id},t}),define("CatLab/Webremote/Tools/Preloader",["../Config","CatLab/Webremote/Tools/Deferred"],function(e,o){function i(t){this.provider=t,this.provider.on("file:preload",function(t){t&&t.url&&this.preloadClientFile(t.url)}.bind(this)),this.urlMap={}}var t=i.prototype;return t.preload=function(e){if(Array.isArray(e)){for(var t=new o,i=[],n=0;n<e.length;n++)i.push(this.preload(e[n]));return o.when.apply(o,i).then(function(){t.resolve(Array.prototype.slice.call(arguments))}),t.promise()}var s=new o;return this.provider.emit("file:preload",{url:e},function(t){this.urlMap[e]=t.url,s.resolve(t)}.bind(this)),s.promise()},t.getPreloadedUrl=function(t){return this.urlMap[t]},t.preloadClientFile=function(t){void 0===this.urlMap[t]&&(t.toLowerCase().indexOf("http")<0&&(t=e.getProtocol()+":"+t),this.urlMap[t]=document.createElement("img"),this.urlMap[t].src=t)},t.serialize=function(){return{urlMap:this.urlMap}},i.unserialize=function(t,e){t=new i(t);return void 0!==e&&void 0!==e.urlMap&&(t.urlMap=e.urlMap),t},i}),define("CatLab/Webremote/Tools/Eventable",["CatLab/Webremote/Tools/Tools"],function(n){"use strict";function t(){}var s=0,e=t.prototype;return e.initializeEventable=function(){this._eventableEvents=[]},e.trigger=function(t){this.eventableTrigger.apply(this,arguments)},e.eventableTrigger=function(t){if("string"!=typeof t)throw new Error("eventableTrigger must be a string");if(void 0!==this._eventableEvents){var e,i=Array.prototype.slice.call(arguments);for(e in i.push(i.shift()),this._eventableEvents)this._eventableEvents.hasOwnProperty(e)&&this.eventMatches(t,e)&&this._eventableEvents[e].slice().forEach(function(t){try{t.method.apply(t.scope,i)}catch(t){console.error(t)}}.bind(this))}},e.eventMatches=function(t,e){return"*"===e||t===e},e.on=function(t,e,i){void 0===this._eventableEvents&&(this._eventableEvents={}),void 0===this._eventableEvents[t]&&(this._eventableEvents[t]=[]),s++,this._eventableEvents[t].push({id:s,method:e,scope:void 0!==i?i:this});var n=[t,s];return{id:n,name:t,method:e,unbind:function(){this.off(null,{id:n,name:t})}.bind(this)}},e.once=function(t,e,i){var n=this.on(t,function(){n.unbind(),e.apply(i,arguments)});return n},e.off=function(t,e){if(void 0!==t||void 0!==e)if(void 0===t||void 0!==e){if(t=e.name,e=e.id,void 0===this._eventableEvents[t])return null;var i=n.findIndex(this._eventableEvents[t],function(t){return t.id=e});0<=i&&(this._eventableEvents[t]=this._eventableEvents[t].splice(i,1))}else this._eventableEvents[t]=[];else this._eventableEvents=[]},e.clearEvents=function(){this.clearEventableEvents()},e.clearEventableEvents=function(){this._eventableEvents={}},t}),define("CatLab/Webremote/Models/User",["jquery","CatLab/Webremote/Config"],function(t,i){return function(t){this.accessToken=t,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(t){this.id=t},this.getId=function(){return this.id},this.setName=function(t){this.name=t},this.getName=function(){return this.name},this.setAvatar=function(t){var e=this;this.avatar=t,this.imageLoaded=!1,this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=function(){e.afterImageLoad()},this.image.src=i.getProxiedImage(this.avatar)},this.getAvatar=function(){return this.avatar},this.getAvatarSmiley=function(t){var e=this.getAvatar();return e?(e=e.split("?")[0],e+="?shape=circle&size=64&borderWidth=4",t&&(e+="&borderColor="+t.substr(1)),e):null},this.afterImageLoad=function(){this.imageLoaded=!0;for(var t=0;t<this.imageCallbacks.length;t++)this.imageCallbacks[t](this.image);this.imageCallbacks=[]},this.getImage=function(t){this.imageLoaded?t(this.image):this.imageCallbacks.push(t)}}}),define("CatLab/Webremote/Tools/Storage",["CatLab/Webremote/Tools/Cookies"],function(t){var e={clean:function(){if(this.isSupported())for(var t=Object.keys(window.localStorage),e=0;e<t.length;e++)this.get(t)},get:function(t,e){if(void 0===e&&(e=function(){}),this.isSupported())try{var i,n=window.localStorage.getItem(t);n?void 0!==(n=JSON.parse(n)).expires?(i=Date.now(),n.expires<i?(this.delete(t),e(null)):e(n.content)):e(n):e(null)}catch(t){e(null),console.log(t)}else e(null)},add:function(e,i,n,s){var o=this;n=n||function(){},this.isSupported()?this.get(e,function(t){(t=null!=t&&""!==t?t:[]).push(i),o.set(e,t,n,s)}):n(null)},set:function(t,e,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(t,JSON.stringify({expires:s,content:e}))}catch(t){console.log(t)}i()}else i(null)},delete:function(t){this.isSupported()&&window.localStorage.removeItem(t)},remove:function(n,s){var o;this.isSupported()&&(o=this).get(n,function(t){null!=t&&""!=t||(t=[]);for(var e=JSON.stringify(s),i=0;i<t.length;i++)if(e===JSON.stringify(t[i]))return t.splice(i,1),void o.set(n,t)})},isSupported:function(){if("undefined"==typeof window)return!1;try{if(void 0===window.localStorage)return!1}catch(t){return console.log(t),!1}return!0}};try{e.clean()}catch(t){console.error(t)}return e}),define("CatLab/Webremote/Collections/AuthenticatedUsers",["CatLab/Webremote/Models/User","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Tools/Eventable"],function(i,s,t){function e(){this.initializeEventable()}var o,r,n=[],t=e.prototype=new t;return t.initialize=function(t,e){o=e,r=t;var n=this;s.get("users",function(i){null!==i&&s.get("currentuser",function(e){for(var t=0;t<i.length;t++)n.addFromAccessToken(i[t].access_token,function(t){t&&e&&t.getAccessToken()===e&&void 0!==r.setUser&&r.setUser(t)})})})},t.addFromAccessToken=function(e,i){i=i||function(){};var n=this;o.profile(e,function(t){t?(t=n.add(e,t.user),i(t)):s.remove("users",{access_token:e})})},t.add=function(t,e){t=new i(t);return t.setId(e.id),t.setName(e.username),t.setAvatar(e.avatar),function(t){for(var e=0;e<n.length;e++)if(n[e].getId()==t.getId())return n[e]=t;n.push(t)}(t),this.trigger("update"),t},t.remove=function(t){for(var e=0;e<n.length;e++)if(n[e].getId()==t.getId())return void n.splice(e,1)},t.getFromId=function(t){for(var e=0;e<n.length;e++)if(n[e].getId()==t)return n[e];return null},t.getAll=function(){return n},new e}),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,callbacks=[],initialized=!1,afterInit=[],events=[],etPhoneHome=null;function OAuth2(){this.initializeEventable()}var p=OAuth2.prototype=new Eventable;return p.initialize=function(t){url=(t=t||{}).authorization||"https://quizted.catlab.eu/oauth2/authorize",client_id=t.client_id||"none",authorization=t.authorization||"default",profile_url=t.profile||"",avatar_url=t.profile+"/avatar",initialized=!0;var e=this;if("undefined"!=typeof window){function i(t){e.onMessage(t)}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(t,e){this.redirectHost=t,this.redirectUrl=t+e},p.getAuthorizeURL=function(){var t="",t=(Config.all().oauth&&Config.all().oauth.redirectUrl&&(t=Config.all().oauth.redirectUrl),url+"?client_id="+encodeURIComponent(client_id)+"&authorization="+encodeURIComponent(authorization)+"&response_type=token&redirect_uri="+encodeURIComponent(t)+"&reset=1&state=login");return void 0!==this.redirectUrl?this.redirectUrl+"?url="+encodeURIComponent(t):t},p.onMessage=function(t){if("I must've called a thousand times"!==t.data){var e;if("string"==typeof t.data&&t.data.match(/^oauth::/))try{e=JSON.parse(t.data.substring(7))}catch(t){return}else if("string"==typeof t.data)try{e=JSON.parse(t.data)}catch(t){return}else e=t.data;void 0!==e.access_token&&this.addAccessToken(e.access_token)}},p.addAccessToken=function(n){var t=function(t){var e,i=Users.add(n,t.user);for(Storage.add("users",{access_token:n}),Tools.closePopup();e=callbacks.shift();)e(i);this.trigger("update")}.bind(this);this.call(profile_url,n,t)},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(t,e){this.call(profile_url,t,e)},p.changeAvatar=function(e,t){var i;if(e.getAccessToken())return(i=new FormData).append("avatar",t.files[0]),$.ajax({type:"POST",url:avatar_url,data:i,contentType:!1,processData:!1,headers:{Authorization:"Bearer "+e.getAccessToken()},success:function(t){e.setAvatar(t.url)}})},p.link=function(e){var i=new Deferred,t={},t=("object"==typeof(e=void 0===e?{}:e)&&(e=(t=e).callback||function(){}),t.fullscreen||!1),n=(etPhoneHome&&clearInterval(etPhoneHome),this.getAuthorizeURL()),s=Tools.oauth2Popup(n,t);return s&&(etPhoneHome=setInterval(function(){s.postMessage("Hello from the other side","*")}.bind(this),1e3)),callbacks.push(function(t){e(t),i.resolve(t)}),i.promise()},p.onInit=function(t){afterInit.push(t)},p.onAdds=function(){for(var t=0;t<afterInit.length;t++)afterInit[t]()},p.getParamsFromHash=function(t){if("undefined"!=typeof window)return t=(t=t||window.location.hash).slice(1),(t=decodeURIComponent(t)).split("&").reduce(function(t,e){return t[(e=e.split("="))[0]]=e[1],t},{})},p.finish=function(){var t='oauth::{"catlabremote":1,"event":"user:authenticated","access_token":"'+this.getParamsFromHash().access_token+'"}';setTimeout(function(){window.opener&&window.opener.postMessage(t,"*"),window.parent&&window.parent.postMessage(t,"*"),void 0!==window.dialogArguments&&window.dialogArguments.opener&&window.dialogArguments.opener.postMessage(t,"*"),setTimeout(function(){etPhoneHome&&clearInterval(etPhoneHome),window.close()},1)},1)},new OAuth2}),define("CatLab/Webremote/Views/Popups/BasePopup",["jquery"],function(n){function t(){this.scrollable=!1}var e=t.prototype;return e.render=function(t){this.popupContainer=document.createElement("div"),this.popupContainer.className="catlab-popup-container";var e=document.createElement("div"),e=(e.className="overlay",this.popupContainer.appendChild(e),this.container=document.createElement("div"),this.container.className="popup",this.popupContainer.appendChild(this.container),n(this.container).click(function(t){t.stopPropagation()}),this.content=document.createElement("div"),this.container.appendChild(this.content),document.createElement("p")),i=(e.className="close",document.createElement("a"));i.href="javascript:void(0)",i.innerHTML="<span>Close</span>",i.onclick=function(){this.close()}.bind(this),e.appendChild(i),this.container.appendChild(e),t.appendChild(this.popupContainer),this.scrollable&&n(this.content).addClass("scrollable"),this.renderContent(this.content)},e.renderContent=function(){},e.close=function(){this.popupContainer.parentNode.removeChild(this.popupContainer)},t}),define("CatLab/Webremote/Views/User",["CatLab/Webremote/Controllers/OAuth2","jquery"],function(i,n){return function(d){this.render=function(t,e,i){e=e||[];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<e.length;u++)(h=document.createElement("li")).className=e[u].token,c.appendChild(h),(l=document.createElement("a")).onclick=e[u].click,l.innerHTML=e[u].text,l.href="javascript:void(0)",h.appendChild(l);r.appendChild(c),t.innerHTML="",t.appendChild(o);i=document.createElement("div");i.className="clearer",o.appendChild(i)},this.renderAvatar=function(){var t=d.getAvatar(),e=document.createElement("img");e.src=t,e.alt="User avatar",n(this.avatardiv).html(e)},this.enableAvatarUpload=function(t){var e=document.createElement("input");e.type="file",e.accept="image/*",this.avatarFileInput=e,n(e).on("change",function(){n(this.avatardiv).addClass("loading"),n.when(i.changeAvatar(d,e)).then(function(){n(this.avatardiv).removeClass("loading"),this.renderAvatar(),t.setUser(d)}.bind(this))}.bind(this)),n(this.avatardiv).click(function(){e.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(t,h,l,c,u,d){return function(e){function t(){h.link(function(t){s.updateUsers(),s.selectUser(t)})}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(){t()},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(t){e.setUser(t),s.close(),d.track("Click","Select user","AuthenticationPopup")},this.updateUsers=function(){o.innerHTML="";for(var t=l.getAll(),e=0;e<t.length;e++)!function(t,e){var i=document.createElement("li"),n=[{token:"select",text:"select",click:function(){s.selectUser(e)}},{token:"logout",text:"logout",click:function(){l.remove(e),u.remove("users",{access_token:e.getAccessToken()}),s.updateUsers(),d.track("Click","Logout","AuthenticationPopup")}}];new c(e).render(i,n,function(){s.selectUser(e)}),t.appendChild(i)}(o,t[e])},this.close=function(){i.parentNode.removeChild(i),d.track("Click","Close popup","AuthenticationPopup")},this.connect=function(){d.track("Click","Connect new","AuthenticationPopup"),t()},this.render=function(t){t.appendChild(i),this.updateUsers()},this.setLoginUrl=function(t){console.log(t)}}}),define("CatLab/Webremote/Views/Popups/SelectSmileyPopup",["CatLab/Webremote/Views/Popups/BasePopup"],function(t){function e(t,e,i){this.Webremote=t,this.callback=e,this.scrollable=!0,this.disableTaken=i}t=e.prototype=new t;return t.renderContent=function(t){$(t).addClass("smileys-popup");var e,i=$('<ul class="smileys"></ul>'),n=($(t).append(i),this.Webremote.smileys.smileyKeys.slice());this.Webremote.getUser()&&this.Webremote.getUser().getAvatar()&&(e=this.Webremote.getUser().getAvatarSmiley(this.Webremote.color))&&n.unshift(e);for(var s=0;s<n.length;s++)this.renderSmiley(i,n[s]);$(t).append('<div class="clearer"></div>')},t.renderSmiley=function(t,e){var i=$("<li>");i.append(this.Webremote.smileys.getElement(e)),this.disableTaken&&!this.Webremote.smileys.isAvailable(e)&&i.addClass("unavailable"),this.Webremote.getSmiley()===e&&i.addClass("selected"),i.click(function(){this.selectSmiley(e),t.find(".selected").removeClass("selected"),i.addClass("selected"),this.close()}.bind(this)),t.append(i)},t.selectSmiley=function(t){this.callback(t)},e}),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(t){var e,i,n;t.innerHTML="",s.canAuthenticate()&&(n=s.getUser(),(e=document.createElement("div")).className="overlay player-color-background",t.appendChild(e),(e=document.createElement("div")).className="content",e.className+=" player-color-border",t.appendChild(e),n?(t=[{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 t=s.getUser();r.remove(t),s.setUser(null),a.remove("users",{access_token:t.getAccessToken()}),h.track("Click","Logout","CurrentUser")}}],(i=new o(n)).render(e,t),i.enableAvatarUpload(s)):((n=document.createElement("p")).className="catlab-not-loggedin",(t=document.createElement("a")).href="javascript:void(0);",t.innerHTML="Login",t.onclick=function(){s.showAuthenticationPopup(0===r.getAll().length),h.track("Click","Login","CurrentUser")},n.appendChild(t),e.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(t){for(var e,i,n,s,o,r,a,h=function(t){if(m[t])return m[t];for(var e,i=t,n=[],s=0;i;){if(null!==(e=f.text.exec(i)))n.push(e[0]);else if(null!==(e=f.modulo.exec(i)))n.push("%");else{if(null===(e=f.placeholder.exec(i)))throw new SyntaxError("[sprintf] unexpected placeholder");if(e[2]){s|=1;var o=[],r=e[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])}e[2]=o}else s|=2;if(3===s)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n.push({placeholder:e[0],param_no:e[1],keys:e[2],sign:e[3],pad_char:e[4],align:e[5],width:e[6],precision:e[7],type:e[8]})}i=i.substring(e[0].length)}return m[t]=n}(t),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(e=l[c],i=0;i<n.keys.length;i++){if(null==e)throw new Error(g('[sprintf] Cannot access property "%s" of undefined value "%s"',n.keys[i],n.keys[i-1]));e=e[n.keys[i]]}else e=n.param_no?l[n.param_no]:l[c++];if(f.not_type.test(n.type)&&f.not_primitive.test(n.type)&&e instanceof Function&&(e=e()),f.numeric_arg.test(n.type)&&"number"!=typeof e&&isNaN(e))throw new TypeError(g("[sprintf] expecting number but found %T",e));switch(f.number.test(n.type)&&(r=0<=e),n.type){case"b":e=parseInt(e,10).toString(2);break;case"c":e=String.fromCharCode(parseInt(e,10));break;case"d":case"i":e=parseInt(e,10);break;case"j":e=JSON.stringify(e,null,n.width?parseInt(n.width):0);break;case"e":e=n.precision?parseFloat(e).toExponential(n.precision):parseFloat(e).toExponential();break;case"f":e=n.precision?parseFloat(e).toFixed(n.precision):parseFloat(e);break;case"g":e=n.precision?String(Number(e.toPrecision(n.precision))):parseFloat(e);break;case"o":e=(parseInt(e,10)>>>0).toString(8);break;case"s":e=String(e),e=n.precision?e.substring(0,n.precision):e;break;case"t":e=String(!!e),e=n.precision?e.substring(0,n.precision):e;break;case"T":e=Object.prototype.toString.call(e).slice(8,-1).toLowerCase(),e=n.precision?e.substring(0,n.precision):e;break;case"u":e=parseInt(e,10)>>>0;break;case"v":e=e.valueOf(),e=n.precision?e.substring(0,n.precision):e;break;case"x":e=(parseInt(e,10)>>>0).toString(16);break;case"X":e=(parseInt(e,10)>>>0).toString(16).toUpperCase()}f.json.test(n.type)?d+=e:(!f.number.test(n.type)||r&&!n.sign?a="":(a=r?"+":"-",e=e.toString().replace(f.sign,"")),s=n.pad_char?"0"===n.pad_char?"0":n.pad_char.charAt(1):" ",o=n.width-(a+e).length,o=n.width&&0<o?s.repeat(o):"",d+=n.align?a+e+o:"0"===s?a+o+e:o+a+e)}return d}function t(t,e){return g.apply(null,[t].concat(e||[]))}var m=Object.create(null);"undefined"!=typeof exports&&(exports.sprintf=g,exports.vsprintf=t),"undefined"!=typeof window&&(window.sprintf=g,window.vsprintf=t,"function"==typeof define)&&define.amd&&define("sprintf",[],function(){return{sprintf:g,vsprintf:t}})}(),define("CatLab/Webremote/Tools/Translator",["sprintf"],function(e){function t(){this.translator=null}var i,n,s=t.prototype;return s.setTranslator=function(t){this.translatorScope=this,"function"==typeof t?this.translator=t:("function"==typeof t.t?this.translator=t.t:(t._,this.translator=t._),this.translatorScope=t)},s.t=function(t){if(this.translator)return this.translator.apply(this.translatorScope,arguments);for(i=[],n=1;n<arguments.length;n++)i.push(arguments[n]);return e.vsprintf(t,i)},new t}),define("CatLab/Webremote/Views/Blocks/CurrentSmiley",["jquery","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/Deferred"],function(t,e,i){"use strict";function n(t,e,i,n){this.Webremote=t,this.canSwitch=void 0!==e&&!!e,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(t,e){n.isInitialized.resolve()})),n.isInitialized.promise()}.bind(this),n.activeSmileys=["1f601","1f60d","1f60e"];var s=n.prototype;return s.setSmiley=function(t){Array.isArray(t)||(t=[t]),this.smileys=t,n.initialize().then(function(){this.selector&&(this.selector.html(""),t.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(t,e){if(this.dragDisabled)return!1;o=e.position,r=$(e.helper).offset(),this.disableDrag(),i.toggleClass("flinging",!0)}.bind(this),stop:function(t,e){var i=e.position,n=this.getDistance(o,i);10<n?(i=this.getAngle(o,i),this.slingshot(r,i,n,e.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)">'+e.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(t,e){var i=t.left-e.left,t=t.top-e.top;return Math.sqrt(i*i+t*t)},s.getAngle=function(t,e){return Math.atan2(e.top-t.top,e.left-t.top)},s.slingshot=function(t,e,i,n,s){var o=Math.min(1,i/this.getMaxDistance());0<Math.sin(e-Math.PI)?n.animate({left:0,top:0,opacity:1},1e3):(i=1.5*Math.max(t.left,t.top),n.animate({left:Math.cos(e-Math.PI)*i,top:Math.sin(e-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:e,speed:o,smiley:s})}.bind(this),800))},s.render=function(t){n.initialize().then(function(){this.container=$(t),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(t){if(-1===n.activeSmileys.indexOf(t)){for(;2<n.activeSmileys.length;)n.activeSmileys.shift();n.activeSmileys.push(t),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 t(t){return decodeURIComponent(t.replace(n," "))}for(var e,i={},n=/\+/g,s=/([^&;=]+)=?([^&;]*)/g,o=window.location.hash.substring(1);e=s.exec(o);)i[t(e[1])]=t(e[2]);return i},getParameter:function(t){var e=this.getParameters();return void 0!==e[t]?e[t]:null},clear:function(){history.pushState("",document.title,window.location.pathname+window.location.search)}}}),define("CatLab/Webremote/Views/Alert",[],function(){return function(t,e){e=e||function(){},alert(t),e()}}),define("CatLab/Webremote/Views/Welcome",["CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Views/User","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Tools/Tracker"],function(t,e,i,o){return function(t){var e=this,i=document.createElement("div"),n=(i.className="catlab-popup-container",document.createElement("div")),n=(n.className="overlay",i.appendChild(n),document.createElement("div")),t=(n.className="popup thanks",i.appendChild(n),n.innerHTML=t,document.createElement("a")),s=(t.innerHTML="Start playing",t.onclick=function(){e.close()},t.href="javascript:void(0)",document.createElement("p"));s.appendChild(t),s.className="playnow",n.appendChild(s),this.close=function(){i.parentNode.removeChild(i),o.track("Click","Close popup","WelcomePopup")},this.render=function(t){t.appendChild(i)}}}),define("CatLab/Webremote/Views/ConnectionTrouble",["CatLab/Webremote/Tools/Translator"],function(t){function e(){this.visible=!1,this.div=null,this.timeoutTillShow=3e3,this.showTimeout=null,this.message=null}var i=e.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(t.t("Connection lost")))}.bind(this),this.timeoutTillShow))},i.text=function(t){this.message=t,this.div&&(this.div.innerHTML="<p>"+t+"</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},e}),define("CatLab/Webremote/Views/GamePaused",["CatLab/Webremote/Tools/Translator"],function(t){function e(){this.visible=!1,this.div=null,this.timeoutTillShow=1,this.showTimeout=null,this.message=null}var i=e.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(t.t("Please wait, the game is paused.")))}.bind(this),this.timeoutTillShow))},i.text=function(t){this.message=t,this.div&&(this.div.innerHTML='<p style="height: 100%; padding: 20% 0">'+t+"</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},e}),define("CatLab/Webremote/Synchronization/ClientRemoteView",["jquery"],function(n){"use strict";function t(t,e,i,n,s,o){this.controller=t,this.html="<p>Loading</p>",this.context={},this.viewId=e,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={},e=t.prototype;return e.render=function(t){var e;this.iframe?(e=document.createElement("iframe"),$(e).css({width:"100%",height:"100%",border:"none",margin:0,padding:0,position:"absolute",left:0,top:0}),$(t).html(e),this.element=e.contentDocument.body):this.element=t,this.el=t,this.$el=n(t),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)},e.updateEvents=function(){var c=this;function t(n,e,s){var o,r,a,h,l;c.shouldSetEvents(n,"touch")&&(h=!1,l=null,n.addEventListener("touchstart",function(t){return o=new Date,r={x:t.touches[0].pageX,y:t.touches[0].pageY},a={x:t.touches[0].pageX,y:t.touches[0].pageY},h=!0,l&&clearTimeout(l),e.apply(c,[n])}),n.addEventListener("touchmove",function(t){a={x:t.touches[0].pageX,y:t.touches[0].pageY}}),n.addEventListener("touchend",function(t){var e,i;if(r)return i=Math.abs(a.x-r.x),e=Math.abs(a.y-r.y),r=null,i=(new Date).getTime()-o.getTime()<300&&i<20&&e<20,l=setTimeout(function(){h=!1},1e3),s.apply(c,[n,i])}),n.addEventListener("mousedown",function(t){if(t.preventDefault(),!h)return e.apply(c,[n])}),n.addEventListener("mouseup",function(t){if(t.preventDefault(),!h)return s.apply(c,[n,!0])}))}for(var e=this.element.querySelectorAll("[data-button-id]"),i=0;i<e.length;i++)t(e[i],c.buttonDown,c.buttonUp),this.buttons.push(e[i]);for(e=this.element.querySelectorAll("[data-authentication-button]"),i=0;i<e.length;i++)t(e[i],function(){},c.authenticate);for(e=this.element.querySelectorAll("[data-value-id]"),i=0;i<e.length;i++)!function(e){var i,t;c.shouldSetEvents(e,"change")&&(i=e.getAttribute("data-value-id"),c.currentValues[i]=c.getDataValue(e),e.addEventListener("change",function(t){s[i]=new Date,c.syncValue(e)}),t=null,e.addEventListener("keyup",function(){t&&clearTimeout(t),t=setTimeout(function(){s[i]=new Date,c.syncValue(e)},1e3)}))}(e[i])},e.getDataValue=function(t){return"checkbox"===t.type?t.checked?1:0:t.value},e.syncValues=function(){for(var t=this.element.querySelectorAll("[data-value-id]"),e=0;e<t.length;e++)this.syncValue(t[e])},e.syncValue=function(t){var e=this.getDataValue(t),i=t.getAttribute("data-value-id");void 0!==this.currentValues[i]&&this.currentValues[i]===e||(this.currentValues[i]=e,this.controller.syncValue(i,this.getDataValue(t),this.viewId))},e.update=function(){for(var t=this.element.querySelectorAll("[data-button-decorator]"),e=0;e<t.length;e++)void 0===t[e].dataset.initialClasses&&(t[e].dataset.initialClasses=t[e].className);this.updateBigTextSizes()},e.updateBigTextSizes=function(){var i=$(this.element),t=i.find(".bigtext"),n={};t.each(function(){var t=$(this).attr("data-bigtext-group"),e=t?(void 0===n[t]&&(n[t]=0,i.find('.bigtext[data-bigtext-group="'+t+'"]').each(function(){n[t]=Math.max(n[t],$(this).text().length)})),n[t]):$(this).text().length;$(this).attr("data-bigtext-length",e)})},e.shouldSetEvents=function(t,e){return void 0===t["hasCatlabEventsAlready"+e]&&(t["hasCatlabEventsAlready"+e]=!0)},e.buttonDown=function(t){try{this.syncValues()}catch(t){console.error(t)}return this.controller.buttonDown(t.getAttribute("data-button-id"),this.viewId),!1},e.buttonUp=function(t,e){return this.controller.buttonUp(t.getAttribute("data-button-id"),this.viewId,e),!1},e.setLabel=function(t,e){for(var i=this.element.querySelectorAll("[data-button-label="+t+"]"),n=0;n<i.length;n++)i[n].innerHTML=e;this.update()},e.setClass=function(t,e){for(var i=this.element.querySelectorAll("[data-button-decorator="+t+"]"),n=0;n<i.length;n++){var s=i[n];s.className=s.dataset.initialClasses+" "+e}this.update()},e.domAppend=function(t,e){var i=document.getElementById(t);if(i){for(var n=this.stringToDom(e),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(t){console.log(t)}5e3<(new Date).getTime()-this.createdAt.getTime()&&0<s.length&&void 0!==s[0].scrollIntoView&&s[0].scrollIntoView(),this.update(),this.updateEvents()}},e.domReplace=function(t,e){t=document.getElementById(t);t&&(t.innerHTML=e,this.controller.components.attach(this._currentView,t,!1),this.update(),this.updateEvents())},e.domAttribute=function(t,e,i){n(t).attr(e,i)},e.changeValue=function(t){if(void 0!==s[t.id]){if((e=Math.abs(s[t.id].getTime()-(new Date).getTime()))<5)return}else var e=9999999999999;for(var i=this.element.querySelectorAll("[data-value-id="+t.id+"]"),n=0;n<i.length;n++)document.activeElement==i[n]&&e<5e3||(this.currentValues[t.id]=t.value,i[n].value=t.value)},e.vibrate=function(t){void 0!==window.navigator.vibrate&&void 0!==t.pattern&&Array.isArray(t.pattern)&&window.navigator.vibrate(t.pattern)},e.stringToDom=function(t){var e;return(e=0<=t.toLowerCase().indexOf("<tr")?document.createElement("tbody"):document.createElement("div")).innerHTML=t,e},e.stringInterpolateDataElements=function(t,s){return t.replace(/{{(.+?)}}/g,function(t,e,i,n){e=this.controller.resolveDataAttribute(e.trim());return e=s?s(e):e}.bind(this))},e.destroy=function(){this.syncValues(),void 0!==this.synchronizedData&&this.synchronizedData.destroy()},t}),define("CatLab/Webremote/Synchronization/DataItem",[],function(){function i(t,e,i){this.key=t,this.shared=e,this.side=i}var t=i.prototype;return t.setValue=function(t){this.value=t},t.canWrite=function(t){return!!this.shared||this.side===t},t.serialize=function(){return{key:this.key,shared:this.shared,side:this.side,value:this.value}},i.unserialize=function(t){var e=new i(t.key,t.shared,t.side);return e.setValue(t.value),e},i}),define("CatLab/Webremote/Synchronization/SynchronizedData",["CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Synchronization/DataItem"],function(t,s){function e(t,e,i){this.initializeEventable(),this.id=t,this.synchronizer=e,this.side=i,this.data={}}t=e.prototype=new t;return t.set=function(t,e,i){if(void 0===this.data[t])this.data[t]=new s(t,i,this.side);else if(!this.data[t].canWrite(this.side))throw"Trying to overwrite a non shared data attribute: "+t;this.data[t].setValue(e),this.emit(this.data[t])},t.processMessage=function(t){var e=t.key,i=t.side,n=t.value,t=t.shared;if(void 0===this.data[e])this.data[e]=new s(e,t,i);else if(!this.data[e].canWrite(i))throw"Trying to overwrite a non shared data attribute: "+e;this.data[e].setValue(n)},t.get=function(t){return void 0===this.data[t]?null:this.data[t].value},t.emit=function(t,e){void 0===e&&(e=this.synchronizer.emit);t=t.serialize();t.namespace=this.synchronizer.namespace,t.container=this.id,e("data:set",t)},t.refreshTarget=function(t){for(var e in this.data)this.data.hasOwnProperty(e)&&this.emit(this.data[e],t)},t.destroy=function(){this.synchronizer.destroy(this)},t.serialize=function(){var t,e={};for(t in this.data)this.data.hasOwnProperty(t)&&(e[t]=this.data[t].serialize());return e},t.unserialize=function(t){for(var e in this.data={},t)t.hasOwnProperty(e)&&(this.data[e]=s.unserialize(t[e]))},e}),define("CatLab/Webremote/Synchronization/DataSynchronizer",["CatLab/Webremote/Synchronization/SynchronizedData"],function(e){function t(t,e,i){this.namespace=t,this.emit=e,this.dataModels={},this.side=i}t.eventsToListenFor=["data:set"];var i=t.prototype;return i.checkNamespace=function(t){return void 0!==t.namespace&&t.namespace===this.namespace},i.processMessage=function(t,e){void 0!==e.container&&this.getFromIdentifier(e.container).processMessage(e)},i.getFromIdentifier=function(t){return void 0===this.dataModels[t]&&(this.dataModels[t]=new e(t,this,this.side)),this.dataModels[t]},i.destroy=function(t){t=t.id;void 0===this.dataModels[t]&&delete this.dataModels[t]},i.refreshTarget=function(t){for(var e in this.dataModels)this.dataModels.hasOwnProperty(e)&&this.dataModels[e].refreshTarget(t)},i.serialize=function(){var t,e={};for(t in this.dataModels)this.dataModels.hasOwnProperty(t)&&(e[t]=this.dataModels[t].serialize());return{dataModels:e}},i.unserialize=function(t){for(var e in t.dataModels)t.dataModels.hasOwnProperty(e)&&this.getFromIdentifier(e).unserialize(t.dataModels[e])},t}),define("CatLab/Webremote/Synchronization/EventHandler",["CatLab/Webremote/Tools/Eventable"],function(t){function e(t,e){this.initializeEventable(),this.namespace=t,this.emit=e}e.eventsToListenFor=["event:trigger"];t=e.prototype=new t;return t.checkNamespace=function(t){return void 0!==t.namespace&&t.namespace===this.namespace},t.processMessage=function(t,e){if("event:trigger"===t)return this.processTriggerEvent(e)},t.processTriggerEvent=function(t){void 0!==t.event&&this.eventableTrigger(t.event,void 0===t.parameters?{}:t.parameters)},t.trigger=function(t,e){this.emit("event:trigger",{namespace:this.namespace,event:t,parameters:e})},t.refreshTarget=function(t){},t.serialize=function(){return{}},t.unserialize=function(t){},e}),define("CatLab/Webremote/Synchronization/CombinedEventHandler",["CatLab/Webremote/Tools/Eventable"],function(t){function e(t,e){this.initializeEventable(),this.handlers=[]}return(e.prototype=new t).addHandler=function(t){this.handlers.push(t),t.on("*",function(t,e){this.trigger(e,t)}.bind(this))},e}),define("CatLab/Webremote/Synchronization/MessageQueue",[],function(){"use strict";function t(){this.queue=[]}var e=t.prototype;return e.add=function(t,e,i){this.queue.push({action:t,data:e,ack:i})},e.flush=function(){var t=this.queue;return this.queue=[],t},e.compactFlush=function(){var n,s,o,r,a=[],t=this.flush();return 0===t.length?t:(s={user:{},group:{}},o=0,r={},t.forEach(function(t){if(o++,this.canCompact(t)){var e=null;void 0!==t.data.user?e="user":void 0!==t.data.group&&(e="group"),void 0===s[e][t.action]&&(s[e][t.action]=[]);for(var i=0;i<s[e][t.action].length;i++)if(n=s[e][t.action][i],this.isSimilarMessage(n.event,t)&&(void 0===r[t.data[e]]||r[t.data[e]]<n.index))return r[t.data[e]]=n.index,n.event.data[e].push(t.data[e]),void n.event.data._d.push(this.getDifference(n.event,t));Array.isArray(t.data[e])||(t.data[e]=[t.data[e]]),t.data._d=[{}],r[t.data[e]]=o,s[e][t.action].push({event:t,index:o})}a.push(t)}.bind(this)),a)},e.moveToEnd=function(t,e){t.push(t.splice(t.indexOf(e),1)[0])},e.isSimilarMessage=function(t,e){return t.action===e.action&&this.getCompareDataString(t)===this.getCompareDataString(e)},e.getDifference=function(t,e){var i,n={};for(i in e.data)if(e.data.hasOwnProperty(i)){switch(i){case"user":case"group":case"_d":case"_i":continue}void 0!==t.data[i]&&t.data[i]===e.data[i]||(n[i]=e.data[i])}return n},e.getCompareDataString=function(t){t=Object.assign({},t.data);return delete t.user,delete t.group,delete t.viewId,delete t._d,delete t._i,JSON.stringify(t)},e.canCompact=function(t){return!(void 0!==t.ack&&null!==t.ack||void 0===t.data||void 0===t.data.user&&void 0===t.data.group)},t.unpack=function(t,e){if(void 0===t[e])return[t];var i=Array.isArray(t[e])?t[e]:[t[e]],n=[];void 0!==t._d&&(n=Array.isArray(t._d)?t._d:[t._d]);for(var s=[],o=0;o<i.length;o++){(r={})[e]=i[o];var r=Object.assign({},t,r,void 0!==n[o]?n[o]:{});delete r._d,s.push(r)}return s},Object.defineProperty(e,"length",{get:function(){return this.queue.length}}),t}),define("CatLab/Webremote/Tools/Proxy",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred"],function(o,r){function t(){}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 t.prototype.get=function(t){o.getProxy()&&(t=o.getProxy()+encodeURIComponent(t)),console.log(t);var e,i,n,s=new r;return t=t,e=function(t){s.resolve(t.responseText)},(n=function(){for(var t=!1,e=0;e<a.length;e++){try{t=a[e]()}catch(t){continue}break}return t}())&&(n.open(i?"POST":"GET",t,!0),i&&n.setRequestHeader("Content-type","application/x-www-form-urlencoded"),n.onreadystatechange=function(){4==n.readyState&&(200==n.status||304==n.status?e(n):console.error("CatLab Remote HTTP error "+n.status))},4!=n.readyState)&&n.send(i),s.promise()},new t}),define("CatLab/Webremote/Providers/Provider",["CatLab/Webremote/Synchronization/MessageQueue","CatLab/Webremote/Tools/Proxy","CatLab/Webremote/Tools/Deferred"],function(t,i,n){"use strict";function e(){this.initializeProvider()}var s=e.prototype;return s.initializeProvider=function(){this.queue=new t,this.postInitializeQueue=[],this.scheduled=!1,this.initialized=!1,this.sendBurstDelay=10,this.maxQueueSize=2500,this.messageCounter=null,this.events={}},s.getProviderSettings=function(){var t=new n;return t.resolve({}),t.promise()},s.setMessageCounter=function(t){this.messageCounter=t},s.initMaster=function(t){this.master=t},s.initPlayer=function(t){this.master=t},s.connect=function(){var t=new n;return t.resolve(),t.promise()},s.disconnect=function(){this.off()},s.setOAuthSettings=function(t){this.emit("oauth:set",t)},s.loadViews=function(t,e){(e=void 0===e?!1:e)?i.get(t).then(function(t){this.emit("view:load",{xml:t})}.bind(this)):this.emit("view:load",{url:t})},s.toMaster=function(t,e,i){this.emit(t,e,i)},s.toPlayers=function(t,e,i){this.emit(t,e,i)},s.toPlayer=function(t,e,i,n){i.user=t.getId(),this.emit(e,i,n)},s.toGroup=function(t,e,i,n){i.group=t.getId(),this.emit(e,i,n)},s.emit=function(t,e,i){this.initialized?this.queue?(this.queue.add(t,e,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(t,e,i):this.postInitializeQueue.push({action:t,data:e,ack:i})},s.createGroup=function(t,e,i,n){this.emit("group:create",{externalId:t,globalViews:e,shareColor:i,tags:n=void 0===n?[]:n})},s.executeQueue=function(){this.initialized&&this.emitAll()},s.setInitialized=function(){var t;for(this.initialized=!0;t=this.postInitializeQueue.shift();)this.emit(t.action,t.data,t.ack)},s.setup=function(t){this.emit("master:setup",t)},s.reset=function(t){this.emit("master:reset",null,function(){t()})},s.getStaticUrl=function(t){return t},s.reconnect=function(t,e,i,n){this.emit("master:reconnect",{token:t,accessToken:e,gameConfig:i},function(){n()}.bind(this))},s.off=function(){this.events={}},s.on=function(t,e){this._addEvent(t,e,!1),this._touchEvent(t)},s.once=function(t,e){this._addEvent(t,e,!0),this._touchEvent(t)},s._addEvent=function(t,e,i){void 0===this.events[t]&&(this.events[t]=[]),this.events[t].push({callback:e,once:i})},s._touchEvents=function(){for(var t in this.events)this.events.hasOwnProperty(t)&&this._touchEvent(t)},s._touchEvent=function(t){},s._trigger=function(t,i){var n;void 0!==this.events[t]&&(n=[],this.events[t].forEach(function(t){var e=t.callback;t.once&&n.push(t);try{e.apply(this,[i])}catch(t){console.error(t)}}),0<n.length)&&(n.unshift(this.events),function(t){for(var e,i,n=arguments,s=n.length;1<s&&t.length;)for(e=n[--s];-1!==(i=t.indexOf(e));)t.splice(i,1);return t}.apply(this,n))},s.getConnectURL=function(t){return null},s.getConnectToken=function(t){return null},s.tokenConnect=function(t){var e=new n;return e.resolve(),e.promise()},s.noTokenConnect=function(){var t=new n;return t.resolve(),t.promise()},s.restoreProviderSettings=function(t){},s.serializeProviderSettings=function(){return{}},e}),define("CatLab/Webremote/Providers/SocketIO",["CatLab/Webremote/Providers/Provider","CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Tools"],function(t,r,a,e){function i(){this.initializeProvider(),this.userId=null,this.randomToken=e.getUuid(),this.loadBalancerSessionToken="connid",this.socket=null,this._registeredEvents={}}var h=null,t=i.prototype=new t;return t.getProviderSettings=function(){var e=new a;return r.getServerList()?r.getServerList().getSelectedServer().done(function(t){e.resolve({host:t})}.bind(this)).fail(function(t){alert(t),e.reject(t)}.bind(this)):e.resolve({}),e.promise()},t.connect=function(n,s){var e,o=new a;return this.log("Loading socket.io"),e=function(){this.log("Connecting to socket.io");var t,e=r.getSocketURL(),i=(void 0!==s.host&&s.host&&(e=(t=r.getProtocol())?t+"://"+s.host:"//"+s.host),this.socket=h(e+"/"+n+"?"+this.loadBalancerSessionToken+"="+this.randomToken,{withCredentials:!1,reconnection:!0}),!1);this.socket.on("connect_error",function(t){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(t){this._trigger("reconnect")}.bind(this)),this._touchEvents(),o.resolve())}.bind(this))}.bind(this),require(["socket.io-client"],function(t){h=t,e()}),o.promise()},t.disconnect=function(t){void 0===t&&(t=!0),this.initialized=!1,this.socket&&((t?this:(this._registeredEvents={},this.socket)).off(),this.socket.disconnect(),this.socket=null)},t.off=function(){this._registeredEvents={},this.events={},this.socket.off()},t.setUserId=function(t){return this.userId=t,this},t.emitAll=function(){var t,e=this.queue.compactFlush();if(e.length)for(;t=e.shift();)this.emitOne(t.action,t.data,t.ack)},t.emitOne=function(t,e,i){this.socket.emit(t,e,i),this.messageCounter&&this.messageCounter.outgoing()},t.log=function(){this.master.log.apply(arguments)},t.getStaticUrl=function(t){return t.indexOf("?")<0?t+="?":t+="&",t+(this.loadBalancerSessionToken+"="+this.randomToken)},t._detachEvents=function(t){this.socket&&this.socket.off(t)},t._touchEvent=function(e){this.socket&&void 0===this._registeredEvents[e]&&(this.socket.on(e,function(t){this._trigger(e,t)}.bind(this)),this._registeredEvents[e]=!0)},t._handleSocketIoEvent=function(t,e){switch(t){case"connect":case"disconnect":break;default:return this._trigger(t,e)}},t.getConnectURL=function(t){return r.getServerList()?r.getServerList().getConnectURL():t},t.getConnectToken=function(t){return r.getServerList()?r.getServerList().getConnectToken(t):t},t.tokenConnect=function(t){var e=new a,i={};if(r.getServerList())try{var n=r.getServerList().getFromToken(t);i.host=n.host,t=n.token}catch(t){return e.reject(),e.promise()}return this.connect("remote",i).fail(function(){e.reject()}).then(function(){e.resolve(t)}),e.promise()},t.restoreProviderSettings=function(t){void 0!==t.serverlist&&r.getServerList()&&r.getServerList().unserialize(t.serverlist)},t.serializeProviderSettings=function(){var t={};return r.getServerList()&&(t.serverlist=r.getServerList().serialize()),t},i}),define("CatLab/Webremote/SonicSync/Library/ring-buffer",[],function(){function e(t){this.array=[],this.maxLength=t}return e.prototype.get=function(t){return t>=this.array.length?null:this.array[t]},e.prototype.last=function(){return 0==this.array.length?null:this.array[this.array.length-1]},e.prototype.add=function(t){this.array.push(t),this.array.length>=this.maxLength&&this.array.splice(0,1)},e.prototype.length=function(){return this.array.length},e.prototype.clear=function(){this.array=[]},e.prototype.copy=function(){var t=new e(this.maxLength);return t.array=this.array.slice(0),t},e.prototype.remove=function(t,e){this.array.splice(t,e)},e}),define("CatLab/Webremote/SonicSync/Library/sonic-coder",[],function(){function t(t){this.freqMin=(t=t||{}).freqMin||18500,this.freqMax=t.freqMax||19500,this.freqError=t.freqError||50,this.alphabetString=t.alphabet||"\n abcdefghijklmnopqrstuvwxyz0123456789,.!?@*",this.startChar=t.startChar||"^",this.endChar=t.endChar||"$",this.alphabet=this.startChar+this.alphabetString+this.endChar}return t.prototype.charToFreq=function(t){var e=this.alphabet.indexOf(t),t=(-1==e&&(console.error(t,"is an invalid character."),e=this.alphabet.length-1),this.freqMax-this.freqMin),e=e/this.alphabet.length,t=Math.round(t*e);return this.freqMin+t},t.prototype.freqToChar=function(t){if(!(this.freqMin<t&&t<this.freqMax))if(this.freqMin-t<this.freqError)t=this.freqMin;else{if(!(t-this.freqMax<this.freqError))return console.error(t,"is out of range."),null;t=this.freqMax}var e=this.freqMax-this.freqMin,t=(t-this.freqMin)/e,e=Math.round(this.alphabet.length*t);return this.alphabet[e]},t}),define("CatLab/Webremote/SonicSync/Library/sonic-server",["./ring-buffer","./sonic-coder"],function(e,i){function t(t){this.peakThreshold=(t=t||{}).peakThreshold||-65,this.minRunLength=t.minRunLength||2,this.coder=t.coder||new i(t),this.timeout=t.timeout||300,this.debug=!!t.debug,this.peakHistory=new e(16),this.peakTimes=new e(16),this.callbacks={},this.buffer="",this.state=n,this.isRunning=!1,this.iteration=0}var n=1,s=2;return t.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(t){console.log(t)}},t.prototype.stop=function(){this.isRunning=!1,this.track.stop()},t.prototype.on=function(t,e){"message"==t&&(this.callbacks.message=e),"character"==t&&(this.callbacks.character=e)},t.prototype.setDebug=function(t){this.debug=t;t=document.querySelector("canvas");t&&t.parentElement.removeChild(t)},t.prototype.fire_=function(t,e){"function"==typeof t&&t(e)},t.prototype.onStream_=function(t){var e;void 0!==t.getTracks()[0]?(this.track=t.getTracks()[0],e=new AudioContext,t=(this.audioContext=e).createMediaStreamSource(t),e=e.createAnalyser(),t.connect(e),this.freqs=new Float32Array(e.frequencyBinCount),this.analyser=e,this.isRunning=!0,this.raf_(this.loop.bind(this))):console.log("No microphone found.")},t.prototype.onStreamError_=function(t){console.error("Audio input error:",t)},t.prototype.getPeakFrequency=function(){for(var t=-1/0,e=-1,i=this.freqToIndex(this.coder.freqMin);i<this.freqs.length;i++)this.freqs[i]>t&&(t=this.freqs[i],e=i);return t>this.peakThreshold?this.indexToFreq(e):null},t.prototype.loop=function(){this.analyser.getFloatFrequencyData(this.freqs),(this.iteration+1)%300==0&&this.restartServerIfSanityCheckFails();var t=this.getPeakFrequency();t?(t=this.coder.freqToChar(t),this.debug&&console.log("Transcribed char: "+t),this.peakHistory.add(t),this.peakTimes.add(new Date)):(t=this.peakTimes.last())&&new Date-t>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},t.prototype.indexToFreq=function(t){return this.audioContext.sampleRate/2/this.freqs.length*t},t.prototype.freqToIndex=function(t){var e=this.audioContext.sampleRate/2;return Math.round(t/e*this.freqs.length)},t.prototype.analysePeaks=function(){var t=this.getLastRun();t&&(this.state==n?t==this.coder.startChar&&(this.buffer="",this.state=s):this.state==s&&(t!=this.lastChar&&t!=this.coder.startChar&&t!=this.coder.endChar&&(this.buffer+=t,this.lastChar=t,this.fire_(this.callbacks.character,t)),t==this.coder.endChar)&&(this.state=n,this.fire_(this.callbacks.message,this.buffer),this.buffer=""))},t.prototype.getLastRun=function(){for(var t=this.peakHistory.last(),e=0,i=this.peakHistory.length()-2;0<=i&&this.peakHistory.get(i)==t;i--)e+=1;return e>this.minRunLength?(this.peakHistory.remove(i+1,e+1),t):null},t.prototype.debugDraw_=function(){var t=document.querySelector("canvas");t||(t=document.createElement("canvas"),document.body.appendChild(t)),t.width=document.body.offsetWidth,t.height=480,drawContext=t.getContext("2d");for(var e=0;e<this.freqs.length;e++){var i=this.freqs[e]+400,i=t.height-i-1,n=t.width/this.freqs.length;drawContext.fillStyle="black",drawContext.fillRect(e*n,i,1,1)}},t.prototype.raf_=function(t){"undefined"==typeof window||window.chrome&&chrome.extension?setTimeout(t,1e3/60):requestAnimationFrame(t)},t.prototype.restartServerIfSanityCheckFails=function(){if(this.freqs[0]<-300)console.error("freqs[0] < -300. Restarting."),this.restart();else{for(var t=!0,e=0;e<10;e++)-100==this.freqs[e]&&(t=!1);t||(console.error("freqs[0:10] == -100. Restarting."),this.restart())}},t.prototype.restart=function(){},t}),define("CatLab/Webremote/SonicSync/Library/sonic-socket",["./sonic-coder"],function(e){var i=!1;function t(t){this.coder=(t=t||{}).coder||new e,this.charDuration=t.charDuration||.5,this.coder=t.coder||new e(t),this.rampDuration=t.rampDuration||.001,this.audioContext=new i}return"undefined"!=typeof window&&(i=window.AudioContext||window.webkitAudioContext||!1),t.prototype.send=function(t,e){t=this.coder.startChar+t+this.coder.endChar;for(var i,n=0;n<t.length;n++){var s=t[n],s=this.coder.charToFreq(s),o=this.audioContext.currentTime+this.charDuration*n;this.scheduleToneAt(s,o,this.charDuration)}e&&(i=this.charDuration*t.length,setTimeout(e,1e3*i))},t.prototype.scheduleToneAt=function(t,e,i){var n=this.audioContext.createGain(),i=(n.gain.value=0,n.gain.setValueAtTime(0,e),n.gain.linearRampToValueAtTime(1,e+this.rampDuration),n.gain.setValueAtTime(1,e+i-this.rampDuration),n.gain.linearRampToValueAtTime(0,e+i),n.connect(this.audioContext.destination),this.audioContext.createOscillator());i.frequency.value=t,i.connect(n),i.start(e)},t}),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(e,t,i,n,s,o){function r(t){this.options=e.getAudioSyncConfig(),this.alphabet=this.options.alphabet.split(""),this.controller=t}var a=r.prototype;return a.startListener=function(){this.stop();var t=new n(this.options);t.start(),t.on("message",this.onIncomingMessage.bind(this)),this.sonicServer=t},a.startSender=function(){this.sonicSocket=new s(this.options)},a.stop=function(){this.sonicServer&&this.sonicServer.stop()},a.sync=function(){var t=new o,e=this.generateRandomSequence(this.options.length);return this.sonicSocket.send(e+this.getParityLetter(e),function(){this.controller.trigger("sync:audio",{secret:e})}.bind(this)),t.promise()},a.generateRandomSequence=function(t){for(var e,i="",n="",s=0;s<t;s++){for(;e=Math.floor(Math.random()*this.alphabet.length),(n=this.alphabet[e])===i.substr(i.length-1,1););i+=n}return i},a.getParityLetter=function(t){for(var e=0,i=t.split(""),n=0;n<i.length;n++)e+=this.alphabet.indexOf(i[n]);t=e%this.alphabet.length;return i[i.length-1]===this.alphabet[t]&&(t=(t+1)%this.alphabet.length),this.alphabet[t]},a.onIncomingMessage=function(t){var e=t.substr(0,t.length-1),i=this.getParityLetter(e);i===t[t.length-1]?this.onMessage(e):console.log("Parity check failed, expected "+i+", ignoring message")},a.onMessage=function(t){this.controller.emit("sync:audio",{secret:t})},a.generateAlphabet=function(t){for(var e="",i=0;i<Math.min(t.length,9);i++)e+=i.toString();return e},r}),define("CatLab/Webremote/Tools/ClientSniffer",[],function(){"use strict";function t(){this._canPlayWebM=null}var e=t.prototype;return e.isMobileBrowser=function(){var t,e;return!this.isCordova()&&(t=!1,e=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(e)&&!/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(e.substr(0,4)))||t)},e.isCordova=function(){return"undefined"!=typeof cordova},e.isInternetExplorer=function(){var t=window.navigator.userAgent,e=t.indexOf("MSIE ");return 0<e?parseInt(t.substring(e+5,t.indexOf(".",e)),10):0<t.indexOf("Trident/")?(e=t.indexOf("rv:"),parseInt(t.substring(e+3,t.indexOf(".",e)),10)):0<(e=t.indexOf("Edge/"))&&parseInt(t.substring(e+5,t.indexOf(".",e)),10)},e.supportsLocalStorage=function(){try{if(window.localStorage)return!0}catch(t){return!1}},e.canPlayWebM=function(){if(null===this._canPlayWebM){this._canPlayWebM=!1;try{var t=document.createElement("video");t.canPlayType&&(this._canPlayWebM=t.canPlayType('video/webm; codecs="vp8, vorbis"'))}catch(t){console.error(t)}}return this._canPlayWebM},new t}),define("CatLab/Webremote/Components/ImagePositionInputComponent",["jquery","CatLab/Webremote/Tools/ClientSniffer"],function(h,t){function e(t,e){this.element=e,this.remotePlayerView=t,this.positions=[],this.canvas=null,this.isLoaded=!1,this.isRotated=!1,this.buttons=null,this.pointCountContainer=null,this.draw()}var i=e.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 src="'+this.image+'" /></div>'),this.imageElement=h(this.element).find("img"),this.imageElement.on("load",function(){this.isLoaded=!0,this.resizeImage()}.bind(this)),this.imageElement.on("dragstart",function(t){t.preventDefault()}),this.svgContainer=h('<div class="pointer-container">'),this.element.find(".image").append(this.svgContainer),this.resizeSvgContainer(),this.svgContainer.click(function(t){this.svgClick(t)}.bind(this)))},i.resizeSvgContainer=function(){var t=this.imageElement;this.isRotated&&this.rotatedImageElement&&(t=this.rotatedImageElement),this.svgContainer.css({position:"absolute","z-index":1,width:t.width(),height:t.height(),left:t.position().left,top:t.position().top})},i.resizeImage=function(){this.isLoaded&&(this.element.width(),this.element.height(),this.imageElement.get(0).naturalWidth,this.imageElement.get(0).naturalHeight,t.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 t,e,i,n,s,o,r,a;this.rotatedImageElement||(s=this.imageElement[0],t=this.imageElement.get(0).naturalWidth,e=this.imageElement.get(0).naturalHeight,(i=document.createElement("canvas")).width=e,i.height=t,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,-t/2,-e/2),this.rotatedImageElement=h(i),this.element.find("div.image").append(this.rotatedImageElement))},i.imageClick=function(t){var e=t.offsetX/this.imageElement.width(),t=t.offsetY/this.imageElement.height();this.selectPosition(e,t)},i.svgClick=function(t){var e=t.offsetX/this.svgContainer.width(),t=t.offsetY/this.svgContainer.height();this.isRotated?this.selectPosition(1-t,e):this.selectPosition(e,t)},i.canvasClick=function(t){var e=t.offsetX/this.rotatedImageElement.width(),t=t.offsetY/this.rotatedImageElement.height();this.selectPosition(1-t,e)},i.selectPosition=function(t,e){0<this.getMaxPoints()&&this.positions.length>=this.getMaxPoints()||(this.positions.push({x:t,y:e}),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(e){var t=this.imageElement,i=e.x,n=e.y,s=t.width(),t=t.height(),o=(this.isRotated&&this.rotatedImageElement&&(i=e.y,n=1-e.x,s=this.rotatedImageElement.width(),t=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(t){t.preventDefault(),t.stopPropagation(),this.removePoint(e),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:t*n-o-r})}.bind(this))},i.removePoint=function(t){t=this.positions.indexOf(t);-1<t&&this.positions.splice(t,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()},e.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; } ",e.selector="image-position-input",e}),define("CatLab/Webremote/Components/FullscreenButtonComponent",["jquery","screenfull","CatLab/Webremote/Config"],function(t,e,i){function n(t,e,i){this.element=e,this.remotePlayerView=t,this.position=null,this.componentContainer=i,this.draw()}var s=n.prototype;return s.draw=function(){i.canFullscreen()&&e&&e.isEnabled&&!e.isFullscreen?(t(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>'),t(this.element).click(function(){e.request(null,{navigationUI:"hide"})}.bind(this))):t(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(e){function t(t,e){this.element=e,this.remotePlayerView=t,this.position=null,this.draw()}var i=t.prototype;return i.draw=function(){if(this.element){e(this.element).html("");for(var t=0;t<this.content.childNodes.length;t++)e(this.element).append(this.content.childNodes[t].cloneNode(!0));this.componentContainer.attachComponents(this.remotePlayerView,this.element)}},i.update=function(){this.draw()},i.resize=function(){this.draw()},i.destroy=function(){},t.css=" ",t.selector="view-defined-component",t.content="",t}),define("CatLab/Webremote/Views/Popups/IframePopup",["CatLab/Webremote/Views/Popups/BasePopup"],function(t){function e(t){this.url=t}return(e.prototype=new t).renderContent=function(t){this.container.className+=" iframe";var e=$('<iframe src="'+this.url+'"></iframe>');$(e).css({height:"99%",width:"100%","border-width":0}),$(t).append(e),$(t).css({position:"relative",height:"100%",width:"100%","box-sizing":"border-box",overflow:"auto","-webkit-overflow-scrolling":"touch"})},e}),define("CatLab/Webremote/Components/ModalIframeLink",["jquery","CatLab/Webremote/Views/Popups/IframePopup"],function(e,i){function t(t,e,i){this.element=e,this.remotePlayerView=t,this.position=null,this.componentContainer=i,this.draw()}var n=t.prototype;return n.draw=function(){e(this.element).off("click"),e(this.element).on("click",function(){var t=e(this.element).attr("href"),t=this.remotePlayerView.stringInterpolateDataElements(t,encodeURIComponent);new i(t).render(document.body)}.bind(this))},n.resize=function(){this.draw()},n.update=function(){this.draw()},n.destroy=function(){},t.css=" ",t.selector="modal-iframe-link",t}),define("CatLab/Webremote/Views/Popups/TextPopup",["CatLab/Webremote/Views/Popups/BasePopup"],function(t){function e(t){this.message=t}return(e.prototype=new t).renderContent=function(t){var e=(e=this.message).replace(/(?:\r\n|\r|\n)/g,"<br>");t.innerHTML=e},e}),define("CatLab/Webremote/Components/TooltipComponent",["jquery","CatLab/Webremote/Views/Popups/TextPopup"],function(t,e){function i(t,e,i){this.element=e,this.remotePlayerView=t,this.position=null,this.componentContainer=i,this.draw()}var n=i.prototype;return n.draw=function(){t(this.element).off("click"),t(this.element).on("click",function(){new e(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(e,i,n){"use strict";var s,o=null,t=0;function r(){e(".simple-keyboard").addClass("hidden"),o=null}function a(t,e,i){this.element=e,this.remotePlayerView=t,this.position=null,this.componentContainer=i,this.inputType=e.attr("type")?e.attr("type").toLowerCase():"text",this.draw()}var h=a.prototype;return h.draw=function(){(function(){var t=e.Deferred();e("<link>").appendTo("head").attr({type:"text/css",rel:"stylesheet",href:n.getVendorPath()+"simple-keyboard/build/css/index.css"}),e('<div class="simple-keyboard"></div>').appendTo("body"),s=new i.default({onChange:function(t){o&&o.onKeyboardChange(t)}.bind(this),onKeyPress:function(t){switch(t){case"{shift}":case"{lock}":e="default"===s.options.layoutName?"shift":"default",s.setOptions({layoutName:e});break;case"{numbers}":case"{abc}":e="numbers"!==s.options.layoutName?"numbers":"default",s.setOptions({layoutName:e});break;case"{ent}":r();break;case"{arrowup}":o.increaseValue(1);break;case"{arrowdown}":o.increaseValue(-1)}var e}.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"}}),e(".simple-keyboard").addClass("hidden"),t.promise()})(),this.element.attr("id")||this.element.attr("id","input_"+ ++t),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 t;"number"===(t=this).inputType?s.setOptions({inputName:t.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:t.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}"]}}),e(".simple-keyboard").removeClass("hidden"),o=t,s.setInput(t.element.val(),t.element.attr("id"))},h.onKeyboardChange=function(t){var e;this.element.val(t),this.element.trigger("change"),this.element.attr("data-value-realtime")&&(e=this.element.attr("data-value-id"))&&this.remotePlayerView.controller.syncValue(e,t,this.remotePlayerView.viewId)},h.onInputChange=function(){s.setInput(this.element.val(),this.element.attr("id"))},h.onInputFocus=function(){this.showKeyboard()},h.setInputCaretPosition=function(t){this.element[0].setSelectionRange&&(this.element[0].focus(),this.element[0].setSelectionRange(t,t))},h.increaseValue=function(t){var e;"number"===this.inputType&&(e=(e=parseFloat(this.element.val()))||0,this.element.val(e+t))},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(e){function t(t,e){this.element=e,this.remotePlayerView=t,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=t.prototype;return i.draw=function(){var t;e(this.element).html(""),this.targetDate=this.element.attr("to"),this.targetDate&&(this.element.attr("start")&&(this.startDate=this.element.attr("start")),t=e('<div class="timer-container"></div>'),this.counterHtml=e('<div class="countdown"></div>'),t.append(this.counterHtml),this.progessBar=e('<div class="progress-bar"> </div>'),t.append(this.progessBar),e(this.element).append(t))},i.tick=function(){var t,e;this.targetDate&&this.counterHtml&&this.progessBar&&((t=this.targetDate-Date.now())<0?this.counterHtml.html("0"):(e=(Date.now()-this.startDate)/(this.targetDate-this.startDate)*100,this.counterHtml.html(Math.ceil(t/1e3)),this.progessBar.css("width",e+"%")))},i.resize=function(){},i.update=function(){this.draw()},i.clearInterval=function(){this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null)},i.destroy=function(){this.clearInterval()},t.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; } ",t.selector="timer-countdown",t}),define("CatLab/Webremote/Components/SmileyFlingerComponent",["jquery","CatLab/Webremote/Views/Blocks/CurrentSmiley"],function(t,n){function e(t,e,i){this.element=e,this.remotePlayerView=t,this.position=null,this.componentContainer=i,this.smileySlinger=new n(i.Webremote,!0,!0,!1),this.draw()}var i=e.prototype;return i.draw=function(){this.smileySlinger.render(this.element)},i.resize=function(){this.draw()},i.update=function(){this.draw()},i.destroy=function(){},e.css=" ",e.selector="smiley-flinger",e}),define("CatLab/Webremote/Components/Components",["jquery","./ImagePositionInputComponent","./FullscreenButtonComponent","./ViewDefinedComponent","./ModalIframeLink","./TooltipComponent","./VirtualKeyboardComponent","./TimerComponent","./SmileyFlingerComponent"],function(s,e,i,o,n,r,a,h,l){function t(t){this.components=[e,i,n,r,a,h,l],this.Webremote=t,this.viewDefinedComponents=[],this.existingComponents=[]}var c=t.prototype;return c.initialize=function(){for(var t=0;t<this.components.length;t++)this.initializeComponent(this.components[t])},c.initializeComponent=function(t){t.css;var e=document.createElement("style");e.attributes.type="text/css",e.innerHTML=t.css,document.head.appendChild(e)},c.resetViewDefinedComponents=function(){for(var t=0;t<this.viewDefinedComponents.length;t++)this.removeComponent(this.viewDefinedComponents[t])},c.removeComponent=function(t){for(var e=0;e<this.components.length;e++)if(this.components[e].selector===t)return void this.components.splice(e,1)},c.addComponent=function(t){0<=this.components.indexOf(t)||(this.components.push(t),this.initializeComponent(t))},c.addViewDefinedComponent=function(t,n){for(var e=0;e<this.components.length;e++)if(this.components[e].selector===t)return;function i(t,e,i){this.element=e,this.remotePlayerView=t,this.position=null,this.content=n,this.componentContainer=i,this.draw()}this.viewDefinedComponents.push(t),i.prototype=new o,i.selector=t,i.content=n,this.components.push(i)},c.attach=function(t,e,i){(i=void 0===i?!0:i)&&(this.existingComponents.forEach(function(t){t.destroy()}.bind(this)),this.existingComponents=[]),this.attachComponents(t,e)},c.resize=function(){this.existingComponents.forEach(function(t){t.resize()}.bind(this))},c.update=function(){this.existingComponents.forEach(function(t){t.update()}.bind(this))},c.attachComponents=function(t,e){for(var i=0;i<this.components.length;i++)try{this.attachComponent(t,e,this.components[i])}catch(t){console.log(t)}},c.attachComponent=function(i,t,n){s(t).find(n.selector).each(function(t,e){e=new n(i,s(e),this);this.existingComponents.push(e)}.bind(this))},t}),!function(){!function(t,e){"use strict";"function"==typeof define&&define.amd?define("viewport-units-buggyfill",[],e):"object"==typeof exports?module.exports=e():t.viewportUnitsBuggyfill=e()}(this,function(){"use strict";var a,h,l,i,t,n=!1,e=window.navigator.userAgent,c=/([+-]?[0-9.]+)(vh|vw|vmin|vmax)/g,s=/(https?:)?\/\//,u=[].forEach,d=/MSIE [0-9]\./i.test(e),p=/MSIE [0-8]\./i.test(e),f=-1<e.indexOf("Opera Mini"),g=/(iPhone|iPod|iPad).+AppleWebKit/i.test(e)&&(t=e.match(/OS (\d)/))&&1<t.length&&parseInt(t[1])<10,m=-1<e.indexOf(" Android ")&&-1<e.indexOf("Version/")&&parseFloat((e.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(t,e){var i;return e=e||{bubbles:!1,cancelable:!1,detail:void 0},(i=document.createEvent("CustomEvent")).initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i};v.prototype=window.Event.prototype,window.CustomEvent=v}function b(){n&&(o(),setTimeout(function(){i.textContent=A(),i.parentNode.appendChild(i),window.dispatchEvent(new v("viewport-units-buggyfill-style"))},1))}function o(){return l=[],u.call(document.styleSheets,function(t){var e=function(t){try{if(!t.cssRules)return}catch(t){if("SecurityError"!==t.name)throw t;return}for(var e=[],i=0;i<t.cssRules.length;i++){var n=t.cssRules[i];e.push(n)}return e}(t);!e||"patched-viewport"===t.ownerNode.id||"ignore"===t.ownerNode.getAttribute("data-viewport-units-buggyfill")||t.media&&t.media.mediaText&&window.matchMedia&&!window.matchMedia(t.media.mediaText).matches||u.call(e,r)}),l}function r(i){if(7===i.type){var t;try{t=i.cssText}catch(t){return}c.lastIndex=0,c.test(t)&&!s.test(t)&&(l.push([i,null,t]),a.hacks)&&a.hacks.findDeclarations(l,i,null,t)}else i.style?u.call(i.style,function(t){var e=i.style.getPropertyValue(t);i.style.getPropertyPriority(t)&&(e+=" !important"),c.lastIndex=0,c.test(e)&&(l.push([i,t,e]),a.hacks)&&a.hacks.findDeclarations(l,i,t,e)}):i.cssRules&&u.call(i.cssRules,function(t){r(t)})}function A(){var t=window.innerHeight,e=window.innerWidth;h={vh:t,vw:e,vmax:Math.max(e,t),vmin:Math.min(e,t)};var n,s,o=[],r=[];return l.forEach(function(t){var t=function(t,e,i){var n=[];i=i.replace(c,y),a.hacks&&(i=a.hacks.overwriteDeclaration(t,e,i)),e&&(n.push(t.selectorText),i=e+": "+i+";");for(var s=t.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,t),e=t.selector.length?t.selector.join(" {\n")+" {\n":"",i=new Array(t.selector.length+1).join("\n}");e&&e===n?(e&&!n&&(n=e,s=i),r.push(t.content)):(r.length&&(o.push(n+r.join("\n")+s),r.length=0),e?(n=e,s=i,r.push(t.content)):(o.push(t.content),s=n=null))}),r.length&&o.push(n+r.join("\n")+s),f&&o.push("* { content: normal !important; }"),o.join("\n\n")}function y(t,e,i){i=h[i];return parseFloat(e)/100*i+"px"}function w(t){return t.slice(0,t.indexOf("/",t.indexOf("://")+3))}return{version:"0.6.1",findProperties:o,getCss:A,init:function(t){if(!n){if((a=(t=!0===t?{force:!0}:t)||{}).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 e,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),e=function(){function t(){var t=this,e=arguments;clearTimeout(s),s=setTimeout(function(){i.apply(t,e)},n)}var i,n,s;i=b,n=a.refreshDebounceWait||100;window.addEventListener("orientationchange",t,!0),window.addEventListener("pageshow",t,!0),(a.force||d||function(){try{return window.self!==window.top}catch(t){return 1}}())&&(window.addEventListener("resize",t,!0),a._listeningToResize=!0),a.hacks&&a.hacks.initializeEvents(a,b,t),b()},o=0,r=function(){--o||e()},u.call(document.styleSheets,function(t){if(t.href&&w(t.href)!==w(location.href)&&"ignore"!==t.ownerNode.getAttribute("data-viewport-units-buggyfill")){o++;var e=t.ownerNode,i=r,t=e.href,n=i,s=new XMLHttpRequest;if("withCredentials"in s)s.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)throw new Error("cross-domain XHR not supported");(s=new XDomainRequest).open("GET",t)}s.onload=function(){var t=document.createElement("style");t.media=e.media,t.setAttribute("data-href",e.href),t.textContent=this.responseText,e.parentNode.replaceChild(t,e),i()},s.onerror=n,s.send()}}),o||e()}},refresh:b}})}(),!function(){!function(t,e){"use strict";"function"==typeof define&&define.amd?define("viewport-units-buggyfill.hacks",[],e):"object"==typeof exports?module.exports=e():t.viewportUnitsBuggyfillHacks=e()}(this,function(){"use strict";var r=/calc\(/g,a=/["']/g,t=window.navigator.userAgent,n=(n=/MSIE [0-9]\./i.test(t))||!!navigator.userAgent.match(/MSIE 10\.|Trident.*rv[ :]*1[01]\.| Edge\/1\d\./);return{required:function(t){return t.isMobileSafari||n},initialize:function(){},initializeEvents:function(t,e,i){t.force||n&&!t._listeningToResize&&(window.addEventListener("resize",i,!0),t._listeningToResize=!0)},findDeclarations:function(t,e,i,n){var s,o;null!==i&&(s=t,o=e,t=n,"content"===i)&&-1<t.indexOf("viewport-units-buggyfill")&&t.replace(a,"").split(";").forEach(function(t){var e,t=t.split(":");2===t.length&&"viewport-units-buggyfill"!==(e=t[0].trim())&&(t=t[1].trim(),s.push([o,e,t]),r.test(t))&&(t=t.replace(r,"-webkit-calc("),s.push([o,e,t]))})},overwriteDeclaration:function(t,e,i){return i=n&&"filter"===e?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(t,e,i){t.addEventListener?t.addEventListener(e,i,!1):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}var Webremote=function(){};function getParameterByName(t,e){e=e||window.location.href,t=t.replace(/[\[\]]/g,"\\$&");t=new RegExp("[?&]"+t+"(=([^&#]*)|&|#|$)").exec(e);return t?t[2]?decodeURIComponent(t[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(t,e){void 0!==e.token?this.token=e.token:this.token=getParameterByName("token"),void 0===e&&(e={}),this.setContainer(t),this.showLoading(),this.sonicSync=null,this.components=new Components(this),this.components.initialize(),this._initialize(e).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(t){return(t=void 0===t?{}:t).headless=!0,this._initialize(t)},_initialize:function(e){var i=new Deferred;return Config.set(e),Config.initialize(function(){Tracker.track("App","Initialize"),void 0===e.provider&&(e.provider=new SocketIOProvider),void 0!==e.headless&&(this._headless=!!e.headless),this.provider=e.provider,this.smileys=new Smileys(this.provider),this.provider.initPlayer(this),this.provider.on("disconnect",function(t){var e=this.getConnectionIssuesView();console.log("Connection lost... reconnecting"),e.show(),e.text(i18n.t("Connection lost... reconnecting"))}.bind(this)),this.provider.on("reconnect",function(t){this.provider.emit("user:reconnect",{id:this.gamedata.id,accessToken:this.gamedata.accessToken}),this.getConnectionIssuesView().hide()}.bind(this)),this.provider.on("user:error",function(t){var e;this._connectingDfd&&(e=this._connectingDfd,this._connectingDfd=null,e.reject(t.message))}.bind(this)),this.provider.on("user:initialize",function(t){this.gamedata=t,this.provider.setUserId(t.id),this._storeGameData(t),this._connectingDfd&&(t=this._connectingDfd,this._connectingDfd=null,t.resolve())}.bind(this)),this.provider.on("view:load",function(t){this.loadViewsXML(t.xml)}.bind(this)),this.provider.on("view:reset",function(t){this.resetViews()}.bind(this)),this.provider.on("config:set",function(t){if(Config.set(t),this.sonicSync&&this.sonicSync.stop(),Config.useAudioSync())try{this.sonicSync=new SonicSyncClient(this),this.sonicSync.startListener()}catch(t){console.error(t)}}.bind(this)),this.provider.on("view:set",function(t){this.showView(t.id,t.viewId,t.group),this.handleCombinedMessages(t)}.bind(this)),this.provider.on("button:label",function(t){this.setLabel(t)}.bind(this)),this.provider.on("button:decorate",function(t){this.setClass(t)}.bind(this)),this.provider.on("oauth:set",function(t){Config.supportsAuthentication()&&(OAuth2.initialize(t),this.isOauth2Set=!0,UsersCollection.initialize(this,OAuth2),HashParser.getParameter("access_token"))&&(t=HashParser.getParameter("access_token"),UsersCollection.addFromAccessToken(t,function(t){t&&this.setUser(t)}.bind(this)),HashParser.clear())}.bind(this)),this.provider.on("color:set",function(t){this.setPlayerColor(t.color)}.bind(this)),this.provider.on("user:smiley",function(t){this.setSmiley(t.smiley)}.bind(this)),this.provider.on("smileys:taken",function(t){this.smileys.setTakenSmileys(t.smileys)}.bind(this)),this.provider.on("game:disconnect",function(t){AlertPopup(i18n.t("You have been disconnected from the game."),function(){window.location.reload()})}.bind(this)),this.provider.on("dom:append",function(t){this.domAppend(t)}.bind(this)),this.provider.on("dom:replace",function(t){this.domReplace(t)}.bind(this)),this.provider.on("dom:attribute",function(t){this.domAttribute(t)}.bind(this)),this.provider.on("dom:alert",function(t){AlertPopup(t.message)}),this.provider.on("dom:open",function(t){void 0!==t.url&&window.open(t.url)}),this.provider.on("value:change",function(t){this.changeValue(t)}.bind(this)),this.provider.on("device:vibrate",function(t){this.vibrate(t)}.bind(this)),this.provider.on("game:pause",function(t){this.pause(t)}.bind(this)),this.provider.on("game:unpause",function(t){this.unpause(t)}.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 t=[this.userData,this.groupData],n=[this.userEvents,this.groupEvents];DataSynchronizer.eventsToListenFor.forEach(function(i){this.provider.on(i,function(e){t.forEach(function(t){t.checkNamespace(e)&&t.processMessage(i,e)})}.bind(this))}.bind(this)),EventHandler.eventsToListenFor.forEach(function(i){this.provider.on(i,function(e){n.forEach(function(t){t.checkNamespace(e)&&t.processMessage(i,e)})}.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(t){this.gamedata?(this.provider.emit("user:reconnect",{id:this.gamedata.id,accessToken:this.gamedata.accessToken}),this.provider.once("user:reconnect",function(){t()})):t()},connectProvider:function(t){return this.provider.tokenConnect(t)},_storeGameData:function(){var t=new Deferred,e=this._connectedToken;return Storage.set("gamestate_"+e,this.gamedata,function(){t.resolve()},864e5),t.promise()},_restoreGameData:function(){var e=new Deferred,t=this._connectedToken;return Storage.get("gamestate_"+t,function(t){t?(this.gamedata=t,e.resolve(!0)):e.resolve(!1)}.bind(this)),e.promise()},handleCombinedMessages:function(t){for(var e=[{name:"button:label",method:this.setLabel.bind(this)},{name:"button:decorate",method:this.setClass.bind(this)}],i=0;i<e.length;i++){var n=e[i].name,s=e[i].method;if(void 0!==t[n])for(var o=0;o<t[n].length;o++)s(t[n][o])}},emit:function(t,e){this.provider.toMaster(t,e)},getConnectionIssuesView:function(){return void 0===this.connectionTrouble&&(this.connectionTrouble=new ConnectionTroubleView),this.connectionTrouble},setGamePausedView:function(t){this.gamePaused=t},getGamePausedView:function(){return void 0===this.gamePaused?new GamePausedView:this.gamePaused},setContainer:function(t){domelement=t,this.element=t,dynamicStylesheet=document.createElement("style"),document.body.appendChild(dynamicStylesheet),document.body.className="catlab-remote"},on:function(t,e){void 0===triggers[t]&&(triggers[t]=[]),triggers[t].push(e)},trigger:function(t){var e=[].slice.apply(arguments);if(e.shift(),void 0!==triggers[t])for(var i=0;i<triggers[t].length;i++)triggers[t][i].apply(this,e)},loadViews:function(t,e){var i;e=e||function(){},this._headless?e():((i=new XMLHttpRequest).open("GET",Config.getProxy()+t,!0),i.onreadystatechange=function(){4==i.readyState&&200==i.status&&(this.loadViewsXML(i.responseText),e())}.bind(this),i.send())},resetViews:function(){this.views={},this.components.resetViewDefinedComponents();for(var t=0;t<this.stylesheets.length;t++)try{var e=this.stylesheets[t];e.parentNode&&e.parentNode.removeChild(e)}catch(t){console.error(t)}for(t=0;t<this.links.length;t++)try{var i=this.links[t];i.parentNode&&i.parentNode.removeChild(i)}catch(t){console.error(t)}this.stylesheets=[]},loadViewsXML:function(t,e){if(e=e||function(){},!this._headless){var i;if(Tracker.track("App","Load Views"),window.DOMParser?i=(new DOMParser).parseFromString(t,"text/xml"):((i=new ActiveXObject("Microsoft.XMLDOM")).async=!1,i.loadXML(t)),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(),e(),!0}e()},evalScript:function(xml){var aWebremote=Webremote;!function(){try{var Webremote=aWebremote;eval(xml.textContent)}catch(e){console.error(e)}}.bind(window)()},loadView:function(t){var e=t.getAttribute("id"),i=document.createElement("div"),n=!1;t.getAttribute("iframe")&&"false"!==t.getAttribute("iframe").toLowerCase()&&(n=!0);for(var s=0;s<t.childNodes.length;s++)i.appendChild(t.childNodes[s].cloneNode(!0));i.id=e,i.className="view "+t.className,this.views[e]={iframe:n,html:(new XMLSerializer).serializeToString(i)},this._currentViewId===e&&this.showView(this._currentViewId,this._currentViewViewId,this._currentViewGroupId)},loadComponent:function(t){for(var e=t.getAttribute("id"),i=document.createElement("div"),n=0;n<t.childNodes.length;n++)i.appendChild(t.childNodes[n].cloneNode(!0));this.components.addViewDefinedComponent(e,i)},showView:function(t,e,i){var n,s;this._headless||(this._currentView&&this._currentView.destroy(),"remote:authenticate"!==t?(this._currentViewId=t,this._currentViewViewId=e,this._currentViewGroupId=i,void 0!==this.views[t]?(n=(i?this.groupData:this.userData).getFromIdentifier("view:"+e),s=this.views[t],this._currentView=new ClientRemoteView(this,e,t,i,n,s.iframe),this._currentView.html=s.html,this._currentView.render(this.element),this.updateUser(),Tracker.track("App","Show View",t),this.trigger("remote:view:show",{id:t,view:this._currentView}),this.trigger("view:set",this._currentView)):this.element.innerHTML='<div class="loading"><p>Please wait, loading...</p><p>(Loading view: '+t+")</div></p>"):this.showAuthenticationView())},updateUser:function(){Tracker.track("App","Set user");var t=document.getElementById("authentication");t&&new CurrentUser(this).render(t),this._currentSmileyViews=[],Config.useSmileys()?(this.setSmileySelectViews(),this.setSmileyViews()):this.removeSmileyViews()},setSmileySelectViews:function(){for(var t=document.getElementsByTagName("smiley-select"),e=0;e<t.length;e++){var i=!t[e].hasAttribute("flingable")||"false"!==t[e].getAttribute("flingable"),i=new CurrentSmiley(this,!0,i);i.render(t[e]),this.smiley&&i.setSmiley(this.smiley),this._currentSmileyViews.push(i)}},setSmileyViews:function(){for(var t=document.getElementsByTagName("smiley"),e=0;e<t.length;e++){var i=t[e].hasAttribute("changeable")&&"false"!==t[e].getAttribute("changeable"),n=t[e].hasAttribute("flingable")&&"false"!==t[e].getAttribute("flingable"),i=new CurrentSmiley(this,i,n);i.render(t[e]),this.smiley&&i.setSmiley(this.smiley),this._currentSmileyViews.push(i)}},removeSmileyViews:function(){for(var t=document.getElementsByTagName("smiley-select"),e=0;e<t.length;e++)t[e].parentNode.removeChild(t[e]);for(t=document.getElementsByTagName("smiley"),e=0;e<t.length;e++)t[e].parentNode.removeChild(t[e]);for(var i=document.getElementsByClassName("if-config-smileys"),e=0;e<i.length;e++)i[e].parentNode.removeChild(i[e])},popup:function(t){new WelcomePopup(t).render(domelement)},showAuthenticationPopup:function(t){t=t||!1;var e=new AuthenticationPopup(this);e.render(domelement),t&&e.connect()},showSmileyPopup:function(t,e){void 0===t&&(t=function(t){this.selectSmiley(t)}.bind(this)),new SelectSmileyPopup(this,t,e=void 0===e?!0:e).render(domelement)},showAuthenticationView:function(){this.element&&(this.element.innerHTML='<p id="catlab-message">Please login.</p>',OAuth2.link({fullscreen:!0}).then(function(t){t?(this.setUser(t),this.element.innerHTML='<p id="catlab-message">Welcome! You may now close this screen.</p>',window.close()):this.showAuthenticationView()}.bind(this)))},buttonDown:function(t,e){this.provider.toMaster("button:down",{id:t})},buttonUp:function(t,e,i){this.provider.toMaster("button:up",{id:t,click:i=void 0!==i&&i}),this.trigger("user:interaction")},syncValue:function(t,e,i){return this.provider.toMaster("value:change",{id:t,value:e,viewId:i}),!1},showLoading:function(){this.element&&(this.element.innerHTML='<p id="catlab-loading">Connecting...</p>')},showTokenForm:function(){function e(t){var e=i.connect(t);t!==Cookies.getItem("last_token")&&Cookies.removeItem("last_token"),e.then(function(){Cookies.setItem("last_token",t,.25)}.bind(this)),e.fail(function(t){i.showTokenForm(),screenfull.enabled&&screenfull.isFullscreen&&screenfull.exit(),AlertPopup(t)}),i.showLoading(),i.trigger("remote:token:submit"),i.trigger("user:interaction")}var t=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",t.innerHTML="",t.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&&e(n),t.onsubmit=function(t){t.preventDefault();t=document.getElementById("token").value;return e(t),!1},this.element.innerHTML="",this.element.appendChild(t)},requestFullScreen:function(){screenfull.enabled&&!screenfull.isFullscreen&&screenfull.request()},connect:function(t){return t=t.replace(" ",""),null!==this._connectingDfd&&(this._connectingDfd.reject(),this._connectingDfd=null),this._connectingDfd=new Deferred,this._connectedToken=t,this._connectingDfd.fail(function(){this.provider.disconnect(!1)}.bind(this)),this.connectProvider(t).fail(function(){setTimeout(function(){this._connectingDfd.reject(i18n.t("Game not found. Please check your token."))}.bind(this),1)}.bind(this)).then(function(e){var i=!0;"0"===getParameterByName("reconnect")&&(i=!1),this._restoreGameData().then(function(t){t&&i?this.reconnect(function(){this._connectingDfd.resolve()}.bind(this)):this.provider.emit("user:join",{token:e})}.bind(this))}.bind(this)),this._connectingDfd.promise()},setLabel:function(t){this._currentView&&this._currentView.setLabel(t.id,Tools.nl2br(Tools.sanitize(t.label)))},setClass:function(t){this._currentView&&this._currentView.setClass(t.id,t.styles)},setPlayerColor:function(t){if(this.color=t,void 0!==dynamicStylesheet&&dynamicStylesheet){var e,i,n="",s=(dynamicStylesheet.innerHTML=(n+=".player-color-border { border-color:"+t+"; }")+(".player-color-background { background-color: "+t+"; }")+(".player-color { color: "+t+"; }"),{"theme-color":t,"msapplication-navbutton-color":t,"apple-mobile-web-app-status-bar-style":t});for(e in s)s.hasOwnProperty(e)&&((i=document.createElement("meta")).httpEquiv=e,i.content=s[e],document.getElementsByTagName("head")[0].appendChild(i))}},setSmiley:function(e){this.smiley=e,this._currentSmileyViews.forEach(function(t){t.setSmiley(e)})},getSmiley:function(){return this.smiley},selectSmiley:function(t){this.provider.toMaster("user:smiley",{smiley:t})},setUser:function(t){user=t,this.updateUser(),user?(this.provider.toMaster("user:login",{access_token:user.getAccessToken()}),Storage.set("currentuser",user.getAccessToken()),this.getSmiley()&&(t=user.getAvatarSmiley())&&this.selectSmiley(t)):(this.provider.toMaster("user:logout"),Storage.set("currentuser",null))},getUser:function(){return user},listViews:function(){var t,e=[];for(t in this.views)this.views.hasOwnProperty(t)&&e.push({name:t});return e},getRandomText:function(t,e){var i="abcdefghijklmnopqrstuvwyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";void 0===e&&(e=40);for(var n="",s=(t=void 0===t?10:t)+Math.random()*e,o=0;o<s;o++)n+=i.charAt(Math.floor(Math.random()*i.length)),.8<Math.random()&&(o++,n+=" ");return n},randomLabels:function(t,e){for(var i=domelement.querySelectorAll("[data-button-label]"),n=0;n<i.length;n++)i[n].innerHTML=this.getRandomText(t,e);this.update()},setOrientation:function(){if(window.innerHeight>=window.innerWidth)try{document.body.classList.remove("landscape"),document.body.classList.add("portrait")}catch(t){document.body.className="portrait"}else try{document.body.classList.add("landscape"),document.body.classList.remove("portrait")}catch(t){document.body.className="landscape"}this.components.resize()},domAppend:function(t){this._currentView&&(this._currentView.domAppend(t.id,t.html),this.components.update())},domReplace:function(t){this._currentView&&(this._currentView.domReplace(t.id,t.html),this.components.update())},domAttribute:function(t){this._currentView&&(this._currentView.domAttribute(t.id,t.name,t.value),this.components.update())},changeValue:function(t){this._currentView&&this._currentView.changeValue(t)},vibrate:function(t){this._currentView&&this._currentView.vibrate(t)},pause:function(t){void 0===this._gamePausedView&&(this._gamePausedView=this.getGamePausedView()),this._gamePausedView.show()},unpause:function(t){void 0!==this._gamePausedView&&this._gamePausedView.hide()},log:function(t){Config.debug()&&console.log(t)},canAuthenticate:function(){return this.isOauth2Set},getGroupIds:function(){return void 0===this.gamedata.groups?[]:this.gamedata.groups},resolveDataAttribute:function(t){if("token"===t)return this._connectedToken;var i,t=(t="data."===t.substring(0,5)?t.substring(5):t).split("."),e=(2!==t.length&&t.unshift("any"),t.shift()),t=t.shift();if(e===user)return this.userData.getFromIdentifier("user").get(t);if("group"===e.substring(0,5)){var n,s=this.getGroupIds();if(0===s.length)return null;if("group"===e)return this.groupData.getFromIdentifier("group:"+s[0]).get(t);if("]"===e.substring(e.length,1))return void 0===s[n=e.substr(e.substring(6,e.length-1))]?null:this.groupData.getFromIdentifier("group:"+s[n]).get(t)}return"any"===e&&(i=["user."+t],this.getGroupIds().forEach(function(t,e){i.push("group["+e+"]")}.bind(this))),null}},Webremote}),define("CatLab/Webremote/Tools/Colorwheel",[],function(){var t={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 t=this.colors[this.index%this.colors.length];return this.index++,t}};return t.initialize(),t}),define("CatLab/Webremote/Collections/Users",["CatLab/Webremote/Tools/Colorwheel"],function(i){"use strict";return function(){this.users=[],this.userMap={},this.add=function(t){var e;t.isColorSet()||(e=i.next(),t.setColor(e.color,e.name)),t.hasPlayerId()||t.setPlayerId(this.count()+1),this.users.push(t),this.userMap[t.getId()]=t},this.clear=function(){this.users=[],this.userMap={}},this.remove=function(t){this.users.splice(users.indexOf(t),1),void 0!==this.users[t.getId()]&&delete this.users[t.getId()]},this.getFromId=function(t){return void 0!==this.userMap[t]?this.userMap[t]:null},this.getAll=function(){return this.users},this.count=function(){return this.users.length},this.each=function(t){for(var e=0;e<this.users.length;e++)t(this.users[e])},this.not=function(i){var n=[];return this.each(function(t){for(var e=0;e<i.length;e++)if(i[e].getId()===t.getId())return void n.push(i[e])}),n}}}),define("CatLab/Webremote/Collections/Groups",["CatLab/Webremote/Tools/Colorwheel"],function(i){"use strict";return function(){var e;this.groups=[],this.groupMap={},this.add=function(t){var e;t.colorSet||(e=i.next(),t.setColor(e.color,e.name)),this.groupMap[t.getId()]=t,this.groups.push(t)},this.clear=function(){this.groups=[],this.groupMap=[]},this.addUser=function(t){for(var e,i=t.groupIds,n=!1,s=0;s<i.length;s++)(e=this.getFromId(i[s]))&&(n=!0,e.addUser(t),e.isShareColor())&&t.setColor(e.getColor(),e.getColorName());return n},this.remove=function(t){this.groups.splice(this.groups.indexOf(t),1),delete this.groupMap[t.getId()]},this.getFromId=function(t){return void 0!==this.groupMap[t]?this.groupMap[t]:null},this.getAll=function(){return this.groups},this.each=function(t){for(e=0;e<this.groups.length;e++)t(this.groups[e])}}}),define("CatLab/Webremote/Models/Control",[],function(){return function(i,n,t){var s,o,r=0,a={},h=i,l=[];this.id=i,this.decoration="",this.label="",this.isGlobal=t,this.pushed=function(){return 0===r},this.scale=function(){return r},this.update=function(t,e){0<r&&0===t?((e=void 0===e?!0:e)&&this.trigger("click"),this.trigger("up")):0===r&&0<t&&this.trigger("down"),r=t},this.getLabel=function(t){return(t=void 0===t?!0:t)?'<span class="control-label '+o+'">'+h+"</span>":h},this.setStaticLabel=function(t,e){return h=t,o=e,this},this.setLabel=function(t,e){return this.label=t,n.emit("button:label",{id:i,label:t}),this},this.decorate=function(t){return this.decoration=t,n.emit("button:decorate",{id:i,styles:t}),this},this.click=function(t){return this.on("click",t),this},this.on=function(t,e){return this.log("Setting trigger "+t),void 0===a[t]&&(a[t]=[]),a[t].push(e),this},this.trigger=function(t){this.log("Triggering "+t);var e=[];if(void 0!==a[t])for(this.log("Found "+a[t].length+" events"),s=0;s<a[t].length;s++)e.push(a[t][s]);for(s=0;s<e.length;s++)e[s]();return this},this.hasTriggers=function(t){return void 0===t?0<Object.keys(a).length:void 0!==a[t]&&0<a[t].length},this.off=function(t){return(a=void 0===t?{}:a)[t]=[],this},this.clear=function(){return this.clearEvents(),this.decoration=null,this.label=null,this},this.clearEvents=function(){return a={},this},this.addDomElement=function(t){var e=this,i=[];return i.push(t.addEventListener("click",function(){e.trigger("click")})),l.push({element:t,listeners:i}),this},this.clearDomElements=function(){for(var t=0;t<l.length;t++)for(var e=0;e<l[t].listeners.length;e++)l[t].element.removeEventListener("click",l[t].listeners[e]);return l=[],this},this.isLocalAuthentication=function(){return!1},this.refreshTarget=function(t){this.decoration&&t.emit("button:decorate",{id:i,styles:this.decoration}),this.label&&t.emit("button:label",{id:i,label:this.label})},this.log=function(t){n.log("["+this.id+"] "+t)}}}),define("CatLab/Webremote/Synchronization/MultipleTargetControl",[],function(){function t(t,e){this.id=t,this.remoteView=e,this.label=null,this.decoration=null}var e=t.prototype;return e.pushed=function(){var e=[];return this.remoteView.targets.forEach(function(t){e=e||t.control(this.id).pushed()}.bind(this)),e},e.scale=function(){var e,i=0;return this.remoteView.targets.forEach(function(t){(e=t.scale())>i&&(i=e)}.bind(this)),pushed},e.update=function(e){this.remoteView.targets.forEach(function(t){t.control(this.id).update(e)}.bind(this))},e.getLabel=function(){return this.label},e.setLabel=function(e){return this.label=e,this.remoteView.targets.forEach(function(t){t.control(this.id).setLabel(e)}.bind(this)),this},e.decorate=function(e){return this.decoration=e,this.remoteView.targets.forEach(function(t){t.control(this.id).decorate(e)}.bind(this)),this},e.click=function(t){return this.on("click",t),this},e.on=function(e,i){return this.remoteView.targets.forEach(function(t){t.control(this.id).on(e,i)}.bind(this)),this},e.off=function(e){return this.remoteView.targets.forEach(function(t){t.control(this.id).off(e)}.bind(this)),this},e.refreshTarget=function(e){return this.remoteView.targets.forEach(function(t){t.control(this.id).refreshTarget(e)}.bind(this)),this},t}),define("CatLab/Webremote/Synchronization/RemoteView",["CatLab/Webremote/Models/Control","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Synchronization/MultipleTargetControl","CatLab/Webremote/Synchronization/DataSynchronizer"],function(t,e,i,n){function s(t,e,i,n,s){this.initializeEventable(),this.id=e,this.viewId=t,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(t){this.addTarget(t)}.bind(this))}e=s.prototype=new e;return e.clearValues=function(){this.valueMap={}},e.addTarget=function(t){this.targets.push(t),this.refreshTarget(t)},e.refreshTarget=function(e){var t,i={id:this.id,viewId:this.viewId};for(this.tmpid in this.groupId&&(i.group=this.groupId),e.emit("view:set",i),this.newUserStack.map(function(t){e.emit(t.action,t.data)}.bind(this)),e.controls)e.controls.hasOwnProperty(this.tmpid)&&e.controls[this.tmpid].isGlobal&&e.controls[this.tmpid].refreshTarget(e);for(this.tmpid in this.controls)this.controls.hasOwnProperty(this.tmpid)&&(void 0!==this.controls[this.tmpid].refreshTarget?this.controls[this.tmpid].refreshTarget(e):console.error("Unexpected control:",this.controls[this.tmpid]));for(t in this.valueMap)this.valueMap.hasOwnProperty(t)&&e.emit("value:change",{id:t,value:this.valueMap[t]})},e.emit=function(e,i){this.targets.map(function(t){t.emit(e,i)})},e.clearControls=function(){for(var t=this.Webcontrol.getViewLabels(this.currentView),e=0;e<t.length;e++)this.control(t[e].id).setStaticLabel(t[e].label,"mobile")},e.control=function(t){return void 0===this.controls[t]&&(this.controls[t]=new i(t,this)),this.controls[t]},e.trigger=function(t,e){"value:change"==t&&this.changeValue(e.id,e.value)},e.changeValue=function(t,e){this.valueMap[t]=e,this.emit("value:change",{id:t,value:e}),this.eventableTrigger("value:change",t,e)},e.refreshControls=function(){for(this.tmpid in this.controls)this.controls.hasOwnProperty(this.tmpid)&&this.controls[this.tmpid].refreshControl()},e.getValues=function(){return this.valueMap},e.log=function(t){this.Webcontrol.log(t)},e.domAppend=function(t,e){this._stackAndEmit("dom:append",{id:t,html:e})},e.domReplace=function(t,e){this._stackAndEmit("dom:replace",{id:t,html:e})},e.domAttribute=function(t,e,i){this._stackAndEmit("dom:attribute",{id:t,name:e,value:i})},e.vibrate=function(t){Array.isArray(t)?this.emit("device:vibrate",{pattern:t}):console.error("Vibrate pattern must be an array.")},e.listenTo=function(t,e,i){this.listeners.push(t.on(e,i))},e.stopListening=function(){this.listeners.forEach(function(t){t.unbind()})},e._stackAndEmit=function(t,e){this.newUserStack.push({action:t,data:e}),this.emit(t,e)},e.destroy=function(){this.stopListening(),this.factory.destroy(this)},s}),define("CatLab/Webremote/Synchronization/RemoteViewFactory",["CatLab/Webremote/Synchronization/RemoteView"],function(s){function t(){this.viewCounter=0,this.views={}}var e=t.prototype;return e.create=function(t,e,i,n){return this.viewCounter++,this.views[this.viewCounter]=new s(this.viewCounter,t,e,i,n),(this.views[this.viewCounter].factory=this).views[this.viewCounter]},e.createDummy=function(t,e){return this.create(t,[],e)},e.getFromId=function(t){return this.views[t]},e.destroy=function(t){t=t.id;delete this.views[t]},new t}),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(e,i,n,t,s,o,r,a){function h(t,e){this.initializeEventable(),(e=void 0===e?{}:e).id=t,e.playerId=null,this.initialize(e)}t=h.prototype=new t;return t.hasPlayerId=function(){return 0<this.playerId},t.setPlayerId=function(t){return this.playerId=t,this},t.control=function(t,e){return void 0===e&&(e=!1),void 0===this.controls[t]&&(this.controls[t]=new i(t,this,e)),this.controls[t]},t.getAvailableControls=function(){return["a","b","x","y","up","down","right","left","start","back"]},t.hasControl=function(t){return!0},t.setWebcontrol=function(t){this.Webcontrol=t},t.initialize=function(t){this.id=t.id,t.playerId&&(this.playerId=t.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=t,this.profiledata={},this.access_token=null,this.user=null,this.master=!1,this.authenticated=!1,void 0!==t&&void 0!==t.groups?this.groupIds=t.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={}},t.setSettings=function(t){return this.settings=t,this},t.trigger=function(e,i){0<=o.eventsToListenFor.indexOf(e)?(this.dataSynchronizer.checkNamespace(i)&&this.dataSynchronizer.processMessage(e,i),this.getGroups().forEach(function(t){t.dataSynchronizer.checkNamespace(i)&&t.dataSynchronizer.processMessage(e,i)}.bind(this))):0<=r.eventsToListenFor.indexOf(e)?(this.events.checkNamespace(i)&&this.events.processMessage(e,i),this.getGroups().forEach(function(t){t.events.checkNamespace(i)&&t.events.processMessage(e,i)}.bind(this))):"button:down"===e?this.control(i.id).update(1):"button:up"===e?this.control(i.id).update(0,i.click):"user:login"===e?this.login(i):"user:logout"===e?this.logout(i):"user:smiley"===e?this.setSmiley(i.smiley):"sync:audio"===e&&this.eventableTrigger("sync:audio",i)},t.setSmiley=function(e){this.smiley=e;var i=null;this.getGroups().forEach(function(t){i=!0,t.setSmiley(e,this)}.bind(this)),i||this.Webcontrol.smileys.reserve(e,this.getIdentifier())?this.emit("user:smiley",{smiley:e}):this.emit("dom:alert",{message:s.t("Smiley is already taken. Please select a different smiley.")})},t.setNickname=function(t){return this.nickname=t,this},t.getNickname=function(){return this.nickname||(this.getData().username?this.getData().username:this.playerId?"Player "+this.playerId:"Player "+this.id)},t.clearSmiley=function(){this.smiley=null,this.getGroups().forEach(function(t){t.clearSmiley(this)}.bind(this)),this.emit("user:smiley",{smiley:null})},t.getSmiley=function(){return this.smiley},t.getSmileyImage=function(){return this.Webcontrol.smileys.getImage(this.getSmiley())},t.getSmileyHtml=function(){return this.Webcontrol.smileys.getHtml(this.getSmiley())},t.getSmileyUrl=function(){return this.Webcontrol.smileys.getUrl(this.getSmiley())},t.login=function(t){},t.logout=function(t){},t.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()},t.clearEvents=function(){this.clearControls(),this.clearEventableEvents()},t.emit=function(t,e,i){return this.Webcontrol.provider.toPlayer(this,t,e,i),!0},t.getId=function(){return this.id},t.getName=function(){return"User "+this.getId()},t.getType=function(){return"mobile"},t.getEntityType=function(){return"user"},t.getIcon=function(){return"fa fa-mobile-phone"},t.loginFromAuthUser=function(t,e){t={access_token:t.getAccessToken()};this.login(t,e)},t.login=function(e,i){var n=this;this.Webcontrol.getOAuthClient(function(t){t&&(this.setAccessToken(e.access_token),t.profile(n.access_token,function(t){n.authenticated=!0,this.setProfiledata(t.user),void 0!==i&&i()}.bind(this)))}.bind(this))},t.setAccessToken=function(t){this.access_token=t},t.getAccessToken=function(){return this.access_token},t.setProfiledata=function(t){t=void 0!==(this.profiledata=t).accessToken?t.accessToken:null,t=new e(t);void 0!==this.profiledata.id&&t.setId(this.profiledata.id),void 0!==this.profiledata.username&&t.setName(this.profiledata.username),void 0!==this.profiledata.avatar&&t.setAvatar(this.profiledata.avatar),this.setUser(t),this.eventableTrigger("login",this)},t.isAuthenticated=function(){return this.authenticated},t.getData=function(){return this.profiledata},t.logout=function(t){this.profiledata=null,this.access_token=null,this.authenticated=!1},t.setColor=function(t,e){this.colorSet=!0,this.color=t,this.colorName=e,this.emit("color:set",{color:t,name:e})},t.isColorSet=function(){return this.colorSet},t.getColor=function(){return this.color},t.getColorName=function(){return this.colorName},t.isActive=function(){return this.active},t.toggleActive=function(){this.setActive(!this.active),this.setJoinLabel()},t.setJoinLabel=function(){!0===this.active?this.control("a").setLabel("LEAVE"):this.control("a").setLabel("JOIN")},t.setActive=function(t,e){this.active=t,this.eventableTrigger("active:change",t),this.active&&this.eventableTrigger("active:activate"),void 0!==e&&e&&this.setJoinLabel()},t.setView=function(t){return this.clearView(),this.currentView=n.create(t,[this],this.Webcontrol),this.currentView},t.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())},t.refreshView=function(){this.currentView&&this.currentView.refreshTarget(this)},t.getValues=function(){return this.currentView?this.currentView.getValues():null},t.clearValues=function(){this.currentView&&this.currentView.clearValues()},t.setUser=function(t){return this.usermodel=t,this},t.hasUser=function(){return void 0!==this.usermodel&&this.usermodel},t.getUser=function(){return this.usermodel},t.isLocalAuthentication=function(){return!0},t.log=function(t){this.Webcontrol&&this.Webcontrol.log("[u:"+this.getId()+"] "+t)},t.getGroups=function(){return this.groups},t.hasDisplay=function(){return!0},t.hasKeyboardInput=function(){return!0},t.hasTouchInput=function(){return!0},t.getIdentifier=function(){return{id:this.getId(),type:this.getEntityType()}},t.represents=function(t){if(void 0===t.id||void 0===t.type)throw"Attribute is not an identifier.";var e=this.getIdentifier();return e.type===t.type&&e.id===t.id},t.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"up",authenticate:"y",left:"left",right:"right"}},t.isMainGroup=function(){if(0===this.groups.length)return!0;for(var t=0;t<this.groups.length;t++)if(this.groups[t].isMainGroup())return!0;return!1},t.isMaster=function(){return this.master},t.setMaster=function(t){var e=this.master!==(t=!!(t=void 0===t?!0:t));return this.master=t,e&&this.eventableTrigger("master:change"),this},t.resetViews=function(t){this.emit("view:reset",{},t=void 0===t?function(){}:t)},t.replaceViews=function(t,e){this.resetViews(function(){this.loadViews(t,e)}.bind(this))},t.loadViews=function(t,e){void 0===e&&(e=function(){}),this.log("Loading views for group "+t),this.emit("view:load",{url:t},e)},t.getConnectToken=function(){return this.Webcontrol.getConnectToken()},t.getConnectTokenForDisplay=function(){return this.Webcontrol.getConnectTokenForDisplay()},t.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()}},t.unserialize=function(t){void 0!==t.profiledata&&this.setProfiledata(t.profiledata),void 0!==t.playerId&&(this.playerId=t.playerId),void 0!==t.access_token&&this.setAccessToken(t.access_token),void 0!==t.color&&(this.color=t.color),void 0!==t.colorName&&(this.colorName=t.colorName),void 0!==t.nickname&&(this.nickname=t.nickname),void 0!==t.email&&(this.email=t.email),void 0!==t.smiley&&(this.smiley=t.smiley),void 0!==t.data&&this.dataSynchronizer.unserialize(t.data),void 0!==t.events&&this.events.unserialize(t.events)},h}),define("CatLab/Webremote/Models/GroupControl",[],function(){return function(t,i,e){var n,s,o,r,a,h,l=t,c={};this.label=null,this.decoration="",this.group=i,this.isGlobal=e,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(t){return o=i.getUsers(),(n=0)<o.length?(a=o[n].control(l,this.isGlobal)).getLabel(t):null},this.setStaticLabel=function(t,e){for(o=i.getUsers(),n=0;n<o.length;n++)o[n].control(l).setStaticLabel(t,e);return null},this.setLabel=function(t,e){return this.label=t,i.emit("button:label",{id:l,label:t}),this},this.decorate=function(t){return this.decoration=t,i.emit("button:decorate",{id:l,styles:t}),this},this.click=function(t){return this.on("click",t),this},this.on=function(t,e){for(void 0===c[t]&&(c[t]=[]),c[t].push(e),this.log("Setting group trigger "+t),o=i.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).on(t,e);return this},this.hasTriggers=function(t){for(o=i.getUsers(),n=0;n<o.length;n++)if(o[n].control(l,this.isGlobal).hasTriggers(t))return!0;return!1},this.off=function(t){for(delete c[t],o=i.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).off(t);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(t){this.decoration&&t.emit("button:decorate",{id:l,styles:this.decoration}),this.label&&t.emit("button:label",{id:l,label:this.label})},this.log=function(t){i.log("["+l+"] "+t)}}}),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(t,e,i,n,s,o,r,a,h,l){function c(t,e){this.initializeEventable(),this.id=t,this.initialize(e)}r=c.prototype=new r;return r.setWebcontrol=function(t){this.Webcontrol=t},r.initialize=function(t){this.token=t.token,this.connectURL=t.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=t,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(t){return this.options=t,this},r.getOption=function(t){return void 0!==this.options[t]?this.options[t]:null},r.hasControl=function(t){return!0},r.setAccessToken=function(t){this.access_token=t},r.setProfiledata=function(t){this.profiledata=t},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(t,e,i){return this.Webcontrol.provider.toGroup(this,t,e,i),!0},r.getId=function(){return this.id},r.getName=function(){return"Group "+this.getId()},r.setNickname=function(t){return this.nickname=t,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(t,e,i){void 0===i&&(i=this.shareColor),this.colorSet=!0,this.color=t,this.colorName=e,this.shareColor=i,this.emit("color:set",{color:t,name:e,shareColor:i})},r.getColor=function(){return this.color},r.setShareColor=function(t){this.shareColor=t},r.isShareColor=function(){return this.shareColor},r.getColorName=function(){return this.colorName},r.setView=function(t){return this.clearView(),this.currentView=o.create(t,[this],this.Webcontrol,this.getId()),this.currentView},r.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(),this.users.forEach(function(t){t.clearView(e)}))},r.resetViews=function(t){this.emit("view:reset",{},t=void 0===t?function(){}:t)},r.replaceViews=function(t,e){this.resetViews(function(){this.loadViews(t,e)}.bind(this))},r.loadViews=function(t,e){void 0===e&&(e=function(){}),this.log("Loading views for group "+t),this.emit("view:load",{url:t},e)},r.isAuthenticated=function(){return!1},r.isLocalAuthentication=function(){return!0},r.log=function(t){this.Webcontrol.log("[g:"+this.getId()+"] "+t)},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(e){for(this.tmpid in l.findIndex(this.users,function(t){return t.id===e.id})<0&&this.users.push(e),l.findIndex(e.groups,function(t){return t.id===this.id})<0&&e.groups.push(this),this.currentView&&(this.currentView.refreshTarget(e),e.currentView=this.currentView),this.controls)this.controls.hasOwnProperty(this.tmpid)&&this.controls[this.tmpid].refreshControl();this.events.refreshTarget(e.emit.bind(e)),this.dataSynchronizer.refreshTarget(e.emit.bind(e)),this.smiley&&(e.emit("user:smiley",{smiley:this.smiley}),e.smiley=this.smiley),this.trigger("user:join",e)},r.removeUser=function(e){var t=l.findIndex(this.users,function(t){return t.id===e.id});0<=t&&this.users.splice(t,1)},r.getUsers=function(){return this.users},r.getIdentifier=function(){return{id:this.getId(),type:this.getEntityType()}},r.represents=function(t){if(void 0===t.id||void 0===t.type)throw"Attribute is not an identifier.";var e=this.getIdentifier();return e.type==t.type&&e.id==t.id},r.getValues=function(){return this.currentView?this.currentView.getValues():null},r.clearValues=function(){this.currentView&&this.currentView.clearValues()},r.control=function(t,e){return void 0===e&&(e=!1),void 0===this.controls[t]&&(this.controls[t]=new n(t,this,e)),this.controls[t]},r.isMaster=function(){return this.master},r.setMaster=function(t){return this.master=t=void 0===t?!0:t,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(t){this.emit("oauth:set",t)},r.setSmiley=function(t,e){this.Webcontrol.smileys.reserve(t,this.getIdentifier())?(this.emit("user:smiley",{smiley:t}),this.smiley=t):e.emit("dom:alert",{message:s.t("Smiley is already taken. Please select a different smiley.")})},r.clearSmiley=function(t){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(t){this.emit("config:set",{maxUsers:t})},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(t,e){this.active=t,this.eventableTrigger("active:change",t),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(t){void 0!==t.profiledata&&this.setProfiledata(t.profiledata),void 0!==t.access_token&&this.setAccessToken(t.access_token),void 0!==t.token&&(this.token=t.token),void 0!==t.shareColor&&(this.shareColor=t.shareColor),void 0!==t.color&&(this.color=t.color),void 0!==t.colorName&&(this.colorName=t.colorName),void 0!==t.nickname&&(this.nickname=t.nickname),void 0!==t.email&&(this.email=t.email),void 0!==t.smiley&&(this.smiley=t.smiley,this.emit("user:smiley",{smiley:this.smiley})),void 0!==t.data&&this.dataSynchronizer.unserialize(t.data),void 0!==t.events&&this.events.unserialize(t.events)},c}),define("CatLab/Webremote/Models/State",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Preloader"],function(i,n){function t(t){this.Webcontrol=t}var e=t.prototype;return e.reconnect=function(t,e){void 0!==t.provider&&this.Webcontrol.provider.restoreProviderSettings(t.provider),this.Webcontrol.disconnect(),setTimeout(function(){this.Webcontrol.initialize(i.getAll()).then(function(){this.Webcontrol._reconnect(t.token,t.accessToken,function(){this._setCollectionDetails(t.groups,this.Webcontrol._grouplibrary),this._setCollectionDetails(t.users,this.Webcontrol._userlibrary),this.Webcontrol.preloader=n.unserialize(this.Webcontrol.provider,t.preloader),e()}.bind(this))}.bind(this))}.bind(this),1)},e._setCollectionDetails=function(t,e){var i,n;if(void 0!==t)for(i=0;i<t.length;i++)(n=e.getFromId(t[i].id))?n.unserialize(t[i]):(console.log("Trying to set data for non existing user/group."),console.log(t[i]))},e.getData=function(){var e=[],i=(this.Webcontrol._grouplibrary.each(function(t){e.push(t.serialize())}.bind(this)),[]),t=(this.Webcontrol._userlibrary.each(function(t){i.push(t.serialize())}),{users:i,groups:e,token:this.Webcontrol._gamedata.token,accessToken:this.Webcontrol._gamedata.accessToken,preloader:this.Webcontrol.preloader.serialize()});return t.provider=this.Webcontrol.provider.serializeProviderSettings(),t},e.serialize=function(){var t=this.getData();return JSON.stringify(t)},e.unserialize=function(t){t=JSON.parse(t);this.reconnect(t)},t}),define("CatLab/Webremote/Controllers/Portal",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Tools/Deferred"],function(s,t,i,e,o){"use strict";function n(t,e,i){this.initializeEventable(),this.Webcontrol=e,this.options=i,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.")});var n={controller:this,assets:e.assets,showInactivePlayers:this.supportInactivePlayers()};void 0!==i.element&&(n.element=i.element),this.view=t.portal(n),this.view.loading(),this.useCatLabViews()&&e.loadViews(s.getSocketURL(!0)+"/webremote/views/default.xml"),this.container=t.getContainer(),this.container.easelboneLayer.setView(this.view),this.view.render(),this.eventListeners=[],this.initialize()}t=n.prototype=new t;return t.initialize=function(){var t=this.Webcontrol.on("user:join",function(t){this.userConnect(t),this.eventListeners.push(t.on("login",function(){this.trigger("users:update")}.bind(this)))}.bind(this));this.eventListeners.push(t),this.Webcontrol.getUsers().forEach(function(t){this.userConnect(t)}.bind(this))},t.ensureOption=function(t,e){void 0===this.options[t]&&(this.options[t]=e)},t.useCatLabViews=function(){return!1===this.options.customViews},t.getToggleView=function(t){var e="",e=this.supportInactivePlayers()?"catlab-portal-toggle":"catlab-portal";return this.isMaster(t)||(e+="-nostart"),e},t.addUser=function(t){t.clearEvents(),this.users.push(t),this.supportInactivePlayers()||this.forceToggleableUser(t)||this.activateUser(t),this.trigger("users:update")},t.activateUser=function(t){this.trigger("user:activate",t),t.setActive(!0,this.supportInactivePlayers())},t.deactivateUser=function(t){this.trigger("user:deactivate",t),t.setActive(!1,this.supportInactivePlayers())},t.toggleActive=function(t){(this.supportInactivePlayers()||this.forceToggleableUser(t))&&(t.isActive()?this.deactivateUser(t):this.activateUser(t),this.trigger("users:update"))},t.forceToggleableUser=function(t){return!t.hasDisplay()},t.hasUsersWithoutDisplay=function(){for(var t=0;t<this.users.length;t++)if(!this.users[t].hasDisplay())return!0;return!1},t.countActiveUsers=function(){return this.getActiveUsers().length},t.getActiveUsers=function(){for(var t=[],e=0;e<this.users.length;e++)this.users[e].isActive()&&t.push(this.users[e]);return t},t.userConnect=function(t){this.eventListeners.push(t.on("master:change",function(){this.updateUserView(t)},this)),this.addUser(t),this.updateUserView(t),this.trigger("user:connect",t)},t.updateUserView=function(t){var e=t.setView(this.getToggleView(t));this.controlDisabled||this.enableControls(t,e),this.enableDefaultPlayerControls(t,e)},t.disableControls=function(){this.controlDisabled=!0;for(var t=0;t<this.users.length;t++)this.users[t].clearEvents()},t.enableControls=function(t,e){var i;void 0!==t?(i=t.getPortalControls(),e.control(i.toggleActive).click(function(){this.toggleActive(t)}.bind(this)),e.control(i.start).click(function(){this.startGame()}.bind(this)),e.control(i.back).click(function(){this.back()}.bind(this)),this.supportsLocalAuthentication()&&e.control(i.authenticate).click(function(){t.isLocalAuthentication()||this.authenticate(t)}.bind(this)),this.view.setWebremoteControlsInView(e)):(this.controlDisabled=!1,this.users.forEach(function(t){this.updateUserView(t)}.bind(this)))},t.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 t in this.options.customFunctions)this.options.customFunctions.hasOwnProperty(t)&&function(t,e){n.control(t).click(function(){e(i).then(function(){this.updateUserView(i)}.bind(this))}.bind(this))}.bind(this)(t,this.options.customFunctions[t])},t.changeNickname=function(e){var i=new o,n=e.setView("catlab-nickname");return n.changeValue("name",e.getNickname()),n.control("a").click(function(){var t=n.getValues().name;!t||32<t.length||(e.setNickname(t),i.resolve())}),i.promise()},t.supportInactivePlayers=function(){return this.options.activePlayersPanel},t.supportsLocalAuthentication=function(){return this.options.localAuthenticable&&this.Webcontrol.canAuthenticate()},t.isMaster=function(t){return t.isMaster()},t.getPortalLabels=function(){var s={start:[],back:[],toggleActive:[],authenticate:[]};return this.Webcontrol._userlibrary.each(function(t){var e,i=t.getPortalControls();for(e in i)if(i.hasOwnProperty(e)){var n=t.control(i[e]).getLabel(!1);if(!n)continue;n="["+n.toUpperCase()+"]",void 0===s[e]&&(s[e]=[]),-1===s[e].indexOf(n)&&s[e].push(n)}}.bind(this)),s},t.authenticate=function(t){var e=this,t=(this.disableControls(),this.Webcontrol.authentication(t).view);this.view.addAuthenticationView(t),t.on("view:close",function(){e.enableControls(),e.trigger("users:update")})},t.countAuthenticated=function(t){void 0===t&&(t=!0);for(var e=0,i=0;i<this.users.length;i++)!this.users[i].isAuthenticated()||t&&!this.users[i].isActive()||e++;return e},t.checkAuthentication=function(){var t=this.countAuthenticated();switch(this.options.authentication){case this.Webcontrol.AUTH_REQUIRED_ALL:return t===this.countActiveUsers();case this.Webcontrol.AUTH_REQUIRED_ONE:return 0<t;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."}},t.startGame=function(){var t=this.countActiveUsers();if(t<this.options.minPlayers)this.view.alert("You need "+this.options.minPlayers+" players to start playing");else if(t>this.options.maxPlayers)this.view.alert("Your license is limited to "+this.options.maxPlayers+" players");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.view.alert("All active players must be authenticated.");break;case this.Webcontrol.AUTH_REQUIRED_ONE:case this.Webcontrol.AUTH_REQUIRED_ONE_INACTIVE:this.view.alert("At least one player must be authenticated.")}},t.back=function(){void 0!==this.options.back&&(this.destroy(),this.options.back())},t.getConnectURL=function(){return this.Webcontrol.getConnectURL()},t.getConnectToken=function(){return this.Webcontrol.getConnectTokenForDisplay()},t.getUsers=function(){return this.users},t.setMinPlayers=function(t){return this.options.minPlayers=t,this.trigger("options:change"),this},t.setMaxPlayers=function(t){return this.options.maxPlayers=t,this.trigger("options:change"),this},t.getContainer=function(){return this.container},t.getConnectInstructions=function(){return void 0!==this.Webcontrol.provider.getConnectInstructions?i.t.apply(this,this.Webcontrol.provider.getConnectInstructions()):i.t("Use your tablet or smartphone to surf to %s and enter code %s.",this.getConnectURL(),this.getConnectToken())},t.getStartAndLoginInstructions=function(){var t;return void 0!==this.Webcontrol.provider.getStartAndLoginInstructions?i.t.apply(this,this.Webcontrol.provider.getStartAndLoginInstructions()):(t=this.getPortalLabels(),this.supportsLocalAuthentication()&&(this.showInactivePlayers||this.hasUsersWithoutDisplay())?i.t("Press %s to join, %s to login and %s to start.",e(t.toggleActive),e(t.authenticate),e(t.start)):this.supportsLocalAuthentication()?i.t("Press %s to login and %s to start.",e(t.authenticate),e(t.start)):this.showInactivePlayers||this.hasUsersWithoutDisplay()?i.t("Press %s to join and %s to start.",e(t.toggleActive),e(t.start)):i.t("Press %s to start.",e(t.start)));function e(t){return t.join(" "+i.t("or")+" ")}},t.destroy=function(){this.eventListeners&&this.eventListeners.forEach(function(t){t.unbind()})},n}),define("CatLab/Webremote/Controllers/RemoteAuthentication",["CatLab/Webremote/Controllers/OAuth2"],function(e){return function(t){t.setView("remote:authenticate"),t.on("user:join",function(t){t.on("login",function(t){e.addAccessToken(t.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"],function(s,n,o,t,r,i){function e(t,e,i,n){this.initializeEventable(),this.view=t.authentication({controller:this,assets:e.assets}),this.Webcontrol=e,this.user=i,o.on("update",this.updateUsers,this),s.on("update",function(){this.view.updateUsers()},this),this.getLoginUrl().then(function(t){this.loginUrl=t,this.view.setLoginUrl(t)}.bind(this)),this.container=t.getContainer(),this.container.easelboneLayer.setView(this.view),this.view.render()}var a=null,h=null,t=e.prototype=new t;return t.link=function(){s.link(function(t){this.selectUser(t)}.bind(this))},t.updateUsers=function(){this.trigger("users:update")},t.selectUser=function(t){var e=this;this.user.loginFromAuthUser(t,function(){i.setCookie("ctlb_ps_"+this.user.id,t.id),e.close()}.bind(this))},t.getUsers=function(){return o},t.close=function(){this.view.close()},t.getLoginUrl=function(){var e,t,i=new r;return e=this.Webcontrol,(null!==a?((t=new r).resolve(a),t):(null===h&&(h=new r,e.newGroup().then(function(t){new n(a=t),t.setOAuthSettings(e.getOAuthSettings()),h.resolve(t)})),h)).promise().then(function(t){i.resolve(t.getConnectURL()+"/"+t.getConnectToken())}),i.promise()},t.getContainer=function(){return this.container},t.attemptLastLogin=function(){var t=i.getCookie("ctlb_ps_"+this.user.id);if(t){t=o.getFromId(t);if(t)return this.selectUser(t),!0}return!1},e}),define("CatLab/Webremote/Tools/MessageCounter",["CatLab/Webremote/Tools/Eventable"],function(t){"use strict";function e(t){this.interval=t||1e3,this.initializeEventable(),this.countIncoming=0,this.countOutgoing=0;var e,i,n=(new Date).getTime();setInterval(function(){e=(new Date).getTime(),i=e-n,n=e,this.trigger("tick",{in:this.countIncoming,out:this.countOutgoing,dt:i}),this.countIncoming=0,this.countOutgoing=0}.bind(this),this.interval)}t=e.prototype=new t;return t.incoming=function(){this.countIncoming++},t.outgoing=function(){this.countOutgoing++},e}),define("CatLab/Webremote/Views/Portal",["CatLab/Webremote/Config"],function(F,t){return function(t){var s=t.element||document.body,e=s,i=t.countdown||5e3,n=t.done||function(){alert("Game should start now... yet it doesn't.")},o=t["min-players"]||1,r=(o<1&&(o=1),t["max-players"]||1e3);r<o&&(r=o);var a,h,l,c,u,d,p,f,g,m,v,b=!t.customViews,A=[],y=!1,w=!1,C=null,k=this;function T(s){s.setView("catlab-portal-toggle"),s.control("join-game").click(function(){!function(t){if(P(t)){t.control("join-game").setLabel("JOIN");for(var e=t,i=0;i<A.length;i++)if(A[i].getId()==e.getId())return A.splice(i,1)}else t.control("join-game").setLabel("LEAVE"),A.push(t)}(s),M(),x(),U()}),s.control("start-game").click(function(){var t;y?U():A.length<o?D(o+" players are required to start the game. Please gather more friends."):A.length>r?D("This game can have only "+r+" players."):(t=i,U(),y=!0,(p=new Date).setTime((new Date).getTime()+t),u.show(),d=setInterval(V,100))}),s.control("down").click(function(){_(s)}),s.control("right").click(function(){_(s)}),s.control("left").click(function(){S(s)}),s.control("up").click(function(){S(s)}),s.control("a").click(function(){var t,i,e,n;t=s,w&&I(t)?(n=v.find(".available-accounts").find("li.selected"))&&(n=WebcontrolOAuthClient.getFromToken(n.attr("data-accessToken")))&&(e=n.access_token,n=n.user,C.setUserData(e,n),L()):(y&&U(),w||(i=t,Webcontrol.getOAuthClient(function(e){e.onInit(function(){E(e)}),WebcontrolAccessKeyLibrary.init(function(){w=!0,C=i,m.show(),v.show();var t=$('<a href="javascript:void(0);">Link new account</a>');t.click(function(){e.getNewAccessToken(function(){E(e)})}),v.find(".link-new-account").html(t)}),E(e)})))}),s.control("b").click(function(){w&&I(s)&&(C.setUserData(!1),L())}),W(),x()}function S(t){w&&I(t)&&(t=v.find(".available-accounts").find("li.selected"),v.find(".available-accounts").find("li").removeClass("selected").addClass("unselected"),(t.length&&t.prev().length?t.prev():v.find(".available-accounts").find("li").last()).addClass("selected").removeClass("unselected"))}function _(t){w&&I(t)&&(t=v.find(".available-accounts").find("li.selected"),v.find(".available-accounts").find("li").removeClass("selected").addClass("unselected"),(t.length&&t.next().length?t.next():v.find(".available-accounts").find("li").first()).addClass("selected").removeClass("unselected"))}function I(t){return C&&t.getId()==C.getId()}function L(){m.hide(),v.hide(),w=!1,C=null}function E(t){v.find(".available-accounts").html("");for(var e=t.listUsers(),i=0;i<e.length;i++){var n=$("<li>"+e[i].user.username+"</li>");n.addClass("unselected"),n.attr("data-accessToken",e[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(t){for(var e=0;e<A.length;e++)if(A[e].getId()==t.getId())return 1}function W(){var t=Webcontrol.getUsers();a.html("");for(var e=[],i=0;i<t.length;i++)P(t[i])||e.push(t[i]);for(0==e.length&&a.append('<li class="empty"><span>More players? Add devices!</span></li>'),i=0;i<e.length;i++)a.append('<li class="user '+e[i].getType()+'" style="background-color: '+e[i].getColor()+'"><i class="'+e[i].getIcon()+'"></i><span>'+e[i].getName()+"</span></li>")}function M(){h.html(""),0==A.length&&h.append('<li class="empty"><span class="buttoninstructions join-game">Press <span class="labels"></span> to join the game.</span></li>');for(var t=0;t<A.length;t++)h.append('<li class="user '+A[t].getType()+'" style="background-color: '+A[t].getColor()+'"><i class="'+A[t].getIcon()+'"></i><span>'+A[t].getName()+"</span></li>");W()}function V(){f=Math.ceil((p.getTime()-(new Date).getTime())/1e3),u.find(".counter").html(f),f<0&&(void 0!==e&&(void 0!==e.hide?e.hide():void 0!==e.style&&(e.style.display="none")),U(),n(A))}function U(){y=!1,d&&(D("Countdown stopped!"),u.hide(),clearInterval(d),d=null)}function D(t){var e=jQuery("<p></p>").html(t).appendTo(g);setTimeout(function(){e.fadeOut(1e3,function(){e.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!==t.theme&&(t=F.getSocketURL()+"/webremote/themes/"+t.theme+"/"+t.theme+".css",Webcontrol._loadCSS(t),Webcontrol._loadCSS(F.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 t=s,t=(s=jQuery('<div class="webremote-portal-inner"></div>').appendTo(t),(s=jQuery(s)).html('<div class="loading"><p>Please wait, connecting to server.</p></div>'),b&&Webcontrol.loadViews(F.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>')),e=(a=jQuery('<ul class="connected-users"></ul>').appendTo(t.find(".inner")),jQuery('<div class="active-users"><div class="inner"><h2>Active users</h2></div></div>'));h=jQuery('<ul class="active-users"></ul>').appendTo(e.find(".inner")),s.append(t),s.append(e),(t=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()),t.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),t.append(l),t.append(c),s.append(t),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(t){T(t)});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(e){"use strict";function t(){}return t.prototype.getPortal=function(t){return new e(t)},t}),define("CatLab/Webremote/Models/Users/GamepadUser",["CatLab/Webremote/Models/Users/ControlUser"],function(t){function e(t){t=t.id||"1",this.initialize({id:"gamepad_"+t}),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"}},t=e.prototype=new t;return t.getType=function(){return"gamepad"},t.getIcon=function(){return"fa fa-gamepad"},t.emit=function(){return!1},t.isLocalAuthentication=function(){return!1},t.controlFromKey=function(t){return this.control(i[t].id)},t.hasDisplay=function(){return!1},t.hasKeyboardInput=function(){return!1},t.hasTouchInput=function(){return!1},e}),define("CatLab/Webremote/Gamepads/GamepadAPI",["CatLab/Webremote/Models/Users/GamepadUser"],function(i){function t(){this.gamepads={},this.initialized=!1,this.Webcontrol=null}var n,e,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=t.prototype;return o.initialize=function(t){var e;this.Webcontrol=t,this.initialized||(this.initialized=!0,t=function(){var t=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads||[];for(n=0;n<t.length;n++)if(t[n]){for(n=0;n<t.length;n++)t[n]&&this.onConnect(t[n]);this.startGamepadPolling(),clearInterval(e)}}.bind(this),"undefined"!=typeof window&&("ongamepadconnected"in window?(window.addEventListener("gamepadconnected",function(t){this.onConnect(t.gamepad)}.bind(this)),window.addEventListener("gamepaddisconnected",function(t){this.onDisconnect(t.gamepad)}.bind(this))):e=setInterval(t,1e3)))},o.startGamepadPolling=function(){setInterval(this.poll.bind(this),50)},o.poll=function(){var t=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads||[];for(n=0;n<t.length;n++)if(t[n])for(e=0;e<t[n].buttons.length;e++)this.gamepads[t[n].index].user&&void 0!==s[e]&&this.gamepads[t[n].index].user.controlFromKey(s[e]).update(t[n].buttons[e].pressed?1:0)},o.onConnect=function(t){var e=new i({id:t.id});this.gamepads[t.index]={user:e},this.Webcontrol.addCustomControl(e),this.startGamepadPolling()},o.onDisconnect=function(t){},new t}),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"],function(a,t,e,i,n,s,h,o,r,l,c,u,d,p,f,g,m,v,b,A,y,w,C,k,T,S){"use strict";function _(){this.initializeEventable(),this.provider=null,this._events={},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._viewCounter=null,this._lastView=null,this._options={},this._groupCallbacks={id:1},this._viewFactory=null,this.state=null,this.connected=!1,this._userlibrary=new t,this._grouplibrary=new e}g=_.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(t){function e(){s.resolve(),n()}var i,n=function(){},s=(void 0!==(t=void 0===(t="function"==typeof t?{callback:t}:t)?{}:t).callback&&(n=t.callback),new u);return this._initialized?e():(this.sonicSyncClient=null,delete t.callback,t.headless,(i=!!t.headless)||void 0===t.assets||this.setAssets(t.assets),a.set(t),a.initialize(function(){null===this.provider&&(void 0===t.provider&&(t.provider=new k),this.provider=t.provider),this.smileys=new f(this.provider),void 0!==t.translator&&d.setTranslator(t.translator),this._initialize(i,e)}.bind(this))),s.promise()},disconnect:function(){this._initialized=!1,this.provider.disconnect()},_initialize:function(s,t){var o,r=new u;return(t&&r.then(t),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(t){this.provider.connect("control",t).then(function(){this.connected=!0,this.provider.on("disconnect",function(){var t=this.getConnectionIssuesView();t.show(),t.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(t){this.log("Initializing"),this._gamedata=t,this.log("Game initialize; URL "+this.getConnectURL()+", token "+this.getConnectToken()),r.resolve(this.connected)}.bind(this)),this.provider.on("master:error",function(t){alert(t.message)}.bind(this)),this.provider.on("user:join",function(t){this._playerJoin(t)}.bind(this)),this.provider.on("user:reconnect",function(t){this._playerReconnect(t)}.bind(this)),this.provider.on("user:leave",function(t){this._playerLeave(t)}.bind(this)),this.provider.on("view:labels",function(t){this._setViewLabels(t)}.bind(this)),this.provider.on("group:create",function(t){this._onNewGroup(t)}.bind(this)),this.provider.on("user:smiley",function(t){this._playerTrigger("user:smiley",t),this._userlibrary.each(function(t){this.smileys.refreshTakenSmileys(t)}.bind(this))}.bind(this)),this.provider.on("smileys:slingshot",function(t){var e=this._userlibrary.getFromId(t.user);e?(e.trigger("smileys:slingshot",t),t.user=e,this.trigger("smileys:slingshot",t)):console.log("User not found: "+t.user)}.bind(this));for(var t=(t=(t=["user:login","user:logout","button:down","button:up","sync:audio"]).concat(A.eventsToListenFor)).concat(y.eventsToListenFor),e=0;e<t.length;e++)!function(e){o.provider.on(e,function(t){o._playerTrigger(e,t)})}(t[e]);var i=["value:change"];for(var n=0;n<i.length;n++)!function(e){o.provider.on(e,function(t){o._viewTrigger(e,t)})}(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(t){var e;"string"==typeof t?(e=document.getElementById(t),this.log=this.getDomLogger(e)):this.log=t},getProviderSettings:function(){return this.provider.getProviderSettings()},setMessageCounter:function(t){t=new m(t);return this.provider.setMessageCounter(t),t},setName:function(t){this.provider.toMaster("master:name",{name:t})},setMaxUsers:function(t){this.provider.toMaster("config:set",{maxUsers:t})},setViewFactory:function(t){return this._viewFactory=t,this._viewFactory.initialize()},getViewFactory:function(){return"undefined"===this._viewFactory&&(this._viewFactory=new w),this._viewFactory},getDomLogger:function(e){return function(t){e.innerHTML=t+"\n"+e.innerHTML}},oAuth:function(t,e){void 0===e&&(e=!1),this._authentication=!0,this._oauthsettings=t,this.provider&&!e&&this.provider.setOAuthSettings(this._oauthsettings),o.initialize(t),i.initialize(this,o)},getOAuthClient:function(t){this._oauthsettings?(null===this._oauthClient&&(this._oauthClient=o,this._oauthClient.initialize(this._oauthsettings)),t(this._oauthClient)):t(null)},getOAuthSettings:function(){return this._oauthsettings},clearEvents:function(t){if(void 0===t&&(t=!1),this._events={},t)for(var e=this._userlibrary.getAll(),i=0;i<e.length;i++)e[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(t,e){this.provider.loadViews(t,e)},getUsers:function(){return this._userlibrary.getAll()},portal:function(t){var e,i;if(this._initialized)return i=this.getViewFactory(),e=new u,i=new r(i,this,t),e.resolve(i),{view:i.getContainer(),promise:e};throw new Error("Please initialize Webcontrol first.")},authentication:function(t,e){var i,n;if(this._initialized)return n=this.getViewFactory(),i=new u,n=new l(n,this,t,e),i.resolve(n),{view:n.getContainer(),promise:i.promise()};throw new Error("Please initialize Webcontrol first.")},getConnectionIssuesView:function(){return void 0===this.connectionTrouble&&(this.connectionTrouble=new C),this.connectionTrouble},setView:function(t,e){var i;return void 0===e?(i=b.create(t,[this],this),this._lastView=i):i=b.create(t,e,this),i},beacon:function(t,e){this.provider.toMaster("master:beacon",{beacon:t,token:e})},emit:function(t,e){this.provider.toPlayers(t,e)},getControlLabels:function(t,e){for(var i=[],n={},s=this.getUsers(),o=0;o<s.length;o++){var r=s[o].control(t).getLabel(e);void 0===n[r]&&i.push(n[r]=r)}return i},addCustomControl:function(t){this.log("adding "+t.getType()),t.setWebcontrol(this),this._userlibrary.add(t),this._initializeSmiley(t,{}),this.trigger("user:join",t)},enableGamepads:function(){T.initialize(this)},newGroup:function(t){var e=new u,i={},n=(void 0===t?t={}:"function"==typeof t&&(t={callback:t}),void 0===t.callback&&(t.callback=function(){}),!0),s=(void 0!==t.globalViews&&(n=t.globalViews),!0),o=(void 0!==t.shareColor&&(s=t.shareColor),[]),r=(void 0!==t.tags&&(o=t.tags),!0),r=(void 0!==t.smiley&&(r=!!t.smiley),i.smiley=r,this._groupCallbacks.id);return this._groupCallbacks.id++,this._groupCallbacks[r]={id:r,callback:t.callback,deferred:e,options:i},this.provider.createGroup(r,n,s,o),e.promise()},preload:function(t){return this.preloader.preload(t)},getPreloadedUrl:function(t){return this.preloader.getPreloadedUrl(t)},_reset:function(){this._userlibrary.clear(),this._grouplibrary.clear()},reset:function(){var t=new u;return this._initialized=!1,this.provider.reset(function(){t.resolve()}.bind(this)),t.promise()},_playerJoin:function(t){var e;this._userlibrary.getFromId(t.id)||((e=new n(t.id,t)).setWebcontrol(this),void 0!==t.color&&e.setColor(t.color.color,t.color.name),this._grouplibrary.addUser(e)||(this._lastView&&this._lastView.addTarget(e),this._initializeSmiley(e,t)),this._userlibrary.add(e),this.log(e),e&&this.trigger("user:join",e))},_playerReconnect:function(t){var e=this._userlibrary.getFromId(t.id);e?(e.getSmiley()&&e.emit("user:smiley",{smiley:e.getSmiley()}),this._grouplibrary.addUser(e)||this._lastView&&this._lastView.addTarget(e),e.refreshView(),this.trigger("user:rejoin",e),e.eventableTrigger("rejoined"),this.smileys.refreshTakenSmileys(e)):this._playerJoin(t)},_playerLeave:function(t){t=this._userlibrary.getFromId(t.id);t&&(this.trigger("user:leave",t),t.eventableTrigger("left"))},_onNewGroup:function(t){var e,i=new s(t.id,t),n=(i.setWebcontrol(this),!1);void 0!==t.shareColor&&(n=t.shareColor),void 0!==t.color?i.setColor(t.color.color,t.color.name):i.setShareColor(n),this._grouplibrary.getFromId(t.id)||(n=function(){},void 0!==(e=t.externalId)&&void 0!==this._groupCallbacks[e]&&(i.setOptions(this._groupCallbacks[e].options),n=function(){this._groupCallbacks[e].callback(i),this._groupCallbacks[e].deferred.resolve(i)}.bind(this)),this._grouplibrary.add(i),i.getOption("smiley")&&this._initializeSmiley(i,t),this.trigger("group:create",i),this.log("New group "+i.getId()+"; URL "+i.getConnectURL()+", token "+i.getConnectToken()),n())},_initializeSmiley:function(t,e){var i;a.useSmileys()?void 0===e.smiley?null!==(i=this.smileys.getRandom(t.getIdentifier()))&&t.setSmiley(i):t.setSmiley(e.smiley):t.clearSmiley(),this.smileys.refreshTakenSmileys(t)},_playerTrigger:function(t,e){var i=this._userlibrary.getFromId(e.user);i?i.trigger(t,e):console.log("User not found: "+e.user)},_viewTrigger:function(t,e){var i=b.getFromId(e.viewId);i&&i.trigger(t,e)},_loadCSS:function(t){for(var e=0;e<this._cssloads.length;e++)if(this._cssloads[e]==t)return;this._cssloads.push(t);var i=document.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("type","text/css"),i.setAttribute("href",t),document.body.appendChild(i)},_setViewLabels:function(t){this._labeldata[t.id]=t.labels;for(var e=this.getUsers(),i=0;i<e.length;i++)for(var n=0;n<t.labels.length;n++)e[i].control(t.id).setStaticLabel(t.labels[n].label,"mobile")},getViewLabels:function(t){return void 0!==this._labeldata[t]?this._labeldata[t]:[]},getFromIdentifier:function(t){switch(t.type){case"user":return this._userlibrary.getFromId(t.id);case"group":return this._grouplibrary.getFromId(t.id)}return null},log:function(t){a.debug()&&(console.log(a),console.log(t))},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()},recover:function(t){var e=this.state.getData();this._reconnect(e.token,e.accessToken,t)},_reconnect:function(t,e,i){this.provider.reconnect(t,e,a.getProviderConfig(),i)},getIceCredentials:function(){var e=new u;return this.provider.toMaster("webrct:stun+turn",{},function(t){void 0===t.error?e.resolve(t):e.fail(t.error)}),e.promise()}}),_}),define("CatLab/Webremote/Models/Users/KeyboardUser",["CatLab/Webremote/Models/Users/ControlUser"],function(t){"use strict";function e(t,e){var i="keyboard"+ ++n;this.initializeKeyboardUser({id:i,keys:t}),this.exitOnUnassignedBackButton=e}var n=0,t=((e.prototype=Object.create(t.prototype)).constructor=e).prototype;return t.initializeKeyboardUser=function(t){this.initialize({id:t.id}),void 0===t.keys&&(t.keys=this.getDefaultKeys()),this.keys=t.keys,this.attachKeyboardEvents(),document&&document.addEventListener("fullscreenchange",this.attachKeyboardEvents.bind(this)),this.clearControls=function(){for(var t,e=0;e<this.keys.length;e++)this.control(this.keys[e].id).setStaticLabel(this.keys[e].label,"keyboard");for(t in this.controls)!this.controls.hasOwnProperty(t)||this.controls[t].isGlobal||this.controls[t].clear()},this.on("view:set",function(t){this.clearControls()}.bind(this)),this.getType=function(){return"keyboard"},this.getIcon=function(){return"fa fa-keyboard-o"},this.emit=function(t,e){return!1},this.isLocalAuthentication=function(){return!1},this.clearControls()},t.getAvailableControls=function(){for(var t=[],e=0;e<this.keys.length;e++)t.push(this.keys[e].id);return t},t.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"]}]},t.hasControl=function(t){return-1!==this.getAvailableControls().indexOf(t)},t.hasDisplay=function(){return!1},t.hasKeyboardInput=function(){return!0},t.hasTouchInput=function(){return!0},t.stopListening=function(){try{this._keydownListener&&window.document.removeEventListener("keydown",this._keydownListener),this._keyupListener&&window.document.removeEventListener("keyup",this._keyupListener),this.messageListener&&window.removeEventListener("message",this.messageListener,!1),window.parent&&window.parent.document&&window.parent.document.removeEventListener("keyup",this._keyUp)}catch(t){console.log(t)}},t.resumeListening=function(){this.attachKeyboardEvents()},t.attachKeyboardEvents=function(){this.stopListening();try{var t=window.document;if(!document.fullscreenElement&&window.parent&&!(t=window.parent.document))throw new Error("Unaccessible");this._keydownListener=this._keyDown.bind(this),this._keyupListener=this._keyUp.bind(this),t.addEventListener("keydown",this._keydownListener),t.addEventListener("keyup",this._keyupListener)}catch(t){try{this.messageListener=this._onMessage.bind(this),window.addEventListener("message",this.messageListener,!1)}catch(t){console.error(t)}}},t.getConfigFromKey=function(t){for(var e=0;e<this.keys.length;e++){if(void 0!==this.keys[e].code&&this._keyMatches(this.keys[e].code,t.code))return this.keys[e];if(void 0!==this.keys[e].key&&this._keyMatches(this.keys[e].key,t.key))return this.keys[e];if(void 0!==this.keys[e].keyCode&&this._keyMatches(this.keys[e].keyCode,t.keyCode))return this.keys[e]}return null},t._keyMatches=function(t,e){return!!(Array.isArray(t)&&-1<t.indexOf(e))||t==e},t._onMessage=function(t){var e=t.data;if("object"==typeof e&&void 0!==e.type&&"catlab:keyboard"===e.type&&void 0!==e.code&&void 0!==e.action)switch(e.action){case"down":return void this._keyDown(t.data);case"up":return void this._keyUp(t.data)}},t._keyDown=function(t){var e;"Escape"!==t.key||!this.exitOnUnassignedBackButton||this.control("back").hasTriggers("click")||this.control("back").hasTriggers("up")||this.control("back").hasTriggers("down")?(e=this.getConfigFromKey(t))&&(this.control(e.id).update(1),void 0!==e.preventDefault)&&e.preventDefault&&t.preventDefault():this.requestExitApp()},t._keyUp=function(t){var e=this.getConfigFromKey(t);e&&(this.control(e.id).update(0),void 0!==e.preventDefault)&&e.preventDefault&&t.preventDefault()},t.requestExitApp=function(){var t;window.onbeforeunload?(t=window.onbeforeunload({}))&&this.confirm(t,function(t){t&&this.exitApp()}.bind(this)):this.exitApp()},t.exitApp=function(){window.close()},t.confirm=function(t,e){e(window.confirm(t))},e}),define("CatLab/Webremote/Models/Users/CordovaUser",["CatLab/Webremote/Models/Users/KeyboardUser"],function(t){function e(t,e,i){void 0===i&&(i=!0),void 0===e&&(e="back"),this.initializeKeyboardUser({id:"cordova",keys:t}),this.initializeBackButtonExit(e,i)}t=((e.prototype=Object.create(t.prototype)).constructor=e).prototype;return t.initializeBackButtonExit=function(i,n){void 0===n&&(n=!0);var s=new Date;document.addEventListener("backbutton",function(t){var e=new Date;e.getTime()-s.getTime()<300?this.requestExitApp():(s=e,t.preventDefault(),!n||this.control("back").hasTriggers("click")||this.control("back").hasTriggers("up")||this.control("back").hasTriggers("down")?(console.log("assigning back button to ",i),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)},t.exitApp=function(){navigator.app.exitApp()},t.confirm=function(t,e){navigator.notification.confirm(t,function(t){e(1===t)})},t.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}]},t.hasDisplay=function(){return!1},t.hasKeyboardInput=function(){return!0},t.hasTouchInput=function(){return!0},e}),define("CatLab/Webremote/Models/Users/AndroidRemoteUser",["CatLab/Webremote/Models/Users/CordovaUser"],function(t){function e(t,e,i){this.initializeKeyboardUser({id:"cordova",keys:t}),this.initializeBackButtonExit(e,i)}t=((e.prototype=Object.create(t.prototype)).constructor=e).prototype;return t.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}]},t.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"up",authenticate:"menu",left:"left",right:"right"}},t.hasDisplay=function(){return!1},t.hasKeyboardInput=function(){return!1},t.hasTouchInput=function(){return!1},this.getType=function(){return"android-keyboard"},e}),define("CatLab/Webremote/Models/Users/DummyUser",["CatLab/Webremote/Models/Users/ControlUser"],function(t){function e(t){this.initialize({id:t}),this.clearControls=function(){},this.getType=function(){return"dummy"},this.getIcon=function(){return"fa fa-keyboard-o"},this.emit=function(t,e){return!1},this.isLocalAuthentication=function(){return!1},this.log=function(t){this.Webcontrol&&this.Webcontrol.log("[u:"+this.getId()+"] "+t)},this.hasDisplay=function(){return!1},this.hasKeyboardInput=function(){return!0},this.hasTouchInput=function(){return!0},this.clearControls()}return(e.prototype=Object.create(t.prototype)).constructor=e}),define("CatLab/Webremote/Tools/ParseXML",[],function(){function t(){}var e=null;"undefined"!=typeof window&&(void 0!==window.DOMParser?e=function(t){return(new window.DOMParser).parseFromString(t,"text/xml")}:void 0!==window.ActiveXObject&&new window.ActiveXObject("Microsoft.XMLDOM")&&(e=function(t){var e=new window.ActiveXObject("Microsoft.XMLDOM");return e.async="false",e.loadXML(t),e}));return t.prototype.parse=function(t){if(e)return e(t);throw new Error("No XML parser found")},new t}),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(t,e,i,n,s,o,r){function a(t){t&&(this.airconsole=t),this.showTokenForm=!1,this.oauth={},this.views=[],this.knownUsers={},this.started=!1,this.userId=null,this.sendBurstDelay=50,this.connectCode=null}t=a.prototype=new t;return t.connect=function(t){return this.log("Airconsole connecting"),this.setInitialized(),this.path=t,this._trigger("connect",null),this.readyState.promise()},t.noTokenConnect=function(){return this.connect("remote")},t.setUserId=function(t){return this.userId=t,this},t.initMaster=function(t){this.master=t,this.airconsole||(this.airconsole=new AirConsole),this.airconsole.onMessage=this.onMessage.bind(this),this.airconsole.onConnect=function(t){this.emitAirConsole(t,"airconsole:well-hello-there",{user:t})}.bind(this),this.readyState=new i,this.airconsole.onReady=function(t){this.connectCode=t,this.readyState.resolve()}.bind(this),this.airconsole.onDeviceProfileChange=function(t){this.updateDeviceProfile(t)}.bind(this),this.on("player:join",function(t){this.onPlayerConnect(t.user)}.bind(this)),this.once("connect",function(){setTimeout(function(){this.started=!0}.bind(this),1)}.bind(this))},t.initPlayer=function(t){this.master=t,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(t){this.emitAirConsole(0,"player:join",{})}.bind(this))},t.onMessage=function(e,t){var i;void 0!==(t="string"==typeof t?JSON.parse(t):t).b&&Array.isArray(t.b)?(i=0,t.b.forEach(function(t){setTimeout(function(){this.processMessage(e,t)}.bind(this),i++)}.bind(this))):this.processMessage(e,t)},t.processMessage=function(t,e){var i;e&&e[0]&&(i=e[0],e=e[1],this.isMaster()&&(0<t&&"player:join"!==i&&void 0===this.knownUsers[t]&&this.onPlayerConnect(t),0<t)&&(e.user=t),o.unpack(e,"user").forEach(function(t){this.isRemote()&&void 0!==t.user&&t.user!==this.airconsole.getDeviceId()||this._trigger(i,t)}.bind(this)))},t.onPlayerConnect=function(t){this.log("Welcoming our newest player "+t),this.knownUsers[t]=!0;for(var e=0;e<this.views.length;e++)this.emitAirConsole(t,"view:load",{xml:this.views[e]}),this.emitAirConsole(t,"view:set",{id:"loading"});this._trigger("user:join",{id:t}),this.updateDeviceProfile(t)},t.updateDeviceProfile=function(t){var e,i,n=this.master._userlibrary.getFromId(t);n&&(e={username:this.airconsole.getNickname(t)},(i=this.airconsole.getProfilePicture(t))&&(e.avatar=i),this.airconsole.getMasterControllerDeviceId()===t&&n.setMaster(!0),n.setProfiledata(e))},t.emitAll=function(){this.isMaster()&&this.emitMaster(),this.isRemote()&&this.emitClient()},t.isMaster=function(){return"control"===this.path},t.isRemote=function(){return"remote"===this.path},t.emitClient=function(){this.queue.flush().forEach(function(t){this.emitAirConsole(0,t.action,t.data)}.bind(this))},t.emitMaster=function(){var e,i,t=this.queue.compactFlush();t.length&&(e=5<t.length,i=[],t.forEach(function(t){e||void 0===t.data.user||Array.isArray(t.data.user)&&1<t.data.user.length?i.push(t):this.emitAirConsole(t.user,t.action,t.data)}.bind(this)),0<i.length)&&this.broadcastAirconsole(i)},t.emitAirConsole=function(t,e,i){e=[e,i],delete e[1].action,i=JSON.stringify(e);this.airconsole.message(t,i)},t.broadcastAirconsole=function(t){var e=[],t=(t.forEach(function(t){e.push([t.action,t.data])}),JSON.stringify({b:e}));this.airconsole.broadcast(t)},t.setOAuthSettings=function(t){this.oauth=t,this.toPlayers("oauth:set",t)},t.loadViews=function(t){n.get(t).then(function(t){this.views.push(t),this.toPlayers("view:load",{xml:t})}.bind(this))},t.log=function(){this.master.log.apply(arguments)},t.setup=function(t){this._trigger("master:initialize",{})},t.toMaster=function(t,e){e.user=0,this.emit(t,e)},t.log=function(t){var e=[],i=(Array.prototype.push.apply(e,arguments),"["+this.path+"]");"remote"===this.path&&(i="["+this.path+":"+this.airconsole.getDeviceId()+"]"),e.unshift(i),console.log.apply(console,e)},t.getConnectInstructions=function(){return["Open the Airconsole app on your smartphone and connect with code %s.",this.connectCode]},t.getStartAndLoginInstructions=function(){return["Use the onscreen button to start the game."]},a}),define("CatLab/Webremote/CreateJS/LayerContainer",["easeljs","easelbone"],function(n,s){"use strict";function t(t,e){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=t,this.height=e,this.initialize(),this.easelboneLayer=new s.Views.Layer({container:this});var i=this;this.easelboneLayer.on("all",function(t){t=new n.Event(t);i.dispatchEvent(t)})}var e=t.prototype=new n.Container;return e.Container_initialize=e.initialize,e.initialize=function(){this.Container_initialize(),this.setBounds(0,0,this.width,this.height),this.on("click",function(t){t.stopPropagation()})},e.loading=function(){},e.render=function(){this.easelboneLayer.render()},t}),define("CatLab/Webremote/CreateJS/Views/PortalView",["easeljs","easelbone","CatLab/Webremote/Tools/Translator"],function(t,n,i){"use strict";return n.Views.Navigatable.extend({initialize:function(t){this.initializeNavigatable({orientation:this.ORIENTATION.HORIZONTAL});var e=this;this.assets=t.assets,t.showInactivePlayers?this.setScreen(new t.assets.PortalView):this.setScreen(new t.assets.PortalViewNoInactive),this.showInactivePlayers=t.showInactivePlayers||!1,this.portalController=t.controller,this.showInactivePlayers&&(this.connectedUsersContainer=new n.EaselJS.Placeholder(this.getScreen().connectedUsers),this.connectedUsers=new n.Controls.FloatContainer(function(t){return e.getUserIcon(t)},6),this.connectedUsersContainer.addChild(this.connectedUsers)),this.activeUsersContainer=new n.EaselJS.Placeholder(this.getScreen().activeUsers),this.activeUsers=new n.Controls.FloatContainer(function(t){return e.getUserIcon(t)},t.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(){e.portalController.startGame()}),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(){e.portalController.back()}),this.addControl(this.back)),this.portalController.on("users:update",function(){this.refreshUsers()}.bind(this)),this.portalController.on("options:change",function(){this.showCurrentAndMaxUsers()}.bind(this)),this.findPlaceholders("instructionHeader").forEach(function(t){t.addChild(new n.EaselJS.BigText(i.t("Instructions")))}),this.findPlaceholders("activePlayersHeader").forEach(function(t){t.addChild(new n.EaselJS.BigText(i.t("Active devices")))}),this.findPlaceholders("connectedPlayersHeader").forEach(function(t){t.addChild(new n.EaselJS.BigText(i.t("Connected devices")))}),this.instructionTexts=[],this.findPlaceholders("instructionText").forEach(function(t){var e=new n.EaselJS.BigText(this.getInstructionText());this.instructionTexts.push(e),t.addChild(e)}.bind(this)),this.activePlayerTexts=[],this.findPlaceholders("activePlayers").forEach(function(t){var e=new n.EaselJS.BigText(this.getActiveUsersText());this.activePlayerTexts.push(e),t.addChild(e)}.bind(this))},getActiveUsersText:function(){return this.portalController.countActiveUsers()+"/"+this.portalController.options.maxPlayers},getInstructionText:function(){return this.portalController.getConnectInstructions()+"\n"+this.portalController.getStartAndLoginInstructions()},getUserIcon:function(t){var e,i;return t?t.hasUser()?(e=new this.assets.UserIconAuthenticated,this.addControllerIcon(e,t)):e=this.getControllerIcon(t):e=this.getControllerIcon(),t&&(i=e.PlayerColor)&&new n.EaselJS.Placeholder(i).addChild(new n.EaselJS.Fill(t.getColor())),t&&this.setUserDetails(e,t),e},addControllerIcon:function(t,e){var i;t.ControllerIcon&&(t=new n.EaselJS.Placeholder(t.ControllerIcon),i=this.getControllerIcon(e),t.addChild(i),i.scaleX=i.scaleY=.5,e)&&(t=i.PlayerColor)&&new n.EaselJS.Placeholder(t).addChild(new n.EaselJS.Fill(e.getColor()))},getControllerIcon:function(t){if(t)switch(t.getType()){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(t){alert(t)},refreshUsers:function(){this.showCurrentAndMaxUsers(),this.showInformation(),this.reloadUserIcons(this.portalController.getUsers())},showCurrentAndMaxUsers:function(){this.getScreen().playercount&&(this.getScreen().playercount.text=this.portalController.countActiveUsers()+"/"+this.portalController.options.maxPlayers),this.activePlayerTexts.forEach(function(t){t.setText(this.portalController.countActiveUsers()+"/"+this.portalController.options.maxPlayers)}.bind(this)),this.getScreen().login&&(this.getScreen().login.text=this.portalController.getStartAndLoginInstructions())},showInformation:function(){var t=this.portalController.getConnectInstructions();this.getScreen().login?this.getScreen().login.text=this.portalController.getStartAndLoginInstructions():t+="\n "+this.portalController.getStartAndLoginInstructions(),this.getScreen().token&&(this.getScreen().token.text=t),this.instructionTexts.forEach(function(t){t.setText(this.getInstructionText())}.bind(this))},removeAllUserIcons:function(){this.showInactivePlayers&&this.connectedUsers.removeAllChildren(),this.activeUsers.removeAllChildren()},reloadUserIcons:function(t){var e=24,i=24;this.showInactivePlayers||(i=48),this.removeAllUserIcons(),t.forEach(function(t){t.isActive()?i<=0||(i--,this.activeUsers.createElement(t)):!this.showInactivePlayers||e<=0||(e--,this.connectedUsers.createElement(t))}.bind(this))},setUserDetails:function(t,e){var i;e.hasUser()&&t.userimage&&(i=new n.EaselJS.Placeholder(t.userimage),e.getUser().getImage(function(t){i.addChild(new n.EaselJS.Fill(t))}))},addAuthenticationView:function(t){this.el.addChild(t);var e=this;t.on("view:close",function(){e.el.removeChild(t)})},render:function(){this.el.addChild(this.getScreen()),this.refreshUsers()}})}),define("CatLab/Webremote/CreateJS/Views/AuthenticationView",["easelbone","CatLab/Webremote/Tools/Translator"],function(s,i){"use strict";return s.Views.Base.extend({initialize:function(t){var e=this,t=(this.assets=t.assets,this.screen=new t.assets.Signin,this.controller=t.controller,this.screen.close.on("click",function(){e.controller.close()}),this.linkAccount=new s.Controls.Button(this.screen.linkAccount),this.titlePlaceholder=null,this.explanationPlaceholder=null,s.Helpers.MovieClipHelper.findFromNames(["title"],[this.screen]).forEach(function(t){this.titlePlaceholder=new s.EaselJS.Placeholder(t)}.bind(this)),s.Helpers.MovieClipHelper.findFromNames(["explanation"],[this.screen]).forEach(function(t){this.explanationPlaceholder=new s.EaselJS.Placeholder(t)}.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(){e.controller.link()}),new s.Controls.ScrollArea(this.screen.accounts));this.users=new s.Controls.FloatContainer(function(t){return e.getUserObject(t)},4),t.content.addChild(this.users),this.controller.on("users:update",this.updateUsers,this),this.updateUsers(),this.on("removed",function(){this.trigger("close")}.bind(this))},updateUsers:function(){var t=this.controller.getUsers().getAll();this.users.removeAllChildren();for(var e=0;e<t.length;e++)this.users.createElement(t[e])},getUserObject:function(t){var e,i=this,n=new this.assets.UserModel;return t&&(n.namePlaceholder?new s.EaselJS.Placeholder(n.namePlaceholder).addChild(new s.EaselJS.BigText(t.getName())):n.name&&(n.name.text=t.getName()),e=new s.EaselJS.Placeholder(n.picture),t.getImage(function(t){e.addChild(new s.EaselJS.Fill(t))}),n.on("click",function(){i.controller.selectUser(t)})),n},close:function(){this.trigger("close")},render:function(){this.el.addChild(this.screen)},setLoginUrl:function(t){this.loginUrl=t,this.setLoginUrlText()},setLoginUrlText:function(){var t;this.linkAccount&&(this.linkAccount.setText(i.t("Login to add profile")),this.explanationPlaceholder)&&(t=new s.EaselJS.BigText(i.t("Or surf to %s to login from your phone.",this.loginUrl)),this.explanationPlaceholder.removeAllChildren(),this.explanationPlaceholder.addChild(t))}})}),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(t){return function(){return t.ctlbrmtassets}}(this)),define("CatLab/Webremote/ViewFactory/CreatejsViewFactory",["CatLab/Webremote/Tools/Deferred"],function(e){"use strict";function t(t){void 0!==t&&this.setAssets(t)}var o,r,a,i=t.prototype;return i.initialize=function(){var t=new e;return this.loadAssets().then(function(){this.setAssets(this.assets),t.resolve()}.bind(this)),t},i.loadAssets=function(){var s=new e;return require(["CatLab/Webremote/CreateJS/LayerContainer","CatLab/Webremote/CreateJS/Views/PortalView","CatLab/Webremote/CreateJS/Views/AuthenticationView","CatLab/Webremote/assets/createjsassets"],function(t,e,i,n){o=t,r=e,a=i,s.resolve()}.bind(this)),s.promise()},i.portal=function(t){return t.assets=this.assets,new r(t)},i.authentication=function(t){return t.assets=this.assets,new a(t)},i.setAssets=function(t){void 0!==t&&(this.assets=t)},i.getContainer=function(){var t=new o;return t.setBounds(0,0,this.assets.properties.width,this.assets.properties.height),t.loading(),t},t}),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/ViewFactory/ViewFactory","CatLab/Webremote/ViewFactory/CreatejsViewFactory"],function(e,t,i,n,s,o,r,a,h,l,c,u,d,p,f,g){return{Config:function(t){e.set(t)},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},ViewFactories:{HtmlViewFactory:f,CreatejsViewFactory:g},Smileys:a}}),define("catlabremote",["CatLab/Webremote/FrontController"],function(t){return t}),define("CatLab/EaselHacks/AlphaMaskFilter",[],function(t){function e(t){var n=this;this.createjs=t,Object.defineProperty(t.DisplayObject.prototype,"mask",{get:function(){return this.forceMask},set:function(t){var e,i=this;t?(i.originalMask=t,e=n.getFilterFromMask(t,i),i.filters=[e],i.cache(0,0,500,500)):null!==t&&(i.filters=null,i.cache(0,0,500,500))}}),t.DisplayObject.prototype.setMask=function(t){this.forceMask=t}}return e.prototype.getFilterFromMask=function(t,e){var i=this.createjs,n=t.graphics.getInstructions(),s=new i.Graphics;s.beginFill("#000000"),s.beginStroke("#000000");for(var o=0;o<n.length;o++)s.append(n[o]);t.graphics=s;var r=new i.Container,t=(r.addChild(t),r.scaleX=1/e.scaleX,r.scaleY=1/e.scaleY,r.y=-e.y,r.x=-e.x,new i.Container);return t.addChild(r),t.cache(0,0,1e3,1e3),new i.AlphaMaskFilter(t.cacheCanvas)},e}),define("CatLab/EaselHacks/FrontController",["CatLab/EaselHacks/AlphaMaskFilter"],function(t){return{AlphaMaskFilter:t}}),define("easelhacks",["CatLab/EaselHacks/FrontController"],function(t){return t}),define("CatLab/Webremote/Hacks",["easelhacks","easeljs"],function(t,e){new t.AlphaMaskFilter(e)});
|
|
1
|
+
var io,s,t,e,A,i,h,a;define("CatLab/Webremote/Tools/Net",[],function(){"use strict";return{loadJSON:function(t,e,i){var n=new XMLHttpRequest;n.onreadystatechange=function(){n.readyState===XMLHttpRequest.DONE&&200===n.status&&e&&e(JSON.parse(n.responseText))},n.onerror=function(t){t&&i(n,t)},n.open("GET",t,!0),n.send()}}}),define("CatLab/Webremote/Tools/Deferred",[],function(){function l(t){return"[object Array]"===Object.prototype.toString.call(t)}function c(t,e){if(l(t))for(var i=0;i<t.length;i++)e(t[i]);else e(t)}function u(t){var n="pending",s=[],o=[],r=[],a=null,i={done:function(){for(var t=0;t<arguments.length;t++)if(arguments[t])if(l(arguments[t]))for(var e=arguments[t],i=0;i<e.length;i++)"resolved"===n&&e[i].apply(this,a),s.push(e[i]);else"resolved"===n&&arguments[t].apply(this,a),s.push(arguments[t]);return this},fail:function(){for(var t=0;t<arguments.length;t++)if(arguments[t])if(l(arguments[t]))for(var e=arguments[t],i=0;i<e.length;i++)"rejected"===n&&e[i].apply(this,a),o.push(e[i]);else"rejected"===n&&arguments[t].apply(this,a),o.push(arguments[t]);return this},always:function(){return this.done.apply(this,arguments).fail.apply(this,arguments)},progress:function(){for(var t=0;t<arguments.length;t++)if(arguments[t])if(l(arguments[t]))for(var e=arguments[t],i=0;i<e.length;i++)"pending"===n&&r.push(e[i]);else"pending"===n&&r.push(arguments[t]);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(t){if(null==t)return i;for(var e in i)t[e]=i[e];return t},state:function(){return n},debug:function(){console.log("[debug]",s,o,n)},isRejected:function(){return"rejected"===n},isResolved:function(){return"resolved"===n},pipe:function(t,e,i){return u(function(i){c(t,function(e){"function"==typeof e?h.done(function(){var t=e.apply(this,arguments);t&&"function"==typeof t?t.promise().then(i.resolve,i.reject,i.notify):i.resolve(t)}):h.done(i.resolve)}),c(e,function(e){"function"==typeof e?h.fail(function(){var t=e.apply(this,arguments);t&&"function"==typeof t?t.promise().then(i.resolve,i.reject,i.notify):i.reject(t)}):h.fail(i.reject)})}).promise()}},h={resolveWith:function(t){if("pending"===n){n="resolved";for(var e=a=1<arguments.length?arguments[1]:[],i=0;i<s.length;i++)s[i].apply(t,e)}return this},rejectWith:function(t){if("pending"===n){n="rejected";for(var e=a=1<arguments.length?arguments[1]:[],i=0;i<o.length;i++)o[i].apply(t,e)}return this},notifyWith:function(t){if("pending"===n)for(var e=a=1<arguments.length?arguments[1]:[],i=0;i<r.length;i++)r[i].apply(t,e);return this},resolve:function(){return this.resolveWith(this,arguments)},reject:function(){return this.rejectWith(this,arguments)},notify:function(){return this.notifyWith(this,arguments)}},e=i.promise(h);return t&&t.apply(e,[e]),e}return u.when=function(){var t;if(arguments.length<2)return((t=arguments.length?arguments[0]:void 0)&&"function"==typeof t.isResolved&&"function"==typeof t.isRejected?t:u().resolve(t)).promise();for(var i=arguments,n=u(),s=i.length,o=0,r=new Array(s),e=0;e<i.length;e++)!function(t){var e;i[t].done?i[t].done(function(){r[t]=arguments.length<2?arguments[0]:arguments,++o==s&&n.resolve.apply(n,r)}).fail(function(){n.reject(arguments)}):(e=i[t],i[t]=new Deferred,i[t].done(function(){r[t]=arguments.length<2?arguments[0]:arguments,++o==s&&n.resolve.apply(n,r)}).fail(function(){n.reject(arguments)}).resolve(e))}(e);return n.promise()},u}),define("CatLab/Webremote/Collections/ServerList",["CatLab/Webremote/Tools/Deferred"],function(s){"use strict";function t(t,e){this.defaultId=t.default,this.servers=t.servers,this.connectUrl=t.connectUrl,this.selectedServerId=null,this.preferredServer=e,this.assetsUrl=t.assetsUrl}var e=t.prototype;return e.getFromToken=function(t){if(t.length<8)return{host:this.getDefault().host,token:t};var e=t.substr(0,2);if(e){e=this.getFromId(e);if(e)return{host:e.host,token:t.substr(2)}}throw new Error("Code does not correspondent to any servers.")},e.getSelectedServer=function(){var e=new s;return this.selectedServerId?this.getFromId(this.selectedServerId)?e.resolve(this.getFromId(this.selectedServerId).host):e.reject("Selected remote server not found in server list. Please make sure you are connected to the right network."):this.selectBestServer().then(function(t){this.selectedServerId||(this.selectServer(t.id),e.resolve(t.host))}.bind(this)),e.promise()},e.selectBestServer=function(){var i=new s;if(this.preferredServer)for(var t=0;t<this.servers.length;t++)if(this.servers[t].id==this.preferredServer)return i.resolve(this.servers[t]),i.promise();var n=!1;return this.servers.forEach(function(e){e.discoverable&&this.measureRequestSpeed("https://"+e.host+"/info").then(function(t){console.log("[ServerList] "+e.host+" took "+t+"ms"),n||(n=!0,i.resolve(e))}.bind(this))}.bind(this)),i.promise()},e.selectServer=function(t){this.selectedServerId=t},e.measureRequestSpeed=function(t){var e=new Date,i=new s,n=new XMLHttpRequest;return n.onreadystatechange=function(){var t;4==this.readyState&&200==this.status&&(t=(new Date).getTime()-e.getTime(),i.resolve(t))},n.open("GET",t),n.send(),i.promise()},e.getConnectURL=function(){if(this.selectedServerId){var t=this.getFromId(this.selectedServerId);if(t.connectUrl)return t.connectUrl}return this.connectUrl},e.getAssetURL=function(){var t;return this.assetsUrl||((t=this.getConnectURL())?("http"!==t.substring(0,4)&&(t="https://"+t),this.assetsUrl=t+"/assets/",this.assetsUrl):void 0)},e.getConnectToken=function(t){return this.getFromId(this.selectedServerId).connectUrl?t:this.selectedServerId+t},e.getFromId=function(t){for(var e=0;e<this.servers.length;e++)if(this.servers[e].id==t)return this.servers[e];return null},e.getDefault=function(){return this.getFromId(this.defaultId)},e.serialize=function(){return{server:this.selectedServerId}},e.unserialize=function(t){this.selectServer(t.server)},t}),define("CatLab/Webremote/Config",["CatLab/Webremote/Tools/Net","CatLab/Webremote/Collections/ServerList"],function(i,t){"use strict";var e="http";return{_options:{host:"www.catlab.tv",serverlist:null,preferredServer:null,protocol:e="undefined"!=typeof window&&void 0!==window.location&&void 0!==window.location.protocol?window.location.protocol.substr(0,window.location.protocol.length-1):e,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(t){void 0!==t&&(t.host,this._options.host=t.host,void 0!==t.protocol&&(this._options.protocol=t.protocol),void 0!==t.debug&&(this._options.debug=t.debug),void 0!==t.imageproxy&&(this._options.imageproxy=t.imageproxy),void 0!==t.proxy&&(this._options.proxy=t.proxy),void 0!==t.smileys&&(this._options.smileys=t.smileys),void 0!==t.assetsUrl&&(this._options.assetsUrl=t.assetsUrl),void 0!==t.vendorPath&&(this._options.vendorPath=t.vendorPath),void 0!==t.audioSync&&(this._options.audioSync=t.audioSync),void 0!==t.serverlist&&(this._options.serverlist=t.serverlist),void 0!==t.preferredServer&&(this._options.preferredServer=t.preferredServer),void 0!==t.allowAuthentication&&(this._options.allowAuthentication=t.allowAuthentication),void 0!==t.audioSyncConfig&&(this.audioSyncConfig=t.audioSyncConfig),void 0!==t.canFullscreen&&(this._options.canFullscreen=t.canFullscreen),void 0!==t.oauth)&&void 0!==t.oauth.redirectUrl&&(this._options.oauth.redirectUrl=t.oauth.redirectUrl)},getAll:function(){return this._options},initialize:function(e){var t;this._initialized?e():null===this._options.serverlist||"http"!==this._options.serverlist.substring(0,4)?(this._initialized=!0,e()):"json"===this._options.serverlist.substring(this._options.serverlist.length-4)?i.loadJSON(this._options.serverlist,function(t){this._initialized=!0,this._options.serverlist=t,e()}.bind(this),function(t,e){alert("Failed to connect to "+this._options.serverlist+". Game cannot start."),console.log(e)}.bind(this)):((t=document.createElement("script")).onload=function(){this._initialized=!0,this._options.serverlist=getCatLabRemoteServers(),e()}.bind(this),t.onerror=function(){alert("Failed to connect to "+this._options.serverlist+". Game cannot start.")}.bind(this),t.src=this._options.serverlist,document.head.appendChild(t))},getProtocol:function(t){var e=this._options.protocol;switch(e=void 0!==t&&t&&""===e?"http":e){case"http":case"https":break;default:e="https"}return e},getSocketURL:function(t){return this._options.host?((t=this.getProtocol(t))&&(t+=":"),t+"//"+this._options.host):"undefined"!=typeof window&&void 0!==window.location?window.location.protocol+"//"+window.location.hostname:""},getAssetsURL:function(t){var e;return this._options.assetsUrl||((e=this.getServerList())?e.getAssetURL():this.getSocketURL(t)+"/assets/")},debug:function(){return this._options.debug},getProxiedImage:function(t){return this._options.imageproxy?this._options.imageproxy+encodeURIComponent(t):t},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 t={smileys:this.useSmileys(),audioSync:this.useAudioSync()};return this.useAudioSync()&&(t.audioSyncConfig=this.audioSyncConfig),t},getServerList:function(){return this._options.serverlist?(this.serverCollection||(this.serverCollection=new t(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(t,e){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(t),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(t,e,i,n){},e=function(t){s("Page",t,"-",0)};return{setTracker:function(t){s=t},setPageMethod:function(t){e=t},track:function(t,e,i,n){s(t,e,i,n)},page:function(t){e(t)}}}),define("CatLab/Webremote/Tools/Tools",[],function(){var s,o;return{popup:function(t,e){var i=this,n=(e=e||!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=t,(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",e?(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(t,e){return window.open(t,"oauth:catlab-remote")},oauth2Popup:function(t,e){return this.oauth2PopupMethod(t,e)},closePopup:function(){s&&s.parentNode.removeChild(s),o&&o.parentNode.removeChild(o)},setOauth2Popup:function(t){return this.oauth2PopupMethod=t,this},sanitize:function(t){var e;return null==t?null:(e={"&":"&","<":"<",">":">",'"':""","'":"'"},String(t).replace(/[&<>"']/g,function(t){return e[t]}))},nl2br:function(t,e){return null==t?"":(t+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+(e||void 0===e?"<br />":"<br>")+"$2")},shuffle:function(t){for(var e,i,n=t.length-1;0<n;n--)e=Math.floor(Math.random()*(n+1)),i=t[n],t[n]=t[e],t[e]=i},getUuid:function(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)},findIndex:function(t,e){for(var i=0;i<t.length;i++)if(e(t[i]))return i;return-1},getConnectTokenForDisplay:function(t){return null===t?null:t.length%4==0?this.injectFillerInString(t,4," "):(t.length,this.injectFillerInString(t,3," "))},injectFillerInString:function(t,e,i){return t.match(new RegExp(".{1,"+e+"}","g")).join(i)}}}),define("CatLab/Webremote/Tools/Cookies",[],function(){var e={setCookie:function(t,e,i){return this.setItem(t,e,i)},getCookie:function(t){return this.getItem(t)},eraseCookie:function(t){return this.removeItem(t)},getItem:function(t){if("undefined"!=typeof document)return t&&this.hasOwnProperty(t)?unescape(document.cookie.replace(new RegExp("(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"),"$1")):null},key:function(t){if("undefined"!=typeof document)return unescape(document.cookie.replace(/\s*\=(?:.(?!;))*$/,"").split(/\s*\=(?:[^;](?!;))*[^;]?;\s*/)[t])},setItem:function(t,e,i){var n,s;t&&"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(t)+"="+escape(e)+"; expires="+n+"; path=/; SameSite=Strict;",this.updateLength())},length:0,removeItem:function(t){t&&this.hasOwnProperty(t)&&"undefined"!=typeof document&&(document.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; SameSite=Strict;",this.length--)},hasOwnProperty:function(t){if("undefined"!=typeof document)return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie)},updateLength:function(){var t;"undefined"!=typeof document&&document.cookie&&(t=document.cookie.match(/\=/g),e.length=t?t.length:0)}};return e.updateLength(),e}),define("CatLab/Webremote/Tools/Smileys",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Tools"],function(i,n){function t(t){this.provider=t,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 e=t.prototype;return e.shouldHaveUniqueSmileys=function(){return this.takenAmount<this.smileyKeys.length/3},e.setTakenSmileys=function(t){this.taken=t},e.getTakenSmileys=function(t){if(!this.shouldHaveUniqueSmileys())return{};t=this.identifierToText(t);var e,i={};for(e in this.taken)this.taken.hasOwnProperty(e)&&this.taken[e]!==t&&(i[e]=this.taken[e]);return i},e.getRandom=function(t){for(var e=null;null===e&&this.randomSmileys;)if(e=this.randomSmileys.shift(),this.reserve(e,t)||(e=null),0===this.randomSmileys.length)return this.randomSmileys=this.smileyKeys.slice(0),n.shuffle(this.randomSmileys),this.randomSmileys.shift();return e},e.reserve=function(t,e){return this.isExternalSmiley(t)?(this.unreserve(e),!0):(e=this.identifierToText(e),void 0!==this.taken[t]&&this.taken[t]===e?(this.taken[t]=e,!0):!!this.isAvailable(t)&&(this.unreserve(e),this.taken[t]=e,this.takenAmount++,!0))},e.unreserve=function(t){for(var e in t=this.identifierToText(t),this.taken)this.taken.hasOwnProperty(e)&&this.taken[e]===t&&(this.taken[e]=null,delete this.taken[e],this.takenAmount--)},e.isAvailable=function(t){return!this.shouldHaveUniqueSmileys()||!!this.isExternalSmiley(t)||void 0===this.taken[t]||null===this.taken[t]},e.identifierToText=function(t){return JSON.stringify(t)},e.isExternalSmiley=function(t){return"http"===t.substr(0,4)},e.getUrl=function(t){return null===t?null:this.isExternalSmiley(t)?t:i.getAssetsURL()+"smileys/"+t+".png"},e.getHtml=function(t){return null===t?null:'<span class="smiley" style="width: 64px; height: 64px; display: inline-block; background-image: url(\''+this.getUrl(t)+"');\"></span>"},e.getElement=function(t){var e;return null===t?null:((e=document.createElement("div")).innerHTML=this.getHtml(t),e.firstChild)},e.getImage=function(t){var e;return null===t?null:(void 0===this.images[t]&&((e=new Image).crossOrigin="anonymous",e.src=i.getProxiedImage(this.getUrl(t)),this.images[t]=e),this.images[t])},e.refreshTakenSmileys=function(t){this.shouldHaveUniqueSmileys()?t.emit("smileys:taken",{smileys:this.getTakenSmileys(t.getIdentifier())}):this.playerKnowsAboutNonUniqueSmileys[this.getStringIdentifier(t)]},e.getStringIdentifier=function(t){return t.type+":"+t.id},t}),define("CatLab/Webremote/Tools/Preloader",["../Config","CatLab/Webremote/Tools/Deferred"],function(e,o){function i(t){this.provider=t,this.provider.on("file:preload",function(t){t&&t.url&&this.preloadClientFile(t.url)}.bind(this)),this.urlMap={}}var t=i.prototype;return t.preload=function(e){if(Array.isArray(e)){for(var t=new o,i=[],n=0;n<e.length;n++)i.push(this.preload(e[n]));return o.when.apply(o,i).then(function(){t.resolve(Array.prototype.slice.call(arguments))}),t.promise()}var s=new o;return this.provider.emit("file:preload",{url:e},function(t){this.urlMap[e]=t.url,s.resolve(t)}.bind(this)),s.promise()},t.getPreloadedUrl=function(t){return this.urlMap[t]},t.preloadClientFile=function(t){void 0===this.urlMap[t]&&(t.toLowerCase().indexOf("http")<0&&(t=e.getProtocol()+":"+t),this.urlMap[t]=document.createElement("img"),this.urlMap[t].src=t)},t.serialize=function(){return{urlMap:this.urlMap}},i.unserialize=function(t,e){t=new i(t);return void 0!==e&&void 0!==e.urlMap&&(t.urlMap=e.urlMap),t},i}),define("CatLab/Webremote/Tools/Eventable",["CatLab/Webremote/Tools/Tools"],function(n){"use strict";function t(){}var s=0,e=t.prototype;return e.initializeEventable=function(){this._eventableEvents=[]},e.trigger=function(t){this.eventableTrigger.apply(this,arguments)},e.eventableTrigger=function(t){if("string"!=typeof t)throw new Error("eventableTrigger must be a string");if(void 0!==this._eventableEvents){var e,i=Array.prototype.slice.call(arguments);for(e in i.push(i.shift()),this._eventableEvents)this._eventableEvents.hasOwnProperty(e)&&this.eventMatches(t,e)&&this._eventableEvents[e].slice().forEach(function(t){try{t.method.apply(t.scope,i)}catch(t){console.error(t)}}.bind(this))}},e.eventMatches=function(t,e){return"*"===e||t===e},e.on=function(t,e,i){void 0===this._eventableEvents&&(this._eventableEvents={}),void 0===this._eventableEvents[t]&&(this._eventableEvents[t]=[]),s++,this._eventableEvents[t].push({id:s,method:e,scope:void 0!==i?i:this});var n=[t,s];return{id:n,name:t,method:e,unbind:function(){this.off(null,{id:n,name:t})}.bind(this)}},e.once=function(t,e,i){var n=this.on(t,function(){n.unbind(),e.apply(i,arguments)});return n},e.off=function(t,e){if(void 0!==t||void 0!==e)if(void 0===t||void 0!==e){if(t=e.name,e=e.id,void 0===this._eventableEvents[t])return null;var i=n.findIndex(this._eventableEvents[t],function(t){return t.id=e});0<=i&&(this._eventableEvents[t]=this._eventableEvents[t].splice(i,1))}else this._eventableEvents[t]=[];else this._eventableEvents=[]},e.clearEvents=function(){this.clearEventableEvents()},e.clearEventableEvents=function(){this._eventableEvents={}},t}),define("CatLab/Webremote/Models/User",["jquery","CatLab/Webremote/Config"],function(t,i){return function(t){this.accessToken=t,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(t){this.id=t},this.getId=function(){return this.id},this.setName=function(t){this.name=t},this.getName=function(){return this.name},this.setAvatar=function(t){var e=this;this.avatar=t,this.imageLoaded=!1,this.image=new Image,this.image.crossOrigin="anonymous",this.image.onload=function(){e.afterImageLoad()},this.image.src=i.getProxiedImage(this.avatar)},this.getAvatar=function(){return this.avatar},this.getAvatarSmiley=function(t){var e=this.getAvatar();return e?(e=e.split("?")[0],e+="?shape=circle&size=64&borderWidth=4",t&&(e+="&borderColor="+t.substr(1)),e):null},this.afterImageLoad=function(){this.imageLoaded=!0;for(var t=0;t<this.imageCallbacks.length;t++)this.imageCallbacks[t](this.image);this.imageCallbacks=[]},this.getImage=function(t){this.imageLoaded?t(this.image):this.imageCallbacks.push(t)}}}),define("CatLab/Webremote/Tools/Storage",["CatLab/Webremote/Tools/Cookies"],function(t){var e={clean:function(){if(this.isSupported())for(var t=Object.keys(window.localStorage),e=0;e<t.length;e++)this.get(t)},get:function(t,e){if(void 0===e&&(e=function(){}),this.isSupported())try{var i,n=window.localStorage.getItem(t);n?void 0!==(n=JSON.parse(n)).expires?(i=Date.now(),n.expires<i?(this.delete(t),e(null)):e(n.content)):e(n):e(null)}catch(t){e(null),console.log(t)}else e(null)},add:function(e,i,n,s){var o=this;n=n||function(){},this.isSupported()?this.get(e,function(t){(t=null!=t&&""!==t?t:[]).push(i),o.set(e,t,n,s)}):n(null)},set:function(t,e,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(t,JSON.stringify({expires:s,content:e}))}catch(t){console.log(t)}i()}else i(null)},delete:function(t){this.isSupported()&&window.localStorage.removeItem(t)},remove:function(n,s){var o;this.isSupported()&&(o=this).get(n,function(t){null!=t&&""!=t||(t=[]);for(var e=JSON.stringify(s),i=0;i<t.length;i++)if(e===JSON.stringify(t[i]))return t.splice(i,1),void o.set(n,t)})},isSupported:function(){if("undefined"==typeof window)return!1;try{if(void 0===window.localStorage)return!1}catch(t){return console.log(t),!1}return!0}};try{e.clean()}catch(t){console.error(t)}return e}),define("CatLab/Webremote/Collections/AuthenticatedUsers",["CatLab/Webremote/Models/User","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Tools/Eventable"],function(i,s,t){function e(){this.initializeEventable()}var o,r,n=[],t=e.prototype=new t;return t.initialize=function(t,e){o=e,r=t;var n=this;s.get("users",function(i){null!==i&&s.get("currentuser",function(e){for(var t=0;t<i.length;t++)n.addFromAccessToken(i[t].access_token,function(t){t&&e&&t.getAccessToken()===e&&void 0!==r.setUser&&r.setUser(t)})})})},t.addFromAccessToken=function(e,i){i=i||function(){};var n=this;o.profile(e,function(t){t?(t=n.add(e,t.user),i(t)):s.remove("users",{access_token:e})})},t.add=function(t,e){t=new i(t);return t.setId(e.id),t.setName(e.username),t.setAvatar(e.avatar),function(t){for(var e=0;e<n.length;e++)if(n[e].getId()==t.getId())return n[e]=t;n.push(t)}(t),this.trigger("update"),t},t.remove=function(t){for(var e=0;e<n.length;e++)if(n[e].getId()==t.getId())return void n.splice(e,1)},t.getFromId=function(t){for(var e=0;e<n.length;e++)if(n[e].getId()==t)return n[e];return null},t.getAll=function(){return n},new e}),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,callbacks=[],initialized=!1,afterInit=[],events=[],etPhoneHome=null;function OAuth2(){this.initializeEventable()}var p=OAuth2.prototype=new Eventable;return p.initialize=function(t){url=(t=t||{}).authorization||"https://quizted.catlab.eu/oauth2/authorize",client_id=t.client_id||"none",authorization=t.authorization||"default",profile_url=t.profile||"",avatar_url=t.profile+"/avatar",initialized=!0;var e=this;if("undefined"!=typeof window){function i(t){e.onMessage(t)}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(t,e){this.redirectHost=t,this.redirectUrl=t+e},p.getAuthorizeURL=function(){var t="",t=(Config.all().oauth&&Config.all().oauth.redirectUrl&&(t=Config.all().oauth.redirectUrl),url+"?client_id="+encodeURIComponent(client_id)+"&authorization="+encodeURIComponent(authorization)+"&response_type=token&redirect_uri="+encodeURIComponent(t)+"&reset=1&state=login");return void 0!==this.redirectUrl?this.redirectUrl+"?url="+encodeURIComponent(t):t},p.onMessage=function(t){if("I must've called a thousand times"!==t.data){var e;if("string"==typeof t.data&&t.data.match(/^oauth::/))try{e=JSON.parse(t.data.substring(7))}catch(t){return}else if("string"==typeof t.data)try{e=JSON.parse(t.data)}catch(t){return}else e=t.data;void 0!==e.access_token&&this.addAccessToken(e.access_token)}},p.addAccessToken=function(n){var t=function(t){var e,i=Users.add(n,t.user);for(Storage.add("users",{access_token:n}),Tools.closePopup();e=callbacks.shift();)e(i);this.trigger("update")}.bind(this);this.call(profile_url,n,t)},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(t,e){this.call(profile_url,t,e)},p.changeAvatar=function(e,t){var i;if(e.getAccessToken())return(i=new FormData).append("avatar",t.files[0]),$.ajax({type:"POST",url:avatar_url,data:i,contentType:!1,processData:!1,headers:{Authorization:"Bearer "+e.getAccessToken()},success:function(t){e.setAvatar(t.url)}})},p.link=function(e){var i=new Deferred,t={},t=("object"==typeof(e=void 0===e?{}:e)&&(e=(t=e).callback||function(){}),t.fullscreen||!1),n=(etPhoneHome&&clearInterval(etPhoneHome),this.getAuthorizeURL()),s=Tools.oauth2Popup(n,t);return s&&(etPhoneHome=setInterval(function(){s.postMessage("Hello from the other side","*")}.bind(this),1e3)),callbacks.push(function(t){e(t),i.resolve(t)}),i.promise()},p.onInit=function(t){afterInit.push(t)},p.onAdds=function(){for(var t=0;t<afterInit.length;t++)afterInit[t]()},p.getParamsFromHash=function(t){if("undefined"!=typeof window)return t=(t=t||window.location.hash).slice(1),(t=decodeURIComponent(t)).split("&").reduce(function(t,e){return t[(e=e.split("="))[0]]=e[1],t},{})},p.finish=function(){var t='oauth::{"catlabremote":1,"event":"user:authenticated","access_token":"'+this.getParamsFromHash().access_token+'"}';setTimeout(function(){window.opener&&window.opener.postMessage(t,"*"),window.parent&&window.parent.postMessage(t,"*"),void 0!==window.dialogArguments&&window.dialogArguments.opener&&window.dialogArguments.opener.postMessage(t,"*"),setTimeout(function(){etPhoneHome&&clearInterval(etPhoneHome),window.close()},1)},1)},new OAuth2}),define("CatLab/Webremote/Views/Popups/BasePopup",["jquery"],function(n){function t(){this.scrollable=!1}var e=t.prototype;return e.render=function(t){this.popupContainer=document.createElement("div"),this.popupContainer.className="catlab-popup-container";var e=document.createElement("div"),e=(e.className="overlay",this.popupContainer.appendChild(e),this.container=document.createElement("div"),this.container.className="popup",this.popupContainer.appendChild(this.container),n(this.container).click(function(t){t.stopPropagation()}),this.content=document.createElement("div"),this.container.appendChild(this.content),document.createElement("p")),i=(e.className="close",document.createElement("a"));i.href="javascript:void(0)",i.innerHTML="<span>Close</span>",i.onclick=function(){this.close()}.bind(this),e.appendChild(i),this.container.appendChild(e),t.appendChild(this.popupContainer),this.scrollable&&n(this.content).addClass("scrollable"),this.renderContent(this.content)},e.renderContent=function(){},e.close=function(){this.popupContainer.parentNode.removeChild(this.popupContainer)},t}),define("CatLab/Webremote/Views/User",["CatLab/Webremote/Controllers/OAuth2","jquery"],function(i,n){return function(d){this.render=function(t,e,i){e=e||[];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<e.length;u++)(h=document.createElement("li")).className=e[u].token,c.appendChild(h),(l=document.createElement("a")).onclick=e[u].click,l.innerHTML=e[u].text,l.href="javascript:void(0)",h.appendChild(l);r.appendChild(c),t.innerHTML="",t.appendChild(o);i=document.createElement("div");i.className="clearer",o.appendChild(i)},this.renderAvatar=function(){var t=d.getAvatar(),e=document.createElement("img");e.src=t,e.alt="User avatar",n(this.avatardiv).html(e)},this.enableAvatarUpload=function(t){var e=document.createElement("input");e.type="file",e.accept="image/*",this.avatarFileInput=e,n(e).on("change",function(){n(this.avatardiv).addClass("loading"),n.when(i.changeAvatar(d,e)).then(function(){n(this.avatardiv).removeClass("loading"),this.renderAvatar(),t.setUser(d)}.bind(this))}.bind(this)),n(this.avatardiv).click(function(){e.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(t,h,l,c,u,d){return function(e){function t(){h.link(function(t){s.updateUsers(),s.selectUser(t)})}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(){t()},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(t){e.setUser(t),s.close(),d.track("Click","Select user","AuthenticationPopup")},this.updateUsers=function(){o.innerHTML="";for(var t=l.getAll(),e=0;e<t.length;e++)!function(t,e){var i=document.createElement("li"),n=[{token:"select",text:"select",click:function(){s.selectUser(e)}},{token:"logout",text:"logout",click:function(){l.remove(e),u.remove("users",{access_token:e.getAccessToken()}),s.updateUsers(),d.track("Click","Logout","AuthenticationPopup")}}];new c(e).render(i,n,function(){s.selectUser(e)}),t.appendChild(i)}(o,t[e])},this.close=function(){i.parentNode.removeChild(i),d.track("Click","Close popup","AuthenticationPopup")},this.connect=function(){d.track("Click","Connect new","AuthenticationPopup"),t()},this.render=function(t){t.appendChild(i),this.updateUsers()},this.setLoginUrl=function(t){console.log(t)}}}),define("CatLab/Webremote/Views/Popups/SelectSmileyPopup",["CatLab/Webremote/Views/Popups/BasePopup"],function(t){function e(t,e,i){this.Webremote=t,this.callback=e,this.scrollable=!0,this.disableTaken=i}t=e.prototype=new t;return t.renderContent=function(t){$(t).addClass("smileys-popup");var e,i=$('<ul class="smileys"></ul>'),n=($(t).append(i),this.Webremote.smileys.smileyKeys.slice());this.Webremote.getUser()&&this.Webremote.getUser().getAvatar()&&(e=this.Webremote.getUser().getAvatarSmiley(this.Webremote.color))&&n.unshift(e);for(var s=0;s<n.length;s++)this.renderSmiley(i,n[s]);$(t).append('<div class="clearer"></div>')},t.renderSmiley=function(t,e){var i=$("<li>");i.append(this.Webremote.smileys.getElement(e)),this.disableTaken&&!this.Webremote.smileys.isAvailable(e)&&i.addClass("unavailable"),this.Webremote.getSmiley()===e&&i.addClass("selected"),i.click(function(){this.selectSmiley(e),t.find(".selected").removeClass("selected"),i.addClass("selected"),this.close()}.bind(this)),t.append(i)},t.selectSmiley=function(t){this.callback(t)},e}),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(t){var e,i,n;t.innerHTML="",s.canAuthenticate()&&(n=s.getUser(),(e=document.createElement("div")).className="overlay player-color-background",t.appendChild(e),(e=document.createElement("div")).className="content",e.className+=" player-color-border",t.appendChild(e),n?(t=[{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 t=s.getUser();r.remove(t),s.setUser(null),a.remove("users",{access_token:t.getAccessToken()}),h.track("Click","Logout","CurrentUser")}}],(i=new o(n)).render(e,t),i.enableAvatarUpload(s)):((n=document.createElement("p")).className="catlab-not-loggedin",(t=document.createElement("a")).href="javascript:void(0);",t.innerHTML="Login",t.onclick=function(){s.showAuthenticationPopup(0===r.getAll().length),h.track("Click","Login","CurrentUser")},n.appendChild(t),e.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(t){for(var e,i,n,s,o,r,a,h=function(t){if(m[t])return m[t];for(var e,i=t,n=[],s=0;i;){if(null!==(e=f.text.exec(i)))n.push(e[0]);else if(null!==(e=f.modulo.exec(i)))n.push("%");else{if(null===(e=f.placeholder.exec(i)))throw new SyntaxError("[sprintf] unexpected placeholder");if(e[2]){s|=1;var o=[],r=e[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])}e[2]=o}else s|=2;if(3===s)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n.push({placeholder:e[0],param_no:e[1],keys:e[2],sign:e[3],pad_char:e[4],align:e[5],width:e[6],precision:e[7],type:e[8]})}i=i.substring(e[0].length)}return m[t]=n}(t),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(e=l[c],i=0;i<n.keys.length;i++){if(null==e)throw new Error(g('[sprintf] Cannot access property "%s" of undefined value "%s"',n.keys[i],n.keys[i-1]));e=e[n.keys[i]]}else e=n.param_no?l[n.param_no]:l[c++];if(f.not_type.test(n.type)&&f.not_primitive.test(n.type)&&e instanceof Function&&(e=e()),f.numeric_arg.test(n.type)&&"number"!=typeof e&&isNaN(e))throw new TypeError(g("[sprintf] expecting number but found %T",e));switch(f.number.test(n.type)&&(r=0<=e),n.type){case"b":e=parseInt(e,10).toString(2);break;case"c":e=String.fromCharCode(parseInt(e,10));break;case"d":case"i":e=parseInt(e,10);break;case"j":e=JSON.stringify(e,null,n.width?parseInt(n.width):0);break;case"e":e=n.precision?parseFloat(e).toExponential(n.precision):parseFloat(e).toExponential();break;case"f":e=n.precision?parseFloat(e).toFixed(n.precision):parseFloat(e);break;case"g":e=n.precision?String(Number(e.toPrecision(n.precision))):parseFloat(e);break;case"o":e=(parseInt(e,10)>>>0).toString(8);break;case"s":e=String(e),e=n.precision?e.substring(0,n.precision):e;break;case"t":e=String(!!e),e=n.precision?e.substring(0,n.precision):e;break;case"T":e=Object.prototype.toString.call(e).slice(8,-1).toLowerCase(),e=n.precision?e.substring(0,n.precision):e;break;case"u":e=parseInt(e,10)>>>0;break;case"v":e=e.valueOf(),e=n.precision?e.substring(0,n.precision):e;break;case"x":e=(parseInt(e,10)>>>0).toString(16);break;case"X":e=(parseInt(e,10)>>>0).toString(16).toUpperCase()}f.json.test(n.type)?d+=e:(!f.number.test(n.type)||r&&!n.sign?a="":(a=r?"+":"-",e=e.toString().replace(f.sign,"")),s=n.pad_char?"0"===n.pad_char?"0":n.pad_char.charAt(1):" ",o=n.width-(a+e).length,o=n.width&&0<o?s.repeat(o):"",d+=n.align?a+e+o:"0"===s?a+o+e:o+a+e)}return d}function t(t,e){return g.apply(null,[t].concat(e||[]))}var m=Object.create(null);"undefined"!=typeof exports&&(exports.sprintf=g,exports.vsprintf=t),"undefined"!=typeof window&&(window.sprintf=g,window.vsprintf=t,"function"==typeof define)&&define.amd&&define("sprintf",[],function(){return{sprintf:g,vsprintf:t}})}(),define("CatLab/Webremote/Tools/Translator",["sprintf"],function(e){function t(){this.translator=null}var i,n,s=t.prototype;return s.setTranslator=function(t){this.translatorScope=this,"function"==typeof t?this.translator=t:("function"==typeof t.t?this.translator=t.t:(t._,this.translator=t._),this.translatorScope=t)},s.t=function(t){if(this.translator)return this.translator.apply(this.translatorScope,arguments);for(i=[],n=1;n<arguments.length;n++)i.push(arguments[n]);return e.vsprintf(t,i)},new t}),define("CatLab/Webremote/Views/Blocks/CurrentSmiley",["jquery","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/Deferred"],function(t,e,i){"use strict";function n(t,e,i,n){this.Webremote=t,this.canSwitch=void 0!==e&&!!e,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(t,e){n.isInitialized.resolve()})),n.isInitialized.promise()}.bind(this),n.activeSmileys=["1f601","1f60d","1f60e"];var s=n.prototype;return s.setSmiley=function(t){Array.isArray(t)||(t=[t]),this.smileys=t,n.initialize().then(function(){this.selector&&(this.selector.html(""),t.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(t,e){if(this.dragDisabled)return!1;o=e.position,r=$(e.helper).offset(),this.disableDrag(),i.toggleClass("flinging",!0)}.bind(this),stop:function(t,e){var i=e.position,n=this.getDistance(o,i);10<n?(i=this.getAngle(o,i),this.slingshot(r,i,n,e.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)">'+e.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(t,e){var i=t.left-e.left,t=t.top-e.top;return Math.sqrt(i*i+t*t)},s.getAngle=function(t,e){return Math.atan2(e.top-t.top,e.left-t.top)},s.slingshot=function(t,e,i,n,s){var o=Math.min(1,i/this.getMaxDistance());0<Math.sin(e-Math.PI)?n.animate({left:0,top:0,opacity:1},1e3):(i=1.5*Math.max(t.left,t.top),n.animate({left:Math.cos(e-Math.PI)*i,top:Math.sin(e-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:e,speed:o,smiley:s})}.bind(this),800))},s.render=function(t){n.initialize().then(function(){this.container=$(t),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(t){if(-1===n.activeSmileys.indexOf(t)){for(;2<n.activeSmileys.length;)n.activeSmileys.shift();n.activeSmileys.push(t),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 t(t){return decodeURIComponent(t.replace(n," "))}for(var e,i={},n=/\+/g,s=/([^&;=]+)=?([^&;]*)/g,o=window.location.hash.substring(1);e=s.exec(o);)i[t(e[1])]=t(e[2]);return i},getParameter:function(t){var e=this.getParameters();return void 0!==e[t]?e[t]:null},clear:function(){history.pushState("",document.title,window.location.pathname+window.location.search)}}}),define("CatLab/Webremote/Views/Alert",[],function(){return function(t,e){e=e||function(){},alert(t),e()}}),define("CatLab/Webremote/Views/Welcome",["CatLab/Webremote/Controllers/OAuth2","CatLab/Webremote/Views/User","CatLab/Webremote/Tools/Storage","CatLab/Webremote/Tools/Tracker"],function(t,e,i,o){return function(t){var e=this,i=document.createElement("div"),n=(i.className="catlab-popup-container",document.createElement("div")),n=(n.className="overlay",i.appendChild(n),document.createElement("div")),t=(n.className="popup thanks",i.appendChild(n),n.innerHTML=t,document.createElement("a")),s=(t.innerHTML="Start playing",t.onclick=function(){e.close()},t.href="javascript:void(0)",document.createElement("p"));s.appendChild(t),s.className="playnow",n.appendChild(s),this.close=function(){i.parentNode.removeChild(i),o.track("Click","Close popup","WelcomePopup")},this.render=function(t){t.appendChild(i)}}}),define("CatLab/Webremote/Views/ConnectionTrouble",["CatLab/Webremote/Tools/Translator"],function(t){function e(){this.visible=!1,this.div=null,this.timeoutTillShow=3e3,this.showTimeout=null,this.message=null}var i=e.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(t.t("Connection lost")))}.bind(this),this.timeoutTillShow))},i.text=function(t){this.message=t,this.div&&(this.div.innerHTML="<p>"+t+"</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},e}),define("CatLab/Webremote/Views/GamePaused",["CatLab/Webremote/Tools/Translator"],function(t){function e(){this.visible=!1,this.div=null,this.timeoutTillShow=1,this.showTimeout=null,this.message=null}var i=e.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(t.t("Please wait, the game is paused.")))}.bind(this),this.timeoutTillShow))},i.text=function(t){this.message=t,this.div&&(this.div.innerHTML='<p style="height: 100%; padding: 20% 0">'+t+"</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},e}),define("CatLab/Webremote/Synchronization/ClientRemoteView",["jquery"],function(n){"use strict";function t(t,e,i,n,s,o){this.controller=t,this.html="<p>Loading</p>",this.context={},this.viewId=e,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={},e=t.prototype;return e.render=function(t){var e;this.iframe?(e=document.createElement("iframe"),$(e).css({width:"100%",height:"100%",border:"none",margin:0,padding:0,position:"absolute",left:0,top:0}),$(t).html(e),this.element=e.contentDocument.body):this.element=t,this.el=t,this.$el=n(t),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)},e.updateEvents=function(){var c=this;function t(n,e,s){var o,r,a,h,l;c.shouldSetEvents(n,"touch")&&(h=!1,l=null,n.addEventListener("touchstart",function(t){return o=new Date,r={x:t.touches[0].pageX,y:t.touches[0].pageY},a={x:t.touches[0].pageX,y:t.touches[0].pageY},h=!0,l&&clearTimeout(l),e.apply(c,[n])}),n.addEventListener("touchmove",function(t){a={x:t.touches[0].pageX,y:t.touches[0].pageY}}),n.addEventListener("touchend",function(t){var e,i;if(r)return i=Math.abs(a.x-r.x),e=Math.abs(a.y-r.y),r=null,i=(new Date).getTime()-o.getTime()<300&&i<20&&e<20,l=setTimeout(function(){h=!1},1e3),s.apply(c,[n,i])}),n.addEventListener("mousedown",function(t){if(t.preventDefault(),!h)return e.apply(c,[n])}),n.addEventListener("mouseup",function(t){if(t.preventDefault(),!h)return s.apply(c,[n,!0])}))}for(var e=this.element.querySelectorAll("[data-button-id]"),i=0;i<e.length;i++)t(e[i],c.buttonDown,c.buttonUp),this.buttons.push(e[i]);for(e=this.element.querySelectorAll("[data-authentication-button]"),i=0;i<e.length;i++)t(e[i],function(){},c.authenticate);for(e=this.element.querySelectorAll("[data-value-id]"),i=0;i<e.length;i++)!function(e){var i,t;c.shouldSetEvents(e,"change")&&(i=e.getAttribute("data-value-id"),c.currentValues[i]=c.getDataValue(e),e.addEventListener("change",function(t){s[i]=new Date,c.syncValue(e)}),t=null,e.addEventListener("keyup",function(){t&&clearTimeout(t),t=setTimeout(function(){s[i]=new Date,c.syncValue(e)},1e3)}))}(e[i])},e.getDataValue=function(t){return"checkbox"===t.type?t.checked?1:0:t.value},e.syncValues=function(){for(var t=this.element.querySelectorAll("[data-value-id]"),e=0;e<t.length;e++)this.syncValue(t[e])},e.syncValue=function(t){var e=this.getDataValue(t),i=t.getAttribute("data-value-id");void 0!==this.currentValues[i]&&this.currentValues[i]===e||(this.currentValues[i]=e,this.controller.syncValue(i,this.getDataValue(t),this.viewId))},e.update=function(){for(var t=this.element.querySelectorAll("[data-button-decorator]"),e=0;e<t.length;e++)void 0===t[e].dataset.initialClasses&&(t[e].dataset.initialClasses=t[e].className);this.updateBigTextSizes()},e.updateBigTextSizes=function(){var i=$(this.element),t=i.find(".bigtext"),n={};t.each(function(){var t=$(this).attr("data-bigtext-group"),e=t?(void 0===n[t]&&(n[t]=0,i.find('.bigtext[data-bigtext-group="'+t+'"]').each(function(){n[t]=Math.max(n[t],$(this).text().length)})),n[t]):$(this).text().length;$(this).attr("data-bigtext-length",e)})},e.shouldSetEvents=function(t,e){return void 0===t["hasCatlabEventsAlready"+e]&&(t["hasCatlabEventsAlready"+e]=!0)},e.buttonDown=function(t){try{this.syncValues()}catch(t){console.error(t)}return this.controller.buttonDown(t.getAttribute("data-button-id"),this.viewId),!1},e.buttonUp=function(t,e){return this.controller.buttonUp(t.getAttribute("data-button-id"),this.viewId,e),!1},e.setLabel=function(t,e){for(var i=this.element.querySelectorAll("[data-button-label="+t+"]"),n=0;n<i.length;n++)i[n].innerHTML=e;this.update()},e.setClass=function(t,e){for(var i=this.element.querySelectorAll("[data-button-decorator="+t+"]"),n=0;n<i.length;n++){var s=i[n];s.className=s.dataset.initialClasses+" "+e}this.update()},e.domAppend=function(t,e){var i=document.getElementById(t);if(i){for(var n=this.stringToDom(e),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(t){console.log(t)}5e3<(new Date).getTime()-this.createdAt.getTime()&&0<s.length&&void 0!==s[0].scrollIntoView&&s[0].scrollIntoView(),this.update(),this.updateEvents()}},e.domReplace=function(t,e){t=document.getElementById(t);t&&(t.innerHTML=e,this.controller.components.attach(this._currentView,t,!1),this.update(),this.updateEvents())},e.domAttribute=function(t,e,i){n(t).attr(e,i)},e.changeValue=function(t){if(void 0!==s[t.id]){if((e=Math.abs(s[t.id].getTime()-(new Date).getTime()))<5)return}else var e=9999999999999;for(var i=this.element.querySelectorAll("[data-value-id="+t.id+"]"),n=0;n<i.length;n++)document.activeElement==i[n]&&e<5e3||(this.currentValues[t.id]=t.value,i[n].value=t.value)},e.vibrate=function(t){void 0!==window.navigator.vibrate&&void 0!==t.pattern&&Array.isArray(t.pattern)&&window.navigator.vibrate(t.pattern)},e.stringToDom=function(t){var e;return(e=0<=t.toLowerCase().indexOf("<tr")?document.createElement("tbody"):document.createElement("div")).innerHTML=t,e},e.stringInterpolateDataElements=function(t,s){return t.replace(/{{(.+?)}}/g,function(t,e,i,n){e=this.controller.resolveDataAttribute(e.trim());return e=s?s(e):e}.bind(this))},e.destroy=function(){this.syncValues(),void 0!==this.synchronizedData&&this.synchronizedData.destroy()},t}),define("CatLab/Webremote/Synchronization/DataItem",[],function(){function i(t,e,i){this.key=t,this.shared=e,this.side=i}var t=i.prototype;return t.setValue=function(t){this.value=t},t.canWrite=function(t){return!!this.shared||this.side===t},t.serialize=function(){return{key:this.key,shared:this.shared,side:this.side,value:this.value}},i.unserialize=function(t){var e=new i(t.key,t.shared,t.side);return e.setValue(t.value),e},i}),define("CatLab/Webremote/Synchronization/SynchronizedData",["CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Synchronization/DataItem"],function(t,s){function e(t,e,i){this.initializeEventable(),this.id=t,this.synchronizer=e,this.side=i,this.data={}}t=e.prototype=new t;return t.set=function(t,e,i){if(void 0===this.data[t])this.data[t]=new s(t,i,this.side);else if(!this.data[t].canWrite(this.side))throw"Trying to overwrite a non shared data attribute: "+t;this.data[t].setValue(e),this.emit(this.data[t])},t.processMessage=function(t){var e=t.key,i=t.side,n=t.value,t=t.shared;if(void 0===this.data[e])this.data[e]=new s(e,t,i);else if(!this.data[e].canWrite(i))throw"Trying to overwrite a non shared data attribute: "+e;this.data[e].setValue(n)},t.get=function(t){return void 0===this.data[t]?null:this.data[t].value},t.emit=function(t,e){void 0===e&&(e=this.synchronizer.emit);t=t.serialize();t.namespace=this.synchronizer.namespace,t.container=this.id,e("data:set",t)},t.refreshTarget=function(t){for(var e in this.data)this.data.hasOwnProperty(e)&&this.emit(this.data[e],t)},t.destroy=function(){this.synchronizer.destroy(this)},t.serialize=function(){var t,e={};for(t in this.data)this.data.hasOwnProperty(t)&&(e[t]=this.data[t].serialize());return e},t.unserialize=function(t){for(var e in this.data={},t)t.hasOwnProperty(e)&&(this.data[e]=s.unserialize(t[e]))},e}),define("CatLab/Webremote/Synchronization/DataSynchronizer",["CatLab/Webremote/Synchronization/SynchronizedData"],function(e){function t(t,e,i){this.namespace=t,this.emit=e,this.dataModels={},this.side=i}t.eventsToListenFor=["data:set"];var i=t.prototype;return i.checkNamespace=function(t){return void 0!==t.namespace&&t.namespace===this.namespace},i.processMessage=function(t,e){void 0!==e.container&&this.getFromIdentifier(e.container).processMessage(e)},i.getFromIdentifier=function(t){return void 0===this.dataModels[t]&&(this.dataModels[t]=new e(t,this,this.side)),this.dataModels[t]},i.destroy=function(t){t=t.id;void 0===this.dataModels[t]&&delete this.dataModels[t]},i.refreshTarget=function(t){for(var e in this.dataModels)this.dataModels.hasOwnProperty(e)&&this.dataModels[e].refreshTarget(t)},i.serialize=function(){var t,e={};for(t in this.dataModels)this.dataModels.hasOwnProperty(t)&&(e[t]=this.dataModels[t].serialize());return{dataModels:e}},i.unserialize=function(t){for(var e in t.dataModels)t.dataModels.hasOwnProperty(e)&&this.getFromIdentifier(e).unserialize(t.dataModels[e])},t}),define("CatLab/Webremote/Synchronization/EventHandler",["CatLab/Webremote/Tools/Eventable"],function(t){function e(t,e){this.initializeEventable(),this.namespace=t,this.emit=e}e.eventsToListenFor=["event:trigger"];t=e.prototype=new t;return t.checkNamespace=function(t){return void 0!==t.namespace&&t.namespace===this.namespace},t.processMessage=function(t,e){if("event:trigger"===t)return this.processTriggerEvent(e)},t.processTriggerEvent=function(t){void 0!==t.event&&this.eventableTrigger(t.event,void 0===t.parameters?{}:t.parameters)},t.trigger=function(t,e){this.emit("event:trigger",{namespace:this.namespace,event:t,parameters:e})},t.refreshTarget=function(t){},t.serialize=function(){return{}},t.unserialize=function(t){},e}),define("CatLab/Webremote/Synchronization/CombinedEventHandler",["CatLab/Webremote/Tools/Eventable"],function(t){function e(t,e){this.initializeEventable(),this.handlers=[]}return(e.prototype=new t).addHandler=function(t){this.handlers.push(t),t.on("*",function(t,e){this.trigger(e,t)}.bind(this))},e}),define("CatLab/Webremote/Synchronization/MessageQueue",[],function(){"use strict";function t(){this.queue=[]}var e=t.prototype;return e.add=function(t,e,i){this.queue.push({action:t,data:e,ack:i})},e.flush=function(){var t=this.queue;return this.queue=[],t},e.compactFlush=function(){var n,s,o,r,a=[],t=this.flush();return 0===t.length?t:(s={user:{},group:{}},o=0,r={},t.forEach(function(t){if(o++,this.canCompact(t)){var e=null;void 0!==t.data.user?e="user":void 0!==t.data.group&&(e="group"),void 0===s[e][t.action]&&(s[e][t.action]=[]);for(var i=0;i<s[e][t.action].length;i++)if(n=s[e][t.action][i],this.isSimilarMessage(n.event,t)&&(void 0===r[t.data[e]]||r[t.data[e]]<n.index))return r[t.data[e]]=n.index,n.event.data[e].push(t.data[e]),void n.event.data._d.push(this.getDifference(n.event,t));Array.isArray(t.data[e])||(t.data[e]=[t.data[e]]),t.data._d=[{}],r[t.data[e]]=o,s[e][t.action].push({event:t,index:o})}a.push(t)}.bind(this)),a)},e.moveToEnd=function(t,e){t.push(t.splice(t.indexOf(e),1)[0])},e.isSimilarMessage=function(t,e){return t.action===e.action&&this.getCompareDataString(t)===this.getCompareDataString(e)},e.getDifference=function(t,e){var i,n={};for(i in e.data)if(e.data.hasOwnProperty(i)){switch(i){case"user":case"group":case"_d":case"_i":continue}void 0!==t.data[i]&&t.data[i]===e.data[i]||(n[i]=e.data[i])}return n},e.getCompareDataString=function(t){t=Object.assign({},t.data);return delete t.user,delete t.group,delete t.viewId,delete t._d,delete t._i,JSON.stringify(t)},e.canCompact=function(t){return!(void 0!==t.ack&&null!==t.ack||void 0===t.data||void 0===t.data.user&&void 0===t.data.group)},t.unpack=function(t,e){if(void 0===t[e])return[t];var i=Array.isArray(t[e])?t[e]:[t[e]],n=[];void 0!==t._d&&(n=Array.isArray(t._d)?t._d:[t._d]);for(var s=[],o=0;o<i.length;o++){(r={})[e]=i[o];var r=Object.assign({},t,r,void 0!==n[o]?n[o]:{});delete r._d,s.push(r)}return s},Object.defineProperty(e,"length",{get:function(){return this.queue.length}}),t}),define("CatLab/Webremote/Tools/Proxy",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred"],function(o,r){function t(){}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 t.prototype.get=function(t){o.getProxy()&&(t=o.getProxy()+encodeURIComponent(t)),console.log(t);var e,i,n,s=new r;return t=t,e=function(t){s.resolve(t.responseText)},(n=function(){for(var t=!1,e=0;e<a.length;e++){try{t=a[e]()}catch(t){continue}break}return t}())&&(n.open(i?"POST":"GET",t,!0),i&&n.setRequestHeader("Content-type","application/x-www-form-urlencoded"),n.onreadystatechange=function(){4==n.readyState&&(200==n.status||304==n.status?e(n):console.error("CatLab Remote HTTP error "+n.status))},4!=n.readyState)&&n.send(i),s.promise()},new t}),define("CatLab/Webremote/Providers/Provider",["CatLab/Webremote/Synchronization/MessageQueue","CatLab/Webremote/Tools/Proxy","CatLab/Webremote/Tools/Deferred"],function(t,i,n){"use strict";function e(){this.initializeProvider()}var s=e.prototype;return s.initializeProvider=function(){this.queue=new t,this.postInitializeQueue=[],this.scheduled=!1,this.initialized=!1,this.sendBurstDelay=10,this.maxQueueSize=2500,this.messageCounter=null,this.events={}},s.getProviderSettings=function(){var t=new n;return t.resolve({}),t.promise()},s.setMessageCounter=function(t){this.messageCounter=t},s.initMaster=function(t){this.master=t},s.initPlayer=function(t){this.master=t},s.connect=function(){var t=new n;return t.resolve(),t.promise()},s.disconnect=function(){this.off()},s.setOAuthSettings=function(t){this.emit("oauth:set",t)},s.loadViews=function(t,e){(e=void 0===e?!1:e)?i.get(t).then(function(t){this.emit("view:load",{xml:t})}.bind(this)):this.emit("view:load",{url:t})},s.toMaster=function(t,e,i){this.emit(t,e,i)},s.toPlayers=function(t,e,i){this.emit(t,e,i)},s.toPlayer=function(t,e,i,n){i.user=t.getId(),this.emit(e,i,n)},s.toGroup=function(t,e,i,n){i.group=t.getId(),this.emit(e,i,n)},s.emit=function(t,e,i){this.initialized?this.queue?(this.queue.add(t,e,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(t,e,i):this.postInitializeQueue.push({action:t,data:e,ack:i})},s.createGroup=function(t,e,i,n){this.emit("group:create",{externalId:t,globalViews:e,shareColor:i,tags:n=void 0===n?[]:n})},s.executeQueue=function(){this.initialized&&this.emitAll()},s.setInitialized=function(){var t;for(this.initialized=!0;t=this.postInitializeQueue.shift();)this.emit(t.action,t.data,t.ack)},s.setup=function(t){this.emit("master:setup",t)},s.reset=function(t){this.emit("master:reset",null,function(){t()})},s.getStaticUrl=function(t){return t},s.reconnect=function(t,e,i,n){this.emit("master:reconnect",{token:t,accessToken:e,gameConfig:i},function(){n()}.bind(this))},s.off=function(){this.events={}},s.on=function(t,e){this._addEvent(t,e,!1),this._touchEvent(t)},s.once=function(t,e){this._addEvent(t,e,!0),this._touchEvent(t)},s._addEvent=function(t,e,i){void 0===this.events[t]&&(this.events[t]=[]),this.events[t].push({callback:e,once:i})},s._touchEvents=function(){for(var t in this.events)this.events.hasOwnProperty(t)&&this._touchEvent(t)},s._touchEvent=function(t){},s._trigger=function(t,i){var n;void 0!==this.events[t]&&(n=[],this.events[t].forEach(function(t){var e=t.callback;t.once&&n.push(t);try{e.apply(this,[i])}catch(t){console.error(t)}}),0<n.length)&&(n.unshift(this.events),function(t){for(var e,i,n=arguments,s=n.length;1<s&&t.length;)for(e=n[--s];-1!==(i=t.indexOf(e));)t.splice(i,1);return t}.apply(this,n))},s.getConnectURL=function(t){return null},s.getConnectToken=function(t){return null},s.tokenConnect=function(t){var e=new n;return e.resolve(),e.promise()},s.noTokenConnect=function(){var t=new n;return t.resolve(),t.promise()},s.restoreProviderSettings=function(t){},s.serializeProviderSettings=function(){return{}},e}),define("CatLab/Webremote/Providers/SocketIO",["CatLab/Webremote/Providers/Provider","CatLab/Webremote/Config","CatLab/Webremote/Tools/Deferred","CatLab/Webremote/Tools/Tools"],function(t,r,a,e){function i(){this.initializeProvider(),this.userId=null,this.randomToken=e.getUuid(),this.loadBalancerSessionToken="connid",this.socket=null,this._registeredEvents={}}var h=null,t=i.prototype=new t;return t.getProviderSettings=function(){var e=new a;return r.getServerList()?r.getServerList().getSelectedServer().done(function(t){e.resolve({host:t})}.bind(this)).fail(function(t){alert(t),e.reject(t)}.bind(this)):e.resolve({}),e.promise()},t.connect=function(n,s){var e,o=new a;return this.log("Loading socket.io"),e=function(){this.log("Connecting to socket.io");var t,e=r.getSocketURL(),i=(void 0!==s.host&&s.host&&(e=(t=r.getProtocol())?t+"://"+s.host:"//"+s.host),this.socket=h(e+"/"+n+"?"+this.loadBalancerSessionToken+"="+this.randomToken,{withCredentials:!1,reconnection:!0}),!1);this.socket.on("connect_error",function(t){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(t){this._trigger("reconnect")}.bind(this)),this._touchEvents(),o.resolve())}.bind(this))}.bind(this),require(["socket.io-client"],function(t){h=t,e()}),o.promise()},t.disconnect=function(t){void 0===t&&(t=!0),this.initialized=!1,this.socket&&((t?this:(this._registeredEvents={},this.socket)).off(),this.socket.disconnect(),this.socket=null)},t.off=function(){this._registeredEvents={},this.events={},this.socket.off()},t.setUserId=function(t){return this.userId=t,this},t.emitAll=function(){var t,e=this.queue.compactFlush();if(e.length)for(;t=e.shift();)this.emitOne(t.action,t.data,t.ack)},t.emitOne=function(t,e,i){this.socket.emit(t,e,i),this.messageCounter&&this.messageCounter.outgoing()},t.log=function(){this.master.log.apply(arguments)},t.getStaticUrl=function(t){return t.indexOf("?")<0?t+="?":t+="&",t+(this.loadBalancerSessionToken+"="+this.randomToken)},t._detachEvents=function(t){this.socket&&this.socket.off(t)},t._touchEvent=function(e){this.socket&&void 0===this._registeredEvents[e]&&(this.socket.on(e,function(t){this._trigger(e,t)}.bind(this)),this._registeredEvents[e]=!0)},t._handleSocketIoEvent=function(t,e){switch(t){case"connect":case"disconnect":break;default:return this._trigger(t,e)}},t.getConnectURL=function(t){return r.getServerList()?r.getServerList().getConnectURL():t},t.getConnectToken=function(t){return r.getServerList()?r.getServerList().getConnectToken(t):t},t.tokenConnect=function(t){var e=new a,i={};if(r.getServerList())try{var n=r.getServerList().getFromToken(t);i.host=n.host,t=n.token}catch(t){return e.reject(),e.promise()}return this.connect("remote",i).fail(function(){e.reject()}).then(function(){e.resolve(t)}),e.promise()},t.restoreProviderSettings=function(t){void 0!==t.serverlist&&r.getServerList()&&r.getServerList().unserialize(t.serverlist)},t.serializeProviderSettings=function(){var t={};return r.getServerList()&&(t.serverlist=r.getServerList().serialize()),t},i}),define("CatLab/Webremote/SonicSync/Library/ring-buffer",[],function(){function e(t){this.array=[],this.maxLength=t}return e.prototype.get=function(t){return t>=this.array.length?null:this.array[t]},e.prototype.last=function(){return 0==this.array.length?null:this.array[this.array.length-1]},e.prototype.add=function(t){this.array.push(t),this.array.length>=this.maxLength&&this.array.splice(0,1)},e.prototype.length=function(){return this.array.length},e.prototype.clear=function(){this.array=[]},e.prototype.copy=function(){var t=new e(this.maxLength);return t.array=this.array.slice(0),t},e.prototype.remove=function(t,e){this.array.splice(t,e)},e}),define("CatLab/Webremote/SonicSync/Library/sonic-coder",[],function(){function t(t){this.freqMin=(t=t||{}).freqMin||18500,this.freqMax=t.freqMax||19500,this.freqError=t.freqError||50,this.alphabetString=t.alphabet||"\n abcdefghijklmnopqrstuvwxyz0123456789,.!?@*",this.startChar=t.startChar||"^",this.endChar=t.endChar||"$",this.alphabet=this.startChar+this.alphabetString+this.endChar}return t.prototype.charToFreq=function(t){var e=this.alphabet.indexOf(t),t=(-1==e&&(console.error(t,"is an invalid character."),e=this.alphabet.length-1),this.freqMax-this.freqMin),e=e/this.alphabet.length,t=Math.round(t*e);return this.freqMin+t},t.prototype.freqToChar=function(t){if(!(this.freqMin<t&&t<this.freqMax))if(this.freqMin-t<this.freqError)t=this.freqMin;else{if(!(t-this.freqMax<this.freqError))return console.error(t,"is out of range."),null;t=this.freqMax}var e=this.freqMax-this.freqMin,t=(t-this.freqMin)/e,e=Math.round(this.alphabet.length*t);return this.alphabet[e]},t}),define("CatLab/Webremote/SonicSync/Library/sonic-server",["./ring-buffer","./sonic-coder"],function(e,i){function t(t){this.peakThreshold=(t=t||{}).peakThreshold||-65,this.minRunLength=t.minRunLength||2,this.coder=t.coder||new i(t),this.timeout=t.timeout||300,this.debug=!!t.debug,this.peakHistory=new e(16),this.peakTimes=new e(16),this.callbacks={},this.buffer="",this.state=n,this.isRunning=!1,this.iteration=0}var n=1,s=2;return t.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(t){console.log(t)}},t.prototype.stop=function(){this.isRunning=!1,this.track.stop()},t.prototype.on=function(t,e){"message"==t&&(this.callbacks.message=e),"character"==t&&(this.callbacks.character=e)},t.prototype.setDebug=function(t){this.debug=t;t=document.querySelector("canvas");t&&t.parentElement.removeChild(t)},t.prototype.fire_=function(t,e){"function"==typeof t&&t(e)},t.prototype.onStream_=function(t){var e;void 0!==t.getTracks()[0]?(this.track=t.getTracks()[0],e=new AudioContext,t=(this.audioContext=e).createMediaStreamSource(t),e=e.createAnalyser(),t.connect(e),this.freqs=new Float32Array(e.frequencyBinCount),this.analyser=e,this.isRunning=!0,this.raf_(this.loop.bind(this))):console.log("No microphone found.")},t.prototype.onStreamError_=function(t){console.error("Audio input error:",t)},t.prototype.getPeakFrequency=function(){for(var t=-1/0,e=-1,i=this.freqToIndex(this.coder.freqMin);i<this.freqs.length;i++)this.freqs[i]>t&&(t=this.freqs[i],e=i);return t>this.peakThreshold?this.indexToFreq(e):null},t.prototype.loop=function(){this.analyser.getFloatFrequencyData(this.freqs),(this.iteration+1)%300==0&&this.restartServerIfSanityCheckFails();var t=this.getPeakFrequency();t?(t=this.coder.freqToChar(t),this.debug&&console.log("Transcribed char: "+t),this.peakHistory.add(t),this.peakTimes.add(new Date)):(t=this.peakTimes.last())&&new Date-t>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},t.prototype.indexToFreq=function(t){return this.audioContext.sampleRate/2/this.freqs.length*t},t.prototype.freqToIndex=function(t){var e=this.audioContext.sampleRate/2;return Math.round(t/e*this.freqs.length)},t.prototype.analysePeaks=function(){var t=this.getLastRun();t&&(this.state==n?t==this.coder.startChar&&(this.buffer="",this.state=s):this.state==s&&(t!=this.lastChar&&t!=this.coder.startChar&&t!=this.coder.endChar&&(this.buffer+=t,this.lastChar=t,this.fire_(this.callbacks.character,t)),t==this.coder.endChar)&&(this.state=n,this.fire_(this.callbacks.message,this.buffer),this.buffer=""))},t.prototype.getLastRun=function(){for(var t=this.peakHistory.last(),e=0,i=this.peakHistory.length()-2;0<=i&&this.peakHistory.get(i)==t;i--)e+=1;return e>this.minRunLength?(this.peakHistory.remove(i+1,e+1),t):null},t.prototype.debugDraw_=function(){var t=document.querySelector("canvas");t||(t=document.createElement("canvas"),document.body.appendChild(t)),t.width=document.body.offsetWidth,t.height=480,drawContext=t.getContext("2d");for(var e=0;e<this.freqs.length;e++){var i=this.freqs[e]+400,i=t.height-i-1,n=t.width/this.freqs.length;drawContext.fillStyle="black",drawContext.fillRect(e*n,i,1,1)}},t.prototype.raf_=function(t){"undefined"==typeof window||window.chrome&&chrome.extension?setTimeout(t,1e3/60):requestAnimationFrame(t)},t.prototype.restartServerIfSanityCheckFails=function(){if(this.freqs[0]<-300)console.error("freqs[0] < -300. Restarting."),this.restart();else{for(var t=!0,e=0;e<10;e++)-100==this.freqs[e]&&(t=!1);t||(console.error("freqs[0:10] == -100. Restarting."),this.restart())}},t.prototype.restart=function(){},t}),define("CatLab/Webremote/SonicSync/Library/sonic-socket",["./sonic-coder"],function(e){var i=!1;function t(t){this.coder=(t=t||{}).coder||new e,this.charDuration=t.charDuration||.5,this.coder=t.coder||new e(t),this.rampDuration=t.rampDuration||.001,this.audioContext=new i}return"undefined"!=typeof window&&(i=window.AudioContext||window.webkitAudioContext||!1),t.prototype.send=function(t,e){t=this.coder.startChar+t+this.coder.endChar;for(var i,n=0;n<t.length;n++){var s=t[n],s=this.coder.charToFreq(s),o=this.audioContext.currentTime+this.charDuration*n;this.scheduleToneAt(s,o,this.charDuration)}e&&(i=this.charDuration*t.length,setTimeout(e,1e3*i))},t.prototype.scheduleToneAt=function(t,e,i){var n=this.audioContext.createGain(),i=(n.gain.value=0,n.gain.setValueAtTime(0,e),n.gain.linearRampToValueAtTime(1,e+this.rampDuration),n.gain.setValueAtTime(1,e+i-this.rampDuration),n.gain.linearRampToValueAtTime(0,e+i),n.connect(this.audioContext.destination),this.audioContext.createOscillator());i.frequency.value=t,i.connect(n),i.start(e)},t}),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(e,t,i,n,s,o){function r(t){this.options=e.getAudioSyncConfig(),this.alphabet=this.options.alphabet.split(""),this.controller=t}var a=r.prototype;return a.startListener=function(){this.stop();var t=new n(this.options);t.start(),t.on("message",this.onIncomingMessage.bind(this)),this.sonicServer=t},a.startSender=function(){this.sonicSocket=new s(this.options)},a.stop=function(){this.sonicServer&&this.sonicServer.stop()},a.sync=function(){var t=new o,e=this.generateRandomSequence(this.options.length);return this.sonicSocket.send(e+this.getParityLetter(e),function(){this.controller.trigger("sync:audio",{secret:e})}.bind(this)),t.promise()},a.generateRandomSequence=function(t){for(var e,i="",n="",s=0;s<t;s++){for(;e=Math.floor(Math.random()*this.alphabet.length),(n=this.alphabet[e])===i.substr(i.length-1,1););i+=n}return i},a.getParityLetter=function(t){for(var e=0,i=t.split(""),n=0;n<i.length;n++)e+=this.alphabet.indexOf(i[n]);t=e%this.alphabet.length;return i[i.length-1]===this.alphabet[t]&&(t=(t+1)%this.alphabet.length),this.alphabet[t]},a.onIncomingMessage=function(t){var e=t.substr(0,t.length-1),i=this.getParityLetter(e);i===t[t.length-1]?this.onMessage(e):console.log("Parity check failed, expected "+i+", ignoring message")},a.onMessage=function(t){this.controller.emit("sync:audio",{secret:t})},a.generateAlphabet=function(t){for(var e="",i=0;i<Math.min(t.length,9);i++)e+=i.toString();return e},r}),define("CatLab/Webremote/Tools/ClientSniffer",[],function(){"use strict";function t(){this._canPlayWebM=null}var e=t.prototype;return e.isMobileBrowser=function(){var t,e;return!this.isCordova()&&(t=!1,e=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(e)&&!/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(e.substr(0,4)))||t)},e.isCordova=function(){return"undefined"!=typeof cordova},e.isInternetExplorer=function(){var t=window.navigator.userAgent,e=t.indexOf("MSIE ");return 0<e?parseInt(t.substring(e+5,t.indexOf(".",e)),10):0<t.indexOf("Trident/")?(e=t.indexOf("rv:"),parseInt(t.substring(e+3,t.indexOf(".",e)),10)):0<(e=t.indexOf("Edge/"))&&parseInt(t.substring(e+5,t.indexOf(".",e)),10)},e.supportsLocalStorage=function(){try{if(window.localStorage)return!0}catch(t){return!1}},e.canPlayWebM=function(){if(null===this._canPlayWebM){this._canPlayWebM=!1;try{var t=document.createElement("video");t.canPlayType&&(this._canPlayWebM=t.canPlayType('video/webm; codecs="vp8, vorbis"'))}catch(t){console.error(t)}}return this._canPlayWebM},new t}),define("CatLab/Webremote/Components/ImagePositionInputComponent",["jquery","CatLab/Webremote/Tools/ClientSniffer"],function(h,t){function e(t,e){this.element=e,this.remotePlayerView=t,this.positions=[],this.canvas=null,this.isLoaded=!1,this.isRotated=!1,this.buttons=null,this.pointCountContainer=null,this.draw()}var i=e.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 src="'+this.image+'" /></div>'),this.imageElement=h(this.element).find("img"),this.imageElement.on("load",function(){this.isLoaded=!0,this.resizeImage()}.bind(this)),this.imageElement.on("dragstart",function(t){t.preventDefault()}),this.svgContainer=h('<div class="pointer-container">'),this.element.find(".image").append(this.svgContainer),this.resizeSvgContainer(),this.svgContainer.click(function(t){this.svgClick(t)}.bind(this)))},i.resizeSvgContainer=function(){var t=this.imageElement;this.isRotated&&this.rotatedImageElement&&(t=this.rotatedImageElement),this.svgContainer.css({position:"absolute","z-index":1,width:t.width(),height:t.height(),left:t.position().left,top:t.position().top})},i.resizeImage=function(){this.isLoaded&&(this.element.width(),this.element.height(),this.imageElement.get(0).naturalWidth,this.imageElement.get(0).naturalHeight,t.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 t,e,i,n,s,o,r,a;this.rotatedImageElement||(s=this.imageElement[0],t=this.imageElement.get(0).naturalWidth,e=this.imageElement.get(0).naturalHeight,(i=document.createElement("canvas")).width=e,i.height=t,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,-t/2,-e/2),this.rotatedImageElement=h(i),this.element.find("div.image").append(this.rotatedImageElement))},i.imageClick=function(t){var e=t.offsetX/this.imageElement.width(),t=t.offsetY/this.imageElement.height();this.selectPosition(e,t)},i.svgClick=function(t){var e=t.offsetX/this.svgContainer.width(),t=t.offsetY/this.svgContainer.height();this.isRotated?this.selectPosition(1-t,e):this.selectPosition(e,t)},i.canvasClick=function(t){var e=t.offsetX/this.rotatedImageElement.width(),t=t.offsetY/this.rotatedImageElement.height();this.selectPosition(1-t,e)},i.selectPosition=function(t,e){0<this.getMaxPoints()&&this.positions.length>=this.getMaxPoints()||(this.positions.push({x:t,y:e}),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(e){var t=this.imageElement,i=e.x,n=e.y,s=t.width(),t=t.height(),o=(this.isRotated&&this.rotatedImageElement&&(i=e.y,n=1-e.x,s=this.rotatedImageElement.width(),t=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(t){t.preventDefault(),t.stopPropagation(),this.removePoint(e),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:t*n-o-r})}.bind(this))},i.removePoint=function(t){t=this.positions.indexOf(t);-1<t&&this.positions.splice(t,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()},e.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; } ",e.selector="image-position-input",e}),define("CatLab/Webremote/Components/FullscreenButtonComponent",["jquery","screenfull","CatLab/Webremote/Config"],function(t,e,i){function n(t,e,i){this.element=e,this.remotePlayerView=t,this.position=null,this.componentContainer=i,this.draw()}var s=n.prototype;return s.draw=function(){i.canFullscreen()&&e&&e.isEnabled&&!e.isFullscreen?(t(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>'),t(this.element).click(function(){e.request(null,{navigationUI:"hide"})}.bind(this))):t(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(e){function t(t,e){this.element=e,this.remotePlayerView=t,this.position=null,this.draw()}var i=t.prototype;return i.draw=function(){if(this.element){e(this.element).html("");for(var t=0;t<this.content.childNodes.length;t++)e(this.element).append(this.content.childNodes[t].cloneNode(!0));this.componentContainer.attachComponents(this.remotePlayerView,this.element)}},i.update=function(){this.draw()},i.resize=function(){this.draw()},i.destroy=function(){},t.css=" ",t.selector="view-defined-component",t.content="",t}),define("CatLab/Webremote/Views/Popups/IframePopup",["CatLab/Webremote/Views/Popups/BasePopup"],function(t){function e(t){this.url=t}return(e.prototype=new t).renderContent=function(t){this.container.className+=" iframe";var e=$('<iframe src="'+this.url+'"></iframe>');$(e).css({height:"99%",width:"100%","border-width":0}),$(t).append(e),$(t).css({position:"relative",height:"100%",width:"100%","box-sizing":"border-box",overflow:"auto","-webkit-overflow-scrolling":"touch"})},e}),define("CatLab/Webremote/Components/ModalIframeLink",["jquery","CatLab/Webremote/Views/Popups/IframePopup"],function(e,i){function t(t,e,i){this.element=e,this.remotePlayerView=t,this.position=null,this.componentContainer=i,this.draw()}var n=t.prototype;return n.draw=function(){e(this.element).off("click"),e(this.element).on("click",function(){var t=e(this.element).attr("href"),t=this.remotePlayerView.stringInterpolateDataElements(t,encodeURIComponent);new i(t).render(document.body)}.bind(this))},n.resize=function(){this.draw()},n.update=function(){this.draw()},n.destroy=function(){},t.css=" ",t.selector="modal-iframe-link",t}),define("CatLab/Webremote/Views/Popups/TextPopup",["CatLab/Webremote/Views/Popups/BasePopup"],function(t){function e(t){this.message=t}return(e.prototype=new t).renderContent=function(t){var e=(e=this.message).replace(/(?:\r\n|\r|\n)/g,"<br>");t.innerHTML=e},e}),define("CatLab/Webremote/Components/TooltipComponent",["jquery","CatLab/Webremote/Views/Popups/TextPopup"],function(t,e){function i(t,e,i){this.element=e,this.remotePlayerView=t,this.position=null,this.componentContainer=i,this.draw()}var n=i.prototype;return n.draw=function(){t(this.element).off("click"),t(this.element).on("click",function(){new e(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(e,i,n){"use strict";var s,o=null,t=0;function r(){e(".simple-keyboard").addClass("hidden"),o=null}function a(t,e,i){this.element=e,this.remotePlayerView=t,this.position=null,this.componentContainer=i,this.inputType=e.attr("type")?e.attr("type").toLowerCase():"text",this.draw()}var h=a.prototype;return h.draw=function(){(function(){var t=e.Deferred();e("<link>").appendTo("head").attr({type:"text/css",rel:"stylesheet",href:n.getVendorPath()+"simple-keyboard/build/css/index.css"}),e('<div class="simple-keyboard"></div>').appendTo("body"),s=new i.default({onChange:function(t){o&&o.onKeyboardChange(t)}.bind(this),onKeyPress:function(t){switch(t){case"{shift}":case"{lock}":e="default"===s.options.layoutName?"shift":"default",s.setOptions({layoutName:e});break;case"{numbers}":case"{abc}":e="numbers"!==s.options.layoutName?"numbers":"default",s.setOptions({layoutName:e});break;case"{ent}":r();break;case"{arrowup}":o.increaseValue(1);break;case"{arrowdown}":o.increaseValue(-1)}var e}.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"}}),e(".simple-keyboard").addClass("hidden"),t.promise()})(),this.element.attr("id")||this.element.attr("id","input_"+ ++t),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 t;"number"===(t=this).inputType?s.setOptions({inputName:t.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:t.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}"]}}),e(".simple-keyboard").removeClass("hidden"),o=t,s.setInput(t.element.val(),t.element.attr("id"))},h.onKeyboardChange=function(t){var e;this.element.val(t),this.element.trigger("change"),this.element.attr("data-value-realtime")&&(e=this.element.attr("data-value-id"))&&this.remotePlayerView.controller.syncValue(e,t,this.remotePlayerView.viewId)},h.onInputChange=function(){s.setInput(this.element.val(),this.element.attr("id"))},h.onInputFocus=function(){this.showKeyboard()},h.setInputCaretPosition=function(t){this.element[0].setSelectionRange&&(this.element[0].focus(),this.element[0].setSelectionRange(t,t))},h.increaseValue=function(t){var e;"number"===this.inputType&&(e=(e=parseFloat(this.element.val()))||0,this.element.val(e+t))},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(e){function t(t,e){this.element=e,this.remotePlayerView=t,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=t.prototype;return i.draw=function(){var t;e(this.element).html(""),this.targetDate=this.element.attr("to"),this.targetDate&&(this.element.attr("start")&&(this.startDate=this.element.attr("start")),t=e('<div class="timer-container"></div>'),this.counterHtml=e('<div class="countdown"></div>'),t.append(this.counterHtml),this.progessBar=e('<div class="progress-bar"> </div>'),t.append(this.progessBar),e(this.element).append(t))},i.tick=function(){var t,e;this.targetDate&&this.counterHtml&&this.progessBar&&((t=this.targetDate-Date.now())<0?this.counterHtml.html("0"):(e=(Date.now()-this.startDate)/(this.targetDate-this.startDate)*100,this.counterHtml.html(Math.ceil(t/1e3)),this.progessBar.css("width",e+"%")))},i.resize=function(){},i.update=function(){this.draw()},i.clearInterval=function(){this.countdownInterval&&(clearInterval(this.countdownInterval),this.countdownInterval=null)},i.destroy=function(){this.clearInterval()},t.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; } ",t.selector="timer-countdown",t}),define("CatLab/Webremote/Components/SmileyFlingerComponent",["jquery","CatLab/Webremote/Views/Blocks/CurrentSmiley"],function(t,n){function e(t,e,i){this.element=e,this.remotePlayerView=t,this.position=null,this.componentContainer=i,this.smileySlinger=new n(i.Webremote,!0,!0,!1),this.draw()}var i=e.prototype;return i.draw=function(){this.smileySlinger.render(this.element)},i.resize=function(){this.draw()},i.update=function(){this.draw()},i.destroy=function(){},e.css=" ",e.selector="smiley-flinger",e}),define("CatLab/Webremote/Components/Components",["jquery","./ImagePositionInputComponent","./FullscreenButtonComponent","./ViewDefinedComponent","./ModalIframeLink","./TooltipComponent","./VirtualKeyboardComponent","./TimerComponent","./SmileyFlingerComponent"],function(s,e,i,o,n,r,a,h,l){function t(t){this.components=[e,i,n,r,a,h,l],this.Webremote=t,this.viewDefinedComponents=[],this.existingComponents=[]}var c=t.prototype;return c.initialize=function(){for(var t=0;t<this.components.length;t++)this.initializeComponent(this.components[t])},c.initializeComponent=function(t){t.css;var e=document.createElement("style");e.attributes.type="text/css",e.innerHTML=t.css,document.head.appendChild(e)},c.resetViewDefinedComponents=function(){for(var t=0;t<this.viewDefinedComponents.length;t++)this.removeComponent(this.viewDefinedComponents[t])},c.removeComponent=function(t){for(var e=0;e<this.components.length;e++)if(this.components[e].selector===t)return void this.components.splice(e,1)},c.addComponent=function(t){0<=this.components.indexOf(t)||(this.components.push(t),this.initializeComponent(t))},c.addViewDefinedComponent=function(t,n){for(var e=0;e<this.components.length;e++)if(this.components[e].selector===t)return;function i(t,e,i){this.element=e,this.remotePlayerView=t,this.position=null,this.content=n,this.componentContainer=i,this.draw()}this.viewDefinedComponents.push(t),i.prototype=new o,i.selector=t,i.content=n,this.components.push(i)},c.attach=function(t,e,i){(i=void 0===i?!0:i)&&(this.existingComponents.forEach(function(t){t.destroy()}.bind(this)),this.existingComponents=[]),this.attachComponents(t,e)},c.resize=function(){this.existingComponents.forEach(function(t){t.resize()}.bind(this))},c.update=function(){this.existingComponents.forEach(function(t){t.update()}.bind(this))},c.attachComponents=function(t,e){for(var i=0;i<this.components.length;i++)try{this.attachComponent(t,e,this.components[i])}catch(t){console.log(t)}},c.attachComponent=function(i,t,n){s(t).find(n.selector).each(function(t,e){e=new n(i,s(e),this);this.existingComponents.push(e)}.bind(this))},t}),!function(){!function(t,e){"use strict";"function"==typeof define&&define.amd?define("viewport-units-buggyfill",[],e):"object"==typeof exports?module.exports=e():t.viewportUnitsBuggyfill=e()}(this,function(){"use strict";var a,h,l,i,t,n=!1,e=window.navigator.userAgent,c=/([+-]?[0-9.]+)(vh|vw|vmin|vmax)/g,s=/(https?:)?\/\//,u=[].forEach,d=/MSIE [0-9]\./i.test(e),p=/MSIE [0-8]\./i.test(e),f=-1<e.indexOf("Opera Mini"),g=/(iPhone|iPod|iPad).+AppleWebKit/i.test(e)&&(t=e.match(/OS (\d)/))&&1<t.length&&parseInt(t[1])<10,m=-1<e.indexOf(" Android ")&&-1<e.indexOf("Version/")&&parseFloat((e.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(t,e){var i;return e=e||{bubbles:!1,cancelable:!1,detail:void 0},(i=document.createEvent("CustomEvent")).initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i};v.prototype=window.Event.prototype,window.CustomEvent=v}function b(){n&&(o(),setTimeout(function(){i.textContent=A(),i.parentNode.appendChild(i),window.dispatchEvent(new v("viewport-units-buggyfill-style"))},1))}function o(){return l=[],u.call(document.styleSheets,function(t){var e=function(t){try{if(!t.cssRules)return}catch(t){if("SecurityError"!==t.name)throw t;return}for(var e=[],i=0;i<t.cssRules.length;i++){var n=t.cssRules[i];e.push(n)}return e}(t);!e||"patched-viewport"===t.ownerNode.id||"ignore"===t.ownerNode.getAttribute("data-viewport-units-buggyfill")||t.media&&t.media.mediaText&&window.matchMedia&&!window.matchMedia(t.media.mediaText).matches||u.call(e,r)}),l}function r(i){if(7===i.type){var t;try{t=i.cssText}catch(t){return}c.lastIndex=0,c.test(t)&&!s.test(t)&&(l.push([i,null,t]),a.hacks)&&a.hacks.findDeclarations(l,i,null,t)}else i.style?u.call(i.style,function(t){var e=i.style.getPropertyValue(t);i.style.getPropertyPriority(t)&&(e+=" !important"),c.lastIndex=0,c.test(e)&&(l.push([i,t,e]),a.hacks)&&a.hacks.findDeclarations(l,i,t,e)}):i.cssRules&&u.call(i.cssRules,function(t){r(t)})}function A(){var t=window.innerHeight,e=window.innerWidth;h={vh:t,vw:e,vmax:Math.max(e,t),vmin:Math.min(e,t)};var n,s,o=[],r=[];return l.forEach(function(t){var t=function(t,e,i){var n=[];i=i.replace(c,y),a.hacks&&(i=a.hacks.overwriteDeclaration(t,e,i)),e&&(n.push(t.selectorText),i=e+": "+i+";");for(var s=t.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,t),e=t.selector.length?t.selector.join(" {\n")+" {\n":"",i=new Array(t.selector.length+1).join("\n}");e&&e===n?(e&&!n&&(n=e,s=i),r.push(t.content)):(r.length&&(o.push(n+r.join("\n")+s),r.length=0),e?(n=e,s=i,r.push(t.content)):(o.push(t.content),s=n=null))}),r.length&&o.push(n+r.join("\n")+s),f&&o.push("* { content: normal !important; }"),o.join("\n\n")}function y(t,e,i){i=h[i];return parseFloat(e)/100*i+"px"}function w(t){return t.slice(0,t.indexOf("/",t.indexOf("://")+3))}return{version:"0.6.1",findProperties:o,getCss:A,init:function(t){if(!n){if((a=(t=!0===t?{force:!0}:t)||{}).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 e,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),e=function(){function t(){var t=this,e=arguments;clearTimeout(s),s=setTimeout(function(){i.apply(t,e)},n)}var i,n,s;i=b,n=a.refreshDebounceWait||100;window.addEventListener("orientationchange",t,!0),window.addEventListener("pageshow",t,!0),(a.force||d||function(){try{return window.self!==window.top}catch(t){return 1}}())&&(window.addEventListener("resize",t,!0),a._listeningToResize=!0),a.hacks&&a.hacks.initializeEvents(a,b,t),b()},o=0,r=function(){--o||e()},u.call(document.styleSheets,function(t){if(t.href&&w(t.href)!==w(location.href)&&"ignore"!==t.ownerNode.getAttribute("data-viewport-units-buggyfill")){o++;var e=t.ownerNode,i=r,t=e.href,n=i,s=new XMLHttpRequest;if("withCredentials"in s)s.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)throw new Error("cross-domain XHR not supported");(s=new XDomainRequest).open("GET",t)}s.onload=function(){var t=document.createElement("style");t.media=e.media,t.setAttribute("data-href",e.href),t.textContent=this.responseText,e.parentNode.replaceChild(t,e),i()},s.onerror=n,s.send()}}),o||e()}},refresh:b}})}(),!function(){!function(t,e){"use strict";"function"==typeof define&&define.amd?define("viewport-units-buggyfill.hacks",[],e):"object"==typeof exports?module.exports=e():t.viewportUnitsBuggyfillHacks=e()}(this,function(){"use strict";var r=/calc\(/g,a=/["']/g,t=window.navigator.userAgent,n=(n=/MSIE [0-9]\./i.test(t))||!!navigator.userAgent.match(/MSIE 10\.|Trident.*rv[ :]*1[01]\.| Edge\/1\d\./);return{required:function(t){return t.isMobileSafari||n},initialize:function(){},initializeEvents:function(t,e,i){t.force||n&&!t._listeningToResize&&(window.addEventListener("resize",i,!0),t._listeningToResize=!0)},findDeclarations:function(t,e,i,n){var s,o;null!==i&&(s=t,o=e,t=n,"content"===i)&&-1<t.indexOf("viewport-units-buggyfill")&&t.replace(a,"").split(";").forEach(function(t){var e,t=t.split(":");2===t.length&&"viewport-units-buggyfill"!==(e=t[0].trim())&&(t=t[1].trim(),s.push([o,e,t]),r.test(t))&&(t=t.replace(r,"-webkit-calc("),s.push([o,e,t]))})},overwriteDeclaration:function(t,e,i){return i=n&&"filter"===e?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(t,e,i){t.addEventListener?t.addEventListener(e,i,!1):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i}var Webremote=function(){};function getParameterByName(t,e){e=e||window.location.href,t=t.replace(/[\[\]]/g,"\\$&");t=new RegExp("[?&]"+t+"(=([^&#]*)|&|#|$)").exec(e);return t?t[2]?decodeURIComponent(t[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(t,e){void 0!==e.token?this.token=e.token:this.token=getParameterByName("token"),void 0===e&&(e={}),this.setContainer(t),this.showLoading(),this.sonicSync=null,this.components=new Components(this),this.components.initialize(),this._initialize(e).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(t){return(t=void 0===t?{}:t).headless=!0,this._initialize(t)},_initialize:function(e){var i=new Deferred;return Config.set(e),Config.initialize(function(){Tracker.track("App","Initialize"),void 0===e.provider&&(e.provider=new SocketIOProvider),void 0!==e.headless&&(this._headless=!!e.headless),this.provider=e.provider,this.smileys=new Smileys(this.provider),this.provider.initPlayer(this),this.provider.on("disconnect",function(t){var e=this.getConnectionIssuesView();console.log("Connection lost... reconnecting"),e.show(),e.text(i18n.t("Connection lost... reconnecting"))}.bind(this)),this.provider.on("reconnect",function(t){this.provider.emit("user:reconnect",{id:this.gamedata.id,accessToken:this.gamedata.accessToken}),this.getConnectionIssuesView().hide()}.bind(this)),this.provider.on("user:error",function(t){var e;this._connectingDfd&&(e=this._connectingDfd,this._connectingDfd=null,e.reject(t.message))}.bind(this)),this.provider.on("user:initialize",function(t){this.gamedata=t,this.provider.setUserId(t.id),this._storeGameData(t),this._connectingDfd&&(t=this._connectingDfd,this._connectingDfd=null,t.resolve())}.bind(this)),this.provider.on("view:load",function(t){this.loadViewsXML(t.xml)}.bind(this)),this.provider.on("view:reset",function(t){this.resetViews()}.bind(this)),this.provider.on("config:set",function(t){if(Config.set(t),this.sonicSync&&this.sonicSync.stop(),Config.useAudioSync())try{this.sonicSync=new SonicSyncClient(this),this.sonicSync.startListener()}catch(t){console.error(t)}}.bind(this)),this.provider.on("view:set",function(t){this.showView(t.id,t.viewId,t.group),this.handleCombinedMessages(t)}.bind(this)),this.provider.on("button:label",function(t){this.setLabel(t)}.bind(this)),this.provider.on("button:decorate",function(t){this.setClass(t)}.bind(this)),this.provider.on("oauth:set",function(t){Config.supportsAuthentication()&&(OAuth2.initialize(t),this.isOauth2Set=!0,UsersCollection.initialize(this,OAuth2),HashParser.getParameter("access_token"))&&(t=HashParser.getParameter("access_token"),UsersCollection.addFromAccessToken(t,function(t){t&&this.setUser(t)}.bind(this)),HashParser.clear())}.bind(this)),this.provider.on("color:set",function(t){this.setPlayerColor(t.color)}.bind(this)),this.provider.on("user:smiley",function(t){this.setSmiley(t.smiley)}.bind(this)),this.provider.on("smileys:taken",function(t){this.smileys.setTakenSmileys(t.smileys)}.bind(this)),this.provider.on("game:disconnect",function(t){AlertPopup(i18n.t("You have been disconnected from the game."),function(){window.location.reload()})}.bind(this)),this.provider.on("dom:append",function(t){this.domAppend(t)}.bind(this)),this.provider.on("dom:replace",function(t){this.domReplace(t)}.bind(this)),this.provider.on("dom:attribute",function(t){this.domAttribute(t)}.bind(this)),this.provider.on("dom:alert",function(t){AlertPopup(t.message)}),this.provider.on("dom:open",function(t){void 0!==t.url&&window.open(t.url)}),this.provider.on("value:change",function(t){this.changeValue(t)}.bind(this)),this.provider.on("device:vibrate",function(t){this.vibrate(t)}.bind(this)),this.provider.on("game:pause",function(t){this.pause(t)}.bind(this)),this.provider.on("game:unpause",function(t){this.unpause(t)}.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 t=[this.userData,this.groupData],n=[this.userEvents,this.groupEvents];DataSynchronizer.eventsToListenFor.forEach(function(i){this.provider.on(i,function(e){t.forEach(function(t){t.checkNamespace(e)&&t.processMessage(i,e)})}.bind(this))}.bind(this)),EventHandler.eventsToListenFor.forEach(function(i){this.provider.on(i,function(e){n.forEach(function(t){t.checkNamespace(e)&&t.processMessage(i,e)})}.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(t){this.gamedata?(this.provider.emit("user:reconnect",{id:this.gamedata.id,accessToken:this.gamedata.accessToken}),this.provider.once("user:reconnect",function(){t()})):t()},connectProvider:function(t){return this.provider.tokenConnect(t)},_storeGameData:function(){var t=new Deferred,e=this._connectedToken;return Storage.set("gamestate_"+e,this.gamedata,function(){t.resolve()},864e5),t.promise()},_restoreGameData:function(){var e=new Deferred,t=this._connectedToken;return Storage.get("gamestate_"+t,function(t){t?(this.gamedata=t,e.resolve(!0)):e.resolve(!1)}.bind(this)),e.promise()},handleCombinedMessages:function(t){for(var e=[{name:"button:label",method:this.setLabel.bind(this)},{name:"button:decorate",method:this.setClass.bind(this)}],i=0;i<e.length;i++){var n=e[i].name,s=e[i].method;if(void 0!==t[n])for(var o=0;o<t[n].length;o++)s(t[n][o])}},emit:function(t,e){this.provider.toMaster(t,e)},getConnectionIssuesView:function(){return void 0===this.connectionTrouble&&(this.connectionTrouble=new ConnectionTroubleView),this.connectionTrouble},setGamePausedView:function(t){this.gamePaused=t},getGamePausedView:function(){return void 0===this.gamePaused?new GamePausedView:this.gamePaused},setContainer:function(t){domelement=t,this.element=t,dynamicStylesheet=document.createElement("style"),document.body.appendChild(dynamicStylesheet),document.body.className="catlab-remote"},on:function(t,e){void 0===triggers[t]&&(triggers[t]=[]),triggers[t].push(e)},trigger:function(t){var e=[].slice.apply(arguments);if(e.shift(),void 0!==triggers[t])for(var i=0;i<triggers[t].length;i++)triggers[t][i].apply(this,e)},loadViews:function(t,e){var i;e=e||function(){},this._headless?e():((i=new XMLHttpRequest).open("GET",Config.getProxy()+t,!0),i.onreadystatechange=function(){4==i.readyState&&200==i.status&&(this.loadViewsXML(i.responseText),e())}.bind(this),i.send())},resetViews:function(){this.views={},this.components.resetViewDefinedComponents();for(var t=0;t<this.stylesheets.length;t++)try{var e=this.stylesheets[t];e.parentNode&&e.parentNode.removeChild(e)}catch(t){console.error(t)}for(t=0;t<this.links.length;t++)try{var i=this.links[t];i.parentNode&&i.parentNode.removeChild(i)}catch(t){console.error(t)}this.stylesheets=[]},loadViewsXML:function(t,e){if(e=e||function(){},!this._headless){var i;if(Tracker.track("App","Load Views"),window.DOMParser?i=(new DOMParser).parseFromString(t,"text/xml"):((i=new ActiveXObject("Microsoft.XMLDOM")).async=!1,i.loadXML(t)),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(),e(),!0}e()},evalScript:function(xml){var aWebremote=Webremote;!function(){try{var Webremote=aWebremote;eval(xml.textContent)}catch(e){console.error(e)}}.bind(window)()},loadView:function(t){var e=t.getAttribute("id"),i=document.createElement("div"),n=!1;t.getAttribute("iframe")&&"false"!==t.getAttribute("iframe").toLowerCase()&&(n=!0);for(var s=0;s<t.childNodes.length;s++)i.appendChild(t.childNodes[s].cloneNode(!0));i.id=e,i.className="view "+t.className,this.views[e]={iframe:n,html:(new XMLSerializer).serializeToString(i)},this._currentViewId===e&&this.showView(this._currentViewId,this._currentViewViewId,this._currentViewGroupId)},loadComponent:function(t){for(var e=t.getAttribute("id"),i=document.createElement("div"),n=0;n<t.childNodes.length;n++)i.appendChild(t.childNodes[n].cloneNode(!0));this.components.addViewDefinedComponent(e,i)},showView:function(t,e,i){var n,s;this._headless||(this._currentView&&this._currentView.destroy(),"remote:authenticate"!==t?(this._currentViewId=t,this._currentViewViewId=e,this._currentViewGroupId=i,void 0!==this.views[t]?(n=(i?this.groupData:this.userData).getFromIdentifier("view:"+e),s=this.views[t],this._currentView=new ClientRemoteView(this,e,t,i,n,s.iframe),this._currentView.html=s.html,this._currentView.render(this.element),this.updateUser(),Tracker.track("App","Show View",t),this.trigger("remote:view:show",{id:t,view:this._currentView}),this.trigger("view:set",this._currentView)):this.element.innerHTML='<div class="loading"><p>Please wait, loading...</p><p>(Loading view: '+t+")</div></p>"):this.showAuthenticationView())},updateUser:function(){Tracker.track("App","Set user");var t=document.getElementById("authentication");t&&new CurrentUser(this).render(t),this._currentSmileyViews=[],Config.useSmileys()?(this.setSmileySelectViews(),this.setSmileyViews()):this.removeSmileyViews()},setSmileySelectViews:function(){for(var t=document.getElementsByTagName("smiley-select"),e=0;e<t.length;e++){var i=!t[e].hasAttribute("flingable")||"false"!==t[e].getAttribute("flingable"),i=new CurrentSmiley(this,!0,i);i.render(t[e]),this.smiley&&i.setSmiley(this.smiley),this._currentSmileyViews.push(i)}},setSmileyViews:function(){for(var t=document.getElementsByTagName("smiley"),e=0;e<t.length;e++){var i=t[e].hasAttribute("changeable")&&"false"!==t[e].getAttribute("changeable"),n=t[e].hasAttribute("flingable")&&"false"!==t[e].getAttribute("flingable"),i=new CurrentSmiley(this,i,n);i.render(t[e]),this.smiley&&i.setSmiley(this.smiley),this._currentSmileyViews.push(i)}},removeSmileyViews:function(){for(var t=document.getElementsByTagName("smiley-select"),e=0;e<t.length;e++)t[e].parentNode.removeChild(t[e]);for(t=document.getElementsByTagName("smiley"),e=0;e<t.length;e++)t[e].parentNode.removeChild(t[e]);for(var i=document.getElementsByClassName("if-config-smileys"),e=0;e<i.length;e++)i[e].parentNode.removeChild(i[e])},popup:function(t){new WelcomePopup(t).render(domelement)},showAuthenticationPopup:function(t){t=t||!1;var e=new AuthenticationPopup(this);e.render(domelement),t&&e.connect()},showSmileyPopup:function(t,e){void 0===t&&(t=function(t){this.selectSmiley(t)}.bind(this)),new SelectSmileyPopup(this,t,e=void 0===e?!0:e).render(domelement)},showAuthenticationView:function(){this.element&&(this.element.innerHTML='<p id="catlab-message">Please login.</p>',OAuth2.link({fullscreen:!0}).then(function(t){t?(this.setUser(t),this.element.innerHTML='<p id="catlab-message">Welcome! You may now close this screen.</p>',window.close()):this.showAuthenticationView()}.bind(this)))},buttonDown:function(t,e){this.provider.toMaster("button:down",{id:t})},buttonUp:function(t,e,i){this.provider.toMaster("button:up",{id:t,click:i=void 0!==i&&i}),this.trigger("user:interaction")},syncValue:function(t,e,i){return this.provider.toMaster("value:change",{id:t,value:e,viewId:i}),!1},showLoading:function(){this.element&&(this.element.innerHTML='<p id="catlab-loading">Connecting...</p>')},showTokenForm:function(){function e(t){var e=i.connect(t);t!==Cookies.getItem("last_token")&&Cookies.removeItem("last_token"),e.then(function(){Cookies.setItem("last_token",t,.25)}.bind(this)),e.fail(function(t){i.showTokenForm(),screenfull.enabled&&screenfull.isFullscreen&&screenfull.exit(),AlertPopup(t)}),i.showLoading(),i.trigger("remote:token:submit"),i.trigger("user:interaction")}var t=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",t.innerHTML="",t.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&&e(n),t.onsubmit=function(t){t.preventDefault();t=document.getElementById("token").value;return e(t),!1},this.element.innerHTML="",this.element.appendChild(t)},requestFullScreen:function(){screenfull.enabled&&!screenfull.isFullscreen&&screenfull.request()},connect:function(t){return t=t.replace(" ",""),null!==this._connectingDfd&&(this._connectingDfd.reject(),this._connectingDfd=null),this._connectingDfd=new Deferred,this._connectedToken=t,this._connectingDfd.fail(function(){this.provider.disconnect(!1)}.bind(this)),this.connectProvider(t).fail(function(){setTimeout(function(){this._connectingDfd.reject(i18n.t("Game not found. Please check your token."))}.bind(this),1)}.bind(this)).then(function(e){var i=!0;"0"===getParameterByName("reconnect")&&(i=!1),this._restoreGameData().then(function(t){t&&i?this.reconnect(function(){this._connectingDfd.resolve()}.bind(this)):this.provider.emit("user:join",{token:e})}.bind(this))}.bind(this)),this._connectingDfd.promise()},setLabel:function(t){this._currentView&&this._currentView.setLabel(t.id,Tools.nl2br(Tools.sanitize(t.label)))},setClass:function(t){this._currentView&&this._currentView.setClass(t.id,t.styles)},setPlayerColor:function(t){if(this.color=t,void 0!==dynamicStylesheet&&dynamicStylesheet){var e,i,n="",s=(dynamicStylesheet.innerHTML=(n+=".player-color-border { border-color:"+t+"; }")+(".player-color-background { background-color: "+t+"; }")+(".player-color { color: "+t+"; }"),{"theme-color":t,"msapplication-navbutton-color":t,"apple-mobile-web-app-status-bar-style":t});for(e in s)s.hasOwnProperty(e)&&((i=document.createElement("meta")).httpEquiv=e,i.content=s[e],document.getElementsByTagName("head")[0].appendChild(i))}},setSmiley:function(e){this.smiley=e,this._currentSmileyViews.forEach(function(t){t.setSmiley(e)})},getSmiley:function(){return this.smiley},selectSmiley:function(t){this.provider.toMaster("user:smiley",{smiley:t})},setUser:function(t){user=t,this.updateUser(),user?(this.provider.toMaster("user:login",{access_token:user.getAccessToken()}),Storage.set("currentuser",user.getAccessToken()),this.getSmiley()&&(t=user.getAvatarSmiley())&&this.selectSmiley(t)):(this.provider.toMaster("user:logout"),Storage.set("currentuser",null))},getUser:function(){return user},listViews:function(){var t,e=[];for(t in this.views)this.views.hasOwnProperty(t)&&e.push({name:t});return e},getRandomText:function(t,e){var i="abcdefghijklmnopqrstuvwyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";void 0===e&&(e=40);for(var n="",s=(t=void 0===t?10:t)+Math.random()*e,o=0;o<s;o++)n+=i.charAt(Math.floor(Math.random()*i.length)),.8<Math.random()&&(o++,n+=" ");return n},randomLabels:function(t,e){for(var i=domelement.querySelectorAll("[data-button-label]"),n=0;n<i.length;n++)i[n].innerHTML=this.getRandomText(t,e);this.update()},setOrientation:function(){if(window.innerHeight>=window.innerWidth)try{document.body.classList.remove("landscape"),document.body.classList.add("portrait")}catch(t){document.body.className="portrait"}else try{document.body.classList.add("landscape"),document.body.classList.remove("portrait")}catch(t){document.body.className="landscape"}this.components.resize()},domAppend:function(t){this._currentView&&(this._currentView.domAppend(t.id,t.html),this.components.update())},domReplace:function(t){this._currentView&&(this._currentView.domReplace(t.id,t.html),this.components.update())},domAttribute:function(t){this._currentView&&(this._currentView.domAttribute(t.id,t.name,t.value),this.components.update())},changeValue:function(t){this._currentView&&this._currentView.changeValue(t)},vibrate:function(t){this._currentView&&this._currentView.vibrate(t)},pause:function(t){void 0===this._gamePausedView&&(this._gamePausedView=this.getGamePausedView()),this._gamePausedView.show()},unpause:function(t){void 0!==this._gamePausedView&&this._gamePausedView.hide()},log:function(t){Config.debug()&&console.log(t)},canAuthenticate:function(){return this.isOauth2Set},getGroupIds:function(){return void 0===this.gamedata.groups?[]:this.gamedata.groups},resolveDataAttribute:function(t){if("token"===t)return this._connectedToken;var i,t=(t="data."===t.substring(0,5)?t.substring(5):t).split("."),e=(2!==t.length&&t.unshift("any"),t.shift()),t=t.shift();if(e===user)return this.userData.getFromIdentifier("user").get(t);if("group"===e.substring(0,5)){var n,s=this.getGroupIds();if(0===s.length)return null;if("group"===e)return this.groupData.getFromIdentifier("group:"+s[0]).get(t);if("]"===e.substring(e.length,1))return void 0===s[n=e.substr(e.substring(6,e.length-1))]?null:this.groupData.getFromIdentifier("group:"+s[n]).get(t)}return"any"===e&&(i=["user."+t],this.getGroupIds().forEach(function(t,e){i.push("group["+e+"]")}.bind(this))),null}},Webremote}),define("CatLab/Webremote/Tools/Colorwheel",[],function(){var t={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 t=this.colors[this.index%this.colors.length];return this.index++,t}};return t.initialize(),t}),define("CatLab/Webremote/Collections/Users",["CatLab/Webremote/Tools/Colorwheel"],function(i){"use strict";return function(){this.users=[],this.userMap={},this.add=function(t){var e;t.isColorSet()||(e=i.next(),t.setColor(e.color,e.name)),t.hasPlayerId()||t.setPlayerId(this.count()+1),this.users.push(t),this.userMap[t.getId()]=t},this.clear=function(){this.users=[],this.userMap={}},this.remove=function(t){this.users.splice(users.indexOf(t),1),void 0!==this.users[t.getId()]&&delete this.users[t.getId()]},this.getFromId=function(t){return void 0!==this.userMap[t]?this.userMap[t]:null},this.getAll=function(){return this.users},this.count=function(){return this.users.length},this.each=function(t){for(var e=0;e<this.users.length;e++)t(this.users[e])},this.not=function(i){var n=[];return this.each(function(t){for(var e=0;e<i.length;e++)if(i[e].getId()===t.getId())return void n.push(i[e])}),n}}}),define("CatLab/Webremote/Collections/Groups",["CatLab/Webremote/Tools/Colorwheel"],function(i){"use strict";return function(){var e;this.groups=[],this.groupMap={},this.add=function(t){var e;t.colorSet||(e=i.next(),t.setColor(e.color,e.name)),this.groupMap[t.getId()]=t,this.groups.push(t)},this.clear=function(){this.groups=[],this.groupMap=[]},this.addUser=function(t){for(var e,i=t.groupIds,n=!1,s=0;s<i.length;s++)(e=this.getFromId(i[s]))&&(n=!0,e.addUser(t),e.isShareColor())&&t.setColor(e.getColor(),e.getColorName());return n},this.remove=function(t){this.groups.splice(this.groups.indexOf(t),1),delete this.groupMap[t.getId()]},this.getFromId=function(t){return void 0!==this.groupMap[t]?this.groupMap[t]:null},this.getAll=function(){return this.groups},this.each=function(t){for(e=0;e<this.groups.length;e++)t(this.groups[e])}}}),define("CatLab/Webremote/Models/Control",[],function(){return function(i,n,t){var s,o,r=0,a={},h=i,l=[];this.id=i,this.decoration="",this.label="",this.isGlobal=t,this.pushed=function(){return 0===r},this.scale=function(){return r},this.update=function(t,e){0<r&&0===t?((e=void 0===e?!0:e)&&this.trigger("click"),this.trigger("up")):0===r&&0<t&&this.trigger("down"),r=t},this.getLabel=function(t){return(t=void 0===t?!0:t)?'<span class="control-label '+o+'">'+h+"</span>":h},this.setStaticLabel=function(t,e){return h=t,o=e,this},this.setLabel=function(t,e){return this.label=t,n.emit("button:label",{id:i,label:t}),this},this.decorate=function(t){return this.decoration=t,n.emit("button:decorate",{id:i,styles:t}),this},this.click=function(t){return this.on("click",t),this},this.on=function(t,e){return this.log("Setting trigger "+t),void 0===a[t]&&(a[t]=[]),a[t].push(e),this},this.trigger=function(t){this.log("Triggering "+t);var e=[];if(void 0!==a[t])for(this.log("Found "+a[t].length+" events"),s=0;s<a[t].length;s++)e.push(a[t][s]);for(s=0;s<e.length;s++)e[s]();return this},this.hasTriggers=function(t){return void 0===t?0<Object.keys(a).length:void 0!==a[t]&&0<a[t].length},this.off=function(t){return(a=void 0===t?{}:a)[t]=[],this},this.clear=function(){return this.clearEvents(),this.decoration=null,this.label=null,this},this.clearEvents=function(){return a={},this},this.addDomElement=function(t){var e=this,i=[];return i.push(t.addEventListener("click",function(){e.trigger("click")})),l.push({element:t,listeners:i}),this},this.clearDomElements=function(){for(var t=0;t<l.length;t++)for(var e=0;e<l[t].listeners.length;e++)l[t].element.removeEventListener("click",l[t].listeners[e]);return l=[],this},this.isLocalAuthentication=function(){return!1},this.refreshTarget=function(t){this.decoration&&t.emit("button:decorate",{id:i,styles:this.decoration}),this.label&&t.emit("button:label",{id:i,label:this.label})},this.log=function(t){n.log("["+this.id+"] "+t)}}}),define("CatLab/Webremote/Synchronization/MultipleTargetControl",[],function(){function t(t,e){this.id=t,this.remoteView=e,this.label=null,this.decoration=null}var e=t.prototype;return e.pushed=function(){var e=[];return this.remoteView.targets.forEach(function(t){e=e||t.control(this.id).pushed()}.bind(this)),e},e.scale=function(){var e,i=0;return this.remoteView.targets.forEach(function(t){(e=t.scale())>i&&(i=e)}.bind(this)),pushed},e.update=function(e){this.remoteView.targets.forEach(function(t){t.control(this.id).update(e)}.bind(this))},e.getLabel=function(){return this.label},e.setLabel=function(e){return this.label=e,this.remoteView.targets.forEach(function(t){t.control(this.id).setLabel(e)}.bind(this)),this},e.decorate=function(e){return this.decoration=e,this.remoteView.targets.forEach(function(t){t.control(this.id).decorate(e)}.bind(this)),this},e.click=function(t){return this.on("click",t),this},e.on=function(e,i){return this.remoteView.targets.forEach(function(t){t.control(this.id).on(e,i)}.bind(this)),this},e.off=function(e){return this.remoteView.targets.forEach(function(t){t.control(this.id).off(e)}.bind(this)),this},e.refreshTarget=function(e){return this.remoteView.targets.forEach(function(t){t.control(this.id).refreshTarget(e)}.bind(this)),this},t}),define("CatLab/Webremote/Synchronization/RemoteView",["CatLab/Webremote/Models/Control","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Synchronization/MultipleTargetControl","CatLab/Webremote/Synchronization/DataSynchronizer"],function(t,e,i,n){function s(t,e,i,n,s){this.initializeEventable(),this.id=e,this.viewId=t,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(t){this.addTarget(t)}.bind(this))}e=s.prototype=new e;return e.clearValues=function(){this.valueMap={}},e.addTarget=function(t){this.targets.push(t),this.refreshTarget(t)},e.refreshTarget=function(e){var t,i={id:this.id,viewId:this.viewId};for(this.tmpid in this.groupId&&(i.group=this.groupId),e.emit("view:set",i),this.newUserStack.map(function(t){e.emit(t.action,t.data)}.bind(this)),e.controls)e.controls.hasOwnProperty(this.tmpid)&&e.controls[this.tmpid].isGlobal&&e.controls[this.tmpid].refreshTarget(e);for(this.tmpid in this.controls)this.controls.hasOwnProperty(this.tmpid)&&(void 0!==this.controls[this.tmpid].refreshTarget?this.controls[this.tmpid].refreshTarget(e):console.error("Unexpected control:",this.controls[this.tmpid]));for(t in this.valueMap)this.valueMap.hasOwnProperty(t)&&e.emit("value:change",{id:t,value:this.valueMap[t]})},e.emit=function(e,i){this.targets.map(function(t){t.emit(e,i)})},e.clearControls=function(){for(var t=this.Webcontrol.getViewLabels(this.currentView),e=0;e<t.length;e++)this.control(t[e].id).setStaticLabel(t[e].label,"mobile")},e.control=function(t){return void 0===this.controls[t]&&(this.controls[t]=new i(t,this)),this.controls[t]},e.trigger=function(t,e){"value:change"==t&&this.changeValue(e.id,e.value)},e.changeValue=function(t,e){this.valueMap[t]=e,this.emit("value:change",{id:t,value:e}),this.eventableTrigger("value:change",t,e)},e.refreshControls=function(){for(this.tmpid in this.controls)this.controls.hasOwnProperty(this.tmpid)&&this.controls[this.tmpid].refreshControl()},e.getValues=function(){return this.valueMap},e.log=function(t){this.Webcontrol.log(t)},e.domAppend=function(t,e){this._stackAndEmit("dom:append",{id:t,html:e})},e.domReplace=function(t,e){this._stackAndEmit("dom:replace",{id:t,html:e})},e.domAttribute=function(t,e,i){this._stackAndEmit("dom:attribute",{id:t,name:e,value:i})},e.vibrate=function(t){Array.isArray(t)?this.emit("device:vibrate",{pattern:t}):console.error("Vibrate pattern must be an array.")},e.listenTo=function(t,e,i){this.listeners.push(t.on(e,i))},e.stopListening=function(){this.listeners.forEach(function(t){t.unbind()})},e._stackAndEmit=function(t,e){this.newUserStack.push({action:t,data:e}),this.emit(t,e)},e.destroy=function(){this.stopListening(),this.factory.destroy(this)},s}),define("CatLab/Webremote/Synchronization/RemoteViewFactory",["CatLab/Webremote/Synchronization/RemoteView"],function(s){function t(){this.viewCounter=0,this.views={}}var e=t.prototype;return e.create=function(t,e,i,n){return this.viewCounter++,this.views[this.viewCounter]=new s(this.viewCounter,t,e,i,n),(this.views[this.viewCounter].factory=this).views[this.viewCounter]},e.createDummy=function(t,e){return this.create(t,[],e)},e.getFromId=function(t){return this.views[t]},e.destroy=function(t){t=t.id;delete this.views[t]},new t}),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(e,i,n,t,s,o,r,a){function h(t,e){this.initializeEventable(),(e=void 0===e?{}:e).id=t,e.playerId=null,this.initialize(e)}t=h.prototype=new t;return t.hasPlayerId=function(){return 0<this.playerId},t.setPlayerId=function(t){return this.playerId=t,this},t.control=function(t,e){return void 0===e&&(e=!1),void 0===this.controls[t]&&(this.controls[t]=new i(t,this,e)),this.controls[t]},t.getAvailableControls=function(){return["a","b","x","y","up","down","right","left","start","back"]},t.hasControl=function(t){return!0},t.setWebcontrol=function(t){this.Webcontrol=t},t.initialize=function(t){this.id=t.id,t.playerId&&(this.playerId=t.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=t,this.profiledata={},this.access_token=null,this.user=null,this.master=!1,this.authenticated=!1,void 0!==t&&void 0!==t.groups?this.groupIds=t.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={}},t.setSettings=function(t){return this.settings=t,this},t.trigger=function(e,i){0<=o.eventsToListenFor.indexOf(e)?(this.dataSynchronizer.checkNamespace(i)&&this.dataSynchronizer.processMessage(e,i),this.getGroups().forEach(function(t){t.dataSynchronizer.checkNamespace(i)&&t.dataSynchronizer.processMessage(e,i)}.bind(this))):0<=r.eventsToListenFor.indexOf(e)?(this.events.checkNamespace(i)&&this.events.processMessage(e,i),this.getGroups().forEach(function(t){t.events.checkNamespace(i)&&t.events.processMessage(e,i)}.bind(this))):"button:down"===e?this.control(i.id).update(1):"button:up"===e?this.control(i.id).update(0,i.click):"user:login"===e?this.login(i):"user:logout"===e?this.logout(i):"user:smiley"===e?this.setSmiley(i.smiley):"sync:audio"===e&&this.eventableTrigger("sync:audio",i)},t.setSmiley=function(e){this.smiley=e;var i=null;this.getGroups().forEach(function(t){i=!0,t.setSmiley(e,this)}.bind(this)),i||this.Webcontrol.smileys.reserve(e,this.getIdentifier())?this.emit("user:smiley",{smiley:e}):this.emit("dom:alert",{message:s.t("Smiley is already taken. Please select a different smiley.")})},t.setNickname=function(t){return this.nickname=t,this},t.getNickname=function(){return this.nickname||(this.getData().username?this.getData().username:this.playerId?"Player "+this.playerId:"Player "+this.id)},t.clearSmiley=function(){this.smiley=null,this.getGroups().forEach(function(t){t.clearSmiley(this)}.bind(this)),this.emit("user:smiley",{smiley:null})},t.getSmiley=function(){return this.smiley},t.getSmileyImage=function(){return this.Webcontrol.smileys.getImage(this.getSmiley())},t.getSmileyHtml=function(){return this.Webcontrol.smileys.getHtml(this.getSmiley())},t.getSmileyUrl=function(){return this.Webcontrol.smileys.getUrl(this.getSmiley())},t.login=function(t){},t.logout=function(t){},t.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()},t.clearEvents=function(){this.clearControls(),this.clearEventableEvents()},t.emit=function(t,e,i){return this.Webcontrol.provider.toPlayer(this,t,e,i),!0},t.getId=function(){return this.id},t.getName=function(){return"User "+this.getId()},t.getType=function(){return"mobile"},t.getEntityType=function(){return"user"},t.getIcon=function(){return"fa fa-mobile-phone"},t.loginFromAuthUser=function(t,e){t={access_token:t.getAccessToken()};this.login(t,e)},t.login=function(e,i){var n=this;this.Webcontrol.getOAuthClient(function(t){t&&(this.setAccessToken(e.access_token),t.profile(n.access_token,function(t){n.authenticated=!0,this.setProfiledata(t.user),void 0!==i&&i()}.bind(this)))}.bind(this))},t.setAccessToken=function(t){this.access_token=t},t.getAccessToken=function(){return this.access_token},t.setProfiledata=function(t){t=void 0!==(this.profiledata=t).accessToken?t.accessToken:null,t=new e(t);void 0!==this.profiledata.id&&t.setId(this.profiledata.id),void 0!==this.profiledata.username&&t.setName(this.profiledata.username),void 0!==this.profiledata.avatar&&t.setAvatar(this.profiledata.avatar),this.setUser(t),this.eventableTrigger("login",this)},t.isAuthenticated=function(){return this.authenticated},t.getData=function(){return this.profiledata},t.logout=function(t){this.profiledata=null,this.access_token=null,this.authenticated=!1},t.setColor=function(t,e){this.colorSet=!0,this.color=t,this.colorName=e,this.emit("color:set",{color:t,name:e})},t.isColorSet=function(){return this.colorSet},t.getColor=function(){return this.color},t.getColorName=function(){return this.colorName},t.isActive=function(){return this.active},t.toggleActive=function(){this.setActive(!this.active),this.setJoinLabel()},t.setJoinLabel=function(){!0===this.active?this.control("a").setLabel("LEAVE"):this.control("a").setLabel("JOIN")},t.setActive=function(t,e){this.active=t,this.eventableTrigger("active:change",t),this.active&&this.eventableTrigger("active:activate"),void 0!==e&&e&&this.setJoinLabel()},t.setView=function(t){return this.clearView(),this.currentView=n.create(t,[this],this.Webcontrol),this.currentView},t.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())},t.refreshView=function(){this.currentView&&this.currentView.refreshTarget(this)},t.getValues=function(){return this.currentView?this.currentView.getValues():null},t.clearValues=function(){this.currentView&&this.currentView.clearValues()},t.setUser=function(t){return this.usermodel=t,this},t.hasUser=function(){return void 0!==this.usermodel&&this.usermodel},t.getUser=function(){return this.usermodel},t.isLocalAuthentication=function(){return!0},t.log=function(t){this.Webcontrol&&this.Webcontrol.log("[u:"+this.getId()+"] "+t)},t.getGroups=function(){return this.groups},t.hasDisplay=function(){return!0},t.hasKeyboardInput=function(){return!0},t.hasTouchInput=function(){return!0},t.getIdentifier=function(){return{id:this.getId(),type:this.getEntityType()}},t.represents=function(t){if(void 0===t.id||void 0===t.type)throw"Attribute is not an identifier.";var e=this.getIdentifier();return e.type===t.type&&e.id===t.id},t.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"up",authenticate:"y",left:"left",right:"right"}},t.isMainGroup=function(){if(0===this.groups.length)return!0;for(var t=0;t<this.groups.length;t++)if(this.groups[t].isMainGroup())return!0;return!1},t.isMaster=function(){return this.master},t.setMaster=function(t){var e=this.master!==(t=!!(t=void 0===t?!0:t));return this.master=t,e&&this.eventableTrigger("master:change"),this},t.resetViews=function(t){this.emit("view:reset",{},t=void 0===t?function(){}:t)},t.replaceViews=function(t,e){this.resetViews(function(){this.loadViews(t,e)}.bind(this))},t.loadViews=function(t,e){void 0===e&&(e=function(){}),this.log("Loading views for group "+t),this.emit("view:load",{url:t},e)},t.getConnectToken=function(){return this.Webcontrol.getConnectToken()},t.getConnectTokenForDisplay=function(){return this.Webcontrol.getConnectTokenForDisplay()},t.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()}},t.unserialize=function(t){void 0!==t.profiledata&&this.setProfiledata(t.profiledata),void 0!==t.playerId&&(this.playerId=t.playerId),void 0!==t.access_token&&this.setAccessToken(t.access_token),void 0!==t.color&&(this.color=t.color),void 0!==t.colorName&&(this.colorName=t.colorName),void 0!==t.nickname&&(this.nickname=t.nickname),void 0!==t.email&&(this.email=t.email),void 0!==t.smiley&&(this.smiley=t.smiley),void 0!==t.data&&this.dataSynchronizer.unserialize(t.data),void 0!==t.events&&this.events.unserialize(t.events)},h}),define("CatLab/Webremote/Models/GroupControl",[],function(){return function(t,i,e){var n,s,o,r,a,h,l=t,c={};this.label=null,this.decoration="",this.group=i,this.isGlobal=e,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(t){return o=i.getUsers(),(n=0)<o.length?(a=o[n].control(l,this.isGlobal)).getLabel(t):null},this.setStaticLabel=function(t,e){for(o=i.getUsers(),n=0;n<o.length;n++)o[n].control(l).setStaticLabel(t,e);return null},this.setLabel=function(t,e){return this.label=t,i.emit("button:label",{id:l,label:t}),this},this.decorate=function(t){return this.decoration=t,i.emit("button:decorate",{id:l,styles:t}),this},this.click=function(t){return this.on("click",t),this},this.on=function(t,e){for(void 0===c[t]&&(c[t]=[]),c[t].push(e),this.log("Setting group trigger "+t),o=i.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).on(t,e);return this},this.hasTriggers=function(t){for(o=i.getUsers(),n=0;n<o.length;n++)if(o[n].control(l,this.isGlobal).hasTriggers(t))return!0;return!1},this.off=function(t){for(delete c[t],o=i.getUsers(),n=0;n<o.length;n++)o[n].control(l,this.isGlobal).off(t);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(t){this.decoration&&t.emit("button:decorate",{id:l,styles:this.decoration}),this.label&&t.emit("button:label",{id:l,label:this.label})},this.log=function(t){i.log("["+l+"] "+t)}}}),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(t,e,i,n,s,o,r,a,h,l){function c(t,e){this.initializeEventable(),this.id=t,this.initialize(e)}r=c.prototype=new r;return r.setWebcontrol=function(t){this.Webcontrol=t},r.initialize=function(t){this.token=t.token,this.connectURL=t.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=t,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(t){return this.options=t,this},r.getOption=function(t){return void 0!==this.options[t]?this.options[t]:null},r.hasControl=function(t){return!0},r.setAccessToken=function(t){this.access_token=t},r.setProfiledata=function(t){this.profiledata=t},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(t,e,i){return this.Webcontrol.provider.toGroup(this,t,e,i),!0},r.getId=function(){return this.id},r.getName=function(){return"Group "+this.getId()},r.setNickname=function(t){return this.nickname=t,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(t,e,i){void 0===i&&(i=this.shareColor),this.colorSet=!0,this.color=t,this.colorName=e,this.shareColor=i,this.emit("color:set",{color:t,name:e,shareColor:i})},r.getColor=function(){return this.color},r.setShareColor=function(t){this.shareColor=t},r.isShareColor=function(){return this.shareColor},r.getColorName=function(){return this.colorName},r.setView=function(t){return this.clearView(),this.currentView=o.create(t,[this],this.Webcontrol,this.getId()),this.currentView},r.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(),this.users.forEach(function(t){t.clearView(e)}))},r.resetViews=function(t){this.emit("view:reset",{},t=void 0===t?function(){}:t)},r.replaceViews=function(t,e){this.resetViews(function(){this.loadViews(t,e)}.bind(this))},r.loadViews=function(t,e){void 0===e&&(e=function(){}),this.log("Loading views for group "+t),this.emit("view:load",{url:t},e)},r.isAuthenticated=function(){return!1},r.isLocalAuthentication=function(){return!0},r.log=function(t){this.Webcontrol.log("[g:"+this.getId()+"] "+t)},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(e){for(this.tmpid in l.findIndex(this.users,function(t){return t.id===e.id})<0&&this.users.push(e),l.findIndex(e.groups,function(t){return t.id===this.id})<0&&e.groups.push(this),this.currentView&&(this.currentView.refreshTarget(e),e.currentView=this.currentView),this.controls)this.controls.hasOwnProperty(this.tmpid)&&this.controls[this.tmpid].refreshControl();this.events.refreshTarget(e.emit.bind(e)),this.dataSynchronizer.refreshTarget(e.emit.bind(e)),this.smiley&&(e.emit("user:smiley",{smiley:this.smiley}),e.smiley=this.smiley),this.trigger("user:join",e)},r.removeUser=function(e){var t=l.findIndex(this.users,function(t){return t.id===e.id});0<=t&&this.users.splice(t,1)},r.getUsers=function(){return this.users},r.getIdentifier=function(){return{id:this.getId(),type:this.getEntityType()}},r.represents=function(t){if(void 0===t.id||void 0===t.type)throw"Attribute is not an identifier.";var e=this.getIdentifier();return e.type==t.type&&e.id==t.id},r.getValues=function(){return this.currentView?this.currentView.getValues():null},r.clearValues=function(){this.currentView&&this.currentView.clearValues()},r.control=function(t,e){return void 0===e&&(e=!1),void 0===this.controls[t]&&(this.controls[t]=new n(t,this,e)),this.controls[t]},r.isMaster=function(){return this.master},r.setMaster=function(t){return this.master=t=void 0===t?!0:t,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(t){this.emit("oauth:set",t)},r.setSmiley=function(t,e){this.Webcontrol.smileys.reserve(t,this.getIdentifier())?(this.emit("user:smiley",{smiley:t}),this.smiley=t):e.emit("dom:alert",{message:s.t("Smiley is already taken. Please select a different smiley.")})},r.clearSmiley=function(t){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(t){this.emit("config:set",{maxUsers:t})},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(t,e){this.active=t,this.eventableTrigger("active:change",t),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(t){void 0!==t.profiledata&&this.setProfiledata(t.profiledata),void 0!==t.access_token&&this.setAccessToken(t.access_token),void 0!==t.token&&(this.token=t.token),void 0!==t.shareColor&&(this.shareColor=t.shareColor),void 0!==t.color&&(this.color=t.color),void 0!==t.colorName&&(this.colorName=t.colorName),void 0!==t.nickname&&(this.nickname=t.nickname),void 0!==t.email&&(this.email=t.email),void 0!==t.smiley&&(this.smiley=t.smiley,this.emit("user:smiley",{smiley:this.smiley})),void 0!==t.data&&this.dataSynchronizer.unserialize(t.data),void 0!==t.events&&this.events.unserialize(t.events)},c}),define("CatLab/Webremote/Models/State",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Preloader"],function(i,n){function t(t){this.Webcontrol=t}var e=t.prototype;return e.reconnect=function(t,e){void 0!==t.provider&&this.Webcontrol.provider.restoreProviderSettings(t.provider),this.Webcontrol.disconnect(),setTimeout(function(){this.Webcontrol.initialize(i.getAll()).then(function(){this.Webcontrol._reconnect(t.token,t.accessToken,function(){this._setCollectionDetails(t.groups,this.Webcontrol._grouplibrary),this._setCollectionDetails(t.users,this.Webcontrol._userlibrary),this.Webcontrol.preloader=n.unserialize(this.Webcontrol.provider,t.preloader),e()}.bind(this))}.bind(this))}.bind(this),1)},e._setCollectionDetails=function(t,e){var i,n;if(void 0!==t)for(i=0;i<t.length;i++)(n=e.getFromId(t[i].id))?n.unserialize(t[i]):(console.log("Trying to set data for non existing user/group."),console.log(t[i]))},e.getData=function(){var e=[],i=(this.Webcontrol._grouplibrary.each(function(t){e.push(t.serialize())}.bind(this)),[]),t=(this.Webcontrol._userlibrary.each(function(t){i.push(t.serialize())}),{users:i,groups:e,token:this.Webcontrol._gamedata.token,accessToken:this.Webcontrol._gamedata.accessToken,preloader:this.Webcontrol.preloader.serialize()});return t.provider=this.Webcontrol.provider.serializeProviderSettings(),t},e.serialize=function(){var t=this.getData();return JSON.stringify(t)},e.unserialize=function(t){t=JSON.parse(t);this.reconnect(t)},t}),define("CatLab/Webremote/Controllers/Portal",["CatLab/Webremote/Config","CatLab/Webremote/Tools/Eventable","CatLab/Webremote/Tools/Translator","CatLab/Webremote/Tools/Tools","CatLab/Webremote/Tools/Deferred"],function(s,t,i,e,o){"use strict";function n(t,e,i){this.initializeEventable(),this.Webcontrol=e,this.options=i,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.")});var n={controller:this,assets:e.assets,showInactivePlayers:this.supportInactivePlayers()};void 0!==i.element&&(n.element=i.element),this.view=t.portal(n),this.view.loading(),this.useCatLabViews()&&e.loadViews(s.getSocketURL(!0)+"/webremote/views/default.xml"),this.container=t.getContainer(),this.container.easelboneLayer.setView(this.view),this.view.render(),this.eventListeners=[],this.initialize()}t=n.prototype=new t;return t.initialize=function(){var t=this.Webcontrol.on("user:join",function(t){this.userConnect(t),this.eventListeners.push(t.on("login",function(){this.trigger("users:update")}.bind(this)))}.bind(this));this.eventListeners.push(t),this.Webcontrol.getUsers().forEach(function(t){this.userConnect(t)}.bind(this))},t.ensureOption=function(t,e){void 0===this.options[t]&&(this.options[t]=e)},t.useCatLabViews=function(){return!1===this.options.customViews},t.getToggleView=function(t){var e="",e=this.supportInactivePlayers()?"catlab-portal-toggle":"catlab-portal";return this.isMaster(t)||(e+="-nostart"),e},t.addUser=function(t){t.clearEvents(),this.users.push(t),this.supportInactivePlayers()||this.forceToggleableUser(t)||this.activateUser(t),this.trigger("users:update")},t.activateUser=function(t){this.trigger("user:activate",t),t.setActive(!0,this.supportInactivePlayers())},t.deactivateUser=function(t){this.trigger("user:deactivate",t),t.setActive(!1,this.supportInactivePlayers())},t.toggleActive=function(t){(this.supportInactivePlayers()||this.forceToggleableUser(t))&&(t.isActive()?this.deactivateUser(t):this.activateUser(t),this.trigger("users:update"))},t.forceToggleableUser=function(t){return!t.hasDisplay()},t.hasUsersWithoutDisplay=function(){for(var t=0;t<this.users.length;t++)if(!this.users[t].hasDisplay())return!0;return!1},t.countActiveUsers=function(){return this.getActiveUsers().length},t.getActiveUsers=function(){for(var t=[],e=0;e<this.users.length;e++)this.users[e].isActive()&&t.push(this.users[e]);return t},t.userConnect=function(t){this.eventListeners.push(t.on("master:change",function(){this.updateUserView(t)},this)),this.addUser(t),this.updateUserView(t),this.trigger("user:connect",t)},t.updateUserView=function(t){var e=t.setView(this.getToggleView(t));this.controlDisabled||this.enableControls(t,e),this.enableDefaultPlayerControls(t,e)},t.disableControls=function(){this.controlDisabled=!0;for(var t=0;t<this.users.length;t++)this.users[t].clearEvents()},t.enableControls=function(t,e){var i;void 0!==t?(i=t.getPortalControls(),e.control(i.toggleActive).click(function(){this.toggleActive(t)}.bind(this)),e.control(i.start).click(function(){this.startGame()}.bind(this)),e.control(i.back).click(function(){this.back()}.bind(this)),this.supportsLocalAuthentication()&&e.control(i.authenticate).click(function(){t.isLocalAuthentication()||this.authenticate(t)}.bind(this)),this.view.setWebremoteControlsInView(e)):(this.controlDisabled=!1,this.users.forEach(function(t){this.updateUserView(t)}.bind(this)))},t.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 t in this.options.customFunctions)this.options.customFunctions.hasOwnProperty(t)&&function(t,e){n.control(t).click(function(){e(i).then(function(){this.updateUserView(i)}.bind(this))}.bind(this))}.bind(this)(t,this.options.customFunctions[t])},t.changeNickname=function(e){var i=new o,n=e.setView("catlab-nickname");return n.changeValue("name",e.getNickname()),n.control("a").click(function(){var t=n.getValues().name;!t||32<t.length||(e.setNickname(t),i.resolve())}),i.promise()},t.supportInactivePlayers=function(){return this.options.activePlayersPanel},t.supportsLocalAuthentication=function(){return this.options.localAuthenticable&&this.Webcontrol.canAuthenticate()},t.isMaster=function(t){return t.isMaster()},t.getPortalLabels=function(){var s={start:[],back:[],toggleActive:[],authenticate:[]};return this.Webcontrol._userlibrary.each(function(t){var e,i=t.getPortalControls();for(e in i)if(i.hasOwnProperty(e)){var n=t.control(i[e]).getLabel(!1);if(!n)continue;n="["+n.toUpperCase()+"]",void 0===s[e]&&(s[e]=[]),-1===s[e].indexOf(n)&&s[e].push(n)}}.bind(this)),s},t.authenticate=function(t){var e=this,t=(this.disableControls(),this.Webcontrol.authentication(t).view);this.view.addAuthenticationView(t),t.on("view:close",function(){e.enableControls(),e.trigger("users:update")})},t.countAuthenticated=function(t){void 0===t&&(t=!0);for(var e=0,i=0;i<this.users.length;i++)!this.users[i].isAuthenticated()||t&&!this.users[i].isActive()||e++;return e},t.checkAuthentication=function(){var t=this.countAuthenticated();switch(this.options.authentication){case this.Webcontrol.AUTH_REQUIRED_ALL:return t===this.countActiveUsers();case this.Webcontrol.AUTH_REQUIRED_ONE:return 0<t;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."}},t.startGame=function(){var t=this.countActiveUsers();if(t<this.options.minPlayers)this.view.alert("You need "+this.options.minPlayers+" players to start playing");else if(t>this.options.maxPlayers)this.view.alert("Your license is limited to "+this.options.maxPlayers+" players");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.view.alert("All active players must be authenticated.");break;case this.Webcontrol.AUTH_REQUIRED_ONE:case this.Webcontrol.AUTH_REQUIRED_ONE_INACTIVE:this.view.alert("At least one player must be authenticated.")}},t.back=function(){void 0!==this.options.back&&(this.destroy(),this.options.back())},t.getConnectURL=function(){return this.Webcontrol.getConnectURL()},t.getConnectToken=function(){return this.Webcontrol.getConnectTokenForDisplay()},t.getUsers=function(){return this.users},t.setMinPlayers=function(t){return this.options.minPlayers=t,this.trigger("options:change"),this},t.setMaxPlayers=function(t){return this.options.maxPlayers=t,this.trigger("options:change"),this},t.getContainer=function(){return this.container},t.getConnectInstructions=function(){return void 0!==this.Webcontrol.provider.getConnectInstructions?i.t.apply(this,this.Webcontrol.provider.getConnectInstructions()):i.t("Use your tablet or smartphone to surf to %s and enter code %s.",this.getConnectURL(),this.getConnectToken())},t.getStartAndLoginInstructions=function(){var t;return void 0!==this.Webcontrol.provider.getStartAndLoginInstructions?i.t.apply(this,this.Webcontrol.provider.getStartAndLoginInstructions()):(t=this.getPortalLabels(),this.supportsLocalAuthentication()&&(this.showInactivePlayers||this.hasUsersWithoutDisplay())?i.t("Press %s to join, %s to login and %s to start.",e(t.toggleActive),e(t.authenticate),e(t.start)):this.supportsLocalAuthentication()?i.t("Press %s to login and %s to start.",e(t.authenticate),e(t.start)):this.showInactivePlayers||this.hasUsersWithoutDisplay()?i.t("Press %s to join and %s to start.",e(t.toggleActive),e(t.start)):i.t("Press %s to start.",e(t.start)));function e(t){return t.join(" "+i.t("or")+" ")}},t.destroy=function(){this.eventListeners&&this.eventListeners.forEach(function(t){t.unbind()})},n}),define("CatLab/Webremote/Controllers/RemoteAuthentication",["CatLab/Webremote/Controllers/OAuth2"],function(e){return function(t){t.setView("remote:authenticate"),t.on("user:join",function(t){t.on("login",function(t){e.addAccessToken(t.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"],function(s,n,o,t,r,i){function e(t,e,i,n){this.initializeEventable(),this.view=t.authentication({controller:this,assets:e.assets}),this.Webcontrol=e,this.user=i,o.on("update",this.updateUsers,this),s.on("update",function(){this.view.updateUsers()},this),this.getLoginUrl().then(function(t){this.loginUrl=t,this.view.setLoginUrl(t)}.bind(this)),this.container=t.getContainer(),this.container.easelboneLayer.setView(this.view),this.view.render()}var a=null,h=null,t=e.prototype=new t;return t.link=function(){s.link(function(t){this.selectUser(t)}.bind(this))},t.updateUsers=function(){this.trigger("users:update")},t.selectUser=function(t){var e=this;this.user.loginFromAuthUser(t,function(){i.setCookie("ctlb_ps_"+this.user.id,t.id),e.close()}.bind(this))},t.getUsers=function(){return o},t.close=function(){this.view.close()},t.getLoginUrl=function(){var e,t,i=new r;return e=this.Webcontrol,(null!==a?((t=new r).resolve(a),t):(null===h&&(h=new r,e.newGroup().then(function(t){new n(a=t),t.setOAuthSettings(e.getOAuthSettings()),h.resolve(t)})),h)).promise().then(function(t){i.resolve(t.getConnectURL()+"/"+t.getConnectToken())}),i.promise()},t.getContainer=function(){return this.container},t.attemptLastLogin=function(){var t=i.getCookie("ctlb_ps_"+this.user.id);if(t){t=o.getFromId(t);if(t)return this.selectUser(t),!0}return!1},e}),define("CatLab/Webremote/Tools/MessageCounter",["CatLab/Webremote/Tools/Eventable"],function(t){"use strict";function e(t){this.interval=t||1e3,this.initializeEventable(),this.countIncoming=0,this.countOutgoing=0;var e,i,n=(new Date).getTime();setInterval(function(){e=(new Date).getTime(),i=e-n,n=e,this.trigger("tick",{in:this.countIncoming,out:this.countOutgoing,dt:i}),this.countIncoming=0,this.countOutgoing=0}.bind(this),this.interval)}t=e.prototype=new t;return t.incoming=function(){this.countIncoming++},t.outgoing=function(){this.countOutgoing++},e}),define("CatLab/Webremote/Views/Portal",["CatLab/Webremote/Config"],function(F,t){return function(t){var s=t.element||document.body,e=s,i=t.countdown||5e3,n=t.done||function(){alert("Game should start now... yet it doesn't.")},o=t["min-players"]||1,r=(o<1&&(o=1),t["max-players"]||1e3);r<o&&(r=o);var a,h,l,c,u,d,p,f,g,m,v,b=!t.customViews,A=[],y=!1,w=!1,C=null,k=this;function T(s){s.setView("catlab-portal-toggle"),s.control("join-game").click(function(){!function(t){if(P(t)){t.control("join-game").setLabel("JOIN");for(var e=t,i=0;i<A.length;i++)if(A[i].getId()==e.getId())return A.splice(i,1)}else t.control("join-game").setLabel("LEAVE"),A.push(t)}(s),M(),x(),U()}),s.control("start-game").click(function(){var t;y?U():A.length<o?D(o+" players are required to start the game. Please gather more friends."):A.length>r?D("This game can have only "+r+" players."):(t=i,U(),y=!0,(p=new Date).setTime((new Date).getTime()+t),u.show(),d=setInterval(V,100))}),s.control("down").click(function(){_(s)}),s.control("right").click(function(){_(s)}),s.control("left").click(function(){S(s)}),s.control("up").click(function(){S(s)}),s.control("a").click(function(){var t,i,e,n;t=s,w&&I(t)?(n=v.find(".available-accounts").find("li.selected"))&&(n=WebcontrolOAuthClient.getFromToken(n.attr("data-accessToken")))&&(e=n.access_token,n=n.user,C.setUserData(e,n),L()):(y&&U(),w||(i=t,Webcontrol.getOAuthClient(function(e){e.onInit(function(){E(e)}),WebcontrolAccessKeyLibrary.init(function(){w=!0,C=i,m.show(),v.show();var t=$('<a href="javascript:void(0);">Link new account</a>');t.click(function(){e.getNewAccessToken(function(){E(e)})}),v.find(".link-new-account").html(t)}),E(e)})))}),s.control("b").click(function(){w&&I(s)&&(C.setUserData(!1),L())}),W(),x()}function S(t){w&&I(t)&&(t=v.find(".available-accounts").find("li.selected"),v.find(".available-accounts").find("li").removeClass("selected").addClass("unselected"),(t.length&&t.prev().length?t.prev():v.find(".available-accounts").find("li").last()).addClass("selected").removeClass("unselected"))}function _(t){w&&I(t)&&(t=v.find(".available-accounts").find("li.selected"),v.find(".available-accounts").find("li").removeClass("selected").addClass("unselected"),(t.length&&t.next().length?t.next():v.find(".available-accounts").find("li").first()).addClass("selected").removeClass("unselected"))}function I(t){return C&&t.getId()==C.getId()}function L(){m.hide(),v.hide(),w=!1,C=null}function E(t){v.find(".available-accounts").html("");for(var e=t.listUsers(),i=0;i<e.length;i++){var n=$("<li>"+e[i].user.username+"</li>");n.addClass("unselected"),n.attr("data-accessToken",e[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(t){for(var e=0;e<A.length;e++)if(A[e].getId()==t.getId())return 1}function W(){var t=Webcontrol.getUsers();a.html("");for(var e=[],i=0;i<t.length;i++)P(t[i])||e.push(t[i]);for(0==e.length&&a.append('<li class="empty"><span>More players? Add devices!</span></li>'),i=0;i<e.length;i++)a.append('<li class="user '+e[i].getType()+'" style="background-color: '+e[i].getColor()+'"><i class="'+e[i].getIcon()+'"></i><span>'+e[i].getName()+"</span></li>")}function M(){h.html(""),0==A.length&&h.append('<li class="empty"><span class="buttoninstructions join-game">Press <span class="labels"></span> to join the game.</span></li>');for(var t=0;t<A.length;t++)h.append('<li class="user '+A[t].getType()+'" style="background-color: '+A[t].getColor()+'"><i class="'+A[t].getIcon()+'"></i><span>'+A[t].getName()+"</span></li>");W()}function V(){f=Math.ceil((p.getTime()-(new Date).getTime())/1e3),u.find(".counter").html(f),f<0&&(void 0!==e&&(void 0!==e.hide?e.hide():void 0!==e.style&&(e.style.display="none")),U(),n(A))}function U(){y=!1,d&&(D("Countdown stopped!"),u.hide(),clearInterval(d),d=null)}function D(t){var e=jQuery("<p></p>").html(t).appendTo(g);setTimeout(function(){e.fadeOut(1e3,function(){e.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!==t.theme&&(t=F.getSocketURL()+"/webremote/themes/"+t.theme+"/"+t.theme+".css",Webcontrol._loadCSS(t),Webcontrol._loadCSS(F.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 t=s,t=(s=jQuery('<div class="webremote-portal-inner"></div>').appendTo(t),(s=jQuery(s)).html('<div class="loading"><p>Please wait, connecting to server.</p></div>'),b&&Webcontrol.loadViews(F.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>')),e=(a=jQuery('<ul class="connected-users"></ul>').appendTo(t.find(".inner")),jQuery('<div class="active-users"><div class="inner"><h2>Active users</h2></div></div>'));h=jQuery('<ul class="active-users"></ul>').appendTo(e.find(".inner")),s.append(t),s.append(e),(t=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()),t.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),t.append(l),t.append(c),s.append(t),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(t){T(t)});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(e){"use strict";function t(){}return t.prototype.getPortal=function(t){return new e(t)},t}),define("CatLab/Webremote/Models/Users/GamepadUser",["CatLab/Webremote/Models/Users/ControlUser"],function(t){function e(t){t=t.id||"1",this.initialize({id:"gamepad_"+t}),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"}},t=e.prototype=new t;return t.getType=function(){return"gamepad"},t.getIcon=function(){return"fa fa-gamepad"},t.emit=function(){return!1},t.isLocalAuthentication=function(){return!1},t.controlFromKey=function(t){return this.control(i[t].id)},t.hasDisplay=function(){return!1},t.hasKeyboardInput=function(){return!1},t.hasTouchInput=function(){return!1},e}),define("CatLab/Webremote/Gamepads/GamepadAPI",["CatLab/Webremote/Models/Users/GamepadUser"],function(i){function t(){this.gamepads={},this.initialized=!1,this.Webcontrol=null}var n,e,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=t.prototype;return o.initialize=function(t){var e;this.Webcontrol=t,this.initialized||(this.initialized=!0,t=function(){var t=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads||[];for(n=0;n<t.length;n++)if(t[n]){for(n=0;n<t.length;n++)t[n]&&this.onConnect(t[n]);this.startGamepadPolling(),clearInterval(e)}}.bind(this),"undefined"!=typeof window&&("ongamepadconnected"in window?(window.addEventListener("gamepadconnected",function(t){this.onConnect(t.gamepad)}.bind(this)),window.addEventListener("gamepaddisconnected",function(t){this.onDisconnect(t.gamepad)}.bind(this))):e=setInterval(t,1e3)))},o.startGamepadPolling=function(){setInterval(this.poll.bind(this),50)},o.poll=function(){var t=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads||[];for(n=0;n<t.length;n++)if(t[n])for(e=0;e<t[n].buttons.length;e++)this.gamepads[t[n].index].user&&void 0!==s[e]&&this.gamepads[t[n].index].user.controlFromKey(s[e]).update(t[n].buttons[e].pressed?1:0)},o.onConnect=function(t){var e=new i({id:t.id});this.gamepads[t.index]={user:e},this.Webcontrol.addCustomControl(e),this.startGamepadPolling()},o.onDisconnect=function(t){},new t}),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"],function(a,t,e,i,n,s,h,o,r,l,c,u,d,p,f,g,m,v,b,A,y,w,C,k,T,S){"use strict";function _(){this.initializeEventable(),this.provider=null,this._events={},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._viewCounter=null,this._lastView=null,this._options={},this._groupCallbacks={id:1},this._viewFactory=null,this.state=null,this.connected=!1,this._userlibrary=new t,this._grouplibrary=new e}g=_.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(t){function e(){s.resolve(),n()}var i,n=function(){},s=(void 0!==(t=void 0===(t="function"==typeof t?{callback:t}:t)?{}:t).callback&&(n=t.callback),new u);return this._initialized?e():(this.sonicSyncClient=null,delete t.callback,t.headless,(i=!!t.headless)||void 0===t.assets||this.setAssets(t.assets),a.set(t),a.initialize(function(){null===this.provider&&(void 0===t.provider&&(t.provider=new k),this.provider=t.provider),this.smileys=new f(this.provider),void 0!==t.translator&&d.setTranslator(t.translator),this._initialize(i,e)}.bind(this))),s.promise()},disconnect:function(){this._initialized=!1,this.provider.disconnect()},_initialize:function(s,t){var o,r=new u;return(t&&r.then(t),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(t){this.provider.connect("control",t).then(function(){this.connected=!0,this.provider.on("disconnect",function(){var t=this.getConnectionIssuesView();t.show(),t.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(t){this.log("Initializing"),this._gamedata=t,this.log("Game initialize; URL "+this.getConnectURL()+", token "+this.getConnectToken()),r.resolve(this.connected)}.bind(this)),this.provider.on("master:error",function(t){alert(t.message)}.bind(this)),this.provider.on("user:join",function(t){this._playerJoin(t)}.bind(this)),this.provider.on("user:reconnect",function(t){this._playerReconnect(t)}.bind(this)),this.provider.on("user:leave",function(t){this._playerLeave(t)}.bind(this)),this.provider.on("view:labels",function(t){this._setViewLabels(t)}.bind(this)),this.provider.on("group:create",function(t){this._onNewGroup(t)}.bind(this)),this.provider.on("user:smiley",function(t){this._playerTrigger("user:smiley",t),this._userlibrary.each(function(t){this.smileys.refreshTakenSmileys(t)}.bind(this))}.bind(this)),this.provider.on("smileys:slingshot",function(t){var e=this._userlibrary.getFromId(t.user);e?(e.trigger("smileys:slingshot",t),t.user=e,this.trigger("smileys:slingshot",t)):console.log("User not found: "+t.user)}.bind(this));for(var t=(t=(t=["user:login","user:logout","button:down","button:up","sync:audio"]).concat(A.eventsToListenFor)).concat(y.eventsToListenFor),e=0;e<t.length;e++)!function(e){o.provider.on(e,function(t){o._playerTrigger(e,t)})}(t[e]);var i=["value:change"];for(var n=0;n<i.length;n++)!function(e){o.provider.on(e,function(t){o._viewTrigger(e,t)})}(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(t){var e;"string"==typeof t?(e=document.getElementById(t),this.log=this.getDomLogger(e)):this.log=t},getProviderSettings:function(){return this.provider.getProviderSettings()},setMessageCounter:function(t){t=new m(t);return this.provider.setMessageCounter(t),t},setName:function(t){this.provider.toMaster("master:name",{name:t})},setMaxUsers:function(t){this.provider.toMaster("config:set",{maxUsers:t})},setViewFactory:function(t){return this._viewFactory=t,this._viewFactory.initialize()},getViewFactory:function(){return"undefined"===this._viewFactory&&(this._viewFactory=new w),this._viewFactory},getDomLogger:function(e){return function(t){e.innerHTML=t+"\n"+e.innerHTML}},oAuth:function(t,e){void 0===e&&(e=!1),this._authentication=!0,this._oauthsettings=t,this.provider&&!e&&this.provider.setOAuthSettings(this._oauthsettings),o.initialize(t),i.initialize(this,o)},getOAuthClient:function(t){this._oauthsettings?(null===this._oauthClient&&(this._oauthClient=o,this._oauthClient.initialize(this._oauthsettings)),t(this._oauthClient)):t(null)},getOAuthSettings:function(){return this._oauthsettings},clearEvents:function(t){if(void 0===t&&(t=!1),this._events={},t)for(var e=this._userlibrary.getAll(),i=0;i<e.length;i++)e[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(t,e){this.provider.loadViews(t,e)},getUsers:function(){return this._userlibrary.getAll()},portal:function(t){var e,i;if(this._initialized)return i=this.getViewFactory(),e=new u,i=new r(i,this,t),e.resolve(i),{view:i.getContainer(),promise:e};throw new Error("Please initialize Webcontrol first.")},authentication:function(t,e){var i,n;if(this._initialized)return n=this.getViewFactory(),i=new u,n=new l(n,this,t,e),i.resolve(n),{view:n.getContainer(),promise:i.promise()};throw new Error("Please initialize Webcontrol first.")},getConnectionIssuesView:function(){return void 0===this.connectionTrouble&&(this.connectionTrouble=new C),this.connectionTrouble},setView:function(t,e){var i;return void 0===e?(i=b.create(t,[this],this),this._lastView=i):i=b.create(t,e,this),i},beacon:function(t,e){this.provider.toMaster("master:beacon",{beacon:t,token:e})},emit:function(t,e){this.provider.toPlayers(t,e)},getControlLabels:function(t,e){for(var i=[],n={},s=this.getUsers(),o=0;o<s.length;o++){var r=s[o].control(t).getLabel(e);void 0===n[r]&&i.push(n[r]=r)}return i},addCustomControl:function(t){this.log("adding "+t.getType()),t.setWebcontrol(this),this._userlibrary.add(t),this._initializeSmiley(t,{}),this.trigger("user:join",t)},enableGamepads:function(){T.initialize(this)},newGroup:function(t){var e=new u,i={},n=(void 0===t?t={}:"function"==typeof t&&(t={callback:t}),void 0===t.callback&&(t.callback=function(){}),!0),s=(void 0!==t.globalViews&&(n=t.globalViews),!0),o=(void 0!==t.shareColor&&(s=t.shareColor),[]),r=(void 0!==t.tags&&(o=t.tags),!0),r=(void 0!==t.smiley&&(r=!!t.smiley),i.smiley=r,this._groupCallbacks.id);return this._groupCallbacks.id++,this._groupCallbacks[r]={id:r,callback:t.callback,deferred:e,options:i},this.provider.createGroup(r,n,s,o),e.promise()},preload:function(t){return this.preloader.preload(t)},getPreloadedUrl:function(t){return this.preloader.getPreloadedUrl(t)},_reset:function(){this._userlibrary.clear(),this._grouplibrary.clear()},reset:function(){var t=new u;return this._initialized=!1,this.provider.reset(function(){t.resolve()}.bind(this)),t.promise()},_playerJoin:function(t){var e;this._userlibrary.getFromId(t.id)||((e=new n(t.id,t)).setWebcontrol(this),void 0!==t.color&&e.setColor(t.color.color,t.color.name),this._grouplibrary.addUser(e)||(this._lastView&&this._lastView.addTarget(e),this._initializeSmiley(e,t)),this._userlibrary.add(e),this.log(e),e&&this.trigger("user:join",e))},_playerReconnect:function(t){var e=this._userlibrary.getFromId(t.id);e?(e.getSmiley()&&e.emit("user:smiley",{smiley:e.getSmiley()}),this._grouplibrary.addUser(e)||this._lastView&&this._lastView.addTarget(e),e.refreshView(),this.trigger("user:rejoin",e),e.eventableTrigger("rejoined"),this.smileys.refreshTakenSmileys(e)):this._playerJoin(t)},_playerLeave:function(t){t=this._userlibrary.getFromId(t.id);t&&(this.trigger("user:leave",t),t.eventableTrigger("left"))},_onNewGroup:function(t){var e,i=new s(t.id,t),n=(i.setWebcontrol(this),!1);void 0!==t.shareColor&&(n=t.shareColor),void 0!==t.color?i.setColor(t.color.color,t.color.name):i.setShareColor(n),this._grouplibrary.getFromId(t.id)||(n=function(){},void 0!==(e=t.externalId)&&void 0!==this._groupCallbacks[e]&&(i.setOptions(this._groupCallbacks[e].options),n=function(){this._groupCallbacks[e].callback(i),this._groupCallbacks[e].deferred.resolve(i)}.bind(this)),this._grouplibrary.add(i),i.getOption("smiley")&&this._initializeSmiley(i,t),this.trigger("group:create",i),this.log("New group "+i.getId()+"; URL "+i.getConnectURL()+", token "+i.getConnectToken()),n())},_initializeSmiley:function(t,e){var i;a.useSmileys()?void 0===e.smiley?null!==(i=this.smileys.getRandom(t.getIdentifier()))&&t.setSmiley(i):t.setSmiley(e.smiley):t.clearSmiley(),this.smileys.refreshTakenSmileys(t)},_playerTrigger:function(t,e){var i=this._userlibrary.getFromId(e.user);i?i.trigger(t,e):console.log("User not found: "+e.user)},_viewTrigger:function(t,e){var i=b.getFromId(e.viewId);i&&i.trigger(t,e)},_loadCSS:function(t){for(var e=0;e<this._cssloads.length;e++)if(this._cssloads[e]==t)return;this._cssloads.push(t);var i=document.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("type","text/css"),i.setAttribute("href",t),document.body.appendChild(i)},_setViewLabels:function(t){this._labeldata[t.id]=t.labels;for(var e=this.getUsers(),i=0;i<e.length;i++)for(var n=0;n<t.labels.length;n++)e[i].control(t.id).setStaticLabel(t.labels[n].label,"mobile")},getViewLabels:function(t){return void 0!==this._labeldata[t]?this._labeldata[t]:[]},getFromIdentifier:function(t){switch(t.type){case"user":return this._userlibrary.getFromId(t.id);case"group":return this._grouplibrary.getFromId(t.id)}return null},log:function(t){a.debug()&&(console.log(a),console.log(t))},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()},recover:function(t){var e=this.state.getData();this._reconnect(e.token,e.accessToken,t)},_reconnect:function(t,e,i){this.provider.reconnect(t,e,a.getProviderConfig(),i)},getIceCredentials:function(){var e=new u;return this.provider.toMaster("webrct:stun+turn",{},function(t){void 0===t.error?e.resolve(t):e.fail(t.error)}),e.promise()}}),_}),define("CatLab/Webremote/Models/Users/KeyboardUser",["CatLab/Webremote/Models/Users/ControlUser"],function(t){"use strict";function e(t,e){var i="keyboard"+ ++n;this.initializeKeyboardUser({id:i,keys:t}),this.exitOnUnassignedBackButton=e}var n=0,t=((e.prototype=Object.create(t.prototype)).constructor=e).prototype;return t.initializeKeyboardUser=function(t){this.initialize({id:t.id}),void 0===t.keys&&(t.keys=this.getDefaultKeys()),this.keys=t.keys,this.attachKeyboardEvents(),document&&document.addEventListener("fullscreenchange",this.attachKeyboardEvents.bind(this)),this.clearControls=function(){for(var t,e=0;e<this.keys.length;e++)this.control(this.keys[e].id).setStaticLabel(this.keys[e].label,"keyboard");for(t in this.controls)!this.controls.hasOwnProperty(t)||this.controls[t].isGlobal||this.controls[t].clear()},this.on("view:set",function(t){this.clearControls()}.bind(this)),this.getType=function(){return"keyboard"},this.getIcon=function(){return"fa fa-keyboard-o"},this.emit=function(t,e){return!1},this.isLocalAuthentication=function(){return!1},this.clearControls()},t.getAvailableControls=function(){for(var t=[],e=0;e<this.keys.length;e++)t.push(this.keys[e].id);return t},t.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"]}]},t.hasControl=function(t){return-1!==this.getAvailableControls().indexOf(t)},t.hasDisplay=function(){return!1},t.hasKeyboardInput=function(){return!0},t.hasTouchInput=function(){return!0},t.stopListening=function(){try{var t=null;try{t=window.document}catch(t){}t&&(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 e=null;try{e=window.parent.document}catch(t){}e&&(e.removeEventListener("keyup",this._keydownListener),e.removeEventListener("keydown",this._keydownListener))}catch(t){console.log(t)}},t.resumeListening=function(){this.attachKeyboardEvents()},t.attachKeyboardEvents=function(){this.stopListening();try{var t=window.document;if(!document.fullscreenElement&&window.parent&&!(t=window.parent.document))throw new Error("Unaccessible");this._keydownListener=this._keyDown.bind(this),this._keyupListener=this._keyUp.bind(this),t.addEventListener("keydown",this._keydownListener),t.addEventListener("keyup",this._keyupListener)}catch(t){try{this.messageListener=this._onMessage.bind(this),window.addEventListener("message",this.messageListener,!1)}catch(t){console.error(t)}}},t.getConfigFromKey=function(t){for(var e=0;e<this.keys.length;e++){if(void 0!==this.keys[e].code&&this._keyMatches(this.keys[e].code,t.code))return this.keys[e];if(void 0!==this.keys[e].key&&this._keyMatches(this.keys[e].key,t.key))return this.keys[e];if(void 0!==this.keys[e].keyCode&&this._keyMatches(this.keys[e].keyCode,t.keyCode))return this.keys[e]}return null},t._keyMatches=function(t,e){return!!(Array.isArray(t)&&-1<t.indexOf(e))||t==e},t._onMessage=function(t){var e=t.data;if("object"==typeof e&&void 0!==e.type&&"catlab:keyboard"===e.type&&void 0!==e.code&&void 0!==e.action)switch(e.action){case"down":return void this._keyDown(t.data);case"up":return void this._keyUp(t.data)}},t._keyDown=function(t){var e;"Escape"!==t.key||!this.exitOnUnassignedBackButton||this.control("back").hasTriggers("click")||this.control("back").hasTriggers("up")||this.control("back").hasTriggers("down")?(e=this.getConfigFromKey(t))&&(this.control(e.id).update(1),void 0!==e.preventDefault)&&e.preventDefault&&t.preventDefault():this.requestExitApp()},t._keyUp=function(t){var e=this.getConfigFromKey(t);e&&(this.control(e.id).update(0),void 0!==e.preventDefault)&&e.preventDefault&&t.preventDefault()},t.requestExitApp=function(){var t;window.onbeforeunload?(t=window.onbeforeunload({}))&&this.confirm(t,function(t){t&&this.exitApp()}.bind(this)):this.exitApp()},t.exitApp=function(){window.close()},t.confirm=function(t,e){e(window.confirm(t))},e}),define("CatLab/Webremote/Models/Users/CordovaUser",["CatLab/Webremote/Models/Users/KeyboardUser"],function(t){function e(t,e,i){void 0===i&&(i=!0),void 0===e&&(e="back"),this.initializeKeyboardUser({id:"cordova",keys:t}),this.initializeBackButtonExit(e,i)}t=((e.prototype=Object.create(t.prototype)).constructor=e).prototype;return t.initializeBackButtonExit=function(i,n){void 0===n&&(n=!0);var s=new Date;document.addEventListener("backbutton",function(t){var e=new Date;e.getTime()-s.getTime()<300?this.requestExitApp():(s=e,t.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)},t.exitApp=function(){navigator.app.exitApp()},t.confirm=function(t,e){navigator.notification.confirm(t,function(t){e(1===t)})},t.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}]},t.hasDisplay=function(){return!1},t.hasKeyboardInput=function(){return!0},t.hasTouchInput=function(){return!0},e}),define("CatLab/Webremote/Models/Users/AndroidRemoteUser",["CatLab/Webremote/Models/Users/CordovaUser"],function(t){function e(t,e,i){this.initializeKeyboardUser({id:"cordova",keys:t}),this.initializeBackButtonExit(e,i)}t=((e.prototype=Object.create(t.prototype)).constructor=e).prototype;return t.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}]},t.getPortalControls=function(){return{start:"start",back:"back",toggleActive:"up",authenticate:"menu",left:"left",right:"right"}},t.hasDisplay=function(){return!1},t.hasKeyboardInput=function(){return!1},t.hasTouchInput=function(){return!1},this.getType=function(){return"android-keyboard"},e}),define("CatLab/Webremote/Models/Users/DummyUser",["CatLab/Webremote/Models/Users/ControlUser"],function(t){function e(t){this.initialize({id:t}),this.clearControls=function(){},this.getType=function(){return"dummy"},this.getIcon=function(){return"fa fa-keyboard-o"},this.emit=function(t,e){return!1},this.isLocalAuthentication=function(){return!1},this.log=function(t){this.Webcontrol&&this.Webcontrol.log("[u:"+this.getId()+"] "+t)},this.hasDisplay=function(){return!1},this.hasKeyboardInput=function(){return!0},this.hasTouchInput=function(){return!0},this.clearControls()}return(e.prototype=Object.create(t.prototype)).constructor=e}),define("CatLab/Webremote/Tools/ParseXML",[],function(){function t(){}var e=null;"undefined"!=typeof window&&(void 0!==window.DOMParser?e=function(t){return(new window.DOMParser).parseFromString(t,"text/xml")}:void 0!==window.ActiveXObject&&new window.ActiveXObject("Microsoft.XMLDOM")&&(e=function(t){var e=new window.ActiveXObject("Microsoft.XMLDOM");return e.async="false",e.loadXML(t),e}));return t.prototype.parse=function(t){if(e)return e(t);throw new Error("No XML parser found")},new t}),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(t,e,i,n,s,o,r){function a(t){t&&(this.airconsole=t),this.showTokenForm=!1,this.oauth={},this.views=[],this.knownUsers={},this.started=!1,this.userId=null,this.sendBurstDelay=50,this.connectCode=null}t=a.prototype=new t;return t.connect=function(t){return this.log("Airconsole connecting"),this.setInitialized(),this.path=t,this._trigger("connect",null),this.readyState.promise()},t.noTokenConnect=function(){return this.connect("remote")},t.setUserId=function(t){return this.userId=t,this},t.initMaster=function(t){this.master=t,this.airconsole||(this.airconsole=new AirConsole),this.airconsole.onMessage=this.onMessage.bind(this),this.airconsole.onConnect=function(t){this.emitAirConsole(t,"airconsole:well-hello-there",{user:t})}.bind(this),this.readyState=new i,this.airconsole.onReady=function(t){this.connectCode=t,this.readyState.resolve()}.bind(this),this.airconsole.onDeviceProfileChange=function(t){this.updateDeviceProfile(t)}.bind(this),this.on("player:join",function(t){this.onPlayerConnect(t.user)}.bind(this)),this.once("connect",function(){setTimeout(function(){this.started=!0}.bind(this),1)}.bind(this))},t.initPlayer=function(t){this.master=t,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(t){this.emitAirConsole(0,"player:join",{})}.bind(this))},t.onMessage=function(e,t){var i;void 0!==(t="string"==typeof t?JSON.parse(t):t).b&&Array.isArray(t.b)?(i=0,t.b.forEach(function(t){setTimeout(function(){this.processMessage(e,t)}.bind(this),i++)}.bind(this))):this.processMessage(e,t)},t.processMessage=function(t,e){var i;e&&e[0]&&(i=e[0],e=e[1],this.isMaster()&&(0<t&&"player:join"!==i&&void 0===this.knownUsers[t]&&this.onPlayerConnect(t),0<t)&&(e.user=t),o.unpack(e,"user").forEach(function(t){this.isRemote()&&void 0!==t.user&&t.user!==this.airconsole.getDeviceId()||this._trigger(i,t)}.bind(this)))},t.onPlayerConnect=function(t){this.log("Welcoming our newest player "+t),this.knownUsers[t]=!0;for(var e=0;e<this.views.length;e++)this.emitAirConsole(t,"view:load",{xml:this.views[e]}),this.emitAirConsole(t,"view:set",{id:"loading"});this._trigger("user:join",{id:t}),this.updateDeviceProfile(t)},t.updateDeviceProfile=function(t){var e,i,n=this.master._userlibrary.getFromId(t);n&&(e={username:this.airconsole.getNickname(t)},(i=this.airconsole.getProfilePicture(t))&&(e.avatar=i),this.airconsole.getMasterControllerDeviceId()===t&&n.setMaster(!0),n.setProfiledata(e))},t.emitAll=function(){this.isMaster()&&this.emitMaster(),this.isRemote()&&this.emitClient()},t.isMaster=function(){return"control"===this.path},t.isRemote=function(){return"remote"===this.path},t.emitClient=function(){this.queue.flush().forEach(function(t){this.emitAirConsole(0,t.action,t.data)}.bind(this))},t.emitMaster=function(){var e,i,t=this.queue.compactFlush();t.length&&(e=5<t.length,i=[],t.forEach(function(t){e||void 0===t.data.user||Array.isArray(t.data.user)&&1<t.data.user.length?i.push(t):this.emitAirConsole(t.user,t.action,t.data)}.bind(this)),0<i.length)&&this.broadcastAirconsole(i)},t.emitAirConsole=function(t,e,i){e=[e,i],delete e[1].action,i=JSON.stringify(e);this.airconsole.message(t,i)},t.broadcastAirconsole=function(t){var e=[],t=(t.forEach(function(t){e.push([t.action,t.data])}),JSON.stringify({b:e}));this.airconsole.broadcast(t)},t.setOAuthSettings=function(t){this.oauth=t,this.toPlayers("oauth:set",t)},t.loadViews=function(t){n.get(t).then(function(t){this.views.push(t),this.toPlayers("view:load",{xml:t})}.bind(this))},t.log=function(){this.master.log.apply(arguments)},t.setup=function(t){this._trigger("master:initialize",{})},t.toMaster=function(t,e){e.user=0,this.emit(t,e)},t.log=function(t){var e=[],i=(Array.prototype.push.apply(e,arguments),"["+this.path+"]");"remote"===this.path&&(i="["+this.path+":"+this.airconsole.getDeviceId()+"]"),e.unshift(i),console.log.apply(console,e)},t.getConnectInstructions=function(){return["Open the Airconsole app on your smartphone and connect with code %s.",this.connectCode]},t.getStartAndLoginInstructions=function(){return["Use the onscreen button to start the game."]},a}),define("CatLab/Webremote/CreateJS/LayerContainer",["easeljs","easelbone"],function(n,s){"use strict";function t(t,e){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=t,this.height=e,this.initialize(),this.easelboneLayer=new s.Views.Layer({container:this});var i=this;this.easelboneLayer.on("all",function(t){t=new n.Event(t);i.dispatchEvent(t)})}var e=t.prototype=new n.Container;return e.Container_initialize=e.initialize,e.initialize=function(){this.Container_initialize(),this.setBounds(0,0,this.width,this.height),this.on("click",function(t){t.stopPropagation()})},e.loading=function(){},e.render=function(){this.easelboneLayer.render()},t}),define("CatLab/Webremote/CreateJS/Views/PortalView",["easeljs","easelbone","CatLab/Webremote/Tools/Translator"],function(t,n,i){"use strict";return n.Views.Navigatable.extend({initialize:function(t){this.initializeNavigatable({orientation:this.ORIENTATION.HORIZONTAL});var e=this;this.assets=t.assets,t.showInactivePlayers?this.setScreen(new t.assets.PortalView):this.setScreen(new t.assets.PortalViewNoInactive),this.showInactivePlayers=t.showInactivePlayers||!1,this.portalController=t.controller,this.showInactivePlayers&&(this.connectedUsersContainer=new n.EaselJS.Placeholder(this.getScreen().connectedUsers),this.connectedUsers=new n.Controls.FloatContainer(function(t){return e.getUserIcon(t)},6),this.connectedUsersContainer.addChild(this.connectedUsers)),this.activeUsersContainer=new n.EaselJS.Placeholder(this.getScreen().activeUsers),this.activeUsers=new n.Controls.FloatContainer(function(t){return e.getUserIcon(t)},t.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(){e.portalController.startGame()}),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(){e.portalController.back()}),this.addControl(this.back)),this.portalController.on("users:update",function(){this.refreshUsers()}.bind(this)),this.portalController.on("options:change",function(){this.showCurrentAndMaxUsers()}.bind(this)),this.findPlaceholders("instructionHeader").forEach(function(t){t.addChild(new n.EaselJS.BigText(i.t("Instructions")))}),this.findPlaceholders("activePlayersHeader").forEach(function(t){t.addChild(new n.EaselJS.BigText(i.t("Active devices")))}),this.findPlaceholders("connectedPlayersHeader").forEach(function(t){t.addChild(new n.EaselJS.BigText(i.t("Connected devices")))}),this.instructionTexts=[],this.findPlaceholders("instructionText").forEach(function(t){var e=new n.EaselJS.BigText(this.getInstructionText());this.instructionTexts.push(e),t.addChild(e)}.bind(this)),this.activePlayerTexts=[],this.findPlaceholders("activePlayers").forEach(function(t){var e=new n.EaselJS.BigText(this.getActiveUsersText());this.activePlayerTexts.push(e),t.addChild(e)}.bind(this))},getActiveUsersText:function(){return this.portalController.countActiveUsers()+"/"+this.portalController.options.maxPlayers},getInstructionText:function(){return this.portalController.getConnectInstructions()+"\n"+this.portalController.getStartAndLoginInstructions()},getUserIcon:function(t){var e,i;return t?t.hasUser()?(e=new this.assets.UserIconAuthenticated,this.addControllerIcon(e,t)):e=this.getControllerIcon(t):e=this.getControllerIcon(),t&&(i=e.PlayerColor)&&new n.EaselJS.Placeholder(i).addChild(new n.EaselJS.Fill(t.getColor())),t&&this.setUserDetails(e,t),e},addControllerIcon:function(t,e){var i;t.ControllerIcon&&(t=new n.EaselJS.Placeholder(t.ControllerIcon),i=this.getControllerIcon(e),t.addChild(i),i.scaleX=i.scaleY=.5,e)&&(t=i.PlayerColor)&&new n.EaselJS.Placeholder(t).addChild(new n.EaselJS.Fill(e.getColor()))},getControllerIcon:function(t){if(t)switch(t.getType()){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(t){alert(t)},refreshUsers:function(){this.showCurrentAndMaxUsers(),this.showInformation(),this.reloadUserIcons(this.portalController.getUsers())},showCurrentAndMaxUsers:function(){this.getScreen().playercount&&(this.getScreen().playercount.text=this.portalController.countActiveUsers()+"/"+this.portalController.options.maxPlayers),this.activePlayerTexts.forEach(function(t){t.setText(this.portalController.countActiveUsers()+"/"+this.portalController.options.maxPlayers)}.bind(this)),this.getScreen().login&&(this.getScreen().login.text=this.portalController.getStartAndLoginInstructions())},showInformation:function(){var t=this.portalController.getConnectInstructions();this.getScreen().login?this.getScreen().login.text=this.portalController.getStartAndLoginInstructions():t+="\n "+this.portalController.getStartAndLoginInstructions(),this.getScreen().token&&(this.getScreen().token.text=t),this.instructionTexts.forEach(function(t){t.setText(this.getInstructionText())}.bind(this))},removeAllUserIcons:function(){this.showInactivePlayers&&this.connectedUsers.removeAllChildren(),this.activeUsers.removeAllChildren()},reloadUserIcons:function(t){var e=24,i=24;this.showInactivePlayers||(i=48),this.removeAllUserIcons(),t.forEach(function(t){t.isActive()?i<=0||(i--,this.activeUsers.createElement(t)):!this.showInactivePlayers||e<=0||(e--,this.connectedUsers.createElement(t))}.bind(this))},setUserDetails:function(t,e){var i;e.hasUser()&&t.userimage&&(i=new n.EaselJS.Placeholder(t.userimage),e.getUser().getImage(function(t){i.addChild(new n.EaselJS.Fill(t))}))},addAuthenticationView:function(t){this.el.addChild(t);var e=this;t.on("view:close",function(){e.el.removeChild(t)})},render:function(){this.el.addChild(this.getScreen()),this.refreshUsers()}})}),define("CatLab/Webremote/CreateJS/Views/AuthenticationView",["easelbone","CatLab/Webremote/Tools/Translator"],function(s,i){"use strict";return s.Views.Base.extend({initialize:function(t){var e=this,t=(this.assets=t.assets,this.screen=new t.assets.Signin,this.controller=t.controller,this.screen.close.on("click",function(){e.controller.close()}),this.linkAccount=new s.Controls.Button(this.screen.linkAccount),this.titlePlaceholder=null,this.explanationPlaceholder=null,s.Helpers.MovieClipHelper.findFromNames(["title"],[this.screen]).forEach(function(t){this.titlePlaceholder=new s.EaselJS.Placeholder(t)}.bind(this)),s.Helpers.MovieClipHelper.findFromNames(["explanation"],[this.screen]).forEach(function(t){this.explanationPlaceholder=new s.EaselJS.Placeholder(t)}.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(){e.controller.link()}),new s.Controls.ScrollArea(this.screen.accounts));this.users=new s.Controls.FloatContainer(function(t){return e.getUserObject(t)},4),t.content.addChild(this.users),this.controller.on("users:update",this.updateUsers,this),this.updateUsers(),this.on("removed",function(){this.trigger("close")}.bind(this))},updateUsers:function(){var t=this.controller.getUsers().getAll();this.users.removeAllChildren();for(var e=0;e<t.length;e++)this.users.createElement(t[e])},getUserObject:function(t){var e,i=this,n=new this.assets.UserModel;return t&&(n.namePlaceholder?new s.EaselJS.Placeholder(n.namePlaceholder).addChild(new s.EaselJS.BigText(t.getName())):n.name&&(n.name.text=t.getName()),e=new s.EaselJS.Placeholder(n.picture),t.getImage(function(t){e.addChild(new s.EaselJS.Fill(t))}),n.on("click",function(){i.controller.selectUser(t)})),n},close:function(){this.trigger("close")},render:function(){this.el.addChild(this.screen)},setLoginUrl:function(t){this.loginUrl=t,this.setLoginUrlText()},setLoginUrlText:function(){var t;this.linkAccount&&(this.linkAccount.setText(i.t("Login to add profile")),this.explanationPlaceholder)&&(t=new s.EaselJS.BigText(i.t("Or surf to %s to login from your phone.",this.loginUrl)),this.explanationPlaceholder.removeAllChildren(),this.explanationPlaceholder.addChild(t))}})}),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(t){return function(){return t.ctlbrmtassets}}(this)),define("CatLab/Webremote/ViewFactory/CreatejsViewFactory",["CatLab/Webremote/Tools/Deferred"],function(e){"use strict";function t(t){void 0!==t&&this.setAssets(t)}var o,r,a,i=t.prototype;return i.initialize=function(){var t=new e;return this.loadAssets().then(function(){this.setAssets(this.assets),t.resolve()}.bind(this)),t},i.loadAssets=function(){var s=new e;return require(["CatLab/Webremote/CreateJS/LayerContainer","CatLab/Webremote/CreateJS/Views/PortalView","CatLab/Webremote/CreateJS/Views/AuthenticationView","CatLab/Webremote/assets/createjsassets"],function(t,e,i,n){o=t,r=e,a=i,s.resolve()}.bind(this)),s.promise()},i.portal=function(t){return t.assets=this.assets,new r(t)},i.authentication=function(t){return t.assets=this.assets,new a(t)},i.setAssets=function(t){void 0!==t&&(this.assets=t)},i.getContainer=function(){var t=new o;return t.setBounds(0,0,this.assets.properties.width,this.assets.properties.height),t.loading(),t},t}),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/ViewFactory/ViewFactory","CatLab/Webremote/ViewFactory/CreatejsViewFactory"],function(e,t,i,n,s,o,r,a,h,l,c,u,d,p,f,g){return{Config:function(t){e.set(t)},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},ViewFactories:{HtmlViewFactory:f,CreatejsViewFactory:g},Smileys:a}}),define("catlabremote",["CatLab/Webremote/FrontController"],function(t){return t}),define("CatLab/EaselHacks/AlphaMaskFilter",[],function(t){function e(t){var n=this;this.createjs=t,Object.defineProperty(t.DisplayObject.prototype,"mask",{get:function(){return this.forceMask},set:function(t){var e,i=this;t?(i.originalMask=t,e=n.getFilterFromMask(t,i),i.filters=[e],i.cache(0,0,500,500)):null!==t&&(i.filters=null,i.cache(0,0,500,500))}}),t.DisplayObject.prototype.setMask=function(t){this.forceMask=t}}return e.prototype.getFilterFromMask=function(t,e){var i=this.createjs,n=t.graphics.getInstructions(),s=new i.Graphics;s.beginFill("#000000"),s.beginStroke("#000000");for(var o=0;o<n.length;o++)s.append(n[o]);t.graphics=s;var r=new i.Container,t=(r.addChild(t),r.scaleX=1/e.scaleX,r.scaleY=1/e.scaleY,r.y=-e.y,r.x=-e.x,new i.Container);return t.addChild(r),t.cache(0,0,1e3,1e3),new i.AlphaMaskFilter(t.cacheCanvas)},e}),define("CatLab/EaselHacks/FrontController",["CatLab/EaselHacks/AlphaMaskFilter"],function(t){return{AlphaMaskFilter:t}}),define("easelhacks",["CatLab/EaselHacks/FrontController"],function(t){return t}),define("CatLab/Webremote/Hacks",["easelhacks","easeljs"],function(t,e){new t.AlphaMaskFilter(e)});
|