UNPKG

phaser4-rex-plugins

Version:
8 lines (7 loc) 37.6 kB
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).rexlocalforagefilesplugin=n()}(void 0,(function(){var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function r(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var t={exports:{}}; /*! localForage -- Offline Storage, Improved Version 1.10.0 https://localforage.github.io/localForage (c) 2013-2017 Mozilla, Apache License 2.0 */!function(n){n.exports=function e(n,t,o){function i(u,c){if(!t[u]){if(!n[u]){if(!c&&r)return r(u);if(a)return a(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var s=t[u]={exports:{}};n[u][0].call(s.exports,(function(e){var r=n[u][1][e];return i(r||e)}),s,s.exports,e,n,t,o)}return t[u].exports}for(var a=r,u=0;u<o.length;u++)i(o[u]);return i}({1:[function(n,r,t){(function(e){var n,t,o=e.MutationObserver||e.WebKitMutationObserver;if(o){var i=0,a=new o(s),u=e.document.createTextNode("");a.observe(u,{characterData:!0}),n=function(){u.data=i=++i%2}}else if(e.setImmediate||void 0===e.MessageChannel)n="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var n=e.document.createElement("script");n.onreadystatechange=function(){s(),n.onreadystatechange=null,n.parentNode.removeChild(n),n=null},e.document.documentElement.appendChild(n)}:function(){setTimeout(s,0)};else{var c=new e.MessageChannel;c.port1.onmessage=s,n=function(){c.port2.postMessage(0)}}var f=[];function s(){var e,n;t=!0;for(var r=f.length;r;){for(n=f,f=[],e=-1;++e<r;)n[e]();r=f.length}t=!1}function l(e){1!==f.push(e)||t||n()}r.exports=l}).call(this,void 0!==e?e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,n,r){var t=e(1);function o(){}var i={},a=["REJECTED"],u=["FULFILLED"],c=["PENDING"];function f(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=c,this.queue=[],this.outcome=void 0,e!==o&&h(this,e)}function s(e,n,r){this.promise=e,"function"==typeof n&&(this.onFulfilled=n,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function l(e,n,r){t((function(){var t;try{t=n(r)}catch(n){return i.reject(e,n)}t===e?i.reject(e,new TypeError("Cannot resolve promise with itself")):i.resolve(e,t)}))}function d(e){var n=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof n)return function(){n.apply(e,arguments)}}function h(e,n){var r=!1;function t(n){r||(r=!0,i.reject(e,n))}function o(n){r||(r=!0,i.resolve(e,n))}function a(){n(o,t)}var u=v(a);"error"===u.status&&t(u.value)}function v(e,n){var r={};try{r.value=e(n),r.status="success"}catch(e){r.status="error",r.value=e}return r}function p(e){return e instanceof this?e:i.resolve(new this(o),e)}function y(e){var n=new this(o);return i.reject(n,e)}function m(e){var n=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,t=!1;if(!r)return this.resolve([]);for(var a=new Array(r),u=0,c=-1,f=new this(o);++c<r;)s(e[c],c);return f;function s(e,o){function c(e){a[o]=e,++u!==r||t||(t=!0,i.resolve(f,a))}n.resolve(e).then(c,(function(e){t||(t=!0,i.reject(f,e))}))}}function b(e){var n=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var r=e.length,t=!1;if(!r)return this.resolve([]);for(var a=-1,u=new this(o);++a<r;)c(e[a]);return u;function c(e){n.resolve(e).then((function(e){t||(t=!0,i.resolve(u,e))}),(function(e){t||(t=!0,i.reject(u,e))}))}}n.exports=f,f.prototype.catch=function(e){return this.then(null,e)},f.prototype.then=function(e,n){if("function"!=typeof e&&this.state===u||"function"!=typeof n&&this.state===a)return this;var r=new this.constructor(o);return this.state!==c?l(r,this.state===u?e:n,this.outcome):this.queue.push(new s(r,e,n)),r},s.prototype.callFulfilled=function(e){i.resolve(this.promise,e)},s.prototype.otherCallFulfilled=function(e){l(this.promise,this.onFulfilled,e)},s.prototype.callRejected=function(e){i.reject(this.promise,e)},s.prototype.otherCallRejected=function(e){l(this.promise,this.onRejected,e)},i.resolve=function(e,n){var r=v(d,n);if("error"===r.status)return i.reject(e,r.value);var t=r.value;if(t)h(e,t);else{e.state=u,e.outcome=n;for(var o=-1,a=e.queue.length;++o<a;)e.queue[o].callFulfilled(n)}return e},i.reject=function(e,n){e.state=a,e.outcome=n;for(var r=-1,t=e.queue.length;++r<t;)e.queue[r].callRejected(n);return e},f.resolve=p,f.reject=y,f.all=m,f.race=b},{1:1}],3:[function(n,r,t){(function(e){"function"!=typeof e.Promise&&(e.Promise=n(2))}).call(this,void 0!==e?e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,n,r){var t="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};function o(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function i(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}var a=i();function u(){try{if(!a||!a.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),n="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||n)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}function c(e,n){e=e||[],n=n||{};try{return new Blob(e,n)}catch(o){if("TypeError"!==o.name)throw o;for(var r=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),t=0;t<e.length;t+=1)r.append(e[t]);return r.getBlob(n.type)}}"undefined"==typeof Promise&&e(3);var f=Promise;function s(e,n){n&&e.then((function(e){n(null,e)}),(function(e){n(e)}))}function l(e,n,r){"function"==typeof n&&e.then(n),"function"==typeof r&&e.catch(r)}function d(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function h(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var v="local-forage-detect-blob-support",p=void 0,y={},m=Object.prototype.toString,b="readonly",g="readwrite";function _(e){for(var n=e.length,r=new ArrayBuffer(n),t=new Uint8Array(r),o=0;o<n;o++)t[o]=e.charCodeAt(o);return r}function w(e){return new f((function(n){var r=e.transaction(v,g),t=c([""]);r.objectStore(v).put(t,"key"),r.onabort=function(e){e.preventDefault(),e.stopPropagation(),n(!1)},r.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),r=navigator.userAgent.match(/Edge\//);n(r||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}function I(e){return"boolean"==typeof p?f.resolve(p):w(e).then((function(e){return p=e}))}function S(e){var n=y[e.name],r={};r.promise=new f((function(e,n){r.resolve=e,r.reject=n})),n.deferredOperations.push(r),n.dbReady?n.dbReady=n.dbReady.then((function(){return r.promise})):n.dbReady=r.promise}function E(e){var n=y[e.name].deferredOperations.pop();if(n)return n.resolve(),n.promise}function A(e,n){var r=y[e.name].deferredOperations.pop();if(r)return r.reject(n),r.promise}function j(e,n){return new f((function(r,t){if(y[e.name]=y[e.name]||P(),e.db){if(!n)return r(e.db);S(e),e.db.close()}var o=[e.name];n&&o.push(e.version);var i=a.open.apply(a,o);n&&(i.onupgradeneeded=function(n){var r=i.result;try{r.createObjectStore(e.storeName),n.oldVersion<=1&&r.createObjectStore(v)}catch(r){if("ConstraintError"!==r.name)throw r;console.warn('The database "'+e.name+'" has been upgraded from version '+n.oldVersion+" to version "+n.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),i.onerror=function(e){e.preventDefault(),t(i.error)},i.onsuccess=function(){var n=i.result;n.onversionchange=function(e){e.target.close()},r(n),E(e)}}))}function N(e){return j(e,!1)}function O(e){return j(e,!0)}function D(e,n){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),t=e.version<e.db.version,o=e.version>e.db.version;if(t&&(e.version!==n&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),o||r){if(r){var i=e.db.version+1;i>e.version&&(e.version=i)}return!0}return!1}function x(e){return new f((function(n,r){var t=new FileReader;t.onerror=r,t.onloadend=function(r){var t=btoa(r.target.result||"");n({__local_forage_encoded_blob:!0,data:t,type:e.type})},t.readAsBinaryString(e)}))}function R(e){return c([_(atob(e.data))],{type:e.type})}function C(e){return e&&e.__local_forage_encoded_blob}function k(e){var n=this,r=n._initReady().then((function(){var e=y[n._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return l(r,e,e),r}function T(e){S(e);for(var n=y[e.name],r=n.forages,t=0;t<r.length;t++){var o=r[t];o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,N(e).then((function(n){return e.db=n,D(e)?O(e):n})).then((function(t){e.db=n.db=t;for(var o=0;o<r.length;o++)r[o]._dbInfo.db=t})).catch((function(n){throw A(e,n),n}))}function B(e,n,r,t){void 0===t&&(t=1);try{var o=e.db.transaction(e.storeName,n);r(null,o)}catch(o){if(t>0&&(!e.db||"InvalidStateError"===o.name||"NotFoundError"===o.name))return f.resolve().then((function(){if(!e.db||"NotFoundError"===o.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),O(e)})).then((function(){return T(e).then((function(){B(e,n,r,t-1)}))})).catch(r);r(o)}}function P(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function M(e){var n=this,r={db:null};if(e)for(var t in e)r[t]=e[t];var o=y[r.name];o||(o=P(),y[r.name]=o),o.forages.push(n),n._initReady||(n._initReady=n.ready,n.ready=k);var i=[];function a(){return f.resolve()}for(var u=0;u<o.forages.length;u++){var c=o.forages[u];c!==n&&i.push(c._initReady().catch(a))}var s=o.forages.slice(0);return f.all(i).then((function(){return r.db=o.db,N(r)})).then((function(e){return r.db=e,D(r,n._defaultConfig.version)?O(r):e})).then((function(e){r.db=o.db=e,n._dbInfo=r;for(var t=0;t<s.length;t++){var i=s[t];i!==n&&(i._dbInfo.db=r.db,i._dbInfo.version=r.version)}}))}function F(e,n){var r=this;e=d(e);var t=new f((function(n,t){r.ready().then((function(){B(r._dbInfo,b,(function(o,i){if(o)return t(o);try{var a=i.objectStore(r._dbInfo.storeName).get(e);a.onsuccess=function(){var e=a.result;void 0===e&&(e=null),C(e)&&(e=R(e)),n(e)},a.onerror=function(){t(a.error)}}catch(e){t(e)}}))})).catch(t)}));return s(t,n),t}function L(e,n){var r=this,t=new f((function(n,t){r.ready().then((function(){B(r._dbInfo,b,(function(o,i){if(o)return t(o);try{var a=i.objectStore(r._dbInfo.storeName).openCursor(),u=1;a.onsuccess=function(){var r=a.result;if(r){var t=r.value;C(t)&&(t=R(t));var o=e(t,r.key,u++);void 0!==o?n(o):r.continue()}else n()},a.onerror=function(){t(a.error)}}catch(e){t(e)}}))})).catch(t)}));return s(t,n),t}function z(e,n,r){var t=this;e=d(e);var o=new f((function(r,o){var i;t.ready().then((function(){return i=t._dbInfo,"[object Blob]"===m.call(n)?I(i.db).then((function(e){return e?n:x(n)})):n})).then((function(n){B(t._dbInfo,g,(function(i,a){if(i)return o(i);try{var u=a.objectStore(t._dbInfo.storeName);null===n&&(n=void 0);var c=u.put(n,e);a.oncomplete=function(){void 0===n&&(n=null),r(n)},a.onabort=a.onerror=function(){var e=c.error?c.error:c.transaction.error;o(e)}}catch(e){o(e)}}))})).catch(o)}));return s(o,r),o}function U(e,n){var r=this;e=d(e);var t=new f((function(n,t){r.ready().then((function(){B(r._dbInfo,g,(function(o,i){if(o)return t(o);try{var a=i.objectStore(r._dbInfo.storeName).delete(e);i.oncomplete=function(){n()},i.onerror=function(){t(a.error)},i.onabort=function(){var e=a.error?a.error:a.transaction.error;t(e)}}catch(e){t(e)}}))})).catch(t)}));return s(t,n),t}function q(e){var n=this,r=new f((function(e,r){n.ready().then((function(){B(n._dbInfo,g,(function(t,o){if(t)return r(t);try{var i=o.objectStore(n._dbInfo.storeName).clear();o.oncomplete=function(){e()},o.onabort=o.onerror=function(){var e=i.error?i.error:i.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return s(r,e),r}function H(e){var n=this,r=new f((function(e,r){n.ready().then((function(){B(n._dbInfo,b,(function(t,o){if(t)return r(t);try{var i=o.objectStore(n._dbInfo.storeName).count();i.onsuccess=function(){e(i.result)},i.onerror=function(){r(i.error)}}catch(e){r(e)}}))})).catch(r)}));return s(r,e),r}function W(e,n){var r=this,t=new f((function(n,t){e<0?n(null):r.ready().then((function(){B(r._dbInfo,b,(function(o,i){if(o)return t(o);try{var a=i.objectStore(r._dbInfo.storeName),u=!1,c=a.openKeyCursor();c.onsuccess=function(){var r=c.result;r?0===e||u?n(r.key):(u=!0,r.advance(e)):n(null)},c.onerror=function(){t(c.error)}}catch(e){t(e)}}))})).catch(t)}));return s(t,n),t}function K(e){var n=this,r=new f((function(e,r){n.ready().then((function(){B(n._dbInfo,b,(function(t,o){if(t)return r(t);try{var i=o.objectStore(n._dbInfo.storeName).openKeyCursor(),a=[];i.onsuccess=function(){var n=i.result;n?(a.push(n.key),n.continue()):e(a)},i.onerror=function(){r(i.error)}}catch(e){r(e)}}))})).catch(r)}));return s(r,e),r}function J(e,n){n=h.apply(this,arguments);var r=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var t,o=this;if(e.name){var i=e.name===r.name&&o._dbInfo.db?f.resolve(o._dbInfo.db):N(e).then((function(n){var r=y[e.name],t=r.forages;r.db=n;for(var o=0;o<t.length;o++)t[o]._dbInfo.db=n;return n}));t=e.storeName?i.then((function(n){if(n.objectStoreNames.contains(e.storeName)){var r=n.version+1;S(e);var t=y[e.name],o=t.forages;n.close();for(var i=0;i<o.length;i++){var u=o[i];u._dbInfo.db=null,u._dbInfo.version=r}var c=new f((function(n,t){var o=a.open(e.name,r);o.onerror=function(e){o.result.close(),t(e)},o.onupgradeneeded=function(){o.result.deleteObjectStore(e.storeName)},o.onsuccess=function(){var e=o.result;e.close(),n(e)}}));return c.then((function(e){t.db=e;for(var n=0;n<o.length;n++){var r=o[n];r._dbInfo.db=e,E(r._dbInfo)}})).catch((function(n){throw(A(e,n)||f.resolve()).catch((function(){})),n}))}})):i.then((function(n){S(e);var r=y[e.name],t=r.forages;n.close();for(var o=0;o<t.length;o++)t[o]._dbInfo.db=null;var i=new f((function(n,r){var t=a.deleteDatabase(e.name);t.onerror=function(){var e=t.result;e&&e.close(),r(t.error)},t.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},t.onsuccess=function(){var e=t.result;e&&e.close(),n(e)}}));return i.then((function(e){r.db=e;for(var n=0;n<t.length;n++)E(t[n]._dbInfo)})).catch((function(n){throw(A(e,n)||f.resolve()).catch((function(){})),n}))}))}else t=f.reject("Invalid arguments");return s(t,n),t}var Q={_driver:"asyncStorage",_initStorage:M,_support:u(),iterate:L,getItem:F,setItem:z,removeItem:U,clear:q,length:H,key:W,keys:K,dropInstance:J};function X(){return"function"==typeof openDatabase}var G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",V="~~local_forage_type~",Y=/^~~local_forage_type~([^~]+)~/,Z="__lfsc__:",$=Z.length,ee="arbf",ne="blob",re="si08",te="ui08",oe="uic8",ie="si16",ae="si32",ue="ur16",ce="ui32",fe="fl32",se="fl64",le=$+ee.length,de=Object.prototype.toString;function he(e){var n,r,t,o,i,a=.75*e.length,u=e.length,c=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var f=new ArrayBuffer(a),s=new Uint8Array(f);for(n=0;n<u;n+=4)r=G.indexOf(e[n]),t=G.indexOf(e[n+1]),o=G.indexOf(e[n+2]),i=G.indexOf(e[n+3]),s[c++]=r<<2|t>>4,s[c++]=(15&t)<<4|o>>2,s[c++]=(3&o)<<6|63&i;return f}function ve(e){var n,r=new Uint8Array(e),t="";for(n=0;n<r.length;n+=3)t+=G[r[n]>>2],t+=G[(3&r[n])<<4|r[n+1]>>4],t+=G[(15&r[n+1])<<2|r[n+2]>>6],t+=G[63&r[n+2]];return r.length%3==2?t=t.substring(0,t.length-1)+"=":r.length%3==1&&(t=t.substring(0,t.length-2)+"=="),t}function pe(e,n){var r="";if(e&&(r=de.call(e)),e&&("[object ArrayBuffer]"===r||e.buffer&&"[object ArrayBuffer]"===de.call(e.buffer))){var t,o=Z;e instanceof ArrayBuffer?(t=e,o+=ee):(t=e.buffer,"[object Int8Array]"===r?o+=re:"[object Uint8Array]"===r?o+=te:"[object Uint8ClampedArray]"===r?o+=oe:"[object Int16Array]"===r?o+=ie:"[object Uint16Array]"===r?o+=ue:"[object Int32Array]"===r?o+=ae:"[object Uint32Array]"===r?o+=ce:"[object Float32Array]"===r?o+=fe:"[object Float64Array]"===r?o+=se:n(new Error("Failed to get type for BinaryArray"))),n(o+ve(t))}else if("[object Blob]"===r){var i=new FileReader;i.onload=function(){var r=V+e.type+"~"+ve(this.result);n(Z+ne+r)},i.readAsArrayBuffer(e)}else try{n(JSON.stringify(e))}catch(r){console.error("Couldn't convert value into a JSON string: ",e),n(null,r)}}function ye(e){if(e.substring(0,$)!==Z)return JSON.parse(e);var n,r=e.substring(le),t=e.substring($,le);if(t===ne&&Y.test(r)){var o=r.match(Y);n=o[1],r=r.substring(o[0].length)}var i=he(r);switch(t){case ee:return i;case ne:return c([i],{type:n});case re:return new Int8Array(i);case te:return new Uint8Array(i);case oe:return new Uint8ClampedArray(i);case ie:return new Int16Array(i);case ue:return new Uint16Array(i);case ae:return new Int32Array(i);case ce:return new Uint32Array(i);case fe:return new Float32Array(i);case se:return new Float64Array(i);default:throw new Error("Unkown type: "+t)}}var me={serialize:pe,deserialize:ye,stringToBuffer:he,bufferToString:ve};function be(e,n,r,t){e.executeSql("CREATE TABLE IF NOT EXISTS "+n.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,t)}function ge(e){var n=this,r={db:null};if(e)for(var t in e)r[t]="string"!=typeof e[t]?e[t].toString():e[t];var o=new f((function(e,t){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(e){return t(e)}r.db.transaction((function(o){be(o,r,(function(){n._dbInfo=r,e()}),(function(e,n){t(n)}))}),t)}));return r.serializer=me,o}function _e(e,n,r,t,o,i){e.executeSql(r,t,o,(function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[n.storeName],(function(e,u){u.rows.length?i(e,a):be(e,n,(function(){e.executeSql(r,t,o,i)}),i)}),i):i(e,a)}),i)}function we(e,n){var r=this;e=d(e);var t=new f((function(n,t){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){_e(r,o,"SELECT * FROM "+o.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,r){var t=r.rows.length?r.rows.item(0).value:null;t&&(t=o.serializer.deserialize(t)),n(t)}),(function(e,n){t(n)}))}))})).catch(t)}));return s(t,n),t}function Ie(e,n){var r=this,t=new f((function(n,t){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){_e(r,o,"SELECT * FROM "+o.storeName,[],(function(r,t){for(var i=t.rows,a=i.length,u=0;u<a;u++){var c=i.item(u),f=c.value;if(f&&(f=o.serializer.deserialize(f)),void 0!==(f=e(f,c.key,u+1)))return void n(f)}n()}),(function(e,n){t(n)}))}))})).catch(t)}));return s(t,n),t}function Se(e,n,r,t){var o=this;e=d(e);var i=new f((function(i,a){o.ready().then((function(){void 0===n&&(n=null);var u=n,c=o._dbInfo;c.serializer.serialize(n,(function(n,f){f?a(f):c.db.transaction((function(r){_e(r,c,"INSERT OR REPLACE INTO "+c.storeName+" (key, value) VALUES (?, ?)",[e,n],(function(){i(u)}),(function(e,n){a(n)}))}),(function(n){if(n.code===n.QUOTA_ERR){if(t>0)return void i(Se.apply(o,[e,u,r,t-1]));a(n)}}))}))})).catch(a)}));return s(i,r),i}function Ee(e,n,r){return Se.apply(this,[e,n,r,1])}function Ae(e,n){var r=this;e=d(e);var t=new f((function(n,t){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){_e(r,o,"DELETE FROM "+o.storeName+" WHERE key = ?",[e],(function(){n()}),(function(e,n){t(n)}))}))})).catch(t)}));return s(t,n),t}function je(e){var n=this,r=new f((function(e,r){n.ready().then((function(){var t=n._dbInfo;t.db.transaction((function(n){_e(n,t,"DELETE FROM "+t.storeName,[],(function(){e()}),(function(e,n){r(n)}))}))})).catch(r)}));return s(r,e),r}function Ne(e){var n=this,r=new f((function(e,r){n.ready().then((function(){var t=n._dbInfo;t.db.transaction((function(n){_e(n,t,"SELECT COUNT(key) as c FROM "+t.storeName,[],(function(n,r){var t=r.rows.item(0).c;e(t)}),(function(e,n){r(n)}))}))})).catch(r)}));return s(r,e),r}function Oe(e,n){var r=this,t=new f((function(n,t){r.ready().then((function(){var o=r._dbInfo;o.db.transaction((function(r){_e(r,o,"SELECT key FROM "+o.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,r){var t=r.rows.length?r.rows.item(0).key:null;n(t)}),(function(e,n){t(n)}))}))})).catch(t)}));return s(t,n),t}function De(e){var n=this,r=new f((function(e,r){n.ready().then((function(){var t=n._dbInfo;t.db.transaction((function(n){_e(n,t,"SELECT key FROM "+t.storeName,[],(function(n,r){for(var t=[],o=0;o<r.rows.length;o++)t.push(r.rows.item(o).key);e(t)}),(function(e,n){r(n)}))}))})).catch(r)}));return s(r,e),r}function xe(e){return new f((function(n,r){e.transaction((function(t){t.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(r,t){for(var o=[],i=0;i<t.rows.length;i++)o.push(t.rows.item(i).name);n({db:e,storeNames:o})}),(function(e,n){r(n)}))}),(function(e){r(e)}))}))}function Re(e,n){n=h.apply(this,arguments);var r=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var t,o=this;return s(t=e.name?new f((function(n){var t;t=e.name===r.name?o._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?n({db:t,storeNames:[e.storeName]}):n(xe(t))})).then((function(e){return new f((function(n,r){e.db.transaction((function(t){function o(e){return new f((function(n,r){t.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){n()}),(function(e,n){r(n)}))}))}for(var i=[],a=0,u=e.storeNames.length;a<u;a++)i.push(o(e.storeNames[a]));f.all(i).then((function(){n()})).catch((function(e){r(e)}))}),(function(e){r(e)}))}))})):f.reject("Invalid arguments"),n),t}var Ce={_driver:"webSQLStorage",_initStorage:ge,_support:X(),iterate:Ie,getItem:we,setItem:Ee,removeItem:Ae,clear:je,length:Ne,key:Oe,keys:De,dropInstance:Re};function ke(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}function Te(e,n){var r=e.name+"/";return e.storeName!==n.storeName&&(r+=e.storeName+"/"),r}function Be(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}function Pe(){return!Be()||localStorage.length>0}function Me(e){var n=this,r={};if(e)for(var t in e)r[t]=e[t];return r.keyPrefix=Te(e,n._defaultConfig),Pe()?(n._dbInfo=r,r.serializer=me,f.resolve()):f.reject()}function Fe(e){var n=this,r=n.ready().then((function(){for(var e=n._dbInfo.keyPrefix,r=localStorage.length-1;r>=0;r--){var t=localStorage.key(r);0===t.indexOf(e)&&localStorage.removeItem(t)}}));return s(r,e),r}function Le(e,n){var r=this;e=d(e);var t=r.ready().then((function(){var n=r._dbInfo,t=localStorage.getItem(n.keyPrefix+e);return t&&(t=n.serializer.deserialize(t)),t}));return s(t,n),t}function ze(e,n){var r=this,t=r.ready().then((function(){for(var n=r._dbInfo,t=n.keyPrefix,o=t.length,i=localStorage.length,a=1,u=0;u<i;u++){var c=localStorage.key(u);if(0===c.indexOf(t)){var f=localStorage.getItem(c);if(f&&(f=n.serializer.deserialize(f)),void 0!==(f=e(f,c.substring(o),a++)))return f}}}));return s(t,n),t}function Ue(e,n){var r=this,t=r.ready().then((function(){var n,t=r._dbInfo;try{n=localStorage.key(e)}catch(e){n=null}return n&&(n=n.substring(t.keyPrefix.length)),n}));return s(t,n),t}function qe(e){var n=this,r=n.ready().then((function(){for(var e=n._dbInfo,r=localStorage.length,t=[],o=0;o<r;o++){var i=localStorage.key(o);0===i.indexOf(e.keyPrefix)&&t.push(i.substring(e.keyPrefix.length))}return t}));return s(r,e),r}function He(e){var n=this.keys().then((function(e){return e.length}));return s(n,e),n}function We(e,n){var r=this;e=d(e);var t=r.ready().then((function(){var n=r._dbInfo;localStorage.removeItem(n.keyPrefix+e)}));return s(t,n),t}function Ke(e,n,r){var t=this;e=d(e);var o=t.ready().then((function(){void 0===n&&(n=null);var r=n;return new f((function(o,i){var a=t._dbInfo;a.serializer.serialize(n,(function(n,t){if(t)i(t);else try{localStorage.setItem(a.keyPrefix+e,n),o(r)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||i(e),i(e)}}))}))}));return s(o,r),o}function Je(e,n){if(n=h.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var t,o=this;return t=e.name?new f((function(n){e.storeName?n(Te(e,o._defaultConfig)):n(e.name+"/")})).then((function(e){for(var n=localStorage.length-1;n>=0;n--){var r=localStorage.key(n);0===r.indexOf(e)&&localStorage.removeItem(r)}})):f.reject("Invalid arguments"),s(t,n),t}var Qe={_driver:"localStorageWrapper",_initStorage:Me,_support:ke(),iterate:ze,getItem:Le,setItem:Ke,removeItem:We,clear:Fe,length:He,key:Ue,keys:qe,dropInstance:Je},Xe=function(e,n){return e===n||"number"==typeof e&&"number"==typeof n&&isNaN(e)&&isNaN(n)},Ge=function(e,n){for(var r=e.length,t=0;t<r;){if(Xe(e[t],n))return!0;t++}return!1},Ve=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},Ye={},Ze={},$e={INDEXEDDB:Q,WEBSQL:Ce,LOCALSTORAGE:Qe},en=[$e.INDEXEDDB._driver,$e.WEBSQL._driver,$e.LOCALSTORAGE._driver],nn=["dropInstance"],rn=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(nn),tn={description:"",driver:en.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function on(e,n){e[n]=function(){var r=arguments;return e.ready().then((function(){return e[n].apply(e,r)}))}}function an(){for(var e=1;e<arguments.length;e++){var n=arguments[e];if(n)for(var r in n)n.hasOwnProperty(r)&&(Ve(n[r])?arguments[0][r]=n[r].slice():arguments[0][r]=n[r])}return arguments[0]}var un=function(){function e(n){for(var r in o(this,e),$e)if($e.hasOwnProperty(r)){var t=$e[r],i=t._driver;this[r]=i,Ye[i]||this.defineDriver(t)}this._defaultConfig=an({},tn),this._config=an({},this._defaultConfig,n),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":t(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var n in e){if("storeName"===n&&(e[n]=e[n].replace(/\W/g,"_")),"version"===n&&"number"!=typeof e[n])return new Error("Database version must be a number.");this._config[n]=e[n]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,n,r){var t=new f((function(n,r){try{var t=e._driver,o=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void r(o);for(var i=rn.concat("_initStorage"),a=0,u=i.length;a<u;a++){var c=i[a];if((!Ge(nn,c)||e[c])&&"function"!=typeof e[c])return void r(o)}var l=function(){for(var n=function(e){return function(){var n=new Error("Method "+e+" is not implemented by the current driver"),r=f.reject(n);return s(r,arguments[arguments.length-1]),r}},r=0,t=nn.length;r<t;r++){var o=nn[r];e[o]||(e[o]=n(o))}};l();var d=function(r){Ye[t]&&console.info("Redefining LocalForage driver: "+t),Ye[t]=e,Ze[t]=r,n()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(d,r):d(!!e._support):d(!0)}catch(e){r(e)}}));return l(t,n,r),t},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,n,r){var t=Ye[e]?f.resolve(Ye[e]):f.reject(new Error("Driver not found."));return l(t,n,r),t},e.prototype.getSerializer=function(e){var n=f.resolve(me);return l(n,e),n},e.prototype.ready=function(e){var n=this,r=n._driverSet.then((function(){return null===n._ready&&(n._ready=n._initDriver()),n._ready}));return l(r,e,e),r},e.prototype.setDriver=function(e,n,r){var t=this;Ve(e)||(e=[e]);var o=this._getSupportedDrivers(e);function i(){t._config.driver=t.driver()}function a(e){return t._extend(e),i(),t._ready=t._initStorage(t._config),t._ready}function u(e){return function(){var n=0;function r(){for(;n<e.length;){var o=e[n];return n++,t._dbInfo=null,t._ready=null,t.getDriver(o).then(a).catch(r)}i();var u=new Error("No available storage method found.");return t._driverSet=f.reject(u),t._driverSet}return r()}}var c=null!==this._driverSet?this._driverSet.catch((function(){return f.resolve()})):f.resolve();return this._driverSet=c.then((function(){var e=o[0];return t._dbInfo=null,t._ready=null,t.getDriver(e).then((function(e){t._driver=e._driver,i(),t._wrapLibraryMethodsWithReady(),t._initDriver=u(o)}))})).catch((function(){i();var e=new Error("No available storage method found.");return t._driverSet=f.reject(e),t._driverSet})),l(this._driverSet,n,r),this._driverSet},e.prototype.supports=function(e){return!!Ze[e]},e.prototype._extend=function(e){an(this,e)},e.prototype._getSupportedDrivers=function(e){for(var n=[],r=0,t=e.length;r<t;r++){var o=e[r];this.supports(o)&&n.push(o)}return n},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,n=rn.length;e<n;e++)on(this,rn[e])},e.prototype.createInstance=function(n){return new e(n)},e}(),cn=new un;n.exports=cn},{3:3}]},{},[4])(4)}(t);var o=n(t.exports),i=function(e,n,r){if(!e||"number"==typeof e)return r;if("string"==typeof n){if(e.hasOwnProperty(n))return e[n];if(-1===n.indexOf("."))return r;n=n.split(".")}for(var t=n,o=e,i=r,a=0;a<t.length;a++){if(n=t[a],!o.hasOwnProperty(n)){i=r;break}o=i=o[n]}return i},a=function(e){return`H-${e}`},u=function(e){return`C-${e}`},c=function(e){return"H"===e.charAt(0)},f=function(e){return e.split("-")[1]},s=function(e,n){if(void 0===n&&(n=o),Array.isArray(e)){var r=e;e={};for(var t=0,i=r.length;t<i;t++)e[r[t]]=null}var a=[];for(let r in e)a.push(n.getItem(r).then((function(n){e[r]=n})));return Promise.all(a).then((function(){return Promise.resolve(e)}))},l=function(e){if("object"!=typeof e||null===e)return e;if(Array.isArray(e))e.length=0;else for(var n in e)delete e[n];return e},d={exports:{}};!function(e){var n=function(){function e(e,n){if(!o[e]){o[e]={};for(var r=0;r<e.length;r++)o[e][e.charAt(r)]=r}return o[e][n]}var n=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",o={},i={compressToBase64:function(e){if(null==e)return"";var n=i._compress(e,6,(function(e){return r.charAt(e)}));switch(n.length%4){default:case 0:return n;case 1:return n+"===";case 2:return n+"==";case 3:return n+"="}},decompressFromBase64:function(n){return null==n?"":""==n?null:i._decompress(n.length,32,(function(t){return e(r,n.charAt(t))}))},compressToUTF16:function(e){return null==e?"":i._compress(e,15,(function(e){return n(e+32)}))+" "},decompressFromUTF16:function(e){return null==e?"":""==e?null:i._decompress(e.length,16384,(function(n){return e.charCodeAt(n)-32}))},compressToUint8Array:function(e){for(var n=i.compress(e),r=new Uint8Array(2*n.length),t=0,o=n.length;o>t;t++){var a=n.charCodeAt(t);r[2*t]=a>>>8,r[2*t+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),t=0,o=r.length;o>t;t++)r[t]=256*e[2*t]+e[2*t+1];var a=[];return r.forEach((function(e){a.push(n(e))})),i.decompress(a.join(""))},compressToEncodedURIComponent:function(e){return null==e?"":i._compress(e,6,(function(e){return t.charAt(e)}))},decompressFromEncodedURIComponent:function(n){return null==n?"":""==n?null:(n=n.replace(/ /g,"+"),i._decompress(n.length,32,(function(r){return e(t,n.charAt(r))})))},compress:function(e){return i._compress(e,16,(function(e){return n(e)}))},_compress:function(e,n,r){if(null==e)return"";var t,o,i,a={},u={},c="",f="",s="",l=2,d=3,h=2,v=[],p=0,y=0;for(i=0;i<e.length;i+=1)if(c=e.charAt(i),Object.prototype.hasOwnProperty.call(a,c)||(a[c]=d++,u[c]=!0),f=s+c,Object.prototype.hasOwnProperty.call(a,f))s=f;else{if(Object.prototype.hasOwnProperty.call(u,s)){if(s.charCodeAt(0)<256){for(t=0;h>t;t++)p<<=1,y==n-1?(y=0,v.push(r(p)),p=0):y++;for(o=s.charCodeAt(0),t=0;8>t;t++)p=p<<1|1&o,y==n-1?(y=0,v.push(r(p)),p=0):y++,o>>=1}else{for(o=1,t=0;h>t;t++)p=p<<1|o,y==n-1?(y=0,v.push(r(p)),p=0):y++,o=0;for(o=s.charCodeAt(0),t=0;16>t;t++)p=p<<1|1&o,y==n-1?(y=0,v.push(r(p)),p=0):y++,o>>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[s]}else for(o=a[s],t=0;h>t;t++)p=p<<1|1&o,y==n-1?(y=0,v.push(r(p)),p=0):y++,o>>=1;0==--l&&(l=Math.pow(2,h),h++),a[f]=d++,s=String(c)}if(""!==s){if(Object.prototype.hasOwnProperty.call(u,s)){if(s.charCodeAt(0)<256){for(t=0;h>t;t++)p<<=1,y==n-1?(y=0,v.push(r(p)),p=0):y++;for(o=s.charCodeAt(0),t=0;8>t;t++)p=p<<1|1&o,y==n-1?(y=0,v.push(r(p)),p=0):y++,o>>=1}else{for(o=1,t=0;h>t;t++)p=p<<1|o,y==n-1?(y=0,v.push(r(p)),p=0):y++,o=0;for(o=s.charCodeAt(0),t=0;16>t;t++)p=p<<1|1&o,y==n-1?(y=0,v.push(r(p)),p=0):y++,o>>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[s]}else for(o=a[s],t=0;h>t;t++)p=p<<1|1&o,y==n-1?(y=0,v.push(r(p)),p=0):y++,o>>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,t=0;h>t;t++)p=p<<1|1&o,y==n-1?(y=0,v.push(r(p)),p=0):y++,o>>=1;for(;;){if(p<<=1,y==n-1){v.push(r(p));break}y++}return v.join("")},decompress:function(e){return null==e?"":""==e?null:i._decompress(e.length,32768,(function(n){return e.charCodeAt(n)}))},_decompress:function(e,r,t){var o,i,a,u,c,f,s,l=[],d=4,h=4,v=3,p="",y=[],m={val:t(0),position:r,index:1};for(o=0;3>o;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),f=1;f!=c;)u=m.val&m.position,m.position>>=1,0==m.position&&(m.position=r,m.val=t(m.index++)),a|=(u>0?1:0)*f,f<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),f=1;f!=c;)u=m.val&m.position,m.position>>=1,0==m.position&&(m.position=r,m.val=t(m.index++)),a|=(u>0?1:0)*f,f<<=1;s=n(a);break;case 1:for(a=0,c=Math.pow(2,16),f=1;f!=c;)u=m.val&m.position,m.position>>=1,0==m.position&&(m.position=r,m.val=t(m.index++)),a|=(u>0?1:0)*f,f<<=1;s=n(a);break;case 2:return""}for(l[3]=s,i=s,y.push(s);;){if(m.index>e)return"";for(a=0,c=Math.pow(2,v),f=1;f!=c;)u=m.val&m.position,m.position>>=1,0==m.position&&(m.position=r,m.val=t(m.index++)),a|=(u>0?1:0)*f,f<<=1;switch(s=a){case 0:for(a=0,c=Math.pow(2,8),f=1;f!=c;)u=m.val&m.position,m.position>>=1,0==m.position&&(m.position=r,m.val=t(m.index++)),a|=(u>0?1:0)*f,f<<=1;l[h++]=n(a),s=h-1,d--;break;case 1:for(a=0,c=Math.pow(2,16),f=1;f!=c;)u=m.val&m.position,m.position>>=1,0==m.position&&(m.position=r,m.val=t(m.index++)),a|=(u>0?1:0)*f,f<<=1;l[h++]=n(a),s=h-1,d--;break;case 2:return y.join("")}if(0==d&&(d=Math.pow(2,v),v++),l[s])p=l[s];else{if(s!==h)return null;p=i+i.charAt(0)}y.push(p),l[h++]=i+p.charAt(0),i=p,0==--d&&(d=Math.pow(2,v),v++)}}};return i}();null!=e&&(e.exports=n)}(d);var h=n(d.exports),v={toSaveData(e){return this.zipMode&&(e=h.compress(JSON.stringify(e))),e},toLoadData(e){return this.zipMode&&(e=JSON.parse(h.decompress(e))),e}};class p{constructor(e){this.store=o.createInstance({name:i(e,"name","files")}),this.zipMode=i(e,"zip",!0),this.cacheHeaders={}}}var y={save:function(e,n,r,t){"boolean"==typeof r&&(t=r,r=void 0),void 0===t&&(t=!1),void 0===n&&(n={}),n.fileID=e,r&&(r.fileID=e);var i,c,f=a(e),l=u(e),d=this;return new Promise((function(e,n){t?s([f,l]).then((function(n){i=d.toLoadData(n[f]),c=d.toLoadData(n[l]),e()})):e()})).then((function(){i&&n&&(n=Object.assign(i,n)),c&&r&&(r=Object.assign(c,r)),d.cacheHeaders[e]=n;var t={};return n&&(t[f]=d.toSaveData(n)),r&&(t[l]=d.toSaveData(r)),function(e,n){void 0===n&&(n=o);var r=[];for(var t in e)r.push(n.setItem(t,e[t]));return Promise.all(r)}(t,d.store)})).then((function(){return Promise.resolve({fileID:e})})).catch((function(n){return Promise.reject({error:n,fileID:e})}))},load:function(e){var n=a(e),r=u(e),t=this;return s([n,r],this.store).then((function(o){var i=t.toLoadData(o[n]),a=t.toLoadData(o[r]);return t.cacheHeaders[e]=i,Promise.resolve({fileID:e,header:i,content:a})})).catch((function(n){return Promise.reject({fileID:e,error:n})}))},loadHeaders:function(){var e=this;return this.store.keys().then((function(n){return s(n.filter(c),e.store)})).then((function(n){for(var r in l(e.cacheHeaders),n)e.cacheHeaders[f(r)]=e.toLoadData(n[r]);return Promise.resolve({headers:e.cacheHeaders})})).catch((function(){return Promise.reject({error:error})}))},delete:function(e){return function(e,n){var r;if(void 0===n&&(n=o),Array.isArray(e))r=e;else for(var t in r=[],e)r.push(t);for(var i=[],a=0,u=r.length;a<u;a++)i.push(n.removeItem(r[a]));return Promise.all(i)}([a(e),u(e)])},clear:function(){return l(this.cacheHeaders),this.store.clear()}};Object.assign(p.prototype,y,v);class m extends Phaser.Plugins.BasePlugin{constructor(e){super(e)}start(){this.game.events.on("destroy",this.destroy,this)}add(e){return new p(e)}}return m}));