EmulatorJS/data/emulator.min.js
Ethan O'Brien 400f705842 Version 3.1.5
Co-authored-by: Allan Niles <74841470+allancoding@users.noreply.github.com>
Co-authored-by: xufenqi <xufenqi@weili.com>
Co-authored-by: incredibleIdea <510996577@qq.com>
Unverified-co-authored-by: rwv <7891383+rwv@users.noreply.github.com>
2023-06-19 16:59:00 -05:00

1 line
No EOL
460 KiB
JavaScript

var EJS=function(o){window.EJS_MODULES=o;var n={},i=[];function a(e){if(n[e])return n[e].exports;i.push(e);var t=n[e]={i:e,l:!1,exports:{}};return o[e].call(t.exports,t,t.exports,a),t.l=!0,t.exports}return window.getUsedModules=function(){return i.sort(function(e,t){return t<e?1:-1})},window.getUnusedModules=function(){for(var e=[],t=getUsedModules(),n=0;n<o.length;n++)null===o[n]||t.includes(n)||e.push(n);return e},Array.isArray,a.m=o,a.c=n,a.d=function(e,t,n){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)a.d(n,o,function(e){return t[e]}.bind(null,o));return n},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=162)}([function(e){e.exports=function(e,t,n){console.warn(e),e&&e.response&&0===e.response.status?t.innerHTML='<strong style="color:#f00;text-shadow: 0px 0px 3px;"><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors">'+n.localization("CORS Error")+"</a></strong>":t.innerHTML='<strong style="color:#f00;text-shadow: 0px 0px 3px;">'+n.localization("Network Error")+"</strong>"}},null,null,null,null,null,function(e){e.exports=class{gamepads;timeout;listeners;constructor(){this.gamepads=[],this.listeners={},this.timeout=null,this.loop()}terminate(){window.clearTimeout(this.timeout)}getGamepads(){return navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[]}loop(){this.updateGamepadState(),this.timeout=setTimeout(this.loop.bind(this),10)}updateGamepadState(){const o=this.getGamepads();o.forEach((a,n)=>{if(a){let t=!1;this.gamepads.forEach((i,e)=>{i.index===a.index&&(t=!0,i.axes.forEach((e,t)=>{if(a.axes[t]!==e){const e=["LEFT_STICK_X","LEFT_STICK_Y","RIGHT_STICK_X","RIGHT_STICK_Y"][t];e&&this.dispatchEvent("axischanged",{axis:e,value:a.axes[t],index:a.index,gamepadIndex:a.index})}}),a.buttons.forEach((e,t)=>{let n=1===i.buttons[t],o=("object"==typeof i.buttons[t]&&(n=i.buttons[t].pressed),1===e);"object"==typeof e&&(o=e.pressed),n!==o&&(o?this.dispatchEvent("buttondown",{index:t,gamepadIndex:a.index}):this.dispatchEvent("buttonup",{index:t,gamepadIndex:a.index}))}),this.gamepads[e]=o[n])}),t||(this.gamepads.push(o[n]),this.dispatchEvent("connected",{gamepadIndex:a.index}))}});for(let n=0;n<this.gamepads.length;n++)if(this.gamepads[n]){let t=!1;for(let e=0;e<o.length;e++)if(o[e]&&this.gamepads[n].index===o[e].index){t=!0;break}t||(this.dispatchEvent("disconnected",{gamepadIndex:this.gamepads[n].index}),this.gamepads.splice(n,1),n--)}}dispatchEvent(e,t){"function"==typeof this.listeners[e]&&((t=t||{}).type=e,this.listeners[e](t))}on(e,t){this.listeners[e.toLowerCase()]=t}}},null,null,null,null,function(e,t,n){function o(o,i){let e;try{e=new URL(o)}catch(e){}return e&&["http:","https:"].includes(e.protocol)||!e?new Promise(function(t,e){let n=new XMLHttpRequest;i.onProgress&&n.addEventListener("progress",i.onProgress),n.onload=function(){if(n.readyState===n.DONE){let e=n.response;try{e=JSON.parse(e)}catch(e){}t({data:e,headers:{"content-length":n.getResponseHeader("content-length"),"content-type":n.getResponseHeader("content-type"),"last-modified":n.getResponseHeader("last-modified")}})}},n.responseType=i.type,n.onerror=e,n.open(i.method,o,!0),n.send()}):new Promise(async function(t,n){if("HEAD"===i.method)t({headers:{}});else{let e;try{if(e=await fetch(o),i.type&&"arraybuffer"===i.type.toLowerCase())e=await e.arrayBuffer();else{e=await e.text();try{e=JSON.parse(e)}catch(e){}}}catch(e){n(e)}o.startsWith("blob:")&&URL.revokeObjectURL(o),t({data:e,headers:{}})}})}e.exports={a:{get:async function(e,t){var n=t&&t.responseType?t&&t.responseType:"text",t=t&&t.onDownloadProgress;return o(e,{method:"GET",type:n,onProgress:t})},head:async function(e,t){var n=t&&t.responseType?t&&t.responseType:"text",t=t&&t.onDownloadProgress;return o(e,{method:"HEAD",type:n,onProgress:t})}}}},null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,function(e,t){var n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,function(e,t){var n,o,e=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function r(t){if(n===setTimeout)return setTimeout(t,0);if((n===i||!n)&&setTimeout)return(n=setTimeout)(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{o="function"==typeof clearTimeout?clearTimeout:a}catch(e){o=a}var s,c=[],l=!1,d=-1;function u(){l&&s&&(l=!1,s.length?c=s.concat(c):d=-1,c.length&&f())}function f(){if(!l){var e=r(u);l=!0;for(var t=c.length;t;){for(s=c,c=[];++d<t;)s&&s[d].run();d=-1,t=c.length}s=null,l=!1,function(t){if(o===clearTimeout)return clearTimeout(t);if((o===a||!o)&&clearTimeout)return(o=clearTimeout)(t);try{o(t)}catch(e){try{return o.call(null,t)}catch(e){return o.call(this,t)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function h(){}e.nextTick=function(e){var t=new Array(arguments.length-1);if(1<arguments.length)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new p(e,t)),1!==c.length||l||r(f)},p.prototype.run=function(){this.fun.apply(null,this.array)},e.title="browser",e.browser=!0,e.env={},e.argv=[],e.version="",e.versions={},e.on=h,e.addListener=h,e.once=h,e.off=h,e.removeListener=h,e.removeAllListeners=h,e.emit=h,e.prependListener=h,e.prependOnceListener=h,e.listeners=function(e){return[]},e.binding=function(e){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(e){throw new Error("process.chdir is not supported")},e.umask=function(){return 0}},null,null,null,null,null,null,null,function(e,t,n){var o;!function(){"use strict";void 0!==(o="function"==typeof(o=function(){function u(e){throw e}function f(){}function e(e,t){for(var n in void 0===t&&"function"==typeof e&&(t=e),"[object Object]"!=Object.prototype.toString.call(e)&&(e={}),i)this[n]=(void 0!==e[n]?e:i)[n];this.dbName=this.storePrefix+this.storeName,this.dbVersion=parseInt(this.dbVersion,10)||1,t&&(this.onStoreReady=t);var o="object"==typeof window?window:self,t=this.implementationPreference.filter(function(e){return e in o});this.implementation=t[0],this.idb=o[this.implementation],this.keyRange=o.IDBKeyRange||o.webkitIDBKeyRange||o.mozIDBKeyRange,this.consts={READ_ONLY:"readonly",READ_WRITE:"readwrite",VERSION_CHANGE:"versionchange",NEXT:"next",NEXT_NO_DUPLICATE:"nextunique",PREV:"prev",PREV_NO_DUPLICATE:"prevunique"},this.openDB()}var i={storeName:"Store",storePrefix:"IDBWrapper-",dbVersion:1,keyPath:"id",autoIncrement:!0,onStoreReady:function(){},onError:u,indexes:[],implementationPreference:["indexedDB","webkitIndexedDB","mozIndexedDB","shimIndexedDB"]},t={constructor:e,version:"1.7.2",db:null,dbName:null,dbVersion:null,store:null,storeName:null,storePrefix:null,keyPath:null,autoIncrement:null,indexes:null,implementationPreference:null,implementation:"",onStoreReady:null,onError:null,_insertIdCount:0,openDB:function(){var e=this.idb.open(this.dbName,this.dbVersion),i=!1;e.onerror=function(e){var t;("error"in(t=e).target?"VersionError"==t.target.error.name:"errorCode"in t.target&&12==t.target.errorCode)?this.onError(new Error("The version number provided is lower than the existing one.")):(e=e.target.error||(t="IndexedDB unknown error occurred when opening DB "+this.dbName+" version "+this.dbVersion,"errorCode"in e.target&&(t+=" with error code "+e.target.errorCode),new Error(t)),this.onError(e))}.bind(this),e.onsuccess=function(e){var o;i||(this.db?this.onStoreReady():(this.db=e.target.result,"string"!=typeof this.db.version?this.db.objectStoreNames.contains(this.storeName)?(e=this.db.transaction([this.storeName],this.consts.READ_ONLY),this.store=e.objectStore(this.storeName),o=Array.prototype.slice.call(this.getIndexList()),this.indexes.forEach(function(e){var t,n=e.name;if(!n)return i=!0,void this.onError(new Error("Cannot create index: No index name given."));this.normalizeIndexData(e),this.hasIndex(n)?(t=this.store.index(n),this.indexComplies(t,e)||(i=!0,this.onError(new Error('Cannot modify index "'+n+'" for current version. Please bump version number to '+(this.dbVersion+1)+"."))),o.splice(o.indexOf(n),1)):(i=!0,this.onError(new Error('Cannot create new index "'+n+'" for current version. Please bump version number to '+(this.dbVersion+1)+".")))},this),o.length&&(i=!0,this.onError(new Error('Cannot delete index(es) "'+o.toString()+'" for current version. Please bump version number to '+(this.dbVersion+1)+"."))),i||this.onStoreReady()):this.onError(new Error("Object store couldn't be created.")):this.onError(new Error("The IndexedDB implementation in this browser is outdated. Please upgrade your browser."))))}.bind(this),e.onupgradeneeded=function(e){this.db=e.target.result,this.db.objectStoreNames.contains(this.storeName)?this.store=e.target.transaction.objectStore(this.storeName):(e={autoIncrement:this.autoIncrement},null!==this.keyPath&&(e.keyPath=this.keyPath),this.store=this.db.createObjectStore(this.storeName,e));var o=Array.prototype.slice.call(this.getIndexList());this.indexes.forEach(function(e){var t,n=e.name;n||(i=!0,this.onError(new Error("Cannot create index: No index name given."))),this.normalizeIndexData(e),this.hasIndex(n)?(t=this.store.index(n),this.indexComplies(t,e)||(this.store.deleteIndex(n),this.store.createIndex(n,e.keyPath,{unique:e.unique,multiEntry:e.multiEntry})),o.splice(o.indexOf(n),1)):this.store.createIndex(n,e.keyPath,{unique:e.unique,multiEntry:e.multiEntry})},this),o.length&&o.forEach(function(e){this.store.deleteIndex(e)},this)}.bind(this)},deleteDatabase:function(e,t){var n;this.idb.deleteDatabase?(this.db.close(),(n=this.idb.deleteDatabase(this.dbName)).onsuccess=e,n.onerror=t):t(new Error("Browser does not support IndexedDB deleteDatabase!"))},put:function(e,t,n,o){null!==this.keyPath&&(o=n,n=t,t=e),o=o||u,n=n||f;var i=!1,a=null,r=this.db.transaction([this.storeName],this.consts.READ_WRITE);return r.oncomplete=function(){(i?n:o)(a)},r.onabort=o,r.onerror=o,(t=null!==this.keyPath?(this._addIdPropertyIfNeeded(t),r.objectStore(this.storeName).put(t)):r.objectStore(this.storeName).put(t,e)).onsuccess=function(e){i=!0,a=e.target.result},t.onerror=o,r},get:function(e,t,n){n=n||u,t=t||f;var o=!1,i=null,a=this.db.transaction([this.storeName],this.consts.READ_ONLY),e=(a.oncomplete=function(){(o?t:n)(i)},a.onabort=n,a.onerror=n,a.objectStore(this.storeName).get(e));return e.onsuccess=function(e){o=!0,i=e.target.result},e.onerror=n,a},remove:function(e,t,n){n=n||u,t=t||f;var o=!1,i=null,a=this.db.transaction([this.storeName],this.consts.READ_WRITE),e=(a.oncomplete=function(){(o?t:n)(i)},a.onabort=n,a.onerror=n,a.objectStore(this.storeName).delete(e));return e.onsuccess=function(e){o=!0,i=e.target.result},e.onerror=n,a},batch:function(e,t,a){if(a=a||u,t=t||f,"[object Array]"!=Object.prototype.toString.call(e))a(new Error("dataArray argument must be of type Array."));else if(0===e.length)return t(!0);function r(){0!=--n||s||(o=s=!0)}var n=e.length,s=!1,o=!1,c=this.db.transaction([this.storeName],this.consts.READ_WRITE);c.oncomplete=function(){(o?t:a)(o)},c.onabort=a,c.onerror=a;return e.forEach(function(e){function t(e){c.abort(),s||(s=!0,a(e,o,i))}var n,o=e.type,i=e.key,e=e.value;"remove"==o?((n=c.objectStore(this.storeName).delete(i)).onsuccess=r,n.onerror=t):"put"==o&&((n=null!==this.keyPath?(this._addIdPropertyIfNeeded(e),c.objectStore(this.storeName).put(e)):c.objectStore(this.storeName).put(e,i)).onsuccess=r,n.onerror=t)},this),c},putBatch:function(e,t,n){e=e.map(function(e){return{type:"put",value:e}});return this.batch(e,t,n)},upsertBatch:function(t,e,n,o){"function"==typeof e&&(o=n=e,e={}),o=o||u,n=n||f,e=e||{},"[object Array]"!=Object.prototype.toString.call(t)&&o(new Error("dataArray argument must be of type Array."));function i(e){t[l++][a]=e.target.result,0!=--r||s||(c=s=!0)}var a=e.keyField||this.keyPath,r=t.length,s=!1,c=!1,l=0,d=this.db.transaction([this.storeName],this.consts.READ_WRITE);d.oncomplete=function(){c?n(t):o(!1)},d.onabort=o,d.onerror=o;return t.forEach(function(e){var t=e.key,e=null!==this.keyPath?(this._addIdPropertyIfNeeded(e),d.objectStore(this.storeName).put(e)):d.objectStore(this.storeName).put(e,t);e.onsuccess=i,e.onerror=function(e){d.abort(),s||(s=!0,o(e))}},this),d},removeBatch:function(e,t,n){e=e.map(function(e){return{type:"remove",key:e}});return this.batch(e,t,n)},getBatch:function(e,t,n,o){if(n=n||u,t=t||f,o=o||"sparse","[object Array]"!=Object.prototype.toString.call(e))n(new Error("keyArray argument must be of type Array."));else if(0===e.length)return t([]);function i(e){e.target.result||"dense"==o?a.push(e.target.result):"sparse"==o&&a.length++,0==--r&&(s=!0,c=a)}var a=[],r=e.length,s=!1,c=null,l=this.db.transaction([this.storeName],this.consts.READ_ONLY);l.oncomplete=function(){(s?t:n)(c)},l.onabort=n,l.onerror=n;return e.forEach(function(e){e=l.objectStore(this.storeName).get(e);e.onsuccess=i,e.onerror=function(e){n(c=e),l.abort()}},this),l},getAll:function(e,t){t=t||u,e=e||f;var n=this.db.transaction([this.storeName],this.consts.READ_ONLY),o=n.objectStore(this.storeName);return o.getAll?this._getAllNative(n,o,e,t):this._getAllCursor(n,o,e,t),n},_getAllNative:function(e,t,n,o){var i=!1,a=null,e=(e.oncomplete=function(){(i?n:o)(a)},e.onabort=o,e.onerror=o,t.getAll());e.onsuccess=function(e){i=!0,a=e.target.result},e.onerror=o},_getAllCursor:function(e,t,n,o){var i=[],a=!1,r=null,e=(e.oncomplete=function(){(a?n:o)(r)},e.onabort=o,e.onerror=o,t.openCursor());e.onsuccess=function(e){e=e.target.result;e?(i.push(e.value),e.continue()):(a=!0,r=i)},e.onError=o},clear:function(e,t){t=t||u,e=e||f;var n=!1,o=null,i=this.db.transaction([this.storeName],this.consts.READ_WRITE),a=(i.oncomplete=function(){(n?e:t)(o)},i.onabort=t,i.onerror=t,i.objectStore(this.storeName).clear());return a.onsuccess=function(e){n=!0,o=e.target.result},a.onerror=t,i},_addIdPropertyIfNeeded:function(e){void 0===e[this.keyPath]&&(e[this.keyPath]=this._insertIdCount+++Date.now())},getIndexList:function(){return this.store.indexNames},hasIndex:function(e){return this.store.indexNames.contains(e)},normalizeIndexData:function(e){e.keyPath=e.keyPath||e.name,e.unique=!!e.unique,e.multiEntry=!!e.multiEntry},indexComplies:function(a,r){return["keyPath","unique","multiEntry"].every(function(e){if("multiEntry"==e&&void 0===a[e]&&!1===r[e])return!0;if("keyPath"!=e||"[object Array]"!=Object.prototype.toString.call(r[e]))return r[e]==a[e];var t=r.keyPath,n=a.keyPath;if("string"==typeof n)return t.toString()==n;if("function"!=typeof n.contains&&"function"!=typeof n.indexOf)return!1;if(n.length!==t.length)return!1;for(var o=0,i=t.length;o<i;o++)if(!(n.contains&&n.contains(t[o])||n.indexOf(-1!==t[o])))return!1;return!0})},iterate:function(n,o){var e="desc"==(o=s({index:null,order:"ASC",autoContinue:!0,filterDuplicates:!1,keyRange:null,writeAccess:!1,onEnd:null,onError:u,limit:1/0,offset:0,allowItemRejection:!1},o||{})).order.toLowerCase()?"PREV":"NEXT",i=(o.filterDuplicates&&(e+="_NO_DUPLICATE"),!1),a=this.db.transaction([this.storeName],this.consts[o.writeAccess?"READ_WRITE":"READ_ONLY"]),t=a.objectStore(this.storeName),r=(o.index&&(t=t.index(o.index)),0),t=(a.oncomplete=function(){i?o.onEnd?o.onEnd():n(null):o.onError(null)},a.onabort=o.onError,a.onerror=o.onError,t.openCursor(o.keyRange,this.consts[e]));return t.onerror=o.onError,t.onsuccess=function(e){var t,e=e.target.result;e?o.offset?(e.advance(o.offset),o.offset=0):(t=n(e.value,e,a),o.allowItemRejection&&!1===t||r++,o.autoContinue&&(r+o.offset<o.limit?e.continue():i=!0)):i=!0},a},query:function(e,n){var o=[],i=0;return(n=n||{}).autoContinue=!0,n.writeAccess=!1,n.allowItemRejection=!!n.filter,n.onEnd=function(){e(o,i)},this.iterate(function(e){i++;var t=!n.filter||n.filter(e);return!1!==t&&o.push(e),t},n)},count:function(e,t){var n=(t=s({index:null,keyRange:null},t||{})).onError||u,o=!1,i=null,a=this.db.transaction([this.storeName],this.consts.READ_ONLY),r=(a.oncomplete=function(){(o?e:n)(i)},a.onabort=n,a.onerror=n,a.objectStore(this.storeName)),r=(r=t.index?r.index(t.index):r).count(t.keyRange);return r.onsuccess=function(e){o=!0,i=e.target.result},r.onError=n,a},makeKeyRange:function(e){var t,n=void 0!==e.lower,o=void 0!==e.upper;switch(!0){case void 0!==e.only:t=this.keyRange.only(e.only);break;case n&&o:t=this.keyRange.bound(e.lower,e.upper,e.excludeLower,e.excludeUpper);break;case n:t=this.keyRange.lowerBound(e.lower,e.excludeLower);break;case o:t=this.keyRange.upperBound(e.upper,e.excludeUpper);break;default:throw new Error('Cannot create KeyRange. Provide one or both of "lower" or "upper" value, or an "only" value.')}return t}},a={};function s(e,t){var n,o;for(n in t)(o=t[n])!==a[n]&&o!==e[n]&&(e[n]=o);return e}return e.prototype=t,e.version=t.version,e})?o.call(t,n,t,e):o)&&(e.exports=o)}()},null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,function(e,o,t){!function o(i,a,r){function s(t,e){if(!a[t]){if(!i[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(c)return c(t,!0);e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}n=a[t]={exports:{}};i[t][0].call(n.exports,function(e){return s(i[t][1][e]||e)},n,n.exports,o,i,a,r)}return a[t].exports}for(var c="function"==typeof require&&require,e=0;e<r.length;e++)s(r[e]);return s}({1:[function(e,t,n){o.Buffer=e("buffer").Buffer},{buffer:3}],2:[function(e,t,n){"use strict";n.byteLength=function(e){var e=d(e),t=e[0],e=e[1];return 3*(t+e)/4-e},n.toByteArray=function(e){for(var t,n=d(e),o=n[0],n=n[1],i=new l(3*(o+n)/4-n),a=0,r=0<n?o-4:o,s=0;s<r;s+=4)t=c[e.charCodeAt(s)]<<18|c[e.charCodeAt(s+1)]<<12|c[e.charCodeAt(s+2)]<<6|c[e.charCodeAt(s+3)],i[a++]=t>>16&255,i[a++]=t>>8&255,i[a++]=255&t;return 2===n&&(t=c[e.charCodeAt(s)]<<2|c[e.charCodeAt(s+1)]>>4,i[a++]=255&t),1===n&&(t=c[e.charCodeAt(s)]<<10|c[e.charCodeAt(s+1)]<<4|c[e.charCodeAt(s+2)]>>2,i[a++]=t>>8&255,i[a++]=255&t),i},n.fromByteArray=function(e){for(var t,n=e.length,o=n%3,i=[],a=0,r=n-o;a<r;a+=16383)i.push(function(e,t,n){for(var o,i=[],a=t;a<n;a+=3)o=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(s[(o=o)>>18&63]+s[o>>12&63]+s[o>>6&63]+s[63&o]);return i.join("")}(e,a,r<a+16383?r:a+16383));return 1==o?(t=e[n-1],i.push(s[t>>2]+s[t<<4&63]+"==")):2==o&&(t=(e[n-2]<<8)+e[n-1],i.push(s[t>>10]+s[t>>4&63]+s[t<<2&63]+"=")),i.join("")};for(var s=[],c=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,a=o.length;i<a;++i)s[i]=o[i],c[o.charCodeAt(i)]=i;function d(e){var t=e.length;if(0<t%4)throw new Error("Invalid string. Length must be a multiple of 4");e=e.indexOf("=");return[e=-1===e?t:e,e===t?0:4-e%4]}c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},{}],3:[function(A,e,O){!function(e){!function(){"use strict";var x=A("base64-js"),a=A("ieee754"),t=(O.Buffer=u,O.SlowBuffer=function(e){return u.alloc(+(e=+e!=e?0:e))},O.INSPECT_MAX_BYTES=50,2147483647);function d(e){if(t<e)throw new RangeError('The value "'+e+'" is invalid for option "size"');e=new Uint8Array(e);return e.__proto__=u.prototype,e}function u(e,t,n){if("number"!=typeof e)return o(e,t,n);if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return r(e)}function o(e,t,n){if("string"==typeof e){var o=e,i=t;if(!u.isEncoding(i="string"==typeof i&&""!==i?i:"utf8"))throw new TypeError("Unknown encoding: "+i);var a=0|h(o,i),r=d(a);return r=(o=r.write(o,i))!==a?r.slice(0,o):r}if(ArrayBuffer.isView(e))return f(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(M(e,ArrayBuffer)||e&&M(e.buffer,ArrayBuffer)){i=e,a=t,o=n;if(a<0||i.byteLength<a)throw new RangeError('"offset" is outside of buffer bounds');if(i.byteLength<a+(o||0))throw new RangeError('"length" is outside of buffer bounds');return(i=void 0===a&&void 0===o?new Uint8Array(i):void 0===o?new Uint8Array(i,a):new Uint8Array(i,a,o)).__proto__=u.prototype,i}if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return u.from(r,t,n);var s,c,l=u.isBuffer(s=e)?(0!==(c=d(l=0|p(s.length))).length&&s.copy(c,0,0,l),c):void 0!==s.length?"number"!=typeof s.length||R(s.length)?d(0):f(s):"Buffer"===s.type&&Array.isArray(s.data)?f(s.data):void 0;if(l)return l;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return u.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function i(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function r(e){return i(e),d(e<0?0:0|p(e))}function f(e){for(var t=e.length<0?0:0|p(e.length),n=d(t),o=0;o<t;o+=1)n[o]=255&e[o];return n}function p(e){if(t<=e)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+t.toString(16)+" bytes");return 0|e}function h(e,t){if(u.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||M(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var n=e.length,o=2<arguments.length&&!0===arguments[2];if(!o&&0===n)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return S(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return T(e).length;default:if(i)return o?-1:S(e).length;t=(""+t).toLowerCase(),i=!0}}function n(e,t,n){var o=e[t];e[t]=e[n],e[n]=o}function s(e,t,n,o,i){if(0===e.length)return-1;if("string"==typeof n?(o=n,n=0):2147483647<n?n=2147483647:n<-2147483648&&(n=-2147483648),(n=(n=R(n=+n)?i?0:e.length-1:n)<0?e.length+n:n)>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=u.from(t,o)),u.isBuffer(t))return 0===t.length?-1:c(e,t,n,o,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?(i?Uint8Array.prototype.indexOf:Uint8Array.prototype.lastIndexOf).call(e,t,n):c(e,[t],n,o,i);throw new TypeError("val must be string, number or Buffer")}function c(e,t,n,o,i){var a=1,r=e.length,s=t.length;if(void 0!==o&&("ucs2"===(o=String(o).toLowerCase())||"ucs-2"===o||"utf16le"===o||"utf-16le"===o)){if(e.length<2||t.length<2)return-1;r/=a=2,s/=2,n/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i)for(var l=-1,d=n;d<r;d++)if(c(e,d)===c(t,-1===l?0:d-l)){if(d-(l=-1===l?d:l)+1===s)return l*a}else-1!==l&&(d-=d-l),l=-1;else for(d=n=r<n+s?r-s:n;0<=d;d--){for(var u=!0,f=0;f<s;f++)if(c(e,d+f)!==c(t,f)){u=!1;break}if(u)return d}return-1}function y(e,t,n,o){return E(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,o)}function C(e,t,n){n=Math.min(e.length,n);for(var o=[],i=t;i<n;){var a,r,s,c,l=e[i],d=null,u=239<l?4:223<l?3:191<l?2:1;if(i+u<=n)switch(u){case 1:l<128&&(d=l);break;case 2:128==(192&(a=e[i+1]))&&127<(c=(31&l)<<6|63&a)&&(d=c);break;case 3:a=e[i+1],r=e[i+2],128==(192&a)&&128==(192&r)&&2047<(c=(15&l)<<12|(63&a)<<6|63&r)&&(c<55296||57343<c)&&(d=c);break;case 4:a=e[i+1],r=e[i+2],s=e[i+3],128==(192&a)&&128==(192&r)&&128==(192&s)&&65535<(c=(15&l)<<18|(63&a)<<12|(63&r)<<6|63&s)&&c<1114112&&(d=c)}null===d?(d=65533,u=1):65535<d&&(d-=65536,o.push(d>>>10&1023|55296),d=56320|1023&d),o.push(d),i+=u}var f=o,p=f.length;if(p<=g)return String.fromCharCode.apply(String,f);for(var h="",m=0;m<p;)h+=String.fromCharCode.apply(String,f.slice(m,m+=g));return h}O.kMaxLength=t,(u.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}())||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),u.poolSize=8192,u.from=o,u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,u.alloc=function(e,t,n){return t=t,n=n,i(e=e),!(e<=0)&&void 0!==t?"string"==typeof n?d(e).fill(t,n):d(e).fill(t):d(e)},u.allocUnsafe=r,u.allocUnsafeSlow=r,u.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==u.prototype},u.compare=function(e,t){if(M(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),M(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var n=e.length,o=t.length,i=0,a=Math.min(n,o);i<a;++i)if(e[i]!==t[i]){n=e[i],o=t[i];break}return n<o?-1:o<n?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);if(void 0===t)for(i=t=0;i<e.length;++i)t+=e[i].length;for(var n=u.allocUnsafe(t),o=0,i=0;i<e.length;++i){var a=e[i];if(M(a,Uint8Array)&&(a=u.from(a)),!u.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(n,o),o+=a.length}return n},u.byteLength=h,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)n(this,t,t+1);return this},u.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)n(this,t,t+3),n(this,t+1,t+2);return this},u.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)n(this,t,t+7),n(this,t+1,t+6),n(this,t+2,t+5),n(this,t+3,t+4);return this},u.prototype.toLocaleString=u.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?C(this,0,e):function(e,t,n){var o,i=!1;if((t=void 0===t||t<0?0:t)>this.length)return"";if((n=void 0===n||n>this.length?this.length:n)<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":var a=this,r=t,s=n,c=a.length;(!s||s<0||c<s)&&(s=c);for(var l="",d=r=!r||r<0?0:r;d<s;++d)l+=function(e){return e<16?"0"+e.toString(16):e.toString(16)}(a[d]);return l;case"utf8":case"utf-8":return C(this,t,n);case"ascii":var u=this,c=t,f=n,p="";f=Math.min(u.length,f);for(var h=c;h<f;++h)p+=String.fromCharCode(127&u[h]);return p;case"latin1":case"binary":var m=this,r=t,g=n,v="";g=Math.min(m.length,g);for(var y=r;y<g;++y)v+=String.fromCharCode(m[y]);return v;case"base64":return b=this,o=n,0===(_=t)&&o===b.length?x.fromByteArray(b):x.fromByteArray(b.slice(_,o));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":for(var b=t,_=n,w=this.slice(b,_),S="",T=0;T<w.length;T+=2)S+=String.fromCharCode(w[T]+256*w[T+1]);return S;default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}.apply(this,arguments)},u.prototype.equals=function(e){if(u.isBuffer(e))return this===e||0===u.compare(this,e);throw new TypeError("Argument must be a Buffer")},u.prototype.inspect=function(){var e="",t=O.INSPECT_MAX_BYTES,e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim();return this.length>t&&(e+=" ... "),"<Buffer "+e+">"},u.prototype.compare=function(e,t,n,o,i){if(M(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===n&&(n=e?e.length:0),void 0===o&&(o=0),void 0===i&&(i=this.length),(t=void 0===t?0:t)<0||n>e.length||o<0||i>this.length)throw new RangeError("out of range index");if(i<=o&&n<=t)return 0;if(i<=o)return-1;if(n<=t)return 1;if(this===e)return 0;for(var a=(i>>>=0)-(o>>>=0),r=(n>>>=0)-(t>>>=0),s=Math.min(a,r),c=this.slice(o,i),l=e.slice(t,n),d=0;d<s;++d)if(c[d]!==l[d]){a=c[d],r=l[d];break}return a<r?-1:r<a?1:0},u.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},u.prototype.indexOf=function(e,t,n){return s(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return s(this,e,t,n,!1)},u.prototype.write=function(e,t,n,o){if(void 0===t)o="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)o=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(n)?(n>>>=0,void 0===o&&(o="utf8")):(o=n,n=void 0)}var i=this.length-t;if((void 0===n||i<n)&&(n=i),0<e.length&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o=o||"utf8";for(var a,r,s,c,l,d=!1;;)switch(o){case"hex":var u=this,f=e,p=t,h=n,m=(p=Number(p)||0,u.length-p);(!h||(h=Number(h))>m)&&(h=m),(m=f.length)/2<h&&(h=m/2);for(var g=0;g<h;++g){var v=parseInt(f.substr(2*g,2),16);if(R(v))return g;u[p+g]=v}return g;case"utf8":case"utf-8":return m=t,l=n,E(S(e,(c=this).length-m),c,m,l);case"ascii":return y(this,e,t,n);case"latin1":case"binary":return y(this,e,t,n);case"base64":return c=this,l=t,s=n,E(T(e),c,l,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=t,r=n,E(function(e,t){for(var n,o,i=[],a=0;a<e.length&&!((t-=2)<0);++a)o=(n=e.charCodeAt(a))>>8,i.push(n%256),i.push(o);return i}(e,(a=this).length-s),a,s,r);default:if(d)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),d=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var g=4096;function l(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(n<e+t)throw new RangeError("Trying to access beyond buffer length")}function m(e,t,n,o,i,a){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(i<t||t<a)throw new RangeError('"value" argument is out of bounds');if(n+o>e.length)throw new RangeError("Index out of range")}function v(e,t,n,o){if(n+o>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function b(e,t,n,o,i){return t=+t,n>>>=0,i||v(e,0,n,4),a.write(e,t,n,o,23,4),n+4}function _(e,t,n,o,i){return t=+t,n>>>=0,i||v(e,0,n,8),a.write(e,t,n,o,52,8),n+8}u.prototype.slice=function(e,t){var n=this.length,n=((e=~~e)<0?(e+=n)<0&&(e=0):n<e&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):n<t&&(t=n),t<e&&(t=e),this.subarray(e,t));return n.__proto__=u.prototype,n},u.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||l(e,t,this.length);for(var o=this[e],i=1,a=0;++a<t&&(i*=256);)o+=this[e+a]*i;return o},u.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||l(e,t,this.length);for(var o=this[e+--t],i=1;0<t&&(i*=256);)o+=this[e+--t]*i;return o},u.prototype.readUInt8=function(e,t){return e>>>=0,t||l(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||l(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||l(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||l(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return e>>>=0,t||l(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||l(e,t,this.length);for(var o=this[e],i=1,a=0;++a<t&&(i*=256);)o+=this[e+a]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},u.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||l(e,t,this.length);for(var o=t,i=1,a=this[e+--o];0<o&&(i*=256);)a+=this[e+--o]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*t)),a},u.prototype.readInt8=function(e,t){return e>>>=0,t||l(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||l(e,2,this.length);t=this[e]|this[e+1]<<8;return 32768&t?4294901760|t:t},u.prototype.readInt16BE=function(e,t){e>>>=0,t||l(e,2,this.length);t=this[e+1]|this[e]<<8;return 32768&t?4294901760|t:t},u.prototype.readInt32LE=function(e,t){return e>>>=0,t||l(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e>>>=0,t||l(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return e>>>=0,t||l(e,4,this.length),a.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||l(e,4,this.length),a.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||l(e,8,this.length),a.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||l(e,8,this.length),a.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,n,o){e=+e,t>>>=0,n>>>=0,o||m(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,a=0;for(this[t]=255&e;++a<n&&(i*=256);)this[t+a]=e/i&255;return t+n},u.prototype.writeUIntBE=function(e,t,n,o){e=+e,t>>>=0,n>>>=0,o||m(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,a=1;for(this[t+i]=255&e;0<=--i&&(a*=256);)this[t+i]=e/a&255;return t+n},u.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||m(this,e,t,1,255,0),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||m(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||m(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||m(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||m(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},u.prototype.writeIntLE=function(e,t,n,o){e=+e,t>>>=0,o||m(this,e,t,n,(o=Math.pow(2,8*n-1))-1,-o);var i=0,a=1,r=0;for(this[t]=255&e;++i<n&&(a*=256);)e<0&&0===r&&0!==this[t+i-1]&&(r=1),this[t+i]=(e/a>>0)-r&255;return t+n},u.prototype.writeIntBE=function(e,t,n,o){e=+e,t>>>=0,o||m(this,e,t,n,(o=Math.pow(2,8*n-1))-1,-o);var i=n-1,a=1,r=0;for(this[t+i]=255&e;0<=--i&&(a*=256);)e<0&&0===r&&0!==this[t+i+1]&&(r=1),this[t+i]=(e/a>>0)-r&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||m(this,e,t,1,127,-128),this[t]=255&(e=e<0?255+e+1:e),t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||m(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||m(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||m(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||m(this,e,t,4,2147483647,-2147483648),this[t]=(e=e<0?4294967295+e+1:e)>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},u.prototype.writeFloatLE=function(e,t,n){return b(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return b(this,e,t,!1,n)},u.prototype.writeDoubleLE=function(e,t,n){return _(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return _(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,o){if(!u.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n=n||0,o||0===o||(o=this.length),t>=e.length&&(t=e.length),(o=0<o&&o<n?n:o)===n)return 0;if(0===e.length||0===this.length)return 0;if((t=t||0)<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length);var i=(o=e.length-t<o-n?e.length-t+n:o)-n;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,n,o);else if(this===e&&n<t&&t<o)for(var a=i-1;0<=a;--a)e[a+t]=this[a+n];else Uint8Array.prototype.set.call(e,this.subarray(n,o),t);return i},u.prototype.fill=function(e,t,n,o){if("string"==typeof e){if("string"==typeof t?(o=t,t=0,n=this.length):"string"==typeof n&&(o=n,n=this.length),void 0!==o&&"string"!=typeof o)throw new TypeError("encoding must be a string");if("string"==typeof o&&!u.isEncoding(o))throw new TypeError("Unknown encoding: "+o);var i;1===e.length&&(i=e.charCodeAt(0),("utf8"===o&&i<128||"latin1"===o)&&(e=i))}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var a;if(t>>>=0,n=void 0===n?this.length:n>>>0,"number"==typeof(e=e||0))for(a=t;a<n;++a)this[a]=e;else{var r=u.isBuffer(e)?e:u.from(e,o),s=r.length;if(0===s)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(a=0;a<n-t;++a)this[a+t]=r[a%s]}return this};var w=/[^+/0-9A-Za-z-_]/g;function S(e,t){var n;t=t||1/0;for(var o=e.length,i=null,a=[],r=0;r<o;++r){if(55295<(n=e.charCodeAt(r))&&n<57344){if(!i){if(56319<n){-1<(t-=3)&&a.push(239,191,189);continue}if(r+1===o){-1<(t-=3)&&a.push(239,191,189);continue}i=n;continue}if(n<56320){-1<(t-=3)&&a.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&-1<(t-=3)&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return a}function T(e){return x.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(w,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function E(e,t,n,o){for(var i=0;i<o&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function M(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function R(e){return e!=e}}.call(this)}.call(this,A("buffer").Buffer)},{"base64-js":2,buffer:3,ieee754:4}],4:[function(e,t,n){n.read=function(e,t,n,o,i){var a,r,s=8*i-o-1,c=(1<<s)-1,l=c>>1,d=-7,u=n?i-1:0,f=n?-1:1,i=e[t+u];for(u+=f,a=i&(1<<-d)-1,i>>=-d,d+=s;0<d;a=256*a+e[t+u],u+=f,d-=8);for(r=a&(1<<-d)-1,a>>=-d,d+=o;0<d;r=256*r+e[t+u],u+=f,d-=8);if(0===a)a=1-l;else{if(a===c)return r?NaN:1/0*(i?-1:1);r+=Math.pow(2,o),a-=l}return(i?-1:1)*r*Math.pow(2,a-o)},n.write=function(e,t,n,o,i,a){var r,s,c=8*a-i-1,l=(1<<c)-1,d=l>>1,u=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=o?0:a-1,p=o?1:-1,a=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,r=l):(r=Math.floor(Math.log(t)/Math.LN2),t*(o=Math.pow(2,-r))<1&&(r--,o*=2),2<=(t+=1<=r+d?u/o:u*Math.pow(2,1-d))*o&&(r++,o/=2),l<=r+d?(s=0,r=l):1<=r+d?(s=(t*o-1)*Math.pow(2,i),r+=d):(s=t*Math.pow(2,d-1)*Math.pow(2,i),r=0));8<=i;e[n+f]=255&s,f+=p,s/=256,i-=8);for(r=r<<i|s,c+=i;0<c;e[n+f]=255&r,f+=p,r/=256,c-=8);e[n+f-p]|=128*a}},{}]},{},[1])},null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,function(e,t,n){var o;!function(){"use strict";var a={}.hasOwnProperty;function r(){for(var e=[],t=0;t<arguments.length;t++){var n=arguments[t];if(n){var o=typeof n;if("string"==o||"number"==o)e.push(this&&this[n]||n);else if(Array.isArray(n))e.push(r.apply(this,n));else if("object"==o)for(var i in n)a.call(n,i)&&n[i]&&e.push(this&&this[i]||i)}}return e.join(" ")}e.exports?e.exports=r.default=r:void 0!==(o=function(){return r}.apply(t,[]))&&(e.exports=o)}()},function(e){e.exports={"ejs-wrapper":"ejs--de6433374cb30211f10e148b320b2f",ejs:"ejs--7a5f920ceffb2913f6dbda780573cf","ejs--full-ui":"ejs--f3a002bba9836fe4ebfed357a45521","controls-tabs":"ejs--008adea3c1ef33a8fc94892a1e97e6",overlay:"ejs--85a95eb6bf74a40ab61b91a91e5bff","key-setting-popup":"ejs--d169a219343bc32dd4aecc3f6b7f25","loading-info":"ejs--782e3572812f983b3a150eec177391",p1:"ejs--c426dd1d179aa351e6cec47e1d9438",p2:"ejs--31e7e81db48819ee35ec6f50378a2e",p3:"ejs--20d4eb2646d396f558a645dc0574f1",p4:"ejs--4de05306c8b099bdeb4585571ac095",ejs__contextmenu:"ejs--c7957d8666bb6b8fc7c3e9c021aaf8",ad:"ejs--cbcfe0a1421cadac9a04c81d6431d6","close-ad":"ejs--f3a1903d935f6cf720d4a0498db62a","start-game":"ejs--73f9b4e94a7a1fe74e11107d5ab2ef",pulse:"ejs--9bd947b3e6427453595f083d740a7c",ejs__control:"ejs--8732295ca5c4902a060d34706a8146","ejs__tab-focus":"ejs--a83b6c705e103e81a7762d0ed5e64b","ejs__control--pressed":"ejs--b1238136ec472a92297159882cf4b8","icon--pressed":"ejs--ec731619062226d943da67f5d83009","icon--not-pressed":"ejs--dc7068585e3d84fe0e676864c1439e","label--pressed":"ejs--0c6561f9155750b0aeeed6da5da7bf","label--not-pressed":"ejs--13d64e30c1333cc99391af48ddabaa","ejs--video":"ejs--d5f430a99a1619b3434bf58e34a99c",ejs__controls:"ejs--1acedc5ed6816abe96dd27d910fd74",ejs__progress:"ejs--f1aa376719b564cae0e653157cde14",ejs__time:"ejs--90d2780f99bcc76fdb6b0378a7238e",ejs__menu:"ejs--c7bfb2d1b75a40fdaaf90624bea9e7",ejs__volume:"ejs--36ceeeec0df37a9cf4bbe05fa204ec","ejs--hide-controls":"ejs--1b8cb7f2294b1eb5de5238daea3513","ejs--fullscreen-enabled":"ejs--19409fe2057ab935a7e46abb5b4f49",ejs__tooltip:"ejs--74c6d4176d27e37a19d2e9e61de8f4",ejs__menu__container:"ejs--013213afedeeb6878089b1ca1b4e47","ejs-popup":"ejs--c2532bfe04554193cc42b3be753700","ejs__control--forward":"ejs--0b4cdb4057d1a4623e60836ccc6275","ejs__control--back":"ejs--a7ad9de0cb0ca672b6703c50de7db9",ejs__menu__value:"ejs--f91e90fe7cabc875aff9a431bf5389","ejs__tooltip--visible":"ejs--6ea27aa07e60d1d6e4c9782740028a","ejs--menu-open":"ejs--da54136ccf8c6b0b16d98e8b8e8b88","ejs__video-wrapper":"ejs--057800d021995e1347ec07cb748672",portrait:"ejs--64f1256f556fb94454b930cb3ea7f2","game-started":"ejs--7da7949f602347007818e6d192eb23",ejs__progress__buffer:"ejs--f8d706413436fd119cf01aaf5a9d9d","ejs--audio":"ejs--bd0222e58d71b0a304d6037dfcffd5","ejs--loading":"ejs--2521e1257996f264de36e77cc9c5ee",ejs__dialogs:"ejs--d31688f864f56d6426ebbf2217d6ee",ejs__dialog:"ejs--5e71fd80268afbb1d588e40b993508",ejs__cache__container:"ejs--1e0f0672f67d0e96592314c9ed78b0",ejs__loading__container:"ejs--d7e6a6a8f38bfaa256fe5d709a8258","ejs__load-state__container":"ejs--b183f581b5336c4908ad258d3e1cc7",ejs__screenRecord__container:"ejs--b183f581b5336cashrqd258d3e1cc7",ejs__netplay__container:"ejs--158ea9dd34e3e7af2d837f8b05babb",ejs__gamepad__container:"ejs--3f0897a8158ba363a0ee0afe4da7c5","dialog-container":"ejs--38cc09882a55e98c76168dbe838aa0","dialog-title":"ejs--b373c9d5029d49324fb8ac3ece96c1","dialog-content":"ejs--a5e2629abb9a5bcbc8b2c1307922d2","dialog-buttons":"ejs--580e3c22e63f8a1eb29694fd0b141b","btn-cancel":"ejs--ad20569e1449d7b8e99e6465960456","btn-reset":"ejs--ad20569e1449d7b8e99e6465963825","btn-clear":"ejs--ad20569e1449d7b8e99e6468571053","btn-close":"ejs--iehanqurh382hriwqoriuehqr83hq9",tabs:"ejs--8e7922427f460a31935084b7acfb1a",active:"ejs--68d337c212ec6a5bc43125440d422b","tabs-content":"ejs--31eb28817642bb1bfe0a2c422108bb","tabs-panel":"ejs--f932566a0af5314da834324c901978","button-container":"ejs--c233fb69cbef43078bc39e9d1efac8","btn-submit":"ejs--bdb54e9fc47f9805b506b746e897bf","btn-create-room":"ejs--67d03ee7480b871ad6507d6319a839","btn-quit":"ejs--c2d931157456c1d438d40a2f66af2c",set:"ejs--6604c83041a275a78837c452a71dd8","btn-join-room":"ejs--99150e15f962c63c689cadc81ef40d","netplay-player-name":"ejs--71527b6509aa48afce3ce1a11c02f0","netplay-player-name-input":"ejs--7ad35768e3f6b9faf97db01d5b60ae","netplay-player-name-set":"ejs--9c403e5e107a3e4374ba244b636400","netplay-roomlist":"ejs--d6a46533fa6e510a571af5c28b440a","netplay-create-room":"ejs--57ca9b3853cc7de731483cfcc95a59","netplay-room-name-input":"ejs--0885d5e25e19127b6b516014426a1b","netplay-room-password-input":"ejs--25023d28756fdb9dfbbfb6dccb8677","netplay-create-room-set":"ejs--75b3a8d35aacc6424ed7422fdeaaaa","netplay-room":"ejs--eefdf28d69ed2d20f197308981bb61","cheats-add":"ejs--9e670880bb57e824400fa00f09aaad","cheats-list":"ejs--2b4e3c245b7b25dfdac5e09155a68e","cheat-code-input":"ejs--572b0b3a0345a6b01b01a15a02842c","cheat-name-input":"ejs--a7d7f80c8999469c991ea452a85dd9",ejs__widgets:"ejs--952c974392296e7f643d51db380157",ejs__widget:"ejs--0d7e216cf12ae73705b5d5bb0452fc",ejs__widget_controls_toggle:"ejs--666d4296310579687cf3cf3d2cf951",ejs__widget_netplay:"ejs--c0a5e71f6613caab66d6ae15a5a00f","virtual-gamepad":"ejs--2440e3b831017ff8327c939e2a4413",top:"ejs--b8d8b771d0bbb94e2bbd03054f53fd",left:"ejs--c83d70cb63c933edc073c7fe92e32b",buttons:"ejs--6e7015634623fd6a82e6a7d3488c84",center:"ejs--49fa47c86a131e4ca8fb268bfdde89",right:"ejs--7d2b19f77fd0ccabf94dc1ca39ae18",touch:"ejs--d708d9d486f1eca73a593d5c09f8ad",modal:"ejs--eefec939452eb92fad035932d0f47c",modal__overlay:"ejs--f1f43b27384834c8c22c6f81d0c5ae",modal__container:"ejs--c4ee33766a01ed0356c3ec07898e96",modal__header:"ejs--a073f32023da1ced805c5f95a4e81c",modal__footer:"ejs--ed44f59bb8cd49177586b140658c6c",modal__title:"ejs--81470ba5e6a6d68014839ad4d9a977",modal__close:"ejs--c3c85789c2a7f56d8b26dba75b7e1f",modal__content:"ejs--db44f5520e6f4fd0dd34b478bb9ee8",modal__btn:"ejs--319bcec5dee9444e1a2a53d6503b7c","modal__btn-primary":"ejs--eaf3c1cba25d415d92ac48d7db34dd",modal__errmsg:"ejs--940087708c06b6129ce2bfa45f1d89","micromodal-slide":"ejs--bef295f3125e9ba83d4f3677264bae","is-open":"ejs--60c17e0d149099f207b06f27edae6a",mmfadeIn:"ejs--9d7aa2bd5ee276be085e5b2a0bbc2e",mmslideIn:"ejs--8b069266f76099cc6bc220f6ea56cc",mmfadeOut:"ejs--184b7558ffeb569c1790654537477b",mmslideOut:"ejs--379a464ad0e66ea5fc601e5f2fd73e","ejs-switch":"ejs--4c3e63d4005bd8a0468e9c74a35f62","ejs-delete-cheat":"ejs--90bcdd71cd0d2307e9ee0dffa916da","icon--exit-fullscreen":"ejs--2b3dd6e2e26c0f0dc4ac5779dedd5e","ejs--fullscreen-fallback":"ejs--412041671de21945d3e028b6ae84c9","ejs--no-transition":"ejs--33643265135cf89e6c0a0d9866d6f1","ejs__sr-only":"ejs--6f0e996cd15e5fb6be0256918531d7","ejs-fade-in":"ejs--7cadf43f3d9eb17c7e3c36de84973b","dpad-container":"ejs--914358605501b11476e86626b2ff16","dpad-bg":"ejs--be66239219d594001da38f91c9ad02","dpad-front":"ejs--9dbb9be3403878e912527181e2d41b","dpad-1":"ejs--f9c7797bdf05569bdc13b4f2074270","dpad-2":"ejs--2645f3bad105488a313c5e30dab74f","dpad-1-bg":"ejs--a57cf324c8ff108947112e35e589b5","dpad-2-bg":"ejs--4873d94c18140ab195da609b40b71a","dpad-left":"ejs--bd9311b0a4f654af6ab5ba28bcf358","dpad-right":"ejs--704d45ea060cc6809451a0d9d47ad7","dpad-up":"ejs--f0b89ca5b5621659af184c8e012ccb","dpad-down":"ejs--8de361d6b01eaa181f8db4ac3eb7af"}},function(e,t,n){var o;function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}o=function(){function e(){}function c(e,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=e,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1},this.config(t),"dynamic"===this.options.mode&&(this.options.restOpacity=0),this.id=c.id,c.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}function o(e,t){var n=this;return n.nipples=[],n.idles=[],n.actives=[],n.ids=[],n.pressureIntervals={},n.manager=e,n.id=o.id,o.id+=1,n.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,lockX:!1,lockY:!1},n.config(t),"static"!==n.options.mode&&"semi"!==n.options.mode||(n.options.multitouch=!1),n.options.multitouch||(n.options.maxNumberOfNipples=1),n.updateBox(),n.prepareNipples(),n.bindings(),n.begin(),n.nipples}function t(e){var t,o=this;return o.ids={},o.index=0,o.collections=[],o.config(e),o.prepareCollections(),u.bindEvt(window,"resize",function(e){clearTimeout(t),t=setTimeout(function(){var t,n=u.getScroll();o.collections.forEach(function(e){e.forEach(function(e){t=e.el.getBoundingClientRect(),e.position={x:n.x+t.left,y:n.y+t.top}})})},100)}),o.collections}var i,n=!!("ontouchstart"in window),a=!!window.PointerEvent,r=!!window.MSPointerEvent,s={start:"mousedown",move:"mousemove",end:"mouseup"},l={},u=(a?i={start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"}:r?i={start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:n?(i={start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},l=s):i=s,{distance:function(e,t){var n=t.x-e.x,t=t.y-e.y;return Math.sqrt(n*n+t*t)},angle:function(e,t){var n=t.x-e.x,t=t.y-e.y;return u.degrees(Math.atan2(t,n))},findCoord:function(e,t,n){var o={x:0,y:0};return n=u.radians(n),o.x=e.x-t*Math.cos(n),o.y=e.y-t*Math.sin(n),o},radians:function(e){return e*(Math.PI/180)},degrees:function(e){return e*(180/Math.PI)},bindEvt:function(e,t,n){for(var o,i=t.split(/[ ,]+/g),a=0;a<i.length;a+=1)o=i[a],e.addEventListener?e.addEventListener(o,n,!1):e.attachEvent&&e.attachEvent(o,n)},unbindEvt:function(e,t,n){for(var o,i=t.split(/[ ,]+/g),a=0;a<i.length;a+=1)o=i[a],e.removeEventListener?e.removeEventListener(o,n):e.detachEvent&&e.detachEvent(o,n)},trigger:function(e,t,n){t=new CustomEvent(t,n);e.dispatchEvent(t)},prepareEvent:function(e){return e.preventDefault(),e.type.match(/^touch/)?e.changedTouches:e},getScroll:function(){return{x:void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,y:void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop}},applyPosition:function(e,t){t.top||t.right||t.bottom||t.left?(e.style.top=t.top,e.style.right=t.right,e.style.bottom=t.bottom,e.style.left=t.left):(e.style.left=t.x+"px",e.style.top=t.y+"px")},getTransitionStyle:function(e,t,n){var o,i=u.configStylePropertyObject(e);for(o in i)if(i.hasOwnProperty(o))if("string"==typeof t)i[o]=t+" "+n;else{for(var a="",r=0,s=t.length;r<s;r+=1)a+=t[r]+" "+n+", ";i[o]=a.slice(0,-2)}return i},getVendorStyle:function(e,t){var n,o=u.configStylePropertyObject(e);for(n in o)o.hasOwnProperty(n)&&(o[n]=t);return o},configStylePropertyObject:function(t){var n={};return n[t]="",["webkit","Moz","o"].forEach(function(e){n[e+t.charAt(0).toUpperCase()+t.slice(1)]=""}),n},extend:function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},safeExtend:function(e,t){var n,o={};for(n in e)e.hasOwnProperty(n)&&t.hasOwnProperty(n)?o[n]=t[n]:e.hasOwnProperty(n)&&(o[n]=e[n]);return o},map:function(e,t){if(e.length)for(var n=0,o=e.length;n<o;n+=1)t(e[n]);else t(e)}}),d=(e.prototype.on=function(e,t){var n,o=this,i=e.split(/[ ,]+/g);o._handlers_=o._handlers_||{};for(var a=0;a<i.length;a+=1)n=i[a],o._handlers_[n]=o._handlers_[n]||[],o._handlers_[n].push(t);return o},e.prototype.off=function(e,t){var n=this;return n._handlers_=n._handlers_||{},void 0===e?n._handlers_={}:void 0===t?n._handlers_[e]=null:n._handlers_[e]&&0<=n._handlers_[e].indexOf(t)&&n._handlers_[e].splice(n._handlers_[e].indexOf(t),1),n},e.prototype.trigger=function(e,t){var n,o=this,i=e.split(/[ ,]+/g);o._handlers_=o._handlers_||{};for(var a=0;a<i.length;a+=1)n=i[a],o._handlers_[n]&&o._handlers_[n].length&&o._handlers_[n].forEach(function(e){e.call(o,{type:n,target:o},t)})},e.prototype.config=function(e){this.options=this.defaults||{},e&&(this.options=u.safeExtend(this.options,e))},e.prototype.bindEvt=function(e,t){var n=this;return n._domHandlers_=n._domHandlers_||{},n._domHandlers_[t]=function(){"function"==typeof n["on"+t]?n["on"+t].apply(n,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},u.bindEvt(e,i[t],n._domHandlers_[t]),l[t]&&u.bindEvt(e,l[t],n._domHandlers_[t]),n},e.prototype.unbindEvt=function(e,t){var n=this;return n._domHandlers_=n._domHandlers_||{},u.unbindEvt(e,i[t],n._domHandlers_[t]),l[t]&&u.unbindEvt(e,l[t],n._domHandlers_[t]),delete n._domHandlers_[t],this},c.prototype=new e,(c.constructor=c).id=0,c.prototype.buildEl=function(e){return this.ui={},this.options.dataOnly||(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front)),this},c.prototype.stylize=function(){if(this.options.dataOnly)return this;var e=this.options.fadeTime+"ms",t=u.getVendorStyle("borderRadius","50%"),e=u.getTransitionStyle("transition","opacity",e),n={};return n.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},n.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:this.options.color,opacity:".5"},n.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:this.options.color,opacity:".5"},u.extend(n.el,e),u.extend(n.back,t),u.extend(n.front,t),this.applyStyles(n),this},c.prototype.applyStyles=function(e){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var n in e[t])this.ui[t].style[n]=e[t][n];return this},c.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)||this.options.zone.appendChild(this.ui.el),this},c.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)||this.options.zone.removeChild(this.ui.el),this},c.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()},c.prototype.show=function(e){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),"function"==typeof e&&e.call(this)},t.options.fadeTime)),t},c.prototype.hide=function(t){var n=this;return n.options.dataOnly||(n.ui.el.style.opacity=n.options.restOpacity,clearTimeout(n.removeTimeout),clearTimeout(n.showTimeout),clearTimeout(n.restTimeout),n.removeTimeout=setTimeout(function(){var e="dynamic"===n.options.mode?"none":"block";n.ui.el.style.display=e,"function"==typeof t&&t.call(n),n.trigger("hidden",n.instance)},n.options.fadeTime),n.options.restJoystick&&n.restPosition()),n},c.prototype.restPosition=function(e){var t=this,n=(t.frontPosition={x:0,y:0},t.options.fadeTime+"ms"),o={},n=(o.front=u.getTransitionStyle("transition",["top","left"],n),{front:{}});n.front={left:t.frontPosition.x+"px",top:t.frontPosition.y+"px"},t.applyStyles(o),t.applyStyles(n),t.restTimeout=setTimeout(function(){"function"==typeof e&&e.call(t),t.restCallback()},t.options.fadeTime)},c.prototype.restCallback=function(){var e={};e.front=u.getTransitionStyle("transition","none",""),this.applyStyles(e),this.trigger("rested",this.instance)},c.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}},c.prototype.computeDirection=function(e){var t,n,o,i=e.angle.radian,a=Math.PI/4,r=Math.PI/2;if(a<i&&i<3*a&&!e.lockX?t="up":-a<i&&i<=a&&!e.lockY?t="left":3*-a<i&&i<=-a&&!e.lockX?t="down":e.lockY||(t="right"),e.lockY||(n=-r<i&&i<r?"left":"right"),e.lockX||(o=0<i?"up":"down"),e.force>this.options.threshold){var s={};for(c in this.direction)this.direction.hasOwnProperty(c)&&(s[c]=this.direction[c]);var c,l={};for(c in this.direction={x:n,y:o,angle:t},e.direction=this.direction,s)s[c]===this.direction[c]&&(l[c]=!0);if(l.x&&l.y&&l.angle)return e;l.x&&l.y||this.trigger("plain",e),l.x||this.trigger("plain:"+n,e),l.y||this.trigger("plain:"+o,e),l.angle||this.trigger("dir dir:"+t,e)}return e},o.prototype=new e,(o.constructor=o).id=0,o.prototype.prepareNipples=function(){var e=this,o=e.nipples;o.on=e.on.bind(e),o.off=e.off.bind(e),o.options=e.options,o.destroy=e.destroy.bind(e),o.ids=e.ids,o.id=e.id,o.processOnMove=e.processOnMove.bind(e),o.processOnEnd=e.processOnEnd.bind(e),o.get=function(e){if(void 0===e)return o[0];for(var t=0,n=o.length;t<n;t+=1)if(o[t].identifier===e)return o[t];return!1}},o.prototype.bindings=function(){this.bindEvt(this.options.zone,"start"),this.options.zone.style.touchAction="none",this.options.zone.style.msTouchAction="none"},o.prototype.begin=function(){var e=this.options;"static"===e.mode&&((e=this.createNipple(e.position,this.manager.getIdentifier())).add(),this.idles.push(e))},o.prototype.createNipple=function(e,t){var n,o=this,i=u.getScroll(),a={},r=o.options,s=(e.x&&e.y?a={x:e.x-(i.x+o.box.left),y:e.y-(i.y+o.box.top)}:(e.top||e.right||e.bottom||e.left)&&((s=document.createElement("DIV")).style.display="hidden",s.style.top=e.top,s.style.right=e.right,s.style.bottom=e.bottom,s.style.left=e.left,s.style.position="absolute",r.zone.appendChild(s),n=s.getBoundingClientRect(),r.zone.removeChild(s),a=e,e={x:n.left+i.x,y:n.top+i.y}),new c(o,{color:r.color,size:r.size,threshold:r.threshold,fadeTime:r.fadeTime,dataOnly:r.dataOnly,restJoystick:r.restJoystick,restOpacity:r.restOpacity,mode:r.mode,identifier:t,position:e,zone:r.zone,frontPosition:{x:0,y:0}}));return r.dataOnly||(u.applyPosition(s.ui.el,a),u.applyPosition(s.ui.front,s.frontPosition)),o.nipples.push(s),o.trigger("added "+s.identifier+":added",s),o.manager.trigger("added "+s.identifier+":added",s),o.bindNipple(s),s},o.prototype.updateBox=function(){this.box=this.options.zone.getBoundingClientRect()},o.prototype.bindNipple=function(e){function t(e,t){n=e.type+" "+t.id+":"+e.type,o.trigger(n,t)}var n,o=this;e.on("destroyed",o.onDestroyed.bind(o)),e.on("shown hidden rested dir plain",t),e.on("dir:up dir:right dir:down dir:left",t),e.on("plain:up plain:right plain:down plain:left",t)},o.prototype.pressureFn=function(t,n,e){var o=this,i=0;clearInterval(o.pressureIntervals[e]),o.pressureIntervals[e]=setInterval(function(){var e=t.force||t.pressure||t.webkitForce||0;e!==i&&(n.trigger("pressure",e),o.trigger("pressure "+n.identifier+":pressure",e),i=e)}.bind(o),100)},o.prototype.onstart=function(e){var t=this,n=t.options;return e=u.prepareEvent(e),t.updateBox(),u.map(e,function(e){t.actives.length<n.maxNumberOfNipples&&t.processOnStart(e)}),t.manager.bindDocument(),!1},o.prototype.processOnStart=function(t){function e(e){e.trigger("start",e),n.trigger("start "+e.id+":start",e),e.show(),0<a&&n.pressureFn(t,e,e.identifier),n.processOnMove(t)}var n=this,o=n.options,i=n.manager.getIdentifier(t),a=t.force||t.pressure||t.webkitForce||0,r={x:t.pageX,y:t.pageY},s=n.getOrCreate(i,r);s.identifier!==i&&n.manager.removeIdentifier(s.identifier),s.identifier=i;if(0<=(i=n.idles.indexOf(s))&&n.idles.splice(i,1),n.actives.push(s),n.ids.push(s.identifier),"semi"!==o.mode)e(s);else{if(!(u.distance(r,s.position)<=o.catchDistance))return s.destroy(),void n.processOnStart(t);e(s)}return s},o.prototype.getOrCreate=function(e,t){var n,o=this,i=o.options;return/(semi|static)/.test(i.mode)?(n=o.idles[0])?(o.idles.splice(0,1),n):"semi"===i.mode?o.createNipple(t,e):(console.warn("Coudln't find the needed nipple."),!1):o.createNipple(t,e)},o.prototype.processOnMove=function(e){var t=this,n=t.options,o=t.manager.getIdentifier(e),i=t.nipples.get(o);if(!i)return console.error("Found zombie joystick with ID "+o),void t.manager.removeIdentifier(o);i.identifier=o;var o=i.options.size/2,a={x:e.pageX,y:e.pageY},r=u.distance(a,i.position),s=u.angle(a,i.position),c=u.radians(s),l=r/o,o=(a=o<r?u.findCoord(i.position,r=o,s):a).x-i.position.x,d=a.y-i.position.y,o=(n.lockX&&(d=0),n.lockY&&(o=0),i.frontPosition={x:o,y:d},n.dataOnly||u.applyPosition(i.ui.front,i.frontPosition),{identifier:i.identifier,position:a,force:l,pressure:e.force||e.pressure||e.webkitForce||0,distance:r,angle:{radian:c,degree:s},instance:i,lockX:n.lockX,lockY:n.lockY});(o=i.computeDirection(o)).angle={radian:u.radians(180-s),degree:180-s},i.trigger("move",o),t.trigger("move "+i.id+":move",o)},o.prototype.processOnEnd=function(e){var t=this,n=t.options,e=t.manager.getIdentifier(e),o=t.nipples.get(e),e=t.manager.removeIdentifier(o.identifier);o&&(n.dataOnly||o.hide(function(){"dynamic"===n.mode&&(o.trigger("removed",o),t.trigger("removed "+o.id+":removed",o),t.manager.trigger("removed "+o.id+":removed",o),o.destroy())}),clearInterval(t.pressureIntervals[o.identifier]),o.resetDirection(),o.trigger("end",o),t.trigger("end "+o.id+":end",o),0<=t.ids.indexOf(o.identifier)&&t.ids.splice(t.ids.indexOf(o.identifier),1),0<=t.actives.indexOf(o)&&t.actives.splice(t.actives.indexOf(o),1),/(semi|static)/.test(n.mode)?t.idles.push(o):0<=t.nipples.indexOf(o)&&t.nipples.splice(t.nipples.indexOf(o),1),t.manager.unbindDocument(),/(semi|static)/.test(n.mode)&&(t.manager.ids[e.id]=e.identifier))},o.prototype.onDestroyed=function(e,t){var n=this;0<=n.nipples.indexOf(t)&&n.nipples.splice(n.nipples.indexOf(t),1),0<=n.actives.indexOf(t)&&n.actives.splice(n.actives.indexOf(t),1),0<=n.idles.indexOf(t)&&n.idles.splice(n.idles.indexOf(t),1),0<=n.ids.indexOf(t.identifier)&&n.ids.splice(n.ids.indexOf(t.identifier),1),n.manager.removeIdentifier(t.identifier),n.manager.unbindDocument()},o.prototype.destroy=function(){var e,t=this;for(e in t.unbindEvt(t.options.zone,"start"),t.nipples.forEach(function(e){e.destroy()}),t.pressureIntervals)t.pressureIntervals.hasOwnProperty(e)&&clearInterval(t.pressureIntervals[e]);t.trigger("destroyed",t.nipples),t.manager.unbindDocument(),t.off()},t.prototype=new e,(t.constructor=t).prototype.prepareCollections=function(){var e=this;e.collections.create=e.create.bind(e),e.collections.on=e.on.bind(e),e.collections.off=e.off.bind(e),e.collections.destroy=e.destroy.bind(e),e.collections.get=function(t){var n;return e.collections.every(function(e){return!(n=e.get(t))}),n}},t.prototype.create=function(e){return this.createCollection(e)},t.prototype.createCollection=function(e){e=new o(this,e);return this.bindCollection(e),this.collections.push(e),e},t.prototype.bindCollection=function(e){function t(e,t){n=e.type+" "+t.id+":"+e.type,o.trigger(n,t)}var n,o=this;e.on("destroyed",o.onDestroyed.bind(o)),e.on("shown hidden rested dir plain",t),e.on("dir:up dir:right dir:down dir:left",t),e.on("plain:up plain:right plain:down plain:left",t)},t.prototype.bindDocument=function(){this.binded||(this.bindEvt(document,"move").bindEvt(document,"end"),this.binded=!0)},t.prototype.unbindDocument=function(e){Object.keys(this.ids).length&&!0!==e||(this.unbindEvt(document,"move").unbindEvt(document,"end"),this.binded=!1)},t.prototype.getIdentifier=function(e){var t;return e?void 0===(t=void 0===e.identifier?e.pointerId:e.identifier)&&(t=this.latest||0):t=this.index,void 0===this.ids[t]&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]},t.prototype.removeIdentifier=function(e){var t,n={};for(t in this.ids)if(this.ids[t]===e){n.id=t,n.identifier=this.ids[t],delete this.ids[t];break}return n},t.prototype.onmove=function(e){return this.onAny("move",e),!1},t.prototype.onend=function(e){return this.onAny("end",e),!1},t.prototype.oncancel=function(e){return this.onAny("end",e),!1},t.prototype.onAny=function(e,t){var n,o=this,i="processOn"+e.charAt(0).toUpperCase()+e.slice(1);t=u.prepareEvent(t);return u.map(t,function(e){n=o.getIdentifier(e),u.map(o.collections,function(e,t,n){0<=n.ids.indexOf(t)&&(n[i](e),e._found_=!0)}.bind(null,e,n)),e._found_||o.removeIdentifier(n)}),!1},t.prototype.destroy=function(){var e=this;e.unbindDocument(!0),e.ids={},e.index=0,e.collections.forEach(function(e){e.destroy()}),e.off()},t.prototype.onDestroyed=function(e,t){if(this.collections.indexOf(t)<0)return!1;this.collections.splice(this.collections.indexOf(t),1)},new t);return{create:function(e){return d.create(e)},factory:d}},"object"==i(t)&&void 0!==e?e.exports=o():void 0!==(t="function"==typeof(o=o)?o.apply(t,[]):o)&&(e.exports=t)},null,function(e,a,Ve){"use strict";!function(g,ze,De){function Ue(e){return(Ue="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function je(){var r=this,i=new e,n=(r.chunks={},r.users={},r.readAsArrayBuffer=function(t,n,e){var o={file:t,earlyCallback:function(e){n(s(e,{currentPosition:-1}))},extra:e||{userid:0}};t.extra&&Object.keys(t.extra).length&&Object.keys(t.extra).forEach(function(e){o.extra[e]=t.extra[e]}),i.readAsArrayBuffer(r,o)},r.getNextChunk=function(e,t,n){void 0!==e.currentPosition&&(i=e.currentPosition,e=e.uuid);var o=r.chunks[e];if(o){var i,a=o[i=void 0!==n?(r.users[n+""]||(r.users[n+""]={fileUUID:e,userid:n,currentPosition:-1}),void 0!==i&&(r.users[n+""].currentPosition=i),r.users[n+""].currentPosition++,r.users[n+""].currentPosition):(void 0!==i&&(r.chunks[e].currentPosition=i),r.chunks[e].currentPosition++,r.chunks[e].currentPosition)];if(!a)return delete r.chunks[e],void r.convertToArrayBuffer({chunkMissing:!0,currentPosition:i,uuid:e},t);a=s(a),void 0!==n&&(a.remoteUserId=n+""),a.start&&r.onBegin(a),a.end&&r.onEnd(a),r.onProgress(a),r.convertToArrayBuffer(a,function(e){a.currentPosition!=a.maxChunks?t(e,!1):t(e,!0)})}},new t(r));function s(e,t){if(null==e||"object"!=Ue(e))return e;if(e.constructor!=Object&&e.constructor!=Array)return e;if(e.constructor==Date||e.constructor==RegExp||e.constructor==Function||e.constructor==String||e.constructor==Number||e.constructor==Boolean)return new e.constructor(e);for(var n in t=t||new e.constructor,e)t[n]=void 0===t[n]?s(e[n],null):t[n];return t}r.addChunk=function(e,t){e&&n.receive(e,function(e){r.convertToArrayBuffer({readyForNextChunk:!0,currentPosition:e.currentPosition,uuid:e.uuid},t)})},r.chunkMissing=function(e){delete n.chunks[e.uuid],delete n.chunksWaiters[e.uuid]},r.onBegin=function(){},r.onEnd=function(){},r.onProgress=function(){},r.convertToObject=o.ConvertToObject,r.convertToArrayBuffer=o.ConvertToArrayBuffer,r.setMultipleUsers=function(){}}function e(){this.readAsArrayBuffer=function(t,n){var e,i,a,r,s,c,l,d,u,f,p,h,o=n.earlyCallback;delete n.earlyCallback,i=(i=function(e){t.chunks[e.uuid]||(t.chunks[e.uuid]={currentPosition:-1}),n.extra=n.extra||{userid:0},e.userid=n.userid||n.extra.userid||0,e.extra=n.extra,(t.chunks[e.uuid][e.currentPosition]=e).end&&o&&(o(e.uuid),o=null),200<e.maxChunks&&200==e.currentPosition&&o&&(o(e.uuid),o=null)})||function(e){postMessage(e)},(a=(e=n).file).uuid||(a.uuid=(100*Math.random()).toString().replace(/\./g,"")),r=e.chunkSize||15e3,e.extra&&e.extra.chunkSize&&(r=e.extra.chunkSize),c=0,e=r,l=Math.floor(Math.min(1e8,e)/r)*r,d=Math.ceil(a.size/r),a.maxChunks=d,f=[],i({currentPosition:u=0,uuid:a.uuid,maxChunks:d,size:a.size,name:a.name,type:a.type,lastModifiedDate:(a.lastModifiedDate||new Date).toString(),start:!0}),(h=new FileReader).onloadend=function(e){if(e.target.readyState==FileReader.DONE){a.name;var t=e.target.result;s=Math.ceil(t.byteLength/r);for(var n=0;n<s;n++){var o=n*r;f[u]=t.slice(o,Math.min(o+r,t.byteLength)),i({uuid:a.uuid,buffer:f[u],currentPosition:u,maxChunks:d,size:a.size,name:a.name,lastModifiedDate:(a.lastModifiedDate||new Date).toString(),type:a.type}),u++}(++c+1)*l<a.size?(p=a.slice(c*l,(c+1)*l),h.readAsArrayBuffer(p)):c*l<a.size?(p=a.slice(c*l,a.size),h.readAsArrayBuffer(p)):(a.url=URL.createObjectURL(a),i({currentPosition:u,uuid:a.uuid,maxChunks:d,size:a.size,name:a.name,lastModifiedDate:(a.lastModifiedDate||new Date).toString(),url:URL.createObjectURL(a),type:a.type,end:!0}))}},u+=1,p=a.slice(c*l,(c+1)*l),h.readAsArrayBuffer(p)}}function Be(){var a=this,r=function(){};function n(e,n,t){e=e||function(){};var o,i=document.createElement("input"),t=(i.type="file",n&&(i.multiple=!0),t&&(i.webkitdirectory=!0),i.accept=a.accept,i.onclick=function(){i.clickStarted=!0},document.body.onfocus=function(){setTimeout(function(){i.clickStarted&&(i.clickStarted=!1,i.value||r())},500)},i.onchange=function(){if(n){if(!i.files.length)return void console.error("No file selected.");var t=[];return Array.from(i.files).forEach(function(e){e.url=e.webkitRelativePath,t.push(e)}),void e(t)}i.files[0]?(e(i.files[0]),i.parentNode.removeChild(i)):console.error("No file selected.")},i.style.display="none",(document.body||document.documentElement).appendChild(i),i);"function"==typeof t.click?t.click():"function"==typeof t.change?t.change():(void 0!==document.createEvent("Event")&&"function"==typeof(o=document.createEvent("Event")).initEvent&&"function"==typeof t.dispatchEvent?o.initEvent("click",!0,!0):o=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0}),t.dispatchEvent(o))}a.selectSingleFile=function(e,t){t&&(r=t),n(e)},a.selectMultipleFiles=function(e,t){t&&(r=t),n(e,!0)},a.selectDirectory=function(e,t){t&&(r=t),n(e,!0,!0)},a.accept="*.*"}function t(r){var s=this;s.chunks={},s.chunksWaiters={},s.receive=function t(n,o){var i,a,e;n.uuid?(n.start&&!s.chunks[n.uuid]&&(s.chunks[n.uuid]={},r.onBegin&&r.onBegin(n)),!n.end&&n.buffer&&(s.chunks[n.uuid][n.currentPosition]=n.buffer),n.end&&(i=s.chunks[n.uuid],a=[],Object.keys(i).forEach(function(e,t){a.push(i[e])}),(e=Fe(e=new Blob(a,{type:n.type}),n)).url=URL.createObjectURL(e),e.uuid=n.uuid,e.size||console.error("Something went wrong. Blob Size is 0."),r.onEnd&&r.onEnd(e),delete s.chunks[n.uuid],delete s.chunksWaiters[n.uuid]),n.buffer&&r.onProgress&&r.onProgress(n),n.end||(o(n),s.chunksWaiters[n.uuid]=function(){setTimeout(function e(){n.buffer&&s.chunks[n.uuid]&&(n.currentPosition==n.maxChunks||s.chunks[n.uuid][n.currentPosition]||(o(n),setTimeout(e,5e3)))},5e3)},s.chunksWaiters[n.uuid]())):r.convertToObject(n,function(e){t(e)})}}var o={ConvertToArrayBuffer:function(e,t){i.pack(e,function(e){t(e.buffer)})},ConvertToObject:function(e,t){i.unpack(e,t)}};function Fe(e,t){if(e=e||{},!t)return e;for(var n in t)try{e[n]=t[n]}catch(e){}return e}function v(e,t){var n,o,i=0,a=e.getUint8(t,!1),r=(t+=y,a!==w.ARRAY&&a!==w.OBJECT||(c=e.getUint16(t,!1),t+=b),n=e.getUint32(t,!1),t+=_,S[a]),s=null===r?0:window[r+"Array"].BYTES_PER_ELEMENT;switch(a){case w.NULL:case w.UNDEFINED:p=null;break;case w.STRING:for(var c=n/s,l=[],i=0;i<c;i++){var d=e.getUint16(t,!1);t+=s,l.push(String.fromCharCode(d))}p=l.join("");break;case w.NUMBER:p=e.getFloat64(t,!1),t+=s;break;case w.BOOLEAN:p=1===e.getUint8(t,!1),t+=s;break;case w.INT8ARRAY:case w.INT16ARRAY:case w.INT32ARRAY:case w.UINT8ARRAY:case w.UINT16ARRAY:case w.UINT32ARRAY:case w.FLOAT32ARRAY:case w.FLOAT64ARRAY:case w.ARRAYBUFFER:o=e.buffer.slice(t,t+n),t+=n,p=a===w.ARRAYBUFFER?o:new window[r+"Array"](o);break;case w.BLOB:var u,f,p=window.Blob?(t=(f=v(e,(u=v(e,t)).cursor)).cursor,new Blob([f.value],{type:u.value})):(o=e.buffer.slice(t,t+n),t+=n,new g(o));break;case w.ARRAY:for(p=[],i=0;i<c;i++)t=(o=v(e,t)).cursor,p.push(o.value);break;case w.OBJECT:for(p={},i=0;i<c;i++){var h=v(e,t),m=v(e,h.cursor);t=m.cursor,p[h.value]=m.value}break;default:throw"TypeError: Type not supported."}return{value:p,cursor:t}}function f(e,i){for(var a=e.length,r=[],s=0,c=0,t=0;t<e.length;t++)!function(o){n(e[o],function(e){if(r[o]=e,c+=e[0].header_size+e[0].byte_length,++s===a){for(var t=[],n=0;n<r.length;n++)t=t.concat(r[n]);i(t,c)}})}(t)}var y=Uint8Array.BYTES_PER_ELEMENT,b=Uint16Array.BYTES_PER_ELEMENT,_=Uint32Array.BYTES_PER_ELEMENT,w={NULL:0,UNDEFINED:1,STRING:2,NUMBER:3,BOOLEAN:4,ARRAY:5,OBJECT:6,INT8ARRAY:7,INT16ARRAY:8,INT32ARRAY:9,UINT8ARRAY:10,UINT16ARRAY:11,UINT32ARRAY:12,FLOAT32ARRAY:13,FLOAT64ARRAY:14,ARRAYBUFFER:15,BLOB:16,FILE:16,BUFFER:17},S=[null,null,"Uint16","Float64","Uint8",null,null,"Int8","Int16","Int32","Uint8","Uint16","Uint32","Float32","Float64","Uint8","Uint8","Uint8"],n=function(n,o){var i=y+_,e=0,a=0,t=n,r=function(e){var t=void 0;if(void 0===e)t=w.UNDEFINED;else if(null===e)t=w.NULL;else{var n=e.constructor.name,o=e.constructor.toString().match(/\w+/g)[1];if(void 0!==n&&void 0!==w[n.toUpperCase()])t=w[n.toUpperCase()];else if(void 0!==o&&void 0!==w[o.toUpperCase()])t=w[o.toUpperCase()];else switch(Ue(e)){case"string":t=w.STRING;break;case"number":t=w.NUMBER;break;case"boolean":t=w.BOOLEAN;break;case"object":e instanceof Array?t=w.ARRAY:e instanceof Int8Array?t=w.INT8ARRAY:e instanceof Int16Array?t=w.INT16ARRAY:e instanceof Int32Array?t=w.INT32ARRAY:e instanceof Uint8Array?t=w.UINT8ARRAY:e instanceof Uint16Array?t=w.UINT16ARRAY:e instanceof Uint32Array?t=w.UINT32ARRAY:e instanceof Float32Array?t=w.FLOAT32ARRAY:e instanceof Float64Array?t=w.FLOAT64ARRAY:e instanceof ArrayBuffer?t=w.ARRAYBUFFER:e instanceof Blob?t=w.BLOB:e instanceof g?t=w.BUFFER:e instanceof Object&&(t=w.OBJECT)}}return t}(n),s=null==S[r]?0:window[S[r]+"Array"].BYTES_PER_ELEMENT;switch(r){case w.UNDEFINED:case w.NULL:break;case w.NUMBER:case w.BOOLEAN:e=s;break;case w.STRING:e+=(a=n.length)*s;break;case w.INT8ARRAY:case w.INT16ARRAY:case w.INT32ARRAY:case w.UINT8ARRAY:case w.UINT16ARRAY:case w.UINT32ARRAY:case w.FLOAT32ARRAY:case w.FLOAT64ARRAY:e+=(a=n.length)*s;break;case w.ARRAY:return void f(n,function(e,t){o([{type:r,length:n.length,header_size:i+b,byte_length:t,value:null}].concat(e))});case w.OBJECT:var c,l=[];for(c in n)n.hasOwnProperty(c)&&(l.push(c),l.push(n[c]),a++);return void f(l,function(e,t){o([{type:r,length:a,header_size:i+b,byte_length:t,value:null}].concat(e))});case w.ARRAYBUFFER:e+=n.byteLength;break;case w.BLOB:var d=n.type,u=new FileReader;return u.onload=function(e){f([d,e.target.result],function(e,t){o([{type:r,length:a,header_size:i,byte_length:t,value:null}].concat(e))})},u.onerror=function(e){throw"FileReader Error: "+e},void u.readAsArrayBuffer(n);case w.BUFFER:e+=n.length;break;default:throw'TypeError: Type "'+n.constructor.name+'" not supported.'}o([{type:r,length:a,header_size:i,byte_length:e,value:t}].concat([]))},i={pack:function(e,t){try{n(e,function(e){t(function(e){for(var t=0,n=0,o=0,i=new ArrayBuffer(e[0].byte_length+e[0].header_size),a=new DataView(i),n=0;n<e.length;n++){e[n].header_size;var r=e[n].type,s=e[n].length,c=e[n].value,l=e[n].byte_length,d=S[r],u=null===d?0:window[d+"Array"].BYTES_PER_ELEMENT;switch(r===w.BUFFER?a.setUint8(t,w.BLOB,!1):a.setUint8(t,r,!1),t+=y,r!==w.ARRAY&&r!==w.OBJECT||(a.setUint16(t,s,!1),t+=b),a.setUint32(t,l,!1),t+=_,r){case w.NULL:case w.UNDEFINED:break;case w.STRING:for(o=0;o<s;o++,t+=u)a.setUint16(t,c.charCodeAt(o),!1);break;case w.NUMBER:case w.BOOLEAN:a["set"+d](t,c,!1),t+=u;break;case w.INT8ARRAY:case w.INT16ARRAY:case w.INT32ARRAY:case w.UINT8ARRAY:case w.UINT16ARRAY:case w.UINT32ARRAY:case w.FLOAT32ARRAY:case w.FLOAT64ARRAY:new Uint8Array(a.buffer,t,l).set(new Uint8Array(c.buffer)),t+=l;break;case w.ARRAYBUFFER:case w.BUFFER:new Uint8Array(a.buffer,t,l).set(new Uint8Array(c)),t+=l;break;case w.BLOB:case w.ARRAY:case w.OBJECT:break;default:throw"TypeError: Unexpected type found."}}return a}(e))})}catch(e){throw e}},unpack:function(e,t){try{t(function(e){e=e instanceof DataView?e:new DataView(e);return v(e,0).value}(e))}catch(e){throw e}}};a.a=function(z,D){let U;function n(a,e){function r(e){return!e.audio&&!e.video&&!e.screen&&e.data}var t="",t=(t=(t=(t=(t+="?coreVer="+a.coreVer+"&userid="+a.userid)+("&sessionid="+a.sessionid))+("&msgEvent="+a.socketMessageEvent))+("&socketCustomEvent="+a.socketCustomEvent))+("&autoCloseEntireSession="+!!a.autoCloseEntireSession);if(!0===a.session.broadcast&&(t+="&oneToMany=true"),t+="&maxParticipantsAllowed="+a.maxParticipantsAllowed,a.enableScalableBroadcast&&(t=t+"&enableScalableBroadcast=true"+("&maxRelayLimitPerUser="+(a.maxRelayLimitPerUser||2))),t+="&extra="+JSON.stringify(a.extra||{}),a.socketCustomParameters&&(t+=a.socketCustomParameters),a.socketURL||(a.socketURL="/"),"/"!=a.socketURL.substr(a.socketURL.length-1,1))throw'"socketURL" MUST end with a slash.';a.enableLogs&&("/"==a.socketURL?console.info("socket.io url is: ",location.origin+"/"):console.info("socket.io url is: ",a.socketURL)),a.socket=U(a.socketURL+t);var s=a.multiPeersHandler;function c(e,t){a.peersBackup[e]||(a.peersBackup[e]={userid:e,extra:{}}),a.peersBackup[e].extra=t}a.socket.on("extra-data-updated",function(e,t){a.peers[e]&&(a.peers[e].extra=t,a.onExtraDataUpdated({userid:e,extra:t}),c(e,t))}),a.socket.on(a.socketMessageEvent,function e(t){if(t.remoteUserId==a.userid)if(a.peers[t.sender]&&a.peers[t.sender].extra!=t.message.extra&&(a.peers[t.sender].extra=t.extra,a.onExtraDataUpdated({userid:t.sender,extra:t.extra}),c(t.sender,t.extra)),t.message.streamSyncNeeded&&a.peers[t.sender]){var n=a.streamEvents[t.message.streamid];if(n&&n.stream){var o=t.message.action;if("ended"===o||"inactive"===o||"stream-removed"===o)return a.peersBackup[n.userid]&&(n.extra=a.peersBackup[n.userid].extra),void a.onstreamended(n);var i="both"!=t.message.type?t.message.type:null;"function"==typeof n.stream[o]&&n.stream[o](i)}}else if("dropPeerConnection"!==t.message){if(t.message.allParticipants)return-1===t.message.allParticipants.indexOf(t.sender)&&t.message.allParticipants.push(t.sender),void t.message.allParticipants.forEach(function(e){s[a.peers[e]?"renegotiatePeer":"createNewPeer"](e,{localPeerSdpConstraints:{OfferToReceiveAudio:a.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:a.sdpConstraints.mandatory.OfferToReceiveVideo},remotePeerSdpConstraints:{OfferToReceiveAudio:a.session.oneway?!!a.session.audio:a.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:a.session.oneway?!!a.session.video||!!a.session.screen:a.sdpConstraints.mandatory.OfferToReceiveVideo},isOneWay:!!a.session.oneway||"one-way"===a.direction,isDataOnly:r(a.session)})});if(t.message.newParticipant)t.message.newParticipant==a.userid||a.peers[t.message.newParticipant]||s.createNewPeer(t.message.newParticipant,t.message.userPreferences||{localPeerSdpConstraints:{OfferToReceiveAudio:a.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:a.sdpConstraints.mandatory.OfferToReceiveVideo},remotePeerSdpConstraints:{OfferToReceiveAudio:a.session.oneway?!!a.session.audio:a.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:a.session.oneway?!!a.session.video||!!a.session.screen:a.sdpConstraints.mandatory.OfferToReceiveVideo},isOneWay:!!a.session.oneway||"one-way"===a.direction,isDataOnly:r(a.session)});else if(t.message.readyForOffer&&(a.attachStreams.length&&(a.waitingForLocalMedia=!1),a.waitingForLocalMedia))setTimeout(function(){e(t)},1);else if(t.message.newParticipationRequest&&t.sender!==a.userid){a.peers[t.sender]&&a.deletePeer(t.sender);n={extra:t.extra||{},localPeerSdpConstraints:t.message.remotePeerSdpConstraints||{OfferToReceiveAudio:a.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:a.sdpConstraints.mandatory.OfferToReceiveVideo},remotePeerSdpConstraints:t.message.localPeerSdpConstraints||{OfferToReceiveAudio:a.session.oneway?!!a.session.audio:a.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:a.session.oneway?!!a.session.video||!!a.session.screen:a.sdpConstraints.mandatory.OfferToReceiveVideo},isOneWay:void 0!==t.message.isOneWay?t.message.isOneWay:!!a.session.oneway||"one-way"===a.direction,isDataOnly:void 0!==t.message.isDataOnly?t.message.isDataOnly:r(a.session),dontGetRemoteStream:void 0!==t.message.isOneWay?t.message.isOneWay:!!a.session.oneway||"one-way"===a.direction,dontAttachLocalStream:!!t.message.dontGetRemoteStream,connectionDescription:t,successCallback:function(){}};a.onNewParticipant(t.sender,n)}else{if(t.message.changedUUID&&a.peers[t.message.oldUUID]&&(a.peers[t.message.newUUID]=a.peers[t.message.oldUUID],delete a.peers[t.message.oldUUID]),t.message.userLeft)return s.onUserLeft(t.sender),void(t.message.autoCloseEntireSession&&a.leave());s.addNegotiatedMessage(t.message,t.sender)}}else a.deletePeer(t.sender)});var n=!1;a.socket.resetProps=function(){n=!1},a.socket.on("connect",function(){n||(n=!0,a.enableLogs&&console.info("socket.io connection is opened."),setTimeout(function(){a.socket.emit("extra-data-updated",a.extra)},1e3),e&&e(a.socket))}),a.socket.on("disconnect",function(){a.enableLogs&&console.warn("socket.io connection is closed"),a.close()}),a.socket.on("user-disconnected",function(e){e!==a.userid&&(a.onUserStatusChanged({userid:e,status:"offline",extra:a.peers[e]&&a.peers[e].extra||{}}),a.deletePeer(e))}),a.socket.on("user-connected",function(e){e!==a.userid&&a.onUserStatusChanged({userid:e,status:"online",extra:a.peers[e]&&a.peers[e].extra||{}})}),a.socket.on("closed-entire-session",function(e,t){a.leave(),a.onEntireSessionClosed({sessionid:e,userid:e,extra:t})}),a.socket.on("userid-already-taken",function(e,t){a.onUserIdAlreadyTaken(e,t)}),a.socket.on("logs",function(e){a.enableLogs&&console.debug("server-logs",e)}),a.socket.on("number-of-broadcast-viewers-updated",function(e){a.onNumberOfBroadcastViewersUpdated(e)}),a.socket.on("set-isInitiator-true",function(e){e==a.sessionid&&(a.isInitiator=!0)})}function j(i){var a=this,o=["getAllParticipants","getLength","selectFirst","streams","send","forEach"];function r(){i.fbr=new je,i.fbr.onProgress=function(e){i.onFileProgress(e)},i.fbr.onBegin=function(e){i.onFileStart(e)},i.fbr.onEnd=function(e){i.onFileEnd(e)}}i.peers={getLength:function(){var e,t=0;for(e in this)-1==o.indexOf(e)&&t++;return t},selectFirst:function(){var e,t;for(t in this)-1==o.indexOf(t)&&(e=this[t]);return e},getAllParticipants:function(e){var t,n=[];for(t in this)-1==o.indexOf(t)&&t!=e&&n.push(t);return n},forEach:function(t){this.getAllParticipants().forEach(function(e){t(i.peers[e])})},send:function(t,e){var n=this;if(!H(t.size)&&!H(t.type)){if(i.enableFileSharing)return void a.shareFile(t,e);"string"!=typeof t&&(t=JSON.stringify(t))}if("text"===t.type||t instanceof ArrayBuffer||t instanceof DataView){if("text"===t.type&&(t=JSON.stringify(t)),e){var o=i.peers[e];if(o)return o.channels.length?void o.channels.forEach(function(e){e.send(t)}):(i.peers[e].createDataChannel(),i.renegotiate(e),void setTimeout(function(){n.send(t,e)},3e3))}this.getAllParticipants().forEach(function(e){if(!n[e].channels.length)return i.peers[e].createDataChannel(),i.renegotiate(e),void setTimeout(function(){n[e].channels.forEach(function(e){e.send(t)})},3e3);n[e].channels.forEach(function(e){e.send(t)})})}else Ae.send({text:t,channel:this,connection:i,remoteUserId:e})}},this.uuid=i.userid,this.getLocalConfig=function(e,n,t){return{streamsToShare:(t=t||{}).streamsToShare||{},rtcMultiConnection:i,connectionDescription:t.connectionDescription,userid:n,localPeerSdpConstraints:t.localPeerSdpConstraints,remotePeerSdpConstraints:t.remotePeerSdpConstraints,dontGetRemoteStream:!!t.dontGetRemoteStream,dontAttachLocalStream:!!t.dontAttachLocalStream,renegotiatingPeer:!!t.renegotiatingPeer,peerRef:t.peerRef,channels:t.channels||[],onLocalSdp:function(e){a.onNegotiationNeeded(e,n)},onLocalCandidate:function(e){(e=_e.processCandidates(i,e))&&a.onNegotiationNeeded(e,n)},remoteSdp:e,onDataChannelMessage:function(e){var t;!i.fbr&&i.enableFileSharing&&r(),"string"!=typeof e&&i.enableFileSharing?(t=this,e instanceof ArrayBuffer||e instanceof DataView?i.fbr.convertToObject(e,function(e){t.onDataChannelMessage(e)}):e.readyForNextChunk?i.fbr.getNextChunk(e,function(t,e){i.peers[n].channels.forEach(function(e){e.send(t)})},n):e.chunkMissing?i.fbr.chunkMissing(e):i.fbr.addChunk(e,function(e){i.peers[n].peer.channel.send(e)})):a.onDataChannelMessage(e,n)},onDataChannelError:function(e){a.onDataChannelError(e,n)},onDataChannelOpened:function(e){a.onDataChannelOpened(e,n)},onDataChannelClosed:function(e){a.onDataChannelClosed(e,n)},onRemoteStream:function(e){i.peers[n]&&i.peers[n].streams.push(e),a.onGettingRemoteMedia(e,n)},onRemoteStreamRemoved:function(e){a.onRemovingRemoteMedia(e,n)},onPeerStateChanged:function(e){a.onPeerStateChanged(e),"new"===e.iceConnectionState&&a.onNegotiationStarted(n,e),"connected"===e.iceConnectionState&&a.onNegotiationCompleted(n,e),-1!==e.iceConnectionState.search(/closed|failed/gi)&&(a.onUserLeft(n),a.disconnectWith(n))}}},this.createNewPeer=function(e,t){if(!(i.maxParticipantsAllowed<=i.getAllParticipants().length)){if(t=t||{},i.isInitiator&&i.session.audio&&"two-way"===i.session.audio&&!t.streamsToShare&&(t.isOneWay=!1,t.isDataOnly=!1,t.session=i.session),!t.isOneWay&&!t.isDataOnly)return t.isOneWay=!0,void this.onNegotiationNeeded({enableMedia:!0,userPreferences:t},e);t=i.setUserPreferences(t,e);t=this.getLocalConfig(null,e,t);i.peers[e]=new me(t)}},this.createAnsweringPeer=function(e,t,n){n=i.setUserPreferences(n||{},t);e=this.getLocalConfig(e,t,n);i.peers[t]=new me(e)},this.renegotiatePeer=function(e,t,n){i.peers[e]?((t=t||{}).renegotiatingPeer=!0,t.peerRef=i.peers[e].peer,t.channels=i.peers[e].channels,n=this.getLocalConfig(n,e,t),i.peers[e]=new me(n)):i.enableLogs&&console.error("Peer ("+e+") does not exist. Renegotiation skipped.")},this.replaceTrack=function(t,n,o){if(!i.peers[n])throw"This peer ("+n+") does not exist.";var e=i.peers[n].peer;e.getSenders&&"function"==typeof e.getSenders&&e.getSenders().length?e.getSenders().forEach(function(e){o&&"video"===e.track.kind&&(i.peers[n].peer.lastVideoTrack=e.track,e.replaceTrack(t)),o||"audio"!==e.track.kind||(i.peers[n].peer.lastAudioTrack=e.track,e.replaceTrack(t))}):(console.warn("RTPSender.replaceTrack is NOT supported."),this.renegotiatePeer(n))},this.onNegotiationNeeded=function(e,t){},this.addNegotiatedMessage=function(e,t){return e.type&&e.sdp?("answer"==e.type&&i.peers[t]&&i.peers[t].addRemoteSdp(e),"offer"==e.type&&(e.renegotiatingPeer?this.renegotiatePeer(t,null,e):this.createAnsweringPeer(e,t)),void(i.enableLogs&&console.log("Remote peer's sdp:",e.sdp))):e.candidate?(i.peers[t]&&i.peers[t].addRemoteCandidate(e),void(i.enableLogs&&console.log("Remote peer's candidate pairs:",e.candidate))):(e.enableMedia&&(i.session=e.userPreferences.session||i.session,i.session.oneway&&i.attachStreams.length&&(i.attachStreams=[]),e.userPreferences.isDataOnly&&i.attachStreams.length&&(i.attachStreams.length=[]),n={},i.attachStreams.forEach(function(e){n[e.streamid]={isAudio:!!e.isAudio,isVideo:!!e.isVideo,isScreen:!!e.isScreen}}),e.userPreferences.streamsToShare=n,a.onNegotiationNeeded({readyForOffer:!0,userPreferences:e.userPreferences},t)),void(e.readyForOffer&&i.onReadyForOffer(t,e.userPreferences)));var n},this.onGettingRemoteMedia=function(e,t){},this.onRemovingRemoteMedia=function(e,t){},this.onGettingLocalMedia=function(e){},this.onLocalMediaError=function(e,t){i.onMediaError(e,t)},this.shareFile=function(e,n){r(),i.fbr.readAsArrayBuffer(e,function(t){var e=i.getAllParticipants();(e=n?[n]:e).forEach(function(e){i.fbr.getNextChunk(t,function(t){i.peers[e].channels.forEach(function(e){e.send(t)})},e)})},{userid:i.userid,chunkSize:"Firefox"===DetectRTC.browser.name?15e3:i.chunkSize||0})};var n=new Ee(i);this.onDataChannelMessage=function(e,t){n.receive(JSON.parse(e),t,i.peers[t]?i.peers[t].extra:{})},this.onDataChannelClosed=function(e,t){e.userid=t,e.extra=i.peers[t]?i.peers[t].extra:{},i.onclose(e)},this.onDataChannelError=function(e,t){e.userid=t,event.extra=i.peers[t]?i.peers[t].extra:{},i.onerror(e)},this.onDataChannelOpened=function(e,t){i.peers[t].channels.length?i.peers[t].channels=[e]:(i.peers[t].channels.push(e),i.onopen({userid:t,extra:i.peers[t]?i.peers[t].extra:{},channel:e}))},this.onPeerStateChanged=function(e){i.onPeerStateChanged(e)},this.onNegotiationStarted=function(e,t){},this.onNegotiationCompleted=function(e,t){},this.getRemoteStreams=function(e){return e=e||i.peers.getAllParticipants()[0],i.peers[e]?i.peers[e].streams:[]}}function B(e,t,n){"undefined"!=typeof CustomEvent&&(t=new CustomEvent(t,{arguments:n,__exposedProps__:n}),e.dispatchEvent(t))}function F(t,n){n.stream&&n.stream&&n.stream.addEventListener&&(n.stream.addEventListener("mute",function(e){(e=t.streamEvents[n.streamid]).session={audio:"audio"===e.muteType,video:"video"===e.muteType},t.onmute(e)},!1),n.stream.addEventListener("unmute",function(e){(e=t.streamEvents[n.streamid]).session={audio:"audio"===e.unmuteType,video:"video"===e.unmuteType},t.onunmute(e)},!1))}function f(){if(window.crypto&&window.crypto.getRandomValues&&-1===navigator.userAgent.indexOf("Safari")){for(var e=window.crypto.getRandomValues(new Uint32Array(3)),t="",n=0,o=e.length;n<o;n++)t+=e[n].toString(36);return t}return(Math.random()*(new Date).getTime()).toString(36).replace(/\./g,"")}function V(n,t,o){if(o.autoCreateMediaElement){var i,e=!1,a=(S(n,"video").length||n.isVideo||n.isScreen||(e=!0),"Firefox"===DetectRTC.browser.name&&(o.session.video||o.session.screen)&&(e=!1),document.createElement(e?"audio":"video"));a.srcObject=n;try{a.setAttributeNode(document.createAttribute("autoplay")),a.setAttributeNode(document.createAttribute("playsinline")),a.setAttributeNode(document.createAttribute("controls"))}catch(e){a.setAttribute("autoplay",!0),a.setAttribute("playsinline",!0),a.setAttribute("controls",!0)}"Firefox"===DetectRTC.browser.name&&(i="ended","oninactive"in a&&(i="inactive"),a.addEventListener(i,function(){var t,e;currentUserMediaRequest.remove(n.idInstance),"local"===n.type&&(i="ended","oninactive"in n&&(i="inactive"),R.onSyncNeeded(n.streamid,i),o.attachStreams.forEach(function(e,t){n.streamid===e.streamid&&delete o.attachStreams[t]}),t=[],o.attachStreams.forEach(function(e){e&&t.push(e)}),o.attachStreams=t,(e=o.streamEvents[n.streamid])?o.onstreamended(e):this.parentNode&&this.parentNode.removeChild(this))},!1));var r,e=a.play();void 0!==e?(r=!1,setTimeout(function(){r||(r=!0,t(a))},1e3),e.then(function(){r||(r=!0,t(a))}).catch(function(e){r||(r=!0,t(a))})):t(a)}else t({})}function G(e,t){window.removeEventListener(e,t),window.addEventListener(e,t,!1)}function q(e){var t=[];return e.forEach(function(e){e&&t.push(e)}),t}function c(e){return!e.audio&&!e.video&&!e.screen&&e.data}function H(e){return void 0===e}U=function(){"use strict";function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function l(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},i.apply(this,arguments)}function t(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&a(e,t)}function r(e){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},r(e)}function a(e,t){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},a(e,t)}function z(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function d(e,t,n){return d=z()?Reflect.construct.bind():function(e,t,n){var o=[null];o.push.apply(o,t);var i=new(Function.bind.apply(e,o));return n&&a(i,n.prototype),i},d.apply(null,arguments)}function n(e){var o="function"==typeof Map?new Map:void 0;return n=function(e){if(null===e||(t=e,-1===Function.toString.call(t).indexOf("[native code]")))return e;var t;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==o){if(o.has(e))return o.get(e);o.set(e,n)}function n(){return d(e,arguments,r(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)},n(e)}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function D(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return f(e)}function p(o){var i=z();return function(){var e,t=r(o);if(i){var n=r(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return D(this,e)}}function U(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=r(e)););return e}function u(){return u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var o=U(e,t);if(o){var i=Object.getOwnPropertyDescriptor(o,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},u.apply(this,arguments)}function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function B(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return j(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?j(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,r=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return r=e.done,e},e:function(e){s=!0,a=e},f:function(){try{r||null==n.return||n.return()}finally{if(s)throw a}}}}var h=Object.create(null),m=(h.open="0",h.close="1",h.ping="2",h.pong="3",h.message="4",h.upgrade="5",h.noop="6",Object.create(null));Object.keys(h).forEach(function(e){m[h[e]]=e});for(var F={type:"error",data:"parser error"},V="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),G="function"==typeof ArrayBuffer,q=function(e,t,n){var o,i=e.type,a=e.data;return V&&a instanceof Blob?t?n(a):H(a,n):G&&(a instanceof ArrayBuffer||(o=a,"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(o):o&&o.buffer instanceof ArrayBuffer))?t?n(a):H(new Blob([a]),n):n(h[i]+(a||""))},H=function(e,t){var n=new FileReader;return n.onload=function(){var e=n.result.split(",")[1];t("b"+e)},n.readAsDataURL(e)},W="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",g="undefined"==typeof Uint8Array?[]:new Uint8Array(256),e=0;e<W.length;e++)g[W.charCodeAt(e)]=e;var Y="function"==typeof ArrayBuffer,X=function(e,t){if("string"!=typeof e)return{type:"message",data:K(e,t)};var n=e.charAt(0);return"b"===n?{type:"message",data:J(e.substring(1),t)}:m[n]?e.length>1?{type:m[n],data:e.substring(1)}:{type:m[n]}:F},J=function(e,t){if(Y){var n=function(e){var t,n,o,i,a,r=.75*e.length,s=e.length,c=0;"="===e[e.length-1]&&(r--,"="===e[e.length-2]&&r--);var l=new ArrayBuffer(r),d=new Uint8Array(l);for(t=0;t<s;t+=4)n=g[e.charCodeAt(t)],o=g[e.charCodeAt(t+1)],i=g[e.charCodeAt(t+2)],a=g[e.charCodeAt(t+3)],d[c++]=n<<2|o>>4,d[c++]=(15&o)<<4|i>>2,d[c++]=(3&i)<<6|63&a;return l}(e);return K(n,t)}return{base64:!0,data:e}},K=function(e,t){return"blob"===t&&e instanceof ArrayBuffer?new Blob([e]):e},Q=String.fromCharCode(30);function v(e){if(e)return function(e){for(var t in v.prototype)e[t]=v.prototype[t];return e}(e)}v.prototype.on=v.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},v.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},v.prototype.off=v.prototype.removeListener=v.prototype.removeAllListeners=v.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,o=this._callbacks["$"+e];if(!o)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i<o.length;i++)if((n=o[i])===t||n.fn===t){o.splice(i,1);break}return 0===o.length&&delete this._callbacks["$"+e],this},v.prototype.emitReserved=v.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],o=1;o<arguments.length;o++)t[o-1]=arguments[o];if(n){o=0;for(var i=(n=n.slice(0)).length;o<i;++o)n[o].apply(this,t)}return this},v.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},v.prototype.hasListeners=function(e){return!!this.listeners(e).length};var y="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function $(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),o=1;o<e;o++)t[o-1]=arguments[o];return t.reduce(function(e,t){return n.hasOwnProperty(t)&&(e[t]=n[t]),e},{})}var Z=setTimeout,ee=clearTimeout;function b(e,t){t.useNativeTimers?(e.setTimeoutFn=Z.bind(y),e.clearTimeoutFn=ee.bind(y)):(e.setTimeoutFn=setTimeout.bind(y),e.clearTimeoutFn=clearTimeout.bind(y))}var te,ne=function(e){t(a,e);var i=p(a);function a(e,t,n){var o;return s(this,a),(o=i.call(this,e)).description=t,o.context=n,o.type="TransportError",o}return l(a)}(n(Error)),oe=function(e){t(o,e);var n=p(o);function o(e){var t;return s(this,o),(t=n.call(this)).writable=!1,b(f(t),e),t.opts=e,t.query=e.query,t.readyState="",t.socket=e.socket,t}return l(o,[{key:"onError",value:function(e,t,n){return u(r(o.prototype),"emitReserved",this).call(this,"error",new ne(e,t,n)),this}},{key:"open",value:function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this}},{key:"close",value:function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}},{key:"send",value:function(e){"open"===this.readyState&&this.write(e)}},{key:"onOpen",value:function(){this.readyState="open",this.writable=!0,u(r(o.prototype),"emitReserved",this).call(this,"open")}},{key:"onData",value:function(e){var t=X(e,this.socket.binaryType);this.onPacket(t)}},{key:"onPacket",value:function(e){u(r(o.prototype),"emitReserved",this).call(this,"packet",e)}},{key:"onClose",value:function(e){this.readyState="closed",u(r(o.prototype),"emitReserved",this).call(this,"close",e)}}]),o}(v),ie="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),ae={},re=0,_=0;function se(e){var t="";do{t=ie[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function ce(){var e=se(+new Date);return e!==te?(re=0,te=e):e+"."+se(re++)}for(;_<64;_++)ae[ie[_]]=_;function le(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function de(e){for(var t={},n=e.split("&"),o=0,i=n.length;o<i;o++){var a=n[o].split("=");t[decodeURIComponent(a[0])]=decodeURIComponent(a[1])}return t}var ue=!1;try{ue="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(c){}var fe=ue;function pe(e){var t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||fe))return new XMLHttpRequest}catch(e){}if(!t)try{return new y[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch(e){}}function he(){}var me=null!=new pe({xdomain:!1}).responseType,ge=function(e){t(r,e);var a=p(r);function r(e){var t;if(s(this,r),(t=a.call(this,e)).polling=!1,"undefined"!=typeof location){var n="https:"===location.protocol,o=location.port;o||(o=n?"443":"80"),t.xd="undefined"!=typeof location&&e.hostname!==location.hostname||o!==e.port,t.xs=e.secure!==n}var i=e&&e.forceBase64;return t.supportsBinary=me&&!i,t}return l(r,[{key:"name",get:function(){return"polling"}},{key:"doOpen",value:function(){this.poll()}},{key:"pause",value:function(e){var t=this;this.readyState="pausing";var n=function(){t.readyState="paused",e()};if(this.polling||!this.writable){var o=0;this.polling&&(o++,this.once("pollComplete",function(){--o||n()})),this.writable||(o++,this.once("drain",function(){--o||n()}))}else n()}},{key:"poll",value:function(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}},{key:"onData",value:function(e){var t=this;(function(e,t){for(var n=e.split(Q),o=[],i=0;i<n.length;i++){var a=X(n[i],t);if(o.push(a),"error"===a.type)break}return o})(e,this.socket.binaryType).forEach(function(e){if("opening"===t.readyState&&"open"===e.type&&t.onOpen(),"close"===e.type)return t.onClose({description:"transport closed by the server"}),!1;t.onPacket(e)}),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}},{key:"doClose",value:function(){var e=this,t=function(){e.write([{type:"close"}])};"open"===this.readyState?t():this.once("open",t)}},{key:"write",value:function(e){var t=this;this.writable=!1,function(e,n){var o=e.length,i=new Array(o),a=0;e.forEach(function(e,t){q(e,!1,function(e){i[t]=e,++a===o&&n(i.join(Q))})})}(e,function(e){t.doWrite(e,function(){t.writable=!0,t.emitReserved("drain")})})}},{key:"uri",value:function(){var e=this.query||{},t=this.opts.secure?"https":"http",n="";!1!==this.opts.timestampRequests&&(e[this.opts.timestampParam]=ce()),this.supportsBinary||e.sid||(e.b64=1),this.opts.port&&("https"===t&&443!==Number(this.opts.port)||"http"===t&&80!==Number(this.opts.port))&&(n=":"+this.opts.port);var o=le(e);return t+"://"+(-1!==this.opts.hostname.indexOf(":")?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(o.length?"?"+o:"")}},{key:"request",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i(e,{xd:this.xd,xs:this.xs},this.opts),new w(this.uri(),e)}},{key:"doWrite",value:function(e,t){var n=this,o=this.request({method:"POST",data:e});o.on("success",t),o.on("error",function(e,t){n.onError("xhr post error",e,t)})}},{key:"doPoll",value:function(){var n=this,e=this.request();e.on("data",this.onData.bind(this)),e.on("error",function(e,t){n.onError("xhr poll error",e,t)}),this.pollXhr=e}}]),r}(oe),w=function(e){t(i,e);var o=p(i);function i(e,t){var n;return s(this,i),b(f(n=o.call(this)),t),n.opts=t,n.method=t.method||"GET",n.uri=e,n.async=!1!==t.async,n.data=void 0!==t.data?t.data:null,n.create(),n}return l(i,[{key:"create",value:function(){var e=this,t=$(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd,t.xscheme=!!this.opts.xs;var n=this.xhr=new pe(t);try{n.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders)for(var o in n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0),this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(o)&&n.setRequestHeader(o,this.opts.extraHeaders[o])}catch(e){}if("POST"===this.method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{n.setRequestHeader("Accept","*/*")}catch(e){}"withCredentials"in n&&(n.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(n.timeout=this.opts.requestTimeout),n.onreadystatechange=function(){4===n.readyState&&(200===n.status||1223===n.status?e.onLoad():e.setTimeoutFn(function(){e.onError("number"==typeof n.status?n.status:0)},0))},n.send(this.data)}catch(t){return void this.setTimeoutFn(function(){e.onError(t)},0)}"undefined"!=typeof document&&(this.index=i.requestsCount++,i.requests[this.index]=this)}},{key:"onError",value:function(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}},{key:"cleanup",value:function(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=he,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete i.requests[this.index],this.xhr=null}}},{key:"onLoad",value:function(){var e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}},{key:"abort",value:function(){this.cleanup()}}]),i}(v);if(w.requestsCount=0,w.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",ve);else if("function"==typeof addEventListener)addEventListener("onpagehide"in y?"pagehide":"unload",ve,!1);function ve(){for(var e in w.requests)w.requests.hasOwnProperty(e)&&w.requests[e].abort()}var ye="function"==typeof Promise&&"function"==typeof Promise.resolve?function(e){return Promise.resolve().then(e)}:function(e,t){return t(e,0)},S=y.WebSocket||y.MozWebSocket,be="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),_e,we={websocket:function(e){t(o,e);var n=p(o);function o(e){var t;return s(this,o),(t=n.call(this,e)).supportsBinary=!e.forceBase64,t}return l(o,[{key:"name",get:function(){return"websocket"}},{key:"doOpen",value:function(){if(this.check()){var e=this.uri(),t=this.opts.protocols,n=be?{}:$(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=be?new S(e,t,n):t?new S(e,t):new S(e)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType||"arraybuffer",this.addEventListeners()}}},{key:"addEventListeners",value:function(){var t=this;this.ws.onopen=function(){t.opts.autoUnref&&t.ws._socket.unref(),t.onOpen()},this.ws.onclose=function(e){return t.onClose({description:"websocket connection closed",context:e})},this.ws.onmessage=function(e){return t.onData(e.data)},this.ws.onerror=function(e){return t.onError("websocket error",e)}}},{key:"write",value:function(o){var i=this;this.writable=!1;for(var e=function(e){var t=o[e],n=e===o.length-1;q(t,i.supportsBinary,function(e){try{i.ws.send(e)}catch(e){}n&&ye(function(){i.writable=!0,i.emitReserved("drain")},i.setTimeoutFn)})},t=0;t<o.length;t++)e(t)}},{key:"doClose",value:function(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}},{key:"uri",value:function(){var e=this.query||{},t=this.opts.secure?"wss":"ws",n="";this.opts.port&&("wss"===t&&443!==Number(this.opts.port)||"ws"===t&&80!==Number(this.opts.port))&&(n=":"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=ce()),this.supportsBinary||(e.b64=1);var o=le(e);return t+"://"+(-1!==this.opts.hostname.indexOf(":")?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(o.length?"?"+o:"")}},{key:"check",value:function(){return!!S}}]),o}(oe),polling:ge},Se=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Te=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function T(e){var t=e,n=e.indexOf("["),o=e.indexOf("]");-1!=n&&-1!=o&&(e=e.substring(0,n)+e.substring(n,o).replace(/:/g,";")+e.substring(o,e.length));for(var i,a,r=Se.exec(e||""),s={},c=14;c--;)s[Te[c]]=r[c]||"";return-1!=n&&-1!=o&&(s.source=t,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=function(e,t){var n=/\/{2,9}/g,o=t.replace(n,"/").split("/");"/"!=t.substr(0,1)&&0!==t.length||o.splice(0,1);"/"==t.substr(t.length-1,1)&&o.splice(o.length-1,1);return o}(0,s.path),s.queryKey=(i=s.query,a={},i.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,n){t&&(a[t]=n)}),a),s}var x=function(e){t(u,e);var o=p(u);function u(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s(this,u),t=o.call(this),e&&"object"===c(e)&&(n=e,e=null),e?(e=T(e),n.hostname=e.host,n.secure="https"===e.protocol||"wss"===e.protocol,n.port=e.port,e.query&&(n.query=e.query)):n.host&&(n.hostname=T(n.host).host),b(f(t),n),t.secure=null!=n.secure?n.secure:"undefined"!=typeof location&&"https:"===location.protocol,n.hostname&&!n.port&&(n.port=t.secure?"443":"80"),t.hostname=n.hostname||("undefined"!=typeof location?location.hostname:"localhost"),t.port=n.port||("undefined"!=typeof location&&location.port?location.port:t.secure?"443":"80"),t.transports=n.transports||["polling","websocket"],t.readyState="",t.writeBuffer=[],t.prevBufferLen=0,t.opts=i({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},n),t.opts.path=t.opts.path.replace(/\/$/,"")+"/","string"==typeof t.opts.query&&(t.opts.query=de(t.opts.query)),t.id=null,t.upgrades=null,t.pingInterval=null,t.pingTimeout=null,t.pingTimeoutTimer=null,"function"==typeof addEventListener&&(t.opts.closeOnBeforeunload&&addEventListener("beforeunload",function(){t.transport&&(t.transport.removeAllListeners(),t.transport.close())},!1),"localhost"!==t.hostname&&(t.offlineEventListener=function(){t.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",t.offlineEventListener,!1))),t.open(),t}return l(u,[{key:"createTransport",value:function(e){var t=i({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);var n=i({},this.opts.transportOptions[e],this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new we[e](n)}},{key:"open",value:function(){var e,t=this;if(this.opts.rememberUpgrade&&u.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn(function(){t.emitReserved("error","No transports available")},0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}},{key:"setTransport",value:function(e){var t=this;this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",function(e){return t.onClose("transport close",e)})}},{key:"probe",value:function(e){var n=this,o=this.createTransport(e),i=!1;u.priorWebsocketSuccess=!1;var t=function(){i||(o.send([{type:"ping",data:"probe"}]),o.once("packet",function(e){if(!i)if("pong"===e.type&&"probe"===e.data){if(n.upgrading=!0,n.emitReserved("upgrading",o),!o)return;u.priorWebsocketSuccess="websocket"===o.name,n.transport.pause(function(){i||"closed"!==n.readyState&&(d(),n.setTransport(o),o.send([{type:"upgrade"}]),n.emitReserved("upgrade",o),o=null,n.upgrading=!1,n.flush())})}else{var t=new Error("probe error");t.transport=o.name,n.emitReserved("upgradeError",t)}}))};function a(){i||(i=!0,d(),o.close(),o=null)}var r=function(e){var t=new Error("probe error: "+e);t.transport=o.name,a(),n.emitReserved("upgradeError",t)};function s(){r("transport closed")}function c(){r("socket closed")}function l(e){o&&e.name!==o.name&&a()}var d=function(){o.removeListener("open",t),o.removeListener("error",r),o.removeListener("close",s),n.off("close",c),n.off("upgrading",l)};o.once("open",t),o.once("error",r),o.once("close",s),this.once("close",c),this.once("upgrading",l),o.open()}},{key:"onOpen",value:function(){if(this.readyState="open",u.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade&&this.transport.pause)for(var e=0,t=this.upgrades.length;e<t;e++)this.probe(this.upgrades[e])}},{key:"onPacket",value:function(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.resetPingTimeout(),this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":var t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}},{key:"onHandshake",value:function(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}},{key:"resetPingTimeout",value:function(){var e=this;this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(function(){e.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}},{key:"onDrain",value:function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}},{key:"flush",value:function(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){var e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}},{key:"getWritablePackets",value:function(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;for(var e,t=1,n=0;n<this.writeBuffer.length;n++){var o=this.writeBuffer[n].data;if(o&&(t+="string"==typeof(e=o)?function(e){for(var t=0,n=0,o=0,i=e.length;o<i;o++)(t=e.charCodeAt(o))<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(o++,n+=4);return n}(e):Math.ceil(1.33*(e.byteLength||e.size))),n>0&&t>this.maxPayload)return this.writeBuffer.slice(0,n);t+=2}return this.writeBuffer}},{key:"write",value:function(e,t,n){return this.sendPacket("message",e,t,n),this}},{key:"send",value:function(e,t,n){return this.sendPacket("message",e,t,n),this}},{key:"sendPacket",value:function(e,t,n,o){if("function"==typeof t&&(o=t,t=void 0),"function"==typeof n&&(o=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){(n=n||{}).compress=!1!==n.compress;var i={type:e,data:t,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),o&&this.once("flush",o),this.flush()}}},{key:"close",value:function(){var t=this,n=function(){t.onClose("forced close"),t.transport.close()},e=function e(){t.off("upgrade",e),t.off("upgradeError",e),n()},o=function(){t.once("upgrade",e),t.once("upgradeError",e)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",function(){t.upgrading?o():n()}):this.upgrading?o():n()),this}},{key:"onError",value:function(e){u.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}},{key:"onClose",value:function(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&removeEventListener("offline",this.offlineEventListener,!1),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}},{key:"filterUpgrades",value:function(e){for(var t=[],n=0,o=e.length;n<o;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}]),u}(v),xe=(x.protocol=4,x.protocol,"function"==typeof ArrayBuffer),Ce=Object.prototype.toString,Ee="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Ce.call(Blob),Me="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Ce.call(File),C;function E(e){return xe&&(e instanceof ArrayBuffer||function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer}(e))||Ee&&e instanceof Blob||Me&&e instanceof File}function M(e,t){if(!e||"object"!==c(e))return!1;if(Array.isArray(e)){for(var n=0,o=e.length;n<o;n++)if(M(e[n]))return!0;return!1}if(E(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return M(e.toJSON(),!0);for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&M(e[i]))return!0;return!1}function Re(e){var t=[],n=e.data,o=e;return o.data=R(n,t),o.attachments=t.length,{packet:o,buffers:t}}function R(e,t){if(!e)return e;if(E(e)){var n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){for(var o=new Array(e.length),i=0;i<e.length;i++)o[i]=R(e[i],t);return o}if("object"===c(e)&&!(e instanceof Date)){var a={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(a[r]=R(e[r],t));return a}return e}function Ae(e,t){return e.data=A(e.data,t),e.attachments=void 0,e}function A(e,t){if(!e)return e;if(e&&e._placeholder)return t[e.num];if(Array.isArray(e))for(var n=0;n<e.length;n++)e[n]=A(e[n],t);else if("object"===c(e))for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(e[o]=A(e[o],t));return e}var O=C||(C={}),Oe=(O[O.CONNECT=0]="CONNECT",O[O.DISCONNECT=1]="DISCONNECT",O[O.EVENT=2]="EVENT",O[O.ACK=3]="ACK",O[O.CONNECT_ERROR=4]="CONNECT_ERROR",O[O.BINARY_EVENT=5]="BINARY_EVENT",O[O.BINARY_ACK=6]="BINARY_ACK",function(){function t(e){s(this,t),this.replacer=e}return l(t,[{key:"encode",value:function(e){return e.type!==C.EVENT&&e.type!==C.ACK||!M(e)?[this.encodeAsString(e)]:(e.type=e.type===C.EVENT?C.BINARY_EVENT:C.BINARY_ACK,this.encodeAsBinary(e))}},{key:"encodeAsString",value:function(e){var t=""+e.type;return e.type!==C.BINARY_EVENT&&e.type!==C.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}},{key:"encodeAsBinary",value:function(e){var t=Re(e),n=this.encodeAsString(t.packet),o=t.buffers;return o.unshift(n),o}}]),t}()),ke=function(e){t(d,e);var n=p(d);function d(e){var t;return s(this,d),(t=n.call(this)).reviver=e,t}return l(d,[{key:"add",value:function(e){var t;if("string"==typeof e)(t=this.decodeString(e)).type===C.BINARY_EVENT||t.type===C.BINARY_ACK?(this.reconstructor=new Pe(t),0===t.attachments&&u(r(d.prototype),"emitReserved",this).call(this,"decoded",t)):u(r(d.prototype),"emitReserved",this).call(this,"decoded",t);else{if(!E(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(t=this.reconstructor.takeBinaryData(e))&&(this.reconstructor=null,u(r(d.prototype),"emitReserved",this).call(this,"decoded",t))}}},{key:"decodeString",value:function(e){var t=0,n={type:Number(e.charAt(0))};if(void 0===C[n.type])throw new Error("unknown packet type "+n.type);if(n.type===C.BINARY_EVENT||n.type===C.BINARY_ACK){for(var o=t+1;"-"!==e.charAt(++t)&&t!=e.length;);var i=e.substring(o,t);if(i!=Number(i)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(i)}if("/"===e.charAt(t+1)){for(var a=t+1;++t;){if(","===e.charAt(t))break;if(t===e.length)break}n.nsp=e.substring(a,t)}else n.nsp="/";var r=e.charAt(t+1);if(""!==r&&Number(r)==r){for(var s=t+1;++t;){var c=e.charAt(t);if(null==c||Number(c)!=c){--t;break}if(t===e.length)break}n.id=Number(e.substring(s,t+1))}if(e.charAt(++t)){var l=this.tryParse(e.substr(t));if(!d.isPayloadValid(n.type,l))throw new Error("invalid payload");n.data=l}return n}},{key:"tryParse",value:function(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}},{key:"destroy",value:function(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}],[{key:"isPayloadValid",value:function(e,t){switch(e){case C.CONNECT:return"object"===c(t);case C.DISCONNECT:return void 0===t;case C.CONNECT_ERROR:return"string"==typeof t||"object"===c(t);case C.EVENT:case C.BINARY_EVENT:return Array.isArray(t)&&t.length>0;case C.ACK:case C.BINARY_ACK:return Array.isArray(t)}}}]),d}(v),Pe=function(){function t(e){s(this,t),this.packet=e,this.buffers=[],this.reconPack=e}return l(t,[{key:"takeBinaryData",value:function(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){var t=Ae(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}},{key:"finishedReconstruction",value:function(){this.reconPack=null,this.buffers=[]}}]),t}(),Ie=Object.freeze({__proto__:null,protocol:5,get PacketType(){return C},Encoder:Oe,Decoder:ke});function k(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var Ne=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Le=function(e){t(a,e);var i=p(a);function a(e,t,n){var o;return s(this,a),(o=i.call(this)).connected=!1,o.receiveBuffer=[],o.sendBuffer=[],o.ids=0,o.acks={},o.flags={},o.io=e,o.nsp=t,n&&n.auth&&(o.auth=n.auth),o.io._autoConnect&&o.open(),o}return l(a,[{key:"disconnected",get:function(){return!this.connected}},{key:"subEvents",value:function(){if(!this.subs){var e=this.io;this.subs=[k(e,"open",this.onopen.bind(this)),k(e,"packet",this.onpacket.bind(this)),k(e,"error",this.onerror.bind(this)),k(e,"close",this.onclose.bind(this))]}}},{key:"active",get:function(){return!!this.subs}},{key:"connect",value:function(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}},{key:"open",value:function(){return this.connect()}},{key:"send",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.unshift("message"),this.emit.apply(this,t),this}},{key:"emit",value:function(e){if(Ne.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];n.unshift(e);var i={type:C.EVENT,data:n,options:{}};if(i.options.compress=!1!==this.flags.compress,"function"==typeof n[n.length-1]){var a=this.ids++,r=n.pop();this._registerAckCallback(a,r),i.id=a}var s=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable,c=this.flags.volatile&&(!s||!this.connected);return c||(this.connected?(this.notifyOutgoingListeners(i),this.packet(i)):this.sendBuffer.push(i)),this.flags={},this}},{key:"_registerAckCallback",value:function(t,o){var i=this,e=this.flags.timeout;if(void 0!==e){var a=this.io.setTimeoutFn(function(){delete i.acks[t];for(var e=0;e<i.sendBuffer.length;e++)i.sendBuffer[e].id===t&&i.sendBuffer.splice(e,1);o.call(i,new Error("operation has timed out"))},e);this.acks[t]=function(){i.io.clearTimeoutFn(a);for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];o.apply(i,[null].concat(t))}}else this.acks[t]=o}},{key:"packet",value:function(e){e.nsp=this.nsp,this.io._packet(e)}},{key:"onopen",value:function(){var t=this;"function"==typeof this.auth?this.auth(function(e){t.packet({type:C.CONNECT,data:e})}):this.packet({type:C.CONNECT,data:this.auth})}},{key:"onerror",value:function(e){this.connected||this.emitReserved("connect_error",e)}},{key:"onclose",value:function(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}},{key:"onpacket",value:function(e){if(e.nsp===this.nsp)switch(e.type){case C.CONNECT:if(e.data&&e.data.sid){var t=e.data.sid;this.onconnect(t)}else this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case C.EVENT:case C.BINARY_EVENT:this.onevent(e);break;case C.ACK:case C.BINARY_ACK:this.onack(e);break;case C.DISCONNECT:this.ondisconnect();break;case C.CONNECT_ERROR:this.destroy();var n=new Error(e.data.message);n.data=e.data.data,this.emitReserved("connect_error",n)}}},{key:"onevent",value:function(e){var t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}},{key:"emitEvent",value:function(e){if(this._anyListeners&&this._anyListeners.length){var t,n=B(this._anyListeners.slice());try{for(n.s();!(t=n.n()).done;)t.value.apply(this,e)}catch(e){n.e(e)}finally{n.f()}}u(r(a.prototype),"emit",this).apply(this,e)}},{key:"ack",value:function(o){var i=this,a=!1;return function(){if(!a){a=!0;for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];i.packet({type:C.ACK,id:o,data:t})}}}},{key:"onack",value:function(e){var t=this.acks[e.id];"function"==typeof t&&(t.apply(this,e.data),delete this.acks[e.id])}},{key:"onconnect",value:function(e){this.id=e,this.connected=!0,this.emitBuffered(),this.emitReserved("connect")}},{key:"emitBuffered",value:function(){var t=this;this.receiveBuffer.forEach(function(e){return t.emitEvent(e)}),this.receiveBuffer=[],this.sendBuffer.forEach(function(e){t.notifyOutgoingListeners(e),t.packet(e)}),this.sendBuffer=[]}},{key:"ondisconnect",value:function(){this.destroy(),this.onclose("io server disconnect")}},{key:"destroy",value:function(){this.subs&&(this.subs.forEach(function(e){return e()}),this.subs=void 0),this.io._destroy(this)}},{key:"disconnect",value:function(){return this.connected&&this.packet({type:C.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}},{key:"close",value:function(){return this.disconnect()}},{key:"compress",value:function(e){return this.flags.compress=e,this}},{key:"volatile",get:function(){return this.flags.volatile=!0,this}},{key:"timeout",value:function(e){return this.flags.timeout=e,this}},{key:"onAny",value:function(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}},{key:"prependAny",value:function(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}},{key:"offAny",value:function(e){if(!this._anyListeners)return this;if(e){for(var t=this._anyListeners,n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}},{key:"listenersAny",value:function(){return this._anyListeners||[]}},{key:"onAnyOutgoing",value:function(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}},{key:"prependAnyOutgoing",value:function(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}},{key:"offAnyOutgoing",value:function(e){if(!this._anyOutgoingListeners)return this;if(e){for(var t=this._anyOutgoingListeners,n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}},{key:"listenersAnyOutgoing",value:function(){return this._anyOutgoingListeners||[]}},{key:"notifyOutgoingListeners",value:function(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){var t,n=B(this._anyOutgoingListeners.slice());try{for(n.s();!(t=n.n()).done;)t.value.apply(this,e.data)}catch(e){n.e(e)}finally{n.f()}}}}]),a}(v);function P(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}P.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},P.prototype.reset=function(){this.attempts=0},P.prototype.setMin=function(e){this.ms=e},P.prototype.setMax=function(e){this.max=e},P.prototype.setJitter=function(e){this.jitter=e};var I=function(e){t(r,e);var a=p(r);function r(e,t){var n,o;s(this,r),(n=a.call(this)).nsps={},n.subs=[],e&&"object"===c(e)&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",n.opts=t,b(f(n),t),n.reconnection(!1!==t.reconnection),n.reconnectionAttempts(t.reconnectionAttempts||1/0),n.reconnectionDelay(t.reconnectionDelay||1e3),n.reconnectionDelayMax(t.reconnectionDelayMax||5e3),n.randomizationFactor(null!==(o=t.randomizationFactor)&&void 0!==o?o:.5),n.backoff=new P({min:n.reconnectionDelay(),max:n.reconnectionDelayMax(),jitter:n.randomizationFactor()}),n.timeout(null==t.timeout?2e4:t.timeout),n._readyState="closed",n.uri=e;var i=t.parser||Ie;return n.encoder=new i.Encoder,n.decoder=new i.Decoder,n._autoConnect=!1!==t.autoConnect,n._autoConnect&&n.open(),n}return l(r,[{key:"reconnection",value:function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}},{key:"reconnectionAttempts",value:function(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}},{key:"reconnectionDelay",value:function(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}},{key:"randomizationFactor",value:function(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}},{key:"reconnectionDelayMax",value:function(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}},{key:"timeout",value:function(e){return arguments.length?(this._timeout=e,this):this._timeout}},{key:"maybeReconnectOnOpen",value:function(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}},{key:"open",value:function(t){var n=this;if(~this._readyState.indexOf("open"))return this;this.engine=new x(this.uri,this.opts);var e=this.engine,o=this;this._readyState="opening",this.skipReconnect=!1;var i=k(e,"open",function(){o.onopen(),t&&t()}),a=k(e,"error",function(e){o.cleanup(),o._readyState="closed",n.emitReserved("error",e),t?t(e):o.maybeReconnectOnOpen()});if(!1!==this._timeout){var r=this._timeout;0===r&&i();var s=this.setTimeoutFn(function(){i(),e.close(),e.emit("error",new Error("timeout"))},r);this.opts.autoUnref&&s.unref(),this.subs.push(function(){clearTimeout(s)})}return this.subs.push(i),this.subs.push(a),this}},{key:"connect",value:function(e){return this.open(e)}},{key:"onopen",value:function(){this.cleanup(),this._readyState="open",this.emitReserved("open");var e=this.engine;this.subs.push(k(e,"ping",this.onping.bind(this)),k(e,"data",this.ondata.bind(this)),k(e,"error",this.onerror.bind(this)),k(e,"close",this.onclose.bind(this)),k(this.decoder,"decoded",this.ondecoded.bind(this)))}},{key:"onping",value:function(){this.emitReserved("ping")}},{key:"ondata",value:function(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error")}}},{key:"ondecoded",value:function(e){this.emitReserved("packet",e)}},{key:"onerror",value:function(e){this.emitReserved("error",e)}},{key:"socket",value:function(e,t){var n=this.nsps[e];return n||(n=new Le(this,e,t),this.nsps[e]=n),n}},{key:"_destroy",value:function(e){for(var t=0,n=Object.keys(this.nsps);t<n.length;t++){var o=n[t];if(this.nsps[o].active)return}this._close()}},{key:"_packet",value:function(e){for(var t=this.encoder.encode(e),n=0;n<t.length;n++)this.engine.write(t[n],e.options)}},{key:"cleanup",value:function(){this.subs.forEach(function(e){return e()}),this.subs.length=0,this.decoder.destroy()}},{key:"_close",value:function(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}},{key:"disconnect",value:function(){return this._close()}},{key:"onclose",value:function(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}},{key:"reconnect",value:function(){var t=this;if(this._reconnecting||this.skipReconnect)return this;var n=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{var e=this.backoff.duration();this._reconnecting=!0;var o=this.setTimeoutFn(function(){n.skipReconnect||(t.emitReserved("reconnect_attempt",n.backoff.attempts),n.skipReconnect||n.open(function(e){e?(n._reconnecting=!1,n.reconnect(),t.emitReserved("reconnect_error",e)):n.onreconnect()}))},e);this.opts.autoUnref&&o.unref(),this.subs.push(function(){clearTimeout(o)})}}},{key:"onreconnect",value:function(){var e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}]),r}(v),N={};function L(e,t){"object"===c(e)&&(t=e,e=void 0);var n,o=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,o=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==n?n.protocol+"//"+e:"https://"+e),o=T(e)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";var i=-1!==o.host.indexOf(":")?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+i+":"+o.port+t,o.href=o.protocol+"://"+i+(n&&n.port===o.port?"":":"+o.port),o}(e,(t=t||{}).path||"/socket.io"),i=o.source,a=o.id,r=o.path,s=N[a]&&r in N[a].nsps;return t.forceNew||t["force new connection"]||!1===t.multiplex||s?n=new I(i,t):(N[a]||(N[a]=new I(i,t)),n=N[a]),o.query&&!t.query&&(t.query=o.queryKey),n.socket(o.path,t)}return i(L,{Manager:I,Socket:Le,io:L,connect:L}),L}(),(t=void 0!==ze?ze:null)&&"undefined"==typeof window&&void 0!==ze&&(ze.navigator={userAgent:"Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45",getUserMedia:function(){}},ze.console||(ze.console={}),void 0===ze.console.debug&&(ze.console.debug=ze.console.info=ze.console.error=ze.console.log=ze.console.log||function(){console.log(arguments)}),"undefined"==typeof document&&(t.document={},document.createElement=document.captureStream=document.mozCaptureStream=function(){var e={getContext:function(){return e},play:function(){},pause:function(){},drawImage:function(){},toDataURL:function(){return""}};return e},document.addEventListener=document.removeEventListener=t.addEventListener=t.removeEventListener=function(){},t.HTMLVideoElement=t.HTMLMediaElement=function(){}),0==typeof location&&(t.location={protocol:"file:",href:"",hash:"",origin:"self"}),"undefined"==typeof screen&&(t.screen={width:0,height:0}),"undefined"==typeof URL&&(t.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),t.window=ze);var e,t="Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45",s=("object"===(void 0===De?"undefined":Ue(De))&&"object"===Ue(De.versions)&&De.versions.node&&!De.browser&&(e=De.versions.node.toString().replace("v",""),t="Nodejs/"+e+" (NodeOS) AppleWebKit/"+e+" (KHTML, like Gecko) Nodejs/"+e+" Nodejs/"+e),e=void 0!==ze?ze:window,"undefined"==typeof window&&("undefined"==typeof window&&void 0!==ze&&(ze.navigator={userAgent:t,getUserMedia:function(){}},e.window=ze),"undefined"==typeof location&&(e.location={protocol:"file:",href:"",hash:""}),"undefined"==typeof screen&&(e.screen={width:0,height:0})),window.navigator),t=(void 0!==s?(void 0!==s.webkitGetUserMedia&&(s.getUserMedia=s.webkitGetUserMedia),void 0!==s.mozGetUserMedia&&(s.getUserMedia=s.mozGetUserMedia)):s={getUserMedia:function(){},userAgent:t},!!/Android|webOS|iPhone|iPad|iPod|BB10|BlackBerry|IEMobile|Opera Mini|Mobile|mobile/i.test(s.userAgent||"")),W=!(-1===s.userAgent.indexOf("Edge")||!s.msSaveOrOpenBlob&&!s.msSaveBlob),Y=!!window.opera||0<=s.userAgent.indexOf(" OPR/"),X=void 0!==window.InstallTrigger,J=/^((?!chrome|android).)*safari/i.test(s.userAgent),K=!!window.chrome&&!Y,Q="undefined"!=typeof document&&!!document.documentMode&&!W;function $(e,t){var n=0,o=!1,i=window.setInterval(function(){e()&&(window.clearInterval(i),t(o)),50<n++&&(window.clearInterval(i),t(o=!0))},10)}var o,Z,i={Android:function(){return s.userAgent.match(/Android/i)},BlackBerry:function(){return s.userAgent.match(/BlackBerry|BB10/i)},iOS:function(){return s.userAgent.match(/iPhone|iPad|iPod/i)},Opera:function(){return s.userAgent.match(/Opera Mini/i)},Windows:function(){return s.userAgent.match(/IEMobile/i)},any:function(){return i.Android()||i.BlackBerry()||i.iOS()||i.Opera()||i.Windows()},getOsName:function(){var e="Unknown OS";return i.Android()&&(e="Android"),i.BlackBerry()&&(e="BlackBerry"),i.iOS()&&(e="iOS"),i.Opera()&&(e="Opera Mini"),e=i.Windows()?"Windows":e}},a="Unknown OS",r="Unknown OS Version",l=((y=function(){for(var e,t=s.appVersion,n=s.userAgent,o="-",i=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Windows Vista",r:/Windows NT 6.0/},{s:"Windows Server 2003",r:/Windows NT 5.2/},{s:"Windows XP",r:/(Windows NT 5.1|Windows XP)/},{s:"Windows 2000",r:/(Windows NT 5.0|Windows 2000)/},{s:"Windows ME",r:/(Win 9x 4.90|Windows ME)/},{s:"Windows 98",r:/(Windows 98|Win98)/},{s:"Windows 95",r:/(Windows 95|Win95|Windows_95)/},{s:"Windows NT 4.0",r:/(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/},{s:"Windows CE",r:/Windows CE/},{s:"Windows 3.11",r:/Win16/},{s:"Android",r:/Android/},{s:"Open BSD",r:/OpenBSD/},{s:"Sun OS",r:/SunOS/},{s:"Linux",r:/(Linux|X11)/},{s:"iOS",r:/(iPhone|iPad|iPod)/},{s:"Mac OS X",r:/Mac OS X/},{s:"Mac OS",r:/(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/},{s:"QNX",r:/QNX/},{s:"UNIX",r:/UNIX/},{s:"BeOS",r:/BeOS/},{s:"OS/2",r:/OS\/2/},{s:"Search Bot",r:/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/}],a=0;e=i[a];a++)if(e.r.test(n)){o=e.s;break}var r="-";switch(/Windows/.test(o)&&(/Windows (.*)/.test(o)&&(r=/Windows (.*)/.exec(o)[1]),o="Windows"),o){case"Mac OS X":/Mac OS X (10[\.\_\d]+)/.test(n)&&(r=/Mac OS X (10[\.\_\d]+)/.exec(n)[1]);break;case"Android":/Android ([\.\_\d]+)/.test(n)&&(r=/Android ([\.\_\d]+)/.exec(n)[1]);break;case"iOS":/OS (\d+)_(\d+)_?(\d+)?/.test(n)&&(r=(r=/OS (\d+)_(\d+)_?(\d+)?/.exec(t))[1]+"."+r[2]+"."+(0|r[3]))}return{osName:o,osVersion:r}}())&&y.osName&&"-"!=y.osName?(a=y.osName,r=y.osVersion):i.any()&&"Android"==(a=i.getOsName())&&(r=!!(y=(l=(l||s.userAgent).toLowerCase()).match(/android\s([0-9\.]*)/))&&y[1]),"object"===(void 0===De?"undefined":Ue(De))&&"object"===Ue(De.versions)&&De.versions.node),ee=("Unknown OS"===a&&l&&(a="Nodejs",r=De.versions.node.toString().replace("v","")),!1),te=!1,ne=(["captureStream","mozCaptureStream","webkitCaptureStream"].forEach(function(e){"undefined"!=typeof document&&"function"==typeof document.createElement&&(!ee&&e in document.createElement("canvas")&&(ee=!0),!te&&e in document.createElement("video")&&(te=!0))}),/^(192\.168\.|169\.254\.|10\.|172\.(1[6-9]|2\d|3[01]))/),oe=/([0-9]{1,3}(\.[0-9]{1,3}){3})/,ie=/[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7}/,d=[],u=[],p=[],h=[],ae=(s.mediaDevices&&s.mediaDevices.enumerateDevices&&(s.enumerateDevices=function(e){var t=s.mediaDevices.enumerateDevices();t&&t.then?s.mediaDevices.enumerateDevices().then(e).catch(function(){e([])}):e([])}),!1),re=((void 0!==C&&"getSources"in C||s.mediaDevices&&s.mediaDevices.enumerateDevices)&&(ae=!0),!1),se=!1,ce=!1,m=!1,g=!1,v=window.DetectRTC||{};v.browser=function(){s.appVersion;var e,t,n=s.userAgent,o=s.appName,i=""+parseFloat(s.appVersion),a=parseInt(s.appVersion,10);if(J&&!K&&-1!==n.indexOf("CriOS")&&(K=!(J=!1)),Y){o="Opera";try{a=(i=s.userAgent.split("OPR/")[1].split(" ")[0]).split(".")[0]}catch(e){i="0.0.0.0",a=0}}else Q?(i=0<(e=n.indexOf("rv:"))?n.substring(e+3):(e=n.indexOf("MSIE"),n.substring(e+5)),o="IE"):K?(e=n.indexOf("Chrome"),o="Chrome",i=n.substring(e+7)):J?(e=n.indexOf("Safari"),o="Safari",i=n.substring(e+7),-1!==(e=n.indexOf("Version"))&&(i=n.substring(e+8)),-1!==s.userAgent.indexOf("Version/")&&(i=s.userAgent.split("Version/")[1].split(" ")[0])):X?(e=n.indexOf("Firefox"),o="Firefox",i=n.substring(e+8)):(t=n.lastIndexOf(" ")+1)<(e=n.lastIndexOf("/"))&&(o=n.substring(t,e),i=n.substring(e+1),o.toLowerCase()===o.toUpperCase()&&(o=s.appName));return W&&(o="Edge",i=s.userAgent.split("Edge/")[1]),-1!==(t=i.search(/[; \)]/))&&(i=i.substring(0,t)),a=parseInt(""+i,10),isNaN(a)&&(i=""+parseFloat(s.appVersion),a=parseInt(s.appVersion,10)),{fullVersion:i,version:a,name:o,isPrivateBrowsing:!1}}();try{if(window.webkitRequestFileSystem)window.webkitRequestFileSystem(window.TEMPORARY,1,function(){o=!1},function(e){o=!0});else if(window.indexedDB&&/Firefox/.test(window.navigator.userAgent)){try{(Z=window.indexedDB.open("test")).onerror=function(){return!0}}catch(e){o=!0}void 0===o&&$(function(){return"done"===Z.readyState},function(e){e||(o=!Z.result)})}else if(function(){var e=window.navigator.userAgent.toLowerCase();if(0!==e.indexOf("msie")||0!==e.indexOf("trident"))return e=/(?:msie|rv:)\s?([\d\.]+)/.exec(e),e&&10<=parseInt(e[1],10)}()){o=!1;try{window.indexedDB||(o=!0)}catch(e){o=!0}}else if(window.localStorage&&/Safari/.test(window.navigator.userAgent)){try{window.localStorage.setItem("test",1)}catch(e){o=!0}void 0===o&&(o=!1,window.localStorage.removeItem("test"))}}catch(e){o=!1}$(function(){return void 0!==o},function(e){var t;t=o,v.browser.isPrivateBrowsing=!!t}),v.browser["is"+v.browser.name]=!0,v.osName=a,v.osVersion=r,"object"===(void 0===De?"undefined":Ue(De))&&"object"===Ue(De.versions)&&De.versions["node-webkit"];var le=!1,y=(["RTCPeerConnection","webkitRTCPeerConnection","mozRTCPeerConnection","RTCIceGatherer"].forEach(function(e){le||e in window&&(le=!0)}),v.isWebRTCSupported=le,v.isORTCSupported="undefined"!=typeof RTCIceGatherer,!1),b=((v.browser.isChrome&&35<=v.browser.version||v.browser.isFirefox&&34<=v.browser.version||v.browser.isEdge&&17<=v.browser.version||"Android"===v.osName&&v.browser.isChrome)&&(y=!0),/^(https:|chrome-extension:)$/g.test(location.protocol||"")||("undefined"!=typeof document&&"string"==typeof document.domain&&document.domain.search&&-1===document.domain.search(/localhost|127.0./g)&&(v.browser.isChrome||v.browser.isEdge||v.browser.isOpera)||v.browser.isFirefox)&&(y=!1),v.isScreenCapturingSupported=y,{isSupported:!1,isCreateMediaStreamSourceSupported:!1}),l=(["AudioContext","webkitAudioContext","mozAudioContext","msAudioContext"].forEach(function(e){b.isSupported||e in window&&(b.isSupported=!0,window[e]&&"createMediaStreamSource"in window[e].prototype&&(b.isCreateMediaStreamSourceSupported=!0))}),v.isAudioContextSupported=b.isSupported,v.isCreateMediaStreamSourceSupported=b.isCreateMediaStreamSourceSupported,!1),a=(v.browser.isChrome&&31<v.browser.version&&(l=!0),v.isRtpDataChannelsSupported=l,!1),r=((v.browser.isFirefox&&28<v.browser.version||v.browser.isChrome&&25<v.browser.version||v.browser.isOpera&&11<=v.browser.version)&&(a=!0),v.isSctpDataChannelsSupported=a,v.isMobileDevice=t,!1),_=((s.getUserMedia||s.mediaDevices&&s.mediaDevices.getUserMedia)&&(r=!0),v.browser.isChrome&&46<=v.browser.version&&!/^(https:|chrome-extension:)$/g.test(location.protocol||"")&&"undefined"!=typeof document&&"string"==typeof document.domain&&document.domain.search&&-1===document.domain.search(/localhost|127.0./g)&&(r="Requires HTTPs"),"Nodejs"===v.osName&&(r=!1),v.isGetUserMediaSupported=r,y="",screen.width&&(y+=(screen.width||"")+" x "+(screen.height||"")),v.displayResolution=y,v.displayAspectRatio=((l=screen.width)/(t=function e(t,n){return 0==n?t:e(n,t%n)}(l,a=screen.height))/(a/t)).toFixed(2),v.isCanvasSupportsStreamCapturing=ee,v.isVideoSupportsStreamCapturing=te,"Chrome"==v.browser.name&&53<=v.browser.version&&(v.isCanvasSupportsStreamCapturing||(v.isCanvasSupportsStreamCapturing="Requires chrome flag: enable-experimental-web-platform-features"),v.isVideoSupportsStreamCapturing||(v.isVideoSupportsStreamCapturing="Requires chrome flag: enable-experimental-web-platform-features")),v.DetectLocalIPAddress=function(n,e){if(v.isWebRTCSupported){var o=!0,i=!0;if("undefined"!=typeof document&&"function"==typeof document.getElementById){var a={};if(!(r=window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection)){var t=document.getElementById("iframe");if(!t)return;var t=t.contentWindow,r=t.RTCPeerConnection||t.mozRTCPeerConnection||t.webkitRTCPeerConnection}if(r){var t=null,s=new r({iceServers:[{urls:"stun:stun.l.google.com:19302"}]},t="Chrome"===v.browser&&v.browser.version<58?{optional:[{RtpDataChannels:!0}]}:t);if(e&&(s.addStream?s.addStream(e):s.addTrack&&e.getTracks()[0]&&s.addTrack(e.getTracks()[0],e)),s.onicecandidate=function(e){e.candidate&&c(e.candidate.candidate)},!e)try{s.createDataChannel("sctp",{})}catch(e){}v.isPromisesSupported?s.createOffer().then(function(e){s.setLocalDescription(e).then(l)}):s.createOffer(function(e){s.setLocalDescription(e,l,function(){})},function(){})}}function c(e){var t=oe.exec(e);t&&(t=t[1],e.match(ne),void 0===a[t]&&((e=t).match(ne)?n("Local: "+e,o=!1,i):e.match(ie)?n("Public: "+e,o,i=!1):n("Public: "+e,o,i)),a[t]=!0)}function l(){s.localDescription.sdp.split("\n").forEach(function(e){0===e.indexOf("a=candidate:")&&c(e)})}}},v.isWebSocketsSupported="WebSocket"in window&&2===window.WebSocket.CLOSING,v.isWebSocketsBlocked=!v.isWebSocketsSupported,"Nodejs"===v.osName&&(v.isWebSocketsSupported=!0,v.isWebSocketsBlocked=!1),v.checkWebSocketsSupport=function(t){t=t||function(){};try{var e,n=new WebSocket("wss://echo.websocket.org:443/");n.onopen=function(){v.isWebSocketsBlocked=!1,e=(new Date).getTime(),n.send("ping")},n.onmessage=function(){v.WebsocketLatency=(new Date).getTime()-e+"ms",t(),n.close(),n=null},n.onerror=function(){v.isWebSocketsBlocked=!0,t()}}catch(e){v.isWebSocketsBlocked=!0,t()}},v.load=function(e){var t,o;t=e=e||function(){},ae?(!s.enumerateDevices&&window.MediaStreamTrack&&window.MediaStreamTrack.getSources&&(s.enumerateDevices=window.MediaStreamTrack.getSources.bind(window.MediaStreamTrack)),!s.enumerateDevices&&s.enumerateDevices&&(s.enumerateDevices=s.enumerateDevices.bind(s)),s.enumerateDevices?(d=[],u=[],p=[],g=m=ce=se=re=!(h=[]),o={},s.enumerateDevices(function(e){e.forEach(function(e){var t,n={};for(t in e)try{"function"!=typeof e[t]&&(n[t]=e[t])}catch(e){}o[n.deviceId+n.label+n.kind]||("audio"===n.kind&&(n.kind="audioinput"),"video"===n.kind&&(n.kind="videoinput"),n.deviceId||(n.deviceId=n.id),n.id||(n.id=n.deviceId),n.label?("videoinput"!==n.kind||g||(g=!0),"audioinput"!==n.kind||m||(m=!0)):(n.isCustomLabel=!0,"videoinput"===n.kind?n.label="Camera "+(h.length+1):"audioinput"===n.kind?n.label="Microphone "+(u.length+1):"audiooutput"===n.kind?n.label="Speaker "+(p.length+1):n.label="Please invoke getUserMedia once.",void 0!==v&&v.browser.isChrome&&46<=v.browser.version&&!/^(https:|chrome-extension:)$/g.test(location.protocol||"")&&"undefined"!=typeof document&&"string"==typeof document.domain&&document.domain.search&&-1===document.domain.search(/localhost|127.0./g)&&(n.label="HTTPs is required to get label of this "+n.kind+" device.")),"audioinput"===n.kind&&(re=!0,-1===u.indexOf(n)&&u.push(n)),"audiooutput"===n.kind&&(se=!0,-1===p.indexOf(n)&&p.push(n)),"videoinput"===n.kind&&(ce=!0,-1===h.indexOf(n)&&h.push(n)),d.push(n),o[n.deviceId+n.label+n.kind]=n)}),void 0!==v&&(v.MediaDevices=d,v.hasMicrophone=re,v.hasSpeakers=se,v.hasWebcam=ce,v.isWebsiteHasWebcamPermissions=g,v.isWebsiteHasMicrophonePermissions=m,v.audioInputDevices=u,v.audioOutputDevices=p,v.videoInputDevices=h),t&&t()})):t&&t()):t&&t()},v.MediaDevices=void 0!==d?d:[],v.hasMicrophone=re,v.hasSpeakers=se,v.hasWebcam=ce,v.isWebsiteHasWebcamPermissions=g,v.isWebsiteHasMicrophonePermissions=m,v.audioInputDevices=u,v.audioOutputDevices=p,v.videoInputDevices=h,r=!1,"undefined"!=typeof document&&"function"==typeof document.createElement&&"setSinkId"in document.createElement("video")&&(r=!0),v.isSetSinkIdSupported=r,y=!1,v.browser.isFirefox&&"undefined"!=typeof mozRTCPeerConnection?"getSenders"in mozRTCPeerConnection.prototype&&(y=!0):v.browser.isChrome&&"undefined"!=typeof webkitRTCPeerConnection&&"getSenders"in webkitRTCPeerConnection.prototype&&(y=!0),v.isRTPSenderReplaceTracksSupported=y,l=!1,v.browser.isFirefox&&38<v.browser.version&&(l=!0),v.isRemoteStreamProcessingSupported=l,a=!1,void 0!==C&&"applyConstraints"in C.prototype&&(a=!0),v.isApplyConstraintsSupported=a,t=!1,v.browser.isFirefox&&43<=v.browser.version&&(t=!0),v.isMultiMonitorScreenCapturingSupported=t,v.isPromisesSupported=!!("Promise"in window),v.version="1.3.7",void 0===v&&(window.DetectRTC={}),void 0===(r=window.MediaStream)&&"undefined"!=typeof webkitMediaStream&&(r=webkitMediaStream),v.MediaStream=void 0!==r&&"function"==typeof r&&Object.keys(r.prototype),v.MediaStreamTrack=void 0!==C&&Object.keys(C.prototype),y=window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,v.RTCPeerConnection=void 0!==y&&Object.keys(y.prototype),window.DetectRTC=v,"function"==typeof define&&Ve(144)&&define("DetectRTC",[],function(){return v}),"undefined"!=typeof cordova&&(DetectRTC.isMobileDevice=!0,DetectRTC.browser.name="Chrome"),navigator&&navigator.userAgent&&-1!==navigator.userAgent.indexOf("Crosswalk")&&(DetectRTC.isMobileDevice=!0,DetectRTC.browser.name="Chrome"),window.addEventListener||(window.addEventListener=function(e,t,n){e.attachEvent&&e.attachEvent("on"+t,n)}),window.attachEventListener=function(e,t,n,o){e.addEventListener(t,n,o)},window.MediaStream);function w(e,t){return!(e.session.audio&&"two-way"===e.session.audio||("Firefox"!==DetectRTC.browser.name||!1===t)&&("Chrome"!==DetectRTC.browser.name||DetectRTC.browser.version<50||!0!==typeof t&&(void 0!==t||!e.session.audio||!e.session.screen||e.session.video)))}function de(e){return"Firefox"===DetectRTC.browser.name||"Chrome"===DetectRTC.browser.name&&{mandatory:{chromeMediaSource:e.mandatory.chromeMediaSource,chromeMediaSourceId:e.mandatory.chromeMediaSourceId}}}function S(e,t){return e&&e.getTracks?e.getTracks().filter(function(e){return e.kind===(t||"audio")}):[]}function ue(){var e;"undefined"!=typeof cordova&&void 0!==cordova.plugins&&void 0!==cordova.plugins.iosrtc&&(e=cordova.plugins.iosrtc,window.webkitRTCPeerConnection=e.RTCPeerConnection,window.RTCSessionDescription=e.RTCSessionDescription,window.RTCIceCandidate=e.RTCIceCandidate,window.MediaStream=e.MediaStream,window.MediaStreamTrack=e.MediaStreamTrack,navigator.getUserMedia=navigator.webkitGetUserMedia=e.getUserMedia,e.debug.enable("iosrtc*"),"function"==typeof e.selectAudioOutput&&e.selectAudioOutput(window.iOSDefaultAudioOutputDevice||"speaker"),e.registerGlobals())}void 0===(_=void 0===_&&"undefined"!=typeof webkitMediaStream?webkitMediaStream:_)||"stop"in _.prototype||(_.prototype.stop=function(){this.getTracks().forEach(function(e){e.stop()})}),window.iOSDefaultAudioOutputDevice=window.iOSDefaultAudioOutputDevice||"speaker",document.addEventListener("deviceready",ue,!1),ue();var T,x={};function fe(e){return{OfferToReceiveAudio:!!e.OfferToReceiveAudio,OfferToReceiveVideo:!!e.OfferToReceiveVideo}}void 0!==window.RTCPeerConnection?T=window.RTCPeerConnection:"undefined"!=typeof mozRTCPeerConnection?T=mozRTCPeerConnection:"undefined"!=typeof webkitRTCPeerConnection&&(T=webkitRTCPeerConnection);var pe=window.RTCSessionDescription||window.mozRTCSessionDescription,he=window.RTCIceCandidate||window.mozRTCIceCandidate,C=window.MediaStreamTrack;function me(n){if(void 0!==window.RTCPeerConnection?T=window.RTCPeerConnection:"undefined"!=typeof mozRTCPeerConnection?T=mozRTCPeerConnection:"undefined"!=typeof webkitRTCPeerConnection&&(T=webkitRTCPeerConnection),pe=window.RTCSessionDescription||window.mozRTCSessionDescription,he=window.RTCIceCandidate||window.mozRTCIceCandidate,C=window.MediaStreamTrack,!T)throw"WebRTC 1.0 (RTCPeerConnection) API are NOT available in this browser.";var o=n.rtcMultiConnection,i=(this.extra=(n.remoteSdp||o).extra,this.userid=n.userid,this.streams=[],this.channels=n.channels||[],this.connectionDescription=n.connectionDescription,this.addStream=function(e){o.addStream(e,i.userid)},this.removeStream=function(e){o.removeStream(e,i.userid)},this);n.remoteSdp&&(this.connectionDescription=n.remoteSdp.connectionDescription);var a,r={},e=(x.sdpConstraints=fe({OfferToReceiveAudio:!0,OfferToReceiveVideo:!0}),!!n.renegotiatingPeer),t=(n.remoteSdp&&(e=!!n.remoteSdp.renegotiatingPeer),[]);if(o.attachStreams.forEach(function(e){e&&t.push(e)}),e)a=n.peerRef;else{var s="all";!o.candidates.turn&&!o.candidates.relay||o.candidates.stun||o.candidates.reflexive||o.candidates.host||(s="relay");try{var c={iceServers:o.iceServers,iceTransportPolicy:o.iceTransportPolicy||s};void 0!==o.iceCandidatePoolSize&&(c.iceCandidatePoolSize=o.iceCandidatePoolSize),void 0!==o.bundlePolicy&&(c.bundlePolicy=o.bundlePolicy),void 0!==o.rtcpMuxPolicy&&(c.rtcpMuxPolicy=o.rtcpMuxPolicy),"Chrome"===DetectRTC.browser.name&&(c.sdpSemantics=o.sdpSemantics||"unified-plan"),o.iceServers&&o.iceServers.length||(c=null,o.optionalArgument=null),a=new T(c,o.optionalArgument)}catch(e){try{c={iceServers:o.iceServers},a=new T(c)}catch(e){a=new T}}}!a.getRemoteStreams&&a.getReceivers&&(a.getRemoteStreams=function(){var t=new _;return a.getReceivers().forEach(function(e){t.addTrack(e.track)}),[t]}),!a.getLocalStreams&&a.getSenders&&(a.getLocalStreams=function(){var t=new _;return a.getSenders().forEach(function(e){t.addTrack(e.track)}),[t]}),a.onicecandidate=function(e){e.candidate?o.trickleIce&&n.onLocalCandidate({candidate:e.candidate.candidate,sdpMid:e.candidate.sdpMid,sdpMLineIndex:e.candidate.sdpMLineIndex}):o.trickleIce||(e=a.localDescription,n.onLocalSdp({type:e.type,sdp:e.sdp,remotePeerSdpConstraints:n.remotePeerSdpConstraints||!1,renegotiatingPeer:!!n.renegotiatingPeer||!1,connectionDescription:i.connectionDescription,dontGetRemoteStream:!!n.dontGetRemoteStream,extra:o?o.extra:{},streamsToShare:u}))},t.forEach(function(t){n.remoteSdp&&n.remoteSdp.remotePeerSdpConstraints&&n.remoteSdp.remotePeerSdpConstraints.dontGetRemoteStream||n.dontAttachLocalStream||(t=o.beforeAddingStream(t,i))&&(a.getLocalStreams().forEach(function(e){t&&e.id==t.id&&(t=null)}),t&&t.getTracks&&t.getTracks().forEach(function(e){try{a.addTrack(e,t)}catch(e){}}))}),a.oniceconnectionstatechange=a.onsignalingstatechange=function(){var e=i.extra;o.peers[i.userid]&&(e=o.peers[i.userid].extra||e),a&&(n.onPeerStateChanged({iceConnectionState:a.iceConnectionState,iceGatheringState:a.iceGatheringState,signalingState:a.signalingState,extra:e,userid:i.userid}),a&&a.iceConnectionState&&-1!==a.iceConnectionState.search(/closed|failed/gi)&&i.streams instanceof Array&&i.streams.forEach(function(e){e=o.streamEvents[e.id]||{streamid:e.id,stream:e,type:"remote"};o.onstreamended(e)}))};var s={OfferToReceiveAudio:!!t.length,OfferToReceiveVideo:!!t.length},l=(n.localPeerSdpConstraints&&(s=n.localPeerSdpConstraints),x.sdpConstraints=fe(s),{}),c=(a.ontrack=function(t){var e;t&&"track"===t.type&&(t.stream=t.streams[t.streams.length-1],t.stream.id||(t.stream.id=t.track.id),l[t.stream.id]&&"Safari"!==DetectRTC.browser.name?t.track&&(t.track.onended=function(){a.onremovestream(t)}):(l[t.stream.id]=t.stream.id,e={},n.remoteSdp&&n.remoteSdp.streamsToShare?e=n.remoteSdp.streamsToShare:n.streamsToShare&&(e=n.streamsToShare),(e=e[t.stream.id])?(t.stream.isAudio=e.isAudio,t.stream.isVideo=e.isVideo,t.stream.isScreen=e.isScreen):(t.stream.isVideo=!!S(t.stream,"video").length,t.stream.isAudio=!t.stream.isVideo,t.stream.isScreen=!1),t.stream.streamid=t.stream.id,r[t.stream.id]=t.stream,n.onRemoteStream(t.stream),t.stream.getTracks().forEach(function(e){e.onended=function(){a.onremovestream(t)}}),t.stream.onremovetrack=function(){a.onremovestream(t)}))},a.onremovestream=function(e){e.stream.streamid=e.stream.id,r[e.stream.id]&&delete r[e.stream.id],n.onRemoteStreamRemoved(e.stream)},"function"!=typeof a.removeStream&&(a.removeStream=function(t){t.getTracks().forEach(function(e){a.removeTrack(e,t)})}),this.addRemoteCandidate=function(e){a.addIceCandidate(new he(e))},this.addRemoteSdp=function(t,n){n=n||function(){},"Safari"!==DetectRTC.browser.name&&(t.sdp=o.processSdp(t.sdp)),a.setRemoteDescription(new pe(t)).then(n,function(e){o.enableLogs&&console.error("setRemoteDescription failed","\n",e,"\n",t.sdp),n()}).catch(function(e){o.enableLogs&&console.error("setRemoteDescription failed","\n",e,"\n",t.sdp),n()})},!0);function d(t){t.binaryType="arraybuffer",t.onmessage=function(e){n.onDataChannelMessage(e.data)},t.onopen=function(){n.onDataChannelOpened(t)},t.onerror=function(e){n.onDataChannelError(e)},t.onclose=function(e){n.onDataChannelClosed(e)},t.internalSend=t.send,t.send=function(e){"open"===t.readyState&&t.internalSend(e)},a.channel=t}n.remoteSdp&&(c=!1),this.createDataChannel=function(){d(a.createDataChannel("sctp",{}))},!0!==o.session.data||e||(c?this.createDataChannel():a.ondatachannel=function(e){d(e.channel)}),this.enableDisableVideoEncoding=function(e){var t,n;a.getSenders().forEach(function(e){t||"video"!==e.track.kind||(t=e)}),t&&t.getParameters&&((n=t.getParameters()).encodings[1]&&(n.encodings[1].active=!!e),n.encodings[2]&&(n.encodings[2].active=!!e),t.setParameters(n))},n.remoteSdp&&(n.remoteSdp.remotePeerSdpConstraints&&(s=n.remoteSdp.remotePeerSdpConstraints),x.sdpConstraints=fe(s),this.addRemoteSdp(n.remoteSdp,function(){f("createAnswer")})),"two-way"!=o.session.audio&&"two-way"!=o.session.video&&"two-way"!=o.session.screen||(x.sdpConstraints=fe({OfferToReceiveAudio:"two-way"==o.session.audio||n.remoteSdp&&n.remoteSdp.remotePeerSdpConstraints&&n.remoteSdp.remotePeerSdpConstraints.OfferToReceiveAudio,OfferToReceiveVideo:"two-way"==o.session.video||"two-way"==o.session.screen||n.remoteSdp&&n.remoteSdp.remotePeerSdpConstraints&&n.remoteSdp.remotePeerSdpConstraints.OfferToReceiveAudio}));var u={};function f(e){a[e](x.sdpConstraints).then(function(e){"Safari"!==DetectRTC.browser.name&&(e.sdp=o.processSdp(e.sdp)),a.setLocalDescription(e).then(function(){o.trickleIce&&(n.onLocalSdp({type:e.type,sdp:e.sdp,remotePeerSdpConstraints:n.remotePeerSdpConstraints||!1,renegotiatingPeer:!!n.renegotiatingPeer||!1,connectionDescription:i.connectionDescription,dontGetRemoteStream:!!n.dontGetRemoteStream,extra:o?o.extra:{},streamsToShare:u}),o.onSettingLocalDescription(i))},function(e){o.enableLogs&&console.error("setLocalDescription error",e)})},function(e){o.enableLogs&&console.error("sdp-error",e)})}a.getLocalStreams().forEach(function(e){u[e.streamid]={isAudio:!!e.isAudio,isVideo:!!e.isVideo,isScreen:!!e.isScreen}}),c&&f("createOffer"),a.nativeClose=a.close,a.close=function(){if(a){try{a.nativeClose!==a.close&&a.nativeClose()}catch(e){}a=null,i.peer=null}},this.peer=a}var E={removeVPX:function(e){var t=ye(e);return e=ve(e,"vp9",t,!0),ve(e,"vp8",t,!0)},disableNACK:function(e){if(e&&"string"==typeof e)return(e=(e=(e=e.replace("a=rtcp-fb:126 nack\r\n","")).replace("a=rtcp-fb:126 nack pli\r\n","a=rtcp-fb:126 pli\r\n")).replace("a=rtcp-fb:97 nack\r\n","")).replace("a=rtcp-fb:97 nack pli\r\n","a=rtcp-fb:97 pli\r\n");throw"Invalid arguments."},prioritize:function(o,e){if(e&&e.getSenders&&e.getSenders().length){if(!o||"string"!=typeof o)throw"Invalid arguments.";e.getSenders().forEach(function(e){for(var t=e.getParameters(),n=0;n<t.codecs.length;n++)if(t.codecs[n].mimeType==o){t.codecs.unshift(t.codecs.splice(n,1));break}e.setParameters(t)})}},removeNonG722:function(e){return e.replace(/m=audio ([0-9]+) RTP\/SAVPF ([0-9 ]*)/g,"m=audio $1 RTP/SAVPF 9")},setApplicationSpecificBandwidth:function(e,t,n){return e=e,n=n,!(t=t)||void 0!==xe&&xe||(n&&(t.screen?t.screen<300&&console.warn("It seems that you are using wrong bandwidth value for screen. Screen sharing is expected to fail."):console.warn("It seems that you are not using bandwidth for screen. Screen sharing is expected to fail.")),t.screen&&n&&(e=(e=e.replace(/b=AS([^\r\n]+\r\n)/g,"")).replace(/a=mid:video\r\n/g,"a=mid:video\r\nb=AS:"+t.screen+"\r\n")),(t.audio||t.video)&&(e=e.replace(/b=AS([^\r\n]+\r\n)/g,"")),t.audio&&(e=e.replace(/a=mid:audio\r\n/g,"a=mid:audio\r\nb=AS:"+t.audio+"\r\n")),t.screen?e=e.replace(/a=mid:video\r\n/g,"a=mid:video\r\nb=AS:"+t.screen+"\r\n"):t.video&&(e=e.replace(/a=mid:video\r\n/g,"a=mid:video\r\nb=AS:"+t.video+"\r\n"))),e},setVideoBitrates:function(e,t){var n,o,i=void 0,t=(i=t||{}).min,i=i.max,a=e.split("\r\n"),r=M(a,"a=rtpmap","VP8/90000");return(n=r?be(a[r]):n)?((r=M(a,"a=rtpmap","rtx/90000"))&&(o=be(a[r])),r&&null!==(r=M(a,"a=fmtp:"+o.toString()))&&(o="\r\n",a[r]=a[r].concat(o+="a=fmtp:"+n+" x-google-min-bitrate="+(t||"228")+"; x-google-max-bitrate="+(i||"228")),e=a.join("\r\n")),e):e},setOpusAttributes:function(e,t){var n=void 0,t=(n=t||{},e.split("\r\n")),o=M(t,"a=rtpmap","opus/48000");if(!(i=o?be(t[o]):i))return e;if(null===(o=M(t,"a=fmtp:"+i.toString())))return e;var i="",i=(i+="; stereo="+(void 0!==n.stereo?n.stereo:"1"))+("; sprop-stereo="+(void 0!==n["sprop-stereo"]?n["sprop-stereo"]:"1"));return void 0!==n.maxaveragebitrate&&(i+="; maxaveragebitrate="+(n.maxaveragebitrate||1048576)),void 0!==n.maxplaybackrate&&(i+="; maxplaybackrate="+(n.maxplaybackrate||1048576)),void 0!==n.cbr&&(i+="; cbr="+(void 0!==n.cbr?n.cbr:"1")),void 0!==n.useinbandfec&&(i+="; useinbandfec="+n.useinbandfec),void 0!==n.usedtx&&(i+="; usedtx="+n.usedtx),void 0!==n.maxptime&&(i+="\r\na=maxptime:"+n.maxptime),t[o]=t[o].concat(i),t.join("\r\n")},preferVP9:function(e){return ge(e,"vp9")},preferCodec:ge,forceStereoAudio:function(e){for(var t=e.split("\r\n"),n=null,o=0;o<t.length;o++)if(-1!==t[o].search("opus/48000")){var i=extractSdp(t[o],/:(\d+) opus\/48000/i);break}for(o=0;o<t.length;o++)if(-1!==t[o].search("a=fmtp")&&extractSdp(t[o],/a=fmtp:(\d+)/)===i){n=o;break}return null===n?e:(t[n]=t[n].concat("; stereo=1; sprop-stereo=1"),t.join("\r\n"))}};function ge(e,t){var n=ye(e);return!n.videoCodecNumbers||"vp8"===t&&n.vp8LineNumber===n.videoCodecNumbers[0]||"vp9"===t&&n.vp9LineNumber===n.videoCodecNumbers[0]||"h264"===t&&n.h264LineNumber===n.videoCodecNumbers[0]?e:ve(e,t,n)}function ve(e,t,n,o){var i="";if("vp8"===t){if(!n.vp8LineNumber)return e;i=n.vp8LineNumber}if("vp9"===t){if(!n.vp9LineNumber)return e;i=n.vp9LineNumber}if("h264"===t){if(!n.h264LineNumber)return e;i=n.h264LineNumber}var t=n.videoCodecNumbersOriginal.split("SAVPF")[0]+"SAVPF ",a=o?[]:[i];return n.videoCodecNumbers.forEach(function(e){e!==i&&a.push(e)}),t+=a.join(" "),e.replace(n.videoCodecNumbersOriginal,t)}function ye(e){var n={};return e.split("\n").forEach(function(t){0===t.indexOf("m=video")&&(n.videoCodecNumbers=[],t.split("SAVPF")[1].split(" ").forEach(function(e){(e=e.trim())&&e.length&&(n.videoCodecNumbers.push(e),n.videoCodecNumbersOriginal=t)})),-1===t.indexOf("VP8/90000")||n.vp8LineNumber||(n.vp8LineNumber=t.replace("a=rtpmap:","").split(" ")[0]),-1===t.indexOf("VP9/90000")||n.vp9LineNumber||(n.vp9LineNumber=t.replace("a=rtpmap:","").split(" ")[0]),-1===t.indexOf("H264/90000")||n.h264LineNumber||(n.h264LineNumber=t.replace("a=rtpmap:","").split(" ")[0])}),n}function M(e,t,n){for(var o=e,i=t,a=n,r=o.length,s=0;s<r;++s)if(0===o[s].indexOf(i)&&(!a||-1!==o[s].toLowerCase().indexOf(a.toLowerCase())))return s;return null}function be(e){var t=new RegExp("a=rtpmap:(d+) w+/d+"),e=e.match(t);return e&&2===e.length?e[1]:null}window.BandwidthHandler=E;var _e={processCandidates:function(e,t){var n=t.candidate,o=e.candidates,i=o.stun,a=o.turn;if(H(o.reflexive)||(i=o.reflexive),H(o.relay)||(a=o.relay),(o.host||!n.match(/typ host/g))&&(a||!n.match(/typ relay/g))&&(i||!n.match(/typ srflx/g))){o=e.iceProtocols;if((o.udp||!n.match(/ udp /g))&&(o.tcp||!n.match(/ tcp /g)))return e.enableLogs&&console.debug("Your candidate pairs:",n),{candidate:n,sdpMid:t.sdpMid,sdpMLineIndex:t.sdpMLineIndex}}}},l=function(e){return window.EJS_TURN_URLS};function we(i){if(!0!==currentUserMediaRequest.mutex){currentUserMediaRequest.mutex=!0;var t,n,o,a=JSON.stringify(i.localMediaConstraints);if(currentUserMediaRequest.streams[a])r(currentUserMediaRequest.streams[a].stream,!0);else{if(/BB10|BlackBerry/i.test(navigator.userAgent||"")||void 0===navigator.mediaDevices||"function"!=typeof navigator.mediaDevices.getUserMedia)return navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia,void navigator.getUserMedia(i.localMediaConstraints,function(e){e.streamid=e.streamid||e.id||f(),e.idInstance=a,r(e)},function(e){i.onLocalMediaError(e,i.localMediaConstraints)});void 0===navigator.mediaDevices&&(navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia,o=function(){},navigator.mediaDevices={getUserMedia:function(e){return navigator.getUserMedia(e,function(e){e(stream),t=stream},function(e){o(e),n=e}),{then:function(e){if(!t)return{then:function(e){n?e(n):o=e}};e(t)}}}}),navigator.mediaDevices.getUserMedia(i.localMediaConstraints).then(function(e){e.streamid=e.streamid||e.id||f(),e.idInstance=a,r(e)}).catch(function(e){i.onLocalMediaError(e,i.localMediaConstraints)})}}else currentUserMediaRequest.queueRequests.push(i);function r(e,t){o=i.localMediaConstraints,n=e,o.mandatory&&o.mandatory.chromeMediaSource||o.mozMediaSource||o.mediaSource?n.isScreen=!0:o.video?n.isVideo=!0:o.audio&&(n.isAudio=!0);var n,o="ended";"oninactive"in e&&(o="inactive"),e.addEventListener(o,function(){delete currentUserMediaRequest.streams[a],currentUserMediaRequest.mutex=!1,currentUserMediaRequest.queueRequests.indexOf(i)&&(delete currentUserMediaRequest.queueRequests[currentUserMediaRequest.queueRequests.indexOf(i)],currentUserMediaRequest.queueRequests=q(currentUserMediaRequest.queueRequests))},!1),currentUserMediaRequest.streams[a]={stream:e},currentUserMediaRequest.mutex=!1,currentUserMediaRequest.queueRequests.length&&we(currentUserMediaRequest.queueRequests.shift()),i.onGettingLocalMedia(e,t)}}window.currentUserMediaRequest={streams:[],mutex:!1,queueRequests:[],remove:function(e){this.mutex=!1;var t=this.streams[e];t&&(t=t.stream.currentUserMediaRequestOptions,this.queueRequests.indexOf(t)&&(delete this.queueRequests[this.queueRequests.indexOf(t)],this.queueRequests=q(this.queueRequests)),this.streams[e].stream=null,delete this.streams[e])}};var R={setHandlers:function(o,i,a){var e;o&&o.addEventListener&&(void 0!==i&&1!=i||(e="ended","oninactive"in o&&(e="inactive"),o.addEventListener(e,function(){R.onSyncNeeded(this.streamid,e)},!1)),o.mute=function(e,t){e=Se(e),void 0!==t&&(i=t),void 0!==e&&"audio"!=e||S(o,"audio").forEach(function(e){e.enabled=!1,a.streamEvents[o.streamid].isAudioMuted=!0}),void 0!==e&&"video"!=e||S(o,"video").forEach(function(e){e.enabled=!1}),void 0!==i&&1!=i||R.onSyncNeeded(o.streamid,"mute",e),a.streamEvents[o.streamid].muteType=e||"both",B(o,"mute",e)},o.unmute=function(e,t){var n;e=Se(e),void 0!==t&&(i=t),a.streamEvents[o.streamid].mediaElement&&((n=a.streamEvents[o.streamid].mediaElement).volume=0,function e(t,n,o,i){n<=(i=(i||0)+1)||setTimeout(function(){o(),e(t,n,o,i)},t)}(200,5,function(){try{n.volume+=.2}catch(e){n.volume=1}})),void 0!==e&&"audio"!=e||S(o,"audio").forEach(function(e){e.enabled=!0,a.streamEvents[o.streamid].isAudioMuted=!1}),void 0!==e&&"video"!=e||(S(o,"video").forEach(function(e){e.enabled=!0}),void 0!==e&&"video"==e&&a.streamEvents[o.streamid].isAudioMuted&&function e(t){t=t||0,++t<100&&a.streamEvents[o.streamid].isAudioMuted&&(o.mute("audio"),setTimeout(function(){e(t)},50))}()),void 0!==i&&1!=i||R.onSyncNeeded(o.streamid,"unmute",e),a.streamEvents[o.streamid].unmuteType=e||"both",B(o,"unmute",e)})},onSyncNeeded:function(e,t,n){}};function Se(e){if(e)return"string"==typeof e||void 0===e?e:e.audio&&e.video?null:e.audio?"audio":e.video?"video":void 0}window.addEventListener("message",function(e){if(e.origin==window.location.origin){e=e.data;if("PermissionDeniedError"==e){if(k="PermissionDeniedError",O)return void O("PermissionDeniedError");throw new Error("PermissionDeniedError")}"rtcmulticonnection-extension-loaded"==e&&(k="desktop"),e.sourceId&&O&&O(A=e.sourceId,!0===e.canRequestAudioTrack)}});var A,O,k="screen";function Te(e){if(e){if("desktop"==k)return e(!0);window.postMessage("are-you-there","*"),setTimeout(function(){e("screen"!=k)},2e3)}}var xe=void 0!==window.InstallTrigger;window.opera||navigator.userAgent.indexOf(" OPR/");function Ce(e,t){if(xe)return t("not-chrome");2!=arguments.length&&(t=e,e="ajhifddimkapgcifgcodmmfdlknahffk");var n=document.createElement("img");n.src="chrome-extension://"+e+"/icon.png",n.onload=function(){k="screen",window.postMessage("are-you-there","*"),setTimeout(function(){t("screen"==k?"installed-disabled":"installed-enabled")},2e3)},n.onerror=function(){t("not-installed")}}function Ee(r){var s={};return{receive:function(e,t,n){var o,i,a=e.uuid;s[a]||(s[a]=[]),s[a].push(e.message),e.last&&(o=s[a].join(""),i={data:o=e.isobject?JSON.parse(o):o,userid:t,extra:n,latency:(new Date).getTime()-e.sendingTime},r.autoTranslateText?(i.original=i.data,r.Translator.TranslateText(i.data,function(e){i.data=e,r.onmessage(i)})):r.onmessage(i),delete s[a])}}}window.chrome;var P,I,Me,N,Re,Ae={send:function(e){var i=e.connection,a=e.channel,r=e.remoteUserId,e=e.text,s=i.chunkSize||1e3,c="",l=!1,d=("string"!=typeof e&&(l=!0,e=JSON.stringify(e)),f()),u=(new Date).getTime();!function e(t,n){var o={type:"text",uuid:d,sendingTime:u};t&&(n=t,o.packets=parseInt(n.length/s)),n.length>s?o.message=n.slice(0,s):(o.message=n,o.last=!0,o.isobject=l),a.send(o,r),(c=n.slice(o.message.length)).length&&setTimeout(function(){e(null,c)},i.chunkInterval||100)}(e)}},a={handle:function(n){var o={};n.onFileStart=function(e){var t=document.createElement("div");if(t.title=e.name,t.innerHTML="<label>0%</label> <progress></progress>",e.remoteUserId&&(t.innerHTML+=" (Sharing with:"+e.remoteUserId+")"),n.filesContainer||(n.filesContainer=document.body||document.documentElement),n.filesContainer.insertBefore(t,n.filesContainer.firstChild),!e.remoteUserId)return o[e.uuid]={div:t,progress:t.querySelector("progress"),label:t.querySelector("label")},void(o[e.uuid].progress.max=e.maxChunks);o[e.uuid]||(o[e.uuid]={}),o[e.uuid][e.remoteUserId]={div:t,progress:t.querySelector("progress"),label:t.querySelector("label")},o[e.uuid][e.remoteUserId].progress.max=e.maxChunks},n.onFileProgress=function(e){var t=o[e.uuid];!t||e.remoteUserId&&!(t=o[e.uuid][e.remoteUserId])||(t.progress.value=e.currentPosition||e.maxChunks||t.progress.max,e=t.progress,t=t.label,-1!==e.position&&(e=+e.position.toFixed(2).split(".")[1]||100,t.innerHTML=e+"%"))},n.onFileEnd=function(e){var t=o[e.uuid];t?e.remoteUserId&&!(t=o[e.uuid][e.remoteUserId])||(t=t.div,-1!=e.type.indexOf("image")?t.innerHTML='<a href="'+e.url+'" download="'+e.name+'">Download <strong style="color:red;">'+e.name+'</strong> </a><br /><img src="'+e.url+'" title="'+e.name+'" style="max-width: 80%;">':t.innerHTML='<a href="'+e.url+'" download="'+e.name+'">Download <strong style="color:red;">'+e.name+'</strong> </a><br /><iframe src="'+e.url+'" title="'+e.name+'" style="width: 80%;border: 0;height: inherit;margin-top:1em;"></iframe>'):console.error("No such progress-helper element exist.",e)}}},t={handle:function(i){i.autoTranslateText=!1,i.language="en",i.googKey="AIzaSyCgB5hmFY74WYB-EoWkhr9cAGr6TiTHrEE",i.Translator={TranslateText:function(e,t){var n=document.createElement("script"),e=(n.type="text/javascript",encodeURIComponent(e)),o="method"+i.token(),o=(window[o]=function(e){e.data&&e.data.translations[0]&&t?t(e.data.translations[0].translatedText):e.error&&"Daily Limit Exceeded"===e.error.message?console.error('Text translation failed. Error message: "Daily Limit Exceeded."'):e.error?console.error(e.error.message):console.error(e)},"https://www.googleapis.com/language/translate/v2?key="+i.googKey+"&target="+(i.language||"en-US")+"&callback=window."+o+"&q="+e);n.src=o,document.getElementsByTagName("head")[0].appendChild(n)},getListOfLanguages:function(t){var n=new XMLHttpRequest,e=(n.onreadystatechange=function(){var e;n.readyState==XMLHttpRequest.DONE&&((e=JSON.parse(n.responseText))&&e.data&&e.data.languages?t(e.data.languages):e.error&&"Daily Limit Exceeded"===e.error.message?console.error('Text translation failed. Error message: "Daily Limit Exceeded."'):e.error?console.error(e.error.message):console.error(e))},"https://www.googleapis.com/language/translate/v2/languages?key="+i.googKey+"&target=en");n.open("GET",e,!0),n.send(null)}}}};function L(t){if(P.socketAutoReConnect=!0,P.socket)t&&t(P.socket);else{if(void 0===n)if("undefined"!=typeof FirebaseConnection)window.SocketConnection=FirebaseConnection;else{if("undefined"==typeof PubNubConnection)throw"SocketConnection.js seems missed.";window.SocketConnection=PubNubConnection}new n(P,function(e){t&&t(P.socket)})}}function Oe(n,o){P.socket.emit("join-room",{sessionid:P.sessionid,session:P.session,mediaConstraints:P.mediaConstraints,sdpConstraints:P.sdpConstraints,streams:Pe(),extra:P.extra,password:void 0!==P.password&&"object"!==Ue(P.password)?P.password:""},function(e,t){if(!0===e){if(P.enableLogs&&console.log("isRoomJoined: ",e," roomid: ",P.sessionid),P.peers[P.sessionid])return;I.onNegotiationNeeded(n)}!1===e&&P.enableLogs&&console.warn("isRoomJoined: ",t," roomid: ",P.sessionid),o(e,P.sessionid,t)})}function ke(n){P.enableLogs&&console.log("Sending open-room signal to socket.io"),P.waitingForLocalMedia=!1,P.socket.emit("open-room",{sessionid:P.sessionid,session:P.session,mediaConstraints:P.mediaConstraints,sdpConstraints:P.sdpConstraints,streams:Pe(),extra:P.extra,identifier:P.publicRoomIdentifier,password:void 0!==P.password&&"object"!==Ue(P.password)?P.password:""},function(e,t){!0===e&&(P.enableLogs&&console.log("isRoomOpened: ",e," roomid: ",P.sessionid),n(e,P.sessionid)),!1===e&&(P.enableLogs&&console.warn("isRoomOpened: ",t," roomid: ",P.sessionid),n(e,P.sessionid,t))})}function Pe(){try{return P.streamEvents.selectAll("local").map(function(e){return{streamid:e.streamid,tracks:e.stream.getTracks().length}})}catch(e){return[]}}function Ie(e,n){var t,o;P.dontCaptureUserMedia||e.isDataOnly?n():(t={},e.localPeerSdpConstraints.OfferToReceiveAudio&&(t.audio=P.mediaConstraints.audio),e.localPeerSdpConstraints.OfferToReceiveVideo&&(t.video=P.mediaConstraints.video),(o=e.session||P.session).oneway&&"two-way"!==o.audio&&"two-way"!==o.video&&"two-way"!==o.screen?n():((o=o.oneway&&o.audio&&"two-way"===o.audio?{audio:!0}:o).audio||o.video||o.screen)&&(o.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:w(P)}).then(function(e){e.isScreen=!0,I.onGettingLocalMedia(e),!o.audio&&!o.video||w(P)?n(e):P.invokeGetUserMedia(null,n)},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){P.invokeGetUserMedia({audio:!!w(P)&&de(t),video:t,isScreen:!0},!o.audio&&!o.video||w(P)?n:P.invokeGetUserMedia(null,n))}):(o.audio||o.video)&&P.invokeGetUserMedia(null,n,o)))}function Ne(e,t){e?(t.audio&&S(e,"audio").forEach(function(e){e.applyConstraints(t.audio)}),t.video&&S(e,"video").forEach(function(e){e.applyConstraints(t.video)})):P.enableLogs&&console.error("No stream to applyConstraints.")}function Le(t,e,n){e?I.replaceTrack(t,e,n):P.peers.getAllParticipants().forEach(function(e){I.replaceTrack(t,e,n)})}D=D||{useDefaultDevices:!0},(P=this).channel=P.sessionid=(z||location.href.replace(/\/|:|#|\?|\$|\^|%|\.|`|~|!|\+|@|\[|\||]|\|*. /g,"").split("\n").join("").split("\r").join(""))+"",I=new j(P),Me={},I.onGettingLocalMedia=function(t,i){if(i=i||function(){},Me[t.streamid])i();else{Me[t.streamid]=!0;try{t.type="local"}catch(e){}P.setStreamEndHandler(t),V(t,function(e){e.id=t.streamid,e.muted=!0,e.volume=0,-1===P.attachStreams.indexOf(t)&&P.attachStreams.push(t),void 0!==R&&R.setHandlers(t,!0,P),P.streamEvents[t.streamid]={stream:t,type:"local",mediaElement:e,userid:P.userid,extra:P.extra,streamid:t.streamid,isAudioMuted:!0};try{var n=P,o=P.streamEvents[t.streamid];if(o.stream&&S(o.stream,"audio").length){if(!n||!o)throw"Both arguments are required.";if(n.onspeaking&&n.onsilence){if("undefined"==typeof hark)throw"hark.js not found.";hark(o.stream,{onspeaking:function(){n.onspeaking(o)},onsilence:function(){n.onsilence(o)},onvolumechange:function(e,t){n.onvolumechange&&n.onvolumechange(Fe({volume:e,threshold:t},o))}})}}F(P,P.streamEvents[t.streamid]),P.onstream(P.streamEvents[t.streamid])}catch(e){}i()},P)}},I.onGettingRemoteMedia=function(t,n){try{t.type="remote"}catch(e){}P.setStreamEndHandler(t,"remote-stream"),V(t,function(e){e.id=t.streamid,void 0!==R&&R.setHandlers(t,!1,P),P.streamEvents[t.streamid]={stream:t,type:"remote",userid:n,extra:P.peers[n]?P.peers[n].extra:{},mediaElement:e,streamid:t.streamid},F(P,P.streamEvents[t.streamid]),P.onstream(P.streamEvents[t.streamid])},P)},I.onRemovingRemoteMedia=function(e,t){var n=(n=P.streamEvents[e.streamid])||{stream:e,type:"remote",userid:t,extra:P.peers[t]?P.peers[t].extra:{},streamid:e.streamid,mediaElement:P.streamEvents[e.streamid]?P.streamEvents[e.streamid].mediaElement:null};P.peersBackup[n.userid]&&(n.extra=P.peersBackup[n.userid].extra),P.onstreamended(n),delete P.streamEvents[e.streamid]},I.onNegotiationNeeded=function(e,t,n){n=n||function(){};var o={remoteUserId:t=t||e.remoteUserId,message:e=e||"",sender:P.userid};e.remoteUserId&&e.message&&e.sender&&(o=e),L(function(){P.socket.emit(P.socketMessageEvent,o,n)})},I.onUserLeft=function(e){P.deletePeer(e)},I.disconnectWith=function(e,t){P.socket&&P.socket.emit("disconnect-with",e,t||function(){}),P.deletePeer(e)},P.socketOptions={transport:"polling"},P.openOrJoin=function(e,r){r=r||function(){},P.checkPresence(e,function(e,t){var n,o,i,a;e?(P.sessionid=t,e=!!P.session.oneway,n=c(P.session),o={OfferToReceiveAudio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:P.sdpConstraints.mandatory.OfferToReceiveVideo},i={OfferToReceiveAudio:e?!!P.session.audio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:e?!!P.session.video||!!P.session.screen:P.sdpConstraints.mandatory.OfferToReceiveVideo},Ie((a={remoteUserId:P.sessionid,message:{newParticipationRequest:!0,isOneWay:e,isDataOnly:n,localPeerSdpConstraints:i,remotePeerSdpConstraints:o},sender:P.userid}).message,function(){Oe(a,r)})):(P.waitingForLocalMedia=!0,P.isInitiator=!0,P.sessionid=t||P.sessionid,c(P.session)?ke(r):P.captureUserMedia(function(){ke(r)}))})},P.waitingForLocalMedia=!1,P.open=function(e,t){t=t||function(){},P.waitingForLocalMedia=!0,P.isInitiator=!0,P.sessionid=e||P.sessionid,L(function(){c(P.session)?ke(t):P.captureUserMedia(function(){ke(t)})})},P.peersBackup={},P.deletePeer=function(e){if(e&&P.peers[e]){var t={userid:e,extra:P.peers[e]?P.peers[e].extra:{}};if(P.peersBackup[t.userid]&&(t.extra=P.peersBackup[t.userid].extra),P.onleave(t),P.peers[e]){P.peers[e].streams.forEach(function(e){e.stop()});t=P.peers[e].peer;if(t&&"closed"!==t.iceConnectionState)try{t.close()}catch(e){}P.peers[e]&&(P.peers[e].peer=null,delete P.peers[e])}}},P.rejoin=function(e){var t;!P.isInitiator&&e&&Object.keys(e).length&&(t={},P.peers[e.remoteUserId]&&(t=P.peers[e.remoteUserId].extra,P.deletePeer(e.remoteUserId)),e&&e.remoteUserId&&(P.join(e.remoteUserId),P.onReConnecting({userid:e.remoteUserId,extra:t})))},P.join=function(e,t){P.sessionid=!!e&&(e.sessionid||e.remoteUserId||e)||P.sessionid,P.sessionid+="";var n=!1,o=!1,i=!1,a=!1,r=((e&&e.session||!e||"string"==typeof e)&&(i=!!(e=e&&e.session||P.session).oneway,a=c(e),o={OfferToReceiveAudio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:P.sdpConstraints.mandatory.OfferToReceiveVideo},n={OfferToReceiveAudio:i?!!P.session.audio:P.sdpConstraints.mandatory.OfferToReceiveAudio,OfferToReceiveVideo:i?!!P.session.video||!!P.session.screen:P.sdpConstraints.mandatory.OfferToReceiveVideo}),function(){}),s=("function"==typeof(t=t||{})&&(r=t,t={}),void 0!==t.localPeerSdpConstraints&&(n=t.localPeerSdpConstraints),void 0!==t.remotePeerSdpConstraints&&(o=t.remotePeerSdpConstraints),void 0!==t.isOneWay&&(i=t.isOneWay),void 0!==t.isDataOnly&&(a=t.isDataOnly),{remoteUserId:P.sessionid,message:{newParticipationRequest:!0,isOneWay:i,isDataOnly:a,localPeerSdpConstraints:n,remotePeerSdpConstraints:o},sender:P.userid});return Ie(s.message,function(){L(function(){Oe(s,r)})}),s},P.publicRoomIdentifier="",P.getUserMedia=P.captureUserMedia=function(o,i){o=o||function(){};var a=i||P.session;P.dontCaptureUserMedia||c(a)?o():(a.audio||a.video||a.screen)&&(a.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:w(P)}).then(function(e){if(e.isScreen=!0,I.onGettingLocalMedia(e),!a.audio&&!a.video||w(P))o(e);else{var t,n={};for(t in a)"screen"!==t&&(n[t]=a[t]);P.invokeGetUserMedia(i,o,n)}},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){if(e)throw e;P.invokeGetUserMedia({audio:!!w(P)&&de(t),video:t,isScreen:!0},function(e){if(!a.audio&&!a.video||w(P))o(e);else{var t,n={};for(t in a)"screen"!==t&&(n[t]=a[t]);P.invokeGetUserMedia(i,o,n)}})}):(a.audio||a.video)&&P.invokeGetUserMedia(i,o,a))},P.onbeforeunload=function(e,t){P.closeBeforeUnload&&(P.peers.getAllParticipants().forEach(function(e){I.onNegotiationNeeded({userLeft:!0},e),P.peers[e]&&P.peers[e].peer&&P.peers[e].peer.close(),delete P.peers[e]}),t||P.closeSocket(),P.isInitiator=!1)},window.ignoreBeforeUnload?P.closeBeforeUnload=!1:(P.closeBeforeUnload=!0,window.addEventListener("beforeunload",P.onbeforeunload,!1)),P.userid=f(),P.changeUserId=function(e,t){t=t||function(){},P.userid=e||f(),P.socket.emit("changed-uuid",P.userid,t)},P.extra={},P.attachStreams=[],P.session={audio:!0,video:!0},P.enableFileSharing=!1,P.bandwidth={screen:!1,audio:!1,video:!1},P.codecs={audio:"opus",video:"VP9"},P.processSdp=function(e){return function(){var t=!1;try{if("undefined"==typeof RTCRtpTransceiver)return;if(!("currentDirection"in RTCRtpTransceiver.prototype))return;var e=new T;try{e.addTransceiver("audio"),t=!0}catch(e){}e.close()}catch(e){t=!1}return t&&function(){var t=!1;try{var e=new T({sdpSemantics:"unified-plan"});try{var n=e.getConfiguration(),t="unified-plan"==n.sdpSemantics||(n.sdpSemantics,!1)}catch(e){t=!1}}catch(e){t=!1}return t}()}()||"Safari"!==DetectRTC.browser.name&&("VP8"===P.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"vp8")),"VP9"===P.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"vp9")),"H264"===P.codecs.video.toUpperCase()&&(e=E.preferCodec(e,"h264")),"G722"===P.codecs.audio&&(e=E.removeNonG722(e)),"Firefox"!==DetectRTC.browser.name&&((P.bandwidth.video||P.bandwidth.screen)&&(e=E.setApplicationSpecificBandwidth(e,P.bandwidth,!!P.session.screen)),P.bandwidth.video&&(e=E.setVideoBitrates(e,{min:8*P.bandwidth.video*1024,max:8*P.bandwidth.video*1024})),P.bandwidth.audio&&(e=E.setOpusAttributes(e,{maxaveragebitrate:8*P.bandwidth.audio*1024,maxplaybackrate:8*P.bandwidth.audio*1024,stereo:1,maxptime:3})))),e},void 0!==E&&(P.BandwidthHandler=P.CodecsHandler=E),P.mediaConstraints={audio:{mandatory:{},optional:P.bandwidth.audio?[{bandwidth:8*P.bandwidth.audio*1024||1048576}]:[]},video:{mandatory:{},optional:P.bandwidth.video?[{bandwidth:8*P.bandwidth.video*1024||1048576},{facingMode:"user"}]:[{facingMode:"user"}]}},"Firefox"===DetectRTC.browser.name&&(P.mediaConstraints={audio:!0,video:!0}),D.useDefaultDevices||DetectRTC.isMobileDevice||DetectRTC.load(function(){var t,n;if(DetectRTC.MediaDevices.forEach(function(e){"audioinput"===e.kind&&!1!==P.mediaConstraints.audio&&(t=e),"videoinput"===e.kind&&!1!==P.mediaConstraints.video&&(n=e)}),t){if("Firefox"===DetectRTC.browser.name)return void(!0!==P.mediaConstraints.audio?P.mediaConstraints.audio.deviceId=t.id:P.mediaConstraints.audio={deviceId:t.id});1==P.mediaConstraints.audio&&(P.mediaConstraints.audio={mandatory:{},optional:[]}),P.mediaConstraints.audio.optional||(P.mediaConstraints.audio.optional=[]);var e=[{sourceId:t.id}];P.mediaConstraints.audio.optional=e.concat(P.mediaConstraints.audio.optional)}n&&("Firefox"===DetectRTC.browser.name?!0!==P.mediaConstraints.video?P.mediaConstraints.video.deviceId=n.id:P.mediaConstraints.video={deviceId:n.id}:(1==P.mediaConstraints.video&&(P.mediaConstraints.video={mandatory:{},optional:[]}),P.mediaConstraints.video.optional||(P.mediaConstraints.video.optional=[]),e=[{sourceId:n.id}],P.mediaConstraints.video.optional=e.concat(P.mediaConstraints.video.optional)))}),P.sdpConstraints={mandatory:{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0},optional:[{VoiceActivityDetection:!1}]},P.sdpSemantics=null,P.iceCandidatePoolSize=null,P.bundlePolicy=null,P.rtcpMuxPolicy=null,P.iceTransportPolicy=null,P.optionalArgument={optional:[{DtlsSrtpKeyAgreement:!0},{googImprovedWifiBwe:!0},{googScreencastMinBitrate:300},{googIPv6:!0},{googDscp:!0},{googCpuUnderuseThreshold:55},{googCpuOveruseThreshold:85},{googSuspendBelowMinBitrate:!0},{googCpuOveruseDetection:!0}],mandatory:{}},P.iceServers=l(P),P.candidates={host:!0,stun:!0,turn:!0},P.iceProtocols={tcp:!0,udp:!0},P.onopen=function(e){P.enableLogs&&console.info("Data connection has been opened between you & ",e.userid)},P.onclose=function(e){P.enableLogs&&console.warn("Data connection has been closed between you & ",e.userid)},P.onerror=function(e){P.enableLogs&&console.error(e.userid,"data-error",e)},P.onmessage=function(e){P.enableLogs&&console.debug("data-message",e.userid,e.data)},P.send=function(e,t){P.peers.send(e,t)},P.close=P.disconnect=P.leave=function(){P.onbeforeunload(!1,!0)},P.closeEntireSession=function(t){t=t||function(){},P.socket.emit("close-entire-session",function e(){P.getAllParticipants().length?setTimeout(e,100):(P.onEntireSessionClosed({sessionid:P.sessionid,userid:P.userid,extra:P.extra}),P.changeUserId(null,function(){P.close(),t()}))})},P.onEntireSessionClosed=function(e){P.enableLogs&&console.info("Entire session is closed: ",e.sessionid,e.extra)},P.onstream=function(e){var t=P.videosContainer,t=(t.insertBefore(e.mediaElement,t.firstChild),e.mediaElement.play());void 0===t?setTimeout(function(){e.mediaElement.play()},2e3):t.catch(function(){}).then(function(){setTimeout(function(){e.mediaElement.play()},2e3)})},P.onstreamended=function(e){e.mediaElement||(e.mediaElement=document.getElementById(e.streamid)),e.mediaElement&&e.mediaElement.parentNode&&e.mediaElement.parentNode.removeChild(e.mediaElement)},P.direction="many-to-many",P.removeStream=function(t,n){var o;P.attachStreams.forEach(function(e){e.id===t&&(o=e)}),o?(P.peers.getAllParticipants().forEach(function(e){if(!n||e===n){e=P.peers[e];try{e.peer.removeStream(o)}catch(e){}}}),P.renegotiate()):console.warn("No such stream exist.",t)},P.addStream=function(n,t){if(n.getTracks)return-1===P.attachStreams.indexOf(n)&&(n.streamid||(n.streamid=n.id),P.attachStreams.push(n)),void P.renegotiate(t);function o(e){n.streamCallback&&n.streamCallback(e),P.renegotiate(t)}c(n)?P.renegotiate(t):(n.audio||n.video||n.screen)&&(n.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:w(P)}).then(function(e){e.isScreen=!0,I.onGettingLocalMedia(e),!n.audio&&!n.video||w(P)?o(e):P.invokeGetUserMedia(null,function(e){o(e)})},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){if(e)return"PermissionDeniedError"===e?(n.streamCallback&&n.streamCallback(null),void(P.enableLogs&&console.error("User rejected to share his screen."))):alert(e);P.invokeGetUserMedia({audio:!!w(P)&&de(t),video:t,isScreen:!0},function(e){!n.audio&&!n.video||w(P)?o(e):P.invokeGetUserMedia(null,function(e){o(e)})})}):(n.audio||n.video)&&P.invokeGetUserMedia(null,o))},P.invokeGetUserMedia=function(n,o,e){e=e||P.session,we({onGettingLocalMedia:function(e){var t=n.video;t&&(t.mediaSource||t.mozMediaSource||t.mandatory&&t.mandatory.chromeMediaSource)&&(e.isScreen=!0),e.isScreen||(e.isVideo=!!S(e,"video").length,e.isAudio=!e.isVideo&&S(e,"audio").length),I.onGettingLocalMedia(e,function(){"function"==typeof o&&o(e)})},onLocalMediaError:function(e,t){I.onLocalMediaError(e,t)},localMediaConstraints:(n=n||P.mediaConstraints)||{audio:!!e.audio&&n.audio,video:!!e.video&&n.video}})},P.applyConstraints=function(t,e){var n;C&&C.prototype.applyConstraints?e?Ne(n=P.streamEvents[e]?P.streamEvents[e].stream:n,t):P.attachStreams.forEach(function(e){Ne(e,t)}):alert("track.applyConstraints is NOT supported in your browser.")},P.replaceTrack=function(n,t,o){if(n=n||{},T.prototype.getSenders)if(n instanceof C)Le(n,t,o);else{if(n instanceof _)return S(n,"video").length&&Le(S(n,"video")[0],t,!0),void(S(n,"audio").length&&Le(S(n,"audio")[0],t,!1));if(c(n))throw"connection.replaceTrack requires audio and/or video and/or screen.";(n.audio||n.video||n.screen)&&(n.screen?"Edge"===DetectRTC.browser.name?navigator.getDisplayMedia({video:!0,audio:w(P)}).then(function(e){e.isScreen=!0,I.onGettingLocalMedia(e),!n.audio&&!n.video||w(P)?i(e):P.invokeGetUserMedia(null,i)},function(e){console.error("Unable to capture screen on Edge. HTTPs and version 17+ is required.")}):P.getScreenConstraints(function(e,t){if(e)return alert(e);P.invokeGetUserMedia({audio:!!w(P)&&de(t),video:t,isScreen:!0},!n.audio&&!n.video||w(P)?i:P.invokeGetUserMedia(null,i))}):(n.audio||n.video)&&P.invokeGetUserMedia(null,i))}else P.addStream(n);function i(e){P.replaceTrack(e,t,o||n.video||n.screen)}},P.resetTrack=function(e,n){(e="string"==typeof(e=e||P.getAllParticipants())?[e]:e).forEach(function(e){var t=P.peers[e].peer;void 0!==n&&!0!==n||!t.lastVideoTrack||P.replaceTrack(t.lastVideoTrack,e,!0),void 0!==n&&!1!==n||!t.lastAudioTrack||P.replaceTrack(t.lastAudioTrack,e,!1)})},P.renegotiate=function(e){e?I.renegotiatePeer(e):P.peers.getAllParticipants().forEach(function(e){I.renegotiatePeer(e)})},P.setStreamEndHandler=function(o,i){var e;o&&o.addEventListener&&(i=!!i,!o.alreadySetEndHandler)&&(o.alreadySetEndHandler=!0,e="ended","oninactive"in o&&(e="inactive"),o.addEventListener(e,function(){o.idInstance&&currentUserMediaRequest.remove(o.idInstance),i||(t=[],P.attachStreams.forEach(function(e){e.id!=o.id&&t.push(e)}),P.attachStreams=t);var e,t,n=(n=P.streamEvents[o.streamid])||{stream:o,streamid:o.streamid,type:i?"remote":"local",userid:P.userid,extra:P.extra,mediaElement:P.streamEvents[o.streamid]?P.streamEvents[o.streamid].mediaElement:null};i&&P.peers[n.userid]&&(e=P.peers[n.userid].peer,t=[],e.getRemoteStreams().forEach(function(e){e.id!=o.id&&t.push(e)}),P.peers[n.userid].streams=t),n.userid===P.userid&&"remote"===n.type||(P.peersBackup[n.userid]&&(n.extra=P.peersBackup[n.userid].extra),P.onstreamended(n),delete P.streamEvents[o.streamid])},!1))},P.onMediaError=function(e,t){P.enableLogs&&console.error(e,t)},P.autoCloseEntireSession=!1,P.filesContainer=P.videosContainer=document.body||document.documentElement,P.isInitiator=!1,P.shareFile=I.shareFile,a.handle(P),t.handle(P),P.token=f,P.onNewParticipant=function(e,t){P.acceptParticipationRequest(e,t)},P.acceptParticipationRequest=function(e,t){t.successCallback&&(t.successCallback(),delete t.successCallback),I.createNewPeer(e,t)},void 0!==R&&(P.StreamsHandler=R),P.onleave=function(e){},P.invokeSelectFileDialog=function(e){var t=new Be;t.accept="*.*",t.selectSingleFile(e)},P.onmute=function(e){var t;e&&e.mediaElement&&("both"===e.muteType||"video"===e.muteType?(e.mediaElement.src=null,void 0!==(t=e.mediaElement.pause())?t.then(function(){e.mediaElement.poster=e.snapshot||"https://cdn.webrtc-experiment.com/images/muted.png"}):e.mediaElement.poster=e.snapshot||"https://cdn.webrtc-experiment.com/images/muted.png"):"audio"===e.muteType&&(e.mediaElement.muted=!0))},P.onunmute=function(e){e&&e.mediaElement&&e.stream&&("both"===e.unmuteType||"video"===e.unmuteType?(e.mediaElement.poster=null,e.mediaElement.srcObject=e.stream,e.mediaElement.play()):"audio"===e.unmuteType&&(e.mediaElement.muted=!1))},P.onExtraDataUpdated=function(e){e.status="online",P.onUserStatusChanged(e,!0)},P.getAllParticipants=function(e){return P.peers.getAllParticipants(e)},void 0!==R&&(R.onSyncNeeded=function(t,n,o){P.peers.getAllParticipants().forEach(function(e){I.onNegotiationNeeded({streamid:t,action:n,streamSyncNeeded:!0,type:o||"both"},e)})}),P.connectSocket=function(e){L(e)},P.closeSocket=function(){try{_0x31267b.a.sockets={}}catch(e){}P.socket&&("function"==typeof P.socket.disconnect&&P.socket.disconnect(),"function"==typeof P.socket.resetProps&&P.socket.resetProps(),P.socket=null)},P.getSocket=function(e){return!e&&P.enableLogs&&console.warn("getSocket.callback paramter is required."),e=e||function(){},P.socket?e(P.socket):L(function(){e(P.socket)}),P.socket},P.getRemoteStreams=I.getRemoteStreams,Re=["selectFirst","selectAll","forEach"],P.streamEvents={selectFirst:function(e){return P.streamEvents.selectAll(e)[0]},selectAll:function(n){"video"==(n="audio"==(n="screen"==(n="remote"==(n="local"==(n=n||{local:!0,remote:!0,isScreen:!0,isAudio:!0,isVideo:!0})?{local:!0}:n)?{remote:!0}:n)?{isScreen:!0}:n)?{isAudio:!0}:n)&&(n={isVideo:!0});var o=[];return Object.keys(P.streamEvents).forEach(function(e){var t=P.streamEvents[e];-1===Re.indexOf(e)&&(e=!0,n.local&&"local"===t.type&&(e=!1),n.remote&&"remote"===t.type&&(e=!1),n.isScreen&&t.stream.isScreen&&(e=!1),n.isVideo&&t.stream.isVideo&&(e=!1),n.isAudio&&t.stream.isAudio&&(e=!1),!1===(e=n.userid&&t.userid===n.userid?!1:e)&&o.push(t))}),o}},P.socketURL="/",P.socketMessageEvent="RTCMultiConnection-Message",P.socketCustomEvent="RTCMultiConnection-Custom-Message",P.DetectRTC=DetectRTC,P.setCustomSocketEvent=function(e){e&&(P.socketCustomEvent=e),P.socket&&P.socket.emit("set-custom-socket-event-listener",P.socketCustomEvent)},P.getNumberOfBroadcastViewers=function(e,t){P.socket&&e&&t&&P.socket.emit("get-number-of-users-in-specific-broadcast",e,t)},P.onNumberOfBroadcastViewersUpdated=function(e){P.enableLogs&&P.isInitiator&&console.info("Number of broadcast (",e.broadcastId,") viewers",e.numberOfBroadcastViewers)},P.onUserStatusChanged=function(e,t){P.enableLogs&&!t&&console.info(e.userid,e.status)},P.getUserMediaHandler=we,P.multiPeersHandler=I,P.enableLogs=!0,P.setCustomSocketHandler=function(e){void 0!==n&&(n=e)},P.chunkSize=4e4,P.maxParticipantsAllowed=1e3,P.disconnectWith=I.disconnectWith,P.checkPresence=function(e,o){e=e||P.sessionid,"SSEConnection"!==n.name?P.socket?P.socket.emit("check-presence",e+"",function(e,t,n){P.enableLogs&&console.log("checkPresence.isRoomExist: ",e," roomid: ",t),o(e,t,n)}):P.connectSocket(function(){P.checkPresence(e,o)}):SSEConnection.checkPresence(e,function(e,t,n){if(!P.socket)return e||(P.userid=t),void P.connectSocket(function(){o(e,t,n)});o(e,t)})},P.onReadyForOffer=function(e,t){P.multiPeersHandler.createNewPeer(e,t)},P.setUserPreferences=function(e){return P.dontAttachStream&&(e.dontAttachLocalStream=!0),P.dontGetRemoteStream&&(e.dontGetRemoteStream=!0),e},P.updateExtraData=function(){P.socket.emit("extra-data-updated",P.extra)},P.enableScalableBroadcast=!1,P.maxRelayLimitPerUser=3,P.dontCaptureUserMedia=!1,P.dontAttachStream=!1,P.dontGetRemoteStream=!1,P.onReConnecting=function(e){P.enableLogs&&console.info("ReConnecting with",e.userid,"...")},P.beforeAddingStream=function(e){return e},P.beforeRemovingStream=function(e){return e},P.checkIfChromeExtensionAvailable=Te,"undefined"!=typeof isFirefoxExtensionAvailable&&(P.checkIfChromeExtensionAvailable=isFirefoxExtensionAvailable),P.getChromeExtensionStatus=Ce,P.getScreenConstraints=function(n,e){w(P,e)&&(e=!0);var o,i=function(e,t){e||(t=P.modifyScreenConstraints(t),n(e,t))};xe?i(null,{mozMediaSource:"window",mediaSource:"window"}):(o={mandatory:{chromeMediaSource:k,maxWidth:1920<screen.width?screen.width:1920,maxHeight:1080<screen.height?screen.height:1080},optional:[]},"desktop"!=k||A?("desktop"==k&&(o.mandatory.chromeMediaSourceId=A),i(null,o)):e?(e=function(e,t){o.mandatory.chromeMediaSourceId=e,t&&(o.canRequestAudioTrack=!0),i("PermissionDeniedError"==e?e:null,o)},A?e(A):(O=e,window.postMessage("audio-plus-tab","*"))):(e=function(e){o.mandatory.chromeMediaSourceId=e,i("PermissionDeniedError"==e?e:null,o)},A?e(A):(O=e,window.postMessage("get-sourceId","*"))))},P.modifyScreenConstraints=function(e){return e},P.onPeerStateChanged=function(e){P.enableLogs&&-1!==e.iceConnectionState.search(/closed|failed/gi)&&console.error("Peer connection is closed between you & ",e.userid,e.extra,"state:",e.iceConnectionState)},P.isOnline=!0,G("online",function(){P.isOnline=!0}),G("offline",function(){P.isOnline=!1}),P.isLowBandwidth=!1,navigator&&navigator.connection&&navigator.connection.type&&(P.isLowBandwidth=-1!==navigator.connection.type.toString().toLowerCase().search(/wifi|cell/g),P.isLowBandwidth)&&(P.bandwidth={audio:!1,video:!1,screen:!1},P.mediaConstraints.audio&&P.mediaConstraints.audio.optional&&P.mediaConstraints.audio.optional.length&&(N=[],P.mediaConstraints.audio.optional.forEach(function(e){void 0===e.bandwidth&&N.push(e)}),P.mediaConstraints.audio.optional=N),P.mediaConstraints.video&&P.mediaConstraints.video.optional&&P.mediaConstraints.video.optional.length&&(N=[],P.mediaConstraints.video.optional.forEach(function(e){void 0===e.bandwidth&&N.push(e)}),P.mediaConstraints.video.optional=N)),P.getExtraData=function(e,o){if(!e)throw"remoteUserId is required.";if(!o)return P.peers[e]?P.peers[e].extra:P.peersBackup[e]?P.peersBackup[e].extra:{};P.socket.emit("get-remote-user-extra-data",e,function(e,t,n){o(e,t,n)})},D.autoOpenOrJoin&&P.openOrJoin(P.sessionid),P.onUserIdAlreadyTaken=function(e,t){P.close(),P.closeSocket(),P.isInitiator=!1,P.userid=P.token(),P.join(P.sessionid),P.enableLogs&&console.warn("Userid already taken.",e,"Your new userid:",P.userid)},P.trickleIce=!0,P.version="3.6.5",P.onSettingLocalDescription=function(e){P.enableLogs&&console.info("Set local description for remote user",e.userid)},P.resetScreen=function(){A=null,DetectRTC&&DetectRTC.screen&&delete DetectRTC.screen.sourceId,currentUserMediaRequest={streams:[],mutex:!1,queueRequests:[]}},P.autoCreateMediaElement=!0,P.password=null,P.setPassword=function(e,t){t=t||function(){},P.socket?P.socket.emit("set-password",e,t):(P.password=e,t(!0,P.sessionid,null))},P.errors={ROOM_NOT_AVAILABLE:"Room not available",INVALID_PASSWORD:"Invalid password",USERID_NOT_AVAILABLE:"User ID does not exist",ROOM_PERMISSION_DENIED:"Room permission denied",ROOM_FULL:"Room full",DID_NOT_JOIN_ANY_ROOM:"Did not join any room yet",INVALID_SOCKET:"Invalid socket",PUBLIC_IDENTIFIER_MISSING:"publicRoomIdentifier is required",INVALID_ADMIN_CREDENTIAL:"Invalid username or password attempted"}}}.call(this,Ve(73).Buffer,Ve(31),Ve(49))},function(p,i,r){"use strict";for(var h in window.EJS_RESET_VARS=[],window)window.EJS_RESET_VARS.push(h);r.r(i);function t(e){return null!=e?e.constructor:null}function n(e,t){return Boolean(e&&t&&e instanceof t)}function v(e){return null==e}function y(e){return t(e)===Object}function b(e){return t(e)===String}function _(e){return Array.isArray(e)}function w(e){return n(e,NodeList)}function S(e){return v(e)||(b(e)||_(e)||w(e))&&!e.length||y(e)&&!Object.keys(e).length}let T={volume:.5,muted:!1,i18n:{restart:"Restart",play:"Play",pause:"Pause",played:"Played",volume:"Volume",mute:"Mute (F9)",unmute:"Unmute (F9)",enterFullscreen:"Enter fullscreen",exitFullscreen:"Exit fullscreen",settings:"Settings",saveState:"Save State (Shift + F2)",loadState:"Load State (Shift + F4)",screenRecord:"Start Screen Recording",cacheManager:"Cache Manager",netplay:"Netplay",gamepad:"Control Settings",cheat:"Cheats",menuBack:"Go back to previous menu",normal:"Normal",all:"All",reset:"Reset",disabled:"Disabled",enabled:"Enabled",playNow:"Start Game"},listeners:{play:null,pause:null,restart:null,rewind:null,mute:null,volume:null,fullscreen:null},events:["ready"],selectors:{editable:"input, textarea, select, [contenteditable]",container:".ejs",controls:{container:null,wrapper:".jes__controls"},buttons:{play:'[data-btn="play"]',pause:'[data-btn="pause"]',mute:'[data-btn="mute"]',fullscreen:'[data-btn="fullscreen"]',settings:'[data-btn="settings"]',saveState:'[data-btn="save-state"]',loadState:'[data-btn="load-state"]',screenRecord:'[data-btn="screen-record"]',cacheManager:'[data-btn="cache-manager"]',gamepad:'[data-btn="gamepad"]',netplay:'[data-btn="netplay"]',cheat:'[data-btn="cheat"]'},inputs:{volume:'[data-range="volume"]'}},classNames:{type:"ejs--video",video:"ejs__video-wrapper",poster:"ejs__poster",posterEnabled:"ejs__poster-enabled",control:"ejs__control",controlPressed:"ejs__control--pressed",playing:"ejs--playing",paused:"ejs--paused",stopped:"ejs--stopped",loading:"ejs--loading",hover:"ejs--hover",tooltip:"ejs__tooltip",hidden:"ejs__sr-only",hideControls:"ejs--hide-controls",isIos:"ejs--is-ios",isTouch:"ejs--is-touch",uiSupported:"ejs--full-ui",noTransition:"ejs--no-transition",menu:{value:"ejs__menu__value",badge:"ejs__badge",open:"ejs--menu-open"},fullscreen:{enabled:"ejs--fullscreen-enabled",fallback:"ejs--fullscreen-fallback"},tabFocus:"ejs__tab-focus"}},D=r(0),x=r(157),C=r.n(x),U={nullOrUndefined:v,object:y,number:function(e){return t(e)===Number&&!Number.isNaN(e)},string:b,boolean:function(e){return t(e)===Boolean},function:function(e){return t(e)===Function},array:_,weakMap:function(e){return n(e,WeakMap)},nodeList:w,element:function(e){return n(e,Element)},textNode:function(e){return t(e)===Text},event:function(e){return n(e,Event)},keyboardEvent:function(e){return n(e,KeyboardEvent)},cue:function(e){return n(e,window.TextTrackCue)||n(e,window.VTTCue)},track:function(e){return n(e,TextTrack)||!v(e)&&b(e.kind)},url:function(e){if(n(e,window.URL))return!0;let t=e;e.startsWith("http://")&&e.startsWith("https://")||(t="http://".concat(e));try{return!S(new URL(t).hostname)}catch(e){return!1}},empty:S},E=function(){let e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){return e=!0,null}});window.addEventListener("test",null,t),window.removeEventListener("test",null,t)}catch(e){}return e}();function c(n,o,i){let a=this,r=3<arguments.length&&void 0!==arguments[3]&&arguments[3],s=!(4<arguments.length&&void 0!==arguments[4])||arguments[4],c=5<arguments.length&&void 0!==arguments[5]&&arguments[5];if(n&&"addEventListener"in n&&!U.empty(o)&&U.function(i)){let e=o.split(" "),t=c;E&&(t={passive:s,capture:c}),e.forEach(function(e){a&&a.eventListeners&&r&&a.eventListeners.push({element:n,type:e,callback:i,options:t}),n[r?"addEventListener":"removeEventListener"](e,i)})}}function j(e){c.call(this,e,1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",2<arguments.length?arguments[2]:void 0,!0,!(3<arguments.length&&void 0!==arguments[3])||arguments[3],4<arguments.length&&void 0!==arguments[4]&&arguments[4])}function M(e){c.call(this,e,1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",2<arguments.length?arguments[2]:void 0,!1,!(3<arguments.length&&void 0!==arguments[3])||arguments[3],4<arguments.length&&void 0!==arguments[4]&&arguments[4])}function ie(o){let i=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",a=2<arguments.length?arguments[2]:void 0,r=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],s=4<arguments.length&&void 0!==arguments[4]&&arguments[4];c.call(this,o,i,function e(){M(o,i,e,r,s);let t=arguments.length,n=new Array(t);for(let e=0;e<t;e++)n[e]=arguments[e];a.apply(this,n)},!0,r,s)}function B(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};U.element(e)&&!U.empty(t)&&(t=new CustomEvent(t,{bubbles:n,detail:Object.assign({},o,{emulator:this})}),e.dispatchEvent(t))}let R=r(158),A=r.n(R);function O(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(n,o){let i=[],a=!0,t=!1,r=void 0;try{for(let e,t=n[Symbol.iterator]();!(a=(e=t.next()).done)&&(i.push(e.value),!o||i.length!==o);a=!0);}catch(e){t=!0,r=e}finally{try{a||null==_0x557ef0.return||_0x557ef0.return()}finally{if(t)throw r}}return i}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function k(e,a){e=e.length?e:[e];Array.from(e).reverse().forEach(function(e,t){let n=0<t?a.cloneNode(!0):a,o=e.parentNode,i=e.nextSibling;n.appendChild(e),i?o.insertBefore(n,i):o.appendChild(n)})}function P(n,e){U.element(n)&&!U.empty(e)&&Object.entries(e).filter(function(e){e=O(e,2)[1];return!U.nullOrUndefined(e)}).forEach(function(e){var e=O(e,2),t=e[0],e=e[1];return n.setAttribute(t,e)})}function F(e,t,n){let o=document.createElement(e);return U.object(t)&&P(o,t),U.string(n)&&(o.innerText=n),o}function I(e){U.nodeList(e)||U.array(e)?Array.from(e).forEach(I):U.element(e)&&U.element(e.parentNode)&&e.parentNode.removeChild(e)}function N(e,t){if(!U.string(e)||U.empty(e))return{};let r={},s=t;return e.split(",").forEach(function(e){let t=e.trim(),n=t.replace(".",""),o=t.replace(/[[\]]/g,"").split("="),i=o[0],a=1<o.length?o[1].replace(/["']/g,""):"";switch(t.charAt(0)){case".":U.object(s)&&U.string(s.class)&&(s.class+=" ".concat(n)),r.class=n;break;case"#":r.id=t.replace("#","");break;case"[":r[i]=a}}),r}function V(t,n){if(U.element(t)){let e=n;(e=U.boolean(e)?e:!t.hidden)?t.setAttribute("hidden",""):t.removeAttribute("hidden")}}function G(t,n,o){if(U.nodeList(t))return Array.from(t).map(function(e){return G(e,n,o)});if(U.element(t)){let e=void 0!==o?o?"add":"remove":"toggle";return t.classList[e](n),t.classList.contains(n)}return!1}function L(e,t){return U.element(e)&&e.classList.contains(t)}function z(e,t){let n={Element:Element};return(n.matches||n.webkitMatchesSelector||n.mozMatchesSelector||n.msMatchesSelector||function(){return Array.from(document.querySelectorAll(t)).includes(this)}).call(e,t)}function l(e){return this.elements.container.querySelectorAll(e)}function q(e){return this.elements.container.querySelector(e)}function ae(){let e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,t=1<arguments.length&&void 0!==arguments[1]&&arguments[1];U.element(e)&&(e.focus(),t&&G(e,this.config.classNames.tabFocus))}function H(e){return C.a.bind(A.a)(e)}let re,se,ce,le=(re=document.createElement("span"),se={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},ce=Object.keys(se).find(function(e){return void 0!==re.style[e]}),!!U.string(ce)&&se[ce]);function de(e){setTimeout(function(){try{V(e,!0),e.offsetHeight,V(e,!1)}catch(e){}},0)}let ue,W={isEdge:"Netscape"===navigator.appName&&-1<navigator.appVersion.indexOf("Edge"),isIE:!!document.documentMode,isWebkit:"WebkitAppearance"in document.documentElement.style&&!/Edge/.test(navigator.userAgent),isIPhone:/(iPhone|iPod)/gi.test(navigator.platform),isIos:/(iPad|iPhone|iPod)/gi.test(navigator.userAgent)||/Macintosh/i.test(navigator.userAgent)&&navigator.maxTouchPoints&&1<navigator.maxTouchPoints,info:function(){let e=/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d\.apre]+)/.exec(navigator.userAgent);return{name:e[1].toLowerCase(),version:e[2]}}},Y={rangeInput:((ue=document.createElement("input")).type="range")===ue.type,touch:"ontouchstart"in document.documentElement,transitions:!1!==le,reducedMotion:"matchMedia"in window&&window.matchMedia("(prefers-reduced-motion)").matches,webgl:function(){let a={DETECTED:!1};if(!a.DETECTED){let i=document.createElement("canvas");if(i&&i.getContext)for(let n=["webgl2","experimental-webgl2","webgl","experimental-webgl"],o=0,e=n.length;o<e;++o){let e=n[o],t=i.getContext(e);if(t){a.WEBGL_CONTEXT=e,a.WEBGL_VERSION=t.getParameter(t.VERSION),a.WEBGL_VENDOR=t.getParameter(t.VENDOR),a.WEBGL_SL_VERSION=t.getParameter(t.SHADING_LANGUAGE_VERSION),a.MAX_TEXTURE_SIZE=t.getParameter(t.MAX_TEXTURE_SIZE);var r=t.getExtension("WEBGL_debug_renderer_info");r&&(a.WEBGL_VENDOR=t.getParameter(r.UNMASKED_VENDOR_WEBGL),a.WEBGL_RENDERER=t.getParameter(r.UNMASKED_RENDERER_WEBGL)),a.DETECTED=!0;break}}}return a}(),wasm:"undefined"!=typeof WebAssembly&&U.object(WebAssembly),audioContext:"undefined"!=typeof AudioContext};function fe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function X(){let t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=new Array(1<i?i-1:0);for(let e=arguments.length,t=1;t<e;t++)n[t-1]=arguments[t];if(!n.length)return t;let o=n.shift();return U.object(o)?(Object.keys(o).forEach(function(e){U.object(o[e])?(Object.keys(t).includes(e)||Object.assign(t,fe({},e,{})),X(t[e],o[e])):Object.assign(t,fe({},e,o[e]))}),X.apply(void 0,[t].concat(n))):t}function pe(e,t,n){let o=0<arguments.length&&void 0!==e?e:"",i=1<arguments.length&&void 0!==t?t:"",a=2<arguments.length&&void 0!==n?n:"";return o.replace(new RegExp(i.toString().replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1"),"g"),a.toString())}let he={get:function(){var e,t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(U.empty(t)||U.empty(n))return"";e=n.i18n;let o=t.split(".").reduce(function(e,t){return e&&e[t]},e);if(U.empty(o))return"";t={"{seektime}":n.seekTime,"{title}":n.title};return Object.entries(t).forEach(function(e){t=2;var e=function(e){if(Array.isArray(e))return e}(e=e)||function(n,o){let i=[],a=!0,t=!1,r=void 0;try{for(let e,t=n[Symbol.iterator]();!(a=(e=t.next()).done)&&(i.push(e.value),!o||i.length!==o);a=!0);}catch(e){t=!0,r=e}finally{try{a||null==_0x2f59ed.return||_0x2f59ed.return()}finally{if(t)throw r}}return i}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}(),t=e[0],e=e[1];o=pe(o,t,e)}),o}};function me(n,o){for(let t=0;t<o.length;t++){let e=o[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}u=[{key:"supported",get:function(){try{return"localStorage"in window&&(window.localStorage.getItem("___test")||window.localStorage.setItem("___test","___test"),!0)}catch(e){return!1}}}],me((e=ve).prototype,[{key:"get",value:function(e){if(!ve.supported||!this.enabled)return null;var t=window.localStorage.getItem(this.key);if(U.empty(t))return null;t=JSON.parse(t);return U.string(e)&&e.length?t[e]:t}},{key:"set",value:function(t){if(ve.supported&&this.enabled&&U.object(t)){let e=this.get();X(e=U.empty(e)?{}:e,t),window.localStorage.setItem(this.key,JSON.stringify(e))}}}]),me(e,u);let ge=ve;function ve(e,t){if(!(this instanceof ve))throw new TypeError("Cannot call a class as a function");this.enabled=!0,this.key=t}let ye,be=r(6),_e=r(159),we=r.n(_e),Se={"2xScaleHQ.glslp":'shaders = 1\n\nshader0 = "2xScaleHQ.glsl"\nfilter_linear0 = false\nscale_type_0 = source\n',"4xScaleHQ.glslp":'shaders = 1\n\nshader0 = "4xScaleHQ.glsl"\nfilter_linear0 = false\nscale_type_0 = source\n',"crt-easymode.glslp":"shaders = 1\n\nshader0 = crt-easymode.glsl\nfilter_linear0 = false\nscale_type_0 = source\n","crt-aperture.glslp":"shaders = 1\n\nshader0 = crt-aperture.glsl\nfilter_linear0 = false\n","crt-geom.glslp":"shaders = 1\n\nshader0 = crt-geom.glsl\nfilter_linear0 = false\nscale_type_0 = source\n","crt-mattias.glslp":"\nshaders = 1\nshader0 = crt-mattias.glsl\nfilter_linear0 = false\n","2xScaleHQ.glsl":"/*\n2xGLSLHqFilter shader\n\nCopyright (C) 2005 guest(r) - guest.r@gmail.com\n\nThis program is free software; you can redistribute it and/or\nmodify it under the terms of the GNU General Public License\nas published by the Free Software Foundation; either version 2\nof the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n*/\n\n#if defined(VERTEX)\n\n#if __VERSION__ >= 130\n#define COMPAT_VARYING out\n#define COMPAT_ATTRIBUTE in\n#define COMPAT_TEXTURE texture\n#else\n#define COMPAT_VARYING varying \n#define COMPAT_ATTRIBUTE attribute \n#define COMPAT_TEXTURE texture2D\n#endif\n\n#ifdef GL_ES\n#define COMPAT_PRECISION mediump\n#else\n#define COMPAT_PRECISION\n#endif\n\nCOMPAT_ATTRIBUTE vec4 VertexCoord;\nCOMPAT_ATTRIBUTE vec4 COLOR;\nCOMPAT_ATTRIBUTE vec4 TexCoord;\nCOMPAT_VARYING vec4 COL0;\nCOMPAT_VARYING vec4 TEX0;\nCOMPAT_VARYING vec4 t1;\nCOMPAT_VARYING vec4 t2;\nCOMPAT_VARYING vec4 t3;\nCOMPAT_VARYING vec4 t4;\n\nvec4 _oPosition1; \nuniform mat4 MVPMatrix;\nuniform COMPAT_PRECISION int FrameDirection;\nuniform COMPAT_PRECISION int FrameCount;\nuniform COMPAT_PRECISION vec2 OutputSize;\nuniform COMPAT_PRECISION vec2 TextureSize;\nuniform COMPAT_PRECISION vec2 InputSize;\n\n// compatibility #defines\n#define vTexCoord TEX0.xy\n#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize\n#define OutSize vec4(OutputSize, 1.0 / OutputSize)\n\nvoid main()\n{\ngl_Position = MVPMatrix * VertexCoord;\nTEX0.xy = TexCoord.xy;\nfloat x = 0.5 * SourceSize.z;\nfloat y = 0.5 * SourceSize.w;\nvec2 dg1 = vec2( x, y);\nvec2 dg2 = vec2(-x, y);\nvec2 dx = vec2(x, 0.0);\nvec2 dy = vec2(0.0, y);\nt1 = vec4(vTexCoord - dg1, vTexCoord - dy);\nt2 = vec4(vTexCoord - dg2, vTexCoord + dx);\nt3 = vec4(vTexCoord + dg1, vTexCoord + dy);\nt4 = vec4(vTexCoord + dg2, vTexCoord - dx);\n}\n\n#elif defined(FRAGMENT)\n\n#if __VERSION__ >= 130\n#define COMPAT_VARYING in\n#define COMPAT_TEXTURE texture\nout vec4 FragColor;\n#else\n#define COMPAT_VARYING varying\n#define FragColor gl_FragColor\n#define COMPAT_TEXTURE texture2D\n#endif\n\n#ifdef GL_ES\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#define COMPAT_PRECISION mediump\n#else\n#define COMPAT_PRECISION\n#endif\n\nuniform COMPAT_PRECISION int FrameDirection;\nuniform COMPAT_PRECISION int FrameCount;\nuniform COMPAT_PRECISION vec2 OutputSize;\nuniform COMPAT_PRECISION vec2 TextureSize;\nuniform COMPAT_PRECISION vec2 InputSize;\nuniform sampler2D Texture;\nCOMPAT_VARYING vec4 TEX0;\nCOMPAT_VARYING vec4 t1;\nCOMPAT_VARYING vec4 t2;\nCOMPAT_VARYING vec4 t3;\nCOMPAT_VARYING vec4 t4;\n\n// compatibility #defines\n#define Source Texture\n#define vTexCoord TEX0.xy\n\n#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize\n#define OutSize vec4(OutputSize, 1.0 / OutputSize)\n\nfloat mx = 0.325; // start smoothing wt.\nfloat k = -0.250; // wt. decrease factor\nfloat max_w = 0.25; // max filter weight\nfloat min_w =-0.05; // min filter weight\nfloat lum_add = 0.25; // affects smoothing\nvec3 dt = vec3(1.0);\n\nvoid main()\n{\nvec3 c00 = COMPAT_TEXTURE(Source, t1.xy).xyz; \nvec3 c10 = COMPAT_TEXTURE(Source, t1.zw).xyz; \nvec3 c20 = COMPAT_TEXTURE(Source, t2.xy).xyz; \nvec3 c01 = COMPAT_TEXTURE(Source, t4.zw).xyz; \nvec3 c11 = COMPAT_TEXTURE(Source, vTexCoord).xyz; \nvec3 c21 = COMPAT_TEXTURE(Source, t2.zw).xyz; \nvec3 c02 = COMPAT_TEXTURE(Source, t4.xy).xyz; \nvec3 c12 = COMPAT_TEXTURE(Source, t3.zw).xyz; \nvec3 c22 = COMPAT_TEXTURE(Source, t3.xy).xyz; \n\nfloat md1 = dot(abs(c00 - c22), dt);\nfloat md2 = dot(abs(c02 - c20), dt);\n\nfloat w1 = dot(abs(c22 - c11), dt) * md2;\nfloat w2 = dot(abs(c02 - c11), dt) * md1;\nfloat w3 = dot(abs(c00 - c11), dt) * md2;\nfloat w4 = dot(abs(c20 - c11), dt) * md1;\n\nfloat t1 = w1 + w3;\nfloat t2 = w2 + w4;\nfloat ww = max(t1, t2) + 0.0001;\n\nc11 = (w1 * c00 + w2 * c20 + w3 * c22 + w4 * c02 + ww * c11) / (t1 + t2 + ww);\n\nfloat lc1 = k / (0.12 * dot(c10 + c12 + c11, dt) + lum_add);\nfloat lc2 = k / (0.12 * dot(c01 + c21 + c11, dt) + lum_add);\n\nw1 = clamp(lc1 * dot(abs(c11 - c10), dt) + mx, min_w, max_w);\nw2 = clamp(lc2 * dot(abs(c11 - c21), dt) + mx, min_w, max_w);\nw3 = clamp(lc1 * dot(abs(c11 - c12), dt) + mx, min_w, max_w);\nw4 = clamp(lc2 * dot(abs(c11 - c01), dt) + mx, min_w, max_w);\nFragColor = vec4(w1 * c10 + w2 * c21 + w3 * c12 + w4 * c01 + (1.0 - w1 - w2 - w3 - w4) * c11, 1.0);\n} \n#endif\n","4xScaleHQ.glsl":"/*\n4xGLSLHqFilter shader\n\nCopyright (C) 2005 guest(r) - guest.r@gmail.com\n\nThis program is free software; you can redistribute it and/or\nmodify it under the terms of the GNU General Public License\nas published by the Free Software Foundation; either version 2\nof the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n*/\n\n#if defined(VERTEX)\n\n#if __VERSION__ >= 130\n#define COMPAT_VARYING out\n#define COMPAT_ATTRIBUTE in\n#define COMPAT_TEXTURE texture\n#else\n#define COMPAT_VARYING varying \n#define COMPAT_ATTRIBUTE attribute \n#define COMPAT_TEXTURE texture2D\n#endif\n\n#ifdef GL_ES\n#define COMPAT_PRECISION mediump\n#else\n#define COMPAT_PRECISION\n#endif\n\nCOMPAT_ATTRIBUTE vec4 VertexCoord;\nCOMPAT_ATTRIBUTE vec4 COLOR;\nCOMPAT_ATTRIBUTE vec4 TexCoord;\nCOMPAT_VARYING vec4 COL0;\nCOMPAT_VARYING vec4 TEX0;\nCOMPAT_VARYING vec4 t1;\nCOMPAT_VARYING vec4 t2;\nCOMPAT_VARYING vec4 t3;\nCOMPAT_VARYING vec4 t4;\nCOMPAT_VARYING vec4 t5;\nCOMPAT_VARYING vec4 t6;\n\nvec4 _oPosition1; \nuniform mat4 MVPMatrix;\nuniform COMPAT_PRECISION int FrameDirection;\nuniform COMPAT_PRECISION int FrameCount;\nuniform COMPAT_PRECISION vec2 OutputSize;\nuniform COMPAT_PRECISION vec2 TextureSize;\nuniform COMPAT_PRECISION vec2 InputSize;\n\n// compatibility #defines\n#define vTexCoord TEX0.xy\n#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize\n#define OutSize vec4(OutputSize, 1.0 / OutputSize)\n\nvoid main()\n{\ngl_Position = MVPMatrix * VertexCoord;\nTEX0.xy = TexCoord.xy;\nfloat x = 0.5 * SourceSize.z;\nfloat y = 0.5 * SourceSize.w;\nvec2 dg1 = vec2( x, y);\nvec2 dg2 = vec2(-x, y);\nvec2 sd1 = dg1 * 0.5;\nvec2 sd2 = dg2 * 0.5;\nvec2 ddx = vec2(x, 0.0);\nvec2 ddy = vec2(0.0, y);\nt1 = vec4(vTexCoord - sd1, vTexCoord - ddy);\nt2 = vec4(vTexCoord - sd2, vTexCoord + ddx);\nt3 = vec4(vTexCoord + sd1, vTexCoord + ddy);\nt4 = vec4(vTexCoord + sd2, vTexCoord - ddx);\nt5 = vec4(vTexCoord - dg1, vTexCoord - dg2);\nt6 = vec4(vTexCoord + dg1, vTexCoord + dg2);\n}\n\n#elif defined(FRAGMENT)\n\n#if __VERSION__ >= 130\n#define COMPAT_VARYING in\n#define COMPAT_TEXTURE texture\nout vec4 FragColor;\n#else\n#define COMPAT_VARYING varying\n#define FragColor gl_FragColor\n#define COMPAT_TEXTURE texture2D\n#endif\n\n#ifdef GL_ES\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#define COMPAT_PRECISION mediump\n#else\n#define COMPAT_PRECISION\n#endif\n\nuniform COMPAT_PRECISION int FrameDirection;\nuniform COMPAT_PRECISION int FrameCount;\nuniform COMPAT_PRECISION vec2 OutputSize;\nuniform COMPAT_PRECISION vec2 TextureSize;\nuniform COMPAT_PRECISION vec2 InputSize;\nuniform sampler2D Texture;\nCOMPAT_VARYING vec4 TEX0;\nCOMPAT_VARYING vec4 t1;\nCOMPAT_VARYING vec4 t2;\nCOMPAT_VARYING vec4 t3;\nCOMPAT_VARYING vec4 t4;\nCOMPAT_VARYING vec4 t5;\nCOMPAT_VARYING vec4 t6;\n\n// compatibility #defines\n#define Source Texture\n#define vTexCoord TEX0.xy\n\n#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize\n#define OutSize vec4(OutputSize, 1.0 / OutputSize)\n\nfloat mx = 1.0; // start smoothing wt.\nfloat k = -1.10; // wt. decrease factor\nfloat max_w = 0.75; // max filter weight\nfloat min_w = 0.03; // min filter weight\nfloat lum_add = 0.33; // affects smoothing\nvec3 dt = vec3(1.0);\n\nvoid main()\n{\nvec3 c = COMPAT_TEXTURE(Source, vTexCoord).xyz;\nvec3 i1 = COMPAT_TEXTURE(Source, t1.xy).xyz; \nvec3 i2 = COMPAT_TEXTURE(Source, t2.xy).xyz; \nvec3 i3 = COMPAT_TEXTURE(Source, t3.xy).xyz; \nvec3 i4 = COMPAT_TEXTURE(Source, t4.xy).xyz; \nvec3 o1 = COMPAT_TEXTURE(Source, t5.xy).xyz; \nvec3 o3 = COMPAT_TEXTURE(Source, t6.xy).xyz; \nvec3 o2 = COMPAT_TEXTURE(Source, t5.zw).xyz;\nvec3 o4 = COMPAT_TEXTURE(Source, t6.zw).xyz;\nvec3 s1 = COMPAT_TEXTURE(Source, t1.zw).xyz; \nvec3 s2 = COMPAT_TEXTURE(Source, t2.zw).xyz; \nvec3 s3 = COMPAT_TEXTURE(Source, t3.zw).xyz; \nvec3 s4 = COMPAT_TEXTURE(Source, t4.zw).xyz; \n\nfloat ko1=dot(abs(o1-c),dt);\nfloat ko2=dot(abs(o2-c),dt);\nfloat ko3=dot(abs(o3-c),dt);\nfloat ko4=dot(abs(o4-c),dt);\n\nfloat k1=min(dot(abs(i1-i3),dt),max(ko1,ko3));\nfloat k2=min(dot(abs(i2-i4),dt),max(ko2,ko4));\n\nfloat w1 = k2; if(ko3<ko1) w1*=ko3/ko1;\nfloat w2 = k1; if(ko4<ko2) w2*=ko4/ko2;\nfloat w3 = k2; if(ko1<ko3) w3*=ko1/ko3;\nfloat w4 = k1; if(ko2<ko4) w4*=ko2/ko4;\n\nc=(w1*o1+w2*o2+w3*o3+w4*o4+0.001*c)/(w1+w2+w3+w4+0.001);\nw1 = k*dot(abs(i1-c)+abs(i3-c),dt)/(0.125*dot(i1+i3,dt)+lum_add);\nw2 = k*dot(abs(i2-c)+abs(i4-c),dt)/(0.125*dot(i2+i4,dt)+lum_add);\nw3 = k*dot(abs(s1-c)+abs(s3-c),dt)/(0.125*dot(s1+s3,dt)+lum_add);\nw4 = k*dot(abs(s2-c)+abs(s4-c),dt)/(0.125*dot(s2+s4,dt)+lum_add);\n\nw1 = clamp(w1+mx,min_w,max_w); \nw2 = clamp(w2+mx,min_w,max_w);\nw3 = clamp(w3+mx,min_w,max_w); \nw4 = clamp(w4+mx,min_w,max_w);\n\nFragColor = vec4((w1*(i1+i3)+w2*(i2+i4)+w3*(s1+s3)+w4*(s2+s4)+c)/(2.0*(w1+w2+w3+w4)+1.0), 1.0);\n} \n#endif\n","crt-easymode.glsl":"#if defined(VERTEX)\n\n #if __VERSION__ >= 130\n #define COMPAT_VARYING out\n #define COMPAT_ATTRIBUTE in\n #define COMPAT_TEXTURE texture\n #else\n #define COMPAT_VARYING varying\n #define COMPAT_ATTRIBUTE attribute\n #define COMPAT_TEXTURE texture2D\n #endif\n \n #ifdef GL_ES\n #define COMPAT_PRECISION mediump\n #else\n #define COMPAT_PRECISION\n #endif\n COMPAT_VARYING float _frame_rotation;\n struct input_dummy {\n vec2 _video_size;\n vec2 _texture_size;\n vec2 _output_dummy_size;\n float _frame_count;\n float _frame_direction;\n float _frame_rotation;\n };\n vec4 _oPosition1;\n vec4 _r0005;\n COMPAT_ATTRIBUTE vec4 VertexCoord;\n COMPAT_ATTRIBUTE vec4 TexCoord;\n COMPAT_VARYING vec4 TEX0;\n \n uniform mat4 MVPMatrix;\n uniform int FrameDirection;\n uniform int FrameCount;\n uniform COMPAT_PRECISION vec2 OutputSize;\n uniform COMPAT_PRECISION vec2 TextureSize;\n uniform COMPAT_PRECISION vec2 InputSize;\n void main()\n {\n vec2 _oTex;\n _r0005 = VertexCoord.x*MVPMatrix[0];\n _r0005 = _r0005 + VertexCoord.y*MVPMatrix[1];\n _r0005 = _r0005 + VertexCoord.z*MVPMatrix[2];\n _r0005 = _r0005 + VertexCoord.w*MVPMatrix[3];\n _oPosition1 = _r0005;\n _oTex = TexCoord.xy;\n gl_Position = _r0005;\n TEX0.xy = TexCoord.xy;\n }\n #elif defined(FRAGMENT)\n \n #if __VERSION__ >= 130\n #define COMPAT_VARYING in\n #define COMPAT_TEXTURE texture\n out vec4 FragColor;\n #else\n #define COMPAT_VARYING varying\n #define FragColor gl_FragColor\n #define COMPAT_TEXTURE texture2D\n #endif\n \n #ifdef GL_ES\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n #else\n precision mediump float;\n #endif\n #define COMPAT_PRECISION mediump\n #else\n #define COMPAT_PRECISION\n #endif\n COMPAT_VARYING float _frame_rotation;\n struct input_dummy {\n vec2 _video_size;\n vec2 _texture_size;\n vec2 _output_dummy_size;\n float _frame_count;\n float _frame_direction;\n float _frame_rotation;\n };\n vec4 _ret_0;\n float _TMP30;\n float _TMP29;\n float _TMP28;\n float _TMP13;\n float _TMP32;\n float _TMP11;\n float _TMP10;\n float _TMP31;\n float _TMP9;\n float _TMP8;\n float _TMP15;\n float _TMP14;\n float _TMP33;\n vec4 _TMP34;\n vec4 _TMP27;\n vec4 _TMP25;\n vec4 _TMP23;\n vec4 _TMP21;\n vec4 _TMP26;\n vec4 _TMP24;\n vec4 _TMP22;\n vec4 _TMP20;\n float _TMP4;\n vec4 _TMP3;\n vec4 _TMP2;\n float _TMP19;\n float _TMP18;\n float _TMP17;\n float _TMP16;\n vec4 _TMP1;\n vec2 _TMP0;\n uniform sampler2D Texture;\n input_dummy _IN1;\n float _TMP43;\n float _x_step0044;\n float _curve0044;\n float _a0048;\n float _val0052;\n float _a0052;\n vec4 _TMP57;\n vec4 _x0072;\n vec2 _c0086;\n vec4 _x0088;\n vec4 _x0094;\n vec2 _c0098;\n vec4 _x0100;\n vec2 _c0104;\n vec4 _x0106;\n vec4 _sample_min0110;\n vec4 _sample_max0110;\n vec4 _r0112;\n vec4 _TMP117;\n vec2 _co0124;\n vec2 _c0126;\n vec4 _x0128;\n vec4 _x0134;\n vec2 _c0138;\n vec4 _x0140;\n vec2 _c0144;\n vec4 _x0146;\n vec4 _sample_min0150;\n vec4 _sample_max0150;\n vec4 _r0152;\n vec4 _TMP157;\n float _TMP163;\n float _x_step0164;\n float _curve0164;\n float _a0168;\n float _val0172;\n float _a0172;\n float _TMP183;\n float _TMP189;\n float _x0190;\n float _a0196;\n float _x0198;\n vec2 _x0200;\n float _x0208;\n COMPAT_VARYING vec4 TEX0;\n \n uniform COMPAT_PRECISION vec2 OutputSize;\n uniform COMPAT_PRECISION vec2 TextureSize;\n uniform COMPAT_PRECISION vec2 InputSize;\n void main()\n {\n vec2 _dx1;\n vec2 _dy;\n vec2 _pix_co;\n vec2 _tex_co;\n vec2 _dist;\n vec3 _col2;\n vec3 _col21;\n vec4 _coeffs1;\n float _luma;\n float _bright;\n float _scan_weight;\n vec2 _mod_fac;\n int _dot_no;\n vec3 _mask_weight;\n vec3 _TMP37;\n _dx1 = vec2(1.00000000E+00/TextureSize.x, 0.00000000E+00);\n _dy = vec2(0.00000000E+00, 1.00000000E+00/TextureSize.y);\n _pix_co = TEX0.xy*TextureSize - vec2( 5.00000000E-01, 5.00000000E-01);\n _TMP0 = floor(_pix_co);\n _tex_co = (_TMP0 + vec2( 5.00000000E-01, 5.00000000E-01))/TextureSize;\n _dist = fract(_pix_co);\n _x_step0044 = float((_dist.x >= 5.00000000E-01));\n _a0048 = 2.50000000E-01 - (_dist.x - _x_step0044)*(_dist.x - _x_step0044);\n _TMP33 = inversesqrt(_a0048);\n _TMP14 = 1.00000000E+00/_TMP33;\n _a0052 = 5.00000000E-01 - _dist.x;\n _val0052 = float((_a0052 > 0.00000000E+00));\n _TMP15 = _val0052 - float((_a0052 < 0.00000000E+00));\n _curve0044 = 5.00000000E-01 - _TMP14*_TMP15;\n _TMP43 = _dist.x + 2.50000000E-01*(_curve0044 - _dist.x);\n _coeffs1 = 3.14159274E+00*vec4(1.00000000E+00 + _TMP43, _TMP43, 1.00000000E+00 - _TMP43, 2.00000000E+00 - _TMP43);\n _TMP1 = abs(_coeffs1);\n _TMP57 = max(_TMP1, vec4( 9.99999975E-06, 9.99999975E-06, 9.99999975E-06, 9.99999975E-06));\n _TMP16 = sin(_TMP57.x);\n _TMP17 = sin(_TMP57.y);\n _TMP18 = sin(_TMP57.z);\n _TMP19 = sin(_TMP57.w);\n _TMP2 = vec4(_TMP16, _TMP17, _TMP18, _TMP19);\n _x0072 = _TMP57/2.00000000E+00;\n _TMP16 = sin(_x0072.x);\n _TMP17 = sin(_x0072.y);\n _TMP18 = sin(_x0072.z);\n _TMP19 = sin(_x0072.w);\n _TMP3 = vec4(_TMP16, _TMP17, _TMP18, _TMP19);\n _coeffs1 = ((2.00000000E+00*_TMP2)*_TMP3)/(_TMP57*_TMP57);\n _TMP4 = dot(_coeffs1, vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _coeffs1 = _coeffs1/_TMP4;\n _c0086 = _tex_co - _dx1;\n _TMP20 = COMPAT_TEXTURE(Texture, _c0086);\n _x0088 = vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00) + (_TMP20 - vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _TMP21 = _TMP20*_x0088;\n _TMP22 = COMPAT_TEXTURE(Texture, _tex_co);\n _x0094 = vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00) + (_TMP22 - vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _TMP23 = _TMP22*_x0094;\n _c0098 = _tex_co + _dx1;\n _TMP24 = COMPAT_TEXTURE(Texture, _c0098);\n _x0100 = vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00) + (_TMP24 - vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _TMP25 = _TMP24*_x0100;\n _c0104 = _tex_co + 2.00000000E+00*_dx1;\n _TMP26 = COMPAT_TEXTURE(Texture, _c0104);\n _x0106 = vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00) + (_TMP26 - vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _TMP27 = _TMP26*_x0106;\n _r0112 = _coeffs1.x*_TMP21;\n _r0112 = _r0112 + _coeffs1.y*_TMP23;\n _r0112 = _r0112 + _coeffs1.z*_TMP25;\n _r0112 = _r0112 + _coeffs1.w*_TMP27;\n _sample_min0110 = min(_TMP23, _TMP25);\n _sample_max0110 = max(_TMP23, _TMP25);\n _TMP34 = min(_sample_max0110, _r0112);\n _TMP117 = max(_sample_min0110, _TMP34);\n _co0124 = _tex_co + _dy;\n _c0126 = _co0124 - _dx1;\n _TMP20 = COMPAT_TEXTURE(Texture, _c0126);\n _x0128 = vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00) + (_TMP20 - vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _TMP21 = _TMP20*_x0128;\n _TMP22 = COMPAT_TEXTURE(Texture, _co0124);\n _x0134 = vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00) + (_TMP22 - vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _TMP23 = _TMP22*_x0134;\n _c0138 = _co0124 + _dx1;\n _TMP24 = COMPAT_TEXTURE(Texture, _c0138);\n _x0140 = vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00) + (_TMP24 - vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _TMP25 = _TMP24*_x0140;\n _c0144 = _co0124 + 2.00000000E+00*_dx1;\n _TMP26 = COMPAT_TEXTURE(Texture, _c0144);\n _x0146 = vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00) + (_TMP26 - vec4( 1.00000000E+00, 1.00000000E+00, 1.00000000E+00, 1.00000000E+00));\n _TMP27 = _TMP26*_x0146;\n _r0152 = _coeffs1.x*_TMP21;\n _r0152 = _r0152 + _coeffs1.y*_TMP23;\n _r0152 = _r0152 + _coeffs1.z*_TMP25;\n _r0152 = _r0152 + _coeffs1.w*_TMP27;\n _sample_min0150 = min(_TMP23, _TMP25);\n _sample_max0150 = max(_TMP23, _TMP25);\n _TMP34 = min(_sample_max0150, _r0152);\n _TMP157 = max(_sample_min0150, _TMP34);\n _x_step0164 = float((_dist.y >= 5.00000000E-01));\n _a0168 = 2.50000000E-01 - (_dist.y - _x_step0164)*(_dist.y - _x_step0164);\n _TMP33 = inversesqrt(_a0168);\n _TMP14 = 1.00000000E+00/_TMP33;\n _a0172 = 5.00000000E-01 - _dist.y;\n _val0172 = float((_a0172 > 0.00000000E+00));\n _TMP15 = _val0172 - float((_a0172 < 0.00000000E+00));\n _curve0164 = 5.00000000E-01 - _TMP14*_TMP15;\n _TMP163 = _dist.y + (_curve0164 - _dist.y);\n _col2 = _TMP117.xyz + _TMP163*(_TMP157.xyz - _TMP117.xyz);\n _luma = dot(vec3( 2.12599993E-01, 7.15200007E-01, 7.22000003E-02), _col2);\n _TMP8 = max(_col2.y, _col2.z);\n _TMP9 = max(_col2.x, _TMP8);\n _bright = (_TMP9 + _luma)/2.00000000E+00;\n _TMP31 = min(6.49999976E-01, _bright);\n _TMP183 = max(3.49999994E-01, _TMP31);\n _x0190 = _bright*1.50000000E+00;\n _TMP31 = min(1.50000000E+00, _x0190);\n _TMP189 = max(1.50000000E+00, _TMP31);\n _a0196 = TEX0.y*2.00000000E+00*3.14159274E+00*TextureSize.y;\n _TMP10 = cos(_a0196);\n _x0198 = _TMP10*5.00000000E-01 + 5.00000000E-01;\n _TMP11 = pow(_x0198, _TMP189);\n _scan_weight = 1.00000000E+00 - _TMP11;\n _x0200 = (TEX0.xy*OutputSize*TextureSize)/InputSize;\n _mod_fac = floor(_x0200);\n _x0208 = _mod_fac.x/3.00000000E+00;\n _TMP32 = floor(_x0208);\n _TMP13 = _mod_fac.x - 3.00000000E+00*_TMP32;\n _dot_no = int(_TMP13);\n if (_dot_no == 0) {\n _mask_weight = vec3( 1.00000000E+00, 6.99999988E-01, 6.99999988E-01);\n } else {\n if (_dot_no == 1) {\n _mask_weight = vec3( 6.99999988E-01, 1.00000000E+00, 6.99999988E-01);\n } else {\n _mask_weight = vec3( 6.99999988E-01, 6.99999988E-01, 1.00000000E+00);\n }\n }\n if (InputSize.y >= 4.00000000E+02) {\n _scan_weight = 1.00000000E+00;\n }\n _col21 = _col2.xyz;\n _col2 = _col2*vec3(_scan_weight, _scan_weight, _scan_weight);\n _col2 = _col2 + _TMP183*(_col21 - _col2);\n _col2 = _col2*_mask_weight;\n _TMP28 = pow(_col2.x, 5.55555582E-01);\n _TMP29 = pow(_col2.y, 5.55555582E-01);\n _TMP30 = pow(_col2.z, 5.55555582E-01);\n _col2 = vec3(_TMP28, _TMP29, _TMP30);\n _TMP37 = _col2*1.20000005E+00;\n _ret_0 = vec4(_TMP37.x, _TMP37.y, _TMP37.z, 1.00000000E+00);\n FragColor = _ret_0;\n return;\n }\n #endif\n","crt-aperture.glsl":'\n/*\nCRT Shader by EasyMode\nLicense: GPL\n*/\n/*\n#pragma parameter SHARPNESS_IMAGE "Sharpness Image" 1.0 1.0 5.0 1.0\n#pragma parameter SHARPNESS_EDGES "Sharpness Edges" 3.0 1.0 5.0 1.0\n#pragma parameter GLOW_WIDTH "Glow Width" 0.5 0.05 0.65 0.05\n#pragma parameter GLOW_HEIGHT "Glow Height" 0.5 0.05 0.65 0.05\n#pragma parameter GLOW_HALATION "Glow Halation" 0.1 0.0 1.0 0.01\n#pragma parameter GLOW_DIFFUSION "Glow Diffusion" 0.05 0.0 1.0 0.01\n#pragma parameter MASK_COLORS "Mask Colors" 2.0 2.0 3.0 1.0\n#pragma parameter MASK_STRENGTH "Mask Strength" 0.3 0.0 1.0 0.05\n#pragma parameter MASK_SIZE "Mask Size" 1.0 1.0 9.0 1.0\n#pragma parameter SCANLINE_SIZE_MIN "Scanline Size Min." 0.5 0.5 1.5 0.05\n#pragma parameter SCANLINE_SIZE_MAX "Scanline Size Max." 1.5 0.5 1.5 0.05\n#pragma parameter GAMMA_INPUT "Gamma Input" 2.4 1.0 5.0 0.1\n#pragma parameter GAMMA_OUTPUT "Gamma Output" 2.4 1.0 5.0 0.1\n#pragma parameter BRIGHTNESS "Brightness" 1.5 0.0 2.0 0.05\n* */\n\n#define Coord TEX0\n\n#if defined(VERTEX)\n\n#if __VERSION__ >= 130\n#define OUT out\n#define IN in\n#define tex2D texture\n#else\n#define OUT varying \n#define IN attribute \n#define tex2D texture2D\n#endif\n\n#ifdef GL_ES\n#define PRECISION mediump\n#else\n#define PRECISION\n#endif\n\nIN vec4 VertexCoord;\nIN vec4 Color;\nIN vec2 TexCoord;\nOUT vec4 color;\nOUT vec2 Coord;\n\nuniform mat4 MVPMatrix;\nuniform PRECISION int FrameDirection;\nuniform PRECISION int FrameCount;\nuniform PRECISION vec2 OutputSize;\nuniform PRECISION vec2 TextureSize;\nuniform PRECISION vec2 InputSize;\n\nvoid main()\n{\ngl_Position = MVPMatrix * VertexCoord;\ncolor = Color;\nCoord = TexCoord;\n}\n\n#elif defined(FRAGMENT)\n\n#if __VERSION__ >= 130\n#define IN in\n#define tex2D texture\nout vec4 FragColor;\n#else\n#define IN varying\n#define FragColor gl_FragColor\n#define tex2D texture2D\n#endif\n\n#ifdef GL_ES\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#define PRECISION mediump\n#else\n#define PRECISION\n#endif\n\nuniform PRECISION int FrameDirection;\nuniform PRECISION int FrameCount;\nuniform PRECISION vec2 OutputSize;\nuniform PRECISION vec2 TextureSize;\nuniform PRECISION vec2 InputSize;\nuniform sampler2D Texture;\nIN vec2 Coord;\n\n#ifdef PARAMETER_UNIFORM\nuniform PRECISION float SHARPNESS_IMAGE;\nuniform PRECISION float SHARPNESS_EDGES;\nuniform PRECISION float GLOW_WIDTH;\nuniform PRECISION float GLOW_HEIGHT;\nuniform PRECISION float GLOW_HALATION;\nuniform PRECISION float GLOW_DIFFUSION;\nuniform PRECISION float MASK_COLORS;\nuniform PRECISION float MASK_STRENGTH;\nuniform PRECISION float MASK_SIZE;\nuniform PRECISION float SCANLINE_SIZE_MIN;\nuniform PRECISION float SCANLINE_SIZE_MAX;\nuniform PRECISION float GAMMA_INPUT;\nuniform PRECISION float GAMMA_OUTPUT;\nuniform PRECISION float BRIGHTNESS;\n#else\n#define SHARPNESS_IMAGE 1.0\n#define SHARPNESS_EDGES 3.0\n#define GLOW_WIDTH 0.5\n#define GLOW_HEIGHT 0.5\n#define GLOW_HALATION 0.1\n#define GLOW_DIFFUSION 0.05\n#define MASK_COLORS 2.0\n#define MASK_STRENGTH 0.3\n#define MASK_SIZE 1.0\n#define SCANLINE_SIZE_MIN 0.5\n#define SCANLINE_SIZE_MAX 1.5\n#define GAMMA_INPUT 2.4\n#define GAMMA_OUTPUT 2.4\n#define BRIGHTNESS 1.5\n#endif\n\n#define FIX(c) max(abs(c), 1e-5)\n#define PI 3.141592653589\n#define saturate(c) clamp(c, 0.0, 1.0)\n#define TEX2D(c) pow(tex2D(tex, c).rgb, vec3(GAMMA_INPUT))\n\nmat3 get_color_matrix(sampler2D tex, vec2 co, vec2 dx)\n{\nreturn mat3(TEX2D(co - dx), TEX2D(co), TEX2D(co + dx));\n}\n\nvec3 blur(mat3 m, float dist, float rad)\n{\nvec3 x = vec3(dist - 1.0, dist, dist + 1.0) / rad;\nvec3 w = exp2(x * x * -1.0);\n\nreturn (m[0] * w.x + m[1] * w.y + m[2] * w.z) / (w.x + w.y + w.z);\n}\n\nvec3 filter_gaussian(sampler2D tex, vec2 co, vec2 tex_size)\n{\nvec2 dx = vec2(1.0 / tex_size.x, 0.0);\nvec2 dy = vec2(0.0, 1.0 / tex_size.y);\nvec2 pix_co = co * tex_size;\nvec2 tex_co = (floor(pix_co) + 0.5) / tex_size;\nvec2 dist = (fract(pix_co) - 0.5) * -1.0;\n\nmat3 line0 = get_color_matrix(tex, tex_co - dy, dx);\nmat3 line1 = get_color_matrix(tex, tex_co, dx);\nmat3 line2 = get_color_matrix(tex, tex_co + dy, dx);\nmat3 column = mat3(blur(line0, dist.x, GLOW_WIDTH),\n blur(line1, dist.x, GLOW_WIDTH),\n blur(line2, dist.x, GLOW_WIDTH));\n\nreturn blur(column, dist.y, GLOW_HEIGHT);\n}\n\nvec3 filter_lanczos(sampler2D tex, vec2 co, vec2 tex_size, float sharp)\n{\ntex_size.x *= sharp;\n\nvec2 dx = vec2(1.0 / tex_size.x, 0.0);\nvec2 pix_co = co * tex_size - vec2(0.5, 0.0);\nvec2 tex_co = (floor(pix_co) + vec2(0.5, 0.0)) / tex_size;\nvec2 dist = fract(pix_co);\nvec4 coef = PI * vec4(dist.x + 1.0, dist.x, dist.x - 1.0, dist.x - 2.0);\n\ncoef = FIX(coef);\ncoef = 2.0 * sin(coef) * sin(coef / 2.0) / (coef * coef);\ncoef /= dot(coef, vec4(1.0));\n\nvec4 col1 = vec4(TEX2D(tex_co), 1.0);\nvec4 col2 = vec4(TEX2D(tex_co + dx), 1.0);\n\nreturn (mat4(col1, col1, col2, col2) * coef).rgb;\n}\n\nvec3 get_scanline_weight(float x, vec3 col)\n{\nvec3 beam = mix(vec3(SCANLINE_SIZE_MIN), vec3(SCANLINE_SIZE_MAX), col);\nvec3 x_mul = 2.0 / beam;\nvec3 x_offset = x_mul * 0.5;\n\nreturn smoothstep(0.0, 1.0, 1.0 - abs(x * x_mul - x_offset)) * x_offset;\n}\n\nvec3 get_mask_weight(float x)\n{\nfloat i = mod(floor(x * OutputSize.x * TextureSize.x / (InputSize.x * MASK_SIZE)), MASK_COLORS);\n\nif (i == 0.0) return mix(vec3(1.0, 0.0, 1.0), vec3(1.0, 0.0, 0.0), MASK_COLORS - 2.0);\nelse if (i == 1.0) return vec3(0.0, 1.0, 0.0);\nelse return vec3(0.0, 0.0, 1.0);\n}\n\nvoid main()\n{\nvec3 col_glow = filter_gaussian(Texture, Coord, TextureSize);\nvec3 col_soft = filter_lanczos(Texture, Coord, TextureSize, SHARPNESS_IMAGE);\nvec3 col_sharp = filter_lanczos(Texture, Coord, TextureSize, SHARPNESS_EDGES);\nvec3 col = sqrt(col_sharp * col_soft);\n\ncol *= get_scanline_weight(fract(Coord.y * TextureSize.y), col_soft);\ncol_glow = saturate(col_glow - col);\ncol += col_glow * col_glow * GLOW_HALATION;\ncol = mix(col, col * get_mask_weight(Coord.x) * MASK_COLORS, MASK_STRENGTH);\ncol += col_glow * GLOW_DIFFUSION;\ncol = pow(col * BRIGHTNESS, vec3(1.0 / GAMMA_OUTPUT));\n\nFragColor = vec4(col, 1.0);\n}\n\n#endif\n',"crt-geom.glsl":'\n/*\nCRT-interlaced\n\nCopyright (C) 2010-2012 cgwg, Themaister and DOLLS\n\nThis program is free software; you can redistribute it and/or modify it\nunder the terms of the GNU General Public License as published by the Free\nSoftware Foundation; either version 2 of the License, or (at your option)\nany later version.\n\n(cgwg gave their consent to have the original version of this shader\ndistributed under the GPL in this message:\n\nhttp://board.byuu.org/viewtopic.php?p=26075#p26075\n\n"Feel free to distribute my shaders under the GPL. After all, the\nbarrel distortion code was taken from the Curvature shader, which is\nunder the GPL."\n)\nThis shader variant is pre-configured with screen curvature\n*/\n/*\n#pragma parameter CRTgamma "CRTGeom Target Gamma" 2.4 0.1 5.0 0.1\n#pragma parameter monitorgamma "CRTGeom Monitor Gamma" 2.2 0.1 5.0 0.1\n#pragma parameter d "CRTGeom Distance" 1.6 0.1 3.0 0.1\n#pragma parameter CURVATURE "CRTGeom Curvature Toggle" 1.0 0.0 1.0 1.0\n#pragma parameter R "CRTGeom Curvature Radius" 2.0 0.1 10.0 0.1\n#pragma parameter cornersize "CRTGeom Corner Size" 0.03 0.001 1.0 0.005\n#pragma parameter cornersmooth "CRTGeom Corner Smoothness" 1000.0 80.0 2000.0 100.0\n#pragma parameter x_tilt "CRTGeom Horizontal Tilt" 0.0 -0.5 0.5 0.05\n#pragma parameter y_tilt "CRTGeom Vertical Tilt" 0.0 -0.5 0.5 0.05\n#pragma parameter overscan_x "CRTGeom Horiz. Overscan %" 100.0 -125.0 125.0 1.0\n#pragma parameter overscan_y "CRTGeom Vert. Overscan %" 100.0 -125.0 125.0 1.0\n#pragma parameter DOTMASK "CRTGeom Dot Mask Toggle" 0.3 0.0 0.3 0.3\n#pragma parameter SHARPER "CRTGeom Sharpness" 1.0 1.0 3.0 1.0\n#pragma parameter scanline_weight "CRTGeom Scanline Weight" 0.3 0.1 0.5 0.05\n*/\n\n#ifndef PARAMETER_UNIFORM\n#define CRTgamma 2.4\n#define monitorgamma 2.2\n#define d 1.6\n#define CURVATURE 1.0\n#define R 2.0\n#define cornersize 0.03\n#define cornersmooth 1000.0\n#define x_tilt 0.0\n#define y_tilt 0.0\n#define overscan_x 100.0\n#define overscan_y 100.0\n#define DOTMASK 0.3\n#define SHARPER 1.0\n#define scanline_weight 0.3\n#endif\n\n#if defined(VERTEX)\n\n#if __VERSION__ >= 130\n#define COMPAT_VARYING out\n#define COMPAT_ATTRIBUTE in\n#define COMPAT_TEXTURE texture\n#else\n#define COMPAT_VARYING varying \n#define COMPAT_ATTRIBUTE attribute \n#define COMPAT_TEXTURE texture2D\n#endif\n\n#ifdef GL_ES\n#define COMPAT_PRECISION mediump\n#else\n#define COMPAT_PRECISION\n#endif\n\nCOMPAT_ATTRIBUTE vec4 VertexCoord;\nCOMPAT_ATTRIBUTE vec4 COLOR;\nCOMPAT_ATTRIBUTE vec4 TexCoord;\nCOMPAT_VARYING vec4 COL0;\nCOMPAT_VARYING vec4 TEX0;\n\nvec4 _oPosition1; \nuniform mat4 MVPMatrix;\nuniform COMPAT_PRECISION int FrameDirection;\nuniform COMPAT_PRECISION int FrameCount;\nuniform COMPAT_PRECISION vec2 OutputSize;\nuniform COMPAT_PRECISION vec2 TextureSize;\nuniform COMPAT_PRECISION vec2 InputSize;\n\nCOMPAT_VARYING vec2 overscan;\nCOMPAT_VARYING vec2 aspect;\nCOMPAT_VARYING vec3 stretch;\nCOMPAT_VARYING vec2 sinangle;\nCOMPAT_VARYING vec2 cosangle;\nCOMPAT_VARYING vec2 one;\nCOMPAT_VARYING float mod_factor;\nCOMPAT_VARYING vec2 ilfac;\n\n#ifdef PARAMETER_UNIFORM\nuniform COMPAT_PRECISION float CRTgamma;\nuniform COMPAT_PRECISION float monitorgamma;\nuniform COMPAT_PRECISION float d;\nuniform COMPAT_PRECISION float CURVATURE;\nuniform COMPAT_PRECISION float R;\nuniform COMPAT_PRECISION float cornersize;\nuniform COMPAT_PRECISION float cornersmooth;\nuniform COMPAT_PRECISION float x_tilt;\nuniform COMPAT_PRECISION float y_tilt;\nuniform COMPAT_PRECISION float overscan_x;\nuniform COMPAT_PRECISION float overscan_y;\nuniform COMPAT_PRECISION float DOTMASK;\nuniform COMPAT_PRECISION float SHARPER;\nuniform COMPAT_PRECISION float scanline_weight;\n#endif\n\n#define FIX(c) max(abs(c), 1e-5);\n\nfloat intersect(vec2 xy)\n{\nfloat A = dot(xy,xy)+d*d;\nfloat B = 2.0*(R*(dot(xy,sinangle)-d*cosangle.x*cosangle.y)-d*d);\nfloat C = d*d + 2.0*R*d*cosangle.x*cosangle.y;\nreturn (-B-sqrt(B*B-4.0*A*C))/(2.0*A);\n}\n\nvec2 bkwtrans(vec2 xy)\n{\nfloat c = intersect(xy);\nvec2 point = vec2(c)*xy;\npoint -= vec2(-R)*sinangle;\npoint /= vec2(R);\nvec2 tang = sinangle/cosangle;\nvec2 poc = point/cosangle;\nfloat A = dot(tang,tang)+1.0;\nfloat B = -2.0*dot(poc,tang);\nfloat C = dot(poc,poc)-1.0;\nfloat a = (-B+sqrt(B*B-4.0*A*C))/(2.0*A);\nvec2 uv = (point-a*sinangle)/cosangle;\nfloat r = R*acos(a);\nreturn uv*r/sin(r/R);\n}\n\nvec2 fwtrans(vec2 uv)\n{\nfloat r = FIX(sqrt(dot(uv,uv)));\nuv *= sin(r/R)/r;\nfloat x = 1.0-cos(r/R);\nfloat D = d/R + x*cosangle.x*cosangle.y+dot(uv,sinangle);\nreturn d*(uv*cosangle-x*sinangle)/D;\n}\n\nvec3 maxscale()\n{\nvec2 c = bkwtrans(-R * sinangle / (1.0 + R/d*cosangle.x*cosangle.y));\nvec2 a = vec2(0.5,0.5)*aspect;\nvec2 lo = vec2(fwtrans(vec2(-a.x,c.y)).x, fwtrans(vec2(c.x,-a.y)).y)/aspect;\nvec2 hi = vec2(fwtrans(vec2(+a.x,c.y)).x, fwtrans(vec2(c.x,+a.y)).y)/aspect;\nreturn vec3((hi+lo)*aspect*0.5,max(hi.x-lo.x,hi.y-lo.y));\n}\n\nvoid main()\n{\n// START of parameters\n\n// gamma of simulated CRT\n//\tCRTgamma = 1.8;\n// gamma of display monitor (typically 2.2 is correct)\n//\tmonitorgamma = 2.2;\n// overscan (e.g. 1.02 for 2% overscan)\noverscan = vec2(1.00,1.00);\n// aspect ratio\naspect = vec2(1.0, 0.75);\n// lengths are measured in units of (approximately) the width\n// of the monitor simulated distance from viewer to monitor\n//\td = 2.0;\n// radius of curvature\n//\tR = 1.5;\n// tilt angle in radians\n// (behavior might be a bit wrong if both components are\n// nonzero)\nconst vec2 angle = vec2(0.0,0.0);\n// size of curved corners\n//\tcornersize = 0.03;\n// border smoothness parameter\n// decrease if borders are too aliased\n//\tcornersmooth = 1000.0;\n\n// END of parameters\n\nvec4 _oColor;\nvec2 _otexCoord;\ngl_Position = VertexCoord.x * MVPMatrix[0] + VertexCoord.y * MVPMatrix[1] + VertexCoord.z * MVPMatrix[2] + VertexCoord.w * MVPMatrix[3];\n_oPosition1 = gl_Position;\n_oColor = COLOR;\n_otexCoord = TexCoord.xy;\nCOL0 = COLOR;\nTEX0.xy = TexCoord.xy;\n\n// Precalculate a bunch of useful values we\'ll need in the fragment\n// shader.\nsinangle = sin(vec2(x_tilt, y_tilt)) + vec2(0.001);//sin(vec2(max(abs(x_tilt), 1e-3), max(abs(y_tilt), 1e-3)));\ncosangle = cos(vec2(x_tilt, y_tilt)) + vec2(0.001);//cos(vec2(max(abs(x_tilt), 1e-3), max(abs(y_tilt), 1e-3)));\nstretch = maxscale();\n\nilfac = vec2(1.0,clamp(floor(InputSize.y/200.0), 1.0, 2.0));\n\n// The size of one texel, in texture-coordinates.\nvec2 sharpTextureSize = vec2(SHARPER * TextureSize.x, TextureSize.y);\none = ilfac / sharpTextureSize;\n\n// Resulting X pixel-coordinate of the pixel we\'re drawing.\nmod_factor = TexCoord.x * TextureSize.x * OutputSize.x / InputSize.x;\n\n}\n\n#elif defined(FRAGMENT)\n\n#if __VERSION__ >= 130\n#define COMPAT_VARYING in\n#define COMPAT_TEXTURE texture\nout vec4 FragColor;\n#else\n#define COMPAT_VARYING varying\n#define FragColor gl_FragColor\n#define COMPAT_TEXTURE texture2D\n#endif\n\n#ifdef GL_ES\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#define COMPAT_PRECISION mediump\n#else\n#define COMPAT_PRECISION\n#endif\n\nstruct output_dummy {\nvec4 _color;\n};\n\nuniform COMPAT_PRECISION int FrameDirection;\nuniform COMPAT_PRECISION int FrameCount;\nuniform COMPAT_PRECISION vec2 OutputSize;\nuniform COMPAT_PRECISION vec2 TextureSize;\nuniform COMPAT_PRECISION vec2 InputSize;\nuniform sampler2D Texture;\nCOMPAT_VARYING vec4 TEX0;\n\n// Comment the next line to disable interpolation in linear gamma (and\n// gain speed).\n#define LINEAR_PROCESSING\n\n// Enable screen curvature.\n// #define CURVATURE\n\n// Enable 3x oversampling of the beam profile\n#define OVERSAMPLE\n\n// Use the older, purely gaussian beam profile\n//#define USEGAUSSIAN\n\n// Macros.\n#define FIX(c) max(abs(c), 1e-5);\n#define PI 3.141592653589\n\n#ifdef LINEAR_PROCESSING\n# define TEX2D(c) pow(COMPAT_TEXTURE(Texture, (c)), vec4(CRTgamma))\n#else\n# define TEX2D(c) COMPAT_TEXTURE(Texture, (c))\n#endif\n\nCOMPAT_VARYING vec2 one;\nCOMPAT_VARYING float mod_factor;\nCOMPAT_VARYING vec2 ilfac;\nCOMPAT_VARYING vec2 overscan;\nCOMPAT_VARYING vec2 aspect;\nCOMPAT_VARYING vec3 stretch;\nCOMPAT_VARYING vec2 sinangle;\nCOMPAT_VARYING vec2 cosangle;\n\n#ifdef PARAMETER_UNIFORM\nuniform COMPAT_PRECISION float CRTgamma;\nuniform COMPAT_PRECISION float monitorgamma;\nuniform COMPAT_PRECISION float d;\nuniform COMPAT_PRECISION float CURVATURE;\nuniform COMPAT_PRECISION float R;\nuniform COMPAT_PRECISION float cornersize;\nuniform COMPAT_PRECISION float cornersmooth;\nuniform COMPAT_PRECISION float x_tilt;\nuniform COMPAT_PRECISION float y_tilt;\nuniform COMPAT_PRECISION float overscan_x;\nuniform COMPAT_PRECISION float overscan_y;\nuniform COMPAT_PRECISION float DOTMASK;\nuniform COMPAT_PRECISION float SHARPER;\nuniform COMPAT_PRECISION float scanline_weight;\n#endif\n\nfloat intersect(vec2 xy)\n{\nfloat A = dot(xy,xy)+d*d;\nfloat B = 2.0*(R*(dot(xy,sinangle)-d*cosangle.x*cosangle.y)-d*d);\nfloat C = d*d + 2.0*R*d*cosangle.x*cosangle.y;\nreturn (-B-sqrt(B*B-4.0*A*C))/(2.0*A);\n}\n\nvec2 bkwtrans(vec2 xy)\n{\nfloat c = intersect(xy);\nvec2 point = vec2(c)*xy;\npoint -= vec2(-R)*sinangle;\npoint /= vec2(R);\nvec2 tang = sinangle/cosangle;\nvec2 poc = point/cosangle;\nfloat A = dot(tang,tang)+1.0;\nfloat B = -2.0*dot(poc,tang);\nfloat C = dot(poc,poc)-1.0;\nfloat a = (-B+sqrt(B*B-4.0*A*C))/(2.0*A);\nvec2 uv = (point-a*sinangle)/cosangle;\nfloat r = FIX(R*acos(a));\nreturn uv*r/sin(r/R);\n}\n\nvec2 transform(vec2 coord)\n{\ncoord *= TextureSize / InputSize;\ncoord = (coord-vec2(0.5))*aspect*stretch.z+stretch.xy;\nreturn (bkwtrans(coord)/vec2(overscan_x / 100.0, overscan_y / 100.0)/aspect+vec2(0.5)) * InputSize / TextureSize;\n}\n\nfloat corner(vec2 coord)\n{\ncoord *= TextureSize / InputSize;\ncoord = (coord - vec2(0.5)) * vec2(overscan_x / 100.0, overscan_y / 100.0) + vec2(0.5);\ncoord = min(coord, vec2(1.0)-coord) * aspect;\nvec2 cdist = vec2(cornersize);\ncoord = (cdist - min(coord,cdist));\nfloat dist = sqrt(dot(coord,coord));\nreturn clamp((cdist.x-dist)*cornersmooth,0.0, 1.0);\n}\n\n// Calculate the influence of a scanline on the current pixel.\n//\n// \'distance\' is the distance in texture coordinates from the current\n// pixel to the scanline in question.\n// \'color\' is the colour of the scanline at the horizontal location of\n// the current pixel.\nvec4 scanlineWeights(float distance, vec4 color)\n{\n// "wid" controls the width of the scanline beam, for each RGB\n// channel The "weights" lines basically specify the formula\n// that gives you the profile of the beam, i.e. the intensity as\n// a function of distance from the vertical center of the\n// scanline. In this case, it is gaussian if width=2, and\n// becomes nongaussian for larger widths. Ideally this should\n// be normalized so that the integral across the beam is\n// independent of its width. That is, for a narrower beam\n// "weights" should have a higher peak at the center of the\n// scanline than for a wider beam.\n#ifdef USEGAUSSIAN\nvec4 wid = 0.3 + 0.1 * pow(color, vec4(3.0));\nvec4 weights = vec4(distance / wid);\nreturn 0.4 * exp(-weights * weights) / wid;\n#else\nvec4 wid = 2.0 + 2.0 * pow(color, vec4(4.0));\nvec4 weights = vec4(distance / scanline_weight);\nreturn 1.4 * exp(-pow(weights * inversesqrt(0.5 * wid), wid)) / (0.6 + 0.2 * wid);\n#endif\n}\n\nvoid main()\n{\n// Here\'s a helpful diagram to keep in mind while trying to\n// understand the code:\n//\n// | | | | |\n// -------------------------------\n// | | | | |\n// | 01 | 11 | 21 | 31 | <-- current scanline\n// | | @ | | |\n// -------------------------------\n// | | | | |\n// | 02 | 12 | 22 | 32 | <-- next scanline\n// | | | | |\n// -------------------------------\n// | | | | |\n//\n// Each character-cell represents a pixel on the output\n// surface, "@" represents the current pixel (always somewhere\n// in the bottom half of the current scan-line, or the top-half\n// of the next scanline). The grid of lines represents the\n// edges of the texels of the underlying texture.\n\n// Texture coordinates of the texel containing the active pixel.\nvec2 xy = (CURVATURE > 0.5) ? transform(TEX0.xy) : TEX0.xy;\n\nfloat cval = corner(xy);\n\n// Of all the pixels that are mapped onto the texel we are\n// currently rendering, which pixel are we currently rendering?\nvec2 ilvec = vec2(0.0,ilfac.y > 1.5 ? mod(float(FrameCount),2.0) : 0.0);\nvec2 ratio_scale = (xy * TextureSize - vec2(0.5) + ilvec)/ilfac;\n#ifdef OVERSAMPLE\nfloat filter_ = InputSize.y/OutputSize.y;//fwidth(ratio_scale.y);\n#endif\nvec2 uv_ratio = fract(ratio_scale);\n\n// Snap to the center of the underlying texel.\nxy = (floor(ratio_scale)*ilfac + vec2(0.5) - ilvec) / TextureSize;\n\n// Calculate Lanczos scaling coefficients describing the effect\n// of various neighbour texels in a scanline on the current\n// pixel.\nvec4 coeffs = PI * vec4(1.0 + uv_ratio.x, uv_ratio.x, 1.0 - uv_ratio.x, 2.0 - uv_ratio.x);\n\n// Prevent division by zero.\ncoeffs = FIX(coeffs);\n\n// Lanczos2 kernel.\ncoeffs = 2.0 * sin(coeffs) * sin(coeffs / 2.0) / (coeffs * coeffs);\n\n// Normalize.\ncoeffs /= dot(coeffs, vec4(1.0));\n\n// Calculate the effective colour of the current and next\n// scanlines at the horizontal location of the current pixel,\n// using the Lanczos coefficients above.\nvec4 col = clamp(mat4(\n TEX2D(xy + vec2(-one.x, 0.0)),\n TEX2D(xy),\n TEX2D(xy + vec2(one.x, 0.0)),\n TEX2D(xy + vec2(2.0 * one.x, 0.0))) * coeffs,\n 0.0, 1.0);\nvec4 col2 = clamp(mat4(\n TEX2D(xy + vec2(-one.x, one.y)),\n TEX2D(xy + vec2(0.0, one.y)),\n TEX2D(xy + one),\n TEX2D(xy + vec2(2.0 * one.x, one.y))) * coeffs,\n 0.0, 1.0);\n\n#ifndef LINEAR_PROCESSING\ncol = pow(col , vec4(CRTgamma));\ncol2 = pow(col2, vec4(CRTgamma));\n#endif\n\n// Calculate the influence of the current and next scanlines on\n// the current pixel.\nvec4 weights = scanlineWeights(uv_ratio.y, col);\nvec4 weights2 = scanlineWeights(1.0 - uv_ratio.y, col2);\n#ifdef OVERSAMPLE\nuv_ratio.y =uv_ratio.y+1.0/3.0*filter_;\nweights = (weights+scanlineWeights(uv_ratio.y, col))/3.0;\nweights2=(weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2))/3.0;\nuv_ratio.y =uv_ratio.y-2.0/3.0*filter_;\nweights=weights+scanlineWeights(abs(uv_ratio.y), col)/3.0;\nweights2=weights2+scanlineWeights(abs(1.0-uv_ratio.y), col2)/3.0;\n#endif\n\nvec3 mul_res = (col * weights + col2 * weights2).rgb * vec3(cval);\n\n// dot-mask emulation:\n// Output pixels are alternately tinted green and magenta.\nvec3 dotMaskWeights = mix(\nvec3(1.0, 1.0 - DOTMASK, 1.0),\nvec3(1.0 - DOTMASK, 1.0, 1.0 - DOTMASK),\nfloor(mod(mod_factor, 2.0))\n);\n\nmul_res *= dotMaskWeights;\n\n// Convert the image gamma for display on our output device.\nmul_res = pow(mul_res, vec3(1.0 / monitorgamma));\n\n// Color the texel.\noutput_dummy _OUT;\n_OUT._color = vec4(mul_res, 1.0);\nFragColor = _OUT._color;\nreturn;\n} \n#endif\n\n',"crt-mattias.glsl":'\n#pragma parameter CURVATURE "Curvature" 0.5 0.0 1.0 0.05\n#pragma parameter SCANSPEED "Scanline Crawl Speed" 1.0 0.0 10.0 0.5\n#if defined(VERTEX)\n#if __VERSION__ >= 130\n#define COMPAT_VARYING out\n#define COMPAT_ATTRIBUTE in\n#define COMPAT_TEXTURE texture\n#else\n#define COMPAT_VARYING varying \n#define COMPAT_ATTRIBUTE attribute \n#define COMPAT_TEXTURE texture2D\n#endif\n\n#ifdef GL_ES\n#define COMPAT_PRECISION mediump\n#else\n#define COMPAT_PRECISION\n#endif\n\nCOMPAT_ATTRIBUTE vec4 VertexCoord;\nCOMPAT_ATTRIBUTE vec4 COLOR;\nCOMPAT_ATTRIBUTE vec4 TexCoord;\nCOMPAT_VARYING vec4 COL0;\nCOMPAT_VARYING vec4 TEX0;\n\nvec4 _oPosition1; \nuniform mat4 MVPMatrix;\nuniform COMPAT_PRECISION int FrameDirection;\nuniform COMPAT_PRECISION int FrameCount;\nuniform COMPAT_PRECISION vec2 OutputSize;\nuniform COMPAT_PRECISION vec2 TextureSize;\nuniform COMPAT_PRECISION vec2 InputSize;\n\n#define vTexCoord TEX0.xy\n#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize\n#define OutSize vec4(OutputSize, 1.0 / OutputSize)\n\nvoid main()\n{\n gl_Position = MVPMatrix * VertexCoord;\n TEX0.xy = TexCoord.xy;\n}\n\n#elif defined(FRAGMENT)\n\n#ifdef GL_ES\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n#define COMPAT_PRECISION mediump\n#else\n#define COMPAT_PRECISION\n#endif\n\n#if __VERSION__ >= 130\n#define COMPAT_VARYING in\n#define COMPAT_TEXTURE texture\nout COMPAT_PRECISION vec4 FragColor;\n#else\n#define COMPAT_VARYING varying\n#define FragColor gl_FragColor\n#define COMPAT_TEXTURE texture2D\n#endif\n\nuniform COMPAT_PRECISION int FrameDirection;\nuniform COMPAT_PRECISION int FrameCount;\nuniform COMPAT_PRECISION vec2 OutputSize;\nuniform COMPAT_PRECISION vec2 TextureSize;\nuniform COMPAT_PRECISION vec2 InputSize;\nuniform sampler2D Texture;\nCOMPAT_VARYING vec4 TEX0;\n\n// compatibility #defines\n#define Source Texture\n#define vTexCoord TEX0.xy\n\n#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize\n#define OutSize vec4(OutputSize, 1.0 / OutputSize)\n\n#ifdef PARAMETER_UNIFORM\nuniform COMPAT_PRECISION float CURVATURE, SCANSPEED;\n#else\n#define CURVATURE 0.5\n#define SCANSPEED 1.0\n#endif\n\n#define iChannel0 Texture\n#define iTime (float(FrameCount) / 60.0)\n#define iResolution OutputSize.xy\n#define fragCoord gl_FragCoord.xy\n\nvec3 sample_( sampler2D tex, vec2 tc )\n{\n vec3 s = pow(COMPAT_TEXTURE(tex,tc).rgb, vec3(2.2));\n return s;\n}\n\nvec3 blur(sampler2D tex, vec2 tc, float offs)\n{\n vec4 xoffs = offs * vec4(-2.0, -1.0, 1.0, 2.0) / (iResolution.x * TextureSize.x / InputSize.x);\n vec4 yoffs = offs * vec4(-2.0, -1.0, 1.0, 2.0) / (iResolution.y * TextureSize.y / InputSize.y);\n tc = tc * InputSize / TextureSize;\n \n vec3 color = vec3(0.0, 0.0, 0.0);\n color += sample_(tex,tc + vec2(xoffs.x, yoffs.x)) * 0.00366;\n color += sample_(tex,tc + vec2(xoffs.y, yoffs.x)) * 0.01465;\n color += sample_(tex,tc + vec2( 0.0, yoffs.x)) * 0.02564;\n color += sample_(tex,tc + vec2(xoffs.z, yoffs.x)) * 0.01465;\n color += sample_(tex,tc + vec2(xoffs.w, yoffs.x)) * 0.00366;\n \n color += sample_(tex,tc + vec2(xoffs.x, yoffs.y)) * 0.01465;\n color += sample_(tex,tc + vec2(xoffs.y, yoffs.y)) * 0.05861;\n color += sample_(tex,tc + vec2( 0.0, yoffs.y)) * 0.09524;\n color += sample_(tex,tc + vec2(xoffs.z, yoffs.y)) * 0.05861;\n color += sample_(tex,tc + vec2(xoffs.w, yoffs.y)) * 0.01465;\n \n color += sample_(tex,tc + vec2(xoffs.x, 0.0)) * 0.02564;\n color += sample_(tex,tc + vec2(xoffs.y, 0.0)) * 0.09524;\n color += sample_(tex,tc + vec2( 0.0, 0.0)) * 0.15018;\n color += sample_(tex,tc + vec2(xoffs.z, 0.0)) * 0.09524;\n color += sample_(tex,tc + vec2(xoffs.w, 0.0)) * 0.02564;\n \n color += sample_(tex,tc + vec2(xoffs.x, yoffs.z)) * 0.01465;\n color += sample_(tex,tc + vec2(xoffs.y, yoffs.z)) * 0.05861;\n color += sample_(tex,tc + vec2( 0.0, yoffs.z)) * 0.09524;\n color += sample_(tex,tc + vec2(xoffs.z, yoffs.z)) * 0.05861;\n color += sample_(tex,tc + vec2(xoffs.w, yoffs.z)) * 0.01465;\n \n color += sample_(tex,tc + vec2(xoffs.x, yoffs.w)) * 0.00366;\n color += sample_(tex,tc + vec2(xoffs.y, yoffs.w)) * 0.01465;\n color += sample_(tex,tc + vec2( 0.0, yoffs.w)) * 0.02564;\n color += sample_(tex,tc + vec2(xoffs.z, yoffs.w)) * 0.01465;\n color += sample_(tex,tc + vec2(xoffs.w, yoffs.w)) * 0.00366;\n\n return color;\n}\n\nfloat rand(vec2 co)\n{\n float a = 12.9898;\n float b = 78.233;\n float c = 43758.5453;\n float dt= dot(co.xy ,vec2(a,b));\n float sn= mod(dt,3.14);\n return fract(sin(sn) * c);\n}\n\nvec2 curve(vec2 uv)\n{\n uv = (uv - 0.5) * 2.0;\n uv *= 1.1;\t\n uv.x *= 1.0 + pow((abs(uv.y) / 5.0), 2.0);\n uv.y *= 1.0 + pow((abs(uv.x) / 4.0), 2.0);\n uv = (uv / 2.0) + 0.5;\n uv = uv *0.92 + 0.04;\n return uv;\n}\n\nvoid main()\n{\n vec2 q = (vTexCoord.xy * TextureSize.xy / InputSize.xy);//fragCoord.xy / iResolution.xy;\n vec2 uv = q;\n uv = mix( uv, curve( uv ), CURVATURE ) * InputSize.xy / TextureSize.xy;\n vec3 col;\n float x = sin(0.1*iTime+uv.y*21.0)*sin(0.23*iTime+uv.y*29.0)*sin(0.3+0.11*iTime+uv.y*31.0)*0.0017;\n float o =2.0*mod(fragCoord.y,2.0)/iResolution.x;\n x+=o;\n uv = uv * TextureSize / InputSize;\n col.r = 1.0*blur(iChannel0,vec2(uv.x+0.0009,uv.y+0.0009),1.2).x+0.005;\n col.g = 1.0*blur(iChannel0,vec2(uv.x+0.000,uv.y-0.0015),1.2).y+0.005;\n col.b = 1.0*blur(iChannel0,vec2(uv.x-0.0015,uv.y+0.000),1.2).z+0.005;\n col.r += 0.2*blur(iChannel0,vec2(uv.x+0.0009,uv.y+0.0009),2.25).x-0.005;\n col.g += 0.2*blur(iChannel0,vec2(uv.x+0.000,uv.y-0.0015),1.75).y-0.005;\n col.b += 0.2*blur(iChannel0,vec2(uv.x-0.0015,uv.y+0.000),1.25).z-0.005;\n float ghs = 0.05;\n col.r += ghs*(1.0-0.299)*blur(iChannel0,0.75*vec2(0.01, -0.027)+vec2(uv.x+0.001,uv.y+0.001),7.0).x;\n col.g += ghs*(1.0-0.587)*blur(iChannel0,0.75*vec2(-0.022, -0.02)+vec2(uv.x+0.000,uv.y-0.002),5.0).y;\n col.b += ghs*(1.0-0.114)*blur(iChannel0,0.75*vec2(-0.02, -0.0)+vec2(uv.x-0.002,uv.y+0.000),3.0).z;\n \n \n\n col = clamp(col*0.4+0.6*col*col*1.0,0.0,1.0);\n float vig = (0.0 + 1.0*16.0*uv.x*uv.y*(1.0-uv.x)*(1.0-uv.y));\n vig = pow(vig,0.3);\n col *= vec3(vig);\n\n col *= vec3(0.95,1.05,0.95);\n col = mix( col, col * col, 0.3) * 3.8;\n\n float scans = clamp( 0.35+0.15*sin(3.5*(iTime * SCANSPEED)+uv.y*iResolution.y*1.5), 0.0, 1.0);\n \n float s = pow(scans,0.9);\n col = col*vec3( s) ;\n\n col *= 1.0+0.0015*sin(300.0*iTime);\n \n col*=1.0-0.15*vec3(clamp((mod(fragCoord.x+o, 2.0)-1.0)*2.0,0.0,1.0));\n col *= vec3( 1.0 ) - 0.25*vec3( rand( uv+0.0001*iTime), rand( uv+0.0001*iTime + 0.3 ), rand( uv+0.0001*iTime+ 0.5 ) );\n col = pow(col, vec3(0.45));\n\n if (uv.x < 0.0 || uv.x > 1.0)\n col *= 0.0;\n if (uv.y < 0.0 || uv.y > 1.0)\n col *= 0.0;\n \n\n float comp = smoothstep( 0.1, 0.9, sin(iTime) );\n\n FragColor = vec4(col,1.0);\n} \n#endif\n'},Te=r(57),J=r(11),K={addStyleHook:function(){G(this.elements.container,this.config.selectors.container.replace(".",""),!0),G(this.elements.container,this.config.classNames.uiSupported,!0),G(this.elements.container,this.config.classNames.hideControls,!0)},build:function(){this.listeners.media(),U.element(this.elements.controls)||(oe.inject.call(this),this.listeners.controls()),this.volume=null,this.muted=null,oe.updateVolume.call(this),G(this.elements.container,this.config.classNames.isTouch,this.touch),this.ready=!0},toggleControls:function(t){var o=this.elements.controls;if(o){let n=0,e=l.call(this,".".concat(H({ejs__dialogs:!0})," > .").concat(H({ejs__dialog:!0})));Array.from(e).forEach(function(e,t){!0!==e.hidden&&(n+=1)}),0<n?this.toggleControls(!1):this.toggleControls(Boolean(t||this.paused||o.pressed||o.hover))}}};function xe(e){return(xe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){if("object"===xe(e)&&e.files&&(e=e.files[0]),this.littleEndian=!1,this.offset=0,this._lastRead=null,"object"===xe(e)&&e.name&&e.size){if("function"!=typeof window.FileReader)throw new Error("Incompatible Browser");this.fileName=e.name,this.fileType=e.type,this.fileSize=e.size,this._fileReader=new FileReader,(this._fileReader.marcFile=this)._fileReader.addEventListener("load",function(){this.marcFile._u8array=new Uint8Array(this.result),this.marcFile._dataView=new DataView(this.result),t&&t.call()},!1),this._fileReader.readAsArrayBuffer(e)}else if("object"===xe(e)&&"string"==typeof e.fileName&&"boolean"==typeof e.littleEndian){this.fileName=e.fileName,this.fileType=e.fileType,this.fileSize=e.fileSize;new ArrayBuffer(e);this._u8array=new Uint8Array(this.fileType),this._dataView=new DataView(this.fileType),e.copyToFile(this,0),t&&t.call()}else if("object"===xe(e)&&"number"==typeof e.byteLength)this.fileName="file.bin",this.fileType="application/octet-stream",this.fileSize=e.byteLength,void 0!==e.buffer&&(e=e.buffer),this._u8array=new Uint8Array(e),this._dataView=new DataView(e),t&&t.call();else{if("number"!=typeof e)throw new Error("Invalid source");this.fileName="file.bin",this.fileType="application/octet-stream",this.fileSize=e,r=new ArrayBuffer(e),this._u8array=new Uint8Array(r),this._dataView=new DataView(r),t&&t.call()}}o.IS_MACHINE_LITTLE_ENDIAN=(ye=new ArrayBuffer(2),new DataView(ye).setInt16(0,256,!0),256===new Int16Array(ye)[0]),o.prototype.seek=function(e){this.offset=e},o.prototype.skip=function(e){this.offset+=e},o.prototype.isEOF=function(){return!(this.offset<this.fileSize)},o.prototype.slice=function(e,t){let n;return t=t||this.fileSize-e,void 0!==this._u8array.buffer.slice?((n=new o(0)).fileSize=t,n._u8array=new Uint8Array(this._u8array.buffer.slice(e,e+t))):(n=new o(t),this.copyToFile(n,e,t,0)),n.fileName=this.fileName,n.fileType=this.fileType,n.littleEndian=this.littleEndian,n},o.prototype.copyToFile=function(t,n,o,i){void 0===i&&(i=n),o=o||this.fileSize-n;for(let e=0;e<o;e++)t._u8array[i+e]=this._u8array[n+e]},o.prototype.save=function(){let n;try{n=new Blob([this._u8array],{type:this.fileType})}catch(e){if(window.BlobBuilder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder,"InvalidStateError"!==e.name||!window.BlobBuilder)throw new Error("Incompatible Browser");let t=new BlobBuilder;t.append(this._u8array.buffer),n=t.getBlob(this.fileType)}saveAs(n,this.fileName)},o.prototype.readU8=function(){return this._lastRead=this._u8array[this.offset],this.offset++,this._lastRead},o.prototype.readU16=function(){return this.littleEndian?this._lastRead=this._u8array[this.offset]+(this._u8array[this.offset+1]<<8):this._lastRead=(this._u8array[this.offset]<<8)+this._u8array[this.offset+1],this.offset+=2,this._lastRead>>>0},o.prototype.readU24=function(){return this.littleEndian?this._lastRead=this._u8array[this.offset]+(this._u8array[this.offset+1]<<8)+(this._u8array[this.offset+2]<<16):this._lastRead=(this._u8array[this.offset]<<16)+(this._u8array[this.offset+1]<<8)+this._u8array[this.offset+2],this.offset+=3,this._lastRead>>>0},o.prototype.readU32=function(){return this.littleEndian?this._lastRead=this._u8array[this.offset]+(this._u8array[this.offset+1]<<8)+(this._u8array[this.offset+2]<<16)+(this._u8array[this.offset+3]<<24):this._lastRead=(this._u8array[this.offset]<<24)+(this._u8array[this.offset+1]<<16)+(this._u8array[this.offset+2]<<8)+this._u8array[this.offset+3],this.offset+=4,this._lastRead>>>0},o.prototype.readBytes=function(t){this._lastRead=new Array(t);for(let e=0;e<t;e++)this._lastRead[e]=this._u8array[this.offset+e];return this.offset+=t,this._lastRead},o.prototype.readString=function(t){this._lastRead="";for(let e=0;e<t&&this.offset+e<this.fileSize&&0<this._u8array[this.offset+e];e++)this._lastRead=this._lastRead+String.fromCharCode(this._u8array[this.offset+e]);return this.offset+=t,this._lastRead},o.prototype.writeU8=function(e){this._u8array[this.offset]=e,this.offset++},o.prototype.writeU16=function(e){this.littleEndian?(this._u8array[this.offset]=255&e,this._u8array[this.offset+1]=e>>8):(this._u8array[this.offset]=e>>8,this._u8array[this.offset+1]=255&e),this.offset+=2},o.prototype.writeU24=function(e){this.littleEndian?(this._u8array[this.offset]=255&e,this._u8array[this.offset+1]=(65280&e)>>8,this._u8array[this.offset+2]=(16711680&e)>>16):(this._u8array[this.offset]=(16711680&e)>>16,this._u8array[this.offset+1]=(65280&e)>>8,this._u8array[this.offset+2]=255&e),this.offset+=3},o.prototype.writeU32=function(e){this.littleEndian?(this._u8array[this.offset]=255&e,this._u8array[this.offset+1]=(65280&e)>>8,this._u8array[this.offset+2]=(16711680&e)>>16,this._u8array[this.offset+3]=(4278190080&e)>>24):(this._u8array[this.offset]=(4278190080&e)>>24,this._u8array[this.offset+1]=(16711680&e)>>16,this._u8array[this.offset+2]=(65280&e)>>8,this._u8array[this.offset+3]=255&e),this.offset+=4},o.prototype.writeBytes=function(t){for(let e=0;e<t.length;e++)this._u8array[this.offset+e]=t[e];this.offset+=t.length},o.prototype.writeString=function(t,n){n=n||t.length;for(let e=0;e<t.length&&e<n;e++)this._u8array[this.offset+e]=t.charCodeAt(e);for(;r<n;r++)this._u8array[this.offset+r]=0;this.offset+=n};let Q=o,a=0;function s(){this.records=[],this.truncate=!1}function Ce(e){let t=new s;e.seek(5);for(var n,o;!e.isEOF();){if(4542278===(n=e.readU24())){if(e.isEOF())break;if(e.offset+3===e.fileSize){t.truncate=e.readU24();break}}(o=e.readU16())===a?t.addRLERecord(n,e.readU16(),e.readU8()):t.addSimpleRecord(n,e.readBytes(o))}return t}s.prototype.addSimpleRecord=function(e,t){this.records.push({offset:e,type:1,length:t.length,data:t})},s.prototype.addRLERecord=function(e,t,n){this.records.push({offset:e,type:a,length:t,byte:n})},s.prototype.toString=function(){nSimpleRecords=0;for(let e=nRLERecords=0;e<this.records.length;e++)this.records[e].type===a?nRLERecords++:nSimpleRecords++;let e="Simple records: "+nSimpleRecords;return e=(e+="\nRLE records: "+nRLERecords)+("\nTotal records: "+this.records.length),this.truncate&&(e+="\nTruncate at: 0x"+this.truncate.toString(16)),e},s.prototype.export=function(e){for(let e=5,t=0;t<this.records.length;t++)this.records[t].type===a?e+=8:e+=5+this.records[t].data.length;for(i+=3,this.truncate&&(i+=3),(tempFile=new Q(i)).fileName=e+".ips",tempFile.writeString("PATCH"),r=0;r<this.records.length;r++){var t=this.records[r];tempFile.writeU24(t.offset),t.type===a?(tempFile.writeU16(0),tempFile.writeU16(t.length),tempFile.writeU8(t.byte)):(tempFile.writeU16(t.data.length),tempFile.writeBytes(t.data))}return tempFile.writeString("EOF"),_0x512785.truncate&&tempFile.writeU24(_0x512785.truncate),tempFile},s.prototype.apply=function(n){let t;if(this.truncate)t=n.slice(0,this.truncate);else{for(let e=n.fileSize,t=0;t<this.records.length;t++){var o=this.records[t];o.type===a?o.offset+o.length>e&&(e=o.offset+o.length):o.offset+o.data.length>e&&(e=o.offset+o.data.length)}r===n.fileSize?t=n.slice(0,n.fileSize):(t=new Q(r),n.copyToFile(t,0))}for(n.seek(0),_0x5a0a71=0;_0x5a0a71<this.records.length;_0x5a0a71++)if(t.seek(this.records[_0x5a0a71].offset),this.records[_0x5a0a71].type===a)for(let e=0;e<this.records[_0x5a0a71].length;e++)t.writeU8(this.records[_0x5a0a71].byte);else t.writeBytes(this.records[_0x5a0a71].data);return t},"0123456789abcdef".split("");let Ee=function(){for(let t,e=[],n=0;n<256;n++){t=n;for(let e=0;e<8;e++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return i}();function $(i,a,r){for(let e=a?new Uint8Array(i._u8array.buffer,a):i._u8array,t=-1,n=r?e.length-4:e.length,o=0;o<n;o++)t=t>>>8^Ee[255&(t^e[o])];return(-1^_0x20e2c1)>>>0}let Me=1,Re=2,Ae=3;function Oe(){this.sourceSize=0,this.targetSize=0,this.metaData="",this.actions=[],this.sourceChecksum=0,this.targetChecksum=0,this.patchChecksum=0}function ke(n){n.readVLV=Pe,n.littleEndian=!0;let o=new Oe;n.seek(4),o.sourceSize=n.readVLV(),o.targetSize=n.readVLV();var e=n.readVLV();e&&(o.metaData=n.readString(e));for(var i,t=n.fileSize-12;n.offset<t;){let e=n.readVLV(),t={type:3&e,length:1+(e>>2)};t.type===Me?t.bytes=n.readBytes(t.length):t.type!==Re&&t.type!==Ae||(i=n.readVLV(),t.relativeOffset=(1&i?-1:1)*(i>>1)),o.actions.push(t)}if(o.sourceChecksum=n.readU32(),o.targetChecksum=n.readU32(),o.patchChecksum=n.readU32(),o.patchChecksum!==$(n,0,!0))throw new Error("error_crc_patch");return o}function Pe(){for(let e=0,t=1;;){var n=this.readU8();if(e+=(127&n)*t,128&n)break;e+=t<<=7}return this._lastRead=p}function Ie(e){for(;;){var t=127&e;if(0==(e>>=7)){this.writeU8(128|t);break}this.writeU8(t),e--}}function Ne(t){for(let e=0;;){if(0==(t>>=7)){e++;break}e++,t--}return i}Oe.prototype.toString=function(){var e="Source size: "+this.sourceSize;return(e=(e+="\nTarget size: "+this.targetSize)+("\nMetadata: "+this.metaData))+("\n#Actions: "+this.actions.length)},Oe.prototype.validateSource=function(e,t){return this.sourceChecksum===$(e,t)},Oe.prototype.apply=function(i,e){if(e&&!this.validateSource(i))throw new Error("error_crc_input");for(let t=new Q(this.targetSize),n=0,e=0,o=0;o<this.actions.length;o++){var a=this.actions[o];if(0===a.type)i.copyToFile(t,t.offset,a.length),t.skip(a.length);else if(a.type===Me)t.writeBytes(a.bytes);else if(a.type===Re){n+=a.relativeOffset;for(let e=a.length;e--;)t.writeU8(i._u8array[n]),n++}else if(a.type===Ae)for(e+=a.relativeOffset,_0x5c2263=a.length;_0x5c2263--;)t.writeU8(t._u8array[e]),e++}if(e&&this.targetChecksum!==$(r))throw new Error("error_crc_output");return r},Oe.prototype.export=function(e){let t="BPS1".length;t=(t=(t=(t+=Ne(this.sourceSize))+Ne(this.targetSize))+Ne(this.metaData.length))+this.metaData.length;for(let e=0;e<this.actions.length;e++)t+=Ne(((_0x38dad6=this.actions[e]).length-1<<2)+_0x38dad6.type),_0x38dad6.type===Me?t+=_0x38dad6.length:_0x38dad6.type!==Re&&_0x38dad6.type!==Ae||(t+=Ne((Math.abs(_0x38dad6.relativeOffset)<<1)+(_0x38dad6.relativeOffset<0?1:0)));let n=new Q(t+=12);for(n.fileName=e+".bps",n.littleEndian=!0,n.writeVLV=Ie,n.writeString("BPS1"),n.writeVLV(this.sourceSize),n.writeVLV(this.targetSize),n.writeVLV(this.metaData.length),n.writeString(this.metaData,this.metaData.length),r=0;r<this.actions.length;r++){var o=this.actions[r];n.writeVLV((o.length-1<<2)+o.type),o.type===Me?n.writeBytes(o.bytes):o.type!==Re&&o.type!==Ae||n.writeVLV((Math.abs(o.relativeOffset)<<1)+(o.relativeOffset<0?1:0))}return n.writeU32(this.sourceChecksum),n.writeU32(this.targetChecksum),n.writeU32(this.patchChecksum),n};let Le="UPS1";function d(){this.records=[],this.sizeInput=0,this.sizeOutput=0,this.checksumInput=0,this.checksumOutput=0}function ze(e){for(;;){var t=127&e;if(0==(e>>=7)){this.writeU8(128|t);break}this.writeU8(t),--e}}function De(){for(let e=0,t=1;;){var n=this.readU8();if(-1==n)throw new Error("Can't read UPS VLV at 0x"+(this.offset-1).toString(16));if(e+=(127&n)*t,0!=(128&n))break;e+=t<<=7}return p}function Ue(t){for(let e=0;e++,0!=(t>>=7);)--t;return i}function je(t){let e=new d;for(t.readVLV=De,t.seek(Le.length),e.sizeInput=t.readVLV(),e.sizeOutput=t.readVLV();t.offset<t.fileSize-12;){t.readVLV();for(let e=[];t.readU8();)e.push(t._lastRead);e.addRecord(r,_0x3bca86)}return t.littleEndian=!0,e.checksumInput=t.readU32(),e.checksumOutput=t.readU32(),t.littleEndian=!1,e}d.prototype.addRecord=function(e,t){this.records.push({offset:e,XORdata:t})},d.prototype.toString=function(){var e="Records: "+(void 0).records.length;return(e=(e=(e+="\nInput file size: "+(void 0).sizeInput)+("\nOutput file size: "+(void 0).sizeOutput))+("\nInput file checksum: "+padZeroes((void 0).checksumInput,4)))+("\nOutput file checksum: "+padZeroes((void 0).checksumOutput,4))},d.prototype.export=function(e){let t=Le.length;t=(t+=Ue(this.sizeInput))+Ue(this.sizeOutput);for(let e=0;e<this.records.length;e++)t=(t+=Ue(this.records[e].offset))+(this.records[e].XORdata.length+1);for(t+=12,(tempFile=new Q(t)).writeVLV=ze,tempFile.fileName=e+".ups",tempFile.writeString(Le),tempFile.writeVLV(this.sizeInput),tempFile.writeVLV(this.sizeOutput),r=0;r<this.records.length;r++)tempFile.writeVLV(this.records[r].offset),tempFile.writeBytes(this.records[r].XORdata),tempFile.writeU8(0);return tempFile.littleEndian=!0,tempFile.writeU32(this.checksumInput),tempFile.writeU32(this.checksumOutput),tempFile.writeU32($(tempFile,0,!0)),tempFile},d.prototype.validateSource=function(e,t){return $(e,t)===this.checksumInput};var e,u,Z={_FS:{createFolder:function(e,t,n,o){var i;Z.FS&&("function"==typeof Z.FS.mkdir&&window.PATH?(i=PATH.join2("string"==typeof e?e:Z.FS.getPath(e),t),Z.FS.mkdir(i)):Z.FS.createFolder(e,t,n,o))}},romdb:null,supportBatterySave:!(d.prototype.apply=function(t,e){e&&this.validateSource(t),tempFile=new Q(this.sizeOutput),t.copyToFile(tempFile,0,this.sizeInput),t.seek(0);for(let e=0;e<this.records.length;e++){var n=this.records[e];tempFile.skip(n.offset),t.skip(n.offset);for(let e=0;e<n.XORdata.length;e++)tempFile.writeU8((t.isEOF()?0:t.readU8())^n.XORdata[e]);tempFile.skip(1),t.skip(1)}return e&&($(tempFile),this.checksumOutput),tempFile}),hash:"2b35cacf70ae",hash2:"f5cbb3f38c0bb20e4",hash3:"88cc8ad0c350400499a0",loading:null,gamePatch:null,saveFilenames:[],FS:null,Module:null,aspectRatio:4/3,memData:null,wasmData:null,coreFileData:{},coreFileName:"",coreFileVersion:"",isMobileDevice:!!/Android|webOS|iPhone|iPad|iPod|BB10|BlackBerry|IEMobile|Opera Mini|Mobile|mobile/i.test(navigator.userAgent||""),create:function(){let f=this;window.URL=window.URL||window.webkitURL;let p,h,m,n=!1,o=!1,a=!1,g=0,v=!1,y={oldCores:{psx:["bin","iso","cue","img","mdf","pbp","toc","cbn","m3u"],nds:["nds","bin"],nes:["fds","nes","unif","unf"],snes:["smc","fig","sfc","gd3","gd7","dx2","bsx","swc"],snes2002:["smc","fig","sfc","gd3","gd7","dx2","bsx","swc"],snes2005:["smc","fig","sfc","gd3","gd7","dx2","bsx","swc"],snes2010:["smc","fig","sfc","gd3","gd7","dx2","bsx","swc"],gb:["gb","gbc","dmg"],gba:["gb","gbc","gba"],vbanext:["gba"],vb:["vb","vboy","bin"],"3do":["iso","bin","cue"],lynx:["lnx"],jaguar:["j64","jag","rom","abs","cof","bin","prg"],a7800:["a78","bin"],a2600:["a26","bin"],ngp:["ngp","ngc"],n64:["n64","v64","z64","bin","u1","ndd"],pce:["pce","bin","iso","cue","ccd","img","chd"],sega:["mdx","md","smd","gen","bin","iso","cue","sms","gg","sg","68k","chd"],segacd:["mdx","md","smd","gen","bin","iso","cue","sms","gg","sg","68k","chd"],"32x":["32x","bin","gen","smd","md","cue","iso","sms"],saturn:["bin","cue","iso"],msx:["rom","mx1","mx2","dsk","cas"],bluemsx:["rom","ri","mx1","mx2","col","dsk","cas","sg","sc","m3u"],ws:["ws","wsc"],arcade:["zip"],"fba0.2.97.29":["zip"],mame2003:["zip"],mame:["zip"]},newCores:{fceumm:["fds","nes","unif","unf"],snes9x:["smc","sfc","swc","fig","bs","st"],a5200:["a52","bin"],gambatte:["gb","gbc","dmg"],mgba:["gb","gbc","gba"],beetle_vb:["vb","vboy","bin"],mupen64plus_next:["n64","v64","z64","bin","u1","ndd","gb"],fbalpha2012_cps1:["zip"],fbalpha2012_cps2:["zip"],mame2003:["zip"],desmume2015:["nds","bin"],melonds:["nds"],mednafen_psx:["cue","toc","m3u","ccd","exe","pbp","chd"],mednafen_psx_hw:["cue","toc","m3u","ccd","exe","pbp","chd"],nestopia:["fds","nes","unif","unf"],opera:["iso","bin","chd","cue"]}},b={oldCores:{psx:"psx",nds:"nds",nes:"nes",snes:"snes",snes2002:"snes2002",snes2005:"snes2005",snes2010:"snes2010",gb:"gb",gbc:"gb",gba:"gba",vbanext:"vbanext",vb:"vb",n64:"n64","3do":"3do",segaMS:"sega",segaGG:"sega",segaMD:"sega",segaCD:"segacd",sega32x:"32x",segaSaturn:"saturn",ngp:"ngp",pce:"pce",msx:"bluemsx",atari2600:"a2600",atari7800:"a7800",atari5200:"a5200",lynx:"lynx",ws:"ws",arcade:"arcade","fba0.2.97.29":"fba0.2.97.29",jaguar:"jaguar",mame2003:"mame2003"},newCores:{nes:"fceumm",snes:"snes9x",atari5200:"a5200",gb:"gambatte",gba:"mgba",vb:"beetle_vb",n64:"mupen64plus_next",nds:"desmume2015",mame2003:"mame2003",arcade:"fbalpha2012_cps1",psx:"mednafen_psx_hw","3do":"opera"}},i={fceumm:"nes",snes9x:"snes",a5200:"atari5200",gambatte:"gb",mgba:"gba",beetle_vb:"vb",mupen64plus_next:"n64",desmume2015:"nds",mame2003:"mame2003",fbalpha2012_cps1:"arcade",fbalpha2012_cps2:"arcade",mednafen_psx:"psx",mednafen_psx_hw:"psx",melonds:"nds",nestopia:"nes",opera:"3do"},_=function(e,t){return!0===t?i[e]||e:1===t?b.oldCores[e]:b.newCores[e]||e},w=this,S=w.system,r=(window.getSystem=_,window._0x29078e=b,window._0x1e0766=y,p=w.customPaths&&"string"==typeof w.customPaths["extract7z.js"]?w.customPaths["extract7z.js"]:w.dataPath+"extract7z.js",h=w.customPaths&&"string"==typeof w.customPaths["extractzip.js"]?w.customPaths["extractzip.js"]:w.dataPath+"extractzip.js?v=1",m=w.customPaths&&"string"==typeof w.customPaths["libunrar.js"]?w.customPaths["libunrar.js"]:w.dataPath+"libunrar.js",F("canvas",{})),T=(this.game.appendChild(r),Z.loading=F("div",{class:this.config.classNames.loading}),this.elements.container.appendChild(Z.loading),{"loading-info":H({"loading-info":!0}),ad:H({ad:!0}),"close-ad":H({"close-ad":!0}),"start-game":H({"start-game":!0}),on:H({on:!0}),p1:H({p1:!0}),p2:H({p2:!0}),p3:H({p3:!0}),p4:H({p4:!0})});var e;"string"==typeof w.adUrl?(Z.loading.innerHTML='\n <div>\n <div class="'+T.ad+'" style="display:block !important;width:300px !important">\n <div class="'+T["close-ad"]+'" hidden><a href="#" onclick="return false"></a></div>\n <iframe scrolling="no" frameborder="no" style="width:300px !important;height:250px !important;display: block !important;" src="'+w.adUrl+'"></iframe>\n </div>\n <div class="'+T["loading-info"]+'" style="position: absolute;bottom: 20px;left: 50%;transform: translateX(-50%);">\n <div class="'+T.p1+'"></div>\n <div class="'+T.p2+'"></div>\n <div class="'+T.p3+'"></div>\n </div>\n <div style="position: absolute;bottom: 20px;left: 50%;transform: translateX(-50%);">\n <a href="#" onclick="return false" class="'+T["start-game"]+'">'+he.get("playNow",w.config)+"</a>\n </div>\n </div>",e=F("iframe",{src:w.adUrl,scrolling:"no",frameborder:"no",style:"width:300px !important;height:250px !important;display: block !important;"}),Z.loading.querySelector(".".concat(T.ad)).removeChild(Z.loading.querySelector(".".concat(T.ad," iframe"))),Z.loading.querySelector(".".concat(T.ad)).appendChild(e),Y.webgl.DETECTED||(V(Z.loading.querySelector(".".concat(T["start-game"])),!0),Z.loading.querySelector(".".concat(T.p3)).innerHTML='<strong style="color:#f00;text-shadow: 0px 0px 3px;">Failed to initialize WebGL.</strong>'),Z.loading.querySelector(".".concat(T.ad," iframe")).style.setProperty("display","block","important"),Z.loading.querySelector(".".concat(T.ad," iframe")).style.setProperty("visibility","visible","important"),Z.loading.querySelector(".".concat(T.ad)).style.setProperty("display","block","important"),Z.loading.querySelector(".".concat(T.ad)).style.setProperty("visibility","visible","important")):(Z.loading.innerHTML='\n <div>\n <div class="'.concat(T["loading-info"],'" style="position: absolute;bottom: 20px;left: 50%;transform: translateX(-50%);">\n <div class="').concat(T.p1,'"></div>\n <div class="').concat(T.p2,'"></div>\n <div class="').concat(T.p3,'"></div>\n </div>\n <div style="position: absolute;bottom: 20px;left: 50%;transform: translateX(-50%);">\n <a href="#" onclick="return false" class="').concat(T["start-game"],'">').concat(he.get("playNow",w.config),"</a>\n </div>\n </div>"),Y.webgl.DETECTED||(V(Z.loading.querySelector(".".concat(T["start-game"])),!0),Z.loading.querySelector(".".concat(T.p3)).innerHTML='<strong style="color:#f00;text-shadow: 0px 0px 3px;">Failed to initialize WebGL.</strong>'));let s=window.URL||window.webkitURL,x=function(e){return 80===e[0]&&75===e[1]&&(3===e[2]&&4===e[3]||5===e[2]&&6===e[3]||7===e[2]&&8===e[3])?"zip":55===e[0]&&122===e[1]&&188===e[2]&&175===e[3]&&39===e[4]&&28===e[5]?"7z":82===e[0]&&97===e[1]&&114===e[2]&&33===e[3]&&26===e[4]&&7===e[5]&&(0===e[6]||1===e[6]&&0==e[7])?"rar":void 0},C=async function(e){e=await(await fetch(e)).text(),e=new Blob([e],{type:"application/javascript"}),e=window.URL.createObjectURL(e);return new Worker(e)},E=async function(e){var t=await(await fetch(e)).text(),e=new Blob(["\nlet dataToPass = [];\nModule = {\n monitorRunDependencies: function(left) {\n if (left == 0) {\n setTimeout(function() {\n unrar(dataToPass, null);\n }, 100);\n }\n },\n onRuntimeInitialized: function() {\n },\n locateFile: function(file) {\n return '"+e+".mem';\n }\n};\n"+t+'\nlet unrar = function(data, password) {\n let cb = function(fileName, fileSize, progress) {\n postMessage({"t":4,"current":progress,"total":fileSize, "name": fileName});\n };\n\n let rarContent = readRARContent(data.map(function(d) {\n return {\n name: d.name,\n content: new Uint8Array(d.content)\n }\n }), password, cb)\n let rec = function(entry) {\n if (entry.type === \'file\') {\n postMessage({"t":2,"file":entry.fullFileName,"size":entry.fileSize,"data":entry.fileContent});\n } else if (entry.type === \'dir\') {\n Object.keys(entry.ls).forEach(function(k) {\n rec(entry.ls[k]);\n })\n } else {\n throw "Unknown type";\n }\n }\n rec(rarContent);\n postMessage({"t":1});\n return rarContent;\n};\nonmessage = function(data) {\n dataToPass.push({name: \'test.rar\', content: data.data});\n};\n '],{type:"application/javascript"}),t=window.URL.createObjectURL(e);return new Worker(t)},M=null,d=null,c=null;try{M=new Te({dbVersion:1,storePrefix:"ejs-",storeName:"system",keyPath:null,autoIncrement:!1,onStoreReady:function(){n=!0},onError:function(){n=!0}}),d=new Te({dbVersion:1,storePrefix:"ejs-",storeName:"roms",keyPath:null,autoIncrement:!1,onStoreReady:function(){o=!0},onError:function(){o=!0}}),c=new Te({dbVersion:1,storePrefix:"ejs-",storeName:"bios",keyPath:null,autoIncrement:!1,onStoreReady:function(){a=!0},onError:function(){a=!0}})}catch(e){n=!0,o=!0,a=!0,console.log(e)}j.call(w,w.elements.container,"start-game",function(e){w.started=!0,w.playing=!0,V(Z.loading.querySelector(".".concat(T["loading-info"])),!0),!te||"undefined"!=te.virtualGamepadContainer&&null!==te.virtualGamepadContainer||K.toggleControls.call(w,!0);let t=H({"ejs__tooltip--visible":!0}),n=w.elements.buttons.gamepad.querySelector(".".concat(H({ejs__tooltip:!0}))),o=(G(n,t,!0),setTimeout(function(){G(n,t,!1)},5e3),"string"==typeof w.adUrl&&(V(Z.loading.querySelector(".".concat(T["close-ad"])),!1),!0!==w.config.noAutoAdClose&&setTimeout(function(){w.started&&Z.loading.querySelector(".".concat(T.ad))&&Z.loading.querySelector(".".concat(T.ad)).parentNode.removeChild(Z.loading.querySelector(".".concat(T.ad)))},1e4)),V(Z.loading.querySelector(".".concat(T["start-game"])),!0),X(oe.defaultCoreOptionsValues.call(f),oe.storage.get("core-options")||{}));"n64"===_(w.system,!0)&&o&&Object.keys(o).forEach(function(e){"glupen64-aspect"===e&&"16:9"===o[e]&&(r.height=r.width/16*9,Z.aspectRatio=16/9)}),"arcade"!==_(f.system,!0)&&"fba0.2.97.29"!==_(f.system,!0)||o&&Object.keys(o).forEach(function(e){"fba-aspect"===e&&"PAR"===o[e]&&(r.height=r.width/16*9,Z.aspectRatio=16/9)}),"gba"===_(w.system,!0)&&(r.height=r.width/1.5,Z.aspectRatio=1.5);{let e=f;"undefined"!=typeof RI?(document.removeEventListener("mousemove",RI.eventHandler,!1),r.removeEventListener("mousedown",RI.canvasEventHandler,!1),r.removeEventListener("mouseup",RI.canvasEventHandler,!1),e.elements.container.addEventListener("mousemove",function(e){let t=0,n=0,o=e.offsetX-Z.Module.canvas.offsetLeft,i=e.offsetY-Z.Module.canvas.offsetTop;if("mousemove"===e.type){t=o<0?(o=0,-Z.Module.canvas.offsetWidth):o>Z.Module.canvas.offsetWidth?(o=Z.Module.canvas.offsetWidth,Z.Module.canvas.offsetWidth):o-RI.currentX,n=i<0?(i=0,-Z.Module.canvas.offsetHeight):i>Z.Module.canvas.offsetHeight?(i=Z.Module.canvas.offsetHeight,Z.Module.canvas.offsetHeight):i-RI.currentY,RI.currentX=o,RI.currentY=i;for(let e=0;e<RI.contexts.length;e+=1)HEAP32[RI.contexts[e].state+32>>2]=t,HEAP32[RI.contexts[e].state+36>>2]=n}},!1),e.elements.container.addEventListener("mousedown",RI.canvasEventHandler,!1),e.elements.container.addEventListener("mouseup",RI.canvasEventHandler,!1),i=function(s){if(s.targetTouches[0]){let t,n,o=0,i=0,e=s.target.getBoundingClientRect(),a=s.targetTouches[0].clientX-e.left,r=s.targetTouches[0].clientY-e.top;o=a<0?(a=0,-Z.Module.canvas.offsetWidth):a>Z.Module.canvas.offsetWidth?(a=Z.Module.canvas.offsetWidth,Z.Module.canvas.offsetWidth):a-RI.currentX,i=r<0?(r=0,-Z.Module.canvas.offsetHeight):r>Z.Module.canvas.offsetHeight?(r=Z.Module.canvas.offsetHeight,Z.Module.canvas.offsetHeight):r-RI.currentY,RI.currentX=a,RI.currentY=r;for(let e=0;e<RI.contexts.length;e+=1)HEAP32[RI.contexts[e].state+32>>2]=o,HEAP32[RI.contexts[e].state+36>>2]=i;switch(s.type){case"touchend":case"touchstart":if(0===s.button)n=40;else{if(2!==s.button)break;n=41}t="touchend"===s.type?0:1;for(let e=0;e<RI.contexts.length;e+=1)HEAP8[RI.contexts[e].state+n>>0]=t}}},e.elements.container.addEventListener("touchstart",i,!1),e.elements.container.addEventListener("touchend",i,!1)):(i=function(e){e=new MouseEvent(e.type,e);Z.Module.canvas.dispatchEvent(e)},q.call(f,".".concat(H({ejs__dialogs:!0}))).addEventListener("mousemove",i,!1),q.call(f,".".concat(H({ejs__dialogs:!0}))).addEventListener("mousedown",i,!1),q.call(f,".".concat(H({ejs__dialogs:!0}))).addEventListener("mouseup",i,!1))}var i;"msx"===_(w.system,!0)&&"undefined"!=typeof RI&&(document.removeEventListener("keydown",RI.eventHandler,!1),document.removeEventListener("keyup",RI.eventHandler,!1),i=function(n){var e=n.keyCode,o=e>>3,i=1<<(7&e);switch(n.type){case"keyup":case"keydown":if(32<=o)throw"key code error! bad code: "+e;for(let t=0;t<RI.contexts.length;t++){let e=HEAP8[RI.contexts[t].state+o>>0];"keyup"===n.type?e&=~i:e|=i,HEAP8[RI.contexts[t].state+o>>0]=e}}},document.addEventListener("keydown",i,!1),document.addEventListener("keyup",i,!1)),setTimeout(function(){let i;i=W.info(),null===te.setVolume&&"undefined"!=typeof RA?(RA.queueAudio=function(){let e,t=w.volume,n=RA.bufIndex,o=(e=RA.bufIndex?RA.buffers[RA.bufIndex-1].endTime:RA.context.currentTime,RA.buffers[n].endTime=e+RA.buffers[n].duration,RA.context.createBufferSource());if(o.buffer=RA.buffers[n],1===(t=w.muted?0:t))o.connect(RA.context.destination);else{let e=RA.context.createGain();o.connect(e),e.connect(RA.context.destination),W.isEdge||"chrome"===i.name&&parseInt(i.version,10)<=60||"firefox"===i.name&&parseInt(i.version,10)<=56||"opera"===i.name&&parseInt(i.version,10)<=44?e.gain.value=t:"firefox"===i.name?e.gain.setValueAtTime(t,RA.context.currentTime):e.gain.setValueAtTime(t,RA.context.currentTime,0)}o.start(e),RA.bufIndex+=1,RA.bufOffset=0},W.isIos&&window.addEventListener("touchstart",function(){if(RA.context){RA.context.resume();let e=RA.context.createBufferSource();e.connect(RA.context.destination),e.start()}},!1)):te.setVolume()},500),setTimeout(function(){w.elements.container.focus()},30),void 0===window.addRunDependency&&(window.Module=void 0)}),"string"==typeof w.adUrl&&j.call(w,Z.loading.querySelector(".".concat(T["close-ad"])),"click",function(e){e instanceof MouseEvent&&w.started&&Z.loading.querySelector(".".concat(T.ad))&&Z.loading.querySelector(".".concat(T.ad)).parentNode.removeChild(Z.loading.querySelector(".".concat(T.ad))),w.elements.container.focus()});let R=function(i){if(Z.gamePatch){let c=Z.getStartName(!0),e=c.split("/"),t=e.pop().split(".").pop(),n=(Z.gamePatch.split(".").pop(),Z.gamePatch.split("/").pop().split(".").shift()),o="".concat(e.join("/"),"/").concat(n,".").concat(t);o=o.replace(/\#/g,""),Z.gamePatch.startsWith("blob:")&&(o=c);var l,d=Z.gamePatch;if(Z.FS.rename(c,o),i.startName=o,c=Z.getStartName(!0),"snes"===_(i.system,!0)||["snes2002","snes2005","snes2010"].includes(_(i.system,!0))){let e,t,n,o=new Q(Z.FS.readFile(c)),i=$(o),a=new Q(Z.FS.readFile(d)),r=a.readString(6),s=o._u8array.length%1024;r.startsWith("PATCH")?(e=Ce(a),0==s&&"B19ED489"===i.toString(16).toUpperCase()&&((t=new Uint8Array(o._u8array.length+512)).set(new Uint8Array(512),0),t.set(o._u8array,512),o=new Q(t))):r.startsWith(Le)?e=je(a):r.startsWith("BPS1")&&(e=ke(a),0<s&&"A31BEAD4"===i.toString(16).toUpperCase()&&(t=o._u8array.slice?o._u8array.slice(s):o._u8array.subarray(s),o=new Q(t)));try{(n=e.apply(o,!1))&&(0<(l=n._u8array.length%1024)&&(t=n._u8array.slice?n._u8array.slice(l):n._u8array.subarray(l),n=new Q(t)),Z.FS.unlink(d),Z.FS.unlink(c),Z.FS.writeFile(c,n._u8array))}catch(e){}}else{let e,t,n=new Q(Z.FS.readFile(c)),o=new Q(Z.FS.readFile(d)),i=o.readString(6);i.startsWith("PATCH")?e=Ce(o):i.startsWith(Le)?e=je(o):i.startsWith("BPS1")&&(e=ke(o));try{(t=e.apply(n,!1))&&(Z.FS.unlink(d),Z.FS.unlink(c),Z.FS.writeFile(c,t._u8array))}catch(e){}}}},A=function(){var e=2===f.coreVer?"INITIAL_MEMORY":"TOTAL_MEMORY",t=_(f.system,!0);v?(window.Module[e]=268435456,["jaguar"].includes(t)&&(window.Module[e]=268435456),["nds","nes","snes","arcade","mame"].includes(t)&&(window.Module[e]=0),["snes2002","snes2005","snes2010"].includes(t)&&(window.Module[e]=0),"gba"==t&&(window.Module[e]=0),"3do"==t&&(window.Module[e]=0),"n64"==t&&(window.Module[e]=0)):("nes"===t&&(window.Module[e]=134217728),window.Module[e]=g+67108864,["arcade","mame","mame2003","fba0.2.97.29"].includes(t)&&(window.Module[e]=g+268435456,Z.isMobileDevice&&(window.Module[e]=314572800)),["n64","nds","jaguar"].includes(t)&&(window.Module[e]=g+268435456,Z.isMobileDevice&&(window.Module[e]=314572800)),"gba"==t&&(window.Module[e]=268435456)),"undefined"!=typeof EJS_MEMORY&&(window.Module[e]=EJS_MEMORY)},u=function(e,t){function n(t){if(r.innerHTML="Game Data ready",t)try{A(),R(a);let e=[t,[Z.hash,Z.hash2,Z.hash3].join("")];if("undefined"!=typeof EJS_DEBUG_XX&&!0===EJS_DEBUG_XX&&e.unshift("-v"),Z.Module.callMain(e),2===w.coreVer){Z.Module.resumeMainLoop(),Z.Module.setCanvasSize(800,600);let e=0,t=setInterval(function(){20<e&&clearInterval(t),e++,Z.Module.setCanvasSize(800,600)},100)}B.call(a,a.elements.container,"start-game");try{i()}catch(e){}}catch(e){console.log(e),r.innerHTML='<strong style="color:#f00;text-shadow: 0px 0px 3px;">Failed to start game</strong>'}else r.innerHTML='<strong style="color:#f00;text-shadow: 0px 0px 3px;">Invalid Rom</strong>'}function o(e){if(e.data){if(1===e.data.t&&(!a.startName&&l&&(a.startName=l),e.target.terminate(),n(a.startName)),2===e.data.t){var i=(2===a.coreVer?y.newCores:y.oldCores)[c.toLowerCase()];let t=e.data.file.split("/"),n=t.pop(),o=n.split(".").pop();n=n.replace(/\#/g,""),Z.FS.createPath("/",t.join("/"),!0,!0);for(let e=i.length-1;0<=e;--e)i[e]===o.toLowerCase()&&e>s&&(s=e,a.startName=["",t.join("/"),n].join("/"),a.startName=a.startName.replace(/\/+/,"/"));n&&(Z.FS.createDataFile("/".concat(t.join("/")),n,e.data.data,!0,!1),g+=e.data.data.length),l="/".concat(t.join("/"),"/").concat(n)}var t;4===e.data.t&&0<e.data.total&&(t=Math.floor(e.data.current/e.data.total*100),e=e.data.name||"",t<=100&&0<t&&(r.innerHTML=f.localization("Decompress Game Data")+e+" "+t+"%"))}}let a=f,r=Z.loading.querySelector(".".concat(T.p3)),s=-1,c=_(S,f.coreVer),i=function(){if(2===a.coreVer){a.elements.settings.panels.home.querySelector('[role="menu"]').innerHTML="",ne.setNormalOptionsMenu.call(a),ne.setCoreOptionsMenu.call(a);let e=Z.Module.cwrap("toggleMainLoop","null",["number"]);Z.Module.resumeMainLoop=function(){e(1)},Z.Module.pauseMainLoop=function(){e(0)}}"string"==typeof a.loadStateOnStart&&fetch(a.loadStateOnStart).then(function(e){e.arrayBuffer().then(function(e){e=new Uint8Array(e);EJS_loadState(e)})})},l=(window.EJS_terminate=function(){if(Z.Module.pauseMainLoop(),a&&a.eventListeners)for(var e in a)for(let t=0;t<a.eventListeners.length;t++){let e=a.eventListeners[t];e.element.removeEventListener(e.type,e.callback,e.capture)}if(window.EJS_RESET_VARS){let t=[],n=[];for(var o in window)t.push(o);for(let e=0;e<t.length;e++)window.EJS_RESET_VARS.includes(t[e])||n.push(t[e]);for(let e=0;e<n.length;e++)window[n[e]]&&delete window[n[e]]}},""),d=!1;var u;if(["arcade","mame","mame2003","fba0.2.97.29"].includes(_(a.system,!0))||(u=t.slice?t.slice(0,10):t.subarray(0,10),"7z"===(u=x(u))?(C(p).then(function(e){e.onmessage=o,e.postMessage(t)}),d=!0):"zip"===u?(C(h).then(function(e){e.onmessage=o,e.postMessage(t)}),d=!0):"rar"===u&&(E(m).then(function(e){e.onmessage=o,e.postMessage(t)}),d=!0)),!d){a.startName=a.getStartName(),a.startName||(a.startName="rom");try{g+=t.length,Z.FS.createDataFile("/",a.startName,t,!0,!1)}catch(e){console.log(e)}n(a.startName)}},l=function(){let a=f,r=Z.loading.querySelector(".".concat(T.p3)),e=f.config,s=e.gameUrl,c=e.system,t=("vbanext"==c&&(c="gba"),"string"==typeof s?s.split("/"):"ga.me"),l=t[t.length-1];(l=-1<l.indexOf("?")?l.substr(0,l.indexOf("?")):l).split(".").pop(),r.innerHTML=f.localization("Download Game Data"),["arcade","mame","mame2003","fba0.2.97.29"].includes(_(a.system,!0))&&a.config.gameParentUrl&&(r.innerHTML+=" (2/2)"),a.config.gamePatchUrl&&(r.innerHTML+=" (2/2)"),"string"!=typeof s?"[object Blob]"===s.toString()?s.arrayBuffer().then(function(e){u(l,new Uint8Array(e))}):"[object ArrayBuffer]"===s.toString()?u(l,new Uint8Array(s)):u(l,Uint8Array.from(s)):J.a.head(s,{}).then(function(e){function t(){J.a.get(s,{onDownloadProgress:function(e){e=e.total?" "+Math.floor(e.loaded/e.total*100).toString()+"%":" "+(e.loaded/1048576).toFixed(2)+"MB";["arcade","mame","mame2003","fba0.2.97.29"].includes(_(a.system,!0))&&a.config.gameParentUrl||a.config.gamePatchUrl?r.innerHTML=f.localization("Download Game Data")+" (2/2)"+e:r.innerHTML=f.localization("Download Game Data")+e},responseType:"arraybuffer"}).then(function(e){e=new Uint8Array(e.data);"string"!=typeof f.config.gameUrl||"string"==typeof f.config.gameUrl&&(f.config.gameUrl.startsWith("blob:")||f.config.gameUrl.startsWith("file:")||f.config.gameUrl.startsWith("chrome-extension:")||"file:"===window.location.protocol||"chrome-extension:"===window.location.protocol)||f.cacheLimit&&f.cacheLimit<e.byteLength||!f.cacheLimit&&1073741824<e.byteLength||(i&&d.db&&(Z.saveFilenames.push(i),d.put(i,{filename:l,filesize:e.length,filetype:o,key:i,lastaccess:(new Date).valueOf()})),d.db&&d.put(i,{filename:l,filesize:e.length,filetype:o,key:i,data:e})),u(l,e)}).catch(function(e){D(e,r,f)})}let n=e.headers["content-length"],o=e.headers["content-type"],i="".concat(c,"-").concat(l);d.db?d.get(i,function(e){e&&e.filename===l&&e.filesize-n==0&&e.filetype===o&&e.key?u(e.filename,e.data):t()}):t()}).catch(function(e){D(e,r,f)})},O=function(){let t=Z.loading.querySelector(".".concat(T.p3)),n=f.config.gamePatchUrl;if(n){let e=n.split("/"),s=e[e.length-1];(s=-1<s.indexOf("?")?s.substr(0,s.indexOf("?")):s).split(".").pop(),t.innerHTML=f.localization("Download Game Data")+" (1/2)",J.a.get(n,{onDownloadProgress:function(e){e=e.total?" "+Math.floor(e.loaded/e.total*100).toString()+"%":" "+(e.loaded/1048576).toFixed(2)+"MB";t.innerHTML=f.localization("Download Game Data")+" (1/2)"+e},responseType:"arraybuffer"}).then(function(e){function t(o){if(o.data){if(1===o.data.t&&(o.target.terminate(),l()),2===o.data.t){let e=o.data.file.split("/"),t=e.pop(),n=t.split(".").pop();Z.FS.createPath("/",e.join("/"),!0,!0),Z.FS.createDataFile("/"+e.join("/"),t,o.data.data,!0,!1),g+=o.data.data.length,["ips","bps","ups"].includes(n)&&!Z.gamePatch&&(Z.gamePatch="/"+e.join("/")+"/"+t)}var e;4===o.data.t&&0<o.data.total&&(e=Math.floor(o.data.current/o.data.total*100),o=o.data.name||"",e<=100&&0<e&&(i.innerHTML=f.localization("Decompress Game Patch")+" ".concat(o," ").concat(e,"%")))}}let n=new Uint8Array(e.data),o=s.split(".").pop(),i=Z.loading.querySelector(".".concat(T.p3)),a=n.slice?n.slice(0,10):n.subarray(0,10),r=x(a);"7z"===r?C(p).then(function(e){e.onmessage=t,e.postMessage(n)}):"zip"===r?C(h).then(function(e){e.onmessage=t,e.postMessage(n)}):"rar"===r?E(m).then(function(e){e.onmessage=t,e.postMessage(n)}):(g+=n.length,Z.gamePatch="/"+o,Z.FS.createDataFile("/",o,n,!0,!1),l())}).catch(function(e){D(e,h,f)})}else l()},k=function(){let t=f,r=Z.loading.querySelector(".".concat(T.p3)),s=f.config.gameParentUrl;if(s&&["arcade","mame","mame2003","fba0.2.97.29"].includes(_(t.system,!0))){let e=s.split("/"),a=e[e.length-1];(a=-1<a.indexOf("?")?a.substr(0,a.indexOf("?")):a).split(".").pop(),r.innerHTML=f.localization("Download Game Data")+" (1/2)",t.config.gamePatchUrl&&(r.innerHTML=f.localization("Download Game Data")+" (1/3)"),J.a.head(s,{}).then(function(e){function t(){J.a.get(s,{onDownloadProgress:function(e){e=e.total?" "+Math.floor(e.loaded/e.total*100).toString()+"%":" "+(e.loaded/1048576).toFixed(2)+"MB";r.innerHTML=f.localization("Download Game Data")+" (1/2)"+e},responseType:"arraybuffer"}).then(function(e){var e=new Uint8Array(e.data),t=(i&&d.db&&(Z.saveFilenames.push(i),d.put(i,{filename:a,filesize:e.length,filetype:o,key:i,lastaccess:(new Date).valueOf()}),d.db&&d.put(i,{filename:a,filesize:e.length,filetype:o,key:i,data:e})),a.replace(/\#/g,""));try{g+=e.length,Z.FS.createDataFile("/",t,e,!0,!1),O()}catch(e){console.log(e)}}).catch(function(e){D(e,r,f)})}let n=e.headers["content-length"],o=e.headers["content-type"],i=(e.headers["last-modified"],"".concat(S,"-").concat(a));d.db?d.get(i,function(e){e&&e.filename===a&&e.filesize-n==0&&e.filetype===o&&e.key?(Z.FS.createDataFile("/",e.filename,e.data,!0,!1),O()):t()}):t()}).catch(function(e){D(e,r,f)})}else O()},P=function(e,t){function n(n){if(n.data){if(1===n.data.t&&(i.innerHTML="BIOS ready",n.target.terminate(),k()),2===n.data.t){let e=n.data.file.split("/"),t=e.pop();t.split(".").pop(),Z.FS.createPath("/",e.join("/"),!0,!0),Z.FS.createDataFile("/"+e.join("/"),t,n.data.data,!0,!1),g+=n.data.data.length}var e;4===n.data.t&&0<n.data.total&&(e=Math.floor(n.data.current/n.data.total*100),n=n.data.name||"",e<=100&&0<e&&(i.innerHTML="Decompress BIOS ".concat(n," ").concat(e,"%")))}}let o=f,i=Z.loading.querySelector(".".concat(T.p2)),a=(e.split(".").pop(),t.slice?t.slice(0,10):t.subarray(0,10)),r=x(a);"7z"===r?C(p).then(function(e){e.onmessage=n,e.postMessage(t)}):"rar"===r?E(m).then(function(e){e.onmessage=n,e.postMessage(t)}):"zip"!==r||["arcade","mame","mame2003","fba0.2.97.29"].includes(_(o.system,!0))?(g+=t.length,i.innerHTML="BIOS ready",Z.FS.createDataFile("/",e,t,!0,!1),k()):C(h).then(function(e){e.onmessage=n,e.postMessage(t)})},I=function(){if(Z.loading.querySelector(".".concat(T.p1)).innerHTML="Game Core ready",Z.Module._supports_states&&(ee.statesSupported=Z.Module.cwrap("supports_states","number",[])),ee.statesSupported)try{f.statesSupported=!!ee.statesSupported(),U.element(f.elements.buttons.netplay)&&V(f.elements.buttons.netplay,!ne.supportNetPlay.call(f)),U.element(f.elements.buttons.saveState)&&V(f.elements.buttons.saveState,!f.statesSupported),U.element(f.elements.buttons.loadState)&&V(f.elements.buttons.loadState,!f.statesSupported),V(oe.contextMenu.querySelectorAll("ul li").item(2),!f.statesSupported),V(oe.contextMenu.querySelectorAll("ul li").item(3),!f.statesSupported)}catch(e){}let s=f.config.biosUrl,e=(te.bindFunction.call(f),te.setGamepadDialog.call(f),te.setMessageDialog.call(f),te.setCacheDialog.call(f),te.setLoadingDialog.call(f),te.setNetplayDialog.call(f),te.setCheatDialog.call(f),te.initGamepad.call(f),te.initKeyboard.call(f),te.listeners.call(f),Z._FS.createFolder("/","etc",!0,!0),Z.FS.mkdir("/data"),Z.FS.mkdir("/data/saves"),"undefined"!=typeof IDBFS?Z.FS.mount(IDBFS,{},"/data/saves"):Z.FS.mount(Z.FS.filesystems.IDBFS,{},"/data/saves"),Z.FS.mkdir("/shader"),Z.FS.syncfs(!0,function(e){}),te.initShaders(),"");e=(e=(e=(e=(e+="savefile_directory = /data/saves\n")+"video_vsync = true\nscreenshot_directory = /\n")+"video_shader = /shader/shader.glslp\nvideo_shader_enable = true\n")+"video_font_enable = false\nvideo_scale = 1.0\n")+"video_gpu_screenshot = false\naudio_latency = 96\n";var t=_(f.system,!0);let n=oe.defaultCoreOptionsValues.call(f),o=(f.lightgun&&("nes"===t&&(e+='input_libretro_device_p2 = "258"\n'),"segaMS"!==t&&"segaMD"!==t&&"segaCD"!==t||(n.genesis_plus_gx_gun_cursor="yes",n.genesis_plus_gx_invert_mouse="yes",n.genesis_plus_gx_bram="per game",e+='input_libretro_device_p2 = "260"\n'),"snes"===t&&(e+='input_libretro_device_p2 = "260"\n'),["snes2002","snes2005","snes2010","snesnext"].includes(t)&&(e+='input_libretro_device_p2 = "260"\n')),f.mouse&&("snes"===t&&(e+="input_libretro_device_p1 = 2\n"),["snes2002","snes2005","snes2010","snesnext"].includes(t)&&(e+="input_libretro_device_p1 = 2\n")),f.multitap&&["snes2002","snes2005","snes2010","snesnext","snes"].includes(t)&&(e+="input_libretro_device_p2 = 257\n"),"n64"===t&&(e+="input_libretro_device_p1 = 5\n"),e=e+"fastforward_ratio = 1.0\n"+"video_smooth = false\n",X(n,oe.storage.get("core-options")||{})),i="";if(2===f.coreVer?(Z.FS.createDataFile("/etc","retroarch.cfg",e,!0,!0),Z._FS.createFolder("/home/web_user","retroarch",!0,!0),Z._FS.createFolder("/home/web_user/retroarch","userdata",!0,!0),Z.FS.createDataFile("/home/web_user/retroarch/userdata","retroarch.cfg",i,!0,!0)):(Z.FS.createDataFile("/etc","retroarch.cfg",e,!0,!0),Z._FS.createFolder("/home/web_user",".config",!0,!0),Z._FS.createFolder("/home/web_user/.config","retroarch",!0,!0),Z.FS.createDataFile("/home/web_user/.config/retroarch","retroarch-core-options.cfg",i,!0,!0)),o&&Object.keys(o).forEach(function(t){if(f.lightgun&&"nes"===_(f.system,!0)&&"system_type"===t)return!1;i+="".concat(t,' = "').concat(o[t],'"\n'),j.call(f,f.elements.container,"start-game",function(e){te.setVariable(t,o[t])})}),s){let e=s.split("/"),a=e[e.length-1],r=((a=-1<a.indexOf("?")?a.substr(0,a.indexOf("?")):a).split(".").pop(),Z.loading.querySelector(".".concat(T.p2)));J.a.head(s,{}).then(function(e){function t(){J.a.get(s,{onDownloadProgress:function(e){e=e.total?" "+Math.floor(e.loaded/e.total*100).toString()+"%":" "+(e.loaded/1048576).toFixed(2)+"MB";r.innerHTML=f.localization("Download BIOS")+e},responseType:"arraybuffer"}).then(function(e){e=new Uint8Array(e.data);c.db&&c.put(S,{filename:a,filesize:e.length,filetype:o,data:e}),P(a,e)}).catch(function(e){D(e,r,f)})}let n=e.headers["content-length"],o=e.headers["content-type"],i=(e.headers["last-modified"],f.system);c.db?c.get(i,function(e){e&&e.filename===a&&e.filesize-n==0&&e.filetype===o?P(e.filename,e.data):t()}):t()}).catch(function(e){D(e,r,f)})}else k()},N=function(e){e=e.byteLength?new Uint8Array(e):e;"undefined"!=typeof GLOBAL_BASE?Z.Module.HEAPU8.set(e,GLOBAL_BASE):"undefined"!=typeof Runtime&&Runtime.GLOBAL_BASE?Z.Module.HEAPU8.set(e,Runtime.GLOBAL_BASE):Z.Module.HEAPU8.set(e,8)},L=function(t){function n(n){if(n.data){if(1===n.data.t&&(B.call(w,w.elements.container,"script-loaded"),n.target.terminate()),2===n.data.t){let e=n.data.file.split("/").pop(),t=e.split(".").pop();Z.coreFileData[e]=n.data.data,"js"!==t||e.includes(".worker.js")||(o=n.data.data),"mem"===t&&(Z.memData=n.data.data),"wasm"===t&&(Z.wasmData=n.data.data)}4===n.data.t&&0<n.data.total&&(e.innerHTML=f.localization("Decompress Game Core")+" ".concat(Math.floor(n.data.current/n.data.total*100),"%"))}}let e=Z.loading.querySelector(".".concat(T.p1)),o="";j.call(w,w.elements.container,"script-loaded",function(e){{null!==Z.wasmData?(window.Module.wasmBinary=Z.wasmData,A(),window.Module.monitorRunDependencies=function(e){0===e&&I()},window.Module.onRuntimeInitialized=function(){}):(A(),window.Module.monitorRunDependencies=function(e){console.log("monitorRunDependencies, ",e)},window.Module.onRuntimeInitialized=function(){Z.Module||(Z.Module=window.Module),Z.Module&&Z.Module.FS?Z.FS=Z.Module.FS:Z.FS=window.FS,console.log("onRuntimeInitialized"),I()});let n=window.Module;if(null!==Z.wasmData&&(n.wasmBinary=Z.wasmData),W.isIos&&null!==Z.wasmData){let e=new Blob([o],{type:"text/javascript"}),t=F("script",{src:s.createObjectURL(e)});document.body.appendChild(t),t.onload=function(){void 0===window.addRunDependency&&"undefined"!=typeof EmulatorJS&&(Z.Module=EmulatorJS(n),EmulatorJS=void 0),null!==Z.memData&&2!==w.coreVer&&N(Z.memData),Z.Module||(Z.Module=window.Module),Z.Module&&Z.Module.FS?Z.FS=Z.Module.FS:Z.FS=window.FS}}else o=function(n){let o=[];for(let t=0;t<n.length;t+=1){let e=n[t];255<e&&(e&=255),o.push(String.fromCharCode(e))}return o.join("")}(o),window.eval(o),void 0===window.addRunDependency&&"undefined"!=typeof EmulatorJS&&(Z.Module=EmulatorJS(n),EmulatorJS=void 0),null!==Z.memData&&2!==w.coreVer&&N(Z.memData),Z.Module||(Z.Module=window.Module),Z.Module&&Z.Module.FS?Z.FS=Z.Module.FS:Z.FS=window.FS,window.EJS_MODULE=Z.Module,window.ejs_loader=Z,window.ejs_media=te;return void(o=null)}});C(p).then(function(e){e.onmessage=n,e.postMessage(t)})},z=function(t){V(Z.loading.querySelector(".".concat(T["start-game"])),!0);let i=Z.loading.querySelector(".".concat(T.p1));if(i.innerHTML=f.localization("Loading")+"...",!0===n&&!0===o&&!0===a){window.Module={TOTAL_MEMORY:268435456,noInitialRun:!0,arguments:[],preRun:[],postRun:[],canvas:r,print:function(e){!0===window.EJS_DEBUG_XX&&console.log(e)},printErr:function(e){!0===window.EJS_DEBUG_XX&&console.log(e)},totalDependencies:0,monitorRunDependencies:function(e){},locateFile:function(e){let t=null;var n;return e.includes(".worker.js")?(Object.keys(Z.coreFileData).includes(e)&&(t=Z.coreFileData[e]),n=new Blob([""],{type:"application/javascript"}),window.URL.createObjectURL(n)):e.includes(".js.mem")&&Object.keys(Z.coreFileData).includes(e)?(t=Z.coreFileData[e],URL.createObjectURL(new Blob([t.buffer]))):null},readAsync:function(t,n,o){if(t instanceof ArrayBuffer)setTimeout(function(){n(t)},500);else{let e=new XMLHttpRequest;e.open("GET",t,!0),e.responseType="arraybuffer",e.onload=function(){200==e.status||0==e.status&&e.response?n(e.response):o()},e.onerror=o,e.send()}}};let u=function(n,o){var e=f.customPaths&&"string"==typeof f.customPaths[n]?f.customPaths[n]:2===f.coreVer?f.dataPath+"cores/"+n+"?v="+o:f.dataPath+"old/"+n+"?v="+o;J.a.get(e,{onDownloadProgress:function(e){e=e.total?" "+Math.floor(e.loaded/e.total*100).toString()+"%":" "+(e.loaded/1048576).toFixed(2)+"MB";i.innerHTML=f.localization("Download Game Core")+e},responseType:"arraybuffer"}).then(function(e){let t=new Uint8Array(e.data);if(M.db&&M.put(n,{version:o,data:t}),2===f.coreVer)L(t);else{let e=t.slice?t.slice(12):t.subarray(12);e.set([55,122,188,175,39,28,0,3],0),t=null,L(e)}}).catch(function(e){D(e,i,f)})};var e=f.customPaths&&"string"==typeof f.customPaths["v.json"]?f.customPaths["v.json"]:f.dataPath+"v.json";return J.a.get(e,{}).then(function(r){let s,c=b,l=r.data,d=Z.loading.querySelector(".".concat(T.p1));if(c=!0===f.config.oldCores&&l.oldCores[f.system]||!l.newCores[_(f.system)]||!Y.wasm&&!Boolean(l.newCores[_(f.system)].asmjs)||W.isIos?(l=l.oldCores[f.system],c.oldCores[f.system]):(f.coreVer=2,delete Module.readAsync,Module.INITIAL_MEMORY=Module.TOTAL_MEMORY,delete Module.TOTAL_MEMORY,f.elements.settings.panels.home.querySelector('[role="menu"]').innerHTML="",ne.setNormalOptionsMenu.call(f),ne.setCoreOptionsMenu.call(f),l=l.newCores[_(f.system)],_(f.system)),l){let n=l.version||1,e=Boolean(l.netplay),t=Boolean(l.state),o=Boolean(l.asmjs),i=Boolean(l.wasm),a=("nds"!==f.system||Y.wasm||2===f.coreVer||(t=!1),!1===f.statesSupported&&(t=!1),Z.coreFileVersion=n,Z.coreFileName=c,!1);if(["webgl2","experimental-webgl2"].includes(Y.webgl.WEBGL_CONTEXT)&&(a=!0),"undefined"!=typeof EJS_N64_LEGACY&&1==EJS_N64_LEGACY&&(a=!1),"mame"==f.system){let e=f.mameCore;if(!e||null===e||2!==e.split("|").length)return void(d.innerHTML='<strong style="color:#f00;text-shadow: 0px 0px 3px;">'+f.localization("Missing mame config")+"</strong>");r=e.split("|");Z.coreFileName="".concat(f.system,"-").concat(r[0]),t="1"===r[1],U.element(f.elements.buttons.saveState)&&V(f.elements.buttons.saveState,!t),U.element(f.elements.buttons.loadState)&&V(f.elements.buttons.loadState,!t),V(oe.contextMenu.querySelectorAll("ul li").item(2),!t),V(oe.contextMenu.querySelectorAll("ul li").item(3),!t),s=2===f.coreVer?"":f.system.concat("-old-").concat(r[0],"-wasm.data"),r[0]?(Y.wasm&&i?v=!0:(d.innerHTML='<strong style="color:#f00;text-shadow: 0px 0px 3px;">'+f.localization("Webassembly support is not detected in this browser")+"</strong>",s=""),s&&(M.db?M.get(s,function(t){if(t&&t.version===n)if(2===w.coreVer)L(t.data);else{let e=t.data.slice?t.data.slice(12):t.data.subarray(12);e.set([55,122,188,175,39,28,0,3],0),L(e)}else u(s,n)}):u(s,n))):d.innerHTML='<strong style="color:#f00;text-shadow: 0px 0px 3px;">'+f.localization("Unsupported Game")+"</strong>"}else{s=!1;let e;if(Y.wasm&&i?(e="wasm",s=!0,"n64"!==f.system||a||2===f.coreVer||(e="legacy-wasm"),v=!0):o&&(s=!0,e="asmjs","n64"!==f.system||a||2===f.coreVer||(e="legacy-asmjs")),!0!==s)return void(d.innerHTML='<strong style="color:#f00;text-shadow: 0px 0px 3px;">'+f.localization("Please upgrade your browser to the latest version")+"</strong>");s=2===f.coreVer?c+"-"+e+".data":c+"-old-"+e+".data","undefined"!=typeof EJS_CUSTOM_COREFILE&&(s=EJS_CUSTOM_COREFILE),M.db?M.get(s,function(t){if(!t||t.version!==n||"undefined"!=typeof EJS_DEBUG_XX&&!0===EJS_DEBUG_XX)u(s,n);else if(2===w.coreVer)L(t.data);else{let e=t.data.slice?t.data.slice(12):t.data.subarray(12);e.set([55,122,188,175,39,28,0,3],0),L(e)}}):u(s,n)}e||U.element(f.elements.buttons.netplay)&&V(f.elements.buttons.netplay,!0),U.element(f.elements.buttons.saveState)&&V(f.elements.buttons.saveState,!t),U.element(f.elements.buttons.loadState)&&V(f.elements.buttons.loadState,!t),V(oe.contextMenu.querySelectorAll("ul li").item(2),!t),V(oe.contextMenu.querySelectorAll("ul li").item(3),!t),f.statesSupported=t,window.innerWidth<400&&(U.element(f.elements.inputs.volume)&&V(f.elements.inputs.volume,!0),U.element(f.elements.buttons.mute)&&V(f.elements.buttons.mute,!0),U.element(f.elements.buttons.cheat)&&V(f.elements.buttons.cheat,!0)),f.config.buttons&&(!1===f.config.buttons.playPause&&U.element(f.elements.buttons.play[0])&&V(f.elements.buttons.play[0],!0),!1===f.config.buttons.restart&&U.element(f.elements.buttons.restart)&&V(f.elements.buttons.restart,!0),!1===f.config.buttons.mute&&U.element(f.elements.buttons.mute)&&V(f.elements.buttons.mute,!0),!1===f.config.buttons.settings&&U.element(f.elements.buttons.settings)&&V(f.elements.buttons.settings,!0),!1===f.config.buttons.fullscreen&&U.element(f.elements.buttons.fullscreen)&&V(f.elements.buttons.fullscreen,!0),!1===f.config.buttons.saveState&&U.element(f.elements.buttons.saveState)&&V(f.elements.buttons.saveState,!0),!1===f.config.buttons.loadState&&U.element(f.elements.buttons.loadState)&&V(f.elements.buttons.loadState,!0),!1===f.config.buttons.screenRecord&&U.element(f.elements.buttons.screenRecord)&&V(f.elements.buttons.screenRecord,!0),!1===f.config.buttons.cacheManager&&U.element(f.elements.buttons.cacheManager)&&V(f.elements.buttons.cacheManager,!0),!1===f.config.buttons.gamepad&&U.element(f.elements.buttons.gamepad)&&V(f.elements.buttons.gamepad,!0),!1===f.config.buttons.cheat&&U.element(f.elements.buttons.cheat)&&V(f.elements.buttons.cheat,!0),!1===f.config.buttons.volume&&U.element(f.elements.inputs.volume)&&V(f.elements.inputs.volume,!0),!1===f.config.buttons.screenshot&&V(oe.contextMenu.querySelectorAll("ul li").item(0),!0),!1===f.config.buttons.quickSave&&V(oe.contextMenu.querySelectorAll("ul li").item(2),!0),!1===f.config.buttons.quickLoad&&V(oe.contextMenu.querySelectorAll("ul li").item(3),!0))}else d.innerHTML='<strong style="color:#f00;text-shadow: 0px 0px 3px;">'+f.localization("Invalid System")+"</strong>"}).catch(function(e){D(e,t,w)}),Z.romdb=d,!1}setTimeout(z,50)};ie(Z.loading.querySelector(".".concat(T["start-game"])),"click touchstart",z),!0===w.startOnLoad&&Z.loading.querySelector(".".concat(T["start-game"])).click()}};let m=Z;const Be=r(161);function Fe(e){return function(n){if(Array.isArray(n)){for(let e=0,t=new Array(n.length);e<n.length;e++)t[e]=n[e];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function Ve(n,o){for(let t=0;t<o.length;t++){let e=o[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}let Ge,qe,He,We,Ye,g=(Ge=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'],qe=function(){function u(e){var t=e.targetModal,n=e.triggers,n=void 0===n?[]:n,o=e.onShow,o=void 0===o?function(){}:o,i=e.onClose,i=void 0===i?function(){}:i,a=e.openTrigger,a=void 0===a?"data-micromodal-trigger":a,r=e.closeTrigger,r=void 0===r?"data-micromodal-close":r,s=e.disableScroll,s=void 0!==s&&s,c=e.disableFocus,c=void 0!==c&&c,l=e.awaitCloseAnimation,l=void 0!==l&&l,d=e.debugMode,d=void 0!==d&&d,e=e.closeByEsckey,e=void 0===e||e;if(!(this instanceof u))throw new TypeError("Cannot call a class as a function");this.modal=document.getElementById(t),this.config={debugMode:d,disableScroll:s,openTrigger:a,closeTrigger:r,onShow:o,onClose:i,awaitCloseAnimation:l,disableFocus:c,closeByEsckey:e},0<n.length&&this.registerTriggers.apply(this,Fe(n)),this.onClick=this.onClick.bind(this),this.onKeydown=this.onKeydown.bind(this)}let e,t;return e=u,t=[{key:"registerTriggers",value:function(){for(let e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];t.forEach(function(e){e.addEventListener("click",function(){return u.showModal()})})}},{key:"showModal",value:function(){this.activeElement=document.activeElement,this.modal.setAttribute("aria-hidden","false"),this.modal.classList.add(H({"is-open":!0})),this.setFocusToFirstNode(),this.addEventListeners(),this.config.onShow(this.modal)}},{key:"closeModal",value:function(){let t=this.modal;this.modal.setAttribute("aria-hidden","true"),this.removeEventListeners(),this.config.onClose(this.modal),this.config.awaitCloseAnimation?this.modal.addEventListener("animationend",function e(){t.classList.remove(H({"is-open":!0})),t.removeEventListener("animationend",e,!1)},!1):t.classList.remove(H({"is-open":!0}))}},{key:"addEventListeners",value:function(){this.modal.addEventListener("touchstart",this.onClick),this.modal.addEventListener("click",this.onClick),document.addEventListener("keydown",this.onKeydown)}},{key:"removeEventListeners",value:function(){this.modal.removeEventListener("touchstart",this.onClick),this.modal.removeEventListener("click",this.onClick),document.removeEventListener("keydown",this.onKeydown)}},{key:"onClick",value:function(e){e.target.hasAttribute(this.config.closeTrigger)&&(this.closeModal(),e.preventDefault())}},{key:"onKeydown",value:function(e){this.config.closeByEsckey&&27===e.keyCode&&this.closeModal(e),9===e.keyCode&&this.maintainFocus(e)}},{key:"getFocusableNodes",value:function(){let t=this.modal.querySelectorAll(Ge);return Object.keys(t).map(function(e){return t[e]})}},{key:"setFocusToFirstNode",value:function(){if(!this.config.disableFocus){let e=this.getFocusableNodes();e.length&&e[0].focus()}}},{key:"maintainFocus",value:function(e){let t=this.getFocusableNodes();var n;this.modal.contains(document.activeElement)?(n=t.indexOf(document.activeElement),e.shiftKey&&0===n&&(t[t.length-1].focus(),e.preventDefault()),e.shiftKey||n!==t.length-1||(t[0].focus(),e.preventDefault())):t[0].focus()}}],Ve(e.prototype,t),u}(),He=null,We=function(e){if(!document.getElementById(e))return!1},Ye=function(e,t){if(e.length<=0&&(console.warn("MicroModal v".concat(version,": ❗Please specify at least one %c'micromodal-trigger'"),"background-color: #f8f9fa;color: #50596c;font-weight: bold;","data attribute."),console.warn("%cExample:","background-color: #f8f9fa;color: #50596c;font-weight: bold;",'<a href="#" data-micromodal-trigger="my-modal"></a>')),!t)return!0;for(var n in t)We(n);return!0},{init:function(e){let t=Object.assign({},{openTrigger:"data-micromodal-trigger"},e),n=Fe(document.querySelectorAll("[".concat(t.openTrigger,"]"))),o=function(e,n){let o=[];return e.forEach(function(e){var t=e.attributes[n].value;void 0===o[t]&&(o[t]=[]),o[t].push(e)}),o}(n,t.openTrigger);if(!0!==t.debugMode||!1!==Ye(n,o))for(var i in o){var a=o[i];t.targetModal=i,t.triggers=Fe(a),new qe(t)}},show:function(e,t){let n=t||{};return n.targetModal=e,!0===n.debugMode&&!1===We(e)?He=null:(He=new qe(n)).showModal(),He},close:function(){He.closeModal()}});const ee={defaultControllers:{0:{0:{value:"88"},1:{value:"83"},2:{value:"16"},3:{value:"13"},4:{value:"38"},5:{value:"40"},6:{value:"37"},7:{value:"39"},8:{value:"90"},9:{value:"65"},10:{value:"81"},11:{value:"69"},12:{value:"82"},13:{value:"87"},14:{},15:{},16:{value:"72"},17:{value:"70"},18:{value:"71"},19:{value:"84"},20:{value:"76"},21:{value:"74"},22:{value:"75"},23:{value:"73"},24:{},25:{},26:{}},1:{},2:{},3:{}},controllers:{},virtualGamepadContainer:null,keyMap:{8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",19:"pause/break",20:"caps lock",27:"escape",32:"space",33:"page up",34:"page down",35:"end",36:"home",37:"left arrow",38:"up arrow",39:"right arrow",40:"down arrow",45:"insert",46:"delete",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",91:"left window key",92:"right window key",93:"select key",96:"numpad 0",97:"numpad 1",98:"numpad 2",99:"numpad 3",100:"numpad 4",101:"numpad 5",102:"numpad 6",103:"numpad 7",104:"numpad 8",105:"numpad 9",106:"multiply",107:"add",109:"subtract",110:"decimal point",111:"divide",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"num lock",145:"scroll lock",186:"semi-colon",187:"equal sign",188:"comma",189:"dash",190:"period",191:"forward slash",192:"grave accent",219:"open bracket",220:"back slash",221:"close braket",222:"single quote"},saveLoaddbDB:function(){try{return new Te({dbVersion:1,storePrefix:"ejs-",storeName:"states",keyPath:null,autoIncrement:!1,onStoreReady:function(){},onError:function(){}})}catch(e){console.log(e)}}(),saveLoadDB:function(n){try{if(!ee.saveLoaddbDB.db)return!1;if(oe&&"function"==typeof oe.getCoreOptionsValue){var e=oe.getCoreOptionsValue("save-state-location");if(!e||"download"===e)return!1;if(!this.getStartName())return!1;var o=oe.getCoreOptionsValue("save-state-slot");if(!o)return!1;let t=this.getStartName()+"-"+o;return async function(){if("save"===n)try{var e=await ee.saveState();ee.saveLoaddbDB.put(t,e)}catch(e){return}else ee.saveLoaddbDB.get(t,function(e){EJS_loadState(e)})}(),!0}return!1}catch(e){return!1}},disableInput:!1,disableControl:function(e){if(e){for(var t=0;t<24;t+=1)ee.simulateInputFn(0,t,0),ee.simulateInputFn(1,t,0),ee.simulateInputFn(2,t,0),ee.simulateInputFn(3,t,0);ee.disableInput=!0}else ee.disableInput=!1},loadRoomsListTimer:null,loadRoomsList:function(){},stopLoadRooms:function(){ee.loadRoomsListTimer&&clearTimeout(ee.loadRoomsListTimer)},openRoom:function(){},gamepad:null,allowCheat:!0,connection:null,connected:!1,playerName:"",players:[],waitingList:{},roomMaster:null,inputsData:{},coreOptionData:{},currentFrame:0,wait:!1,progressHelper:{},icons:{lock:'<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="lock" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" class="svg-inline--fa fa-lock fa-w-14 fa-3x"><path fill="currentColor" d="M400 224h-24v-72C376 68.2 307.8 0 224 0S72 68.2 72 152v72H48c-26.5 0-48 21.5-48 48v192c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V272c0-26.5-21.5-48-48-48zm-104 0H152v-72c0-39.7 32.3-72 72-72s72 32.3 72 72v72z" class=""></path></svg>'},isPaused:null,setVolume:null,setVariable:null,simulateInput:null,simulateInputFn:null,toggleShader:null,saveState:null,screenRecord:null,cacheManager:null,loadState:null,quickSaveState:null,quickLoadState:null,changeStateSlot:null,getScreenData:null,getStateInfo:null,setCheat:null,resetCheat:null,getGameCoreOptions:null,classNames:{"dialog-container":H({"dialog-container":!0}),tabs:H({tabs:!0}),"dialog-title":H({"dialog-title":!0}),"dialog-content":H({"dialog-content":!0}),"dialog-buttons":H({"dialog-buttons":!0}),overlay:H({overlay:!0}),"key-setting-popup":H({"key-setting-popup":!0}),"tabs-panel":H({"tabs-panel":!0}),"tabs-content":H({"tabs-content":!0}),"button-container":H({"button-container":!0}),set:H({set:!0}),active:H({active:!0}),"btn-cancel":H({"btn-cancel":!0}),"btn-reset":H({"btn-reset":!0}),"btn-clear":H({"btn-clear":!0}),"btn-create":H({"btn-create":!0}),"btn-submit":H({"btn-submit":!0}),"btn-join-room":H({"btn-join-room":!0}),"btn-quit":H({"btn-quit":!0}),"btn-create-room":H({"btn-create-room":!0}),"netplay-player-name":H({"netplay-player-name":!0}),"netplay-roomlist":H({"netplay-roomlist":!0}),"netplay-room-name-input":H({"netplay-room-name-input":!0}),"netplay-room-password-input":H({"netplay-room-password-input":!0}),"netplay-create-room-set":H({"netplay-create-room-set":!0}),"netplay-room":H({"netplay-room":!0}),modal:H({modal:!0}),modal__overlay:H({modal__overlay:!0}),modal__container:H({modal__container:!0}),modal__header:H({modal__header:!0}),modal__title:H({modal__title:!0}),modal__close:H({modal__close:!0}),modal__content:H({modal__content:!0}),modal__btn:H({modal__btn:!0}),"modal__btn-primary":H({"modal__btn-primary":!0}),"micromodal-slide":H({"micromodal-slide":!0}),modal__errmsg:H({modal__errmsg:!0}),modal__footer:H({modal__footer:!0}),"cheats-add":H({"cheats-add":!0}),"cheats-list":H({"cheats-list":!0}),"cheat-code-input":H({"cheat-code-input":!0}),"cheat-name-input":H({"cheat-name-input":!0}),"ejs-switch":H({"ejs-switch":!0}),"ejs-delete-cheat":H({"ejs-delete-cheat":!0})},initShaders:function(){var o=Se;for(let e=Object.keys(o),t,n=0;n<e.length;n+=1)t=o[e[n]],m.FS.writeFile("/shader/".concat(e[n]),t),oe.storage.get("shader")===e[n]&&m.FS.writeFile("/shader/shader.glslp",t)},setMessageDialog:function(){this.elements.dialogs.message.innerHTML='<div class="'+ee.classNames["dialog-container"]+'"><div class="'+ee.classNames["dialog-title"]+'"><h2>'+this.localization("Drop to load save state")+"</h2></div></div>"},setGamepadDialog:function(){let s=this,n=(s.elements.dialogs.gamepad.innerHTML='\n <div class="'+ee.classNames["dialog-container"]+'">\n <div class="'+ee.classNames["dialog-title"]+'">\n <h4>'+s.localization("Control Settings")+'</h4>\n </div>\n \n <ul class="'+ee.classNames.tabs+'" id="controls-tabs">\n <li class="tabs-title" role="presentation"><a href="#" onclick="return false" role="tab" aria-controls="controls-0" aria-selected="false" id="controls-0-label">'+s.localization("Player 1")+'</a></li>\n <li class="tabs-title" role="presentation"><a href="#" onclick="return false" role="tab" aria-controls="controls-1" aria-selected="false" id="controls-1-label">'+s.localization("Player 2")+'</a></li>\n <li class="tabs-title" role="presentation"><a href="#" onclick="return false" role="tab" aria-controls="controls-2" aria-selected="false" id="controls-2-label">'+s.localization("Player 3")+'</a></li>\n <li class="tabs-title" role="presentation"><a href="#" onclick="return false" role="tab" aria-controls="controls-3" aria-selected="false" id="controls-3-label">'+s.localization("Player 4")+'</a></li>\n </ul>\n <div class="'+ee.classNames["dialog-content"]+'">\n <div class="'+ee.classNames["tabs-content"]+' controls">\n \n </div>\n </div>\n <div class="'+ee.classNames["dialog-buttons"]+'">\n <a href="#" onclick="return false" class="'+ee.classNames["btn-reset"]+'">'+s.localization("Reset")+'</a>\n <a href="#" onclick="return false" class="'+ee.classNames["btn-clear"]+'">'+s.localization("Clear")+'</a>\n <a href="#" onclick="return false" style="background-color:#929292;" class="'+ee.classNames["btn-close"]+'">'+s.localization("Close")+'</a>\n </div>\n <div class="'+ee.classNames.overlay+'" hidden>\n <div class="'+ee.classNames["key-setting-popup"]+'">\n <span>[Select]</span><br />\n <div style="color:#fff !important">'+s.localization("Press keyboard or gamepad")+"</div>\n </div>\n </div>\n </div>\n ",'\n <div class="'.concat(ee.classNames["tabs-panel"],'" id="controls-{index}" hidden>\n <div>\n <div style="">\n <div class="gamepad" style="font-size:12px">Connected gamepad: <span class="gamepad-name">n/a</span></div>\n </div>\n <div style="width:25%;float:left">&nbsp;</div>\n <div style="font-size:12px;width:50%;float:left">\n <div class="row">\n <div style="text-align:center;width:50%;float:left">'+s.localization("Gamepad")+'</div>\n <div style="text-align:center;width:50%;float:left">'+s.localization("Keyboard")+'</div>\n </div>\n </div>\n <div style="clear:both"></div>\n </div>\n </div>')),o='\n <div class="'.concat(ee.classNames["button-container"],'" data-id="{id}" data-index="{index}" data-label="{label}" style="margin-bottom:10px">\n <div style="width:25%;float:left;font-size:12px">\n <label>{label}:</label>\n </div>\n <div style="width:50%;float:left">\n <div>\n <div style="width:50%;float:left;padding: 0 5px;">\n <input style="text-align:center;height:25px;width: 100%;" type="text" data-id="{id}" data-value="" data-type="2" data-index="{index}" readonly="" placeholder="">\n </div>\n <div style="width:50%;float:left;padding: 0 5px;">\n <input style="text-align:center;height:25px;width: 100%;" type="text" data-id="{id}" data-value="" data-type="1" data-index="{index}" readonly="" placeholder="">\n </div>\n <div style="clear:both"></div>\n </div>\n </div>\n <div style="width:25%;float:left">\n <a class="').concat(ee.classNames.set,'" href="#" onclick="return false">'+s.localization("Set")+'</a>\n </div>\n <div style="clear:both"></div>\n </div>'),i;"nes"===getSystem(s.system,!0)?i={0:"B",2:"SELECT",3:"START",4:"UP",5:"DOWN",6:"LEFT",7:"RIGHT",8:"A",24:s.localization("QUICK SAVE STATE"),25:s.localization("QUICK LOAD STATE"),26:s.localization("CHANGE STATE SLOT")}:"snes"===getSystem(s.system,!0)?i={0:"B",1:"Y",2:"SELECT",3:"START",4:"UP",5:"DOWN",6:"LEFT",7:"RIGHT",8:"A",9:"X",10:"L",11:"R",24:s.localization("QUICK SAVE STATE"),25:s.localization("QUICK LOAD STATE"),26:s.localization("CHANGE STATE SLOT")}:"n64"===getSystem(s.system,!0)?(i={0:"B",3:"START",4:"UP",5:"DOWN",6:"LEFT",7:"RIGHT",8:"A",10:"L",11:"R",12:"Z",19:"L STICK UP",18:"L STICK DOWN",17:"L STICK LEFT",16:"L STICK RIGHT",23:"R STICK UP",22:"R STICK DOWN",21:"R STICK LEFT",20:"R STICK RIGHT",24:s.localization("QUICK SAVE STATE"),25:s.localization("QUICK LOAD STATE"),26:s.localization("CHANGE STATE SLOT")},2===s.coreVer&&(i[0]="A",i[1]="B",delete i[8])):i="nds"===getSystem(s.system,!0)?{0:"B",1:"Y",2:"SELECT",3:"START",4:"UP",5:"DOWN",6:"LEFT",7:"RIGHT",8:"A",9:"X",10:"L",11:"R",14:"Microphone",24:s.localization("QUICK SAVE STATE"),25:s.localization("QUICK LOAD STATE"),26:s.localization("CHANGE STATE SLOT")}:{0:"B",1:"Y",2:"SELECT",3:"START",4:"UP",5:"DOWN",6:"LEFT",7:"RIGHT",8:"A",9:"X",10:"L",11:"R",12:"L2",13:"R2",14:"L3",15:"R3",19:"L STICK UP",18:"L STICK DOWN",17:"L STICK LEFT",16:"L STICK RIGHT",23:"R STICK UP",22:"R STICK DOWN",21:"R STICK LEFT",20:"R STICK RIGHT",24:s.localization("QUICK SAVE STATE"),25:s.localization("QUICK LOAD STATE"),26:s.localization("CHANGE STATE SLOT")},["arcade","mame"].includes(getSystem(s.system,!0))&&(i[2]=s.localization("INSERT COIN")),!1===s.statesSupported&&(delete i[24],delete i[25],delete i[26]);for(let e=[2,3,4,5,6,7,8,0,9,1,10,11,12,13,14,15,19,18,17,16,23,22,21,20,24,25,26],t=0;t<=3;t++){s.elements.dialogs.gamepad.querySelector(".".concat(ee.classNames["tabs-content"])).innerHTML+=n.replace(/{index}/g,t),e.forEach(function(e){i[e]&&(s.elements.dialogs.gamepad.querySelector("#controls-".concat(t)).innerHTML+=o.replace(/{index}/g,t).replace(/{id}/g,e).replace(/{label}/g,i[e]))});var a=[16,17,18,19,20,21,22,23];for(let e=0;e<a.length;e++)s.elements.dialogs.gamepad.querySelector('[data-id="'+a[e]+'"][data-index="'.concat(t,'"][data-type="2"]'))&&((r=s.elements.dialogs.gamepad.querySelector('[data-id="'+a[e]+'"][data-index="'.concat(t,'"][data-type="2"]'))).style.backgroundColor="#ccc",r.setAttribute("title","This setting is automatically set to your controllers axis."))}var r;Object.keys(ee.controllers).forEach(function(o){ee.controllers[o]&&Object.keys(ee.controllers[o]).forEach(function(e){let t=s.elements.dialogs.gamepad.querySelector('[data-id="'.concat(e,'"][data-index="').concat(o,'"][data-type="1"]')),n=s.elements.dialogs.gamepad.querySelector('[data-id="'.concat(e,'"][data-index="').concat(o,'"][data-type="2"]'));if(!t||!n)return!1;e=ee.controllers[o][e];e&&(e.type&&1!==parseInt(e.type,10)?n.value="":e.value&&(t.value=ee.keyMap[e.value]||"",t.setAttribute("data-value",e.value)),e.value2&&(n.value=isNaN(e.value2)?e.value2:"button ".concat(parseInt(e.value2,10)+1),n.setAttribute("data-value",e.value2)))})}),j.call(this,s.elements.dialogs.gamepad.querySelector(".".concat(ee.classNames["btn-close"])),"click",function(e){let t=s.elements.dialogs.gamepad.querySelectorAll("input"),i={};return Array.from(t).forEach(function(e){let t,n=e.getAttribute("data-index"),o=e.getAttribute("data-value");2===parseInt(e.getAttribute("data-type"),10)&&(t=e.getAttribute("data-value"));e=e.getAttribute("data-id");i[n]||(i[n]={}),i[n][e]||(i[n][e]={}),o&&(i[n][e].value=o),t&&(i[n][e].value2=t)}),oe.storage.set({controllers:i}),ee.controllers=i,V(s.elements.dialogs.gamepad,!0),s.elements.container.focus(),e.stopPropagation(),!1}),j.call(this,s.elements.dialogs.gamepad.querySelector(".".concat(ee.classNames["btn-reset"])),"click",function(e){ee.controllers=JSON.parse(JSON.stringify(ee.defaultControllers)),localStorage.removeItem(oe.storage.key);let t=s.elements.dialogs.gamepad.querySelectorAll("input");for(let e=0;e<t.length;e++){var n=t[e].getAttribute("data-index"),o=t[e].getAttribute("data-type"),i=t[e].getAttribute("data-id"),a=1==o?"value":"value2";ee.defaultControllers[n]&&ee.defaultControllers[n][i]&&ee.defaultControllers[n][i][a]?(t[e].value=1==o?ee.keyMap[ee.defaultControllers[n][i][a]]:"button "+(parseInt(ee.defaultControllers[n][i][a])+1),t[e].setAttribute("data-value",ee.defaultControllers[n][i][a])):(t[e].value="",t[e].setAttribute("data-value",""))}}),j.call(this,s.elements.dialogs.gamepad.querySelector(".".concat(ee.classNames["btn-clear"])),"click",function(e){let t={0:{},1:{},2:{},3:{}};for(var n in i)t[0][n]={},t[1][n]={},t[2][n]={},t[3][n]={};ee.controllers=t,localStorage.setItem(oe.storage.key,JSON.stringify({controllers:ee.controllers}));let o=s.elements.dialogs.gamepad.querySelectorAll("input");for(let e=0;e<o.length;e++)o[e].value="",o[e].setAttribute("data-value","")}),Array.from(s.elements.dialogs.gamepad.querySelectorAll(".".concat(ee.classNames.tabs," li"))).forEach(function(n){j.call(s,n,"mousedown",function(e){G(s.elements.dialogs.gamepad.querySelectorAll(".".concat(ee.classNames.tabs," li")),ee.classNames.active,!1),G(n,ee.classNames.active,!0);var t=n.querySelector("a").getAttribute("aria-controls");return Array.from(s.elements.dialogs.gamepad.querySelectorAll(".".concat(ee.classNames["tabs-content"]," .").concat(ee.classNames["tabs-panel"]))).forEach(function(e){V(e,!0)}),V(s.elements.dialogs.gamepad.querySelector(".".concat(ee.classNames["tabs-content"]," #").concat(t)),!1),e.stopPropagation(),!1})}),B.call(s,s.elements.dialogs.gamepad.querySelector('[aria-controls="controls-0"]').parentNode,"mousedown");let c=s.elements.dialogs.gamepad.querySelector(".".concat(ee.classNames.overlay));j.call(s,c,"mousedown",function(e){V(c,!0),e.stopPropagation()}),Array.from(s.elements.dialogs.gamepad.querySelectorAll(".".concat(ee.classNames["button-container"]))).forEach(function(t){j.call(s,t,"mousedown",function(e){B.call(s,t.querySelector("a.".concat(ee.classNames.set)),e.type,!0,{})})}),Array.from(s.elements.dialogs.gamepad.querySelectorAll(".".concat(ee.classNames["tabs-panel"]," a.").concat(ee.classNames.set))).forEach(function(r){j.call(s,r,"mousedown",function(e){let t=r.parentNode.parentNode,n=t.getAttribute("data-id"),o=t.getAttribute("data-index"),i=t.getAttribute("data-label"),a=(V(c,!1),c.setAttribute("data-id",n),c.setAttribute("data-index",o),"[ ".concat(i," ]"));ee.gamepad.gamepads[o]&&n<16?a+='<br /><span style="font-size:12px">Gamepad:'.concat(ee.gamepad.gamepads[o].id,"</span><br />"+s.localization("Press keyboard or gamepad")+"<br/>"+s.localization("Press escape (esc) to clear")):a+="<br />Press keyboard<br/>"+s.localization("Press escape (esc) to clear"),c.querySelector(".".concat(ee.classNames["key-setting-popup"])).innerHTML=a,e.stopPropagation()})})},setCacheDialog:function(){let t=this;t.elements.dialogs.cache.innerHTML='\n <div class="'+ee.classNames["dialog-container"]+'">\n <div class="'+ee.classNames["dialog-title"]+'">\n <h4>'+t.localization("Cache Manager")+'</h4>\n </div>\n <div class="'+ee.classNames["dialog-content"]+'">\n\n </div>\n <div class="'+ee.classNames["dialog-buttons"]+'">\n <a href="#" onclick="return false" class="'+ee.classNames["btn-clear-all"]+'">'+t.localization("Clear All")+'</a>\n <a href="#" onclick="return false" class="'+ee.classNames["btn-cancel"]+'">'+t.localization("Close")+"</a>\n </div>\n </div>\n ",j.call(this,t.elements.dialogs.cache.querySelector(".".concat(ee.classNames["btn-cancel"])),"click",function(e){return V(t.elements.dialogs.cache,!0),t.elements.container.focus(),e.stopPropagation(),!1}),j.call(this,t.elements.dialogs.cache.querySelector(".".concat(ee.classNames["btn-clear-all"])),"click",function(e){return m.romdb&&(m.romdb.clear(),t.elements.dialogs.cache.querySelector(".".concat(ee.classNames["dialog-content"])).innerHTML='<div style="text-align:center">'+t.localization("Empty")+"</div>"),_0x46992d.stopPropagation(),!1}),j.call(this,t.elements.dialogs.cache.querySelector(".".concat(ee.classNames["dialog-title"]," a")),"click",function(e){return m.romdb&&(m.romdb.clear(),t.elements.dialogs.cache.querySelector(".".concat(ee.classNames["dialog-content"])).innerHTML='<div style="text-align:center">'+t.localization("Empty")+"</div>"),e.stopPropagation(),!1})},showLoading:function(e){g.show("modal-6ed698f3d04061f5",{closeByEsckey:!1}),e&&console.log(""),V(this.elements.dialogs.loading,!1)},hideLoading:function(){g.close(),V(this.elements.dialogs.loading,!0)},setLoadingDialog:function(){this.elements.dialogs.loading&&(this.elements.dialogs.loading.innerHTML='\n <div class="'.concat(ee.classNames.modal," ").concat(ee.classNames["micromodal-slide"],'" id="modal-6ed698f3d04061f5" aria-hidden="true">\n <div class="').concat(ee.classNames.modal__overlay,'" tabindex="-1">\n <div class="').concat(ee.classNames.modal__container,'" role="dialog" aria-modal="true" aria-labelledby="modal-6ed698f3d04061f5-title">\n '+this.localization("Loading")+"...\n </div>\n </div>\n </div>"))},setCheatDialog:function(){let r=this;if(r.elements.dialogs.cheat){r.elements.dialogs.cheat.innerHTML='\n <div class="'.concat(ee.classNames["dialog-container"],'">\n <div class="').concat(ee.classNames["dialog-title"],'">\n <h4>Cheats</h4>\n </div>\n <div class="').concat(ee.classNames["dialog-content"],'">\n <div class="').concat(ee.classNames["cheats-list"],'">\n \n </div>\n </div>\n <div class="').concat(ee.classNames["dialog-buttons"],'">\n <a href="#" onclick="return false" class="').concat(ee.classNames["cheats-add"],'">'+r.localization("Add Cheat")+'</a>\n <a href="#" onclick="return false" class="').concat(ee.classNames["btn-cancel"],'">Close</a>\n </div>\n </div>\n\n \n\n <div class="').concat(ee.classNames.modal," ").concat(ee.classNames["micromodal-slide"],'" id="modal-85cd7a1c543a484b" aria-hidden="true">\n <div class="').concat(ee.classNames.modal__overlay,'" tabindex="-1" data-modal-close>\n <div class="').concat(ee.classNames.modal__container,'" style="width:100%" role="dialog" aria-modal="true" aria-labelledby="modal-85cd7a1c543a484b-title">\n <div class="').concat(ee.classNames.modal__header,'">\n <h2 class="').concat(ee.classNames.modal__title,'" id="modal-85cd7a1c543a484b-title">\n '+r.localization("Add Cheat Code")+'\n </h2>\n <button class="').concat(ee.classNames.modal__close,'" aria-label="Close modal" data-modal-close></button>\n </div>\n <main class="').concat(ee.classNames.modal__content,'" id="modal-85cd7a1c543a484b-content">\n\n <div class="').concat(ee.classNames.modal__errmsg,'"></div>\n <strong>'+r.localization("Code")+'</strong><br />\n <textarea style="width:100%;height:80px;" class="').concat(ee.classNames["cheat-code-input"],'"></textarea><br />\n <strong>'+r.localization("Description")+'</strong><br />\n <input type="text" class="').concat(ee.classNames["cheat-name-input"],'" /><br />\n\n </main>\n <footer class="').concat(ee.classNames.modal__footer,'">\n <button class="').concat(ee.classNames.modal__btn," ").concat(ee.classNames["modal__btn-primary"],'">'+r.localization("Submit")+'</button>\n <button class="').concat(ee.classNames.modal__btn,'" data-modal-close aria-label="Close">'+r.localization("Close")+"</button>\n </footer>\n </div>\n </div>\n </div>\n ");let i=r.elements.dialogs.cheat.querySelector("#modal-85cd7a1c543a484b"),a=(j.call(this,r.elements.dialogs.cheat.querySelector(".".concat(ee.classNames["cheats-add"])),"click",function(e){return g.show("modal-85cd7a1c543a484b",{closeTrigger:"data-modal-close"}),!1}),r.elements.dialogs.cheat.querySelector(".".concat(ee.classNames["cheats-list"]))),o=(j.call(this,i.querySelector(".".concat(ee.classNames["modal__btn-primary"])),"click",function(e){var t=i.querySelector(".".concat(ee.classNames["cheat-name-input"])).value,n=i.querySelector(".".concat(ee.classNames["cheat-code-input"])).value;if(t&&n){let e=a.querySelectorAll("input:checked");i.querySelector(".".concat(ee.classNames["cheat-name-input"])).value="",i.querySelector(".".concat(ee.classNames["cheat-code-input"])).value="",g.close();var o=r.cheats.length;r.cheats.push([t,n]),a.innerHTML+='<div class="'.concat(ee.classNames["ejs-switch"],'">\n <input type="checkbox" value="').concat(o,'" id="ejs-cheat-switch-').concat(o,'">\n <label for="ejs-cheat-switch-').concat(o,'">').concat(t,'</label>\n <a href="#" data-idx="').concat(o,'" onclick="return false" class="').concat(ee.classNames["ejs-delete-cheat"],'">&times;</a>\n </div>'),e.forEach(function(e,t){a.querySelector("#ejs-cheat-switch-".concat(t)).setAttribute("checked","checked")})}return"localStorage"in window&&r.getStartName()&&(localStorage.setItem("".concat(r.system,"-").concat(r.getStartName(),"-cheats"),JSON.stringify(r.cheats)),e.stopPropagation()),!1}),function(){if("localStorage"in window&&r.getStartName()){let e=localStorage.getItem("".concat(r.system,"-").concat(r.getStartName(),"-cheats"));try{e=JSON.parse(e)}catch(e){}e&&(r.cheats=e)}a.innerHTML="",r.cheats&&Array.isArray(r.cheats)&&r.cheats.forEach(function(e,t){var n=e[0];e[1],a.innerHTML+='<div class="'.concat(ee.classNames["ejs-switch"],'">\n <input type="checkbox" value="').concat(t,'" id="ejs-cheat-switch-').concat(t,'">\n <label for="ejs-cheat-switch-').concat(t,'">').concat(n,'</label>\n <a href="#" data-idx="').concat(t,'" onclick="return false" class="').concat(ee.classNames["ejs-delete-cheat"],'">&times;</a>\n </div>')})});j.call(r,a,"click",function(e){if(e.target&&e.target.classList.contains(ee.classNames["ejs-delete-cheat"])&&e.target.getAttribute("data-idx")){var t=e.target.getAttribute("data-idx");r.cheats.splice(t,1),"localStorage"in window&&r.getStartName()&&localStorage.setItem("".concat(r.system,"-").concat(r.getStartName(),"-cheats"),JSON.stringify(r.cheats));let n=[];a.querySelectorAll("input").forEach(function(e,t){n[t]=!!a.querySelector("#ejs-cheat-switch-".concat(t,":checked"))}),n.splice(t,1),o(),n.forEach(function(e,t){e&&a.querySelector("#ejs-cheat-switch-".concat(t)).setAttribute("checked","checked")})}return e.stopPropagation(),!1}),j.call(r,r.elements.container,"start-game",function(e){o()}),j.call(this,r.elements.dialogs.cheat.querySelector(".".concat(ee.classNames["btn-cancel"])),"click",function(e){return ee.resetCheat(),a.querySelectorAll("input:checked").forEach(function(e,t){e=r.cheats[e.value];e&&ee.setCheat(t,1,e[1])}),V(r.elements.dialogs.cheat,!0),r.elements.container.focus(),!1}),"arcade"!==getSystem(r.system,!0)&&"mame"!==getSystem(r.system,!0)&&"mame2003"!==getSystem(r.system,!0)&&"mame2010"!==getSystem(r.system,!0)||(U.element(r.elements.buttons.cheat)&&V(r.elements.buttons.cheat,!0),ee.allowCheat=!1),ee.setCheat||(V(r.elements.buttons.cheat,!0),ee.allowCheat=!1)}},setNetplayDialog:function(){var n,a,o,i,s,c,l,d,e,r,u,f,p=this,h=this;h.elements.dialogs.netplay&&(h.elements.dialogs.netplay.innerHTML='\n <div class="'.concat(ee.classNames["dialog-container"],'">\n <div class="').concat(ee.classNames["dialog-title"],'">\n <h4>'+h.localization("Netplay")+'</h4>\n </div>\n <div class="').concat(ee.classNames["dialog-content"],'">\n <div class="').concat(ee.classNames["netplay-roomlist"],'" hidden>\n <strong>'+h.localization("Rooms")+'</strong>\n <table style="width:100%" cellspacing=0>\n <thead>\n <tr>\n <td>'+h.localization("Room Name")+"</td>\n <td>"+h.localization("Players")+'</td>\n <td></td>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td></td>\n <td></td>\n <td></td>\n </tr>\n </tbody>\n </table>\n </div>\n\n <div class="').concat(ee.classNames["netplay-room"],'" hidden>\n <strong>'+h.localization("Room Name")+"</strong>\n <div data-room-password>"+h.localization("Password")+': <span></span></div>\n <table style="width:100%" cellspacing="0">\n <thead>\n <tr>\n <td>'+h.localization("Player")+"</td>\n <td>"+h.localization("Name")+"</td>\n <td></td>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>1</td>\n <td>"+h.localization("Name")+" 1</td>\n <td></td>\n </tr>\n <tr>\n <td>2</td>\n <td>"+h.localization("Name")+" 2</td>\n <td></td>\n </tr>\n <tr>\n <td>3</td>\n <td>"+h.localization("Name")+" 3</td>\n <td></td>\n </tr>\n <tr>\n <td>4</td>\n <td>"+h.localization("Name")+' 4</td>\n <td></td>\n </tr>\n </tbody>\n </table>\n </div>\n </div>\n <div class="').concat(ee.classNames["dialog-buttons"],'">\n <a href="#" onclick="return false" class="').concat(ee.classNames["btn-quit"],'">'+h.localization("Quit Room")+'</a>\n <a href="#" onclick="return false" class="').concat(ee.classNames["btn-create-room"],'">'+h.localization("Create a Room")+'</a>\n <a href="#" onclick="return false" class="').concat(ee.classNames["btn-cancel"],'">'+h.localization("Close")+'</a>\n </div>\n </div>\n\n \n <div class="').concat(ee.classNames.modal," ").concat(ee.classNames["micromodal-slide"],'" id="modal-9de6c4e9ce2b9361" aria-hidden="true">\n <div class="').concat(ee.classNames.modal__overlay,'" tabindex="-1">\n <div class="').concat(ee.classNames.modal__container,'" role="dialog" aria-modal="true" aria-labelledby="modal-9de6c4e9ce2b9361-title">\n <div class="').concat(ee.classNames.modal__header,'">\n <h2 class="').concat(ee.classNames.modal__title,'" id="modal-9de6c4e9ce2b9361-title">\n '+h.localization("Set Player Name")+'\n </h2>\n </div>\n <main class="').concat(ee.classNames.modal__content,'" id="modal-9de6c4e9ce2b9361-content">\n\n <div class="').concat(ee.classNames.modal__errmsg,'"></div>\n <strong>'+h.localization("Player Name")+'</strong><br />\n <input type="text" maxlength="10" class="').concat(ee.classNames["netplay-player-name"],'" /><br />\n\n </main>\n <footer class="').concat(ee.classNames.modal__footer,'">\n <button class="').concat(ee.classNames.modal__btn," ").concat(ee.classNames["modal__btn-primary"],'">'+h.localization("Submit")+'</button>\n </footer>\n </div>\n </div>\n </div>\n \n <div class="').concat(ee.classNames.modal," ").concat(ee.classNames["micromodal-slide"],'" id="modal-85cd7a1c543a484a" aria-hidden="true">\n <div class="').concat(ee.classNames.modal__overlay,'" tabindex="-1" data-modal-close>\n <div class="').concat(ee.classNames.modal__container,'" role="dialog" aria-modal="true" aria-labelledby="modal-85cd7a1c543a484a-title">\n <div class="').concat(ee.classNames.modal__header,'">\n <h2 class="').concat(ee.classNames.modal__title,'" id="modal-85cd7a1c543a484a-title">\n '+h.localization("Create a Room")+'\n </h2>\n <button class="').concat(ee.classNames.modal__close,'" aria-label="Close modal" data-modal-close></button>\n </div>\n <main class="').concat(ee.classNames.modal__content,'" id="modal-85cd7a1c543a484a-content">\n\n <div class="').concat(ee.classNames.modal__errmsg,'"></div>\n <strong>'+h.localization("Room Name")+'</strong><br />\n <input type="text" maxlength="10" class="').concat(ee.classNames["netplay-room-name-input"],'" /><br />\n <strong>Max Players</strong><br />\n <select data-max-players>\n <option value="2">2</option>\n <option value="3">3</option>\n <option value="4">4</option>\n </select>\n <br />\n <strong>'+h.localization("Password (optional)")+'</strong><br />\n <input type="text" maxlength="10" class="').concat(ee.classNames["netplay-room-password-input"],'" /><br />\n\n </main>\n <footer class="').concat(ee.classNames.modal__footer,'">\n <button class="').concat(ee.classNames.modal__btn," ").concat(ee.classNames["modal__btn-primary"],'">'+h.localization("Submit")+'</button>\n <button class="').concat(ee.classNames.modal__btn,'" data-modal-close aria-label="Close">'+h.localization("Close")+'</button>\n </footer>\n </div>\n </div>\n </div>\n \n <div class="').concat(ee.classNames.modal," ").concat(ee.classNames["micromodal-slide"],'" id="modal-5aa765d61d8327de" aria-hidden="true">\n <div class="').concat(ee.classNames.modal__overlay,'" tabindex="-1" data-modal-close>\n <div class="').concat(ee.classNames.modal__container,'" role="dialog" aria-modal="true" aria-labelledby="modal-5aa765d61d8327de-title">\n <div class="').concat(ee.classNames.modal__header,'">\n <h2 class="').concat(ee.classNames.modal__title,'" id="modal-5aa765d61d8327de-title">\n '+h.localization("Password")+'\n </h2>\n <button class="').concat(ee.classNames.modal__close,'" aria-label="Close modal" data-modal-close></button>\n </div>\n <main class="').concat(ee.classNames.modal__content,'" id="modal-5aa765d61d8327de-content">\n\n <div class="').concat(ee.classNames.modal__errmsg,'"></div>\n <input type="text" maxlength="10" class="').concat(ee.classNames["netplay-room-password-input"],'" /><br />\n\n </main>\n <footer class="').concat(ee.classNames.modal__footer,'">\n <button class="').concat(ee.classNames.modal__btn," ").concat(ee.classNames["modal__btn-primary"],'">'+h.localization("Submit")+'</button>\n <button class="').concat(ee.classNames.modal__btn,'" data-modal-close aria-label="Close">'+h.localization("Close")+'</button>\n </footer>\n </div>\n </div>\n </div>\n \n \n <div class="').concat(ee.classNames.modal," ").concat(ee.classNames["micromodal-slide"],'" id="modal-7d8fd50ed642340b" aria-hidden="true">\n <div class="').concat(ee.classNames.modal__overlay,'" tabindex="-1" data-modal-close>\n <div class="').concat(ee.classNames.modal__container,'" role="dialog" aria-modal="true" aria-labelledby="modal-7d8fd50ed642340b-title">\n <div class="').concat(ee.classNames.modal__header,'">\n <h2 class="').concat(ee.classNames.modal__title,'" id="modal-7d8fd50ed642340b-title"></h2>\n <button class="').concat(ee.classNames.modal__close,'" aria-label="Close modal" data-modal-close></button>\n </div>\n <main class="').concat(ee.classNames.modal__content,'" id="modal-7d8fd50ed642340b-content">\n \n </main>\n <footer class="').concat(ee.classNames.modal__footer,'">\n <button class="').concat(ee.classNames.modal__btn," ").concat(ee.classNames["modal__btn-primary"],'" data-modal-close>OK</button>\n </footer>\n </div>\n </div>\n </div>\n \n '),j.call(this,h.elements.dialogs.netplay.querySelector(".".concat(ee.classNames["btn-cancel"])),"click",function(e){return V(h.elements.dialogs.netplay,!0),ee.disableControl(!1),ee.stopLoadRooms(),e.stopPropagation(),h.elements.container.focus(),!1}),window.setInterval(function(){var o="<ul>";ee.players.forEach(function(e,t){var n=null;e?(ee.connection.peers[e]?n=ee.connection.peers[e].extra:ee.connection.userid===e&&(n=ee.connection.extra),o+="<li>".concat(t+1,". ").concat(n.name,"</li>")):o+="<li>".concat(t+1,". </li>")}),o+="</ul>",h.elements.widgets.netplay.innerHTML=o},500),n=h.elements.dialogs.netplay.querySelector("#modal-9de6c4e9ce2b9361"),a=h.elements.dialogs.netplay.querySelector("#modal-85cd7a1c543a484a"),o=h.elements.dialogs.netplay.querySelector("#modal-7d8fd50ed642340b"),i=h.elements.dialogs.netplay.querySelector("#modal-5aa765d61d8327de"),s={},ee.connection=new Be.a,(e=p.socketUrl).endsWith("/")||(e+="/"),ee.connection.socketURL="/",ee.connection.socketURL=e,ee.connection.socketMessageEvent="emulatorjs-message",ee.connection.socketCustomEvent="emulatorjs-custom-message",e=W.info(),ee.connection.extra={name:ee.playerName,game_id:h.config.gameId,browser_name:e.name,room_name:" ",domain:document.domain},ee.connection.socketMessageEvent="netplay",ee.connection.enableFileSharing=!0,ee.connection.enableLogs=!0,ee.connection.session={data:!0},ee.connection.coreVer=h.coreVer,ee.connection.sdpConstraints.mandatory={OfferToReceiveAudio:!1,OfferToReceiveVideo:!1},ee.connection.onclose=function(){},ee.connection.iceServers=window.EJS_TURN_URLS,ee.connection.maxParticipantsAllowed=4,c=ee.netPlayInitFrame=0,l=!1,Module.postMainLoop=function(){var e,t;if(ee.currentFrame=parseInt(ee.currentFrameNum(),10),ee.connected)if(c+=1,ee.connection.isInitiator)if(1<=c){for(var n=[],o=ee.currentFrame-1;o<ee.currentFrame;o+=1)ee.inputsData[o]?ee.inputsData[o].forEach(function(e,t){n.push("".concat(e.index,"|").concat(e.key,"|").concat(e.status,"|").concat(e.frame))}):n.push("-1|||".concat(o));ee.connection.send(JSON.stringify({act:"sync-control",value:n})),c=0,ee.currentFrame%100==0&&Object.keys(ee.inputsData).forEach(function(e,t){e<ee.currentFrame-50&&(ee.inputsData[e]=null,delete ee.inputsData[e])});return}else return;else{if(ee.coreOptionData[ee.currentFrame]&&(e=ee.coreOptionData[ee.currentFrame].key,t=ee.coreOptionData[ee.currentFrame].value,oe.updateCoreOptions.call(h,e,t),delete ee.coreOptionData[ee.currentFrame]),ee.currentFrame<=0||ee.inputsData[ee.currentFrame])ee.wait=!1,ee.systemPause(0),m.Module.resumeMainLoop(),e=ee.inputsData[ee.currentFrame],ee.inputsData[ee.currentFrame]=null,delete ee.inputsData[ee.currentFrame],(e=e||[]).forEach(function(e,t){0<=e.index&&ee.simulateInputFn(e.index,e.key,e.status)});else{ee.wait=!0,ee.systemPause(1),m.Module.pauseMainLoop();var i=!1,a=Object.keys(ee.inputsData);0==a.length&&(i=!0);for(var r=0;r<a.length;r+=1)if(a[r]>ee.currentFrame){console.log("lost",ee.currentFrame),i=!0;break}i?ee.wait||(!l||l<(new Date).valueOf()-3e3)&&(ee.inputsData={},l=(new Date).valueOf(),ee.connection.send(JSON.stringify({act:"sync-mem",value:ee.connection.userid}),ee.roomMaster)):(ee.wait=!0,ee.systemPause(1),m.Module.pauseMainLoop())}ee.currentFrame%100==0&&Object.keys(ee.inputsData).forEach(function(e,t){e<ee.currentFrame-50&&(ee.inputsData[e]=null,delete ee.inputsData[e])})}},ee.connection.onopen=function(n){ee.connected=!0,ee.connection.isInitiator&&(-1===ee.players.indexOf(n.userid)&&(0<ee.players.filter(function(e,t){return null==e}).length?ee.players.forEach(function(e,t){null!=e||ee.players.includes(n.userid)||(ee.players[t]=n.userid)}):ee.players.push(n.userid)),ee.connection.send(JSON.stringify({act:"get-players-result",value:ee.players,coreOptions:oe.coreOptionsValues,newuser:n.userid,master:ee.connection.userid}))),oe.updateCoreOptionMenuItems.call(h)},ee.connection.onFileStart=function(e){var t=e.name.split("-");"reset"!==t[0]&&0!=t[0]||(ee.inputsData={},ee.disableControl(!0)),ee.progressHelper[e.remoteUserId]={},ee.progressHelper[e.remoteUserId].max=e.maxChunks,ee.showLoading.call(h),ee.connection.isInitiator?(ee.wait=!0,ee.systemPause(1),m.Module.pauseMainLoop()):ee.inputsData={}},ee.connection.onFileProgress=function(e){var t=ee.progressHelper[e.remoteUserId];t.current=e.currentPosition||e.maxChunks||t.max},d=!(ee.connection.onFileEnd=function(e){ee.hideLoading.call(h);var t=e.name.split("-"),n=t[0]>>0;"reset"===t[0]?(n=0,ee.connection.isInitiator?(ee.systemPause(0),ee.disableControl(!1),h.playing=!0,m.Module.resumeMainLoop()):J.a.get(e.url,{responseType:"arraybuffer"}).then(function(e){ee.inputsData={};e=new Uint8Array(e.data);ee.loadState(e,n),ee.wait=!1,ee.systemPause(0),ee.disableInput=!1,h.playing=!0,m.Module.resumeMainLoop()})):"game.state"===t[1]&&(ee.connection.isInitiator?(ee.openRoom(h),ee.wait=!1,ee.systemPause(0),m.Module.resumeMainLoop()):(ee.netPlayInitFrame=n,J.a.get(e.url,{responseType:"arraybuffer"}).then(function(e){e=new Uint8Array(e.data);ee.loadState(e,n),ee.wait=!1,ee.disableInput=!1,ee.connection.send(JSON.stringify({act:"wait-end",value:ee.connection.userid})),ee.hideLoading.call(h),h.playing=!0,m.Module.resumeMainLoop()}))),ee.connection.isInitiator||console.log("recv mem end",ee.currentFrame,e.name)}),ee.connection.onmessage=function(e){var t,r,n,o,e=e.data||e;try{t=JSON.parse(e)}catch(e){t=null}t&&("room-master"===t.act&&(ee.roomMaster=t.value),t.act,"short-pause"!==t.act||d||(ee.systemPause(1),m.Module.pauseMainLoop(),d=!0,ee.wait=!0,setTimeout(function(){ee.systemPause(0),m.Module.resumeMainLoop(),ee.wait=!1,d=!1},48)),"sync-control"===t.act&&(e=t.value,h.playing||ee.wait,r=ee.connection.userid,ee.players.indexOf(r),ee.connection.isInitiator,e.forEach(function(e,t){var e=e.split("|"),n=e[0]>>0,o=e[1]>>0,i=e[2]>>0,e=e[3]>>0,a=ee.currentFrame;ee.inputsData[e]||(ee.inputsData[e]=[]),-1!=n&&e===a&&ee.simulateInputFn(n,o,i),ee.connection.isInitiator?0<=n&&(ee.inputsData[a]||(ee.inputsData[a]=[]),-2!=o&&(ee.inputsData[a].push({index:n,key:o,status:i,frame:a}),ee.simulateInputFn(n,o,i)),d||e<=a-10&&(ee.systemPause(1),m.Module.pauseMainLoop(),d=!0,ee.wait=!0,setTimeout(function(){ee.systemPause(0),m.Module.resumeMainLoop(),ee.wait=!1,d=!1},48))):(""!==n&&ee.inputsData[e].push({index:n,key:o,status:i,frame:e}),ee.inputsData[ee.currentFrame]&&m.Module.resumeMainLoop(),a+10<=e&&e>ee.netPlayInitFrame+100&&ee.connection.send(JSON.stringify({act:"short-pause",value:r}),ee.roomMaster))})),t.act,t.act,"update-core-option"!==t.act||ee.connection.isInitiator||(ee.coreOptionData[t.frame]={key:t.key,value:t.value}),"restart-game"===t.act&&(ee.inputsData={},ee.connection.send(JSON.stringify({act:"sync-mem",value:ee.connection.userid}),ee.roomMaster)),"pause"===t.act&&m.Module.pauseMainLoop(),"resume"===t.act&&m.Module.resumeMainLoop(),"wait"===t.act&&(ee.wait=!0,ee.systemPause(1),t.value!==ee.connection.userid&&(ee.waitingList[t.value]=1),ee.disableControl(!0)),"wait-end"===t.act&&(ee.waitingList[t.value]&&delete ee.waitingList[t.value],0===Object.keys(ee.waitingList).length&&(ee.wait=!1,ee.systemPause(0),ee.disableInput=!1)),"sync-mem"===t.act&&(ee.wait=!0,ee.systemPause(1),n=t.value,ee.disableControl(!0),ee.connection.send(JSON.stringify({act:"wait",value:n})),(async()=>{var e=await ee.saveState(),e=(m.FS.createDataFile("/","game.state",e,!0,!0),m.Module.cwrap("load_state","number",["string","number"])("game.state",0),ee.inputsData={},new File([e],"0-game.state",{type:"",lastModified:new Date}));ee.connection.shareFile(e,n)})()),t.act,"get-players-result"===t.act&&(ee.players=t.value,ee.roomMaster=t.master,t.newuser===ee.connection.userid)&&(o=oe.coreOptionsValues,t.coreOptions&&Object.keys(t.coreOptions).forEach(function(e){o[e]!==t.coreOptions[e]&&oe.updateCoreOptions.call(h,e,t.coreOptions[e])}),ee.showLoading.call(h),ee.disableControl(!0),setTimeout(function(){ee.connection.send(JSON.stringify({act:"sync-mem",value:ee.connection.userid}),ee.roomMaster)},1),ee.roomMaster&&ee.connection.peers[ee.roomMaster]&&(ee.connection.extra.room_name=ee.connection.peers[ee.roomMaster].extra.room_name,ee.connection.updateExtraData()),ee.connection.peers[ee.roomMaster]&&(s=ee.connection.peers[ee.roomMaster].extra),ee.openRoom(h)))},ee.connection.onUserStatusChanged=function(e){var t;"offline"===e.status&&0<=(t=ee.players.indexOf(e.userid))&&(ee.players[t]=null),e.status},ee.connection.onExtraDataUpdated=function(e){e.userid===ee.connection.userid&&(ee.connection.extra=e.extra)},ee.connection.onleave=function(e){var t;e.userid&&0<=(t=ee.players.indexOf(e.userid))&&(ee.players[t]=null),ee.waitingList[e.userid]&&delete ee.waitingList[e.userid],ee.connection.isInitiator&&0===Object.keys(ee.waitingList).length&&ee.wait&&(ee.wait=!1,ee.systemPause(0),ee.disableInput=!1,ee.connection.send(JSON.stringify({act:"wait-end",value:ee.connection.userid}))),ee.openRoom(h),ee.inputsData={},ee.hideLoading.call(h)},e=function(){try{ee.connection.onbeforeunload()}catch(e){}ee.connected=!1,ee.connection.password=null,ee.players=[],ee.connection.peersBackup=[],ee.waitingList={},ee.inputsData={},ee.hideLoading.call(h),V(h.elements.buttons.restart,!1),V(h.elements.buttons.loadState,!1),V(h.elements.buttons.saveState,!1),ee.allowCheat&&V(h.elements.buttons.cheat,!1),V(oe.contextMenu.querySelectorAll("ul li").item(2),!1),V(oe.contextMenu.querySelectorAll("ul li").item(3),!1),Array.from(h.elements.buttons.play).forEach(function(e){V(e,!1)}),oe.updateCoreOptionMenuItems.call(h)},ee.connection.close=e,ee.connection.disconnect=e,ee.connection.leave=e,u=function(e,t,n){ee.hideLoading.call(h),e?(ee.stopLoadRooms(),V(h.elements.buttons.restart,!0),V(h.elements.buttons.loadState,!0),V(h.elements.buttons.saveState,!0),ee.resetCheat(),V(h.elements.buttons.cheat,!0),V(oe.contextMenu.querySelectorAll("ul li").item(2),!0),V(oe.contextMenu.querySelectorAll("ul li").item(3),!0),Array.from(h.elements.buttons.play).forEach(function(e){V(e,!0)}),ee.connection.socket&&ee.connection.socket.on("set-isInitiator-true",function(e){e===ee.connection.sessionid&&(ee.connection.socket.emit("extra-data-updated",ee.connection.extra),ee.connection.send(JSON.stringify({act:"room-master",value:ee.connection.userid})),ee.roomMaster=ee.connection.userid,ee.systemPause(0),m.Module.resumeMainLoop(),oe.updateCoreOptionMenuItems.call(h),V(h.elements.buttons.restart,!1),V(h.elements.buttons.loadState,!1),V(h.elements.buttons.saveState,!1),Array.from(h.elements.buttons.play).forEach(function(e){V(e,!1)}))})):(g.close(),o.querySelector("#modal-7d8fd50ed642340b-content").innerHTML=n,g.show("modal-7d8fd50ed642340b",{closeTrigger:"data-modal-close"}))},f=function(e){if(null===window.EJS_TURN_URLS||!window.EJS_TURN_URLS||0===window.EJS_TURN_URLS.length)return o.querySelector("#modal-7d8fd50ed642340b-content").innerHTML=null===window.EJS_TURN_URLS||0===window.EJS_TURN_URLS.length?"Netplay Currently Unavailable":"Netplay initializing",void g.show("modal-7d8fd50ed642340b",{closeTrigger:"data-modal-close"});ee.connection.iceServers=window.EJS_TURN_URLS;var t=e.target.getAttribute("data-id");if("Y"===e.target.getAttribute("data-password"))g.show("modal-5aa765d61d8327de",{closeTrigger:"data-modal-close"}),i.setAttribute("data-id",t);else{ee.showLoading.call(h),ee.connection.userid=ee.connection.token();try{ee.connection.join(t,u)}catch(e){ee.hideLoading.call(h),o.querySelector("#modal-7d8fd50ed642340b-content").innerHTML="Error",g.show("modal-7d8fd50ed642340b",{closeTrigger:"data-modal-close"})}}return e.stopPropagation(),!1},ee.loadRoomsList=function(){V(h.elements.dialogs.netplay.querySelector(".".concat(ee.classNames["netplay-roomlist"])),!1),V(h.elements.dialogs.netplay.querySelector(".".concat(ee.classNames["netplay-room"])),!0),V(h.elements.dialogs.netplay.querySelector(".".concat(ee.classNames["btn-create-room"])),!1),V(h.elements.dialogs.netplay.querySelector(".".concat(ee.classNames["btn-quit"])),!0);var e=h.listUrl,c=(e.endsWith("/")||(e+="/"),h.elements.dialogs.netplay.querySelector(".".concat(ee.classNames["netplay-roomlist"])).querySelector("tbody")),e=[e,"list?game_id=",h.config.gameId,"&domain=",window.location.hostname,"&coreVer=",h.coreVer].join("");J.a.get(e,{}).then(function(a){var r,s;a.data&&(r=[],s=[],c.querySelectorAll("tr").forEach(function(e){s.push(e.getAttribute("id"))}),Object.keys(a.data).forEach(function(e){var t=a.data[e],n=(r.push(e),s.includes(e)&&(n=c.querySelector('tr[id="'.concat(e,'"]')),c.removeChild(n)),document.createElement("tr")),o=(n.setAttribute("id",e),t.password?ee.icons.lock:""),i=t.password?"Y":"N",e=t.current<t.max?'<span data-id="'.concat(e,'" data-password="').concat(i,'" class="').concat(ee.classNames["btn-join-room"],'">Join</span>'):"",i=t.country||"?";n.innerHTML="<td>[".concat(i,"] ").concat(o," ").concat(t.room_name,"</td><td>").concat(t.current,"/").concat(t.max,"</td><td>").concat(e,"</td>"),j.call(p,n.querySelector(".".concat(ee.classNames["btn-join-room"])),"click",f),c.appendChild(n)}),c.querySelectorAll("tr").forEach(function(e){r.includes(e.id)||c.removeChild(e)})),ee.loadRoomsListTimer=setTimeout(ee.loadRoomsList,2e3)}).catch(function(e){console.log("Network Error",e),ee.loadRoomsListTimer=setTimeout(ee.loadRoomsList,2e3)})},ee.openRoom=function(e){ee.stopLoadRooms(),V(e.elements.dialogs.netplay.querySelector(".".concat(ee.classNames["netplay-roomlist"])),!0),V(e.elements.dialogs.netplay.querySelector(".".concat(ee.classNames["netplay-room"])),!1),V(e.elements.dialogs.netplay.querySelector(".".concat(ee.classNames["btn-create-room"])),!0),V(e.elements.dialogs.netplay.querySelector(".".concat(ee.classNames["btn-quit"])),!1),ee.resetCheat(),V(e.elements.buttons.cheat,!0);var e=e.elements.dialogs.netplay.querySelector(".".concat(ee.classNames["netplay-room"])),t=e.querySelector("[data-room-password]"),o=(null===ee.connection.password?V(t,!0):(V(t,!1),t.querySelector("span").innerText=ee.connection.password),e.querySelector("tbody"));o.innerHTML="",e.querySelector("strong").innerText=s.room_name,ee.players.forEach(function(e,t){var n=null;e&&(ee.connection.peers[e]?n=ee.connection.peers[e].extra:ee.connection.userid===e&&(n=ee.connection.extra),n&&n.name)&&((e=document.createElement("tr")).innerHTML="<td>".concat(t+1,"</td><td>").concat(n.name,"</td><td></td>"),o.appendChild(e))})},j.call(this,i.querySelector(".".concat(ee.classNames["modal__btn-primary"])),"click",function(e){var t=i.querySelector(".".concat(ee.classNames["netplay-room-password-input"])).value,t=(ee.showLoading.call(h),ee.connection.password=t,i.getAttribute("data-id"));ee.connection.join(t,function(e,t,n){u(e,0,n),e&&i.classList.remove(_0x449eac({"is-open":!0}))}),e.stopPropagation()}),j.call(this,n.querySelector(".".concat(ee.classNames["modal__btn-primary"])),"click",function(e){var t=(t=n.querySelector(".".concat(ee.classNames["netplay-player-name"])).value).replace(/<|>/g,"");n.querySelector(".".concat(ee.classNames.modal__errmsg)).innerHTML="",t.trim()&&(ee.playerName=t.trim(),ee.connection.extra.name=t.trim(),g.close()),e.stopPropagation()}),j.call(this,a.querySelector(".".concat(ee.classNames["modal__btn-primary"])),"click",function(e){var t=(t=a.querySelector(".".concat(ee.classNames["netplay-room-name-input"])).value).replace(/<|>/g,""),n=a.querySelector("select[data-max-players] option:checked").value;4<(n=n<2?2:n)&&(n=4);for(var o=0;o<n;o++)ee.players[o]=null;ee.connection.maxParticipantsAllowed=n;var i=a.querySelector(".".concat(ee.classNames["netplay-room-password-input"])).value;a.querySelector(".".concat(ee.classNames.modal__errmsg)).innerHTML="",t.trim()?(ee.connection.extra.room_name=t.trim(),""!==i.trim()&&(ee.connection.password=i.trim()),ee.showLoading.call(h),ee.connection.open(ee.connection.token(),function(e,t,n){ee.hideLoading.call(h),e?(ee.players[0]=ee.connection.userid,ee.roomMaster=ee.connection.userid,r.closeModal(),ee.stopLoadRooms(),s=ee.connection.extra,ee.openRoom(h),V(oe.contextMenu.querySelectorAll("ul li").item(2),!0),V(oe.contextMenu.querySelectorAll("ul li").item(3),!0)):a.querySelector(".".concat(ee.classNames.modal__errmsg)).innerHTML=n})):r.closeModal(),e.stopPropagation()}),j.call(this,h.elements.dialogs.netplay.querySelector(".".concat(ee.classNames["btn-create-room"])),"click",function(e){if(null!==window.EJS_TURN_URLS&&window.EJS_TURN_URLS&&0!==window.EJS_TURN_URLS.length)return ee.connection.iceServers=window.EJS_TURN_URLS,r=g.show("modal-85cd7a1c543a484a",{closeTrigger:"data-modal-close",onClose:function(){h.elements.container.focus()}}),e.stopPropagation(),!1;o.querySelector("#modal-7d8fd50ed642340b-content").innerHTML=null===window.EJS_TURN_URLS||0===window.EJS_TURN_URLS.length?"Netplay Currently Unavailable":"Netplay initializing",g.show("modal-7d8fd50ed642340b",{closeTrigger:"data-modal-close"})}),j.call(this,h.elements.dialogs.netplay.querySelector(".".concat(ee.classNames["btn-quit"])),"click",function(e){return ee.connection.close(),ee.stopLoadRooms(),ee.loadRoomsList(),ee.inputsData={},e.stopPropagation(),!1})),window._0x378b5c=ee},initKeyboard:function(){let t=this,i=this,a=this.elements.dialogs.gamepad.querySelector(".".concat(ee.classNames.overlay));j.call(this,document.body,"keydown keyup",function(o){if(!(112<=o.which&&o.which<=123)){let e=!t.elements.dialogs.gamepad.hidden&&!a.hidden,n="keydown"===o.type;if(n&&e){let e=a.getAttribute("data-index"),t=a.getAttribute("data-id"),n=null;if(o.key&&"escape"===ee.keyMap[o.keyCode])return(n=i.elements.dialogs.gamepad.querySelector('[data-id="'.concat(t,'"][data-index="').concat(e,'"][data-type="1"]'))).setAttribute("data-value",""),n.value=""(n=i.elements.dialogs.gamepad.querySelector('[data-id="'.concat(t,'"][data-index="').concat(e,'"][data-type="2"]'))).setAttribute("data-value",""),n.value="",void V(a,!0);e=a.getAttribute("data-index"),t=a.getAttribute("data-id"),n=null,o.key&&((n=i.elements.dialogs.gamepad.querySelector('[data-id="'.concat(t,'"][data-index="').concat(e,'"][data-type="1"]'))).setAttribute("data-value",o.keyCode),n.value=ee.keyMap[o.keyCode]),V(a,!0)}else Object.keys(ee.controllers).forEach(function(t){Object.keys(ee.controllers[t]).forEach(function(e){parseInt(ee.controllers[t][e].value,10)===o.keyCode&&["24","25","26"].includes(e)&&"keydown"==o.type&&!o.repeat&&("24"==e?ee.quickSaveState():"25"==e?ee.quickLoadState():"26"==e&&ee.changeStateSlot()),parseInt(ee.controllers[t][e].value,10)===o.keyCode&&(n?16<=e&&e<=23?ee.simulateInput(t,e,32767):ee.simulateInput(t,e,1):ee.simulateInput(t,e,0))})})}}),document.body.addEventListener("keydown",function(e){var t=e.keyCode||e.which;[32,37,38,39,40,112,113,114,115,116,117,118,119,120,121,122,123].includes(t)&&e.srcElement===i.elements.container&&e.preventDefault(),e.srcElement.className.split(/ +/).includes(ee.classNames.set)&&e.preventDefault()})},initGamepad:function(){let s=this,i=this,c=this.elements.dialogs.gamepad.querySelector(".".concat(ee.classNames.overlay)),n;try{n=new be}catch(e){return void console.warn("gamepad not supported")}(ee.gamepad=n).on("buttondown",function(n){if(s.elements.dialogs.gamepad.hidden||c.hidden)Object.keys(ee.controllers[n.gamepadIndex.toString()]).forEach(function(e){var t=n.gamepadIndex.toString();parseInt(ee.controllers[t][e].value2,10)===parseInt(n.index,10)&&["24","25","26"].includes(e)&&("24"==e?ee.quickSaveState():"25"==e?ee.quickLoadState():"26"==e&&ee.changeStateSlot()),parseInt(ee.controllers[t][e].value2,10)===parseInt(n.index,10)&&parseInt(t,10)===parseInt(n.gamepadIndex,10)&&ee.simulateInput(t,e,1)});else{var t=parseInt(c.getAttribute("data-index"),10),o=c.getAttribute("data-id");if(n.gamepadIndex===parseInt(t,10)){let e=null;(e=i.elements.dialogs.gamepad.querySelector('[data-id="'.concat(o,'"][data-index="').concat(t,'"][data-type="2"]'))).setAttribute("data-value",n.index),e.value="button ".concat(n.index+1),V(c,!0)}}}),n.on("buttonup",function(n){Object.keys(ee.controllers).forEach(function(t){Object.keys(ee.controllers[t]).forEach(function(e){parseInt(ee.controllers[t][e].value2,10)===parseInt(n.index,10)&&parseInt(t,10)===parseInt(n.gamepadIndex,10)&&ee.simulateInput(t,e,0)})})}),n.on("axischanged",function(n){var o=.5<(t=n.value)||t<-.5?0<t?1:-1:0;if(s.elements.dialogs.gamepad.hidden||c.hidden){ee.prevButtons||(ee.prevButtons={});let t=!1;var i=n.gamepadIndex.toString();ee.prevButtons[i]||(ee.prevButtons[i]={}),ee.prevButtons[i][n.axis]||(ee.prevButtons[i][n.axis]=0),ee.prevButtons[i].buttonID||(ee.prevButtons[i].buttonID=0);for(let e=0;e<Object.keys(ee.controllers[i]).length;e++){var a=Object.keys(ee.controllers[i])[e];ee.controllers[i][a].value2&&(ee.controllers[i][a].value2.split(":")[0]===n.axis&&parseInt(ee.controllers[i][a].value2.split(":")[1])===o&&["24","25","26"].includes(a)&&("24"==a?(t=!0,ee.quickSaveState()):"25"==a?(t=!0,ee.quickLoadState()):"26"==a&&ee.changeStateSlot()),0==o?ee.controllers[i][a].value2.split(":")[0]===n.axis&&(ee.prevButtons[i][n.axis]=o,ee.prevButtons[i].buttonID=a,ee.simulateInput(i,a,0)):((1===ee.prevButtons[i][n.axis]&&-1==o||-1===ee.prevButtons[i][n.axis]&&1==o)&&ee.simulateInput(i,ee.prevButtons[i].buttonID,0),ee.controllers[i][a].value2.split(":")[0]===n.axis&&parseInt(ee.controllers[i][a].value2.split(":")[1])===o&&(ee.prevButtons[i][n.axis]=o,ee.prevButtons[i].buttonID=a,t=!0,ee.simulateInput(i,a,1))))}if(t)return;if(!s.elements.dialogs.gamepad.hidden&&!c.hidden)return}else if(0!=o){var t=c.getAttribute("data-id"),r=parseInt(c.getAttribute("data-index"),10);let e=s.elements.dialogs.gamepad.querySelector('[data-id="'.concat(t,'"][data-index="').concat(r,'"][data-type="2"]'));e.setAttribute("data-value",n.axis+":"+o),e.value=n.axis+":"+o,V(c,!0)}Math.abs(n.value)<=.1&&(n.value=0);t=n.gamepadIndex;s.coreVer;"LEFT_STICK_X"===n.axis?0<n.value?(ee.simulateInput(t,16,32767*n.value),ee.simulateInput(t,17,0)):(ee.simulateInput(t,17,-32767*n.value),ee.simulateInput(t,16,0)):"LEFT_STICK_Y"===n.axis?0<n.value?(ee.simulateInput(t,18,32767*n.value),ee.simulateInput(t,19,0)):(ee.simulateInput(t,19,-32767*n.value),ee.simulateInput(t,18,0)):"RIGHT_STICK_X"===n.axis?0<n.value?(ee.simulateInput(t,20,32767*n.value),ee.simulateInput(t,21,0)):(ee.simulateInput(t,21,-32767*n.value),ee.simulateInput(t,20,0)):"RIGHT_STICK_Y"===n.axis&&(0<n.value?(ee.simulateInput(t,22,32767*n.value),ee.simulateInput(t,23,0)):(ee.simulateInput(t,23,32767*n.value),ee.simulateInput(t,22,0)))}),n.on("disconnected",function(e){[0,1,2,3].forEach(function(e){var t=n.gamepads[e];i.elements.dialogs.gamepad.querySelector("#controls-".concat(e," .gamepad-name")).innerHTML=t?t.id:"n/a"})}),n.on("connected",function(e){Object.keys(n.gamepads).forEach(function(e){var t=n.gamepads[e];i.elements.dialogs.gamepad.querySelector("#controls-".concat(e," .gamepad-name")).innerHTML=t?t.id:"n/a"})})},setShader:function(e){if("disabled"===e)m.FS.unlink("/shader/shader.glslp",""),ee.toggleShader&&ee.toggleShader(0);else{ee.toggleShader&&ee.toggleShader(0);e="/shader/".concat(e);try{m.FS.writeFile("/shader/shader.glslp",m.FS.readFile(e))}catch(e){}ee.toggleShader&&ee.toggleShader(1)}},toggleVirtualGamepad:function(e,t){let c=this;if(ee.virtualGamepadContainer&&!t)V(ee.virtualGamepadContainer,!e);else{ee.virtualGamepadContainer||(ee.virtualGamepadContainer=F("div",{class:H({"ejs-virtual-gamepad":!0}),hidden:""}),this.elements.container.appendChild(ee.virtualGamepadContainer));var l,d="";let o,i=(c.config.VirtualGamepadSettings&&function(t){if(Array.isArray(t)){if(t.length){for(let e=0;e<t.length;e++)if(t[e].type)try{if("zone"===t[e].type||"dpad"===t[e].type){if(!t[e].location)return void console.warn("Missing location value for "+t[e].type+"! Using default gamepad settings");if(t[e].inputValues)continue;return void console.warn("Missing inputValues for "+t[e].type+"! Using default gamepad settings")}if(!t[e].location)return void console.warn("Missing location value for button "+t[e].text+"! Using default gamepad settings");if(!t[e].type)return void console.warn("Missing type value for button "+t[e].text+"! Using default gamepad settings");if(!t[e].id.toString())return void console.warn("Missing id value for button "+t[e].text+"! Using default gamepad settings");if(!t[e].input_value.toString())return void console.warn("Missing input_value for button "+t[e].text+"! Using default gamepad settings")}catch(e){return void console.warn("Error checking values! Using default gamepad settings")}return 1}console.warn("Vritual gamepad settings is empty! Using default gamepad settings")}else console.warn("Vritual gamepad settings is not array! Using default gamepad settings")}(c.config.VirtualGamepadSettings)?o=c.config.VirtualGamepadSettings:["gba","gb","vb","nes"].includes(getSystem(c.system,!0))?(o=[{type:"button",text:"B",id:"b",location:"right",right:-10,top:70,bold:!0,input_value:0},{type:"button",text:"A",id:"a",location:"right",right:60,top:70,bold:!0,input_value:8},{type:"dpad",location:"left",left:"50%",right:"50%",joystickInput:!1,inputValues:[4,5,6,7]},{type:"button",text:"Start",id:"start",location:"center",left:60,fontSize:15,block:!0,input_value:3},{type:"button",text:"Select",id:"select",location:"center",left:-5,fontSize:15,block:!0,input_value:2}],"gba"===getSystem(c.system,!0)&&(o.push({type:"button",text:"L",id:"l",block:!0,location:"top",left:10,top:-40,bold:!0,input_value:10}),o.push({type:"button",text:"R",id:"r",block:!0,location:"top",right:10,top:-40,bold:!0,input_value:11}))):o="n64"===getSystem(c.system,!0)?[{type:"button",text:"B",id:"b",location:"right",left:-10,top:95,input_value:0,bold:!0,input_new_cores:1},{type:"button",text:"A",id:"a",location:"right",left:40,top:150,input_value:8,bold:!0,input_new_cores:0},{type:"zone",location:"left",left:"50%",top:"100%",joystickInput:!0,inputValues:[16,17,18,19]},{type:"zone",location:"left",left:"50%",top:"0%",joystickInput:!1,inputValues:[4,5,6,7]},{type:"button",text:"Start",id:"start",location:"center",left:30,top:-10,fontSize:15,block:!0,input_value:3},{type:"button",text:"L",id:"l",block:!0,location:"top",left:10,top:-40,bold:!0,input_value:10},{type:"button",text:"R",id:"r",block:!0,location:"top",right:10,top:-40,bold:!0,input_value:11},{type:"button",text:"Z",id:"z",block:!0,location:"top",left:10,bold:!0,input_value:12},{fontSize:20,type:"button",text:"CU",id:"cu",location:"right",left:25,top:-65,input_value:23},{fontSize:20,type:"button",text:"CD",id:"cd",location:"right",left:25,top:15,input_value:22},{fontSize:20,type:"button",text:"CL",id:"cl",location:"right",left:-15,top:-25,input_value:21},{fontSize:20,type:"button",text:"CR",id:"cr",location:"right",left:65,top:-25,input_value:20}]:["snes","nds"].includes(getSystem(c.system,!0))?[{type:"button",text:"X",id:"x",location:"right",left:40,bold:!0,input_value:9},{type:"button",text:"Y",id:"y",location:"right",top:40,bold:!0,input_value:1},{type:"button",text:"A",id:"a",location:"right",left:81,top:40,bold:!0,input_value:8},{type:"button",text:"B",id:"b",location:"right",left:40,top:80,bold:!0,input_value:0},{type:"zone",location:"left",left:"50%",top:"50%",joystickInput:!1,inputValues:[4,5,6,7]},{type:"button",text:"Start",id:"start",location:"center",left:60,fontSize:15,block:!0,input_value:3},{type:"button",text:"Select",id:"select",location:"center",left:-5,fontSize:15,block:!0,input_value:2}]:[{type:"button",text:"Y",id:"y",location:"right",left:40,bold:!0,input_value:9},{type:"button",text:"X",id:"X",location:"right",top:40,bold:!0,input_value:1},{type:"button",text:"B",id:"b",location:"right",left:81,top:40,bold:!0,input_value:8},{type:"button",text:"A",id:"a",location:"right",left:40,top:80,bold:!0,input_value:0},{type:"zone",location:"left",left:"50%",top:"50%",joystickInput:!1,inputValues:[4,5,6,7]},{type:"button",text:"Start",id:"start",location:"center",left:60,fontSize:15,block:!0,input_value:3},{type:"button",text:"Select",id:"select",location:"center",left:-5,fontSize:15,block:!0,input_value:2}],o=JSON.parse(JSON.stringify(o)),{top:"",left:"",center:"",right:""}),s=!1;oe&&"function"==typeof oe.getCoreOptionsValue&&(s="on"===oe.getCoreOptionsValue("left-handed-mode"));for(let n=0;n<o.length;n++)if("button"===o[n].type){let e={buttons:!0};s&&["left","right"].includes(o[n].location)&&(o[n].location="left"===o[n].location?"right":"left",(l=JSON.parse(JSON.stringify(o[n]))).left&&(o[n].right=l.left),l.right&&(o[n].left=l.right)),e["b_"+o[n].id.toLowerCase()]=!0;let t="";o[n].left&&(t+="left:"+o[n].left+("number"==typeof o[n].left?"px":"")+";"),o[n].right&&(t+="right:"+o[n].right+("number"==typeof o[n].right?"px":"")+";"),o[n].top&&(t+="top:"+o[n].top+("number"==typeof o[n].top?"px":"")+";"),o[n].bold?o[n].bold&&(t+="font-weight:bold;"):t+="font-weight:normal;",o[n].fontSize=o[n].fontSize||30,t+="font-size:"+o[n].fontSize+"px;",o[n].block&&(t+="height:31px;text-align:center;border:1px solid #ccc;border-radius:5px;line-height:31px;"),["top","center","left","right"].includes(o[n].location)&&(i[o[n].location]+='<div class="'+H(e)+'" style="'+t+'">'+o[n].text+"</div>")}d=(d=(d=(d=(d=(d=(d=(d=(d+='<div class="'+H({"virtual-gamepad":!0})+'" style="display: block;">')+('<div class="'+H({top:!0})+'">'))+i.top+"</div>")+('<div class="'+H({left:!0})+'">'))+i.left+"</div>")+('<div class="'+H({center:!0})+'">'))+i.center+"</div>")+('<div class="'+H({right:!0})+'">'))+i.right+"</div></div>",ee.virtualGamepadContainer.innerHTML=d,V(ee.virtualGamepadContainer,!e);let n=H({"virtual-gamepad":!0}),a=H({touch:!0}),r=(W.isIos||j.call(this,q.call(this,".".concat(n)),"touchmove",function(e){e.stopPropagation()}),o.forEach((i,n)=>{if("dpad"===i.type){let e={};var o;s&&["left","right"].includes(i.location)&&(i.location="left"===i.location?"right":"left",(o=JSON.parse(JSON.stringify(i))).left&&(i.right=o.left),o.right&&(i.left=o.right)),e[i.location.toLowerCase()]=!0;const a=q.call(this,".".concat(H({"ejs-virtual-gamepad":!0})," .").concat(H(e))),r=(e["dpad_"+n]=!0,F("div",{class:".".concat(H({"ejs-virtual-gamepad":!0,"dpad-container":!0})," .").concat(H(e))}));let t="";i.left&&(t+="left:"+i.left+";"),i.right&&(t+="right:"+i.right+";"),i.top&&(t+="top:"+i.top+";"),r.style=t,a.appendChild(r),u({container:r,event:function(e,t,n,o){i.joystickInput&&(1===e&&(e=32767),1===t&&(e=32767),1===n&&(e=32767),1===o&&(e=32767)),ee.syncInput(0,i.inputValues[0],e),ee.syncInput(0,i.inputValues[1],t),ee.syncInput(0,i.inputValues[2],n),ee.syncInput(0,i.inputValues[3],o)}})}}),this.zoneObj&&this.zoneObj.forEach(e=>{e.destroy()}),this.zoneObj=[],o.forEach((i,t)=>{if("zone"===i.type){let e={};s&&["left","right"].includes(i.location)&&(i.location="left"===i.location?"right":"left",(n=JSON.parse(JSON.stringify(i))).left&&(i.right=n.left),n.right&&(i.left=n.right)),e[i.location.toLowerCase()]=!0;const o=q.call(this,".".concat(H({"ejs-virtual-gamepad":!0})," .").concat(H(e)));e["zone_"+t]=!0;var n=F("div",{class:".".concat(H({"ejs-virtual-gamepad":!0})," .").concat(H(e))});o.appendChild(n);const a=we.a.create({zone:n,mode:"static",position:{left:i.left,top:i.top},color:"red"});a.on("end",function(e,t){ee.syncInput(0,i.inputValues[0],0),ee.syncInput(0,i.inputValues[1],0),ee.syncInput(0,i.inputValues[2],0),ee.syncInput(0,i.inputValues[3],0)}),a.on("move",function(e,n){var o=n.angle.degree,n=n.distance;if(!0===i.joystickInput){let e=0,t=0;0<o&&o<=45&&(e=n/50,t=-.022222222222222223*o*n/50),45<o&&o<=90&&(e=.022222222222222223*(90-o)*n/50,t=-n/50),90<o&&o<=135&&(e=.022222222222222223*(90-o)*n/50,t=-n/50),135<o&&o<=180&&(e=-n/50,t=-.022222222222222223*(180-o)*n/50),135<o&&o<=225&&(e=-n/50,t=-.022222222222222223*(180-o)*n/50),225<o&&o<=270&&(e=-.022222222222222223*(270-o)*n/50,t=n/50),270<o&&o<=315&&(e=-.022222222222222223*(270-o)*n/50,t=n/50),315<o&&o<=359.9&&(e=n/50,t=.022222222222222223*(360-o)*n/50),0<e?(ee.syncInput(0,i.inputValues[0],32767*e),ee.syncInput(0,i.inputValues[1],0)):(ee.syncInput(0,i.inputValues[1],32767*-e),ee.syncInput(0,i.inputValues[0],0)),0<t?(ee.syncInput(0,i.inputValues[2],32767*t),ee.syncInput(0,i.inputValues[3],0)):(ee.syncInput(0,i.inputValues[3],32767*-t),ee.syncInput(0,i.inputValues[2],0))}else 30<=o&&o<150?ee.syncInput(0,i.inputValues[0],1):window.setTimeout(function(){ee.syncInput(0,i.inputValues[0],0)},30),210<=o&&o<330?ee.syncInput(0,i.inputValues[1],1):window.setTimeout(function(){ee.syncInput(0,i.inputValues[1],0)},30),120<=o&&o<240?ee.syncInput(0,i.inputValues[2],1):window.setTimeout(function(){ee.syncInput(0,i.inputValues[2],0)},30),300<=o||0<=o&&o<60?ee.syncInput(0,i.inputValues[3],1):window.setTimeout(function(){ee.syncInput(0,i.inputValues[3],0)},30)}),this.zoneObj.push(a)}}),[]);for(let n=0;n<o.length;n++)if("button"===o[n].type){let e={};e["b_"+o[n].id.toLowerCase()]=!0;let t;t=2===c.newCores&&o[n].input_new_cores?o[n].input_new_cores:o[n].input_value,r.push({id:e,number:t})}if(r.forEach(t=>{var e=q.call(c,".".concat(n," .").concat(H(t.id)));e&&j.call(c,e,"touchstart touchend touchcancel",function(e){"touchend"===e.type||"touchcancel"===e.type?(G(e.target,a,!1),window.setTimeout(function(){ee.syncInput(0,t.number,0)},30)):(G(e.target,a,!0),ee.syncInput(0,t.number,1)),e.preventDefault()})}),!t){const f=F("div",{class:H({ejs__widget:!0,ejs__widget_controls_toggle:!0})},"");f.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M0 96C0 78.33 14.33 64 32 64H416C433.7 64 448 78.33 448 96C448 113.7 433.7 128 416 128H32C14.33 128 0 113.7 0 96zM0 256C0 238.3 14.33 224 32 224H416C433.7 224 448 238.3 448 256C448 273.7 433.7 288 416 288H32C14.33 288 0 273.7 0 256zM416 448H32C14.33 448 0 433.7 0 416C0 398.3 14.33 384 32 384H416C433.7 384 448 398.3 448 416C448 433.7 433.7 448 416 448z"/></svg>',q.call(this,".".concat(H({ejs__widgets:!0}))).appendChild(f);let t;j.call(this,f,"mousedown touchstart",function(e){G(e.target,a,!0),clearTimeout(t),K.toggleControls.call(c,!0),t=setTimeout(function(){K.toggleControls.call(c,!1)},5e3)})}function u(e){let t=e.container,l=e.event,d=("function"!=typeof l&&(l=function(){}),F("div",{class:H({"dpad-bg":!0})})),u=F("div",{class:H({"dpad-front":!0})});d.innerHTML='<div class="'.concat(H({"dpad-1":!0}),'"><div class="').concat(H({"dpad-1-bg":!0}),'"></div></div>\n <div class="').concat(H({"dpad-2":!0}),'"><div class="').concat(H({"dpad-2-bg":!0}),'"></div></div>'),t.append(d),t.append(u),j.call(c,u,"touchstart touchmove",function(e){var c=e.targetTouches[0];if(c){let e=u.getBoundingClientRect(),t=c.clientX-e.left-u.clientWidth/2,n=c.clientY-e.top-u.clientHeight/2,o=0,i=0,a=0,r=0,s=Math.atan(t/n)/(Math.PI/180);n<=-10&&(o=1),10<=n&&(i=1),10<=t&&(r=1,(s<(a=0)&&-35<=s||0<s&&s<=35)&&(r=0),o=s<0&&-55<=s?1:0,i=0<s&&s<=55?1:0),t<=-10&&(r=0,a=s<0&&-35<=s||0<s&&s<=35?0:1,o=0<s&&s<=55?1:0,i=s<0&&-55<=s?1:0),d.classList.toggle(H({"dpad-right":!0}),r),d.classList.toggle(H({"dpad-left":!0}),a),d.classList.toggle(H({"dpad-up":!0}),o),d.classList.toggle(H({"dpad-down":!0}),i),l(o,i,a,r)}e.stopPropagation()}),j.call(c,u,"touchend touchcancel",function(e){l(0,0,0,0),d.classList.toggle(H({"dpad-up":!0}),!1),d.classList.toggle(H({"dpad-down":!0}),!1),d.classList.toggle(H({"dpad-right":!0}),!1),d.classList.toggle(H({"dpad-left":!0}),!1),e.stopPropagation()})}}},setup:function(){let o=this;if(this.game){var e;if(ee.playerName=o.config.playerName,G(this.elements.container,this.config.classNames.type,!0),this.elements.container.setAttribute("tabindex","0"),!this.color||(e=function(e){let n=e.toLowerCase();if(n&&/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(n)){if(4===n.length){for(let e="#",t=1;t<4;t+=1)e+=n.slice(t,t+1).concat(n.slice(t,t+1));n=r}let t=[];for(let e=1;e<7;e+=2)t.push(parseInt("0x".concat(n.slice(e,e+2)),16));return t}return null}(this.color))&&this.elements.container.setAttribute("style","--ejs-primary-color: ".concat(e[0],", ").concat(e[1],", ").concat(e[2])),this.elements.wrapper=F("div",{class:this.config.classNames.video}),k(this.game,this.elements.wrapper),"video"!==o.game.tagName.toLocaleLowerCase()){let t=this.config.volume,n=(Object.defineProperty(o.game,"volume",{get:function(){return t},set:function(e){t=e,B.call(o,o.game,"volumechange")}}),o.storage.get("muted"));Object.defineProperty(o.game,"muted",{get:function(){return n},set:function(e){e=!!U.boolean(e)&&e;n=e,B.call(o,o.game,"volumechange")}})}window.addEventListener("beforeunload",function(e){o.started&&o.getStartName()&&(m.FS.syncfs(function(){}),ee.saveSavFiles(),m.FS.syncfs(function(){}))},!0),window.saveSaveFiles=function(){o.getStartName()&&(console.log("saving save files"),ee.saveSavFiles(),m.FS.syncfs(!1,function(){}))},setInterval(function(){o.started&&saveSaveFiles()},6e4)}else console.warn("No game element found!")},listeners:function(){let a=this;var e=q.call(a,".".concat(H({ejs__dialogs:!0})));let i=0;j.call(a,e,"dragenter",function(e){e.preventDefault(),i++,V(a.elements.dialogs.message,!1)}),j.call(a,e,"dragover",function(e){e.preventDefault()}),j.call(a,e,"dragleave",function(e){e.preventDefault(),0===--i&&V(a.elements.dialogs.message,!0)}),j.call(a,e,"dragend",function(e){e.preventDefault(),i=0,V(a.elements.dialogs.message,!0)}),j.call(a,e,"drop",function(e){e.preventDefault(),V(a.elements.dialogs.message,!0),i=0;var t=e.dataTransfer.items;let n;for(let e=0;e<t.length;e++)if("file"===t[e].kind){n=t[e];break}if(n){const o=n.getAsFile();o.arrayBuffer().then(e=>{ee.loadState(new Uint8Array(e),0)})}}),a.elements.buttons.restart&&j.call(a,a.elements.buttons.restart,"click",function(e){ee.restartGame(),ee.inputsData={},ee.connected&&ee.connection.isInitiator&&(async()=>{var e=await ee.saveState(),e=new File([e],"0-game.state",{type:"",lastModified:new Date});ee.connection.shareFile(e),ee.inputsData={},ee.wait=!0,ee.systemPause(1),m.Module.pauseMainLoop(),ee.disableControl(!0)})(),saveSaveFiles()}),a.elements.buttons.screenRecord&&j.call(a,a.elements.buttons.screenRecord,"click",function(e){if(a.recordData||(a.recordData={started:!1,data:[],stopped:!1}),a.recordData.started)a.recordData.started&&(a.recordData.recorder.stop(),a.recordData.stopped=!0);else{let t;function i(e){a.elements.buttons.screenRecord.querySelector(".".concat(H({ejs__tooltip:!0}))).innerHTML=a.localization("Stop Screen Recording"),a.recordData.stream=e,a.recordData.recorder=new MediaRecorder(a.recordData.stream,t),a.recordData.recorder.ondataavailable=function(e){if(0<e.data.size&&a.recordData.data.push(e.data),a.recordData.stopped){let e=document.createElement("a");e.href=window.URL.createObjectURL(new Blob(a.recordData.data,{type:"video/webm"}));let t;"string"==typeof a.gameName&&(t=a.gameName),e.download=t?"".concat(t,"-recording.webm"):"record.webm",e.click(),window.URL.revokeObjectURL(e.href),delete a.recordData,a.elements.buttons.screenRecord.querySelector(".".concat(H({ejs__tooltip:!0}))).innerHTML=a.localization("Start Screen Recording")}},a.recordData.recorder.start(),a.recordData.started=!0}if(t=MediaRecorder.isTypeSupported("video/webm; codecs=h264")?{mimeType:"video/webm; codecs=h264"}:MediaRecorder.isTypeSupported("video/webm; codecs=H264")?{mimeType:"video/webm; codecs=H264"}:MediaRecorder.isTypeSupported("video/webm; codecs=vp9")?{mimeType:"video/webm; codecs=vp9"}:MediaRecorder.isTypeSupported("video/webm; codecs=vp8")?{mimeType:"video/webm; codecs=vp8"}:MediaRecorder.isTypeSupported("video/webm; codecs=avc1")?{mimeType:"video/webm; codecs=avc1"}:MediaRecorder.isTypeSupported("video/webm; codecs=vp9.0")?{mimeType:"video/webm; codecs=vp9.0"}:MediaRecorder.isTypeSupported("video/webm; codecs=vp8.0")?{mimeType:"video/webm; codecs=vp8.0"}:{},window.navigator&&navigator.mediaDevices&&"function"==typeof navigator.mediaDevices.getDisplayMedia){m.Module.pauseMainLoop(),a.playing=!1,alert('Please check "share system audio" to have audio in the recording. We only need the audio stream so your entire screen will not be recorded');let o=setTimeout(function(){a.playing=!0,m.Module.resumeMainLoop()},2e4);navigator.mediaDevices.getDisplayMedia({audio:!0,video:{mediaSource:"screen"}}).then(function(e){let t=m.Module.canvas.captureStream(30);try{clearTimeout(o)}catch(e){}var n=e.getAudioTracks();for(let e=0;e<n.length;e++)t.addTrack(n[e]);i(t),a.playing=!0,m.Module.resumeMainLoop()})}else i(m.Module.canvas.captureStream(30))}}),a.elements.buttons.cacheManager&&j.call(a,a.elements.buttons.cacheManager,"click",function(e){if(m.romdb){V(a.elements.dialogs.cache,!1);let n=a.elements.dialogs.cache.querySelector(".".concat(ee.classNames["dialog-content"]));n.innerHTML="<div>"+a.localization("Loading")+"</div>",m.romdb.getAll(function(t){if(t){let e=F("table",{style:"width:100%;padding-left:10px;text-align:left"}),r=F("tbody");0<t.length?(n.innerHTML="",t.forEach(function(a,e){if(a.key&&!/-part-\d+$/.test(a.key)){let n=[a.key];for(let e=Math.ceil(a.filesize/104857600),t=1;t<e;t+=1)n.push("".concat(a.key,"-part-").concat(t));let t=F("tr"),e=F("td"),o=F("td"),i=F("td");e.innerHTML=a.filename,o.innerHTML=function(e){let t=-1;for(;e/=1024,t++,1024<e;);return Math.max(e,.1).toFixed(1)+[" kB"," MB"," GB"," TB","PB","EB","ZB","YB"][t]}(a.filesize),i.innerHTML='<a href="#" onclick="return false">Remove</a>',t.appendChild(e),t.appendChild(o),t.appendChild(i),r.appendChild(t),i.querySelector("a").onclick=function(e){m.romdb.removeBatch(n);try{r.removeChild(t)}catch(e){}return e.stopPropagation(),!1}}}),e.appendChild(r),n.appendChild(e)):n.innerHTML='<div style="text-align:center">'+a.localization("Empty")+"</div>"}else n.innerHTML='<div style="text-align:center">'+a.localization("Empty")+"</div>"},function(){})}return!1}),a.elements.buttons.play&&Array.from(a.elements.buttons.play).forEach(function(e){j.call(a,e,"click",function(e){a.playing?(a.playing=!1,m.Module.pauseMainLoop(),ee.connected&&ee.connection.isInitiator&&ee.connection.send(JSON.stringify({act:"pause"})),B.call(a,a.elements.container,"pause",!1,{pause:!0})):(a.playing=!0,m.Module.resumeMainLoop(),ee.connected&&ee.connection.isInitiator&&ee.connection.send(JSON.stringify({act:"resume"})),B.call(a,a.elements.container,"pause",!1,{pause:!1}))})}),a.elements.buttons.netplay&&j.call(a,a.elements.buttons.netplay,"click",function(e){null===window.EJS_TURN_URLS||window.EJS_TURN_URLS||!async function(t){try{let e=await fetch(t+"webrtc");window.EJS_TURN_URLS=JSON.parse(await e.text())}catch(e){window.EJS_TURN_URLS=null,console.warn("Could not contact netplay server",e)}}(a.listUrl),ee.disableControl(!0),V(a.elements.dialogs.netplay,!1),0<ee.players.length?ee.openRoom(p):(ee.stopLoadRooms(),ee.loadRoomsList()),ee.playerName||g.show("modal-9de6c4e9ce2b9361",{closeByEsckey:!1})}),a.elements.buttons.cheat&&j.call(a,a.elements.buttons.cheat,"click",function(e){V(a.elements.dialogs.cheat,!1)}),a.game.stateloadField=F("input"),a.game.stateloadField.type="file",a.game.stateloadField.onchange=function e(t){let n,o=t.target.files;0<o.length&&((n=new FileReader).file_name=o[0].name,n.onload=function(){EJS_loadState(new Uint8Array(n.result))},n.readAsArrayBuffer(o[0])),a.game.stateloadField=F("input"),a.game.stateloadField.type="file",a.game.stateloadField.onchange=e},j.call(a,a.elements.container,"loadstate",function(e){ee.saveLoadDB.call(a,"load")||(U.function(a.config.onloadstate)?a.config.onloadstate.call(null,a.loadState):a.game.stateloadField.click(),a.elements.container.focus())}),document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState?console.log("hidden"):console.log("active")})},bindFunction:function(){let r=this,o=getSystem(r.system,!0);if(m.Module&&m.Module._set_volume){let t=m.Module.cwrap("set_volume","null",["number"]);ee.setVolume=function(){let e=0;r.volume<1&&(e=0===r.volume?-80:30*r.volume-30,t(e)),r.muted&&(e=-80),t(e)}}m.Module._save_file_path?ee.getSaveFilePath=m.Module.cwrap("save_file_path","string",[]):ee.getSaveFilePath=()=>null,ee.readSaveFile=function(){return FS.readFile(ee.getSaveFilePath())},ee.setVariable=m.Module.cwrap("set_variable","null",["string","string"]),ee.simulateInputFn=m.Module.cwrap("simulate_input","null",["number","number","number"]);let s={0:null,1:null,2:null,3:null,4:null,5:null,6:null,7:null,8:null,9:null,10:null,11:null,12:null,13:null,14:null,15:null,16:null,17:null,18:null,19:null,20:null,21:null,22:null,23:null,24:null,25:null,26:null,27:null,28:null,29:null,30:null,31:null},i=(ee.simulateInput=function(e,t,n){var o,i,a;ee.connected?r.playing&&!ee.disableInput&&(i=ee.connection.userid,o=ee.roomMaster===i,i=ee.players.indexOf(i),a=ee.currentFrameNum(),e>>0==0&&(s[t]!==n&&(o?(ee.inputsData[a]||(ee.inputsData[a]=[]),ee.inputsData[a].push({index:i,key:t,status:n,frame:a}),ee.simulateInputFn(i,t,n)):ee.connection.send(JSON.stringify({act:"sync-control",value:["".concat(i,"|").concat(t,"|").concat(n,"|").concat(a)]}),ee.roomMaster)),s[t]=n)):ee.disableInput||ee.simulateInputFn(e,t,n)},ee.syncInput=ee.simulateInput,window.simulateInput=ee.simulateInput,ee.toggleShader=m.Module.cwrap("shader_enable","null",["number"]),2!==r.coreVer?ee.getStateInfo=m.Module.cwrap("get_state_info","string",[]):(ee.getInfoOfState=m.Module.cwrap("get_state_info","string",[]),ee.getStateInfo1=m.Module.cwrap("save_state_info","null",[]),ee.getStateInfo=function(){return ee.getStateInfo1(),new Promise(function(t,e){let n=ee.getInfoOfState();if(n)t(n);else{let e=setInterval(function(){(n=ee.getInfoOfState())&&(clearInterval(e),t(n))},50)}})}),ee.saveState=async function(){let n,o;var i=(o=(2!==r.coreVer?ee.getStateInfo():await ee.getStateInfo()).split("|"))[0]>>0;if(0<i){n=new Uint8Array(i);for(let e=o[1]>>0,t=0;t<i;t++)n[t]=m.Module.getValue(e+t)}return n},m.Module.cwrap("load_state","number",["string","number"])),e=(ee.loadState=function(e,t){try{m.FS.unlink("game.state")}catch(e){}m.FS.createDataFile("/","game.state",e,!0,!0),null===t&&(t=0),"arcade"===o?setTimeout(function(){ee.getStateInfo(),i("game.state",t),m.FS.unlink("game.state")},10):(i("game.state",t),setTimeout(function(){m.FS.unlink("game.state")},100)),ee.connected&&ee.connection.isInitiator&&(async()=>{var e=await ee.saveState(),e=new File([e],"0-game.state",{type:"",lastModified:new Date});ee.connection.shareFile(e),ee.inputsData={},ee.wait=!0,ee.systemPause(1),m.Module.pauseMainLoop(),ee.disableControl(!0)})(),r.elements.container.focus()},m.Module._set_cheat&&(ee.setCheat=m.Module.cwrap("set_cheat","number",["number","number","string"])),m.Module._reset_cheat&&(ee.resetCheat=m.Module._reset_cheat),ee.quickSaveState=async function(){if(r.started&&!ee.connected)if(!1===r.statesSupported)ee.doMessageTransition("CANNOT CURRENTLY LOAD STATE");else{let t;var e=(t=oe&&"function"==typeof oe.getCoreOptionsValue&&(t=oe.getCoreOptionsValue("save-state-slot"))||1)+"-quick.state";try{m.FS.unlink(e)}catch(e){}try{var n=await ee.saveState();m.FS.createDataFile("/",e,n,!0,!0),ee.doMessageTransition("STATE SAVED TO SLOT "+t)}catch(e){console.warn(e),ee.doMessageTransition("FAILED TO SAVE STATE TO SLOT "+t)}saveSaveFiles()}},ee.saveMsgTransitions=null,ee.doMessageTransition=function(e){r.elements.widgets.stateInfoDiv.innerText=e,clearTimeout(ee.saveMsgTransitions),ee.saveMsgTransitions=setTimeout(function(){r.elements.widgets.stateInfoDiv.innerText=""},1500)},ee.quickLoadState=function(){if(r.started&&!ee.connected)if(!1===r.statesSupported)ee.doMessageTransition("CANNOT CURRENTLY LOAD STATE");else{let e,t=(e=oe&&"function"==typeof oe.getCoreOptionsValue&&(e=oe.getCoreOptionsValue("save-state-slot"))||1)+"-quick.state",n=!0;try{i(t,0),"arcade"===o&&setTimeout(function(){ee.getStateInfo(),i(t,0)},10)}catch(e){n=!1}n?ee.doMessageTransition("LOADED STATE FROM SLOT "+e):ee.doMessageTransition("FAILED TO LOAD STATE FROM SLOT "+e),saveSaveFiles()}},ee.changeStateSlot=function(e){let t;t=(t=oe&&"function"==typeof oe.getCoreOptionsValue?oe.getCoreOptionsValue("save-state-slot"):t)||1;let n;9<(n="number"!=typeof e?t+1:e)&&(n=1),ne.updateCoreOptions.call(r,"save-state-slot",n),ee.doMessageTransition("SET SAVE STATE SLOT TO "+n)},window.EJS_loadState=function(t){ee.loadState(t,0),setTimeout(()=>{var e;ee.connected&&(e=new File([t],"0-game.state",{type:"",lastModified:new Date}),ee.connection.shareFile(e),ee.inputsData={},ee.wait=!0,ee.systemPause(1),m.Module.pauseMainLoop(),ee.disableControl(!0))},30)},window.EJS_saveState=function(){return ee.saveState()},m.Module.cwrap("cmd_take_screenshot","",[]));ee.getScreenData=function(){return e(),m.FS.readFile("screenshot.png")},ee.restartGame=m.Module.cwrap("system_restart","",[]),ee.currentFrameNum=m.Module.cwrap("get_current_frame_count","",[]),ee.saveSavFiles=m.Module.cwrap("cmd_savefiles","",[]),m.Module._get_core_options&&(ee.getGameCoreOptions=m.Module.cwrap("get_core_options","string",[])),ee.systemPause=function(e){return!1},ee.controllers=oe.storage.get("controllers"),ee.controllers||(ee.controllers=JSON.parse(JSON.stringify(ee.defaultControllers)))}};let te=ee;const ne={storage:null,coreOptionsValues:{},contextMenu:null,normalOptions:{shader:{label:"Shader",options:{disabled:"Disabled","2xScaleHQ.glslp":"2xScaleHQ","4xScaleHQ.glslp":"4xScaleHQ","crt-easymode.glslp":"CRT easymode","crt-aperture.glslp":"CRT aperture","crt-geom.glslp":"CRT geom","crt-mattias.glslp":"CRT mattias"},default:"disabled"},"virtual-gamepad":{label:"Virtual Gamepad",options:{disabled:"Disabled",enabled:"Enabled"},default:"enabled"}},defaultCoreOptionsValues:function(){let e={};if(2===this.coreVer)return{};switch(this.system){case"pce":e={pce_nospritelimit:"enabled"};break;case"jaguar":e={virtualjaguar_doom_res_hack:"enabled"};break;case"psx":e={pcsx_rearmed_memcard2:"enabled"};break;case"nds":e={}}return e},getCoreOptionsValues:function(){if(ne.coreOptionsValues)return JSON.parse(JSON.stringify(ne.coreOptionsValues));let e=ne.storage.get("core-options");return e=U.empty(e)?{}:e},getCoreOptionsValue:function(e){if(ne.coreOptionsValues){var t=JSON.parse(JSON.stringify(ne.coreOptionsValues))[e];if(t)return t}let n=ne.storage.get("core-options");return(n=U.empty(n)?{}:n)[e]},getCoreOptions:function(){let a={};switch(this.system){case"nes":a.fceumm_palette={label:this.localization("Color Palette"),options:{default:this.localization("Default"),asqrealc:"asqrealc","nintendo-vc":"nintendo-vc",rgb:"rgb","yuv-v3":"yuv-v3","unsaturated-final":"unsaturated-final","sony-cxa2025as-us":"sony-cxa2025as-us",pal:"pal","bmf-final2":"bmf-final2","bmf-final3":"bmf-final3","smooth-fbx":"smooth-fbx","composite-direct-fbx":"composite-direct-fbx","pvm-style-d93-fbx":"pvm-style-d93-fbx",nescap:"nescap","ntsc-hardware-fbx":"ntsc-hardware-fbx","nes-classic-fbx-fs":"nes-classic-fbx-fs",wavebeam:"wavebeam"},default:"default"},a.fceumm_nospritelimit={label:this.localization("No Sprite Limit"),options:{enabled:this.localization("Enabled"),disabled:this.localization("Disabled")},default:"disabled"},a.fceumm_sndquality={label:this.localization("Sound Quality"),options:{Low:this.localization("Low"),High:this.localization("High"),"Very High":this.localization("Very High")},default:"Low"},this.lightgun||(a.system_type={label:this.localization("4 Players Support"),options:{nes:"NES",famicom:"Famicom"},default:"nes"}),a.fceumm_turbo_enable={label:this.localization("Turbo Enable"),options:{None:this.localization("None"),"Player 1":this.localization("Player 1"),"Player 2":this.localization("Player 2"),Both:this.localization("Both")},default:"None"},a.fceumm_region={label:this.localization("Region"),options:{Auto:this.localization("Auto"),NTSC:"NTSC",PAL:"PAL",Dendy:"Dendy"},default:"Auto"};break;case"snes":a={snes9x_next_overclock:{label:this.localization("SuperFX Overclock"),options:{disabled:this.localization("Disabled")+"(10MHz)","40MHz":"40MHz","60MHz":"60MHz","80MHz":"80MHz","100MHz":"100MHz"},default:"disabled"}};break;case"snes2002":case"snes2005":case"snes2010":a={};break;case"gb":a={gambatte_gb_colorization:{label:this.localization("GB Colorization"),options:{disabled:this.localization("Disabled"),auto:this.localization("auto"),internal:this.localization("internal")},default:"disabled"},gambatte_gb_internal_palette:{label:this.localization("Internal Palette"),options:{"GBC - Blue":this.localization("GBC - Blue"),"GBC - Brown":this.localization("GBC - Brown"),"GBC - Dark Blue":this.localization("GBC - Dark Blue"),"GBC - Dark Brown":this.localization("GBC - Dark Brown"),"GBC - Dark Green":this.localization("GBC - Dark Green"),"GBC - Grayscale":this.localization("GBC - Grayscale"),"GBC - Green":this.localization("GBC - Green"),"GBC - Inverted":this.localization("GBC - Inverted"),"GBC - Orange":this.localization("GBC - Orange"),"GBC - Pastel Mix":this.localization("GBC - Pastel Mix"),"GBC - Red":this.localization("GBC - Red"),"GBC - Yellow":this.localization("GBC - Yellow")},default:"GBC - Blue"}};break;case"gba":a={mgba_solar_sensor_level:{label:this.localization("Solar sensor level"),options:["0","1","2","3","4","5","6","7","8","9","10"],default:"0"},mgba_frameskip:{label:this.localization("Frameskip"),options:["0","1","2","3","4","5","6","7","8","9","10"],default:"0"}};break;case"vbanext":a={vbanext_turboenable:{label:this.localization("Enable Turbo Buttons"),options:{disabled:this.localization("disabled"),enabled:this.localization("enabled")},default:"disabled"},vbanext_turbodelay:{label:this.localization("Turbo Delay in frames"),options:["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"],default:"2"}};break;case"n64":a={"glupen64-aspect":{label:this.localization("Aspect Ratio (Need to refresh page)"),options:["4:3","16:9"],default:"4:3"},"glupen64-43screensize":{label:this.localization("4:3 Resolution"),options:["320x240","640x480","960x720","1280x960"],default:"320x240"},"glupen64-169screensize":{label:this.localization("16:9 Resolution"),options:["640x360","960x540","1280x720"],default:"640x360"},"glupen64-pak1":{label:this.localization("Player 1 Pak"),options:{none:this.localization("none"),memory:this.localization("memory"),rumble:this.localization("rumble")},default:"none"},"glupen64-pak2":{label:this.localization("Player 2 Pak"),options:{none:this.localization("none"),memory:this.localization("memory"),rumble:this.localization("rumble")},default:"none"},"glupen64-pak3":{label:this.localization("Player 3 Pak"),options:{none:this.localization("none"),memory:this.localization("memory"),rumble:this.localization("rumble")},default:"none"},"glupen64-pak4":{label:this.localization("Player 4 Pak"),options:{none:this.localization("none"),memory:this.localization("memory"),rumble:this.localization("rumble")},default:"none"}};break;case"nds":a={desmume_screens_layout:{label:this.localization("Screen layout"),options:{"top/bottom":this.localization("top/bottom"),"bottom/top":this.localization("bottom/top"),"left/right":this.localization("left/right"),"right/left":this.localization("right/left"),"top only":this.localization("top only"),"bottom only":this.localization("bottom only"),"quick switch":this.localization("quick switch"),"hybrid/top":this.localization("hybrid/top"),"hybrid/bottom":this.localization("hybrid/bottom")},default:"top/bottom"},screen_rotation:{label:this.localization("Screen Rotation"),options:{0:"0°",90:"90°",180:"180°",270:"270°"},default:0},desmume_frameskip:{label:this.localization("Frameskip"),options:["0","1","2","3","4","5","6","7","8","9"],default:"0"}},Y.wasm||delete a.screen_rotation;break;case"vb":case"pce":a={};break;case"segaMS":case"segaGG":case"segaMD":case"segaCD":a={genesis_plus_gx_no_sprite_limit:{label:this.localization("No Sprite Limit"),options:{disabled:this.localization("disabled"),enabled:this.localization("enabled")},default:"disabled"},genesis_plus_gx_overclock:{label:this.localization("CPU speed"),options:["100%","125%","150%","175%","200%"],default:"100%"},genesis_plus_gx_sound_output:{label:this.localization("Sound output"),options:{stereo:this.localization("stereo"),mono:this.localization("mono")},default:"stereo"}};break;case"sega32x":a={picodrive_sprlim:{label:this.localization("No sprite limit"),options:{disabled:this.localization("disabled"),enabled:this.localization("enabled")},default:"disabled"}};break;case"segaSaturn":a={yabause_frameskip:{label:this.localization("Frameskip"),options:{disabled:this.localization("disabled"),enabled:this.localization("enabled")},default:"disabled"}};break;case"msx":a={bluemsx_nospritelimits:{label:this.localization("No Sprite Limit"),options:{OFF:this.localization("OFF"),ON:this.localization("ON")},default:"OFF"}};break;case"ws":case"ngp":a={};break;case"jaguar":a={virtualjaguar_usefastblitter:{label:this.localization("Fast Blitter"),options:{disabled:this.localization("disabled"),enabled:this.localization("enabled")},default:"disabled"},virtualjaguar_bios:{label:this.localization("Bios"),options:{disabled:this.localization("disabled"),enabled:this.localization("enabled")},default:"disabled"}};break;case"psx":a={pcsx_rearmed_frameskip:{label:this.localization("Frameskip"),options:[0,1,2,3],default:0},pcsx_rearmed_memcard2:{label:this.localization("Enable second memory card"),options:{disabled:this.localization("disabled"),enabled:this.localization("enabled")},default:"enabled"},pcsx_rearmed_pad1type:{label:this.localization("Pad 1 Type"),options:{default:this.localization("default"),none:this.localization("none"),standard:this.localization("standard"),analog:this.localization("analog"),negcon:this.localization("negcon")},default:"default"},pcsx_rearmed_pad2type:{label:this.localization("Pad 2 Type"),options:{default:this.localization("default"),none:this.localization("none"),standard:this.localization("standard"),analog:this.localization("analog"),negcon:this.localization("negcon")},default:"default"},pcsx_rearmed_pad3type:{label:this.localization("Pad 3 Type"),options:{default:this.localization("default"),none:this.localization("none"),standard:this.localization("standard"),analog:this.localization("analog"),negcon:this.localization("negcon")},default:"default"},pcsx_rearmed_pad4type:{label:this.localization("Pad 4 Type"),options:{default:this.localization("default"),none:this.localization("none"),standard:this.localization("standard"),analog:this.localization("analog"),negcon:this.localization("negcon")},default:"default"},pcsx_rearmed_vibration:{label:this.localization("Enable Vibration"),options:{disabled:this.localization("disabled"),enabled:this.localization("enabled")},default:"enabled"},pcsx_rearmed_neon_interlace_enable:{label:this.localization("Enable interlacing mode(s)"),options:{disabled:this.localization("disabled"),enabled:this.localization("enabled")},default:"disabled"},pcsx_rearmed_neon_enhancement_enable:{label:this.localization("Enhanced resolution (slow)"),options:{disabled:this.localization("disabled"),enabled:this.localization("enabled")},default:"disabled"},pcsx_rearmed_neon_enhancement_no_main:{label:this.localization("Enhanced resolution speed hack"),options:{disabled:this.localization("disabled"),enabled:this.localization("enabled")},default:"disabled"}};break;case"arcade":case"fba0.2.97.29":a={"fba-aspect":{label:this.localization("Aspect ratio"),options:["DAR","PAR"],default:"DAR"},"fba-frameskip":{label:this.localization("Frameskip"),options:["0","1","2","3","4","5"],default:"0"},"fba-cpu-speed-adjust":{label:this.localization("CPU overclock"),options:["100","110","120","130","140","150","160","170","180","190","200"],default:"100"},"fba-diagnostic-input":{label:this.localization("Diagnostic Input"),options:["None","Hold Start","Start + A + B","Hold Start + A + B","Start + L + R","Hold Start + L + R","Hold Select","Select + A + B","Hold Select + A + B","Select + L + R","Hold Select + L + R"],default:"None"},"fba-neogeo-mode":{label:this.localization("Force Neo Geo mode"),options:["MVS","AES","UNIBIOS","DIPSWITCH"],default:"MVS"}};break;default:a={}}const r=this;2===this.coreVer&&((a={}).fps={label:this.localization("FPS"),options:{show:this.localization("show"),hide:this.localization("hide")},default:"hide"}),!te||"undefined"==te.virtualGamepadContainer&&null===te.virtualGamepadContainer||(a["left-handed-mode"]={label:this.localization("Left Handed Mode"),options:{on:this.localization("On"),off:this.localization("Off")},default:"off"}),!0===this.statesSupported&&(a["save-state-slot"]={label:this.localization("Save State Slot"),options:[1,2,3,4,5,6,7,8,9],default:1}),!0===this.statesSupported&&window.indexedDB&&this.getStartName()&&(a["save-state-location"]={label:this.localization("Save State Location"),options:{download:this.localization("download"),"keep in browser":this.localization("keep in browser")},default:"download"});try{te.getGameCoreOptions&&te.getGameCoreOptions().split("\n").forEach(function(e,t){let o=e.split("; "),i=o[0];if(0===i.indexOf("fba-dipswitch-")||2===r.coreVer){let n=o[1].split("|"),e=i.split("|")[0].replace(/_/g," ").replace(/.+\-(.+)/,"$1");if(n.slice(1,-1),1!==n.length){let t={};for(let e=0;e<n.length;e++)t[n[e]]=r.localization(n[e]);a[i.split("|")[0]]={label:r.localization(e),options:t,default:1<i.split("|").length?i.split("|")[1]:n[0].replace("(Default) ","")}}}})}catch(e){}return a},supportNetPlay:function(){if(2===this.coreVer)return!1;if(!this.listUrl||!this.socketUrl)return!1;if(this.lightgun||this.mouse)return!1;var e=window.RTCPeerConnection||window.webkitPeerConnection00||window.webkitRTCPeerConnection||window.mozRTCPeerConnection,t=window.mozRTCIceCandidate||window.RTCIceCandidate,n=window.mozRTCSessionDescription||window.RTCSessionDescription;return!!(e&&t&&n)&&!!(e&&"createDataChannel"in e.prototype)},isNetPlay:function(){},findElements:function(){try{return this.elements.controls=q.call(this,this.config.selectors.controls.wrapper),this.elements.buttons={play:l.call(this,this.config.selectors.buttons.play),pause:q.call(this,this.config.selectors.buttons.pause),restart:q.call(this,this.config.selectors.buttons.restart),mute:q.call(this,this.config.selectors.buttons.mute),settings:q.call(this,this.config.selectors.buttons.settings),fullscreen:q.call(this,this.config.selectors.buttons.fullscreen),saveState:q.call(this,this.config.selectors.buttons.saveState),cacheManager:q.call(this,this.config.selectors.buttons.cacheManager),screenRecord:q.call(this,this.config.selectors.buttons.screenRecord),loadState:q.call(this,this.config.selectors.buttons.loadState),gamepad:q.call(this,this.config.selectors.buttons.gamepad),netplay:q.call(this,this.config.selectors.buttons.netplay),cheat:q.call(this,this.config.selectors.buttons.cheat)},this.elements.inputs={volume:q.call(this,this.config.selectors.inputs.volume)},!0}catch(e){return this.debug.warn("It looks like there is a problem with your custom controls HTML",e),!1}},createIcon:function(e,t){let n=document.createElementNS("http://www.w3.org/2000/svg","svg"),o=(P(n,X(t,{role:"presentation",focusable:"false"})),document.createElement("div"));o.innerHTML="<svg>".concat(this.icons[e],"</svg>");for(let e=o.childNodes[0].childNodes,t=0;t<e.length;t+=1)n.appendChild(e[t]);return n},createLabel:function(e){let t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=he.get(e,this.config),o={};return o[t.class]=!0,o[this.config.classNames.hidden]=!0,F("span",Object.assign({},t,{class:[t.class,this.config.classNames.tooltip].filter(Boolean).join(" ")}),n)},createBadge:function(e){if(U.empty(e))return null;let t=F("span",{class:this.config.classNames.menu.value});return t.appendChild(F("span",{class:this.config.classNames.menu.badge},e)),t},createButton:function(e,t){let n,o,i,a,r=F("button"),s=Object.assign({},t),c=function(e){let t=(0<arguments.length&&void 0!==e?e:"").toString();return(t=function(e){e=pe((0<arguments.length&&void 0!==e?e:"").toString(),"-"," ");return e=pe(e,"_"," "),pe(function(e){return(0<arguments.length&&void 0!==e?e:"").toString().replace(/\w\S*/g,function(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()})}(e)," ","")}(t)).charAt(0).toLowerCase()+t.slice(1)}(e),l=!1;"type"in s||(s.type="button");t=H({ejs__control:!0});switch("class"in s?s.class.includes(t)||(s.class+=" ".concat(t)):s.class=t,e){case"play":l=!0,n="play",i="pause",o="play",a="pause";break;case"mute":l=!0,n="mute",i="unmute",o="volume",a="muted";break;case"fullscreen":l=!0,n="enterFullscreen",i="exitFullscreen",o="enter-fullscreen",a="exit-fullscreen";break;default:n=c,o=e}return l?(r.appendChild(ne.createIcon.call(this,a,{class:H({"icon--pressed":!0})})),r.appendChild(ne.createIcon.call(this,o,{class:H({"icon--not-pressed":!0})})),r.appendChild(ne.createLabel.call(this,i,{class:H({"icon--pressed":!0})})),r.appendChild(ne.createLabel.call(this,n,{class:H({"icon--not-pressed":!0})}))):(r.appendChild(ne.createIcon.call(this,o)),r.appendChild(ne.createLabel.call(this,n))),X(s,N(this.config.selectors.buttons[c],s)),P(r,s),"play"===c?(U.array(this.elements.buttons[c])||(this.elements.buttons[c]=[]),this.elements.buttons[c].push(r)):this.elements.buttons[c]=r,r},createRange:function(e,t){t=F("input",X(N(this.config.selectors.inputs[e]),{type:"range",min:0,max:100,step:.1,value:0,autocomplete:"off",role:"slider","aria-label":he.get(e,this.config),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":0},t));return this.elements.inputs[e]=t,ne.updateRangeFill.call(this,t),t},bindMenuItemShortcuts:function(o,i){let a=this;j(o,"keydown keyup",function(n){if([32,38,39,40].includes(n.which)&&(n.preventDefault(),n.stopPropagation(),"keydown"!==n.type)){let e,t=z(o,'[role="menuitemradio"]');!t&&[32,39].includes(n.which)?ne.showMenuPanel.call(a,i,!0):32!==n.which&&(40===n.which||t&&39===n.which?(e=o.nextElementSibling,U.element(e)||(e=o.parentNode.firstElementChild)):(e=o.previousElementSibling,U.element(e)||(e=o.parentNode.lastElementChild)),ae.call(a,e,!0))}},!1),j(o,"keyup",function(e){13===e.which&&ne.focusFirstMenuItem.call(a,null,!0)})},createMenuItem:function(e){let t=this,n=e.value,o=e.list,i=e.type,a=e.title,r=e.badge,s=void 0===r?null:r,c=e.checked,l=void 0!==c&&c,d=N(this.config.selectors.inputs[i]),u=F("button",X(d,{type:"button",role:"menuitemradio",class:"".concat(this.config.classNames.control," ").concat(d.class||"").trim(),"aria-checked":l,value:n})),f=F("span"),p=(f.innerHTML=a,U.element(s)&&f.appendChild(s),u.appendChild(f),Object.defineProperty(u,"checked",{enumerable:!0,get:function(){return"true"===u.getAttribute("aria-checked")},set:function(e){e&&Array.from(u.parentNode.children).filter(function(e){return z(e,'[role="menuitemradio"]')}).forEach(function(e){return e.setAttribute("aria-checked","false")}),u.setAttribute("aria-checked",e?"true":"false")}}),ne.getCoreOptions.call(this));this.listeners.bind(u,"click keyup",function(e){U.keyboardEvent(e)&&32!==e.which||(e.preventDefault(),e.stopPropagation(),u.checked=!0,Object.keys(ne.normalOptions).includes(i)&&ne.updateNormalOptions.call(t,i,n),Object.keys(p).includes(i)&&(p[i].netplay&&te.connected?te.connection.isInitiator&&(ne.updateCoreOptions.call(t,i,n),te.connection.send(JSON.stringify({act:"update-core-option",key:i,value:n,frame:te.currentFrame}))):ne.updateCoreOptions.call(t,i,n)),ne.showMenuPanel.call(t,"home",U.keyboardEvent(e)))},i,!1),ne.bindMenuItemShortcuts.call(this,u,i),o.appendChild(u)},updateVolume:function(){U.element(this.elements.inputs.volume)&&ne.setRange.call(this,this.elements.inputs.volume,this.muted?0:this.volume),U.element(this.elements.buttons.mute)&&(this.elements.buttons.mute.pressed=this.muted||0===this.volume)},setRange:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0;U.element(e)&&(e.value=t,ne.updateRangeFill.call(this,e))},updateRangeFill:function(e){let t=U.event(e)?e.target:e;if(U.element(t)&&"range"===t.getAttribute("type")){if(z(t,this.config.selectors.inputs.volume)){let e=100*t.value;t.setAttribute("aria-valuenow",e),t.setAttribute("aria-valuetext","".concat(e.toFixed(1),"%"))}else t.setAttribute("aria-valuenow",t.value);W.isWebkit&&t.style.setProperty("--value","".concat(t.value/t.max*100,"%"))}},toggleMenuButton:function(e,t){V(this.elements.settings.buttons[e],!t)},updateNormalOptions:function(e,t){this.elements.settings.buttons[e].querySelector(".".concat(this.config.classNames.menu.value)).innerHTML=ne.normalOptions[e].options[t];let n={};n[e]=t,ne.storage.set(n),"shader"===e&&te.setShader(t),"virtual-gamepad"===e&&te.toggleVirtualGamepad.call(this,"enabled"===t)},updateCoreOptions:function(t,n){if("nds"===getSystem(this.system,!0)&&!Y.wasm)return!0;if(ne.coreOptionsValues[t]=n,"psx"===getSystem(this.system,!0)&&m.Module.pauseMainLoop(),te.setVariable(t,n),"psx"===getSystem(this.system,!0)&&(setTimeout(function(){m.Module.resumeMainLoop()},100),setTimeout(function(){m.Module.resumeMainLoop()},200)),"nds"===getSystem(this.system,!0)&&Y.wasm){let e=this.elements.wrapper.querySelector("canvas");if("screen_rotation"===t)switch(e.style.transform="rotate("+n+"deg)",n){case"0":te.setVariable("desmume_input_rotation","0");break;case"90":te.setVariable("desmume_input_rotation","270");break;case"180":te.setVariable("desmume_input_rotation","180");break;case"270":te.setVariable("desmume_input_rotation","90")}}if("arcade"===getSystem(this.system,!0)||"fba0.2.97.29"===getSystem(this.system,!0)){let e=this.elements.wrapper.querySelector("canvas");e.height="fba-aspect"===t&&"PAR"===n?e.width/16*9:e.width/4*3}let o=ne.getCoreOptions.call(this),e=ne.storage.get("core-options");if((e=U.empty(e)?{}:e)[t]=n,ne.storage.set({"core-options":e}),this.elements.settings.buttons[t]){let e=this.elements.settings.buttons[t].querySelector(".".concat(this.config.classNames.menu.value));U.object(o[t].options)?e.innerHTML=o[t].options[n]:e.innerHTML=n}"left-handed-mode"===t&&te.toggleVirtualGamepad.call(this,!0,!0)},setOptionMenuItem:function(d,u){let f=this,p=this.elements.settings.panels.home.querySelector('[role="menu"]'),h=this.elements.settings.popup.children[0];Object.keys(d).forEach(function(t){let n=t,e=F("button",X(N(f.config.selectors.buttons.settings),{type:"button",class:H({ejs__control:!0,"ejs__control--forward":!0}),role:"menuitem",item:t,"aria-haspopup":!0}));j(e,"click",function(){ne.showMenuPanel.call(f,n,!1)});let o,i=F("span",null,d[t].label),a=F("span",{class:f.config.classNames.menu.value}),r=(U.object(u)&&(o=u[n]),U.empty(o)&&(o=d[n].default),U.object(d[n].options)?a.innerHTML=d[n].options[o]:a.innerHTML=o,i.appendChild(a),e.appendChild(i),p.appendChild(e),F("div",{"data-pane":escape(n),hidden:""})),s=F("button",{type:"button",class:H({ejs__control:!0,"ejs__control--back":!0})}),c=(s.appendChild(F("span",{"aria-hidden":!0},d[t].label)),s.appendChild(F("span",{class:H({"ejs__sr-only":!0})},he.get("menuBack",f.config))),j(r,"keydown",function(e){37===e.which&&(e.preventDefault(),e.stopPropagation(),ne.showMenuPanel.call(f,"home",!0))},!1),j(s,"click",function(){ne.showMenuPanel.call(f,"home",!1)}),r.appendChild(s),r.appendChild(F("div",{role:"menu"})),h.appendChild(r),f.elements.settings.buttons[n]=e,(f.elements.settings.panels[n]=r).querySelector('[role="menu"]'));var l=c;if(U.element(l))for(let e=l.childNodes.length;0<e;)l.removeChild(l.lastChild),--e;U.object(d[t].options)?Object.keys(d[t].options).forEach(function(e){ne.createMenuItem.call(f,{value:e,list:c,type:n,title:d[t].options[e],badge:null,checked:Boolean(o===e)})}):U.array(d[t].options)&&d[t].options.forEach(function(e){ne.createMenuItem.call(f,{value:e,list:c,type:n,title:e,badge:null,checked:Boolean(o===e)})})})},setNormalOptionsMenu:function(){let r=this,n={};(n=this.config.defaultMenuOptions&&void 0===this.config.defaultMenuOptions.length?this.config.defaultMenuOptions:n).orientation=ne.storage.get("orientation"),n.shader=ne.storage.get("shader")||n.shader,r.touch?(n["virtual-gamepad"]=ne.storage.get("virtual-gamepad")||n["virtual-gamepad"],j.call(r,r.elements.container,"start-game",function(){"enabled"!==n["virtual-gamepad"]&&!U.empty(n["virtual-gamepad"])||te.toggleVirtualGamepad.call(r,!0)})):delete ne.normalOptions["virtual-gamepad"],ne.setOptionMenuItem.call(this,ne.normalOptions,n),j.call(r,r.elements.container,"start-game",function(){var e=ne.storage.get("shader");"disabled"!==e&&te.setShader(e);let a={};te.getGameCoreOptions&&te.getGameCoreOptions().split("\n").forEach(function(e,t){let o=e.split("; "),i=o[0];if(0===i.indexOf("fba-dipswitch-")||2===r.coreVer){let n=o[1].split("|"),e=i.split("|")[0].replace(/_/g," ").replace(/.+\-(.+)/,"$1");if(n.slice(1,-1),1!==n.length){let t={};for(let e=0;e<n.length;e++)t[n[e]]=r.localization(n[e]);a[i.split("|")[0]]={label:r.localization(e),options:t,default:1<i.split("|").length?i.split("|")[1]:n[0].replace("(Default) ","")}}}});e=ne.storage.get("core-options")||{};ne.coreOptionsValues=e,ne.setOptionMenuItem.call(r,a,ne.coreOptionsValues),Object.keys(ne.coreOptionsValues).forEach(function(e,t){ne.updateCoreOptions.call(n,e,ne.coreOptionsValues[e])}),"nds"==getSystem(r.system,!0)&&(m.Module._fast_forward_2?m.Module._fast_forward_2(1):m.Module._fast_forward&&m.Module._fast_forward(1))})},updateCoreOptionMenuItems:function(){let t=this.elements.settings.panels.home.querySelector('[role="menu"]'),n=ne.getCoreOptions.call(this);te.connected&&!te.connection.isInitiator?Object.keys(n).forEach(function(e){n[e].netplay&&t.querySelector('[item="'.concat(e,'"]')).setAttribute("disabled","")}):Object.keys(n).forEach(function(e){t.querySelector('[item="'.concat(e,'"]')).removeAttribute("disabled")})},setCoreOptionsMenu:function(){this.elements.settings.panels.home.querySelector('[role="menu"]'),this.elements.settings.popup.children[0];let e=ne.getCoreOptions.call(this),t=ne.storage.get("core-options");if(t=t||{},this.config.defaultMenuOptions&&void 0===this.config.defaultMenuOptions.length){for(var n in this.config.defaultMenuOptions)t[n]||(t[n]=this.config.defaultMenuOptions[n]);r=this.config.defaultMenuOptions}"undefined"!=typeof EJS_DEBUG_XX&&!0===EJS_DEBUG_XX&&console.log("Available core options: ",e),ne.coreOptionsValues=t,ne.setOptionMenuItem.call(this,e,t)},checkMenu:function(){var e=this.elements.settings.buttons;U.empty(e)||Object.values(e).some(function(e){return!e.hidden}),V(this.elements.settings.menu,!1)},focusFirstMenuItem:function(t){var n=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(!this.elements.settings.popup.hidden){let e=t;t=(e=U.element(e)?e:Object.values(this.elements.settings.panels).find(function(e){return!e.hidden})).querySelector('[role^="menuitem"]');ae.call(this,t,n)}},toggleMenu:function(n){let o=this.elements.settings.popup,i=this.elements.buttons.settings;if(U.element(o)&&U.element(i)){let e=o.hidden,t=e;if(U.boolean(n))t=n;else if(U.keyboardEvent(n)&&27===n.which)t=!1;else if(U.event(n)){var a=o.contains(n.target);if(a||!a&&n.target!==i&&t)return}i.setAttribute("aria-expanded",t),V(o,!t),G(this.elements.container,this.config.classNames.menu.open,t),t&&U.keyboardEvent(n)?ne.focusFirstMenuItem.call(this,null,!0):t||e||ae.call(this,i,U.keyboardEvent(n))}},getMenuSize:function(e){let t=e.cloneNode(!0);t.style.position="absolute",t.style.opacity=0,t.removeAttribute("hidden"),e.parentNode.appendChild(t);var e=t.scrollWidth,n=t.scrollHeight;return I(t),{width:e,height:n}},showLoadStatePanel:function(){},showMenuPanel:function(){let o=this,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"",t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],i=q.call(this,'[data-pane="'.concat(escape(e),'"]'));if(U.element(i)){let n=i.parentNode,e=Array.from(n.children).find(function(e){return!e.hidden});var a,r;Y.transitions&&!Y.reducedMotion&&(n.style.width="".concat(e.scrollWidth,"px"),n.style.height="".concat(e.scrollHeight,"px"),a=ne.getMenuSize.call(this,i),r=function e(t){t.target===n&&["width","height"].includes(t.propertyName)&&(n.style.width="",n.style.height="",M.call(o,n,le,e))},j.call(this,n,le,r),n.style.width="".concat(a.width,"px"),n.style.height="".concat(a.height,"px")),V(e,!0),V(i,!1),ne.focusFirstMenuItem.call(this,i,t)}},setLoadState:function(e,t){e.appendChild(ne.createButton.call(this,"load-state",{"aria-haspopup":!0,"aria-expanded":!1}));let n=F("div",{class:H({ejs__dialog:!0,"ejs__load-state__container":!0}),hidden:""}),o=F("div");n.appendChild(o),q.call(this,".".concat(H({ejs__dialogs:!0}))).appendChild(n),this.elements.dialogs.loadState=n},setScreenRecord:function(n,e){if(window.MediaRecorder){var o=ne.createButton.call(this,"screen-record",{"aria-haspopup":!0,"aria-expanded":!1,style:"margin-right:auto;"});n.appendChild(o);let e=F("div",{class:H({ejs__dialog:!0,ejs__screenRecord__container:!0}),hidden:""}),t=F("div");e.appendChild(t),q.call(this,".".concat(H({ejs__dialogs:!0}))).appendChild(e),this.elements.dialogs.screenRecord=e}},setCacheManager:function(e,t){var n=ne.createButton.call(this,"cache-manager",{"aria-haspopup":!0,"aria-expanded":!1,style:"margin-right:auto;"});e.appendChild(n);let o=F("div",{class:H({ejs__dialog:!0,ejs__cacheManager__container:!0}),hidden:""}),i=F("div");o.appendChild(i),q.call(this,".".concat(H({ejs__dialogs:!0}))).appendChild(o),this.elements.dialogs.cacheManager=o},setGamepad:function(e,t){var n=ne.createButton.call(this,"gamepad",{"aria-haspopup":!0,"aria-expanded":!1,style:"margin-right:auto;"});e.appendChild(n);let o=F("div",{class:H({ejs__dialog:!0,ejs__gamepad__container:!0}),hidden:""}),i=F("div");o.appendChild(i),q.call(this,".".concat(H({ejs__dialogs:!0}))).appendChild(o),this.elements.dialogs.gamepad=o},setMessage:function(e,t){let n=F("div",{class:H({ejs__dialog:!0}),hidden:""}),o=F("div");n.appendChild(o),q.call(this,".".concat(H({ejs__dialogs:!0}))).appendChild(n),this.elements.dialogs.message=n},setCheat:function(e,t){var n=ne.createButton.call(this,"cheat",{"aria-haspopup":!0,"aria-expanded":!1,style:"margin-right:auto;"});e.appendChild(n);let o=F("div",{class:H({ejs__dialog:!0,ejs__cheat__container:!0}),hidden:""}),i=F("div");o.appendChild(i),q.call(this,".".concat(H({ejs__dialogs:!0}))).appendChild(o),this.elements.dialogs.cheat=o},setStateInfoBarWidget:function(){let e=F("div",{class:H({ejs__widget:!0})}),t=F("div");t.style="color: red;font-size: 17px;padding:10px;text-align:left;text-shadow:1px 1px 1px #000",e.appendChild(t),q.call(this,".".concat(H({ejs__widgets:!0}))).appendChild(e),this.elements.widgets.stateInfo=e,this.elements.widgets.stateInfoDiv=t},setNetplayWidgets:function(){let e=F("div",{class:H({ejs__widget:!0,ejs__widget_netplay:!0})}),t=F("div");e.appendChild(t),q.call(this,".".concat(H({ejs__widgets:!0}))).appendChild(e),this.elements.widgets.netplay=e},setNetplay:function(e,t){e.appendChild(ne.createButton.call(this,"netplay",{"aria-haspopup":!0,"aria-expanded":!1}));let n=F("div",{class:H({ejs__dialog:!0,ejs__netplay__container:!0}),hidden:""}),o=F("div");n.appendChild(o),q.call(this,".".concat(H({ejs__dialogs:!0}))).appendChild(n),this.elements.dialogs.netplay=n,ne.setNetplayWidgets.call(this)},toggleContextMenu:function(n,o){if(L(n.target,H({ejs__dialogs:!0}))){let e=ne.contextMenu.timer;if(this.started){let t=q.call(this,".".concat(H({ejs__contextmenu:!0})," ul"));if(o){ne.contextMenu.style.display="block",ne.contextMenu.style.left="".concat(n.layerX,"px"),ne.contextMenu.style.top="".concat(n.layerY,"px");l.call(this,".".concat(H({ejs__contextmenu:!0})," ul li"));if(null===t.getAttribute("menu")){let e=F("li",{});e.appendChild(F("a",{target:"_blank",href:"https://github.com/EmulatorJS/EmulatorJS"},"EmulatorJS v".concat(this.version))),t.appendChild(e),t.setAttribute("menu","")}e&&clearTimeout(e),e=setTimeout(function(){},4e3),ne.contextMenu.timer=e}else ne.contextMenu.style.display="none"}}},create:function(e){let a=this,t=(ne.storage=new ge(this,"ejs_".concat(this.system,"_settings")),F("div",N(this.config.selectors.controls.wrapper))),o=(ne.contextMenu=F("div",{class:H({ejs__contextmenu:!0}),style:"position: absolute; display:none;z-index:9"}),["<ul>","</ul>"]),i=[];function n(e,t,n){"function"==typeof n?i.push(n):i.push(function(){});n=o.length-1;t?o.splice(n,0,'<li hidden><a href="#" onclick="return false">'+e+"</a></li>"):o.splice(n,0,'<li><a href="#" onclick="return false">'+e+"</a></li>")}n(a.localization("Take Screenshot"),!1,function(e){var t=ee.getScreenData();let n;var o=(n="string"==typeof a.gameName?a.gameName:n)?"".concat(n,"-screenshot.png"):"game.png";let i=document.createElement("a");return i.href=URL.createObjectURL(new Blob([t])),i.download=o,i.click(),setTimeout(function(){URL.revokeObjectURL(i.src)}),!1}),n(a.localization("Quick Save")+" (F2)",!1,function(e){ee.quickSaveState(),oe.contextMenu.style.display="none"}),n(a.localization("Quick Load")+" (F4)",!1,function(e){ee.quickLoadState(),oe.contextMenu.style.display="none"}),ne.contextMenu.innerHTML=o.join("");var r=ne.contextMenu.getElementsByTagName("li");for(let e=0;e<r.length;e++)j.call(a,r[e],"click",i[e]);this.elements.container.appendChild(ne.contextMenu);var s=F("div",{class:H({ejs__dialog:!0,ejs__cache__container:!0}),hidden:""}),s=(q.call(this,".".concat(H({ejs__dialogs:!0}))).appendChild(s),this.elements.dialogs.cache=s,F("div",{class:H({ejs__dialog:!0,ejs__loading__container:!0}),hidden:""}));q.call(this,".".concat(H({ejs__dialogs:!0}))).appendChild(s),this.elements.dialogs.loading=s,t.appendChild(ne.createButton.call(this,"restart")),t.appendChild(ne.createButton.call(this,"play")),t.appendChild(ne.createButton.call(this,"save-state",{"aria-expanded":!1})),ne.setLoadState.call(this,t,e),ne.setScreenRecord.call(this,t,e),ne.setCacheManager.call(this,t,e),ne.supportNetPlay.call(this,t)&&0<parseInt(this.config.gameId,10)&&ne.setNetplay.call(this,t,e),ne.setGamepad.call(this,t,e),ne.setMessage.call(this,t,e),ne.setStateInfoBarWidget.call(this,t,e),ne.setCheat.call(this,t,e),t.appendChild(F("span",{style:"flex:1"}));let c=F("div",{class:H({ejs__volume:!0})});c.appendChild(ne.createButton.call(this,"mute"));s={max:1,step:.01,value:this.config.volume};c.appendChild(ne.createRange.call(this,"volume",X(s,{}))),this.elements.volume=c,t.appendChild(c);let l=F("div",{class:H({ejs__menu:!0})}),d=(l.appendChild(ne.createButton.call(this,"settings",{"aria-haspopup":!0,"aria-expanded":!1})),F("div",{class:H({ejs__menu__container:!0}),hidden:""})),u=F("div"),f=F("div",{"data-pane":"home"}),p=F("div",{role:"menu"}),h=(f.appendChild(p),u.appendChild(f),this.elements.settings.panels.home=f,d.appendChild(u),l.appendChild(d),t.appendChild(l),this.elements.settings.popup=d,this.elements.settings.menu=l,t.appendChild(ne.createButton.call(this,"fullscreen")),this);return t.addEventListener("mousedown",function(){h.onButtonDiv=!0}),this.elements.controls=t,ne.setNormalOptionsMenu.call(this),ne.setCoreOptionsMenu.call(this),t},inject:function(){let e=this,t=(this.icons={"enter-fullscreen":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M208 281.4c-12.5-12.5-32.76-12.5-45.26-.002l-78.06 78.07l-30.06-30.06c-6.125-6.125-14.31-9.367-22.63-9.367c-4.125 0-8.279 .7891-12.25 2.43c-11.97 4.953-19.75 16.62-19.75 29.56v135.1C.0013 501.3 10.75 512 24 512h136c12.94 0 24.63-7.797 29.56-19.75c4.969-11.97 2.219-25.72-6.938-34.87l-30.06-30.06l78.06-78.07c12.5-12.49 12.5-32.75 .002-45.25L208 281.4zM487.1 0h-136c-12.94 0-24.63 7.797-29.56 19.75c-4.969 11.97-2.219 25.72 6.938 34.87l30.06 30.06l-78.06 78.07c-12.5 12.5-12.5 32.76 0 45.26l22.62 22.62c12.5 12.5 32.76 12.5 45.26 0l78.06-78.07l30.06 30.06c9.156 9.141 22.87 11.84 34.87 6.937C504.2 184.6 512 172.9 512 159.1V23.1C512 10.74 501.3 0 487.1 0z"/></svg>',"exit-fullscreen":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M215.1 272h-136c-12.94 0-24.63 7.797-29.56 19.75C45.47 303.7 48.22 317.5 57.37 326.6l30.06 30.06l-78.06 78.07c-12.5 12.5-12.5 32.75-.0012 45.25l22.62 22.62c12.5 12.5 32.76 12.5 45.26 .0013l78.06-78.07l30.06 30.06c6.125 6.125 14.31 9.367 22.63 9.367c4.125 0 8.279-.7891 12.25-2.43c11.97-4.953 19.75-16.62 19.75-29.56V296C239.1 282.7 229.3 272 215.1 272zM296 240h136c12.94 0 24.63-7.797 29.56-19.75c4.969-11.97 2.219-25.72-6.938-34.87l-30.06-30.06l78.06-78.07c12.5-12.5 12.5-32.76 .0002-45.26l-22.62-22.62c-12.5-12.5-32.76-12.5-45.26-.0003l-78.06 78.07l-30.06-30.06c-9.156-9.141-22.87-11.84-34.87-6.937c-11.97 4.953-19.75 16.62-19.75 29.56v135.1C272 229.3 282.7 240 296 240z"/></svg>',gamepad:'<svg viewBox="0 0 640 512"><path fill="currentColor" d="M480 96H160C71.6 96 0 167.6 0 256s71.6 160 160 160c44.8 0 85.2-18.4 114.2-48h91.5c29 29.6 69.5 48 114.2 48 88.4 0 160-71.6 160-160S568.4 96 480 96zM256 276c0 6.6-5.4 12-12 12h-52v52c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-52H76c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h52v-52c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v52h52c6.6 0 12 5.4 12 12v40zm184 68c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48zm80-80c-26.5 0-48-21.5-48-48s21.5-48 48-48 48 21.5 48 48-21.5 48-48 48z"/></svg>',"load-state":'<svg viewBox="0 0 576 512"><path fill="currentColor" d="M572.694 292.093L500.27 416.248A63.997 63.997 0 0 1 444.989 448H45.025c-18.523 0-30.064-20.093-20.731-36.093l72.424-124.155A64 64 0 0 1 152 256h399.964c18.523 0 30.064 20.093 20.73 36.093zM152 224h328v-48c0-26.51-21.49-48-48-48H272l-64-64H48C21.49 64 0 85.49 0 112v278.046l69.077-118.418C86.214 242.25 117.989 224 152 224z"/></svg>',muted:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M301.2 34.85c-11.5-5.188-25.02-3.122-34.44 5.253L131.8 160H48c-26.51 0-48 21.49-48 47.1v95.1c0 26.51 21.49 47.1 48 47.1h83.84l134.9 119.9c5.984 5.312 13.58 8.094 21.26 8.094c4.438 0 8.972-.9375 13.17-2.844c11.5-5.156 18.82-16.56 18.82-29.16V64C319.1 51.41 312.7 40 301.2 34.85zM513.9 255.1l47.03-47.03c9.375-9.375 9.375-24.56 0-33.94s-24.56-9.375-33.94 0L480 222.1L432.1 175c-9.375-9.375-24.56-9.375-33.94 0s-9.375 24.56 0 33.94l47.03 47.03l-47.03 47.03c-9.375 9.375-9.375 24.56 0 33.94c9.373 9.373 24.56 9.381 33.94 0L480 289.9l47.03 47.03c9.373 9.373 24.56 9.381 33.94 0c9.375-9.375 9.375-24.56 0-33.94L513.9 255.1z"/></svg>',netplay:'<svg viewBox="0 0 512 512"><path fill="currentColor" d="M364.215 192h131.43c5.439 20.419 8.354 41.868 8.354 64s-2.915 43.581-8.354 64h-131.43c5.154-43.049 4.939-86.746 0-128zM185.214 352c10.678 53.68 33.173 112.514 70.125 151.992.221.001.44.008.661.008s.44-.008.661-.008c37.012-39.543 59.467-98.414 70.125-151.992H185.214zm174.13-192h125.385C452.802 84.024 384.128 27.305 300.95 12.075c30.238 43.12 48.821 96.332 58.394 147.925zm-27.35 32H180.006c-5.339 41.914-5.345 86.037 0 128h151.989c5.339-41.915 5.345-86.037-.001-128zM152.656 352H27.271c31.926 75.976 100.6 132.695 183.778 147.925-30.246-43.136-48.823-96.35-58.393-147.925zm206.688 0c-9.575 51.605-28.163 104.814-58.394 147.925 83.178-15.23 151.852-71.949 183.778-147.925H359.344zm-32.558-192c-10.678-53.68-33.174-112.514-70.125-151.992-.221 0-.44-.008-.661-.008s-.44.008-.661.008C218.327 47.551 195.872 106.422 185.214 160h141.572zM16.355 192C10.915 212.419 8 233.868 8 256s2.915 43.581 8.355 64h131.43c-4.939-41.254-5.154-84.951 0-128H16.355zm136.301-32c9.575-51.602 28.161-104.81 58.394-147.925C127.872 27.305 59.198 84.024 27.271 160h125.385z"/></svg>',pause:'<svg viewBox="0 0 320 512"><path d="M272 63.1l-32 0c-26.51 0-48 21.49-48 47.1v288c0 26.51 21.49 48 48 48L272 448c26.51 0 48-21.49 48-48v-288C320 85.49 298.5 63.1 272 63.1zM80 63.1l-32 0c-26.51 0-48 21.49-48 48v288C0 426.5 21.49 448 48 448l32 0c26.51 0 48-21.49 48-48v-288C128 85.49 106.5 63.1 80 63.1z"/></svg>',play:'<svg viewBox="0 0 320 512"><path d="M361 215C375.3 223.8 384 239.3 384 256C384 272.7 375.3 288.2 361 296.1L73.03 472.1C58.21 482 39.66 482.4 24.52 473.9C9.377 465.4 0 449.4 0 432V80C0 62.64 9.377 46.63 24.52 38.13C39.66 29.64 58.21 29.99 73.03 39.04L361 215z"/></svg>',restart:'<svg viewBox="0 0 512 512"><path d="M496 48V192c0 17.69-14.31 32-32 32H320c-17.69 0-32-14.31-32-32s14.31-32 32-32h63.39c-29.97-39.7-77.25-63.78-127.6-63.78C167.7 96.22 96 167.9 96 256s71.69 159.8 159.8 159.8c34.88 0 68.03-11.03 95.88-31.94c14.22-10.53 34.22-7.75 44.81 6.375c10.59 14.16 7.75 34.22-6.375 44.81c-39.03 29.28-85.36 44.86-134.2 44.86C132.5 479.9 32 379.4 32 256s100.5-223.9 223.9-223.9c69.15 0 134 32.47 176.1 86.12V48c0-17.69 14.31-32 32-32S496 30.31 496 48z"/></svg>',"save-state":'<svg viewBox="0 0 448 512"><path fill="currentColor" d="M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z"/></svg>',"screen-record":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40"><path fill="currentColor" d="M19.994,0C8.952,0,0,8.952,0,19.995c0,11.043,8.952,19.994,19.994,19.994s19.995-8.952,19.995-19.994,C39.989,8.952,31.037,0,19.994,0z M19.994,27.745c-4.28,0-7.75-3.47-7.75-7.75s3.47-7.75,7.75-7.75s7.75,3.47,7.75,7.75,S24.275,27.745,19.994,27.745z"/></svg>',settings:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M495.9 166.6C499.2 175.2 496.4 184.9 489.6 191.2L446.3 230.6C447.4 238.9 448 247.4 448 256C448 264.6 447.4 273.1 446.3 281.4L489.6 320.8C496.4 327.1 499.2 336.8 495.9 345.4C491.5 357.3 486.2 368.8 480.2 379.7L475.5 387.8C468.9 398.8 461.5 409.2 453.4 419.1C447.4 426.2 437.7 428.7 428.9 425.9L373.2 408.1C359.8 418.4 344.1 427 329.2 433.6L316.7 490.7C314.7 499.7 307.7 506.1 298.5 508.5C284.7 510.8 270.5 512 255.1 512C241.5 512 227.3 510.8 213.5 508.5C204.3 506.1 197.3 499.7 195.3 490.7L182.8 433.6C167 427 152.2 418.4 138.8 408.1L83.14 425.9C74.3 428.7 64.55 426.2 58.63 419.1C50.52 409.2 43.12 398.8 36.52 387.8L31.84 379.7C25.77 368.8 20.49 357.3 16.06 345.4C12.82 336.8 15.55 327.1 22.41 320.8L65.67 281.4C64.57 273.1 64 264.6 64 256C64 247.4 64.57 238.9 65.67 230.6L22.41 191.2C15.55 184.9 12.82 175.3 16.06 166.6C20.49 154.7 25.78 143.2 31.84 132.3L36.51 124.2C43.12 113.2 50.52 102.8 58.63 92.95C64.55 85.8 74.3 83.32 83.14 86.14L138.8 103.9C152.2 93.56 167 84.96 182.8 78.43L195.3 21.33C197.3 12.25 204.3 5.04 213.5 3.51C227.3 1.201 241.5 0 256 0C270.5 0 284.7 1.201 298.5 3.51C307.7 5.04 314.7 12.25 316.7 21.33L329.2 78.43C344.1 84.96 359.8 93.56 373.2 103.9L428.9 86.14C437.7 83.32 447.4 85.8 453.4 92.95C461.5 102.8 468.9 113.2 475.5 124.2L480.2 132.3C486.2 143.2 491.5 154.7 495.9 166.6V166.6zM256 336C300.2 336 336 300.2 336 255.1C336 211.8 300.2 175.1 256 175.1C211.8 175.1 176 211.8 176 255.1C176 300.2 211.8 336 256 336z"/></svg>',volume:'<svg viewBox="0 0 640 512"><path d="M412.6 182c-10.28-8.334-25.41-6.867-33.75 3.402c-8.406 10.24-6.906 25.35 3.375 33.74C393.5 228.4 400 241.8 400 255.1c0 14.17-6.5 27.59-17.81 36.83c-10.28 8.396-11.78 23.5-3.375 33.74c4.719 5.806 11.62 8.802 18.56 8.802c5.344 0 10.75-1.779 15.19-5.399C435.1 311.5 448 284.6 448 255.1S435.1 200.4 412.6 182zM473.1 108.2c-10.22-8.334-25.34-6.898-33.78 3.34c-8.406 10.24-6.906 25.35 3.344 33.74C476.6 172.1 496 213.3 496 255.1s-19.44 82.1-53.31 110.7c-10.25 8.396-11.75 23.5-3.344 33.74c4.75 5.775 11.62 8.771 18.56 8.771c5.375 0 10.75-1.779 15.22-5.431C518.2 366.9 544 313 544 255.1S518.2 145 473.1 108.2zM534.4 33.4c-10.22-8.334-25.34-6.867-33.78 3.34c-8.406 10.24-6.906 25.35 3.344 33.74C559.9 116.3 592 183.9 592 255.1s-32.09 139.7-88.06 185.5c-10.25 8.396-11.75 23.5-3.344 33.74C505.3 481 512.2 484 519.2 484c5.375 0 10.75-1.779 15.22-5.431C601.5 423.6 640 342.5 640 255.1S601.5 88.34 534.4 33.4zM301.2 34.98c-11.5-5.181-25.01-3.076-34.43 5.29L131.8 160.1H48c-26.51 0-48 21.48-48 47.96v95.92c0 26.48 21.49 47.96 48 47.96h83.84l134.9 119.8C272.7 477 280.3 479.8 288 479.8c4.438 0 8.959-.9314 13.16-2.835C312.7 471.8 320 460.4 320 447.9V64.12C320 51.55 312.7 40.13 301.2 34.98z"/></svg>',cheat:'<svg viewBox="0 0 496 512"><path fill="currentColor" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm4 72.6c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.7-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.1-8.4-25.3-7.1-33.8 3.1z" class=""></path></svg>',"cache-manager":'<svg viewBox="0 0 1800 1800"><path d="M896 768q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5T231 896 128 768V598q119 84 325 127t443 43zm0 768q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-170q119 84 325 127t443 43zm0-384q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128V982q119 84 325 127t443 43zM896 0q208 0 385 34.5t280 93.5 103 128v128q0 69-103 128t-280 93.5T896 640t-385-34.5T231 512 128 384V256q0-69 103-128t280-93.5T896 0z"/></svg>'},this.id=Math.floor(1e4*Math.random()),null),o=(this.elements.controls=null,{id:this.id}),n=!0;U.function(this.config.controls)&&(this.config.controls=this.config.controls.call(this.props)),this.config.controls||(this.config.controls=[]),U.element(this.config.controls)||U.string(this.config.controls)?t=this.config.controls:(t=ne.create.call(this,{id:this.id,seektime:this.config.seekTime,speed:this.speed,quality:this.quality}),n=!1);function i(e){let n=e;return Object.entries(o).forEach(function(e){t=2;var e=function(e){if(Array.isArray(e))return e}(e=e)||function(n,o){let i=[],a=!0,t=!1,r=void 0;try{for(let e,t=n[Symbol.iterator]();!(a=(e=t.next()).done)&&(i.push(e.value),!o||i.length!==o);a=!0);}catch(e){t=!0,r=e}finally{try{a||null==_0x4d9086.return||_0x4d9086.return()}finally{if(t)throw r}}return i}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}(),t=e[0],e=e[1];n=pe(n,"{".concat(t,"}"),e)}),n}let a;if(n&&(U.string(this.config.controls)?t=i(t):U.element(t)&&(t.innerHTML=i(t.innerHTML))),U.string(this.config.selectors.controls.container)&&(a=document.querySelector(this.config.selectors.controls.container)),(a=U.element(a)?a:this.elements.container)[U.element(t)?"insertAdjacentElement":"insertAdjacentHTML"]("afterbegin",t),U.element(this.elements.controls)||ne.findElements.call(this),!U.empty(this.elements.buttons)){let t=function(t){let n=e.config.classNames.controlPressed;Object.defineProperty(t,"pressed",{enumerable:!0,get:function(){return L(t,n)},set:function(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0];G(t,n,e)}})};Object.values(this.elements.buttons).filter(Boolean).forEach(function(e){U.array(e)||U.nodeList(e)?Array.from(e).filter(Boolean).forEach(t):t(e)})}window.navigator.userAgent.includes("Edge")&&de(a)}},oe=ne;function Xe(n,o){for(let t=0;t<o.length;t++){let e=o[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}function Je(){if(this.enabled){let e=this.player.elements.buttons.fullscreen;U.element(e)&&(e.pressed=this.active),B.call(this.player,this.target,this.active?"enterfullscreen":"exitfullscreen",!0),W.isIos||function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,t=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(U.element(e)){let e=l.call(this,"button:not(:disabled), input:not(:disabled), [tabindex]"),n=e[0],o=e[e.length-1];c.call(this,this.elements.container,"keydown",function(e){var t;"Tab"===e.key&&9===e.keyCode&&((t=document.activeElement)!==o||e.shiftKey?t===n&&e.shiftKey&&(o.focus(),e.preventDefault()):(n.focus(),e.preventDefault()))},t,!1)}}.call(this.player,this.target,this.active)}}function Ke(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0];e?this.scrollPosition={x:window.scrollX||0,y:window.scrollY||0}:window.scrollTo(this.scrollPosition.x,this.scrollPosition.y),document.body.style.overflow=e?"hidden":"",G(this.target,this.player.config.classNames.fullscreen.fallback,e),Je.call(this)}e=[{key:"native",get:function(){return!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)}},{key:"prefix",get:function(){if(U.function(document.exitFullscreen))return"";let t="";return["webkit","moz","ms"].some(function(e){return!(!U.function(document["".concat(e,"ExitFullscreen")])&&!U.function(document["".concat(e,"CancelFullScreen")])||(t=e,0))}),t}},{key:"property",get:function(){return"moz"===this.prefix?"FullScreen":"Fullscreen"}}],Xe((u=f).prototype,[{key:"update",value:function(){this.enabled,G(this.player.elements.container,this.player.config.classNames.fullscreen.enabled,this.enabled)}},{key:"enter",value:function(){this.enabled&&(f.native?this.prefix?U.empty(this.prefix)||this.target["".concat(this.prefix,"Request").concat(this.property)]():this.target.requestFullscreen():Ke.call(this,!0))}},{key:"exit",value:function(){var e;this.enabled&&(f.native?this.prefix?U.empty(this.prefix)||(e="moz"===this.prefix?"Cancel":"Exit",document["".concat(this.prefix).concat(e).concat(this.property)]()):(document.cancelFullScreen||document.exitFullscreen).call(document):Ke.call(this,!1))}},{key:"toggle",value:function(){this.active?this.exit():this.enter()}},{key:"enabled",get:function(){return f.native}},{key:"active",get:function(){return!!this.enabled&&(f.native?(this.prefix?document["".concat(this.prefix).concat(this.property,"Element")]:document.fullscreenElement)===this.target:L(this.target,this.player.config.classNames.fullscreen.fallback))}},{key:"target",get:function(){return W.isEdge?this.player.game:this.player.elements.container}}]),Xe(u,e);let Qe=f;function f(e){let t=this;if(!(this instanceof f))throw new TypeError("Cannot call a class as a function");this.player=e,this.prefix=f.prefix,this.property=f.property,this.scrollPosition={x:0,y:0},j.call(this.player,document,"ms"===this.prefix?"MSFullscreenChange":"".concat(this.prefix,"fullscreenchange"),function(){Je.call(t)}),this.update()}Ze.prototype={toggleMenu:function(e){oe.toggleMenu.call(this.emulator,e)},firstTouch:function(){let e=this.emulator,t=e.elements;e.touch=!0,G(t.container,e.config.classNames.isTouch,!0)},setTabFocus:function(e){let t=this.emulator,n=t.elements,o=t;var i;clearTimeout(this.focusTimer),"keydown"===e.type&&9!==e.which||("keydown"===e.type&&(this.lastKeyDown=e.timeStamp),i=e.timeStamp-this.lastKeyDown<=20,"focus"===e.type&&!i||(e=o.config.classNames.tabFocus,G(l.call(o,".".concat(e)),e,!1),this.focusTimer=setTimeout(function(){var e=document.activeElement;n.container.contains(e)&&G(document.activeElement,o.config.classNames.tabFocus,!0)},10)))},global:function(){let e=!(0<arguments.length&&void 0!==arguments[0])||arguments[0],t=this.emulator,n=t;c.call(n,document.body,"click",this.toggleMenu,e),ie.call(n,document.body,"touchstart",this.firstTouch),c.call(n,document.body,"keydown focus blur",this.setTabFocus,e,!1,!0),j.call(n,document.body,"keyup",function(e){n.started&&(113===e.which&&(e.shiftKey?null===n.elements.buttons.saveState.getAttribute("hidden")&&B.call(n,n.elements.buttons.saveState,"click"):te.quickSaveState()),115===e.which&&(e.shiftKey?null===n.elements.buttons.loadState.getAttribute("hidden")&&B.call(n,n.elements.buttons.loadState,"click"):te.quickLoadState()),120===e.which&&B.call(n,n.elements.buttons.mute,"click"))})},container:function(){let n,o=this.emulator,i=o.elements,a=o,t=null;j.call(a,i.container,"mousemove mouseleave touchstart touchmove enterfullscreen exitfullscreen start-game",function(e){let t=i.controls;t&&"enterfullscreen"===e.type&&(t.pressed=!1,t.hover=!1);if(["touchstart","touchmove","mousemove","start-game"].includes(e.type)){if("nds"===getSystem(o.system,!0)&&"melonds"!==getSystem(o.system,o.coreVer)&&"mousemove"==e.type&&m&&m.Module&&m.Module.canvas&&(document.pointerLockElement===m.Module.canvas||document.mozPointerLockElement===m.Module.canvas))return void K.toggleControls.call(a,!1);!te||"undefined"!=te.virtualGamepadContainer&&null!==te.virtualGamepadContainer||(K.toggleControls.call(a,!0),e=a.touch?3e3:2e3,clearTimeout(n),n=setTimeout(function(){return K.toggleControls.call(a,!1)},e),i.controls.setAttribute("data-timer",n))}}),j.call(a,window,"resize",function(e){let t=a.elements.container.clientHeight,n=l.call(a,".".concat(H({ejs__menu__container:!0}),' [role="menu"]'));Array.from(n).forEach(function(e){e.style.maxHeight="".concat(t-95,"px"),e.style.overflow="auto"}),m.Module&&m.Module.canvas,a.elements.container.clientWidth/a.elements.container.clientHeight<1.3?G(a.elements.container,H({portrait:!0}),!0):G(a.elements.container,H({portrait:!0}),!1)}),B.call(a,window,"resize"),j.call(a,a.elements.container,"enterfullscreen",function(e){if(m.isMobileDevice&&window.screen&&screen.orientation&&"function"==typeof screen.orientation.lock)try{screen.orientation.lock("landscape")}catch(e){}else if(m.isMobileDevice&&window.ScreenOrientation&&"function"==typeof ScreenOrientation.lock)try{ScreenOrientation.lock("landscape")}catch(e){}if(2===a.coreVer&&m.Module){let e=50;clearInterval(t),t=setInterval(function(){m.Module.setCanvasSize(window.innerWidth,window.innerHeight),e<0&&clearInterval(t),e--},100)}setTimeout(function(){B.call(a,window,"resize")},300)}),j.call(a,a.elements.container,"exitfullscreen",function(e){if(m.isMobileDevice&&window.screen&&screen.orientation&&"function"==typeof screen.orientation.unlock)try{screen.orientation.unlock()}catch(e){}else if(m.isMobileDevice&&window.ScreenOrientation&&"function"==typeof ScreenOrientation.unlock)try{ScreenOrientation.unlock()}catch(e){}2===a.coreVer&&m.Module&&(clearInterval(t),m.Module.setCanvasSize(800,600)),setTimeout(function(){B.call(a,window,"resize")},300)}),j.call(a,a.elements.container,"start-game",function(e){let t=window.document.createEvent("UIEvents");t.initUIEvent("resize",!0,!1,window,0),window.dispatchEvent(t),G(a.elements.container,H({"game-started":!0}),!0)}),j.call(a,a.elements.container,"blur",function(e){let t=e.currentTarget;setTimeout(function(){t.contains(document.activeElement)||B.call(a,a.elements,"blurgame")},0)}),j.call(a,a.elements.container,"focus",function(e){let t=e.currentTarget;setTimeout(function(){t.contains(document.activeElement)&&B.call(a,a.elements,"focusgame")},0)})},media:function(){let t=this.emulator,o=t.elements,i=t;j.call(i,i.game,"volumechange",function(e){return oe.updateVolume.call(i,e)}),j.call(i,o.container,"contextmenu",function(e){i.touch||i.lightgun||oe.toggleContextMenu.call(i,e,!0),e.preventDefault()},!1),j.call(i,o.container,"mousewheel",function(e){e.stopPropagation()},!1),j.call(i,o.container,"mousedown",function(e){"nds"===getSystem(t.system,!0)&&"melonds"!==getSystem(t.system,t.coreVer)&&m&&m.Module&&m.Module.canvas&&!m.isMobileDevice&&document.pointerLockElement!==m.Module.canvas&&document.mozPointerLockElement!==m.Module.canvas&&t.started&&!t.connected&&setTimeout(function(){!0!==t.onButtonDiv&&(m.Module.canvas.requestPointerLock=m.Module.canvas.requestPointerLock||m.Module.canvas.mozRequestPointerLock,m.Module.canvas.requestPointerLock()),t.onButtonDiv=!1},100),i.touch||oe.toggleContextMenu.call(i,e,!1)},!1),j.call(i,i.game,"volumechange",function(){i.storage.set({volume:i.volume,muted:i.muted}),te.setVolume&&te.setVolume()});var e=i.config.events.concat(["keyup","keydown"]).join(" ");j.call(i,i.game,e,function(e){let t=e.detail,n=void 0===t?{}:t;"error"===e.type&&(n=i.game.error),B.call(i,o.container,e.type,!0,n)})},proxy:function(e,t,n){let o=this.emulator,i=o.config.listeners[n],a=!0;(a=U.function(i)?i.call(o,e):a)&&U.function(t)&&t.call(o,e)},bind:function(e,t,n,o){let i=this,a=!(4<arguments.length&&void 0!==arguments[4])||arguments[4],r=this.emulator,s=r,c=s.config.listeners[o],l=U.function(c);j.call(s,e,t,function(e){return i.proxy(e,n,o)},a&&!l)},controls:function(){let a=this,s=this.emulator,t=s.elements,n=W.isIE?"change":"input";var e;this.bind(t.buttons.mute,"click",function(){s.muted=!s.muted},"mute"),this.bind(t.buttons.fullscreen,"click",function(){s.fullscreen.toggle()},"fullscreen"),this.bind(t.buttons.gamepad,"click",function(){K.toggleControls.call(s,!1),V(t.dialogs.gamepad,!1)},"mute"),this.bind(t.buttons.saveState,"click",function(){!async function(){B.call(s,s.elements.container,"savestate-start",!1,{});var n=await te.saveState(),o=te.getScreenData();if(!ee.saveLoadDB.call(s,"save")){if(U.function(s.config.onsavestate))s.config.onsavestate.call(null,{screenshot:o,state:n});else{let e=s.getStartName(!0).split("/").pop();o=new Blob([n]),n=(e.includes(".")&&(e=e.substring(0,e.length-e.split(".").pop().length-1)),(e="string"==typeof s.gameName?s.gameName:e)?"".concat(e,".state"):"game.state");let t=document.createElement("a");t.download=n,t.href=URL.createObjectURL(o),t.click(),setTimeout(function(){URL.revokeObjectURL(t.href)},2e3)}s.elements.container.focus()}}(),saveSaveFiles()},"mute"),this.bind(t.buttons.loadState,"click",function(){B.call(s,s.elements.container,"loadstate",!1,{})},"mute"),this.bind(t.buttons.settings,"click",function(e){e.stopPropagation(),oe.toggleMenu.call(s,e)}),this.bind(t.buttons.settings,"keyup",function(e){var t=e.which;[13,32].includes(t)&&(13!==t?(e.preventDefault(),e.stopPropagation(),oe.toggleMenu.call(s,e)):oe.focusFirstMenuItem.call(s,null,!0))},null,!1),this.bind(t.settings.menu,"keydown",function(e){27===e.which&&oe.toggleMenu.call(s,e)}),W.isIos&&(e=l.call(s,'input[type="range"]'),Array.from(e).forEach(function(e){return a.bind(e,n,function(e){return de(e.target)})})),W.isWebkit&&Array.from(l.call(s,'input[type="range"]')).forEach(function(e){a.bind(e,"input",function(e){return oe.updateRangeFill.call(s,e.target)})}),this.bind(t.inputs.volume,n,function(e){s.volume=e.target.value},"volume"),this.bind(t.controls,"mouseenter mouseleave",function(e){"mouseleave"===e.type&&null===e.toElement?t.controls.hover=!0:t.controls.hover=!s.touch&&"mouseenter"===e.type}),this.bind(t.controls,"mousedown mouseup touchstart touchend touchcancel",function(e){["mousedown","touchstart"].includes(e.type)?(t.controls.pressed=!0,e=t.controls.getAttribute("data-timer2"),clearTimeout(e)):(e=setTimeout(function(){t.controls.pressed=!1},4e3),t.controls.setAttribute("data-timer2",e))}),this.bind(t.controls,"focusin focusout",function(e){let t=s.config,n=s.elements,o="focusin"===e.type,i=n.controls.getAttribute("data-timer");G(n.controls,t.classNames.noTransition,o),K.toggleControls.call(s,o),o&&(setTimeout(function(){G(n.controls,t.classNames.noTransition,!1)},0),e=a.touch?3e3:4e3,clearTimeout(i),i=setTimeout(function(){return K.toggleControls.call(s,!1)},e),n.controls.setAttribute("data-timer",i))}),this.bind(t.inputs.volume,"wheel",function(e){let t=e.webkitDirectionInvertedFromDevice,n=function(n,o){if(Array.isArray(n))return n;let i=[],a=!0,t=!1,r=void 0;try{for(let e,t=n[Symbol.iterator]();!(a=(e=t.next()).done)&&(i.push(e.value),!o||i.length!==o);a=!0);}catch(e){t=!0,r=e}finally{try{a||null==_0x1bb8de.return||_0x1bb8de.return()}finally{if(t)throw r}}return i}([e.deltaX,-e.deltaY].map(function(e){return t?-e:e}),2),o=n[0],i=n[1],a=Math.sign(Math.abs(o)>Math.abs(i)?o:i);s.increaseVolume(a/50);var r=s.game.volume;(1===a&&r<1||-1===a&&0<r)&&e.preventDefault()},"volume",!1),this.bind(t.controls,"contextmenu",function(e){e.stopPropagation()}),this.bind(t.contextMenu,"contextmenu",function(e){e.stopPropagation()})}};let $e=Ze;function Ze(e){if(!(this instanceof Ze))throw new TypeError("Cannot call a class as a function");this.emulator=e,this.lastKey=null,this.focusTimer=null,this.lastKeyDown=null,this.toggleMenu=this.toggleMenu.bind(this),this.setTabFocus=this.setTabFocus.bind(this),this.firstTouch=this.firstTouch.bind(this)}function et(n,o){for(let t=0;t<o.length;t++){let e=o[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}u=[{key:"setup",value:function(e){let t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=null;return U.string(e)?n=Array.from(document.querySelectorAll(e)):U.nodeList(e)?n=Array.from(e):U.array(e)&&(n=e.filter(U.element)),U.empty(n)?null:n.map(function(e){return new nt(e,t)})}}],et((e=nt).prototype,[{key:"restart",value:function(){this.currentTime=0}},{key:"increaseVolume",value:function(e){var t=this.game.muted?0:this.volume;this.volume=t+(U.number(e)?e:0)}},{key:"decreaseVolume",value:function(e){this.increaseVolume(-e)}},{key:"toggleControls",value:function(e){return!!this.started&&((e=G(this.elements.container,this.config.classNames.hideControls,void 0===e?void 0:!e))&&oe.toggleMenu.call(this,!1),!e)}},{key:"getStartName",value:function(e){let t;var n=/[#<$+%>!`&*'|{}/\\?"=@:^\r\n]/gi;return!this.startName||!0!==e&&"rom"===this.startName?U.string(this.config.gameUrl)&&!this.config.gameUrl.startsWith("blob:")?t=this.config.gameUrl.split("/").pop().split("?")[0].replace(n,""):this.gameName?t=this.gameName.replace(n,"")+"."+this.system:this.config.gameId?t=this.config.gameId+"."+this.system:U.string(this.config.gameUrl)&&!0===e?t=this.config.gameUrl.split("/").pop().split("?")[0].replace(n,""):!0===e&&(t="rom"):t=this.startName,t}},{key:"loadState",value:function(e){te.loadState(e,0)}},{key:"on",value:function(e,t){j.call(this,this.elements.container,e,t)}},{key:"once",value:function(e,t){ie.call(this,this.elements.container,e,t)}},{key:"off",value:function(e,t){M(this.elements.container,e,t)}},{key:"playing",set:function(){let t=!(0<arguments.length&&void 0!==arguments[0])||arguments[0];Array.from(this.elements.buttons.play||[]).forEach(function(e){e.pressed=t}),this.paused=!t},get:function(){return Boolean(this.ready&&!this.paused)}},{key:"volume",set:function(e){let t=e;U.string(t)&&(t=Number(t)),U.number(t)||(t=this.storage.get("volume")),(t=1<(t=U.number(t)?t:this.config.volume)?1:t)<0&&(t=0),this.config.volume=t,this.game.volume=t,!U.empty(e)&&this.muted&&0<t&&(this.muted=!1)},get:function(){return Number(this.game.volume)}},{key:"muted",set:function(e){let t=e;U.boolean(t)||(t=this.storage.get("muted")),U.boolean(t)||(t=this.config.muted),this.config.muted=t,this.game.muted=t},get:function(){return Boolean(this.game.muted)}}]),et(e,u);let tt=nt;function nt(r,s){return new Promise(async function(e,t){function i(e,t){var n=window.location.pathname.split("/").pop();let o=window.location.pathname.substring(0,window.location.pathname.length-n.length);var i,a=o.split("/"),r=e.split("/");let s=[];for(let e=0;e<a.length;e++)""!=a[e]&&s.push(a[e]);if(!(e.startsWith("/")||e.includes("://")||e.includes("http:")||e.includes("https:")||e.includes("file:")||e.includes("blob:"))){for(let e=0;e<r.length;e++)""!=r[e]&&"."!=r[e]&&(".."==r[e]?0<s.length&&(s=("/"===(i=s.join("/"))?"/":i.substring(0,i.length-i.split("/").pop().length)).split("/")):s.push(r[e]));(e=s.join("/")).startsWith("/")||(e="/"+e),e=window.location.protocol+"//"+window.location.host+e}return!(e=e.startsWith("/")?window.location.protocol+"//"+window.location.host+e:e).endsWith("/")&&t&&(e+="/"),e}let o=this;this.localization=e=>e,this.version="3.1.6",this.system="",this.adUrl=null,this.gameName=null,this.loadStateOnStart=!1,this.statesSupported=!0,this.mameCore=null,this.startOnLoad=!1,this.dataPath="",this.customPaths=null,this.hash="",this.lightgun=!1,this.mouse=!1,this.multitap=!1,this.ready=!1,this.paused=!0,this.started=!1,this.touch=Y.touch,this.game=r,U.string(this.game)&&(this.game=document.querySelectorAll(this.game)),(window.jQuery&&this.game instanceof jQuery||U.nodeList(this.game)||U.array(this.game))&&(this.game=this.game[0]),this.game=this.game,this.game.innerHTML="",this.config=X({},T,nt.defaults,s||{}),this.config.settings&&this.config.settings.volume&&(T.volume=this.config.settings.volume),this.config.settings&&this.config.settings.defaultControllers&&(ee.defaultControllers=this.config.settings.defaultControllers),this.coreVer=1,this.lightgun=this.config.lightgun,this.loadStateOnStart=this.config.loadStateOnStart||!1,this.adUrl=this.config.adUrl||null,U.string(this.config.gameName)&&(this.gameName=this.config.gameName||null),this.mouse=this.config.mouse,this.multitap=this.config.multitap,this.cheats=this.config.cheats,this.cheats||(this.cheats=[]);var n="string"==typeof(n=this.config.netplayUrl)?(n.endsWith("/")||(n+="/"),n):null,n=(this.listUrl=n,this.socketUrl=n,this.mameCore=this.config.mameCore||null,this.color=this.config.color,this.startOnLoad=this.config.startOnLoad||!1,this.statesSupported=this.config.statesSupported||!0,this.customPaths=function(e){if(!e)return{};let t={};for(var n in e)"string"==typeof e[n]&&(t[n]=i(e[n]));return t}(this.config.paths),this.dataPath=function(n){if("string"==typeof n)return i(n,!0);{n=window.location.href;let e=n;var o=e.split("/").pop();let t=e.substring(0,e.length-o.length);return"/"==n?window.location.protocol+"//"+window.location.host+"/":((t=t.startsWith("/")?window.location.protocol+"//"+window.location.host+t:t).endsWith("/")||(t+="/"),t)}}(this.config.dataPath),this.localization=await async function(e,t,n){let o={};if(n&&"string"==typeof n&&"en-US"!==n){t=t&&"string"==typeof t[n+".json"]?t[n+".json"]:e+"localization/"+n+".json";try{let e=await fetch(t);var i=await e.text();o=JSON.parse(i),T.i18n=o.i18n,ne.normalOptions=o.normalOptions}catch(e){console.warn("error setting localization",e)}}return function(e){return"string"==typeof o[e]?o[e]:(n&&"en-US"!==n&&"undefined"!=typeof EJS_DEBUG_XX&&!0===EJS_DEBUG_XX&&console.warn('Missing translation for "'+e+'". Language is set to "'+n+'"'),e)}}(this.dataPath,this.customPaths,this.config.lang),this.config=X({},T,nt.defaults,s||{}),Object.keys(this.config.classNames).forEach(function(n){var e=o;if(U.object(e.config.classNames[n]))Object.keys(e.config.classNames[n]).forEach(function(e){let t={};t[o.config.classNames[n][e]]=!0,o.config.classNames[n][e]=H(t)});else{let e={};e[o.config.classNames[n]]=!0,o.config.classNames[n]=H(e)}}),this.config.selectors.controls.wrapper=".".concat(H({ejs__controls:!0})),this.config.selectors.container=".".concat(H({ejs:!0})),this.system=this.config.system,this.elements={container:null,buttons:{},display:{},inputs:{},settings:{popup:null,menu:null,panels:{},buttons:{}},dialogs:{gamepad:null,loading:null,netplay:null},widgets:{}},this.fullscreen={active:!1},this.config.mute=!0,this.eventListeners=[],this.listeners=new $e(this),this.storage=new ge(this,"ejs_settings"),this.game.emulator=this,U.element(this.elements.container)||(this.elements.container=F("div"),k(this.game,this.elements.container)),F("div",{class:H({ejs__widgets:!0})})),n=(this.elements.container.appendChild(n),F("div",{class:H({ejs__dialogs:!0})}));this.elements.container.appendChild(n),K.addStyleHook.call(this),te.setup.call(this),K.build.call(this),this.listeners.container(),this.listeners.global(),this.fullscreen=new Qe(this),m.create.call(this);let a=document.createElement("script");a.src=this.customPaths&&"string"==typeof this.customPaths["webrtc-adapter.js"]?this.customPaths["webrtc-adapter.js"]:this.dataPath+"webrtc-adapter.js",document.body.appendChild(a),e(this)}.bind(this))}tt.defaults={},i.default=tt}]).default;