@apoorvdwi/excalidraw-collab
Version:
Excalidraw as a React component
2 lines • 481 kB
JavaScript
/*! For license information please see vendor-573620966583f07cdf54.js.LICENSE.txt */
(self.webpackChunkExcalidraw=self.webpackChunkExcalidraw||[]).push([[4736],{9609:function(t,e,n){"use strict";var r,i,o=n(1191),a=n(6287),s=n(3537),u=n(6875),c=((r={})["no-app"]="No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()",r["bad-app-name"]="Illegal App name: '{$appName}",r["duplicate-app"]="Firebase App named '{$appName}' already exists",r["app-deleted"]="Firebase App named '{$appName}' already deleted",r["invalid-app-argument"]="firebase.{$appName}() takes either no argument or a Firebase App instance.",r["invalid-log-argument"]="First argument to `onLog` must be null or a function.",r),h=new a.LL("app","Firebase",c),l="@firebase/app",f="[DEFAULT]",p=((i={})[l]="fire-core",i["@firebase/analytics"]="fire-analytics",i["@firebase/auth"]="fire-auth",i["@firebase/database"]="fire-rtdb",i["@firebase/functions"]="fire-fn",i["@firebase/installations"]="fire-iid",i["@firebase/messaging"]="fire-fcm",i["@firebase/performance"]="fire-perf",i["@firebase/remote-config"]="fire-rc",i["@firebase/storage"]="fire-gcs",i["@firebase/firestore"]="fire-fst",i["fire-js"]="fire-js",i["firebase-wrapper"]="fire-js-all",i),d=new u.Yd("@firebase/app"),g=function(){function t(t,e,n){var r=this;this.firebase_=n,this.isDeleted_=!1,this.name_=e.name,this.automaticDataCollectionEnabled_=e.automaticDataCollectionEnabled||!1,this.options_=(0,a.p$)(t),this.container=new s.H0(e.name),this._addComponent(new s.wA("app",(function(){return r}),"PUBLIC")),this.firebase_.INTERNAL.components.forEach((function(t){return r._addComponent(t)}))}return Object.defineProperty(t.prototype,"automaticDataCollectionEnabled",{get:function(){return this.checkDestroyed_(),this.automaticDataCollectionEnabled_},set:function(t){this.checkDestroyed_(),this.automaticDataCollectionEnabled_=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this.checkDestroyed_(),this.name_},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return this.checkDestroyed_(),this.options_},enumerable:!1,configurable:!0}),t.prototype.delete=function(){var t=this;return new Promise((function(e){t.checkDestroyed_(),e()})).then((function(){return t.firebase_.INTERNAL.removeApp(t.name_),Promise.all(t.container.getProviders().map((function(t){return t.delete()})))})).then((function(){t.isDeleted_=!0}))},t.prototype._getService=function(t,e){return void 0===e&&(e=f),this.checkDestroyed_(),this.container.getProvider(t).getImmediate({identifier:e})},t.prototype._removeServiceInstance=function(t,e){void 0===e&&(e=f),this.container.getProvider(t).clearInstance(e)},t.prototype._addComponent=function(t){try{this.container.addComponent(t)}catch(e){d.debug("Component "+t.name+" failed to register with FirebaseApp "+this.name,e)}},t.prototype._addOrOverwriteComponent=function(t){this.container.addOrOverwriteComponent(t)},t.prototype.toJSON=function(){return{name:this.name,automaticDataCollectionEnabled:this.automaticDataCollectionEnabled,options:this.options}},t.prototype.checkDestroyed_=function(){if(this.isDeleted_)throw h.create("app-deleted",{appName:this.name_})},t}();g.prototype.name&&g.prototype.options||g.prototype.delete||console.log("dc");var m="8.3.3";var v=function t(){var e=function(t){var e={},n=new Map,r={__esModule:!0,initializeApp:function(n,i){void 0===i&&(i={}),"object"==typeof i&&null!==i||(i={name:i});var o=i;void 0===o.name&&(o.name=f);var s=o.name;if("string"!=typeof s||!s)throw h.create("bad-app-name",{appName:String(s)});if((0,a.r3)(e,s))throw h.create("duplicate-app",{appName:s});var u=new t(n,o,r);return e[s]=u,u},app:i,registerVersion:function(t,e,n){var r,i=null!==(r=p[t])&&void 0!==r?r:t;n&&(i+="-"+n);var a=i.match(/\s|\//),u=e.match(/\s|\//);if(a||u){var c=['Unable to register library "'+i+'" with version "'+e+'":'];return a&&c.push('library name "'+i+'" contains illegal characters (whitespace or "/")'),a&&u&&c.push("and"),u&&c.push('version name "'+e+'" contains illegal characters (whitespace or "/")'),void d.warn(c.join(" "))}o(new s.wA(i+"-version",(function(){return{library:i,version:e}}),"VERSION"))},setLogLevel:u.Ub,onLog:function(t,e){if(null!==t&&"function"!=typeof t)throw h.create("invalid-log-argument");(0,u.Am)(t,e)},apps:null,SDK_VERSION:m,INTERNAL:{registerComponent:o,removeApp:function(t){delete e[t]},components:n,useAsService:function(t,e){return"serverAuth"===e?null:e}}};function i(t){if(t=t||f,!(0,a.r3)(e,t))throw h.create("no-app",{appName:t});return e[t]}function o(o){var s=o.name;if(n.has(s))return d.debug("There were multiple attempts to register component "+s+"."),"PUBLIC"===o.type?r[s]:null;if(n.set(s,o),"PUBLIC"===o.type){var u=function(t){if(void 0===t&&(t=i()),"function"!=typeof t[s])throw h.create("invalid-app-argument",{appName:s});return t[s]()};void 0!==o.serviceProps&&(0,a.ZB)(u,o.serviceProps),r[s]=u,t.prototype[s]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._getService.bind(this,s).apply(this,o.multipleInstances?t:[])}}for(var c=0,l=Object.keys(e);c<l.length;c++){var f=l[c];e[f]._addComponent(o)}return"PUBLIC"===o.type?r[s]:null}return r.default=r,Object.defineProperty(r,"apps",{get:function(){return Object.keys(e).map((function(t){return e[t]}))}}),i.App=t,r}(g);return e.INTERNAL=(0,o.pi)((0,o.pi)({},e.INTERNAL),{createFirebaseNamespace:t,extendNamespace:function(t){(0,a.ZB)(e,t)},createSubscribe:a.ne,ErrorFactory:a.LL,deepExtend:a.ZB}),e}(),y=function(){function t(t){this.container=t}return t.prototype.getPlatformInfoString=function(){return this.container.getProviders().map((function(t){if(function(t){var e=t.getComponent();return"VERSION"===(null==e?void 0:e.type)}(t)){var e=t.getImmediate();return e.library+"/"+e.version}return null})).filter((function(t){return t})).join(" ")},t}();if((0,a.jU)()&&void 0!==self.firebase){d.warn("\n Warning: Firebase is already defined in the global scope. Please make sure\n Firebase library is only loaded once.\n ");var A=self.firebase.SDK_VERSION;A&&A.indexOf("LITE")>=0&&d.warn("\n Warning: You are trying to load Firebase while using Firebase Performance standalone script.\n You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.\n ")}var b=v.initializeApp;v.initializeApp=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return(0,a.UG)()&&d.warn('\n Warning: This is a browser-targeted Firebase bundle but it appears it is being\n run in a Node environment. If running in a Node environment, make sure you\n are using the bundle specified by the "main" field in package.json.\n \n If you are using Webpack, you can specify "main" as the first item in\n "resolve.mainFields":\n https://webpack.js.org/configuration/resolve/#resolvemainfields\n \n If using Rollup, use the @rollup/plugin-node-resolve plugin and specify "main"\n as the first item in "mainFields", e.g. [\'main\', \'module\'].\n https://github.com/rollup/@rollup/plugin-node-resolve\n '),b.apply(void 0,t)};var w=v;!function(t,e){t.INTERNAL.registerComponent(new s.wA("platform-logger",(function(t){return new y(t)}),"PRIVATE")),t.registerVersion(l,"0.6.19",e),t.registerVersion("fire-js","")}(w),e.Z=w},3537:function(t,e,n){"use strict";n.d(e,{H0:function(){return u},wA:function(){return o}});var r=n(1191),i=n(6287),o=function(){function t(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}return t.prototype.setInstantiationMode=function(t){return this.instantiationMode=t,this},t.prototype.setMultipleInstances=function(t){return this.multipleInstances=t,this},t.prototype.setServiceProps=function(t){return this.serviceProps=t,this},t.prototype.setInstanceCreatedCallback=function(t){return this.onInstanceCreated=t,this},t}(),a="[DEFAULT]",s=function(){function t(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map}return t.prototype.get=function(t){void 0===t&&(t=a);var e=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(e)){var n=new i.BH;if(this.instancesDeferred.set(e,n),this.isInitialized(e)||this.shouldAutoInitialize())try{var r=this.getOrInitializeService({instanceIdentifier:e});r&&n.resolve(r)}catch(t){}}return this.instancesDeferred.get(e).promise},t.prototype.getImmediate=function(t){var e=(0,r.pi)({identifier:a,optional:!1},t),n=e.identifier,i=e.optional,o=this.normalizeInstanceIdentifier(n);if(!this.isInitialized(o)&&!this.shouldAutoInitialize()){if(i)return null;throw Error("Service "+this.name+" is not available")}try{return this.getOrInitializeService({instanceIdentifier:o})}catch(t){if(i)return null;throw t}},t.prototype.getComponent=function(){return this.component},t.prototype.setComponent=function(t){var e,n;if(t.name!==this.name)throw Error("Mismatching Component "+t.name+" for Provider "+this.name+".");if(this.component)throw Error("Component for "+this.name+" has already been provided");if(this.component=t,this.shouldAutoInitialize()){if(function(t){return"EAGER"===t.instantiationMode}(t))try{this.getOrInitializeService({instanceIdentifier:a})}catch(t){}try{for(var i=(0,r.XA)(this.instancesDeferred.entries()),o=i.next();!o.done;o=i.next()){var s=(0,r.CR)(o.value,2),u=s[0],c=s[1],h=this.normalizeInstanceIdentifier(u);try{var l=this.getOrInitializeService({instanceIdentifier:h});c.resolve(l)}catch(t){}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}}},t.prototype.clearInstance=function(t){void 0===t&&(t=a),this.instancesDeferred.delete(t),this.instances.delete(t)},t.prototype.delete=function(){return(0,r.mG)(this,void 0,void 0,(function(){var t;return(0,r.Jh)(this,(function(e){switch(e.label){case 0:return t=Array.from(this.instances.values()),[4,Promise.all((0,r.ev)((0,r.ev)([],(0,r.CR)(t.filter((function(t){return"INTERNAL"in t})).map((function(t){return t.INTERNAL.delete()})))),(0,r.CR)(t.filter((function(t){return"_delete"in t})).map((function(t){return t._delete()})))))];case 1:return e.sent(),[2]}}))}))},t.prototype.isComponentSet=function(){return null!=this.component},t.prototype.isInitialized=function(t){return void 0===t&&(t=a),this.instances.has(t)},t.prototype.initialize=function(t){var e,n;void 0===t&&(t={});var i=t.instanceIdentifier,o=void 0===i?a:i,s=t.options,u=void 0===s?{}:s,c=this.normalizeInstanceIdentifier(o);if(this.isInitialized(c))throw Error(this.name+"("+c+") has already been initialized");if(!this.isComponentSet())throw Error("Component "+this.name+" has not been registered yet");var h=this.getOrInitializeService({instanceIdentifier:c,options:u});try{for(var l=(0,r.XA)(this.instancesDeferred.entries()),f=l.next();!f.done;f=l.next()){var p=(0,r.CR)(f.value,2),d=p[0],g=p[1];c===this.normalizeInstanceIdentifier(d)&&g.resolve(h)}}catch(t){e={error:t}}finally{try{f&&!f.done&&(n=l.return)&&n.call(l)}finally{if(e)throw e.error}}return h},t.prototype.getOrInitializeService=function(t){var e,n=t.instanceIdentifier,r=t.options,i=void 0===r?{}:r,o=this.instances.get(n);if(!o&&this.component&&(o=this.component.instanceFactory(this.container,{instanceIdentifier:(e=n,e===a?void 0:e),options:i}),this.instances.set(n,o),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,n,o)}catch(t){}return o||null},t.prototype.normalizeInstanceIdentifier=function(t){return this.component?this.component.multipleInstances?t:a:t},t.prototype.shouldAutoInitialize=function(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode},t}();var u=function(){function t(t){this.name=t,this.providers=new Map}return t.prototype.addComponent=function(t){var e=this.getProvider(t.name);if(e.isComponentSet())throw new Error("Component "+t.name+" has already been registered with "+this.name);e.setComponent(t)},t.prototype.addOrOverwriteComponent=function(t){this.getProvider(t.name).isComponentSet()&&this.providers.delete(t.name),this.addComponent(t)},t.prototype.getProvider=function(t){if(this.providers.has(t))return this.providers.get(t);var e=new s(t,this);return this.providers.set(t,e),e},t.prototype.getProviders=function(){return Array.from(this.providers.values())},t}()},6875:function(t,e,n){"use strict";function r(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}var i;n.d(e,{Am:function(){return p},Ub:function(){return f},Yd:function(){return l},in:function(){return o}});var o,a=[];!function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"}(o||(o={}));var s={debug:o.DEBUG,verbose:o.VERBOSE,info:o.INFO,warn:o.WARN,error:o.ERROR,silent:o.SILENT},u=o.INFO,c=((i={})[o.DEBUG]="log",i[o.VERBOSE]="log",i[o.INFO]="info",i[o.WARN]="warn",i[o.ERROR]="error",i),h=function(t,e){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];if(!(e<t.logLevel)){var o=(new Date).toISOString(),a=c[e];if(!a)throw new Error("Attempted to log a message with an invalid logType (value: "+e+")");console[a].apply(console,r(["["+o+"] "+t.name+":"],n))}},l=function(){function t(t){this.name=t,this._logLevel=u,this._logHandler=h,this._userLogHandler=null,a.push(this)}return Object.defineProperty(t.prototype,"logLevel",{get:function(){return this._logLevel},set:function(t){if(!(t in o))throw new TypeError('Invalid value "'+t+'" assigned to `logLevel`');this._logLevel=t},enumerable:!1,configurable:!0}),t.prototype.setLogLevel=function(t){this._logLevel="string"==typeof t?s[t]:t},Object.defineProperty(t.prototype,"logHandler",{get:function(){return this._logHandler},set:function(t){if("function"!=typeof t)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"userLogHandler",{get:function(){return this._userLogHandler},set:function(t){this._userLogHandler=t},enumerable:!1,configurable:!0}),t.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,r([this,o.DEBUG],t)),this._logHandler.apply(this,r([this,o.DEBUG],t))},t.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,r([this,o.VERBOSE],t)),this._logHandler.apply(this,r([this,o.VERBOSE],t))},t.prototype.info=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,r([this,o.INFO],t)),this._logHandler.apply(this,r([this,o.INFO],t))},t.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,r([this,o.WARN],t)),this._logHandler.apply(this,r([this,o.WARN],t))},t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._userLogHandler&&this._userLogHandler.apply(this,r([this,o.ERROR],t)),this._logHandler.apply(this,r([this,o.ERROR],t))},t}();function f(t){a.forEach((function(e){e.setLogLevel(t)}))}function p(t,e){for(var n=function(n){var r=null;e&&e.level&&(r=s[e.level]),n.userLogHandler=null===t?null:function(e,n){for(var i=[],a=2;a<arguments.length;a++)i[a-2]=arguments[a];var s=i.map((function(t){if(null==t)return null;if("string"==typeof t)return t;if("number"==typeof t||"boolean"==typeof t)return t.toString();if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch(t){return null}})).filter((function(t){return t})).join(" ");n>=(null!=r?r:e.logLevel)&&t({level:o[n].toLowerCase(),message:s,args:i,type:e.name})}},r=0,i=a;r<i.length;r++){n(i[r])}}},6287:function(t,e,n){"use strict";n.d(e,{BH:function(){return s},LL:function(){return y},Mn:function(){return m},UG:function(){return h},ZB:function(){return a},ZR:function(){return v},b$:function(){return p},d:function(){return d},jU:function(){return l},m9:function(){return E},ne:function(){return w},p$:function(){return o},r3:function(){return b},ru:function(){return f},uI:function(){return c},w1:function(){return g},z$:function(){return u}});var r=n(1191),i=function(t){for(var e=[],n=0,r=0;r<t.length;r++){var i=t.charCodeAt(r);i<128?e[n++]=i:i<2048?(e[n++]=i>>6|192,e[n++]=63&i|128):55296==(64512&i)&&r+1<t.length&&56320==(64512&t.charCodeAt(r+1))?(i=65536+((1023&i)<<10)+(1023&t.charCodeAt(++r)),e[n++]=i>>18|240,e[n++]=i>>12&63|128,e[n++]=i>>6&63|128,e[n++]=63&i|128):(e[n++]=i>>12|224,e[n++]=i>>6&63|128,e[n++]=63&i|128)}return e};function o(t){return a(void 0,t)}function a(t,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:return new Date(e.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return e}for(var n in e)e.hasOwnProperty(n)&&"__proto__"!==n&&(t[n]=a(t[n],e[n]));return t}var s=function(){function t(){var t=this;this.reject=function(){},this.resolve=function(){},this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))}return t.prototype.wrapCallback=function(t){var e=this;return function(n,r){n?e.reject(n):e.resolve(r),"function"==typeof t&&(e.promise.catch((function(){})),1===t.length?t(n):t(n,r))}},t}();function u(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function c(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(u())}function h(){try{return"[object process]"===Object.prototype.toString.call(n.g.process)}catch(t){return!1}}function l(){return"object"==typeof self&&self.self===self}function f(){var t="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof t&&void 0!==t.id}function p(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function d(){return u().indexOf("Electron/")>=0}function g(){var t=u();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}function m(){return u().indexOf("MSAppHost/")>=0}var v=function(t){function e(n,r,i){var o=t.call(this,r)||this;return o.code=n,o.customData=i,o.name="FirebaseError",Object.setPrototypeOf(o,e.prototype),Error.captureStackTrace&&Error.captureStackTrace(o,y.prototype.create),o}return(0,r.ZT)(e,t),e}(Error),y=function(){function t(t,e,n){this.service=t,this.serviceName=e,this.errors=n}return t.prototype.create=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=e[0]||{},i=this.service+"/"+t,o=this.errors[t],a=o?function(t,e){return t.replace(A,(function(t,n){var r=e[n];return null!=r?String(r):"<"+n+"?>"}))}(o,r):"Error",s=this.serviceName+": "+a+" ("+i+").";return new v(i,s,r)},t}();var A=/\{\$([^}]+)}/g;function b(t,e){return Object.prototype.hasOwnProperty.call(t,e)}!function(){function t(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(var t=1;t<this.blockSize;++t)this.pad_[t]=0;this.reset()}t.prototype.reset=function(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0},t.prototype.compress_=function(t,e){e||(e=0);var n=this.W_;if("string"==typeof t)for(var r=0;r<16;r++)n[r]=t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|t.charCodeAt(e+3),e+=4;else for(r=0;r<16;r++)n[r]=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3],e+=4;for(r=16;r<80;r++){var i=n[r-3]^n[r-8]^n[r-14]^n[r-16];n[r]=4294967295&(i<<1|i>>>31)}var o,a,s=this.chain_[0],u=this.chain_[1],c=this.chain_[2],h=this.chain_[3],l=this.chain_[4];for(r=0;r<80;r++){r<40?r<20?(o=h^u&(c^h),a=1518500249):(o=u^c^h,a=1859775393):r<60?(o=u&c|h&(u|c),a=2400959708):(o=u^c^h,a=3395469782);i=(s<<5|s>>>27)+o+l+a+n[r]&4294967295;l=h,h=c,c=4294967295&(u<<30|u>>>2),u=s,s=i}this.chain_[0]=this.chain_[0]+s&4294967295,this.chain_[1]=this.chain_[1]+u&4294967295,this.chain_[2]=this.chain_[2]+c&4294967295,this.chain_[3]=this.chain_[3]+h&4294967295,this.chain_[4]=this.chain_[4]+l&4294967295},t.prototype.update=function(t,e){if(null!=t){void 0===e&&(e=t.length);for(var n=e-this.blockSize,r=0,i=this.buf_,o=this.inbuf_;r<e;){if(0===o)for(;r<=n;)this.compress_(t,r),r+=this.blockSize;if("string"==typeof t){for(;r<e;)if(i[o]=t.charCodeAt(r),++r,++o===this.blockSize){this.compress_(i),o=0;break}}else for(;r<e;)if(i[o]=t[r],++r,++o===this.blockSize){this.compress_(i),o=0;break}}this.inbuf_=o,this.total_+=e}},t.prototype.digest=function(){var t=[],e=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(var n=this.blockSize-1;n>=56;n--)this.buf_[n]=255&e,e/=256;this.compress_(this.buf_);var r=0;for(n=0;n<5;n++)for(var i=24;i>=0;i-=8)t[r]=this.chain_[n]>>i&255,++r;return t}}();function w(t,e){var n=new _(t,e);return n.subscribe.bind(n)}var _=function(){function t(t,e){var n=this;this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=e,this.task.then((function(){t(n)})).catch((function(t){n.error(t)}))}return t.prototype.next=function(t){this.forEachObserver((function(e){e.next(t)}))},t.prototype.error=function(t){this.forEachObserver((function(e){e.error(t)})),this.close(t)},t.prototype.complete=function(){this.forEachObserver((function(t){t.complete()})),this.close()},t.prototype.subscribe=function(t,e,n){var r,i=this;if(void 0===t&&void 0===e&&void 0===n)throw new Error("Missing Observer.");void 0===(r=function(t,e){if("object"!=typeof t||null===t)return!1;for(var n=0,r=e;n<r.length;n++){var i=r[n];if(i in t&&"function"==typeof t[i])return!0}return!1}(t,["next","error","complete"])?t:{next:t,error:e,complete:n}).next&&(r.next=I),void 0===r.error&&(r.error=I),void 0===r.complete&&(r.complete=I);var o=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then((function(){try{i.finalError?r.error(i.finalError):r.complete()}catch(t){}})),this.observers.push(r),o},t.prototype.unsubscribeOne=function(t){void 0!==this.observers&&void 0!==this.observers[t]&&(delete this.observers[t],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))},t.prototype.forEachObserver=function(t){if(!this.finalized)for(var e=0;e<this.observers.length;e++)this.sendOne(e,t)},t.prototype.sendOne=function(t,e){var n=this;this.task.then((function(){if(void 0!==n.observers&&void 0!==n.observers[t])try{e(n.observers[t])}catch(t){"undefined"!=typeof console&&console.error&&console.error(t)}}))},t.prototype.close=function(t){var e=this;this.finalized||(this.finalized=!0,void 0!==t&&(this.finalError=t),this.task.then((function(){e.observers=void 0,e.onNoObservers=void 0})))},t}();function I(){}function E(t){return t&&t._delegate?t._delegate:t}},3834:function(t,e,n){"use strict";n.r(e),n.d(e,{default:function(){return r.Z}});var r=n(9609);r.Z.registerVersion("firebase","8.3.3","app")},7332:function(t,e,n){"use strict";n.r(e);var r=n(9609),i=n(6287),o=n(6875),a=function(t,e){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},a(t,e)};function s(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}var u,c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{},h=h||{},l=c||self;function f(){}function p(t){var e=typeof t;return"array"==(e="object"!=e?e:t?Array.isArray(t)?"array":e:"null")||"object"==e&&"number"==typeof t.length}function d(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var g="closure_uid_"+(1e9*Math.random()>>>0),m=0;function v(t,e,n){return t.call.apply(t.bind,arguments)}function y(t,e,n){if(!t)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,r),t.apply(e,n)}}return function(){return t.apply(e,arguments)}}function A(t,e,n){return(A=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?v:y).apply(null,arguments)}function b(t,e){var n=Array.prototype.slice.call(arguments,1);return function(){var e=n.slice();return e.push.apply(e,arguments),t.apply(this,e)}}function w(){return Date.now()}function _(t,e){function n(){}n.prototype=e.prototype,t.X=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.Kb=function(t,n,r){for(var i=Array(arguments.length-2),o=2;o<arguments.length;o++)i[o-2]=arguments[o];return e.prototype[n].apply(t,i)}}function I(){this.j=this.j,this.i=this.i}I.prototype.j=!1,I.prototype.ja=function(){if(!this.j&&(this.j=!0,this.G(),0))(function(t){Object.prototype.hasOwnProperty.call(t,g)&&t[g]||(t[g]=++m)})(this)},I.prototype.G=function(){if(this.i)for(;this.i.length;)this.i.shift()()};var E=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if("string"==typeof t)return"string"!=typeof e||1!=e.length?-1:t.indexOf(e,0);for(var n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1},T=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){for(var r=t.length,i="string"==typeof t?t.split(""):t,o=0;o<r;o++)o in i&&e.call(n,i[o],o,t)};function C(t){return Array.prototype.concat.apply([],arguments)}function S(t){var e=t.length;if(0<e){for(var n=Array(e),r=0;r<e;r++)n[r]=t[r];return n}return[]}function x(t){return/^[\s\xa0]*$/.test(t)}var D,k=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function R(t,e){return-1!=t.indexOf(e)}function O(t,e){return t<e?-1:t>e?1:0}t:{var B=l.navigator;if(B){var N=B.userAgent;if(N){D=N;break t}}D=""}function P(t,e,n){for(var r in t)e.call(n,t[r],r,t)}function M(t){var e={};for(var n in t)e[n]=t[n];return e}var L="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function U(t,e){for(var n,r,i=1;i<arguments.length;i++){for(n in r=arguments[i])t[n]=r[n];for(var o=0;o<L.length;o++)n=L[o],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function F(t){return F[" "](t),t}F[" "]=f;var Q,j,q=R(D,"Opera"),G=R(D,"Trident")||R(D,"MSIE"),V=R(D,"Edge"),z=V||G,H=R(D,"Gecko")&&!(R(D.toLowerCase(),"webkit")&&!R(D,"Edge"))&&!(R(D,"Trident")||R(D,"MSIE"))&&!R(D,"Edge"),K=R(D.toLowerCase(),"webkit")&&!R(D,"Edge");function W(){var t=l.document;return t?t.documentMode:void 0}t:{var Y="",J=(j=D,H?/rv:([^\);]+)(\)|;)/.exec(j):V?/Edge\/([\d\.]+)/.exec(j):G?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(j):K?/WebKit\/(\S+)/.exec(j):q?/(?:Version)[ \/]?(\S+)/.exec(j):void 0);if(J&&(Y=J?J[1]:""),G){var X=W();if(null!=X&&X>parseFloat(Y)){Q=String(X);break t}}Q=Y}var Z,$={};function tt(t){return function(t,e){var n=$;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t)}(t,(function(){for(var e=0,n=k(String(Q)).split("."),r=k(String(t)).split("."),i=Math.max(n.length,r.length),o=0;0==e&&o<i;o++){var a=n[o]||"",s=r[o]||"";do{if(a=/(\d*)(\D*)(.*)/.exec(a)||["","","",""],s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],0==a[0].length&&0==s[0].length)break;e=O(0==a[1].length?0:parseInt(a[1],10),0==s[1].length?0:parseInt(s[1],10))||O(0==a[2].length,0==s[2].length)||O(a[2],s[2]),a=a[3],s=s[3]}while(0==e)}return 0<=e}))}if(l.document&&G){var et=W();Z=et||(parseInt(Q,10)||void 0)}else Z=void 0;var nt=Z,rt=!G||9<=Number(nt),it=G&&!tt("9"),ot=function(){if(!l.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{l.addEventListener("test",f,e),l.removeEventListener("test",f,e)}catch(t){}return t}();function at(t,e){this.type=t,this.a=this.target=e,this.defaultPrevented=!1}function st(t,e){if(at.call(this,t?t.type:""),this.relatedTarget=this.a=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.pointerId=0,this.pointerType="",this.c=null,t){var n=this.type=t.type,r=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.a=e,e=t.relatedTarget){if(H){t:{try{F(e.nodeName);var i=!0;break t}catch(t){}i=!1}i||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0),this.button=t.button,this.key=t.key||"",this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType="string"==typeof t.pointerType?t.pointerType:ut[t.pointerType]||"",this.c=t,t.defaultPrevented&&this.b()}}at.prototype.b=function(){this.defaultPrevented=!0},_(st,at);var ut={2:"touch",3:"pen",4:"mouse"};st.prototype.b=function(){st.X.b.call(this);var t=this.c;if(t.preventDefault)t.preventDefault();else if(t.returnValue=!1,it)try{(t.ctrlKey||112<=t.keyCode&&123>=t.keyCode)&&(t.keyCode=-1)}catch(t){}};var ct="closure_listenable_"+(1e6*Math.random()|0),ht=0;function lt(t,e,n,r,i){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!r,this.ca=i,this.key=++ht,this.Y=this.Z=!1}function ft(t){t.Y=!0,t.listener=null,t.proxy=null,t.src=null,t.ca=null}function pt(t){this.src=t,this.a={},this.b=0}function dt(t,e){var n=e.type;if(n in t.a){var r,i=t.a[n],o=E(i,e);(r=0<=o)&&Array.prototype.splice.call(i,o,1),r&&(ft(e),0==t.a[n].length&&(delete t.a[n],t.b--))}}function gt(t,e,n,r){for(var i=0;i<t.length;++i){var o=t[i];if(!o.Y&&o.listener==e&&o.capture==!!n&&o.ca==r)return i}return-1}pt.prototype.add=function(t,e,n,r,i){var o=t.toString();(t=this.a[o])||(t=this.a[o]=[],this.b++);var a=gt(t,e,r,i);return-1<a?(e=t[a],n||(e.Z=!1)):((e=new lt(e,this.src,o,!!r,i)).Z=n,t.push(e)),e};var mt="closure_lm_"+(1e6*Math.random()|0),vt={};function yt(t,e,n,r,i){if(r&&r.once)return bt(t,e,n,r,i);if(Array.isArray(e)){for(var o=0;o<e.length;o++)yt(t,e[o],n,r,i);return null}return n=xt(n),t&&t[ct]?t.va(e,n,d(r)?!!r.capture:!!r,i):At(t,e,n,!1,r,i)}function At(t,e,n,r,i,o){if(!e)throw Error("Invalid event type");var a=d(i)?!!i.capture:!!i;if(a&&!rt)return null;var s=Ct(t);if(s||(t[mt]=s=new pt(t)),(n=s.add(e,n,r,a,o)).proxy)return n;if(r=function(){var t=Tt,e=rt?function(n){return t.call(e.src,e.listener,n)}:function(n){if(!(n=t.call(e.src,e.listener,n)))return n};return e}(),n.proxy=r,r.src=t,r.listener=n,t.addEventListener)ot||(i=a),void 0===i&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(It(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}return n}function bt(t,e,n,r,i){if(Array.isArray(e)){for(var o=0;o<e.length;o++)bt(t,e[o],n,r,i);return null}return n=xt(n),t&&t[ct]?t.wa(e,n,d(r)?!!r.capture:!!r,i):At(t,e,n,!0,r,i)}function wt(t,e,n,r,i){if(Array.isArray(e))for(var o=0;o<e.length;o++)wt(t,e[o],n,r,i);else r=d(r)?!!r.capture:!!r,n=xt(n),t&&t[ct]?(t=t.c,(e=String(e).toString())in t.a&&(-1<(n=gt(o=t.a[e],n,r,i))&&(ft(o[n]),Array.prototype.splice.call(o,n,1),0==o.length&&(delete t.a[e],t.b--)))):t&&(t=Ct(t))&&(e=t.a[e.toString()],t=-1,e&&(t=gt(e,n,r,i)),(n=-1<t?e[t]:null)&&_t(n))}function _t(t){if("number"!=typeof t&&t&&!t.Y){var e=t.src;if(e&&e[ct])dt(e.c,t);else{var n=t.type,r=t.proxy;e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(It(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=Ct(e))?(dt(n,t),0==n.b&&(n.src=null,e[mt]=null)):ft(t)}}}function It(t){return t in vt?vt[t]:vt[t]="on"+t}function Et(t,e){var n=t.listener,r=t.ca||t.src;return t.Z&&_t(t),n.call(r,e)}function Tt(t,e){if(t.Y)return!0;if(!rt){if(!e)t:{e=["window","event"];for(var n=l,r=0;r<e.length;r++)if(null==(n=n[e[r]])){e=null;break t}e=n}return Et(t,e=new st(e,this))}return Et(t,new st(e,this))}function Ct(t){return(t=t[mt])instanceof pt?t:null}var St="__closure_events_fn_"+(1e9*Math.random()>>>0);function xt(t){return"function"==typeof t?t:(t[St]||(t[St]=function(e){return t.handleEvent(e)}),t[St])}function Dt(){I.call(this),this.c=new pt(this),this.J=this,this.C=null}function kt(t,e){var n,r=t.C;if(r)for(n=[];r;r=r.C)n.push(r);if(t=t.J,r=e.type||e,"string"==typeof e)e=new at(e,t);else if(e instanceof at)e.target=e.target||t;else{var i=e;U(e=new at(r,t),i)}if(i=!0,n)for(var o=n.length-1;0<=o;o--){var a=e.a=n[o];i=Rt(a,r,!0,e)&&i}if(i=Rt(a=e.a=t,r,!0,e)&&i,i=Rt(a,r,!1,e)&&i,n)for(o=0;o<n.length;o++)i=Rt(a=e.a=n[o],r,!1,e)&&i}function Rt(t,e,n,r){if(!(e=t.c.a[String(e)]))return!0;e=e.concat();for(var i=!0,o=0;o<e.length;++o){var a=e[o];if(a&&!a.Y&&a.capture==n){var s=a.listener,u=a.ca||a.src;a.Z&&dt(t.c,a),i=!1!==s.call(u,r)&&i}}return i&&!r.defaultPrevented}_(Dt,I),Dt.prototype[ct]=!0,(u=Dt.prototype).addEventListener=function(t,e,n,r){yt(this,t,e,n,r)},u.removeEventListener=function(t,e,n,r){wt(this,t,e,n,r)},u.G=function(){if(Dt.X.G.call(this),this.c){var t,e=this.c;for(t in e.a){for(var n=e.a[t],r=0;r<n.length;r++)ft(n[r]);delete e.a[t],e.b--}}this.C=null},u.va=function(t,e,n,r){return this.c.add(String(t),e,!1,n,r)},u.wa=function(t,e,n,r){return this.c.add(String(t),e,!0,n,r)};var Ot=l.JSON.stringify;function Bt(){this.b=this.a=null}var Nt,Pt=new(function(){function t(t,e){this.c=t,this.f=e,this.b=0,this.a=null}return t.prototype.get=function(){var t;return 0<this.b?(this.b--,t=this.a,this.a=t.next,t.next=null):t=this.c(),t},t}())((function(){return new Lt}),(function(t){t.reset()}));function Mt(){var t=jt,e=null;return t.a&&(e=t.a,t.a=t.a.next,t.a||(t.b=null),e.next=null),e}function Lt(){this.next=this.b=this.a=null}function Ut(t){l.setTimeout((function(){throw t}),0)}function Ft(t,e){Nt||function(){var t=l.Promise.resolve(void 0);Nt=function(){t.then(qt)}}(),Qt||(Nt(),Qt=!0),jt.add(t,e)}Bt.prototype.add=function(t,e){var n=Pt.get();n.set(t,e),this.b?this.b.next=n:this.a=n,this.b=n},Lt.prototype.set=function(t,e){this.a=t,this.b=e,this.next=null},Lt.prototype.reset=function(){this.next=this.b=this.a=null};var Qt=!1,jt=new Bt;function qt(){for(var t;t=Mt();){try{t.a.call(t.b)}catch(t){Ut(t)}var e=Pt;e.f(t),100>e.b&&(e.b++,t.next=e.a,e.a=t)}Qt=!1}function Gt(t,e){Dt.call(this),this.b=t||1,this.a=e||l,this.f=A(this.Za,this),this.g=w()}function Vt(t){t.aa=!1,t.M&&(t.a.clearTimeout(t.M),t.M=null)}function zt(t,e,n){if("function"==typeof t)n&&(t=A(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=A(t.handleEvent,t)}return 2147483647<Number(e)?-1:l.setTimeout(t,e||0)}function Ht(t){t.a=zt((function(){t.a=null,t.c&&(t.c=!1,Ht(t))}),t.h);var e=t.b;t.b=null,t.g.apply(null,e)}_(Gt,Dt),(u=Gt.prototype).aa=!1,u.M=null,u.Za=function(){if(this.aa){var t=w()-this.g;0<t&&t<.8*this.b?this.M=this.a.setTimeout(this.f,this.b-t):(this.M&&(this.a.clearTimeout(this.M),this.M=null),kt(this,"tick"),this.aa&&(Vt(this),this.start()))}},u.start=function(){this.aa=!0,this.M||(this.M=this.a.setTimeout(this.f,this.b),this.g=w())},u.G=function(){Gt.X.G.call(this),Vt(this),delete this.a};var Kt=function(t){function e(e,n){var r=t.call(this)||this;return r.g=e,r.h=n,r.b=null,r.c=!1,r.a=null,r}return function(t,e){function n(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(e,t),e.prototype.f=function(t){this.b=arguments,this.a?this.c=!0:Ht(this)},e.prototype.G=function(){t.prototype.G.call(this),this.a&&(l.clearTimeout(this.a),this.a=null,this.c=!1,this.b=null)},e}(I);function Wt(t){I.call(this),this.b=t,this.a={}}_(Wt,I);var Yt=[];function Jt(t,e,n,r){Array.isArray(n)||(n&&(Yt[0]=n.toString()),n=Yt);for(var i=0;i<n.length;i++){var o=yt(e,n[i],r||t.handleEvent,!1,t.b||t);if(!o)break;t.a[o.key]=o}}function Xt(t){P(t.a,(function(t,e){this.a.hasOwnProperty(e)&&_t(t)}),t),t.a={}}function Zt(){this.a=!0}function $t(t,e,n,r){t.info((function(){return"XMLHTTP TEXT ("+e+"): "+function(t,e){if(!t.a)return e;if(!e)return null;try{var n=JSON.parse(e);if(n)for(t=0;t<n.length;t++)if(Array.isArray(n[t])){var r=n[t];if(!(2>r.length)){var i=r[1];if(Array.isArray(i)&&!(1>i.length)){var o=i[0];if("noop"!=o&&"stop"!=o&&"close"!=o)for(var a=1;a<i.length;a++)i[a]=""}}}return Ot(n)}catch(t){return e}}(t,n)+(r?" "+r:"")}))}Wt.prototype.G=function(){Wt.X.G.call(this),Xt(this)},Wt.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},Zt.prototype.info=function(){};var te={},ee=null;function ne(){return ee=ee||new Dt}function re(t){at.call(this,te.Fa,t)}function ie(t){var e=ne();kt(e,new re(e,t))}function oe(t,e){at.call(this,te.STAT_EVENT,t),this.stat=e}function ae(t){var e=ne();kt(e,new oe(e,t))}function se(t){at.call(this,te.Ga,t)}function ue(t,e){if("function"!=typeof t)throw Error("Fn must not be null and must be a function");return l.setTimeout((function(){t()}),e)}te.Fa="serverreachability",_(re,at),te.STAT_EVENT="statevent",_(oe,at),te.Ga="timingevent",_(se,at);var ce={NO_ERROR:0,$a:1,nb:2,mb:3,hb:4,lb:5,ob:6,Da:7,TIMEOUT:8,rb:9},he={fb:"complete",Bb:"success",Ea:"error",Da:"abort",tb:"ready",ub:"readystatechange",TIMEOUT:"timeout",pb:"incrementaldata",sb:"progress",ib:"downloadprogress",Jb:"uploadprogress"};function le(){}function fe(t){var e;return(e=t.a)||(e=t.a={}),e}function pe(){}le.prototype.a=null;var de,ge={OPEN:"a",eb:"b",Ea:"c",qb:"d"};function me(){at.call(this,"d")}function ve(){at.call(this,"c")}function ye(){}function Ae(t,e,n,r){this.g=t,this.c=e,this.f=n,this.S=r||1,this.J=new Wt(this),this.P=be,t=z?125:void 0,this.R=new Gt(t),this.B=null,this.b=!1,this.j=this.l=this.i=this.H=this.u=this.T=this.o=null,this.s=[],this.a=null,this.D=0,this.h=this.m=null,this.N=-1,this.A=!1,this.O=0,this.F=null,this.V=this.C=this.U=this.I=!1}_(me,at),_(ve,at),_(ye,le),de=new ye;var be=45e3,we={},_e={};function Ie(t,e,n){t.H=1,t.i=ze(Fe(e)),t.j=n,t.I=!0,Ee(t,null)}function Ee(t,e){t.u=w(),Se(t),t.l=Fe(t.i);var n=t.l,r=t.S;Array.isArray(r)||(r=[String(r)]),on(n.b,"t",r),t.D=0,t.a=$n(t.g,t.g.C?e:null),0<t.O&&(t.F=new Kt(A(t.Ca,t,t.a),t.O)),Jt(t.J,t.a,"readystatechange",t.Xa),e=t.B?M(t.B):{},t.j?(t.m||(t.m="POST"),e["Content-Type"]="application/x-www-form-urlencoded",t.a.ba(t.l,t.m,t.j,e)):(t.m="GET",t.a.ba(t.l,t.m,null,e)),ie(1),function(t,e,n,r,i,o){t.info((function(){if(t.a)if(o)for(var a="",s=o.split("&"),u=0;u<s.length;u++){var c=s[u].split("=");if(1<c.length){var h=c[0];c=c[1];var l=h.split("_");a=2<=l.length&&"type"==l[1]?a+(h+"=")+c+"&":a+(h+"=redacted&")}}else a=null;else a=o;return"XMLHTTP REQ ("+r+") [attempt "+i+"]: "+e+"\n"+n+"\n"+a}))}(t.c,t.m,t.l,t.f,t.S,t.j)}function Te(t,e,n){for(var r=!0;!t.A&&t.D<n.length;){var i=Ce(t,n);if(i==_e){4==e&&(t.h=4,ae(14),r=!1),$t(t.c,t.f,null,"[Incomplete Response]");break}if(i==we){t.h=4,ae(15),$t(t.c,t.f,n,"[Invalid Chunk]"),r=!1;break}$t(t.c,t.f,i,null),Oe(t,i)}4==e&&0==n.length&&(t.h=1,ae(16),r=!1),t.b=t.b&&r,r?0<n.length&&!t.V&&(t.V=!0,(e=t.g).a==t&&e.U&&!e.F&&(e.c.info("Great, no buffering proxy detected. Bytes received: "+n.length),zn(e),e.F=!0,ae(11))):($t(t.c,t.f,n,"[Invalid Chunked Response]"),Re(t),ke(t))}function Ce(t,e){var n=t.D,r=e.indexOf("\n",n);return-1==r?_e:(n=Number(e.substring(n,r)),isNaN(n)?we:(r+=1)+n>e.length?_e:(e=e.substr(r,n),t.D=r+n,e))}function Se(t){t.T=w()+t.P,xe(t,t.P)}function xe(t,e){if(null!=t.o)throw Error("WatchDog timer not null");t.o=ue(A(t.Va,t),e)}function De(t){t.o&&(l.clearTimeout(t.o),t.o=null)}function ke(t){0==t.g.v||t.A||Wn(t.g,t)}function Re(t){De(t);var e=t.F;e&&"function"==typeof e.ja&&e.ja(),t.F=null,Vt(t.R),Xt(t.J),t.a&&(e=t.a,t.a=null,e.abort(),e.ja())}function Oe(t,e){try{var n=t.g;if(0!=n.v&&(n.a==t||fn(n.b,t)))if(n.I=t.N,!t.C&&fn(n.b,t)&&3==n.v){try{var r=n.ka.a.parse(e)}catch(t){r=null}if(Array.isArray(r)&&3==r.length){var i=r;if(0==i[0]){t:if(!n.j){if(n.a){if(!(n.a.u+3e3<t.u))break t;Kn(n),Mn(n)}Vn(n),ae(18)}}else n.oa=i[1],0<n.oa-n.P&&37500>i[2]&&n.H&&0==n.o&&!n.m&&(n.m=ue(A(n.Sa,n),6e3));if(1>=ln(n.b)&&n.ea){try{n.ea()}catch(t){}n.ea=void 0}}else Jn(n,11)}else if((t.C||n.a==t)&&Kn(n),!x(e))for(e=r=n.ka.a.parse(e),r=0;r<e.length;r++)if(i=e[r],n.P=i[0],i=i[1],2==n.v)if("c"==i[0]){n.J=i[1],n.ga=i[2];var o=i[3];null!=o&&(n.ha=o,n.c.info("VER="+n.ha));var a=i[4];null!=a&&(n.pa=a,n.c.info("SVER="+n.pa));var s=i[5];if(null!=s&&"number"==typeof s&&0<s){var u=1.5*s;n.D=u,n.c.info("backChannelRequestTimeoutMs_="+u)}u=n;var c=t.a;if(c){var h=c.a?c.a.getResponseHeader("X-Client-Wire-Protocol"):null;if(h){var l=u.b;!l.a&&(R(h,"spdy")||R(h,"quic")||R(h,"h2"))&&(l.f=l.g,l.a=new Set,l.b&&(pn(l,l.b),l.b=null))}if(u.A){var f=c.a?c.a.getResponseHeader("X-HTTP-Session-Id"):null;f&&(u.na=f,Ve(u.B,u.A,f))}}n.v=3,n.f&&n.f.ta(),n.U&&(n.N=w()-t.u,n.c.info("Handshake RTT: "+n.N+"ms"));var p=t;if((u=n).la=Zn(u,u.C?u.ga:null,u.fa),p.C){dn(u.b,p);var d=p,g=u.D;g&&d.setTimeout(g),d.o&&(De(d),Se(d)),u.a=p}else Gn(u);0<n.g.length&&Fn(n)}else"stop"!=i[0]&&"close"!=i[0]||Jn(n,7);else 3==n.v&&("stop"==i[0]||"close"==i[0]?"stop"==i[0]?Jn(n,7):Pn(n):"noop"!=i[0]&&n.f&&n.f.sa(i),n.o=0);ie(4)}catch(t){}}function Be(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(p(t)||"string"==typeof t)T(t,e,void 0);else{if(t.L&&"function"==typeof t.L)var n=t.L();else if(t.K&&"function"==typeof t.K)n=void 0;else if(p(t)||"string"==typeof t){n=[];for(var r=t.length,i=0;i<r;i++)n.push(i)}else for(i in n=[],r=0,t)n[r++]=i;r=function(t){if(t.K&&"function"==typeof t.K)return t.K();if("string"==typeof t)return t.split("");if(p(t)){for(var e=[],n=t.length,r=0;r<n;r++)e.push(t[r]);return e}for(r in e=[],n=0,t)e[n++]=t[r];return e}(t),i=r.length;for(var o=0;o<i;o++)e.call(void 0,r[o],n&&n[o],t)}}function Ne(t,e){this.b={},this.a=[],this.c=0;var n=arguments.length;if(1<n){if(n%2)throw Error("Uneven number of arguments");for(var r=0;r<n;r+=2)this.set(arguments[r],arguments[r+1])}else if(t)if(t instanceof Ne)for(n=t.L(),r=0;r<n.length;r++)this.set(n[r],t.get(n[r]));else for(r in t)this.set(r,t[r])}function Pe(t){if(t.c!=t.a.length){for(var e=0,n=0;e<t.a.length;){var r=t.a[e];Me(t.b,r)&&(t.a[n++]=r),e++}t.a.length=n}if(t.c!=t.a.length){var i={};for(n=e=0;e<t.a.length;)Me(i,r=t.a[e])||(t.a[n++]=r,i[r]=1),e++;t.a.length=n}}function Me(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(u=Ae.prototype).setTimeout=function(t){this.P=t},u.Xa=function(t){t=t.target;var e=this.F;e&&3==Rn(t)?e.f():this.Ca(t)},u.Ca=function(t){try{if(t==this.a)t:{var e=Rn(this.a),n=this.a.ua(),r=this.a.W();if(!(3>e||3==e&&!z&&!this.a.$())){this.A||4!=e||7==n||ie(8==n||0>=r?3:2),De(this);var i=this.a.W();this.N=i;var o=this.a.$();if(this.b=200==i,function(t,e,n,r,i,o,a){t.info((function(){return"XMLHTTP RESP ("+r+") [ attempt "+i+"]: "+e+"\n"+n+"\n"+o+" "+a}))}(this.c,this.m,this.l,this.f,this.S,e,i),this.b){if(this.U&&!this.C){e:{if(this.a){var a,s=this.a;if((a=s.a?s.a.getResponseHeader("X-HTTP-Initial-Response"):null)&&!x(a)){var u=a;break e}}u=null}if(!u){this.b=!1,this.h=3,ae(12),Re(this),ke(this);break t}$t(this.c,this.f,u,"Initial handshake response via X-HTTP-Initial-Response"),this.C=!0,Oe(this,u)}this.I?(Te(this,e,o),z&&this.b&&3==e&&(Jt(this.J,this.R,"tick",this.Wa),this.R.start())):($t(this.c,this.f,o,null),Oe(this,o)),4==e&&Re(this),this.b&&!this.A&&(4==e?Wn(this.g,this):(this.b=!1,Se(this)))}else 400==i&&0<o.indexOf("Unknown SID")?(this.h=3,ae(12)):(this.h=0,ae(13)),Re(this),ke(this)}}}catch(t){}},u.Wa=function(){if(this.a){var t=Rn(this.a),e=this.a.$();this.D<e.length&&(De(this),Te(this,t,e),this.b&&4!=t&&Se(this))}},u.cancel=function(){this.A=!0,Re(this)},u.Va=function(){this.o=null;var t=w();0<=t-this.T?(function(t,e){t.info((function(){return"TIMEOUT: "+e}))}(this.c,this.l),2!=this.H&&(ie(3),ae(17)),Re(this),this.h=2,ke(this)):xe(this,this.T-t)},(u=Ne.prototype).K=function(){Pe(this);for(var t=[],e=0;e<this.a.length;e++)t.push(this.b[this.a[e]]);return t},u.L=function(){return Pe(this),this.a.concat()},u.get=function(t,e){return Me(this.b,t)?this.b[t]:e},u.set=function(t,e){Me(this.b,t)||(this.c++,this.a.push(t)),this.b[t]=e},u.forEach=function(t,e){for(var n=this.L(),r=0;r<n.length;r++){var i=n[r],o=this.get(i);t.call(e,o,i,this)}};var Le=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function Ue(t,e){if(this.c=this.j=this.f="",this.h=null,this.i=this.g="",this.a=!1,t instanceof Ue){this.a=void 0!==e?e:t.a,Qe(this,t.f),this.j=t.j,je(this,t.c),qe(this,t.h),this.g=t.g,e=t.b;var n=new tn;n.c=e.c,e.a&&(n.a=new Ne(e.a),n.b=e.b),Ge(this,n),this.i=t.i}else t&&(n=String(t).match(Le))?(this.a=!!e,Qe(this,n[1]||"",!0),this.j=He(n[2]||""),je(this,n[3]||"",!0),qe(this,n[4]),this.g=He(n[5]||"",!0),Ge(this,n[6]||"",!0),this.i=He(n[7]||"")):(this.a=!!e,this.b=new tn(null,this.a))}function Fe(t){return new Ue(t)}function Qe(t,e,n){t.f=n?He(e,!0):e,t.f&&(t.f=t.f.replace(/:$/,""))}function je(t,e,n){t.c=n?He(e,!0):e}function qe(t,e){if(e){if(e=Number(e),isNaN(e)||0>e)throw Error("Bad port number "+e);t.h=e}else t.h=null}function Ge(t,e,n){e instanceof tn?(t.b=e,function(t,e){e&&!t.f&&(en(t),t.c=null,t.a.forEach((function(t,e){var n=e.toLowerCase();e!=n&&(nn(this,e),on(this,n,t))}),t)),t.f=e}(t.b,t.a)):(n||(e=Ke(e,Ze)),t.b=new tn(e,t.a))}function Ve(t,e,n){t.b.set(e,n)}function ze(t){return Ve(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^w()).toString(36)),t}function He(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function Ke(t,e,n){return"string"==typeof t?(t=encodeURI(t).replace(e,We),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function We(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}Ue.prototype.toString=function(){var t=[],e=this.f;e&&t.push(Ke(e,Ye,!0),":");var n=this.c;return(n||"file"==e)&&(t.push("//"),(e=this.j)&&t.push(Ke(e,Ye,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.h)&&t.push(":",String(n))),(n=this.g)&&(this.c&&"/"!=n.charAt(0)&&t.push("/"),t.push(Ke(n,"/"==n.charAt(0)?Xe:Je,!0))),(n=this.b.toString())&&t.push("?",n),(n=this.i)&&t.push("#",Ke(n,$e)),t.join("")};var Ye=/[#\/\?@]/g,Je=/[#\?:]/g,Xe=/[#\?]/g,Ze=/[#\?@]/g,$e=/#/g;function tn(t,e){this.b=this.a=null,this.c=t||null,this.f=!!e}function en(t){t.a||(t.a=new Ne,t.b=0,t.c&&function(t,e){if(t){t=t.split("&");for(var n=0;n<t.length;n++){var r=t[n].indexOf("="),i=null;if(0<=r){var o=t[n].substring(0,r);i=t[n].substring(r+1)}else o=t[n];e(o,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(t.c,(function(e,n){t.add(decodeURIComponent(e.replace(/\+/g," ")),n)})))}function nn(t,e){en(t),e=an(t,e),Me(t.a.b,e)&&(t.c=null,t.b-=t.a.get(e).length,Me((t=t.a).b,e)&&(delete t.b[e],t.c--,t.a.length>2*t.c&&Pe(t)))}function rn(t,e){return en(t),e=an(t,e),Me(t.a.b,e)}function on(t,e,n){nn(t,e),0<n.length&&(t.c=null,t.a.set(an(t,e),S(n)),t.b+=n.length)}function an(t,e){return e=String(e),t.f&&(e=e.toLowerCase()),e}(u=tn.prototype).add=function(t,e){en(this),this.c=null,t=an(this,t);var n=this.a.get(t);return n||this.a.set(t,n=[]),n.push(e),this.b+=1,this},u.forEach=function(t,e){en(this),this.a.forEach((function(n,r){T(n,(function(n){t.call(e,n,r,this)}),this)}),this)},u.L=function(){en(this);for(var t=this.a.K(),e=this.a.L(),n=[],r=0;r<e.length;r++)for(var i=t[r],o=0;o<i.length;o++)n.push(e[r]);return n},u.K=function(t){en(this);var e=[];if("string"==typeof t)rn(this,t)&&(e=C(e,this.a.get(an(this,t))));else{t=this.a.K();for(var n=0;n<t.length;n++)e=C(e,t[n])}return e},u.set=function(t,e){return en(this),this.c=null,rn(this,t=an(this,t))&&(this.b-=this.a.get(t).length),this.a.set(t,[e]),this.b+=1,this},u.get=function(t,e){return t&&0<(t=this.K(t)).length?String(t[0]):e},u.toString=function(){if(this.c)return this.c;if(!this.a)return"";for(var t=[],e=this.a.L(),n=0;n<e.length;n++){var r=e[n],i=encodeURIComponent(String(r));r=this.K(r);for(var o=0;o<r.length;o++){var a=i;""!==r[o]&&(a+="="+encodeURIComponent(String(r[o]))),t.push(a)}}return this.c=t.join("&")};var sn=function(t,e){this.b=t,this.a=e};function un(t){this.g=t||cn,l.PerformanceNavigationTiming?t=0<(t=l.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):t=!!(l.ia&&l.ia.ya&&l.ia.ya()&&l.ia.ya().Lb),this.f=t?this.g:1,this.a=null,1<this.f&&(this.a=new Set),this.b=null,this.c=[]}var cn=10;function hn(t){return!!t.b||!!t.a&&t.a.size>=t.f}function ln(t){return t.b?1:t.a?t.a.size:0}function fn(t,e){return t.b?t.b==e:!!t.a&&t.a.has(e)}function pn(t,e){t.a?t.a.add(e):t.b=e}function dn(t,e){t.b&&t.b==e?t.b=null:t.a&&t.a.has(e)&&t.a.delete(e)}function gn(t){var e,n;if(null!=t.b)return t.c.concat(t.b.s);if(null!=t.a&&0!==t.a.size){var r=t.c;try{for(var i=s(t.a.values()),o=i.next();!o.done;o=i.next()){var a=o.value;r=r.concat(a.s)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r}return S(t.c)}function mn(){}function vn(){this.a=new mn}function yn(t,e,n){var r=n||"";try{Be(t,(function(t,n){var i=t;d(t)&&(i=Ot(t)),e.push(r+n+"="+encodeURIComponent(i))}))}catch(t){throw e.push(r+"type="+encodeURIComponent("_badmap")),t}}function An(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(t){}}un.prototype.cancel=function(){var t,e;if(this.c=gn(this),this.b)this.b.cancel(),this.b=null;else if(this.a&&0!==this.a.size){try{for(var n=s(this.a.values()),r=n.next();!r.done;r=n.next()){r.value.cancel()}}catch(e){t={error:e}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}this.a.clear()}},mn.prototype.stringify=function(t){return l.JSON.stringify(t,void 0)},mn.prototype.parse=function(t){return l.JSON.parse(t,void 0)};var bn=l.JSON.parse;function wn(t){Dt.call(this),this.headers=new Ne,this.H=t||null,this.b=!1,this.s=this.a=null,this.B="",this.h=0,this.f="",this.g=this.A=this.l=this.u=!1,this.o=0,this.m=null,this.I=_n,this.D=this.F=!1}_(wn,Dt);var _n="",In=/^https?$/i,En=["POST","PUT"];function Tn(t){return"content-type"==t.toLowerCase()}function Cn(t,e){t.b=!1,t.a&&(t.g=!0,t.a.abort(),t.g=!1),t.f=e,t.h=5,Sn(t),Dn(t)}function Sn(t){t.u||(t.u=!0,kt(t,"complete"),kt(t,"error"))}function xn(t){if(t.b&&void 0!==h&&(!t.s[1]||4!=Rn(t)||2!=t.W()))if(t.l&&4==Rn(t))zt(t.za,0,t);else if(kt(t,"readystatechange"),4==Rn(t)){t.b=!1;try{var e,n=t.W();t:switch(n){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var r=!0;break t;default:r=!1}if(!(e=r)){var i;if(i=0===n){var o=String(t.B).match(Le)[1]||null;if(!o&&l.self&&l.self.location){var a=l.self.location.protocol;o=a.substr(0,a.length-1)}i=!In.test(o?o.toLowerCase():"")}e=i}if(e)kt(t,"complete"),kt(t,"success");else{t.h=6;try{var s=2<Rn(t)?t.a.statusText:""}catch(n){s=""}t.f=s+" ["+t.W()+"]",Sn(t)}}finally{Dn(t)}}}function Dn(t,e){if(t.a){kn(t);var n=t.a,r=t.s[0]?f:null;t.a=null,t.s=null,e||kt(t,"ready");try{n.onreadystatechange=r}catch(t){}}}function kn(t){t.a&&t.D&&(t.a.ontimeout=null),t.m&&(l.clearTimeout(t.m),t.m=null)}function Rn(t){return t.a?t.a.readyState:0}function On(t,e,n){t:{for(r in n){var r=!1;break t}r=!0}r||(n=function(t){var e="";return P(t,(function(t,n){e+=n,e+=":",e+=t,e+="\r\n"})),e}(n),"string"==typeof t?null!=n&&encodeURIComponent(String(n)):Ve(t,e,n))}function Bn(t,e,n){return n&&n.internalChannelParams&&n.internalChannelParams[t]||e}function Nn(t){this.pa=0,this.g=[],this.c=new Zt,this.ga=this.la=this.B=this.fa=this.a=this.na=this.A=this.V=this.i=this.O=this.l=null,this.Oa=this.R=0,this.La=Bn("failFast",!1,t),this.H=this.m=this.j=this.h=this.f=null,this.S=!0,this.I=this.oa=this.P=-1,this.T=this.o=this.u=0,this.Ha=Bn("baseRetryDelayMs",5e3,t),this.Ra=Bn("retryDelaySeedMs",1e4,t),this.Ma=Bn("forwardChannelMaxRetries",2,t),this.ma=Bn("forwardChannelRequestTimeoutMs",2e4,t),this.Na=t&&t.g||void 0,this.D=void 0,this.C=t&&t.supportsCrossDomainXhr||!1,this.J="",this.b=new un(t&&t.concurrentRequestLimit),this.ka=new vn,this.da=t&&t.fastHandshake||!1,this.Ia=t&&t.b||!1,t&&t.f&&(this.c.a=!1),t&&t.forceLongPolling&&(this.S=!1),this.U=!this.da&&this.S&&t&&t.detectBufferingProxy||!1,this.ea=void 0,this.N=0,this.F=!1,this.s=null,(this.Ka=t&&t.c||!1)&&this.c.info("Opt-in to enable Chrome Origin Trials.")}function Pn(t){if(Ln(t),3==t.v){var e=t.R++,n=Fe(t.B);Ve(n,"SID",t.J),Ve(n,"RID",e),Ve(n,"TYPE","terminate"),jn(t,n),(e=new Ae(t,t.c,e,void 0)).H=2,e.i=ze(Fe(n)),n=!1,l.navigator&&l.navigator.sendBeacon&&(n=l.navigator.sendBeacon(e.i.toString(),"")),!n&&l.Image&&((new Image).src=e.i,n=!0),n||(e.a=$n(e.g,null),e.a.ba(e.i)),e.u=w(),Se(e)}Xn(t)}function Mn(t){t.a&&(zn(t),t.a.cancel(),t.a=null)}function Ln(t){Mn(t),t.j&&(l.clearTimeout(t.j),t.j=null),Kn(t),t.b.cancel(),t.h&&("number"==typeof t.h&&l.clearTimeout(t.h),t.h=null)}function Un(t,e){t.g.push(new sn(t.Oa++,e)),3==t.v&&Fn(t)}function Fn(t){hn(t.b)||t.h||(t.h=!0,Ft(t.Ba,t),t.u=0)}function Qn(t,e){var n;n=e?e.f:t.R++;var r=Fe(t.B);Ve(r,"SID",t.J),Ve(r,"RID",n),Ve(r,"AID",t.P),jn(t,r),t.i&&t.l&&On(r,t.i,t.l),n=new Ae(t,t.c,n,t.u+1),null===t.i&&(n.B=t.l),e&&(t.g=e.s.concat(t.g)),e=qn(t,n,1e3),n.setTimeout(Math.round(.5*t.ma)+Math.round(.5*t.ma*Math.random())),pn(t.b,n),Ie(n,r,e)}function jn(t,e){t.f&&Be({},(function(t,n){Ve(e,n,t)}))}function qn(t,e,n){n=Math.min(t.g.length,n);var r=t.f?A(t.f.Ja,t.f,t):null;t:for(var i=t.g,o=-1;;){var a=["count="+n];-1==o?0<n?(o=i[0].b,a.push("ofs="+o)):o=0:a.push("ofs="+o);for(var s=!0,u=0;u<n;u++){var c=i[u].b,h=i[u].a;if(0>(c-=o))o=Math.max(0,i[u].b-100),s=!1;else try{yn(h,a,"req"+c+"_")}catch(t){r&&r(h)}}if(s){r=a.join("&");break t}}return t=t.g.splice(0,n),e.s=t,r}function Gn(t){t.a||t.j||(t.T=1,Ft(t.Aa,t),t.o=0)}function Vn(t){return!(t.a||t.j||3<=t.o)&&(t.T++,t.j=ue(A(t.Aa,t),Yn(t,t.o)),t.o++,!0)}function zn(t){null!=t.s&&(l.clearTimeout(t.s),t.s=null)}function Hn(t){t.a=new Ae(t,t.c,"rpc",t.T),null===t.i&&(t.a.B=t.l),t.a.O=0;var e=Fe(t.la);Ve(e,"RID","rpc"),Ve(e,"SID",t.J),Ve(e,"CI",t.H?"0":"1"),Ve(e,"AID",t.P),jn(t,e),Ve(e,"TYPE","xmlhttp"),t.i&&t.l&&On(e,t.i,t.l),t.D&&t.a.setTimeout(t.D);var n=t.a;t=t.ga,n.H=1,n.i=ze(Fe(e)),n.j=null,n.I=!0,Ee(n,t)}function Kn(t){null!=t.m&&(l.clearTimeout(t.m),t.m=null)}function Wn(t,e){var n=null;if(t.a==e){Kn(t),zn(t),t.a=null;var r=2}else{if(!fn(t.b,e))return;n=e.s,dn(t.b,e),r=1}if(t.I=e.N,0!=t.v)if(e.b)if(1==r){n=e.j?e.j.length:0,e=w()-e.u;var i=t.u;kt(r=ne(),new se(r,n,e,i)),Fn(t)}else Gn(t);else if(3==(i=e.h)||0==i&&0<t.I||!(1==r&&function(t,e){return!(ln(t.b)>=t.b.f-(t.h?1:0)||(t.h?(t.g=e.s.concat(t.g),0):1==t.v||2==t.v||t.u>=(t.La?0:t.Ma)||(t.h=ue(A(t.Ba,t,e),Yn(t,t.u)),t.u++,0)))}(t,e)||2==r&&Vn(t)))switch(n&&0<n.length&&(e=t.b,e.c=e.c.concat(n)),i){case 1:Jn(t,5);break;case 4:Jn(t,10);break;case 3:Jn(t,6);break;default:Jn(t,2)}}function Yn(t,e){var n=t.Ha+Math.floor(Math.random()*t.Ra);return t.f||(n*=2),n*e}function Jn(t,e){if(t.c.info("Error code "+e),2==e){var n=null;t.f&&(n=null);var r=A(t.Ya,t);n||(n=new Ue("//www.google.com/images/cleardot.gif"),l.location&&"http"==l.location.protocol||Qe(n,"https"),ze(n)),function(t,e){var n=new Zt;if(l.Image){var r=new Image;r.onload=b(An,n,r,"TestLoadImage: loaded",!0,e),r.onerror=b(An,n,r,"TestLoadImage: error",!1,e),r.onabort=b(An,n,r,"TestLoadImage: abort",!1,e),r.ontimeout=b(An,n,r,"TestLoadImage: timeout",!1,e),l.setTimeout((function(){r.ontimeout&&r.ontimeout()}),1e4),r.src=t}else e(!1)}(n.toString(),r)}else ae(2);t.v=0,t.f&&t.f.ra(e),Xn(t),Ln(t)}function Xn(t){t.v=0,t.I=-1,t.f&&(0==gn(t.b).length&&0==t.g.length||(t.b.c.length=0,S(t.g),t.g.length=0),t.f.qa())}function Zn(t,e,n){var r=function(t){return t instanceof Ue?Fe(t):new Ue(t,void 0)}(n);if(""!=r.c)e&&je(r,e+"."+r.c),qe(r,r.h);else{var i=l.location;r=function(t,e,n,r){var i=new Ue(null,void 0);return t&&Qe(i,t),e&&je(i,e),n&&qe(i,n),r&&(i.g=r),i}(i.protocol,e?e+"."+i.hostname:i.hostname,+i.port,n)}return t.V&&P(t.V,(function(t,e){Ve(r,e,t)})),e=t.A,n=t.na,e&&n&&Ve(r,e,n),Ve(r,"VER",t.ha),jn(t,r),r}function $n(t,e){if(e&&!t.C)throw Error("Can't create secondary domain capable XhrIo object.");return(e=new wn(t.Na)).F=t.C,e}function tr(){}function er(){if(G&&!(10<=Number(nt)))throw Error("Environmental error: no available transport.")}function nr(t,e){Dt.call(this),this.a=new Nn(e),this.o=t,this.b=e&&e.messageUrlParams||null,t=e&&e.messageHeaders||null,e&&e.clientProtocolHeaderRequired&&(t?t["X-Client-Protocol"]="webchannel":t={"X-Client-Protocol":"webchannel"}),this.a.l=t,t=e&&e.initMessageHeaders||null,e&&e.messageContentType&&(t?t["X-WebChannel-Content-Type"]=e.messageContentType:t={"X-WebChannel-Content-Type":e.messageContentType}),e&&e.a&&(t?t["X-WebChannel-Client-Profile"]=e.a:t={"X-WebChannel-Client-Profile":e.a}),this.a.O=t,(t=e&&e.httpHeadersOverwriteParam)&&!x(t)&&(this.a.i=t),this.m=e&&e.supportsCrossDomainXhr||!1,this.l=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!x(e)&&(this.a.A=e,null!==(t=this.b)&&e in t&&(e in(t=this.b)&&delete t[e])),this.f=new or(this)}function rr(t){me.call(this);var e=t.__sm__;if(e){t:{for(var n in e){t=n;break t}t=void 0}(this.c=t)?(t=this.c,this.data=null!==e&&t in e?e[t]:void 0):this.data=e}else this.data=t}function ir(){ve.call(this),this.status=1}function or(t){this.a=t}(u=wn.prototype).ba=function(t,e,n,r){if(this.a)throw Error("[goog.net.XhrIo] Object is active with another request="+this.B+"; newUri="+t);e=e?e.toUpperCase():"GET",this.B=t,this.f="",this.h=0,this.u=!1,this.b=!0,this.a=new XMLHttpRequest,this.s=this.H?fe(this.H):fe(de),this.a.onreadystatechange=A(this.za,this);try{this.A=!0,this.a.open(e,String(t),!0),this.A=!1}catch(t){return void Cn(this,t)}t=n||"";var i=new Ne(this.headers);r&&Be(r,(function(t,e){i.set(e,t)})),r=function(t){t:{for(var e=Tn,n=t.length,r="string"==typeof t?t.split(""):t,i=0;i<n;i++)if(i in r&&e.call(void 0,r[i],i,t)){e=i;break t}e=-1}return 0>e?null:"string"==typeof t?t.charAt(e):t[e]}(i.L()),n=l.FormData&&t instanceof l.FormData,!(0<=E(En,e))||r||n||i.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),i.forEach((function(t,e){this.a.setRequestHeader(e,t)}),this),this.I&&(this.a.responseType=this.I),"withCredentials"in this.a&&this.a.withCredentials!==this.F&&(this.a.withCredentials=this.F);try{kn(this),0<this.o&&((this.D=function(t){return G&&tt(9)&&"number"==typeof t.timeout&&void 0!==t.ontimeout}(this.a))?(this.a.timeout=this.o,this.a.ontimeout=A(this.xa,this)):this.m=zt(this.xa,this.o,this)),this.l=!0,this.a.send(t),this.l=!1}catch(t){Cn(this,t)}},u.xa=function(){void 0!==h&&this.a&&(this.f="Timed out after "+this.o+"ms, aborting",this.h=8,kt(this,"timeout"),this.abort(8))},u.abort=function(t){this.a&&this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1,this.h=t||7,kt(this,"complete"),kt(this,"abort"),Dn(this))},u.G=function(){this.a&&(this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1),Dn(this,!0)),wn.X.G.call(this)},u.za=function(){this.j||(this.A||this.l||this.g?xn(this):this.Ua())},u.Ua=function(){xn(this)},u.W=function(){try{return 2<Rn(this)?this.a.status:-1}catch(t){return-1}},u.$=function(){try{return this.a?this.a.responseText:""}catch(t){return""}},u.Pa=function(t){if(this.a){var e=this.a.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),bn(e)}},u.ua=function(){return this.h},u.Qa=function(){return"string"==typeof this.f?this.f:String(this.f)},(u=Nn.prototype).ha=8,u.v=1,u.Ba=function(t){if(this.h)if(this.h=null,1==this.v){if(!t){this.R=Math.floor(1e5*Math.random()),t=this.R++;var e,n=new Ae(this,this.c,t,void 0),r=this.l;if(this.O&&(r?U(r=M(r),this.O):r=this.O),null===this.i&&(n.B=r),this.da)t:{for(var i=e=0;i<this.g.length;i++){var o=this.g[i];if(void 0===(o="__data__"in o.a&&"string"==typeof(o=o.a.__data__)?o.length:void 0))break;if(4096<(e+=o)){e=i;break t}if(4096===e||i===this.g.length-1){e=i+1;break t}}e=1e3}else e=1e3;e=qn(this,n,e),Ve(i=Fe(this.B),"RID",t),Ve(i,"CVER",22),this.A&&Ve(i,"X-HTTP-Session-Id",this.A),jn(this,i),this.i&&r&&On(i,this.i,r),pn(this.b,n),this.Ia&&Ve(i,"TYPE","init"),this.da?(Ve(i,"$req",e),Ve(i,"SID","null"),n.U=!0,Ie(n,i,null)):Ie(n,i,e),this.v=2}}else 3==this.v&&(t?Qn(this,t):0==this.g.length||hn(this.b)||Qn(this))},u.Aa=function(){if(this.j=null,Hn(this),this.U&&!(this.F||null==this.a||0>=this.N)){var t=2*this.N;this.c.info("BP detection timer enabled: "+t),this.s=ue(A(this.Ta,this),t)}},u.Ta=function(){this.s&&(this.s=null,this.c.info("BP detection timeout reached."),this.c.info("Buffering proxy detected and switch to long-polling!"),this.H=!1,this.F=!0,ae(10),Mn(this),Hn(this))},u.Sa=function(){null!=this.m&&(this.m=null,Mn(this),Vn(this),ae(19))},u.Ya=function(t){t?(this.c.info("Successfully pinged google.com"),ae(2)):(this.c.info("Failed to ping google.com"),ae(1))},(u=tr.prototype).ta=function(){},u.sa=function(){},u.ra=function(){},u.qa=function(){},u.Ja=function(){},er.prototype.a=function(t,e){return new nr(t,e)},_(nr,Dt),nr.prototype.g=function(){this.a.f=this.f,this.m&&(this.a.C=!0);var t=this.a,e=this.o,n=this.b||void 0;ae(0),t.fa=e,t.V=n||{},t.H=t.S,t.B=Zn(t,null,t.fa),Fn(t)},nr.prototype.close=function(){Pn(this.a)},nr.prototype.h=function(t){if("string"==typeof t){var e={};e.__data__=t,Un(this.a,e)}else this.l?((e={}).__data__=Ot(t),Un(this.a,e)):Un(this.a,t)},nr.prototype.G=function(){this.a.f=null,delete this.f,Pn(this.a),delete this.a,nr.X.G.call(this)},_(rr,me),_(ir,ve),_(or,tr),or.prototype.ta=function(){kt(this.a,"a")},or.prototype.sa=function(t){kt(this.a,new rr(t))},or.prototype.ra=function(t){kt(this.a,new ir(t))},or.prototype.qa=function(){kt(this.a,"b")},er.prototype.createWebChannel=er.prototype.a,nr.prototype.send=nr.prototype.h,nr.prototype.open=nr.prototype.g,nr.prototype.close=nr.prototype.close,ce.NO_ERROR=0,ce.TIMEOUT=8,ce.HTTP_ERROR=6,he.COMPLETE="complete",pe.EventType=ge,ge.OPEN="a",ge.CLOSE="b",ge.ERROR="c",ge.MESSAGE="d",Dt.prototype.listen=Dt.prototype.va,wn.prototype.listenOnce=wn.prototype.wa,wn.prototype.getLastError=wn.prototype.Qa,wn.prototype.getLastErrorCode=wn.prototype.ua,wn.prototype.getStatus=wn.prototype.W,wn.prototype.getResponseJson=wn.prototype.Pa,wn.prototype.getResponseText=wn.prototype.$,wn.prototype.send=wn.prototype.ba;var ar=function(){return new er},sr=function(){return ne()},ur=ce,cr=he,hr=te,lr={gb:0,jb:1,kb:2,Db:3,Ib:4,Fb:5,Gb:6,Eb:7,Cb:8,Hb:9,PROXY:10,NOPROXY:11,Ab:12,wb:13,xb:14,vb:15,yb:16,zb:17,bb:18,ab:19,cb:20},fr=pe,pr=wn,dr=n(1191),gr=function(){function t(t,e){var n=this;this.previousValue=t,e&&(e.sequenceNumberHandler=function(t){return n.t(t)},this.i=function(t){return e.writeSequenceNumber(t)})}return t.prototype.t=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},t.prototype.next=function(){var t=++this.previousValue;return this.i&&this.i(t),t},t}();gr.o=-1;var mr={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"},vr=function(t){function e(e,n){var r=this;return(r=t.call(this,n)||this).code=e,r.message=n,r.name="FirebaseError",r.toString=function(){return r.name+": [code="+r.code+"]: "+r.message},r}return(0,dr.ZT)(e,t),e}(Error),yr=new o.Yd("@firebase/firestore");function Ar(){return yr.logLevel}function br(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(yr.logLevel<=o.in.DEBUG){var r=e.map(Ir);yr.debug.apply(yr,(0,dr.ev)(["Firestore (8.3.3): "+t],r))}}function wr(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(yr.logLevel<=o.in.ERROR){var r=e.map(Ir);yr.error.apply(yr,(0,dr.ev)(["Firestore (8.3.3): "+t],r))}}function _r(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(yr.logLevel<=o.in.WARN){var r=e.map(Ir);yr.warn.apply(yr,(0,dr.ev)(["Firestore (8.3.3): "+t],r))}}function Ir(t){if("string"==typeof t)return t;try{return e=t,JSON.stringify(e)}catch(e){return t}var e}function Er(t){void 0===t&&(t="Unexpected state");var e="FIRESTORE (8.3.3) INTERNAL ASSERTION FAILED: "+t;throw wr(e),new Error(e)}function Tr(t,e){t||Er()}function Cr(t,e){return t}function Sr(t){var e="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(n);else for(var r=0;r<t;r++)n[r]=Math.floor(256*Math.random());return n}var xr=function(){function t(){}return t.u=function(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=62*Math.floor(256/62),n="";n.length<20;)for(var r=Sr(40),i=0;i<r.length;++i)n.length<20&&r[i]<e&&(n+=t.charAt(r[i]%62));return n},t}();function Dr(t,e){return t<e?-1:t>e?1:0}function kr(t,e,n){return t.length===e.length&&t.every((function(t,r){return n(t,e[r])}))}function Rr(t){return t+"\0"}var Or=function(){function t(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new vr(mr.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new vr(mr.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new vr(mr.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new vr(mr.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}return t.now=function(){return t.fromMillis(Date.now())},t.fromDate=function(e){return t.fromMillis(e.getTime())},t.fromMillis=function(e){var n=Math.floor(e/1e3);return new t(n,1e6*(e-1e3*n))},t.prototype.toDate=function(){return new Date(this.toMillis())},t.prototype.toMillis=function(){return 1e3*this.seconds+this.nanoseconds/1e6},t.prototype._compareTo=function(t){return this.seconds===t.seconds?Dr(this.nanoseconds,t.nanoseconds):Dr(this.seconds,t.seconds)},t.prototype.isEqual=function(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds},t.prototype.toString=function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"},t.prototype.toJSON=function(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}},t.prototype.valueOf=function(){var t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")},t}(),Br=function(){function t(t){this.timestamp=t}return t.fromTimestamp=function(e){return new t(e)},t.min=function(){return new t(new Or(0,0))},t.prototype.compareTo=function(t){return this.timestamp._compareTo(t.timestamp)},t.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},t.prototype.toMicroseconds=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},t.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},t.prototype.toTimestamp=function(){return this.timestamp},t}();function Nr(t){var e=0;for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function Pr(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function Mr(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}var Lr=function(){function t(t,e,n){void 0===e?e=0:e>t.length&&Er(),void 0===n?n=t.length-e:n>t.length-e&&Er(),this.segments=t,this.offset=e,this.len=n}return Object.defineProperty(t.prototype,"length",{get:function(){return this.len},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(e){return 0===t.comparator(this,e)},t.prototype.child=function(e){var n=this.segments.slice(this.offset,this.limit());return e instanceof t?e.forEach((function(t){n.push(t)})):n.push(e),this.construct(n)},t.prototype.limit=function(){return this.offset+this.length},t.prototype.popFirst=function(t){return t=void 0===t?1:t,this.construct(this.segments,this.offset+t,this.length-t)},t.prototype.popLast=function(){return this.construct(this.segments,this.offset,this.length-1)},t.prototype.firstSegment=function(){return this.segments[this.offset]},t.prototype.lastSegment=function(){return this.get(this.length-1)},t.prototype.get=function(t){return this.segments[this.offset+t]},t.prototype.isEmpty=function(){return 0===this.length},t.prototype.isPrefixOf=function(t){if(t.length<this.length)return!1;for(var e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0},t.prototype.isImmediateParentOf=function(t){if(this.length+1!==t.length)return!1;for(var e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0},t.prototype.forEach=function(t){for(var e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])},t.prototype.toArray=function(){return this.segments.slice(this.offset,this.limit())},t.comparator=function(t,e){for(var n=Math.min(t.length,e.length),r=0;r<n;r++){var i=t.get(r),o=e.get(r);if(i<o)return-1;if(i>o)return 1}return t.length<e.length?-1:t.length>e.length?1:0},t}(),Ur=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,dr.ZT)(e,t),e.prototype.construct=function(t,n,r){return new e(t,n,r)},e.prototype.canonicalString=function(){return this.toArray().join("/")},e.prototype.toString=function(){return this.canonicalString()},e.fromString=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r=[],i=0,o=t;i<o.length;i++){var a=o[i];if(a.indexOf("//")>=0)throw new vr(mr.INVALID_ARGUMENT,"Invalid segment ("+a+"). Paths must not contain // in them.");r.push.apply(r,a.split("/").filter((function(t){return t.length>0})))}return new e(r)},e.emptyPath=function(){return new e([])},e}(Lr),Fr=/^[_a-zA-Z][_a-zA-Z0-9]*$/,Qr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,dr.ZT)(e,t),e.prototype.construct=function(t,n,r){return new e(t,n,r)},e.isValidIdentifier=function(t){return Fr.test(t)},e.prototype.canonicalString=function(){return this.toArray().map((function(t){return t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),e.isValidIdentifier(t)||(t="`"+t+"`"),t})).join(".")},e.prototype.toString=function(){return this.canonicalString()},e.prototype.isKeyField=function(){return 1===this.length&&"__name__"===this.get(0)},e.keyField=function(){return new e(["__name__"])},e.fromServerFormat=function(t){for(var n=[],r="",i=0,o=function(){if(0===r.length)throw new vr(mr.INVALID_ARGUMENT,"Invalid field path ("+t+"). Paths must not be empty, begin with '.', end with '.', or contain '..'");n.push(r),r=""},a=!1;i<t.length;){var s=t[i];if("\\"===s){if(i+1===t.length)throw new vr(mr.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var u=t[i+1];if("\\"!==u&&"."!==u&&"`"!==u)throw new vr(mr.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);r+=u,i+=2}else"`"===s?(a=!a,i++):"."!==s||a?(r+=s,i++):(o(),i++)}if(o(),a)throw new vr(mr.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new e(n)},e.emptyPath=function(){return new e([])},e}(Lr),jr=function(){function t(t){this.fields=t,t.sort(Qr.comparator)}return t.prototype.covers=function(t){for(var e=0,n=this.fields;e<n.length;e++)if(n[e].isPrefixOf(t))return!0;return!1},t.prototype.isEqual=function(t){return kr(this.fields,t.fields,(function(t,e){return t.isEqual(e)}))},t}(),qr=function(){function t(t){this.binaryString=t}return t.fromBase64String=function(e){return new t(atob(e))},t.fromUint8Array=function(e){return new t(function(t){for(var e="",n=0;n<t.length;++n)e+=String.fromCharCode(t[n]);return e}(e))},t.prototype.toBase64=function(){return t=this.binaryString,btoa(t);var t},t.prototype.toUint8Array=function(){return function(t){for(var e=new Uint8Array(t.length),n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}(this.binaryString)},t.prototype.approximateByteSize=function(){return 2*this.binaryString.length},t.prototype.compareTo=function(t){return Dr(this.binaryString,t.binaryString)},t.prototype.isEqual=function(t){return this.binaryString===t.binaryString},t}();qr.EMPTY_BYTE_STRING=new qr("");var Gr=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Vr(t){if(Tr(!!t),"string"==typeof t){var e=0,n=Gr.exec(t);if(Tr(!!n),n[1]){var r=n[1];r=(r+"000000000").substr(0,9),e=Number(r)}var i=new Date(t);return{seconds:Math.floor(i.getTime()/1e3),nanos:e}}return{seconds:zr(t.seconds),nanos:zr(t.nanos)}}function zr(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function Hr(t){return"string"==typeof t?qr.fromBase64String(t):qr.fromUint8Array(t)}function Kr(t){var e,n;return"server_timestamp"===(null===(n=((null===(e=null==t?void 0:t.mapValue)||void 0===e?void 0:e.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function Wr(t){var e=t.mapValue.fields.__previous_value__;return Kr(e)?Wr(e):e}function Yr(t){var e=Vr(t.mapValue.fields.__local_write_time__.timestampValue);return new Or(e.seconds,e.nanos)}function Jr(t){return null==t}function Xr(t){return 0===t&&1/t==-1/0}function Zr(t){return"number"==typeof t&&Number.isInteger(t)&&!Xr(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}var $r=function(){function t(t){this.path=t}return t.fromPath=function(e){return new t(Ur.fromString(e))},t.fromName=function(e){return new t(Ur.fromString(e).popFirst(5))},t.prototype.hasCollectionId=function(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t},t.prototype.isEqual=function(t){return null!==t&&0===Ur.comparator(this.path,t.path)},t.prototype.toString=function(){return this.path.toString()},t.comparator=function(t,e){return Ur.comparator(t.path,e.path)},t.isDocumentKey=function(t){return t.length%2==0},t.fromSegments=function(e){return new t(new Ur(e.slice()))},t}();function ti(t){return"nullValue"in t?0:"booleanValue"in t?1:"integerValue"in t||"doubleValue"in t?2:"timestampValue"in t?3:"stringValue"in t?5:"bytesValue"in t?6:"referenceValue"in t?7:"geoPointValue"in t?8:"arrayValue"in t?9:"mapValue"in t?Kr(t)?4:10:Er()}function ei(t,e){var n=ti(t);if(n!==ti(e))return!1;switch(n){case 0:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return Yr(t).isEqual(Yr(e));case 3:return function(t,e){if("string"==typeof t.timestampValue&&"string"==typeof e.timestampValue&&t.timestampValue.length===e.timestampValue.length)return t.timestampValue===e.timestampValue;var n=Vr(t.timestampValue),r=Vr(e.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(t,e);case 5:return t.stringValue===e.stringValue;case 6:return function(t,e){return Hr(t.bytesValue).isEqual(Hr(e.bytesValue))}(t,e);case 7:return t.referenceValue===e.referenceValue;case 8:return function(t,e){return zr(t.geoPointValue.latitude)===zr(e.geoPointValue.latitude)&&zr(t.geoPointValue.longitude)===zr(e.geoPointValue.longitude)}(t,e);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return zr(t.integerValue)===zr(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){var n=zr(t.doubleValue),r=zr(e.doubleValue);return n===r?Xr(n)===Xr(r):isNaN(n)&&isNaN(r)}return!1}(t,e);case 9:return kr(t.arrayValue.values||[],e.arrayValue.values||[],ei);case 10:return function(t,e){var n=t.mapValue.fields||{},r=e.mapValue.fields||{};if(Nr(n)!==Nr(r))return!1;for(var i in n)if(n.hasOwnProperty(i)&&(void 0===r[i]||!ei(n[i],r[i])))return!1;return!0}(t,e);default:return Er()}}function ni(t,e){return void 0!==(t.values||[]).find((function(t){return ei(t,e)}))}function ri(t,e){var n=ti(t),r=ti(e);if(n!==r)return Dr(n,r);switch(n){case 0:return 0;case 1:return Dr(t.booleanValue,e.booleanValue);case 2:return function(t,e){var n=zr(t.integerValue||t.doubleValue),r=zr(e.integerValue||e.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(t,e);case 3:return ii(t.timestampValue,e.timestampValue);case 4:return ii(Yr(t),Yr(e));case 5:return Dr(t.stringValue,e.stringValue);case 6:return function(t,e){var n=Hr(t),r=Hr(e);return n.compareTo(r)}(t.bytesValue,e.bytesValue);case 7:return function(t,e){for(var n=t.split("/"),r=e.split("/"),i=0;i<n.length&&i<r.length;i++){var o=Dr(n[i],r[i]);if(0!==o)return o}return Dr(n.length,r.length)}(t.referenceValue,e.referenceValue);case 8:return function(t,e){var n=Dr(zr(t.latitude),zr(e.latitude));return 0!==n?n:Dr(zr(t.longitude),zr(e.longitude))}(t.geoPointValue,e.geoPointValue);case 9:return function(t,e){for(var n=t.values||[],r=e.values||[],i=0;i<n.length&&i<r.length;++i){var o=ri(n[i],r[i]);if(o)return o}return Dr(n.length,r.length)}(t.arrayValue,e.arrayValue);case 10:return function(t,e){var n=t.fields||{},r=Object.keys(n),i=e.fields||{},o=Object.keys(i);r.sort(),o.sort();for(var a=0;a<r.length&&a<o.length;++a){var s=Dr(r[a],o[a]);if(0!==s)return s;var u=ri(n[r[a]],i[o[a]]);if(0!==u)return u}return Dr(r.length,o.length)}(t.mapValue,e.mapValue);default:throw Er()}}function ii(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return Dr(t,e);var n=Vr(t),r=Vr(e),i=Dr(n.seconds,r.seconds);return 0!==i?i:Dr(n.nanos,r.nanos)}function oi(t){return ai(t)}function ai(t){return"nullValue"in t?"null":"booleanValue"in t?""+t.booleanValue:"integerValue"in t?""+t.integerValue:"doubleValue"in t?""+t.doubleValue:"timestampValue"in t?function(t){var e=Vr(t);return"time("+e.seconds+","+e.nanos+")"}(t.timestampValue):"stringValue"in t?t.stringValue:"bytesValue"in t?Hr(t.bytesValue).toBase64():"referenceValue"in t?(n=t.referenceValue,$r.fromName(n).toString()):"geoPointValue"in t?"geo("+(e=t.geoPointValue).latitude+","+e.longitude+")":"arrayValue"in t?function(t){for(var e="[",n=!0,r=0,i=t.values||[];r<i.length;r++)n?n=!1:e+=",",e+=ai(i[r]);return e+"]"}(t.arrayValue):"mapValue"in t?function(t){for(var e="{",n=!0,r=0,i=Object.keys(t.fields||{}).sort();r<i.length;r++){var o=i[r];n?n=!1:e+=",",e+=o+":"+ai(t.fields[o])}return e+"}"}(t.mapValue):Er();var e,n}function si(t,e){return{referenceValue:"projects/"+t.projectId+"/databases/"+t.database+"/documents/"+e.path.canonicalString()}}function ui(t){return!!t&&"integerValue"in t}function ci(t){return!!t&&"arrayValue"in t}function hi(t){return!!t&&"nullValue"in t}function li(t){return!!t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function fi(t){return!!t&&"mapValue"in t}var pi=function(){function t(t){this.overlayMap=new Map,this.partialValue=t}return t.empty=function(){return new t({mapValue:{}})},t.prototype.field=function(e){return t.extractNestedValue(this.buildProto(),e)},t.prototype.toProto=function(){return this.field(Qr.emptyPath())},t.prototype.set=function(t,e){this.setOverlay(t,e)},t.prototype.setAll=function(t){var e=this;t.forEach((function(t,n){t?e.set(n,t):e.delete(n)}))},t.prototype.delete=function(t){this.setOverlay(t,null)},t.prototype.isEqual=function(t){return ei(this.buildProto(),t.buildProto())},t.prototype.setOverlay=function(t,e){for(var n=this.overlayMap,r=0;r<t.length-1;++r){var i=t.get(r),o=n.get(i);o instanceof Map?n=o:o&&10===ti(o)?(o=new Map(Object.entries(o.mapValue.fields||{})),n.set(i,o),n=o):(o=new Map,n.set(i,o),n=o)}n.set(t.lastSegment(),e)},t.prototype.applyOverlay=function(e,n){var r=this,i=!1,o=t.extractNestedValue(this.partialValue,e),a=fi(o)?Object.assign({},o.mapValue.fields):{};return n.forEach((function(t,n){if(t instanceof Map){var o=r.applyOverlay(e.child(n),t);null!=o&&(a[n]=o,i=!0)}else null!==t?(a[n]=t,i=!0):a.hasOwnProperty(n)&&(delete a[n],i=!0)})),i?{mapValue:{fields:a}}:null},t.prototype.buildProto=function(){var t=this.applyOverlay(Qr.emptyPath(),this.overlayMap);return null!=t&&(this.partialValue=t,this.overlayMap.clear()),this.partialValue},t.extractNestedValue=function(t,e){if(e.isEmpty())return t;for(var n=t,r=0;r<e.length-1;++r){if(!n.mapValue.fields)return null;if(!fi(n=n.mapValue.fields[e.get(r)]))return null}return(n=(n.mapValue.fields||{})[e.lastSegment()])||null},t.prototype.clone=function(){return new t(this.buildProto())},t}();function di(t){var e=[];return Pr(t.fields||{},(function(t,n){var r=new Qr([t]);if(fi(n)){var i=di(n.mapValue).fields;if(0===i.length)e.push(r);else for(var o=0,a=i;o<a.length;o++){var s=a[o];e.push(r.child(s))}}else e.push(r)})),new jr(e)}var gi=function(){function t(t,e,n,r,i){this.key=t,this.documentType=e,this.version=n,this.data=r,this.documentState=i}return t.newInvalidDocument=function(e){return new t(e,0,Br.min(),pi.empty(),0)},t.newFoundDocument=function(e,n,r){return new t(e,1,n,r,0)},t.newNoDocument=function(e,n){return new t(e,2,n,pi.empty(),0)},t.newUnknownDocument=function(e,n){return new t(e,3,n,pi.empty(),2)},t.prototype.convertToFoundDocument=function(t,e){return this.version=t,this.documentType=1,this.data=e,this.documentState=0,this},t.prototype.convertToNoDocument=function(t){return this.version=t,this.documentType=2,this.data=pi.empty(),this.documentState=0,this},t.prototype.convertToUnknownDocument=function(t){return this.version=t,this.documentType=3,this.data=pi.empty(),this.documentState=2,this},t.prototype.setHasCommittedMutations=function(){return this.documentState=2,this},t.prototype.setHasLocalMutations=function(){return this.documentState=1,this},Object.defineProperty(t.prototype,"hasLocalMutations",{get:function(){return 1===this.documentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasCommittedMutations",{get:function(){return 2===this.documentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasPendingWrites",{get:function(){return this.hasLocalMutations||this.hasCommittedMutations},enumerable:!1,configurable:!0}),t.prototype.isValidDocument=function(){return 0!==this.documentType},t.prototype.isFoundDocument=function(){return 1===this.documentType},t.prototype.isNoDocument=function(){return 2===this.documentType},t.prototype.isUnknownDocument=function(){return 3===this.documentType},t.prototype.isEqual=function(e){return e instanceof t&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)},t.prototype.clone=function(){return new t(this.key,this.documentType,this.version,this.data.clone(),this.documentState)},t.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+JSON.stringify(this.data.toProto())+", {documentType: "+this.documentType+"}), {documentState: "+this.documentState+"})"},t}(),mi=function(t,e,n,r,i,o,a){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=null),void 0===a&&(a=null),this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=o,this.endAt=a,this.h=null};function vi(t,e,n,r,i,o,a){return void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=null),void 0===a&&(a=null),new mi(t,e,n,r,i,o,a)}function yi(t){var e=Cr(t);if(null===e.h){var n=e.path.canonicalString();null!==e.collectionGroup&&(n+="|cg:"+e.collectionGroup),n+="|f:",n+=e.filters.map((function(t){return function(t){return t.field.canonicalString()+t.op.toString()+oi(t.value)}(t)})).join(","),n+="|ob:",n+=e.orderBy.map((function(t){return function(t){return t.field.canonicalString()+t.dir}(t)})).join(","),Jr(e.limit)||(n+="|l:",n+=e.limit),e.startAt&&(n+="|lb:",n+=Ri(e.startAt)),e.endAt&&(n+="|ub:",n+=Ri(e.endAt)),e.h=n}return e.h}function Ai(t,e){if(t.limit!==e.limit)return!1;if(t.orderBy.length!==e.orderBy.length)return!1;for(var n=0;n<t.orderBy.length;n++)if(!Bi(t.orderBy[n],e.orderBy[n]))return!1;if(t.filters.length!==e.filters.length)return!1;for(var r=0;r<t.filters.length;r++)if(i=t.filters[r],o=e.filters[r],i.op!==o.op||!i.field.isEqual(o.field)||!ei(i.value,o.value))return!1;var i,o;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!Pi(t.startAt,e.startAt)&&Pi(t.endAt,e.endAt)}function bi(t){return $r.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}var wi=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).field=e,i.op=n,i.value=r,i}return(0,dr.ZT)(e,t),e.create=function(t,n,r){return t.isKeyField()?"in"===n||"not-in"===n?this.l(t,n,r):new _i(t,n,r):"array-contains"===n?new Ci(t,r):"in"===n?new Si(t,r):"not-in"===n?new xi(t,r):"array-contains-any"===n?new Di(t,r):new e(t,n,r)},e.l=function(t,e,n){return"in"===e?new Ii(t,n):new Ei(t,n)},e.prototype.matches=function(t){var e=t.data.field(this.field);return"!="===this.op?null!==e&&this.m(ri(e,this.value)):null!==e&&ti(this.value)===ti(e)&&this.m(ri(e,this.value))},e.prototype.m=function(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return 0===t;case"!=":return 0!==t;case">":return t>0;case">=":return t>=0;default:return Er()}},e.prototype.g=function(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0},e}((function(){})),_i=function(t){function e(e,n,r){var i=this;return(i=t.call(this,e,n,r)||this).key=$r.fromName(r.referenceValue),i}return(0,dr.ZT)(e,t),e.prototype.matches=function(t){var e=$r.comparator(t.key,this.key);return this.m(e)},e}(wi),Ii=function(t){function e(e,n){var r=this;return(r=t.call(this,e,"in",n)||this).keys=Ti("in",n),r}return(0,dr.ZT)(e,t),e.prototype.matches=function(t){return this.keys.some((function(e){return e.isEqual(t.key)}))},e}(wi),Ei=function(t){function e(e,n){var r=this;return(r=t.call(this,e,"not-in",n)||this).keys=Ti("not-in",n),r}return(0,dr.ZT)(e,t),e.prototype.matches=function(t){return!this.keys.some((function(e){return e.isEqual(t.key)}))},e}(wi);function Ti(t,e){var n;return((null===(n=e.arrayValue)||void 0===n?void 0:n.values)||[]).map((function(t){return $r.fromName(t.referenceValue)}))}var Ci=function(t){function e(e,n){return t.call(this,e,"array-contains",n)||this}return(0,dr.ZT)(e,t),e.prototype.matches=function(t){var e=t.data.field(this.field);return ci(e)&&ni(e.arrayValue,this.value)},e}(wi),Si=function(t){function e(e,n){return t.call(this,e,"in",n)||this}return(0,dr.ZT)(e,t),e.prototype.matches=function(t){var e=t.data.field(this.field);return null!==e&&ni(this.value.arrayValue,e)},e}(wi),xi=function(t){function e(e,n){return t.call(this,e,"not-in",n)||this}return(0,dr.ZT)(e,t),e.prototype.matches=function(t){if(ni(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;var e=t.data.field(this.field);return null!==e&&!ni(this.value.arrayValue,e)},e}(wi),Di=function(t){function e(e,n){return t.call(this,e,"array-contains-any",n)||this}return(0,dr.ZT)(e,t),e.prototype.matches=function(t){var e=this,n=t.data.field(this.field);return!(!ci(n)||!n.arrayValue.values)&&n.arrayValue.values.some((function(t){return ni(e.value.arrayValue,t)}))},e}(wi),ki=function(t,e){this.position=t,this.before=e};function Ri(t){return(t.before?"b":"a")+":"+t.position.map((function(t){return oi(t)})).join(",")}var Oi=function(t,e){void 0===e&&(e="asc"),this.field=t,this.dir=e};function Bi(t,e){return t.dir===e.dir&&t.field.isEqual(e.field)}function Ni(t,e,n){for(var r=0,i=0;i<t.position.length;i++){var o=e[i],a=t.position[i];if(r=o.field.isKeyField()?$r.comparator($r.fromName(a.referenceValue),n.key):ri(a,n.data.field(o.field)),"desc"===o.dir&&(r*=-1),0!==r)break}return t.before?r<=0:r<0}function Pi(t,e){if(null===t)return null===e;if(null===e)return!1;if(t.before!==e.before||t.position.length!==e.position.length)return!1;for(var n=0;n<t.position.length;n++)if(!ei(t.position[n],e.position[n]))return!1;return!0}var Mi=function(t,e,n,r,i,o,a,s){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o="F"),void 0===a&&(a=null),void 0===s&&(s=null),this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=o,this.startAt=a,this.endAt=s,this.p=null,this.T=null,this.startAt,this.endAt};function Li(t,e,n,r,i,o,a,s){return new Mi(t,e,n,r,i,o,a,s)}function Ui(t){return new Mi(t)}function Fi(t){return!Jr(t.limit)&&"F"===t.limitType}function Qi(t){return!Jr(t.limit)&&"L"===t.limitType}function ji(t){return t.explicitOrderBy.length>0?t.explicitOrderBy[0].field:null}function qi(t){for(var e=0,n=t.filters;e<n.length;e++){var r=n[e];if(r.g())return r.field}return null}function Gi(t){return null!==t.collectionGroup}function Vi(t){var e=Cr(t);if(null===e.p){e.p=[];var n=qi(e),r=ji(e);if(null!==n&&null===r)n.isKeyField()||e.p.push(new Oi(n)),e.p.push(new Oi(Qr.keyField(),"asc"));else{for(var i=!1,o=0,a=e.explicitOrderBy;o<a.length;o++){var s=a[o];e.p.push(s),s.field.isKeyField()&&(i=!0)}if(!i){var u=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";e.p.push(new Oi(Qr.keyField(),u))}}}return e.p}function zi(t){var e=Cr(t);if(!e.T)if("F"===e.limitType)e.T=vi(e.path,e.collectionGroup,Vi(e),e.filters,e.limit,e.startAt,e.endAt);else{for(var n=[],r=0,i=Vi(e);r<i.length;r++){var o=i[r],a="desc"===o.dir?"asc":"desc";n.push(new Oi(o.field,a))}var s=e.endAt?new ki(e.endAt.position,!e.endAt.before):null,u=e.startAt?new ki(e.startAt.position,!e.startAt.before):null;e.T=vi(e.path,e.collectionGroup,n,e.filters,e.limit,s,u)}return e.T}function Hi(t,e,n){return new Mi(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function Ki(t,e){return Ai(zi(t),zi(e))&&t.limitType===e.limitType}function Wi(t){return yi(zi(t))+"|lt:"+t.limitType}function Yi(t){return"Query(target="+function(t){var e=t.path.canonicalString();return null!==t.collectionGroup&&(e+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(e+=", filters: ["+t.filters.map((function(t){return(e=t).field.canonicalString()+" "+e.op+" "+oi(e.value);var e})).join(", ")+"]"),Jr(t.limit)||(e+=", limit: "+t.limit),t.orderBy.length>0&&(e+=", orderBy: ["+t.orderBy.map((function(t){return function(t){return t.field.canonicalString()+" ("+t.dir+")"}(t)})).join(", ")+"]"),t.startAt&&(e+=", startAt: "+Ri(t.startAt)),t.endAt&&(e+=", endAt: "+Ri(t.endAt)),"Target("+e+")"}(zi(t))+"; limitType="+t.limitType+")"}function Ji(t,e){return e.isFoundDocument()&&function(t,e){var n=e.key.path;return null!==t.collectionGroup?e.key.hasCollectionId(t.collectionGroup)&&t.path.isPrefixOf(n):$r.isDocumentKey(t.path)?t.path.isEqual(n):t.path.isImmediateParentOf(n)}(t,e)&&function(t,e){for(var n=0,r=t.explicitOrderBy;n<r.length;n++){var i=r[n];if(!i.field.isKeyField()&&null===e.data.field(i.field))return!1}return!0}(t,e)&&function(t,e){for(var n=0,r=t.filters;n<r.length;n++)if(!r[n].matches(e))return!1;return!0}(t,e)&&function(t,e){return!(t.startAt&&!Ni(t.startAt,Vi(t),e)||t.endAt&&Ni(t.endAt,Vi(t),e))}(t,e)}function Xi(t){return function(e,n){for(var r=!1,i=0,o=Vi(t);i<o.length;i++){var a=o[i],s=Zi(a,e,n);if(0!==s)return s;r=r||a.field.isKeyField()}return 0}}function Zi(t,e,n){var r=t.field.isKeyField()?$r.comparator(e.key,n.key):function(t,e,n){var r=e.data.field(t),i=n.data.field(t);return null!==r&&null!==i?ri(r,i):Er()}(t.field,e,n);switch(t.dir){case"asc":return r;case"desc":return-1*r;default:return Er()}}function $i(t,e){if(t.I){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Xr(e)?"-0":e}}function to(t){return{integerValue:""+t}}function eo(t,e){return Zr(e)?to(e):$i(t,e)}var no=function(){this._=void 0};function ro(t,e,n){return t instanceof ao?function(t,e){var n={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:t.seconds,nanos:t.nanoseconds}}}};return e&&(n.fields.__previous_value__=e),{mapValue:n}}(n,e):t instanceof so?uo(t,e):t instanceof co?ho(t,e):function(t,e){var n=oo(t,e),r=fo(n)+fo(t.A);return ui(n)&&ui(t.A)?to(r):$i(t.R,r)}(t,e)}function io(t,e,n){return t instanceof so?uo(t,e):t instanceof co?ho(t,e):n}function oo(t,e){return t instanceof lo?ui(n=e)||function(t){return!!t&&"doubleValue"in t}(n)?e:{integerValue:0}:null;var n}var ao=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,dr.ZT)(e,t),e}(no),so=function(t){function e(e){var n=this;return(n=t.call(this)||this).elements=e,n}return(0,dr.ZT)(e,t),e}(no);function uo(t,e){for(var n=po(e),r=function(t){n.some((function(e){return ei(e,t)}))||n.push(t)},i=0,o=t.elements;i<o.length;i++)r(o[i]);return{arrayValue:{values:n}}}var co=function(t){function e(e){var n=this;return(n=t.call(this)||this).elements=e,n}return(0,dr.ZT)(e,t),e}(no);function ho(t,e){for(var n=po(e),r=function(t){n=n.filter((function(e){return!ei(e,t)}))},i=0,o=t.elements;i<o.length;i++)r(o[i]);return{arrayValue:{values:n}}}var lo=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).R=e,r.A=n,r}return(0,dr.ZT)(e,t),e}(no);function fo(t){return zr(t.integerValue||t.doubleValue)}function po(t){return ci(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}var go=function(t,e){this.field=t,this.transform=e},mo=function(t,e){this.version=t,this.transformResults=e},vo=function(){function t(t,e){this.updateTime=t,this.exists=e}return t.none=function(){return new t},t.exists=function(e){return new t(void 0,e)},t.updateTime=function(e){return new t(e)},Object.defineProperty(t.prototype,"isNone",{get:function(){return void 0===this.updateTime&&void 0===this.exists},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)},t}();function yo(t,e){return void 0!==t.updateTime?e.isFoundDocument()&&e.version.isEqual(t.updateTime):void 0===t.exists||t.exists===e.isFoundDocument()}var Ao=function(){};function bo(t,e,n){t instanceof To?function(t,e,n){var r=t.value.clone(),i=xo(t.fieldTransforms,e,n.transformResults);r.setAll(i),e.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(t,e,n):t instanceof Co?function(t,e,n){if(yo(t.precondition,e)){var r=xo(t.fieldTransforms,e,n.transformResults),i=e.data;i.setAll(So(t)),i.setAll(r),e.convertToFoundDocument(n.version,i).setHasCommittedMutations()}else e.convertToUnknownDocument(n.version)}(t,e,n):function(t,e,n){e.convertToNoDocument(n.version).setHasCommittedMutations()}(0,e,n)}function wo(t,e,n){t instanceof To?function(t,e,n){if(yo(t.precondition,e)){var r=t.value.clone(),i=Do(t.fieldTransforms,n,e);r.setAll(i),e.convertToFoundDocument(Eo(e),r).setHasLocalMutations()}}(t,e,n):t instanceof Co?function(t,e,n){if(yo(t.precondition,e)){var r=Do(t.fieldTransforms,n,e),i=e.data;i.setAll(So(t)),i.setAll(r),e.convertToFoundDocument(Eo(e),i).setHasLocalMutations()}}(t,e,n):function(t,e){yo(t.precondition,e)&&e.convertToNoDocument(Br.min())}(t,e)}function _o(t,e){for(var n=null,r=0,i=t.fieldTransforms;r<i.length;r++){var o=i[r],a=e.data.field(o.field),s=oo(o.transform,a||null);null!=s&&(null==n&&(n=pi.empty()),n.set(o.field,s))}return n||null}function Io(t,e){return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.precondition.isEqual(e.precondition)&&!!function(t,e){return void 0===t&&void 0===e||!(!t||!e)&&kr(t,e,(function(t,e){return function(t,e){return t.field.isEqual(e.field)&&function(t,e){return t instanceof so&&e instanceof so||t instanceof co&&e instanceof co?kr(t.elements,e.elements,ei):t instanceof lo&&e instanceof lo?ei(t.A,e.A):t instanceof ao&&e instanceof ao}(t.transform,e.transform)}(t,e)}))}(t.fieldTransforms,e.fieldTransforms)&&(0===t.type?t.value.isEqual(e.value):1!==t.type||t.data.isEqual(e.data)&&t.fieldMask.isEqual(e.fieldMask))}function Eo(t){return t.isFoundDocument()?t.version:Br.min()}var To=function(t){function e(e,n,r,i){void 0===i&&(i=[]);var o=this;return(o=t.call(this)||this).key=e,o.value=n,o.precondition=r,o.fieldTransforms=i,o.type=0,o}return(0,dr.ZT)(e,t),e}(Ao),Co=function(t){function e(e,n,r,i,o){void 0===o&&(o=[]);var a=this;return(a=t.call(this)||this).key=e,a.data=n,a.fieldMask=r,a.precondition=i,a.fieldTransforms=o,a.type=1,a}return(0,dr.ZT)(e,t),e}(Ao);function So(t){var e=new Map;return t.fieldMask.fields.forEach((function(n){if(!n.isEmpty()){var r=t.data.field(n);e.set(n,r)}})),e}function xo(t,e,n){var r=new Map;Tr(t.length===n.length);for(var i=0;i<n.length;i++){var o=t[i],a=o.transform,s=e.data.field(o.field);r.set(o.field,io(a,s,n[i]))}return r}function Do(t,e,n){for(var r=new Map,i=0,o=t;i<o.length;i++){var a=o[i],s=a.transform,u=n.data.field(a.field);r.set(a.field,ro(s,u,e))}return r}var ko,Ro,Oo=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).key=e,r.precondition=n,r.type=2,r.fieldTransforms=[],r}return(0,dr.ZT)(e,t),e}(Ao),Bo=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).key=e,r.precondition=n,r.type=3,r.fieldTransforms=[],r}return(0,dr.ZT)(e,t),e}(Ao),No=function(t){this.count=t};function Po(t){switch(t){case mr.OK:return Er();case mr.CANCELLED:case mr.UNKNOWN:case mr.DEADLINE_EXCEEDED:case mr.RESOURCE_EXHAUSTED:case mr.INTERNAL:case mr.UNAVAILABLE:case mr.UNAUTHENTICATED:return!1;case mr.INVALID_ARGUMENT:case mr.NOT_FOUND:case mr.ALREADY_EXISTS:case mr.PERMISSION_DENIED:case mr.FAILED_PRECONDITION:case mr.ABORTED:case mr.OUT_OF_RANGE:case mr.UNIMPLEMENTED:case mr.DATA_LOSS:return!0;default:return Er()}}function Mo(t){if(void 0===t)return wr("GRPC error has no .code"),mr.UNKNOWN;switch(t){case ko.OK:return mr.OK;case ko.CANCELLED:return mr.CANCELLED;case ko.UNKNOWN:return mr.UNKNOWN;case ko.DEADLINE_EXCEEDED:return mr.DEADLINE_EXCEEDED;case ko.RESOURCE_EXHAUSTED:return mr.RESOURCE_EXHAUSTED;case ko.INTERNAL:return mr.INTERNAL;case ko.UNAVAILABLE:return mr.UNAVAILABLE;case ko.UNAUTHENTICATED:return mr.UNAUTHENTICATED;case ko.INVALID_ARGUMENT:return mr.INVALID_ARGUMENT;case ko.NOT_FOUND:return mr.NOT_FOUND;case ko.ALREADY_EXISTS:return mr.ALREADY_EXISTS;case ko.PERMISSION_DENIED:return mr.PERMISSION_DENIED;case ko.FAILED_PRECONDITION:return mr.FAILED_PRECONDITION;case ko.ABORTED:return mr.ABORTED;case ko.OUT_OF_RANGE:return mr.OUT_OF_RANGE;case ko.UNIMPLEMENTED:return mr.UNIMPLEMENTED;case ko.DATA_LOSS:return mr.DATA_LOSS;default:return Er()}}(Ro=ko||(ko={}))[Ro.OK=0]="OK",Ro[Ro.CANCELLED=1]="CANCELLED",Ro[Ro.UNKNOWN=2]="UNKNOWN",Ro[Ro.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Ro[Ro.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Ro[Ro.NOT_FOUND=5]="NOT_FOUND",Ro[Ro.ALREADY_EXISTS=6]="ALREADY_EXISTS",Ro[Ro.PERMISSION_DENIED=7]="PERMISSION_DENIED",Ro[Ro.UNAUTHENTICATED=16]="UNAUTHENTICATED",Ro[Ro.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Ro[Ro.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Ro[Ro.ABORTED=10]="ABORTED",Ro[Ro.OUT_OF_RANGE=11]="OUT_OF_RANGE",Ro[Ro.UNIMPLEMENTED=12]="UNIMPLEMENTED",Ro[Ro.INTERNAL=13]="INTERNAL",Ro[Ro.UNAVAILABLE=14]="UNAVAILABLE",Ro[Ro.DATA_LOSS=15]="DATA_LOSS";var Lo=function(){function t(t,e){this.comparator=t,this.root=e||Fo.EMPTY}return t.prototype.insert=function(e,n){return new t(this.comparator,this.root.insert(e,n,this.comparator).copy(null,null,Fo.BLACK,null,null))},t.prototype.remove=function(e){return new t(this.comparator,this.root.remove(e,this.comparator).copy(null,null,Fo.BLACK,null,null))},t.prototype.get=function(t){for(var e=this.root;!e.isEmpty();){var n=this.comparator(t,e.key);if(0===n)return e.value;n<0?e=e.left:n>0&&(e=e.right)}return null},t.prototype.indexOf=function(t){for(var e=0,n=this.root;!n.isEmpty();){var r=this.comparator(t,n.key);if(0===r)return e+n.left.size;r<0?n=n.left:(e+=n.left.size+1,n=n.right)}return-1},t.prototype.isEmpty=function(){return this.root.isEmpty()},Object.defineProperty(t.prototype,"size",{get:function(){return this.root.size},enumerable:!1,configurable:!0}),t.prototype.minKey=function(){return this.root.minKey()},t.prototype.maxKey=function(){return this.root.maxKey()},t.prototype.inorderTraversal=function(t){return this.root.inorderTraversal(t)},t.prototype.forEach=function(t){this.inorderTraversal((function(e,n){return t(e,n),!1}))},t.prototype.toString=function(){var t=[];return this.inorderTraversal((function(e,n){return t.push(e+":"+n),!1})),"{"+t.join(", ")+"}"},t.prototype.reverseTraversal=function(t){return this.root.reverseTraversal(t)},t.prototype.getIterator=function(){return new Uo(this.root,null,this.comparator,!1)},t.prototype.getIteratorFrom=function(t){return new Uo(this.root,t,this.comparator,!1)},t.prototype.getReverseIterator=function(){return new Uo(this.root,null,this.comparator,!0)},t.prototype.getReverseIteratorFrom=function(t){return new Uo(this.root,t,this.comparator,!0)},t}(),Uo=function(){function t(t,e,n,r){this.isReverse=r,this.nodeStack=[];for(var i=1;!t.isEmpty();)if(i=e?n(t.key,e):1,r&&(i*=-1),i<0)t=this.isReverse?t.left:t.right;else{if(0===i){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}return t.prototype.getNext=function(){var t=this.nodeStack.pop(),e={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return e},t.prototype.hasNext=function(){return this.nodeStack.length>0},t.prototype.peek=function(){if(0===this.nodeStack.length)return null;var t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}},t}(),Fo=function(){function t(e,n,r,i,o){this.key=e,this.value=n,this.color=null!=r?r:t.RED,this.left=null!=i?i:t.EMPTY,this.right=null!=o?o:t.EMPTY,this.size=this.left.size+1+this.right.size}return t.prototype.copy=function(e,n,r,i,o){return new t(null!=e?e:this.key,null!=n?n:this.value,null!=r?r:this.color,null!=i?i:this.left,null!=o?o:this.right)},t.prototype.isEmpty=function(){return!1},t.prototype.inorderTraversal=function(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)},t.prototype.reverseTraversal=function(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)},t.prototype.min=function(){return this.left.isEmpty()?this:this.left.min()},t.prototype.minKey=function(){return this.min().key},t.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},t.prototype.insert=function(t,e,n){var r=this,i=n(t,r.key);return(r=i<0?r.copy(null,null,null,r.left.insert(t,e,n),null):0===i?r.copy(null,e,null,null,null):r.copy(null,null,null,null,r.right.insert(t,e,n))).fixUp()},t.prototype.removeMin=function(){if(this.left.isEmpty())return t.EMPTY;var e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),(e=e.copy(null,null,null,e.left.removeMin(),null)).fixUp()},t.prototype.remove=function(e,n){var r,i=this;if(n(e,i.key)<0)i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(e,n),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),0===n(e,i.key)){if(i.right.isEmpty())return t.EMPTY;r=i.right.min(),i=i.copy(r.key,r.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(e,n))}return i.fixUp()},t.prototype.isRed=function(){return this.color},t.prototype.fixUp=function(){var t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t},t.prototype.moveRedLeft=function(){var t=this.colorFlip();return t.right.left.isRed()&&(t=(t=(t=t.copy(null,null,null,null,t.right.rotateRight())).rotateLeft()).colorFlip()),t},t.prototype.moveRedRight=function(){var t=this.colorFlip();return t.left.left.isRed()&&(t=(t=t.rotateRight()).colorFlip()),t},t.prototype.rotateLeft=function(){var e=this.copy(null,null,t.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)},t.prototype.rotateRight=function(){var e=this.copy(null,null,t.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)},t.prototype.colorFlip=function(){var t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)},t.prototype.checkMaxDepth=function(){var t=this.check();return Math.pow(2,t)<=this.size+1},t.prototype.check=function(){if(this.isRed()&&this.left.isRed())throw Er();if(this.right.isRed())throw Er();var t=this.left.check();if(t!==this.right.check())throw Er();return t+(this.isRed()?0:1)},t}();Fo.EMPTY=null,Fo.RED=!0,Fo.BLACK=!1,Fo.EMPTY=new(function(){function t(){this.size=0}return Object.defineProperty(t.prototype,"key",{get:function(){throw Er()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){throw Er()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){throw Er()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){throw Er()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){throw Er()},enumerable:!1,configurable:!0}),t.prototype.copy=function(t,e,n,r,i){return this},t.prototype.insert=function(t,e,n){return new Fo(t,e)},t.prototype.remove=function(t,e){return this},t.prototype.isEmpty=function(){return!0},t.prototype.inorderTraversal=function(t){return!1},t.prototype.reverseTraversal=function(t){return!1},t.prototype.minKey=function(){return null},t.prototype.maxKey=function(){return null},t.prototype.isRed=function(){return!1},t.prototype.checkMaxDepth=function(){return!0},t.prototype.check=function(){return 0},t}());var Qo=function(){function t(t){this.comparator=t,this.data=new Lo(this.comparator)}return t.prototype.has=function(t){return null!==this.data.get(t)},t.prototype.first=function(){return this.data.minKey()},t.prototype.last=function(){return this.data.maxKey()},Object.defineProperty(t.prototype,"size",{get:function(){return this.data.size},enumerable:!1,configurable:!0}),t.prototype.indexOf=function(t){return this.data.indexOf(t)},t.prototype.forEach=function(t){this.data.inorderTraversal((function(e,n){return t(e),!1}))},t.prototype.forEachInRange=function(t,e){for(var n=this.data.getIteratorFrom(t[0]);n.hasNext();){var r=n.getNext();if(this.comparator(r.key,t[1])>=0)return;e(r.key)}},t.prototype.forEachWhile=function(t,e){var n;for(n=void 0!==e?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return},t.prototype.firstAfterOrEqual=function(t){var e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null},t.prototype.getIterator=function(){return new jo(this.data.getIterator())},t.prototype.getIteratorFrom=function(t){return new jo(this.data.getIteratorFrom(t))},t.prototype.add=function(t){return this.copy(this.data.remove(t).insert(t,!0))},t.prototype.delete=function(t){return this.has(t)?this.copy(this.data.remove(t)):this},t.prototype.isEmpty=function(){return this.data.isEmpty()},t.prototype.unionWith=function(t){var e=this;return e.size<t.size&&(e=t,t=this),t.forEach((function(t){e=e.add(t)})),e},t.prototype.isEqual=function(e){if(!(e instanceof t))return!1;if(this.size!==e.size)return!1;for(var n=this.data.getIterator(),r=e.data.getIterator();n.hasNext();){var i=n.getNext().key,o=r.getNext().key;if(0!==this.comparator(i,o))return!1}return!0},t.prototype.toArray=function(){var t=[];return this.forEach((function(e){t.push(e)})),t},t.prototype.toString=function(){var t=[];return this.forEach((function(e){return t.push(e)})),"SortedSet("+t.toString()+")"},t.prototype.copy=function(e){var n=new t(this.comparator);return n.data=e,n},t}(),jo=function(){function t(t){this.iter=t}return t.prototype.getNext=function(){return this.iter.getNext().key},t.prototype.hasNext=function(){return this.iter.hasNext()},t}(),qo=new Lo($r.comparator);function Go(){return qo}var Vo=new Lo($r.comparator);function zo(){return Vo}var Ho=new Lo($r.comparator);function Ko(){return Ho}var Wo=new Qo($r.comparator);function Yo(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=Wo,r=0,i=t;r<i.length;r++){var o=i[r];n=n.add(o)}return n}var Jo=new Qo(Dr);function Xo(){return Jo}var Zo=function(){function t(t,e,n,r,i){this.snapshotVersion=t,this.targetChanges=e,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}return t.createSynthesizedRemoteEventForCurrentChange=function(e,n){var r=new Map;return r.set(e,$o.createSynthesizedTargetChangeForCurrentChange(e,n)),new t(Br.min(),r,Xo(),Go(),Yo())},t}(),$o=function(){function t(t,e,n,r,i){this.resumeToken=t,this.current=e,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}return t.createSynthesizedTargetChangeForCurrentChange=function(e,n){return new t(qr.EMPTY_BYTE_STRING,n,Yo(),Yo(),Yo())},t}(),ta=function(t,e,n,r){this.v=t,this.removedTargetIds=e,this.key=n,this.P=r},ea=function(t,e){this.targetId=t,this.V=e},na=function(t,e,n,r){void 0===n&&(n=qr.EMPTY_BYTE_STRING),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r},ra=function(){function t(){this.S=0,this.D=aa(),this.C=qr.EMPTY_BYTE_STRING,this.N=!1,this.F=!0}return Object.defineProperty(t.prototype,"current",{get:function(){return this.N},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"resumeToken",{get:function(){return this.C},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"k",{get:function(){return 0!==this.S},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"O",{get:function(){return this.F},enumerable:!1,configurable:!0}),t.prototype.$=function(t){t.approximateByteSize()>0&&(this.F=!0,this.C=t)},t.prototype.M=function(){var t=Yo(),e=Yo(),n=Yo();return this.D.forEach((function(r,i){switch(i){case 0:t=t.add(r);break;case 2:e=e.add(r);break;case 1:n=n.add(r);break;default:Er()}})),new $o(this.C,this.N,t,e,n)},t.prototype.L=function(){this.F=!1,this.D=aa()},t.prototype.B=function(t,e){this.F=!0,this.D=this.D.insert(t,e)},t.prototype.q=function(t){this.F=!0,this.D=this.D.remove(t)},t.prototype.U=function(){this.S+=1},t.prototype.K=function(){this.S-=1},t.prototype.j=function(){this.F=!0,this.N=!0},t}(),ia=function(){function t(t){this.W=t,this.G=new Map,this.H=Go(),this.J=oa(),this.Y=new Qo(Dr)}return t.prototype.X=function(t){for(var e=0,n=t.v;e<n.length;e++){var r=n[e];t.P&&t.P.isFoundDocument()?this.Z(r,t.P):this.tt(r,t.key,t.P)}for(var i=0,o=t.removedTargetIds;i<o.length;i++)r=o[i],this.tt(r,t.key,t.P)},t.prototype.et=function(t){var e=this;this.forEachTarget(t,(function(n){var r=e.nt(n);switch(t.state){case 0:e.st(n)&&r.$(t.resumeToken);break;case 1:r.K(),r.k||r.L(),r.$(t.resumeToken);break;case 2:r.K(),r.k||e.removeTarget(n);break;case 3:e.st(n)&&(r.j(),r.$(t.resumeToken));break;case 4:e.st(n)&&(e.it(n),r.$(t.resumeToken));break;default:Er()}}))},t.prototype.forEachTarget=function(t,e){var n=this;t.targetIds.length>0?t.targetIds.forEach(e):this.G.forEach((function(t,r){n.st(r)&&e(r)}))},t.prototype.rt=function(t){var e=t.targetId,n=t.V.count,r=this.ot(e);if(r){var i=r.target;if(bi(i))if(0===n){var o=new $r(i.path);this.tt(e,o,gi.newNoDocument(o,Br.min()))}else Tr(1===n);else this.ct(e)!==n&&(this.it(e),this.Y=this.Y.add(e))}},t.prototype.ut=function(t){var e=this,n=new Map;this.G.forEach((function(r,i){var o=e.ot(i);if(o){if(r.current&&bi(o.target)){var a=new $r(o.target.path);null!==e.H.get(a)||e.at(i,a)||e.tt(i,a,gi.newNoDocument(a,t))}r.O&&(n.set(i,r.M()),r.L())}}));var r=Yo();this.J.forEach((function(t,n){var i=!0;n.forEachWhile((function(t){var n=e.ot(t);return!n||2===n.purpose||(i=!1,!1)})),i&&(r=r.add(t))}));var i=new Zo(t,n,this.Y,this.H,r);return this.H=Go(),this.J=oa(),this.Y=new Qo(Dr),i},t.prototype.Z=function(t,e){if(this.st(t)){var n=this.at(t,e.key)?2:0;this.nt(t).B(e.key,n),this.H=this.H.insert(e.key,e),this.J=this.J.insert(e.key,this.ht(e.key).add(t))}},t.prototype.tt=function(t,e,n){if(this.st(t)){var r=this.nt(t);this.at(t,e)?r.B(e,1):r.q(e),this.J=this.J.insert(e,this.ht(e).delete(t)),n&&(this.H=this.H.insert(e,n))}},t.prototype.removeTarget=function(t){this.G.delete(t)},t.prototype.ct=function(t){var e=this.nt(t).M();return this.W.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size},t.prototype.U=function(t){this.nt(t).U()},t.prototype.nt=function(t){var e=this.G.get(t);return e||(e=new ra,this.G.set(t,e)),e},t.prototype.ht=function(t){var e=this.J.get(t);return e||(e=new Qo(Dr),this.J=this.J.insert(t,e)),e},t.prototype.st=function(t){var e=null!==this.ot(t);return e||br("WatchChangeAggregator","Detected inactive target",t),e},t.prototype.ot=function(t){var e=this.G.get(t);return e&&e.k?null:this.W.lt(t)},t.prototype.it=function(t){var e=this;this.G.set(t,new ra),this.W.getRemoteKeysForTarget(t).forEach((function(n){e.tt(t,n,null)}))},t.prototype.at=function(t,e){return this.W.getRemoteKeysForTarget(t).has(e)},t}();function oa(){return new Lo($r.comparator)}function aa(){return new Lo($r.comparator)}var sa={asc:"ASCENDING",desc:"DESCENDING"},ua={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},ca=function(t,e){this.databaseId=t,this.I=e};function ha(t,e){return t.I?new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")+"."+("000000000"+e.nanoseconds).slice(-9)+"Z":{seconds:""+e.seconds,nanos:e.nanoseconds}}function la(t,e){return t.I?e.toBase64():e.toUint8Array()}function fa(t,e){return ha(t,e.toTimestamp())}function pa(t){return Tr(!!t),Br.fromTimestamp(function(t){var e=Vr(t);return new Or(e.seconds,e.nanos)}(t))}function da(t,e){return function(t){return new Ur(["projects",t.projectId,"databases",t.database])}(t).child("documents").child(e).canonicalString()}function ga(t){var e=Ur.fromString(t);return Tr(Fa(e)),e}function ma(t,e){return da(t.databaseId,e.path)}function va(t,e){var n=ga(e);if(n.get(1)!==t.databaseId.projectId)throw new vr(mr.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+t.databaseId.projectId);if(n.get(3)!==t.databaseId.database)throw new vr(mr.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+t.databaseId.database);return new $r(wa(n))}function ya(t,e){return da(t.databaseId,e)}function Aa(t){var e=ga(t);return 4===e.length?Ur.emptyPath():wa(e)}function ba(t){return new Ur(["projects",t.databaseId.projectId,"databases",t.databaseId.database]).canonicalString()}function wa(t){return Tr(t.length>4&&"documents"===t.get(4)),t.popFirst(5)}function _a(t,e,n){return{name:ma(t,e),fields:n.toProto().mapValue.fields}}function Ia(t,e,n){var r=va(t,e.name),i=pa(e.updateTime),o=new pi({mapValue:{fields:e.fields}}),a=gi.newFoundDocument(r,i,o);return n&&a.setHasCommittedMutations(),n?a.setHasCommittedMutations():a}function Ea(t,e){var n;if(e instanceof To)n={update:_a(t,e.key,e.value)};else if(e instanceof Oo)n={delete:ma(t,e.key)};else if(e instanceof Co)n={update:_a(t,e.key,e.data),updateMask:Ua(e.fieldMask)};else{if(!(e instanceof Bo))return Er();n={verify:ma(t,e.key)}}return e.fieldTransforms.length>0&&(n.updateTransforms=e.fieldTransforms.map((function(t){return function(t,e){var n=e.transform;if(n instanceof ao)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof so)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof co)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof lo)return{fieldPath:e.field.canonicalString(),increment:n.A};throw Er()}(0,t)}))),e.precondition.isNone||(n.currentDocument=function(t,e){return void 0!==e.updateTime?{updateTime:fa(t,e.updateTime)}:void 0!==e.exists?{exists:e.exists}:Er()}(t,e.precondition)),n}function Ta(t,e){var n=e.currentDocument?function(t){return void 0!==t.updateTime?vo.updateTime(pa(t.updateTime)):void 0!==t.exists?vo.exists(t.exists):vo.none()}(e.currentDocument):vo.none(),r=e.updateTransforms?e.updateTransforms.map((function(e){return function(t,e){var n=null;if("setToServerValue"in e)Tr("REQUEST_TIME"===e.setToServerValue),n=new ao;else if("appendMissingElements"in e){var r=e.appendMissingElements.values||[];n=new so(r)}else if("removeAllFromArray"in e){var i=e.removeAllFromArray.values||[];n=new co(i)}else"increment"in e?n=new lo(t,e.increment):Er();var o=Qr.fromServerFormat(e.fieldPath);return new go(o,n)}(t,e)})):[];if(e.update){e.update.name;var i=va(t,e.update.name),o=new pi({mapValue:{fields:e.update.fields}});if(e.updateMask){var a=function(t){var e=t.fieldPaths||[];return new jr(e.map((function(t){return Qr.fromServerFormat(t)})))}(e.updateMask);return new Co(i,o,a,n,r)}return new To(i,o,n,r)}if(e.delete){var s=va(t,e.delete);return new Oo(s,n)}if(e.verify){var u=va(t,e.verify);return new Bo(u,n)}return Er()}function Ca(t,e){return{documents:[ya(t,e.path)]}}function Sa(t,e){var n={structuredQuery:{}},r=e.path;null!==e.collectionGroup?(n.parent=ya(t,r),n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(n.parent=ya(t,r.popLast()),n.structuredQuery.from=[{collectionId:r.lastSegment()}]);var i=function(t){if(0!==t.length){var e=t.map((function(t){return function(t){if("=="===t.op){if(li(t.value))return{unaryFilter:{field:Na(t.field),op:"IS_NAN"}};if(hi(t.value))return{unaryFilter:{field:Na(t.field),op:"IS_NULL"}}}else if("!="===t.op){if(li(t.value))return{unaryFilter:{field:Na(t.field),op:"IS_NOT_NAN"}};if(hi(t.value))return{unaryFilter:{field:Na(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Na(t.field),op:Ba(t.op),value:t.value}}}(t)}));return 1===e.length?e[0]:{compositeFilter:{op:"AND",filters:e}}}}(e.filters);i&&(n.structuredQuery.where=i);var o=function(t){if(0!==t.length)return t.map((function(t){return function(t){return{field:Na(t.field),direction:Oa(t.dir)}}(t)}))}(e.orderBy);o&&(n.structuredQuery.orderBy=o);var a=function(t,e){return t.I||Jr(e)?e:{value:e}}(t,e.limit);return null!==a&&(n.structuredQuery.limit=a),e.startAt&&(n.structuredQuery.startAt=ka(e.startAt)),e.endAt&&(n.structuredQuery.endAt=ka(e.endAt)),n}function xa(t){var e=Aa(t.parent),n=t.structuredQuery,r=n.from?n.from.length:0,i=null;if(r>0){Tr(1===r);var o=n.from[0];o.allDescendants?i=o.collectionId:e=e.child(o.collectionId)}var a=[];n.where&&(a=Da(n.where));var s=[];n.orderBy&&(s=n.orderBy.map((function(t){return function(t){return new Oi(Pa(t.field),function(t){switch(t){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(t.direction))}(t)})));var u=null;n.limit&&(u=function(t){var e;return Jr(e="object"==typeof t?t.value:t)?null:e}(n.limit));var c=null;n.startAt&&(c=Ra(n.startAt));var h=null;return n.endAt&&(h=Ra(n.endAt)),Li(e,i,s,a,u,"F",c,h)}function Da(t){return t?void 0!==t.unaryFilter?[La(t)]:void 0!==t.fieldFilter?[Ma(t)]:void 0!==t.compositeFilter?t.compositeFilter.filters.map((function(t){return Da(t)})).reduce((function(t,e){return t.concat(e)})):Er():[]}function ka(t){return{before:t.before,values:t.position}}function Ra(t){var e=!!t.before,n=t.values||[];return new ki(n,e)}function Oa(t){return sa[t]}function Ba(t){return ua[t]}function Na(t){return{fieldPath:t.canonicalString()}}function Pa(t){return Qr.fromServerFormat(t.fieldPath)}function Ma(t){return wi.create(Pa(t.fieldFilter.field),function(t){switch(t){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return Er()}}(t.fieldFilter.op),t.fieldFilter.value)}function La(t){switch(t.unaryFilter.op){case"IS_NAN":var e=Pa(t.unaryFilter.field);return wi.create(e,"==",{doubleValue:NaN});case"IS_NULL":var n=Pa(t.unaryFilter.field);return wi.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":var r=Pa(t.unaryFilter.field);return wi.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":var i=Pa(t.unaryFilter.field);return wi.create(i,"!=",{nullValue:"NULL_VALUE"});default:return Er()}}function Ua(t){var e=[];return t.fields.forEach((function(t){return e.push(t.canonicalString())})),{fieldPaths:e}}function Fa(t){return t.length>=4&&"projects"===t.get(0)&&"databases"===t.get(2)}function Qa(t){for(var e="",n=0;n<t.length;n++)e.length>0&&(e=qa(e)),e=ja(t.get(n),e);return qa(e)}function ja(t,e){for(var n=e,r=t.length,i=0;i<r;i++){var o=t.charAt(i);switch(o){case"\0":n+="";break;case"":n+="";break;default:n+=o}}return n}function qa(t){return t+""}function Ga(t){var e=t.length;if(Tr(e>=2),2===e)return Tr(""===t.charAt(0)&&""===t.charAt(1)),Ur.emptyPath();for(var n=e-2,r=[],i="",o=0;o<e;){var a=t.indexOf("",o);switch((a<0||a>n)&&Er(),t.charAt(a+1)){case"":var s=t.substring(o,a),u=void 0;0===i.length?u=s:(u=i+=s,i=""),r.push(u);break;case"":i+=t.substring(o,a),i+="\0";break;case"":i+=t.substring(o,a+1);break;default:Er()}o=a+2}return new Ur(r)}var Va=function(t,e){this.seconds=t,this.nanoseconds=e},za=function(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n};za.store="owner",za.key="owner";var Ha=function(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n};Ha.store="mutationQueues",Ha.keyPath="userId";var Ka=function(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i};Ka.store="mutations",Ka.keyPath="batchId",Ka.userMutationsIndex="userMutationsIndex",Ka.userMutationsKeyPath=["userId","batchId"];var Wa=function(){function t(){}return t.prefixForUser=function(t){return[t]},t.prefixForPath=function(t,e){return[t,Qa(e)]},t.key=function(t,e,n){return[t,Qa(e),n]},t}();Wa.store="documentMutations",Wa.PLACEHOLDER=new Wa;var Ya=function(t,e){this.path=t,this.readTime=e},Ja=function(t,e){this.path=t,this.version=e},Xa=function(t,e,n,r,i,o){this.unknownDocument=t,this.noDocument=e,this.document=n,this.hasCommittedMutations=r,this.readTime=i,this.parentPath=o};Xa.store="remoteDocuments",Xa.readTimeIndex="readTimeIndex",Xa.readTimeIndexPath="readTime",Xa.collectionReadTimeIndex="collectionReadTimeIndex",Xa.collectionReadTimeIndexPath=["parentPath","readTime"];var Za=function(t){this.byteSize=t};Za.store="remoteDocumentGlobal",Za.key="remoteDocumentGlobalKey";var $a=function(t,e,n,r,i,o,a){this.targetId=t,this.canonicalId=e,this.readTime=n,this.resumeToken=r,this.lastListenSequenceNumber=i,this.lastLimboFreeSnapshotVersion=o,this.query=a};$a.store="targets",$a.keyPath="targetId",$a.queryTargetsIndexName="queryTargetsIndex",$a.queryTargetsKeyPath=["canonicalId","targetId"];var ts=function(t,e,n){this.targetId=t,this.path=e,this.sequenceNumber=n};ts.store="targetDocuments",ts.keyPath=["targetId","path"],ts.documentTargetsIndex="documentTargetsIndex",ts.documentTargetsKeyPath=["path","targetId"];var es=function(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r};es.key="targetGlobalKey",es.store="targetGlobal";var ns=function(t,e){this.collectionId=t,this.parent=e};ns.store="collectionParents",ns.keyPath=["collectionId","parent"];var rs=function(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r};rs.store="clientMetadata",rs.keyPath="clientId";var is=function(t,e,n){this.bundleId=t,this.createTime=e,this.version=n};is.store="bundles",is.keyPath="bundleId";var os=function(t,e,n){this.name=t,this.readTime=e,this.bundledQuery=n};os.store="namedQueries",os.keyPath="name";var as=(0,dr.ev)((0,dr.ev)([],(0,dr.ev)((0,dr.ev)([],(0,dr.ev)((0,dr.ev)([],(0,dr.ev)((0,dr.ev)([],[Ha.store,Ka.store,Wa.store,Xa.store,$a.store,za.store,es.store,ts.store]),[rs.store])),[Za.store])),[ns.store])),[is.store,os.store]),ss="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",us=function(){function t(){this.onCommittedListeners=[]}return t.prototype.addOnCommittedListener=function(t){this.onCommittedListeners.push(t)},t.prototype.raiseOnCommittedEvent=function(){this.onCommittedListeners.forEach((function(t){return t()}))},t}(),cs=function(){var t=this;this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))},hs=function(){function t(t){var e=this;this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t((function(t){e.isDone=!0,e.result=t,e.nextCallback&&e.nextCallback(t)}),(function(t){e.isDone=!0,e.error=t,e.catchCallback&&e.catchCallback(t)}))}return t.prototype.catch=function(t){return this.next(void 0,t)},t.prototype.next=function(e,n){var r=this;return this.callbackAttached&&Er(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(e,this.result):new t((function(t,i){r.nextCallback=function(n){r.wrapSuccess(e,n).next(t,i)},r.catchCallback=function(e){r.wrapFailure(n,e).next(t,i)}}))},t.prototype.toPromise=function(){var t=this;return new Promise((function(e,n){t.next(e,n)}))},t.prototype.wrapUserFunction=function(e){try{var n=e();return n instanceof t?n:t.resolve(n)}catch(e){return t.reject(e)}},t.prototype.wrapSuccess=function(e,n){return e?this.wrapUserFunction((function(){return e(n)})):t.resolve(n)},t.prototype.wrapFailure=function(e,n){return e?this.wrapUserFunction((function(){return e(n)})):t.reject(n)},t.resolve=function(e){return new t((function(t,n){t(e)}))},t.reject=function(e){return new t((function(t,n){n(e)}))},t.waitFor=function(e){return new t((function(t,n){var r=0,i=0,o=!1;e.forEach((function(e){++r,e.next((function(){++i,o&&i===r&&t()}),(function(t){return n(t)}))})),o=!0,i===r&&t()}))},t.or=function(e){for(var n=t.resolve(!1),r=function(e){n=n.next((function(n){return n?t.resolve(n):e()}))},i=0,o=e;i<o.length;i++)r(o[i]);return n},t.forEach=function(t,e){var n=this,r=[];return t.forEach((function(t,i){r.push(e.call(n,t,i))})),this.waitFor(r)},t}(),ls=function(){function t(t,e){var n=this;this.action=t,this.transaction=e,this.aborted=!1,this.ft=new cs,this.transaction.oncomplete=function(){n.ft.resolve()},this.transaction.onabort=function(){e.error?n.ft.reject(new ds(t,e.error)):n.ft.resolve()},this.transaction.onerror=function(e){var r=As(e.target.error);n.ft.reject(new ds(t,r))}}return t.open=function(e,n,r,i){try{return new t(n,e.transaction(i,r))}catch(e){throw new ds(n,e)}},Object.defineProperty(t.prototype,"dt",{get:function(){return this.ft.promise},enumerable:!1,configurable:!0}),t.prototype.abort=function(t){t&&this.ft.reject(t),this.aborted||(br("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())},t.prototype.store=function(t){var e=this.transaction.objectStore(t);return new ms(e)},t}(),fs=function(){function t(e,n,r){this.name=e,this.version=n,this.wt=r,12.2===t._t((0,i.z$)())&&wr("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}return t.delete=function(t){return br("SimpleDb","Removing database:",t),vs(window.indexedDB.deleteDatabase(t)).toPromise()},t.yt=function(){if("undefined"==typeof indexedDB)return!1;if(t.gt())return!0;var e=(0,i.z$)(),n=t._t(e),r=0<n&&n<10,o=t.Et(e),a=0<o&&o<4.5;return!(e.indexOf("MSIE ")>0||e.indexOf("Trident/")>0||e.indexOf("Edge/")>0||r||a)},t.gt=function(){var t;return"undefined"!=typeof process&&"YES"===(null===(t={REACT_APP_BACKEND_V2_GET_URL:"https://json.excalidraw.com/api/v2/",REACT_APP_BACKEND_V2_POST_URL:"https://json.excalidraw.com/api/v2/post/",REACT_APP_LIBRARY_URL:"https://libraries.excalidraw.com",REACT_APP_LIBRARY_BACKEND:"https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries",REACT_APP_PORTAL_URL:"https://portal.excalidraw.com",REACT_APP_WS_SERVER_URL:"http://localhost:5004",REACT_APP_FIREBASE_CONFIG:'{"apiKey":"AIzaSyCyhHWPekCLzLJC-HA2N7Jv1nYk26B55WI","authDomain":"excalidrawpoc.firebaseapp.com","projectId":"excalidrawpoc","storageBucket":"excalidrawpoc.appspot.com","messagingSenderId":"76413934964","appId":"1:76413934964:web:9e18217fe3818a04ed2021"}',REACT_APP_GOOGLE_ANALYTICS_ID:"UA-387204-13",REACT_APP_PLUS_APP:"https://app.excalidraw.com",PKG_NAME:"@apoorvdwi/excalidraw-collab",PKG_VERSION:"0.4.10",IS_EXCALIDRAW_NPM_PACKAGE:!0})||void 0===t?void 0:t.Tt)},t.It=function(t,e){return t.store(e)},t._t=function(t){var e=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=e?e[1].split("_").slice(0,2).join("."):"-1";return Number(n)},t.Et=function(t){var e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)},t.prototype.At=function(t){return(0,dr.mG)(this,void 0,void 0,(function(){var e,n=this;return(0,dr.Jh)(this,(function(r){switch(r.label){case 0:return this.db?[3,2]:(br("SimpleDb","Opening database:",this.name),e=this,[4,new Promise((function(e,r){var i=indexedDB.open(n.name,n.version);i.onsuccess=function(t){var n=t.target.result;e(n)},i.onblocked=function(){r(new ds(t,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},i.onerror=function(e){var n=e.target.error;"VersionError"===n.name?r(new vr(mr.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):r(new ds(t,n))},i.onupgradeneeded=function(t){br("SimpleDb",'Database "'+n.name+'" requires upgrade from version:',t.oldVersion);var e=t.target.result;n.wt.Rt(e,i.transaction,t.oldVersion,n.version).next((function(){br("SimpleDb","Database upgrade to version "+n.version+" complete")}))}}))]);case 1:e.db=r.sent(),r.label=2;case 2:return[2,(this.bt&&(this.db.onversionchange=function(t){return n.bt(t)}),this.db)]}}))}))},t.prototype.vt=function(t){this.bt=t,this.db&&(this.db.onversionchange=function(e){return t(e)})},t.prototype.runTransaction=function(t,e,n,r){return(0,dr.mG)(this,void 0,void 0,(function(){var i,o,a,s,u;return(0,dr.Jh)(this,(function(c){switch(c.label){case 0:i="readonly"===e,o=0,a=function(){var e,a,u,c,h;return(0,dr.Jh)(this,(function(l){switch(l.label){case 0:++o,l.label=1;case 1:return l.trys.push([1,4,,5]),[4,s.At(t)];case 2:return s.db=l.sent(),e=ls.open(s.db,t,i?"readonly":"readwrite",n),a=r(e).catch((function(t){return e.abort(t),hs.reject(t)})).toPromise(),u={},a.catch((function(){})),[4,e.dt];case 3:return[2,(u.value=(l.sent(),a),u)];case 4:return c=l.sent(),h="FirebaseError"!==c.name&&o<3,br("SimpleDb","Transaction failed with error:",c.message,"Retrying:",h),s.close(),h?[3,5]:[2,{value:Promise.reject(c)}];case 5:return[2]}}))},s=this,c.label=1;case 1:return[5,a()];case 2:if("object"==typeof(u=c.sent()))return[2,u.value];c.label=3;case 3:return[3,1];case 4:return[2]}}))}))},t.prototype.close=function(){this.db&&this.db.close(),this.db=void 0},t}(),ps=function(){function t(t){this.Pt=t,this.Vt=!1,this.St=null}return Object.defineProperty(t.prototype,"isDone",{get:function(){return this.Vt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"Dt",{get:function(){return this.St},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cursor",{set:function(t){this.Pt=t},enumerable:!1,configurable:!0}),t.prototype.done=function(){this.Vt=!0},t.prototype.Ct=function(t){this.St=t},t.prototype.delete=function(){return vs(this.Pt.delete())},t}(),ds=function(t){function e(e,n){var r=this;return(r=t.call(this,mr.UNAVAILABLE,"IndexedDB transaction '"+e+"' failed: "+n)||this).name="IndexedDbTransactionError",r}return(0,dr.ZT)(e,t),e}(vr);function gs(t){return"IndexedDbTransactionError"===t.name}var ms=function(){function t(t){this.store=t}return t.prototype.put=function(t,e){var n;return void 0!==e?(br("SimpleDb","PUT",this.store.name,t,e),n=this.store.put(e,t)):(br("SimpleDb","PUT",this.store.name,"<auto-key>",t),n=this.store.put(t)),vs(n)},t.prototype.add=function(t){return br("SimpleDb","ADD",this.store.name,t,t),vs(this.store.add(t))},t.prototype.get=function(t){var e=this;return vs(this.store.get(t)).next((function(n){return void 0===n&&(n=null),br("SimpleDb","GET",e.store.name,t,n),n}))},t.prototype.delete=function(t){return br("SimpleDb","DELETE",this.store.name,t),vs(this.store.delete(t))},t.prototype.count=function(){return br("SimpleDb","COUNT",this.store.name),vs(this.store.count())},t.prototype.Nt=function(t,e){var n=this.cursor(this.options(t,e)),r=[];return this.xt(n,(function(t,e){r.push(e)})).next((function(){return r}))},t.prototype.Ft=function(t,e){br("SimpleDb","DELETE ALL",this.store.name);var n=this.options(t,e);n.kt=!1;var r=this.cursor(n);return this.xt(r,(function(t,e,n){return n.delete()}))},t.prototype.Ot=function(t,e){var n;e?n=t:(n={},e=t);var r=this.cursor(n);return this.xt(r,e)},t.prototype.$t=function(t){var e=this.cursor({});return new hs((function(n,r){e.onerror=function(t){var e=As(t.target.error);r(e)},e.onsuccess=function(e){var r=e.target.result;r?t(r.primaryKey,r.value).next((function(t){t?r.continue():n()})):n()}}))},t.prototype.xt=function(t,e){var n=[];return new hs((function(r,i){t.onerror=function(t){i(t.target.error)},t.onsuccess=function(t){var i=t.target.result;if(i){var o=new ps(i),a=e(i.primaryKey,i.value,o);if(a instanceof hs){var s=a.catch((function(t){return o.done(),hs.reject(t)}));n.push(s)}o.isDone?r():null===o.Dt?i.continue():i.continue(o.Dt)}else r()}})).next((function(){return hs.waitFor(n)}))},t.prototype.options=function(t,e){var n;return void 0!==t&&("string"==typeof t?n=t:e=t),{index:n,range:e}},t.prototype.cursor=function(t){var e="next";if(t.reverse&&(e="prev"),t.index){var n=this.store.index(t.index);return t.kt?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)},t}();function vs(t){return new hs((function(e,n){t.onsuccess=function(t){var n=t.target.result;e(n)},t.onerror=function(t){var e=As(t.target.error);n(e)}}))}var ys=!1;function As(t){var e=fs._t((0,i.z$)());if(e>=12.2&&e<13){var n="An internal error was encountered in the Indexed Database server";if(t.message.indexOf(n)>=0){var r=new vr("internal","IOS_INDEXEDDB_BUG1: IndexedDb has thrown '"+n+"'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.");return ys||(ys=!0,setTimeout((function(){throw r}),0)),r}}return t}var bs=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).Mt=e,r.currentSequenceNumber=n,r}return(0,dr.ZT)(e,t),e}(us);function ws(t,e){var n=Cr(t);return fs.It(n.Mt,e)}var _s=function(){function t(t,e,n,r){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,this.mutations=r}return t.prototype.applyToRemoteDocument=function(t,e){for(var n=e.mutationResults,r=0;r<this.mutations.length;r++){var i=this.mutations[r];i.key.isEqual(t.key)&&bo(i,t,n[r])}},t.prototype.applyToLocalView=function(t){for(var e=0,n=this.baseMutations;e<n.length;e++)(o=n[e]).key.isEqual(t.key)&&wo(o,t,this.localWriteTime);for(var r=0,i=this.mutations;r<i.length;r++){var o;(o=i[r]).key.isEqual(t.key)&&wo(o,t,this.localWriteTime)}},t.prototype.applyToLocalDocumentSet=function(t){var e=this;this.mutations.forEach((function(n){var r=t.get(n.key),i=r;e.applyToLocalView(i),r.isValidDocument()||i.convertToNoDocument(Br.min())}))},t.prototype.keys=function(){return this.mutations.reduce((function(t,e){return t.add(e.key)}),Yo())},t.prototype.isEqual=function(t){return this.batchId===t.batchId&&kr(this.mutations,t.mutations,(function(t,e){return Io(t,e)}))&&kr(this.baseMutations,t.baseMutations,(function(t,e){return Io(t,e)}))},t}(),Is=function(){function t(t,e,n,r){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.docVersions=r}return t.from=function(e,n,r){Tr(e.mutations.length===r.length);for(var i=Ko(),o=e.mutations,a=0;a<o.length;a++)i=i.insert(o[a].key,r[a].version);return new t(e,n,r,i)},t}(),Es=function(){function t(t,e,n,r,i,o,a){void 0===i&&(i=Br.min()),void 0===o&&(o=Br.min()),void 0===a&&(a=qr.EMPTY_BYTE_STRING),this.target=t,this.targetId=e,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=a}return t.prototype.withSequenceNumber=function(e){return new t(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)},t.prototype.withResumeToken=function(e,n){return new t(this.target,this.targetId,this.purpose,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,e)},t.prototype.withLastLimboFreeSnapshotVersion=function(e){return new t(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken)},t}(),Ts=function(t){this.Lt=t};function Cs(t,e){if(e.document)return Ia(t.Lt,e.document,!!e.hasCommittedMutations);if(e.noDocument){var n=$r.fromSegments(e.noDocument.path),r=Rs(e.noDocument.readTime),i=gi.newNoDocument(n,r);return e.hasCommittedMutations?i.setHasCommittedMutations():i}if(e.unknownDocument){var o=$r.fromSegments(e.unknownDocument.path);return r=Rs(e.unknownDocument.version),gi.newUnknownDocument(o,r)}return Er()}function Ss(t,e,n){var r=xs(n),i=e.key.path.popLast().toArray();if(e.isFoundDocument()){var o=function(t,e){return{name:ma(t,e.key),fields:e.data.toProto().mapValue.fields,updateTime:ha(t,e.version.toTimestamp())}}(t.Lt,e),a=e.hasCommittedMutations;return new Xa(null,null,o,a,r,i)}if(e.isNoDocument()){var s=e.key.path.toArray(),u=ks(e.version);return a=e.hasCommittedMutations,new Xa(null,new Ya(s,u),null,a,r,i)}if(e.isUnknownDocument()){var c=e.key.path.toArray(),h=ks(e.version);return new Xa(new Ja(c,h),null,null,!0,r,i)}return Er()}function xs(t){var e=t.toTimestamp();return[e.seconds,e.nanoseconds]}function Ds(t){var e=new Or(t[0],t[1]);return Br.fromTimestamp(e)}function ks(t){var e=t.toTimestamp();return new Va(e.seconds,e.nanoseconds)}function Rs(t){var e=new Or(t.seconds,t.nanoseconds);return Br.fromTimestamp(e)}function Os(t,e){for(var n=(e.baseMutations||[]).map((function(e){return Ta(t.Lt,e)})),r=0;r<e.mutations.length-1;++r){var i=e.mutations[r];if(r+1<e.mutations.length&&void 0!==e.mutations[r+1].transform){var o=e.mutations[r+1];i.updateTransforms=o.transform.fieldTransforms,e.mutations.splice(r+1,1),++r}}var a=e.mutations.map((function(e){return Ta(t.Lt,e)})),s=Or.fromMillis(e.localWriteTimeMs);return new _s(e.batchId,s,n,a)}function Bs(t){var e,n,r=Rs(t.readTime),i=void 0!==t.lastLimboFreeSnapshotVersion?Rs(t.lastLimboFreeSnapshotVersion):Br.min();return void 0!==t.query.documents?(Tr(1===(n=t.query).documents.length),e=zi(Ui(Aa(n.documents[0])))):e=function(t){return zi(xa(t))}(t.query),new Es(e,t.targetId,0,t.lastListenSequenceNumber,r,i,qr.fromBase64String(t.resumeToken))}function Ns(t,e){var n,r=ks(e.snapshotVersion),i=ks(e.lastLimboFreeSnapshotVersion);n=bi(e.target)?Ca(t.Lt,e.target):Sa(t.Lt,e.target);var o=e.resumeToken.toBase64();return new $a(e.targetId,yi(e.target),r,o,e.sequenceNumber,i,n)}function Ps(t){var e=xa({parent:t.parent,structuredQuery:t.structuredQuery});return"LAST"===t.limitType?Hi(e,e.limit,"L"):e}var Ms=function(){function t(){}return t.prototype.getBundleMetadata=function(t,e){return Ls(t).get(e).next((function(t){if(t)return{id:(e=t).bundleId,createTime:Rs(e.createTime),version:e.version};var e}))},t.prototype.saveBundleMetadata=function(t,e){return Ls(t).put({bundleId:(n=e).id,createTime:ks(pa(n.createTime)),version:n.version});var n},t.prototype.getNamedQuery=function(t,e){return Us(t).get(e).next((function(t){if(t)return{name:(e=t).name,query:Ps(e.bundledQuery),readTime:Rs(e.readTime)};var e}))},t.prototype.saveNamedQuery=function(t,e){return Us(t).put(function(t){return{name:t.name,readTime:ks(pa(t.readTime)),bundledQuery:t.bundledQuery}}(e))},t}();function Ls(t){return ws(t,is.store)}function Us(t){return ws(t,os.store)}var Fs=function(){function t(){this.Bt=new Qs}return t.prototype.addToCollectionParentIndex=function(t,e){return this.Bt.add(e),hs.resolve()},t.prototype.getCollectionParents=function(t,e){return hs.resolve(this.Bt.getEntries(e))},t}(),Qs=function(){function t(){this.index={}}return t.prototype.add=function(t){var e=t.lastSegment(),n=t.popLast(),r=this.index[e]||new Qo(Ur.comparator),i=!r.has(n);return this.index[e]=r.add(n),i},t.prototype.has=function(t){var e=t.lastSegment(),n=t.popLast(),r=this.index[e];return r&&r.has(n)},t.prototype.getEntries=function(t){return(this.index[t]||new Qo(Ur.comparator)).toArray()},t}(),js=function(){function t(){this.qt=new Qs}return t.prototype.addToCollectionParentIndex=function(t,e){var n=this;if(!this.qt.has(e)){var r=e.lastSegment(),i=e.popLast();t.addOnCommittedListener((function(){n.qt.add(e)}));var o={collectionId:r,parent:Qa(i)};return qs(t).put(o)}return hs.resolve()},t.prototype.getCollectionParents=function(t,e){var n=[],r=IDBKeyRange.bound([e,""],[Rr(e),""],!1,!0);return qs(t).Nt(r).next((function(t){for(var r=0,i=t;r<i.length;r++){var o=i[r];if(o.collectionId!==e)break;n.push(Ga(o.parent))}return n}))},t}();function qs(t){return ws(t,ns.store)}var Gs={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},Vs=function(){function t(t,e,n){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=e,this.maximumSequenceNumbersToCollect=n}return t.withCacheSize=function(e){return new t(e,t.DEFAULT_COLLECTION_PERCENTILE,t.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)},t}();function zs(t,e,n){var r=t.store(Ka.store),i=t.store(Wa.store),o=[],a=IDBKeyRange.only(n.batchId),s=0,u=r.Ot({range:a},(function(t,e,n){return s++,n.delete()}));o.push(u.next((function(){Tr(1===s)})));for(var c=[],h=0,l=n.mutations;h<l.length;h++){var f=l[h],p=Wa.key(e,f.key.path,n.batchId);o.push(i.delete(p)),c.push(f.key)}return hs.waitFor(o).next((function(){return c}))}function Hs(t){if(!t)return 0;var e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw Er();e=t.noDocument}return JSON.stringify(e).length}Vs.DEFAULT_COLLECTION_PERCENTILE=10,Vs.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Vs.DEFAULT=new Vs(41943040,Vs.DEFAULT_COLLECTION_PERCENTILE,Vs.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Vs.DISABLED=new Vs(-1,0,0);var Ks=function(){function t(t,e,n,r){this.userId=t,this.R=e,this.Ut=n,this.referenceDelegate=r,this.Qt={}}return t.Kt=function(e,n,r,i){return Tr(""!==e.uid),new t(e.isAuthenticated()?e.uid:"",n,r,i)},t.prototype.checkEmpty=function(t){var e=!0,n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return Ys(t).Ot({index:Ka.userMutationsIndex,range:n},(function(t,n,r){e=!1,r.done()})).next((function(){return e}))},t.prototype.addMutationBatch=function(t,e,n,r){var i=this,o=Js(t),a=Ys(t);return a.add({}).next((function(s){Tr("number"==typeof s);for(var u=new _s(s,e,n,r),c=function(t,e,n){var r=n.baseMutations.map((function(e){return Ea(t.Lt,e)})),i=n.mutations.map((function(e){return Ea(t.Lt,e)}));return new Ka(e,n.batchId,n.localWriteTime.toMillis(),r,i)}(i.R,i.userId,u),h=[],l=new Qo((function(t,e){return Dr(t.canonicalString(),e.canonicalString())})),f=0,p=r;f<p.length;f++){var d=p[f],g=Wa.key(i.userId,d.key.path,s);l=l.add(d.key.path.popLast()),h.push(a.put(c)),h.push(o.put(g,Wa.PLACEHOLDER))}return l.forEach((function(e){h.push(i.Ut.addToCollectionParentIndex(t,e))})),t.addOnCommittedListener((function(){i.Qt[s]=u.keys()})),hs.waitFor(h).next((function(){return u}))}))},t.prototype.lookupMutationBatch=function(t,e){var n=this;return Ys(t).get(e).next((function(t){return t?(Tr(t.userId===n.userId),Os(n.R,t)):null}))},t.prototype.jt=function(t,e){var n=this;return this.Qt[e]?hs.resolve(this.Qt[e]):this.lookupMutationBatch(t,e).next((function(t){if(t){var r=t.keys();return n.Qt[e]=r,r}return null}))},t.prototype.getNextMutationBatchAfterBatchId=function(t,e){var n=this,r=e+1,i=IDBKeyRange.lowerBound([this.userId,r]),o=null;return Ys(t).Ot({index:Ka.userMutationsIndex,range:i},(function(t,e,i){e.userId===n.userId&&(Tr(e.batchId>=r),o=Os(n.R,e)),i.done()})).next((function(){return o}))},t.prototype.getHighestUnacknowledgedBatchId=function(t){var e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),n=-1;return Ys(t).Ot({index:Ka.userMutationsIndex,range:e,reverse:!0},(function(t,e,r){n=e.batchId,r.done()})).next((function(){return n}))},t.prototype.getAllMutationBatches=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return Ys(t).Nt(Ka.userMutationsIndex,n).next((function(t){return t.map((function(t){return Os(e.R,t)}))}))},t.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,e){var n=this,r=Wa.prefixForPath(this.userId,e.path),i=IDBKeyRange.lowerBound(r),o=[];return Js(t).Ot({range:i},(function(r,i,a){var s=r[0],u=r[1],c=r[2],h=Ga(u);if(s===n.userId&&e.path.isEqual(h))return Ys(t).get(c).next((function(t){if(!t)throw Er();Tr(t.userId===n.userId),o.push(Os(n.R,t))}));a.done()})).next((function(){return o}))},t.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,e){var n=this,r=new Qo(Dr),i=[];return e.forEach((function(e){var o=Wa.prefixForPath(n.userId,e.path),a=IDBKeyRange.lowerBound(o),s=Js(t).Ot({range:a},(function(t,i,o){var a=t[0],s=t[1],u=t[2],c=Ga(s);a===n.userId&&e.path.isEqual(c)?r=r.add(u):o.done()}));i.push(s)})),hs.waitFor(i).next((function(){return n.Wt(t,r)}))},t.prototype.getAllMutationBatchesAffectingQuery=function(t,e){var n=this,r=e.path,i=r.length+1,o=Wa.prefixForPath(this.userId,r),a=IDBKeyRange.lowerBound(o),s=new Qo(Dr);return Js(t).Ot({range:a},(function(t,e,o){var a=t[0],u=t[1],c=t[2],h=Ga(u);a===n.userId&&r.isPrefixOf(h)?h.length===i&&(s=s.add(c)):o.done()})).next((function(){return n.Wt(t,s)}))},t.prototype.Wt=function(t,e){var n=this,r=[],i=[];return e.forEach((function(e){i.push(Ys(t).get(e).next((function(t){if(null===t)throw Er();Tr(t.userId===n.userId),r.push(Os(n.R,t))})))})),hs.waitFor(i).next((function(){return r}))},t.prototype.removeMutationBatch=function(t,e){var n=this;return zs(t.Mt,this.userId,e).next((function(r){return t.addOnCommittedListener((function(){n.Gt(e.batchId)})),hs.forEach(r,(function(e){return n.referenceDelegate.markPotentiallyOrphaned(t,e)}))}))},t.prototype.Gt=function(t){delete this.Qt[t]},t.prototype.performConsistencyCheck=function(t){var e=this;return this.checkEmpty(t).next((function(n){if(!n)return hs.resolve();var r=IDBKeyRange.lowerBound(Wa.prefixForUser(e.userId)),i=[];return Js(t).Ot({range:r},(function(t,n,r){if(t[0]===e.userId){var o=Ga(t[1]);i.push(o)}else r.done()})).next((function(){Tr(0===i.length)}))}))},t.prototype.containsKey=function(t,e){return Ws(t,this.userId,e)},t.prototype.zt=function(t){var e=this;return Xs(t).get(this.userId).next((function(t){return t||new Ha(e.userId,-1,"")}))},t}();function Ws(t,e,n){var r=Wa.prefixForPath(e,n.path),i=r[1],o=IDBKeyRange.lowerBound(r),a=!1;return Js(t).Ot({range:o,kt:!0},(function(t,n,r){var o=t[0],s=t[1];t[2],o===e&&s===i&&(a=!0),r.done()})).next((function(){return a}))}function Ys(t){return ws(t,Ka.store)}function Js(t){return ws(t,Wa.store)}function Xs(t){return ws(t,Ha.store)}var Zs=function(){function t(t){this.Ht=t}return t.prototype.next=function(){return this.Ht+=2,this.Ht},t.Jt=function(){return new t(0)},t.Yt=function(){return new t(-1)},t}(),$s=function(){function t(t,e){this.referenceDelegate=t,this.R=e}return t.prototype.allocateTargetId=function(t){var e=this;return this.Xt(t).next((function(n){var r=new Zs(n.highestTargetId);return n.highestTargetId=r.next(),e.Zt(t,n).next((function(){return n.highestTargetId}))}))},t.prototype.getLastRemoteSnapshotVersion=function(t){return this.Xt(t).next((function(t){return Br.fromTimestamp(new Or(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))}))},t.prototype.getHighestSequenceNumber=function(t){return this.Xt(t).next((function(t){return t.highestListenSequenceNumber}))},t.prototype.setTargetsMetadata=function(t,e,n){var r=this;return this.Xt(t).next((function(i){return i.highestListenSequenceNumber=e,n&&(i.lastRemoteSnapshotVersion=n.toTimestamp()),e>i.highestListenSequenceNumber&&(i.highestListenSequenceNumber=e),r.Zt(t,i)}))},t.prototype.addTargetData=function(t,e){var n=this;return this.te(t,e).next((function(){return n.Xt(t).next((function(r){return r.targetCount+=1,n.ee(e,r),n.Zt(t,r)}))}))},t.prototype.updateTargetData=function(t,e){return this.te(t,e)},t.prototype.removeTargetData=function(t,e){var n=this;return this.removeMatchingKeysForTargetId(t,e.targetId).next((function(){return tu(t).delete(e.targetId)})).next((function(){return n.Xt(t)})).next((function(e){return Tr(e.targetCount>0),e.targetCount-=1,n.Zt(t,e)}))},t.prototype.removeTargets=function(t,e,n){var r=this,i=0,o=[];return tu(t).Ot((function(a,s){var u=Bs(s);u.sequenceNumber<=e&&null===n.get(u.targetId)&&(i++,o.push(r.removeTargetData(t,u)))})).next((function(){return hs.waitFor(o)})).next((function(){return i}))},t.prototype.forEachTarget=function(t,e){return tu(t).Ot((function(t,n){var r=Bs(n);e(r)}))},t.prototype.Xt=function(t){return eu(t).get(es.key).next((function(t){return Tr(null!==t),t}))},t.prototype.Zt=function(t,e){return eu(t).put(es.key,e)},t.prototype.te=function(t,e){return tu(t).put(Ns(this.R,e))},t.prototype.ee=function(t,e){var n=!1;return t.targetId>e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n},t.prototype.getTargetCount=function(t){return this.Xt(t).next((function(t){return t.targetCount}))},t.prototype.getTargetData=function(t,e){var n=yi(e),r=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]),i=null;return tu(t).Ot({range:r,index:$a.queryTargetsIndexName},(function(t,n,r){var o=Bs(n);Ai(e,o.target)&&(i=o,r.done())})).next((function(){return i}))},t.prototype.addMatchingKeys=function(t,e,n){var r=this,i=[],o=nu(t);return e.forEach((function(e){var a=Qa(e.path);i.push(o.put(new ts(n,a))),i.push(r.referenceDelegate.addReference(t,n,e))})),hs.waitFor(i)},t.prototype.removeMatchingKeys=function(t,e,n){var r=this,i=nu(t);return hs.forEach(e,(function(e){var o=Qa(e.path);return hs.waitFor([i.delete([n,o]),r.referenceDelegate.removeReference(t,n,e)])}))},t.prototype.removeMatchingKeysForTargetId=function(t,e){var n=nu(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)},t.prototype.getMatchingKeysForTargetId=function(t,e){var n=IDBKeyRange.bound([e],[e+1],!1,!0),r=nu(t),i=Yo();return r.Ot({range:n,kt:!0},(function(t,e,n){var r=Ga(t[1]),o=new $r(r);i=i.add(o)})).next((function(){return i}))},t.prototype.containsKey=function(t,e){var n=Qa(e.path),r=IDBKeyRange.bound([n],[Rr(n)],!1,!0),i=0;return nu(t).Ot({index:ts.documentTargetsIndex,kt:!0,range:r},(function(t,e,n){var r=t[0];t[1],0!==r&&(i++,n.done())})).next((function(){return i>0}))},t.prototype.lt=function(t,e){return tu(t).get(e).next((function(t){return t?Bs(t):null}))},t}();function tu(t){return ws(t,$a.store)}function eu(t){return ws(t,es.store)}function nu(t){return ws(t,ts.store)}function ru(t){return(0,dr.mG)(this,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(e){if(t.code!==mr.FAILED_PRECONDITION||t.message!==ss)throw t;return br("LocalStore","Unexpectedly lost primary lease"),[2]}))}))}function iu(t,e){var n=t[0],r=t[1],i=e[0],o=e[1],a=Dr(n,i);return 0===a?Dr(r,o):a}var ou=function(){function t(t){this.ne=t,this.buffer=new Qo(iu),this.se=0}return t.prototype.ie=function(){return++this.se},t.prototype.re=function(t){var e=[t,this.ie()];if(this.buffer.size<this.ne)this.buffer=this.buffer.add(e);else{var n=this.buffer.last();iu(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}},Object.defineProperty(t.prototype,"maxValue",{get:function(){return this.buffer.last()[0]},enumerable:!1,configurable:!0}),t}(),au=function(){function t(t,e){this.garbageCollector=t,this.asyncQueue=e,this.oe=!1,this.ce=null}return t.prototype.start=function(t){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.ue(t)},t.prototype.stop=function(){this.ce&&(this.ce.cancel(),this.ce=null)},Object.defineProperty(t.prototype,"started",{get:function(){return null!==this.ce},enumerable:!1,configurable:!0}),t.prototype.ue=function(t){var e=this,n=this.oe?3e5:6e4;br("LruGarbageCollector","Garbage collection scheduled in "+n+"ms"),this.ce=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",n,(function(){return(0,dr.mG)(e,void 0,void 0,(function(){var e;return(0,dr.Jh)(this,(function(n){switch(n.label){case 0:this.ce=null,this.oe=!0,n.label=1;case 1:return n.trys.push([1,3,,7]),[4,t.collectGarbage(this.garbageCollector)];case 2:return n.sent(),[3,7];case 3:return gs(e=n.sent())?(br("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e),[3,6]):[3,4];case 4:return[4,ru(e)];case 5:n.sent(),n.label=6;case 6:return[3,7];case 7:return[4,this.ue(t)];case 8:return n.sent(),[2]}}))}))}))},t}(),su=function(){function t(t,e){this.ae=t,this.params=e}return t.prototype.calculateTargetCount=function(t,e){return this.ae.he(t).next((function(t){return Math.floor(e/100*t)}))},t.prototype.nthSequenceNumber=function(t,e){var n=this;if(0===e)return hs.resolve(gr.o);var r=new ou(e);return this.ae.forEachTarget(t,(function(t){return r.re(t.sequenceNumber)})).next((function(){return n.ae.le(t,(function(t){return r.re(t)}))})).next((function(){return r.maxValue}))},t.prototype.removeTargets=function(t,e,n){return this.ae.removeTargets(t,e,n)},t.prototype.removeOrphanedDocuments=function(t,e){return this.ae.removeOrphanedDocuments(t,e)},t.prototype.collect=function(t,e){var n=this;return-1===this.params.cacheSizeCollectionThreshold?(br("LruGarbageCollector","Garbage collection skipped; disabled"),hs.resolve(Gs)):this.getCacheSize(t).next((function(r){return r<n.params.cacheSizeCollectionThreshold?(br("LruGarbageCollector","Garbage collection skipped; Cache size "+r+" is lower than threshold "+n.params.cacheSizeCollectionThreshold),Gs):n.fe(t,e)}))},t.prototype.getCacheSize=function(t){return this.ae.getCacheSize(t)},t.prototype.fe=function(t,e){var n,r,i,a,s,u,c,h=this,l=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next((function(e){return e>h.params.maximumSequenceNumbersToCollect?(br("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+h.params.maximumSequenceNumbersToCollect+" from "+e),r=h.params.maximumSequenceNumbersToCollect):r=e,a=Date.now(),h.nthSequenceNumber(t,r)})).next((function(r){return n=r,s=Date.now(),h.removeTargets(t,n,e)})).next((function(e){return i=e,u=Date.now(),h.removeOrphanedDocuments(t,n)})).next((function(t){return c=Date.now(),Ar()<=o.in.DEBUG&&br("LruGarbageCollector","LRU Garbage Collection\n\tCounted targets in "+(a-l)+"ms\n\tDetermined least recently used "+r+" in "+(s-a)+"ms\n\tRemoved "+i+" targets in "+(u-s)+"ms\n\tRemoved "+t+" documents in "+(c-u)+"ms\nTotal Duration: "+(c-l)+"ms"),hs.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:t})}))},t}(),uu=function(){function t(t,e){this.db=t,this.garbageCollector=function(t,e){return new su(t,e)}(this,e)}return t.prototype.he=function(t){var e=this.de(t);return this.db.getTargetCache().getTargetCount(t).next((function(t){return e.next((function(e){return t+e}))}))},t.prototype.de=function(t){var e=0;return this.le(t,(function(t){e++})).next((function(){return e}))},t.prototype.forEachTarget=function(t,e){return this.db.getTargetCache().forEachTarget(t,e)},t.prototype.le=function(t,e){return this.we(t,(function(t,n){return e(n)}))},t.prototype.addReference=function(t,e,n){return cu(t,n)},t.prototype.removeReference=function(t,e,n){return cu(t,n)},t.prototype.removeTargets=function(t,e,n){return this.db.getTargetCache().removeTargets(t,e,n)},t.prototype.markPotentiallyOrphaned=function(t,e){return cu(t,e)},t.prototype._e=function(t,e){return function(t,e){var n=!1;return Xs(t).$t((function(r){return Ws(t,r,e).next((function(t){return t&&(n=!0),hs.resolve(!t)}))})).next((function(){return n}))}(t,e)},t.prototype.removeOrphanedDocuments=function(t,e){var n=this,r=this.db.getRemoteDocumentCache().newChangeBuffer(),i=[],o=0;return this.we(t,(function(a,s){if(s<=e){var u=n._e(t,a).next((function(e){if(!e)return o++,r.getEntry(t,a).next((function(){return r.removeEntry(a),nu(t).delete([0,Qa(a.path)])}))}));i.push(u)}})).next((function(){return hs.waitFor(i)})).next((function(){return r.apply(t)})).next((function(){return o}))},t.prototype.removeTarget=function(t,e){var n=e.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,n)},t.prototype.updateLimboDocument=function(t,e){return cu(t,e)},t.prototype.we=function(t,e){var n,r=nu(t),i=gr.o;return r.Ot({index:ts.documentTargetsIndex},(function(t,r){var o=t[0],a=(t[1],r.path),s=r.sequenceNumber;0===o?(i!==gr.o&&e(new $r(Ga(n)),i),i=s,n=a):i=gr.o})).next((function(){i!==gr.o&&e(new $r(Ga(n)),i)}))},t.prototype.getCacheSize=function(t){return this.db.getRemoteDocumentCache().getSize(t)},t}();function cu(t,e){return nu(t).put(function(t,e){return new ts(0,Qa(t.path),e)}(e,t.currentSequenceNumber))}var hu=function(){function t(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={}}return t.prototype.get=function(t){var e=this.mapKeyFn(t),n=this.inner[e];if(void 0!==n)for(var r=0,i=n;r<i.length;r++){var o=i[r],a=o[0],s=o[1];if(this.equalsFn(a,t))return s}},t.prototype.has=function(t){return void 0!==this.get(t)},t.prototype.set=function(t,e){var n=this.mapKeyFn(t),r=this.inner[n];if(void 0!==r){for(var i=0;i<r.length;i++)if(this.equalsFn(r[i][0],t))return void(r[i]=[t,e]);r.push([t,e])}else this.inner[n]=[[t,e]]},t.prototype.delete=function(t){var e=this.mapKeyFn(t),n=this.inner[e];if(void 0===n)return!1;for(var r=0;r<n.length;r++)if(this.equalsFn(n[r][0],t))return 1===n.length?delete this.inner[e]:n.splice(r,1),!0;return!1},t.prototype.forEach=function(t){Pr(this.inner,(function(e,n){for(var r=0,i=n;r<i.length;r++){var o=i[r],a=o[0],s=o[1];t(a,s)}}))},t.prototype.isEmpty=function(){return Mr(this.inner)},t}(),lu=function(){function t(){this.changes=new hu((function(t){return t.toString()}),(function(t,e){return t.isEqual(e)})),this.changesApplied=!1}return t.prototype.getReadTime=function(t){var e=this.changes.get(t);return e?e.readTime:Br.min()},t.prototype.addEntry=function(t,e){this.assertNotApplied(),this.changes.set(t.key,{document:t,readTime:e})},t.prototype.removeEntry=function(t,e){void 0===e&&(e=null),this.assertNotApplied(),this.changes.set(t,{document:gi.newInvalidDocument(t),readTime:e})},t.prototype.getEntry=function(t,e){this.assertNotApplied();var n=this.changes.get(e);return void 0!==n?hs.resolve(n.document):this.getFromCache(t,e)},t.prototype.getEntries=function(t,e){return this.getAllFromCache(t,e)},t.prototype.apply=function(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)},t.prototype.assertNotApplied=function(){},t}(),fu=function(){function t(t,e){this.R=t,this.Ut=e}return t.prototype.addEntry=function(t,e,n){return gu(t).put(mu(e),n)},t.prototype.removeEntry=function(t,e){var n=gu(t),r=mu(e);return n.delete(r)},t.prototype.updateMetadata=function(t,e){var n=this;return this.getMetadata(t).next((function(r){return r.byteSize+=e,n.me(t,r)}))},t.prototype.getEntry=function(t,e){var n=this;return gu(t).get(mu(e)).next((function(t){return n.ye(e,t)}))},t.prototype.ge=function(t,e){var n=this;return gu(t).get(mu(e)).next((function(t){return{document:n.ye(e,t),size:Hs(t)}}))},t.prototype.getEntries=function(t,e){var n=this,r=Go();return this.pe(t,e,(function(t,e){var i=n.ye(t,e);r=r.insert(t,i)})).next((function(){return r}))},t.prototype.Ee=function(t,e){var n=this,r=Go(),i=new Lo($r.comparator);return this.pe(t,e,(function(t,e){var o=n.ye(t,e);r=r.insert(t,o),i=i.insert(t,Hs(e))})).next((function(){return{documents:r,Te:i}}))},t.prototype.pe=function(t,e,n){if(e.isEmpty())return hs.resolve();var r=IDBKeyRange.bound(e.first().path.toArray(),e.last().path.toArray()),i=e.getIterator(),o=i.getNext();return gu(t).Ot({range:r},(function(t,e,r){for(var a=$r.fromSegments(t);o&&$r.comparator(o,a)<0;)n(o,null),o=i.getNext();o&&o.isEqual(a)&&(n(o,e),o=i.hasNext()?i.getNext():null),o?r.Ct(o.path.toArray()):r.done()})).next((function(){for(;o;)n(o,null),o=i.hasNext()?i.getNext():null}))},t.prototype.getDocumentsMatchingQuery=function(t,e,n){var r=this,i=Go(),o=e.path.length+1,a={};if(n.isEqual(Br.min())){var s=e.path.toArray();a.range=IDBKeyRange.lowerBound(s)}else{var u=e.path.toArray(),c=xs(n);a.range=IDBKeyRange.lowerBound([u,c],!0),a.index=Xa.collectionReadTimeIndex}return gu(t).Ot(a,(function(t,n,a){if(t.length===o){var s=Cs(r.R,n);e.path.isPrefixOf(s.key.path)?Ji(e,s)&&(i=i.insert(s.key,s)):a.done()}})).next((function(){return i}))},t.prototype.newChangeBuffer=function(t){return new pu(this,!!t&&t.trackRemovals)},t.prototype.getSize=function(t){return this.getMetadata(t).next((function(t){return t.byteSize}))},t.prototype.getMetadata=function(t){return du(t).get(Za.key).next((function(t){return Tr(!!t),t}))},t.prototype.me=function(t,e){return du(t).put(Za.key,e)},t.prototype.ye=function(t,e){if(e){var n=Cs(this.R,e);if(!n.isNoDocument()||!n.version.isEqual(Br.min()))return n}return gi.newInvalidDocument(t)},t}(),pu=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).Ie=e,r.trackRemovals=n,r.Ae=new hu((function(t){return t.toString()}),(function(t,e){return t.isEqual(e)})),r}return(0,dr.ZT)(e,t),e.prototype.applyChanges=function(t){var e=this,n=[],r=0,i=new Qo((function(t,e){return Dr(t.canonicalString(),e.canonicalString())}));return this.changes.forEach((function(o,a){var s=e.Ae.get(o);if(a.document.isValidDocument()){var u=Ss(e.Ie.R,a.document,e.getReadTime(o));i=i.add(o.path.popLast());var c=Hs(u);r+=c-s,n.push(e.Ie.addEntry(t,o,u))}else if(r-=s,e.trackRemovals){var h=Ss(e.Ie.R,gi.newNoDocument(o,Br.min()),e.getReadTime(o));n.push(e.Ie.addEntry(t,o,h))}else n.push(e.Ie.removeEntry(t,o))})),i.forEach((function(r){n.push(e.Ie.Ut.addToCollectionParentIndex(t,r))})),n.push(this.Ie.updateMetadata(t,r)),hs.waitFor(n)},e.prototype.getFromCache=function(t,e){var n=this;return this.Ie.ge(t,e).next((function(t){return n.Ae.set(e,t.size),t.document}))},e.prototype.getAllFromCache=function(t,e){var n=this;return this.Ie.Ee(t,e).next((function(t){var e=t.documents;return t.Te.forEach((function(t,e){n.Ae.set(t,e)})),e}))},e}(lu);function du(t){return ws(t,Za.store)}function gu(t){return ws(t,Xa.store)}function mu(t){return t.path.toArray()}var vu=function(){function t(t){this.R=t}return t.prototype.Rt=function(t,e,n,r){var i=this;Tr(n<r&&n>=0&&r<=11);var o=new ls("createOrUpgrade",e);n<1&&r>=1&&(function(t){t.createObjectStore(za.store)}(t),function(t){t.createObjectStore(Ha.store,{keyPath:Ha.keyPath}),t.createObjectStore(Ka.store,{keyPath:Ka.keyPath,autoIncrement:!0}).createIndex(Ka.userMutationsIndex,Ka.userMutationsKeyPath,{unique:!0}),t.createObjectStore(Wa.store)}(t),yu(t),function(t){t.createObjectStore(Xa.store)}(t));var a=hs.resolve();return n<3&&r>=3&&(0!==n&&(function(t){t.deleteObjectStore(ts.store),t.deleteObjectStore($a.store),t.deleteObjectStore(es.store)}(t),yu(t)),a=a.next((function(){return function(t){var e=t.store(es.store),n=new es(0,0,Br.min().toTimestamp(),0);return e.put(es.key,n)}(o)}))),n<4&&r>=4&&(0!==n&&(a=a.next((function(){return function(t,e){return e.store(Ka.store).Nt().next((function(n){t.deleteObjectStore(Ka.store),t.createObjectStore(Ka.store,{keyPath:Ka.keyPath,autoIncrement:!0}).createIndex(Ka.userMutationsIndex,Ka.userMutationsKeyPath,{unique:!0});var r=e.store(Ka.store),i=n.map((function(t){return r.put(t)}));return hs.waitFor(i)}))}(t,o)}))),a=a.next((function(){!function(t){t.createObjectStore(rs.store,{keyPath:rs.keyPath})}(t)}))),n<5&&r>=5&&(a=a.next((function(){return i.Re(o)}))),n<6&&r>=6&&(a=a.next((function(){return function(t){t.createObjectStore(Za.store)}(t),i.be(o)}))),n<7&&r>=7&&(a=a.next((function(){return i.ve(o)}))),n<8&&r>=8&&(a=a.next((function(){return i.Pe(t,o)}))),n<9&&r>=9&&(a=a.next((function(){!function(t){t.objectStoreNames.contains("remoteDocumentChanges")&&t.deleteObjectStore("remoteDocumentChanges")}(t),function(t){var e=t.objectStore(Xa.store);e.createIndex(Xa.readTimeIndex,Xa.readTimeIndexPath,{unique:!1}),e.createIndex(Xa.collectionReadTimeIndex,Xa.collectionReadTimeIndexPath,{unique:!1})}(e)}))),n<10&&r>=10&&(a=a.next((function(){return i.Ve(o)}))),n<11&&r>=11&&(a=a.next((function(){!function(t){t.createObjectStore(is.store,{keyPath:is.keyPath})}(t),function(t){t.createObjectStore(os.store,{keyPath:os.keyPath})}(t)}))),a},t.prototype.be=function(t){var e=0;return t.store(Xa.store).Ot((function(t,n){e+=Hs(n)})).next((function(){var n=new Za(e);return t.store(Za.store).put(Za.key,n)}))},t.prototype.Re=function(t){var e=this,n=t.store(Ha.store),r=t.store(Ka.store);return n.Nt().next((function(n){return hs.forEach(n,(function(n){var i=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return r.Nt(Ka.userMutationsIndex,i).next((function(r){return hs.forEach(r,(function(r){Tr(r.userId===n.userId);var i=Os(e.R,r);return zs(t,n.userId,i).next((function(){}))}))}))}))}))},t.prototype.ve=function(t){var e=t.store(ts.store),n=t.store(Xa.store);return t.store(es.store).get(es.key).next((function(t){var r=[];return n.Ot((function(n,i){var o=new Ur(n),a=function(t){return[0,Qa(t)]}(o);r.push(e.get(a).next((function(n){return n?hs.resolve():function(n){return e.put(new ts(0,Qa(n),t.highestListenSequenceNumber))}(o)})))})).next((function(){return hs.waitFor(r)}))}))},t.prototype.Pe=function(t,e){t.createObjectStore(ns.store,{keyPath:ns.keyPath});var n=e.store(ns.store),r=new Qs,i=function(t){if(r.add(t)){var e=t.lastSegment(),i=t.popLast();return n.put({collectionId:e,parent:Qa(i)})}};return e.store(Xa.store).Ot({kt:!0},(function(t,e){var n=new Ur(t);return i(n.popLast())})).next((function(){return e.store(Wa.store).Ot({kt:!0},(function(t,e){t[0];var n=t[1],r=(t[2],Ga(n));return i(r.popLast())}))}))},t.prototype.Ve=function(t){var e=this,n=t.store($a.store);return n.Ot((function(t,r){var i=Bs(r),o=Ns(e.R,i);return n.put(o)}))},t}();function yu(t){t.createObjectStore(ts.store,{keyPath:ts.keyPath}).createIndex(ts.documentTargetsIndex,ts.documentTargetsKeyPath,{unique:!0}),t.createObjectStore($a.store,{keyPath:$a.keyPath}).createIndex($a.queryTargetsIndexName,$a.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(es.store)}var Au="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.",bu=function(){function t(e,n,r,i,o,a,s,u,c,h){if(this.allowTabSynchronization=e,this.persistenceKey=n,this.clientId=r,this.Se=o,this.window=a,this.document=s,this.De=c,this.Ce=h,this.Ne=null,this.xe=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Fe=null,this.inForeground=!1,this.ke=null,this.Oe=null,this.$e=Number.NEGATIVE_INFINITY,this.Me=function(t){return Promise.resolve()},!t.yt())throw new vr(mr.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new uu(this,i),this.Le=n+"main",this.R=new Ts(u),this.Be=new fs(this.Le,11,new vu(this.R)),this.qe=new $s(this.referenceDelegate,this.R),this.Ut=new js,this.Ue=function(t,e){return new fu(t,e)}(this.R,this.Ut),this.Qe=new Ms,this.window&&this.window.localStorage?this.Ke=this.window.localStorage:(this.Ke=null,!1===h&&wr("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}return t.prototype.start=function(){var t=this;return this.je().then((function(){if(!t.isPrimary&&!t.allowTabSynchronization)throw new vr(mr.FAILED_PRECONDITION,Au);return t.We(),t.Ge(),t.ze(),t.runTransaction("getHighestListenSequenceNumber","readonly",(function(e){return t.qe.getHighestSequenceNumber(e)}))})).then((function(e){t.Ne=new gr(e,t.De)})).then((function(){t.xe=!0})).catch((function(e){return t.Be&&t.Be.close(),Promise.reject(e)}))},t.prototype.He=function(t){var e=this;return this.Me=function(n){return(0,dr.mG)(e,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(e){return this.started?[2,t(n)]:[2]}))}))},t(this.isPrimary)},t.prototype.setDatabaseDeletedListener=function(t){var e=this;this.Be.vt((function(n){return(0,dr.mG)(e,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(e){switch(e.label){case 0:return null===n.newVersion?[4,t()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))}))},t.prototype.setNetworkEnabled=function(t){var e=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.Se.enqueueAndForget((function(){return(0,dr.mG)(e,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(t){switch(t.label){case 0:return this.started?[4,this.je()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))})))},t.prototype.je=function(){var t=this;return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",(function(e){return _u(e).put(new rs(t.clientId,Date.now(),t.networkEnabled,t.inForeground)).next((function(){if(t.isPrimary)return t.Je(e).next((function(e){e||(t.isPrimary=!1,t.Se.enqueueRetryable((function(){return t.Me(!1)})))}))})).next((function(){return t.Ye(e)})).next((function(n){return t.isPrimary&&!n?t.Xe(e).next((function(){return!1})):!!n&&t.Ze(e).next((function(){return!0}))}))})).catch((function(e){if(gs(e))return br("IndexedDbPersistence","Failed to extend owner lease: ",e),t.isPrimary;if(!t.allowTabSynchronization)throw e;return br("IndexedDbPersistence","Releasing owner lease after error during lease refresh",e),!1})).then((function(e){t.isPrimary!==e&&t.Se.enqueueRetryable((function(){return t.Me(e)})),t.isPrimary=e}))},t.prototype.Je=function(t){var e=this;return wu(t).get(za.key).next((function(t){return hs.resolve(e.tn(t))}))},t.prototype.en=function(t){return _u(t).delete(this.clientId)},t.prototype.nn=function(){return(0,dr.mG)(this,void 0,void 0,(function(){var t,e,n,r,i=this;return(0,dr.Jh)(this,(function(o){switch(o.label){case 0:return!this.isPrimary||this.sn(this.$e,18e5)?[3,2]:(this.$e=Date.now(),[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",(function(t){var e=ws(t,rs.store);return e.Nt().next((function(t){var n=i.rn(t,18e5),r=t.filter((function(t){return-1===n.indexOf(t)}));return hs.forEach(r,(function(t){return e.delete(t.clientId)})).next((function(){return r}))}))})).catch((function(){return[]}))]);case 1:if(t=o.sent(),this.Ke)for(e=0,n=t;e<n.length;e++)r=n[e],this.Ke.removeItem(this.on(r.clientId));o.label=2;case 2:return[2]}}))}))},t.prototype.ze=function(){var t=this;this.Oe=this.Se.enqueueAfterDelay("client_metadata_refresh",4e3,(function(){return t.je().then((function(){return t.nn()})).then((function(){return t.ze()}))}))},t.prototype.tn=function(t){return!!t&&t.ownerId===this.clientId},t.prototype.Ye=function(t){var e=this;return this.Ce?hs.resolve(!0):wu(t).get(za.key).next((function(n){if(null!==n&&e.sn(n.leaseTimestampMs,5e3)&&!e.cn(n.ownerId)){if(e.tn(n)&&e.networkEnabled)return!0;if(!e.tn(n)){if(!n.allowTabSynchronization)throw new vr(mr.FAILED_PRECONDITION,Au);return!1}}return!(!e.networkEnabled||!e.inForeground)||_u(t).Nt().next((function(t){return void 0===e.rn(t,5e3).find((function(t){if(e.clientId!==t.clientId){var n=!e.networkEnabled&&t.networkEnabled,r=!e.inForeground&&t.inForeground,i=e.networkEnabled===t.networkEnabled;if(n||r&&i)return!0}return!1}))}))})).next((function(t){return e.isPrimary!==t&&br("IndexedDbPersistence","Client "+(t?"is":"is not")+" eligible for a primary lease."),t}))},t.prototype.shutdown=function(){return(0,dr.mG)(this,void 0,void 0,(function(){var t=this;return(0,dr.Jh)(this,(function(e){switch(e.label){case 0:return this.xe=!1,this.un(),this.Oe&&(this.Oe.cancel(),this.Oe=null),this.an(),this.hn(),[4,this.Be.runTransaction("shutdown","readwrite",[za.store,rs.store],(function(e){var n=new bs(e,gr.o);return t.Xe(n).next((function(){return t.en(n)}))}))];case 1:return e.sent(),this.Be.close(),this.ln(),[2]}}))}))},t.prototype.rn=function(t,e){var n=this;return t.filter((function(t){return n.sn(t.updateTimeMs,e)&&!n.cn(t.clientId)}))},t.prototype.fn=function(){var t=this;return this.runTransaction("getActiveClients","readonly",(function(e){return _u(e).Nt().next((function(e){return t.rn(e,18e5).map((function(t){return t.clientId}))}))}))},Object.defineProperty(t.prototype,"started",{get:function(){return this.xe},enumerable:!1,configurable:!0}),t.prototype.getMutationQueue=function(t){return Ks.Kt(t,this.R,this.Ut,this.referenceDelegate)},t.prototype.getTargetCache=function(){return this.qe},t.prototype.getRemoteDocumentCache=function(){return this.Ue},t.prototype.getIndexManager=function(){return this.Ut},t.prototype.getBundleCache=function(){return this.Qe},t.prototype.runTransaction=function(t,e,n){var r=this;br("IndexedDbPersistence","Starting transaction:",t);var i,o="readonly"===e?"readonly":"readwrite";return this.Be.runTransaction(t,o,as,(function(o){return i=new bs(o,r.Ne?r.Ne.next():gr.o),"readwrite-primary"===e?r.Je(i).next((function(t){return!!t||r.Ye(i)})).next((function(e){if(!e)throw wr("Failed to obtain primary lease for action '"+t+"'."),r.isPrimary=!1,r.Se.enqueueRetryable((function(){return r.Me(!1)})),new vr(mr.FAILED_PRECONDITION,ss);return n(i)})).next((function(t){return r.Ze(i).next((function(){return t}))})):r.dn(i).next((function(){return n(i)}))})).then((function(t){return i.raiseOnCommittedEvent(),t}))},t.prototype.dn=function(t){var e=this;return wu(t).get(za.key).next((function(t){if(null!==t&&e.sn(t.leaseTimestampMs,5e3)&&!e.cn(t.ownerId)&&!e.tn(t)&&!(e.Ce||e.allowTabSynchronization&&t.allowTabSynchronization))throw new vr(mr.FAILED_PRECONDITION,Au)}))},t.prototype.Ze=function(t){var e=new za(this.clientId,this.allowTabSynchronization,Date.now());return wu(t).put(za.key,e)},t.yt=function(){return fs.yt()},t.prototype.Xe=function(t){var e=this,n=wu(t);return n.get(za.key).next((function(t){return e.tn(t)?(br("IndexedDbPersistence","Releasing primary lease."),n.delete(za.key)):hs.resolve()}))},t.prototype.sn=function(t,e){var n=Date.now();return!(t<n-e||t>n&&(wr("Detected an update time that is in the future: "+t+" > "+n),1))},t.prototype.We=function(){var t=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this.ke=function(){t.Se.enqueueAndForget((function(){return t.inForeground="visible"===t.document.visibilityState,t.je()}))},this.document.addEventListener("visibilitychange",this.ke),this.inForeground="visible"===this.document.visibilityState)},t.prototype.an=function(){this.ke&&(this.document.removeEventListener("visibilitychange",this.ke),this.ke=null)},t.prototype.Ge=function(){var t,e=this;"function"==typeof(null===(t=this.window)||void 0===t?void 0:t.addEventListener)&&(this.Fe=function(){e.un(),e.Se.enqueueAndForget((function(){return e.shutdown()}))},this.window.addEventListener("unload",this.Fe))},t.prototype.hn=function(){this.Fe&&(this.window.removeEventListener("unload",this.Fe),this.Fe=null)},t.prototype.cn=function(t){var e;try{var n=null!==(null===(e=this.Ke)||void 0===e?void 0:e.getItem(this.on(t)));return br("IndexedDbPersistence","Client '"+t+"' "+(n?"is":"is not")+" zombied in LocalStorage"),n}catch(t){return wr("IndexedDbPersistence","Failed to get zombied client id.",t),!1}},t.prototype.un=function(){if(this.Ke)try{this.Ke.setItem(this.on(this.clientId),String(Date.now()))}catch(t){wr("Failed to set zombie client id.",t)}},t.prototype.ln=function(){if(this.Ke)try{this.Ke.removeItem(this.on(this.clientId))}catch(t){}},t.prototype.on=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},t}();function wu(t){return ws(t,za.store)}function _u(t){return ws(t,rs.store)}function Iu(t,e){var n=t.projectId;return t.isDefaultDatabase||(n+="."+t.database),"firestore/"+e+"/"+n+"/"}var Eu=function(t,e){this.progress=t,this.wn=e},Tu=function(){function t(t,e,n){this.Ue=t,this._n=e,this.Ut=n}return t.prototype.mn=function(t,e){var n=this;return this._n.getAllMutationBatchesAffectingDocumentKey(t,e).next((function(r){return n.yn(t,e,r)}))},t.prototype.yn=function(t,e,n){return this.Ue.getEntry(t,e).next((function(t){for(var e=0,r=n;e<r.length;e++)r[e].applyToLocalView(t);return t}))},t.prototype.gn=function(t,e){t.forEach((function(t,n){for(var r=0,i=e;r<i.length;r++)i[r].applyToLocalView(n)}))},t.prototype.pn=function(t,e){var n=this;return this.Ue.getEntries(t,e).next((function(e){return n.En(t,e).next((function(){return e}))}))},t.prototype.En=function(t,e){var n=this;return this._n.getAllMutationBatchesAffectingDocumentKeys(t,e).next((function(t){return n.gn(e,t)}))},t.prototype.getDocumentsMatchingQuery=function(t,e,n){return function(t){return $r.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}(e)?this.Tn(t,e.path):Gi(e)?this.In(t,e,n):this.An(t,e,n)},t.prototype.Tn=function(t,e){return this.mn(t,new $r(e)).next((function(t){var e=zo();return t.isFoundDocument()&&(e=e.insert(t.key,t)),e}))},t.prototype.In=function(t,e,n){var r=this,i=e.collectionGroup,o=zo();return this.Ut.getCollectionParents(t,i).next((function(a){return hs.forEach(a,(function(a){var s=function(t,e){return new Mi(e,null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(e,a.child(i));return r.An(t,s,n).next((function(t){t.forEach((function(t,e){o=o.insert(t,e)}))}))})).next((function(){return o}))}))},t.prototype.An=function(t,e,n){var r,i,o=this;return this.Ue.getDocumentsMatchingQuery(t,e,n).next((function(n){return r=n,o._n.getAllMutationBatchesAffectingQuery(t,e)})).next((function(e){return i=e,o.Rn(t,i,r).next((function(t){r=t;for(var e=0,n=i;e<n.length;e++)for(var o=n[e],a=0,s=o.mutations;a<s.length;a++){var u=s[a],c=u.key,h=r.get(c);null==h&&(h=gi.newInvalidDocument(c),r=r.insert(c,h)),wo(u,h,o.localWriteTime),h.isFoundDocument()||(r=r.remove(c))}}))})).next((function(){return r.forEach((function(t,n){Ji(e,n)||(r=r.remove(t))})),r}))},t.prototype.Rn=function(t,e,n){for(var r=Yo(),i=0,o=e;i<o.length;i++)for(var a=0,s=o[i].mutations;a<s.length;a++){var u=s[a];u instanceof Co&&null===n.get(u.key)&&(r=r.add(u.key))}var c=n;return this.Ue.getEntries(t,r).next((function(t){return t.forEach((function(t,e){e.isFoundDocument()&&(c=c.insert(t,e))})),c}))},t}(),Cu=function(){function t(t,e,n,r){this.targetId=t,this.fromCache=e,this.bn=n,this.vn=r}return t.Pn=function(e,n){for(var r=Yo(),i=Yo(),o=0,a=n.docChanges;o<a.length;o++){var s=a[o];switch(s.type){case 0:r=r.add(s.doc.key);break;case 1:i=i.add(s.doc.key)}}return new t(e,n.fromCache,r,i)},t}(),Su=function(){function t(){}return t.prototype.Vn=function(t){this.Sn=t},t.prototype.getDocumentsMatchingQuery=function(t,e,n,r){var i=this;return function(t){return 0===t.filters.length&&null===t.limit&&null==t.startAt&&null==t.endAt&&(0===t.explicitOrderBy.length||1===t.explicitOrderBy.length&&t.explicitOrderBy[0].field.isKeyField())}(e)||n.isEqual(Br.min())?this.Dn(t,e):this.Sn.pn(t,r).next((function(a){var s=i.Cn(e,a);return(Fi(e)||Qi(e))&&i.Nn(e.limitType,s,r,n)?i.Dn(t,e):(Ar()<=o.in.DEBUG&&br("QueryEngine","Re-using previous result from %s to execute query: %s",n.toString(),Yi(e)),i.Sn.getDocumentsMatchingQuery(t,e,n).next((function(t){return s.forEach((function(e){t=t.insert(e.key,e)})),t})))}))},t.prototype.Cn=function(t,e){var n=new Qo(Xi(t));return e.forEach((function(e,r){Ji(t,r)&&(n=n.add(r))})),n},t.prototype.Nn=function(t,e,n,r){if(n.size!==e.size)return!0;var i="F"===t?e.last():e.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)},t.prototype.Dn=function(t,e){return Ar()<=o.in.DEBUG&&br("QueryEngine","Using full collection scan to execute query:",Yi(e)),this.Sn.getDocumentsMatchingQuery(t,e,Br.min())},t}(),xu=function(){function t(t,e,n,r){this.persistence=t,this.xn=e,this.R=r,this.Fn=new Lo(Dr),this.kn=new hu((function(t){return yi(t)}),Ai),this.On=Br.min(),this._n=t.getMutationQueue(n),this.$n=t.getRemoteDocumentCache(),this.qe=t.getTargetCache(),this.Mn=new Tu(this.$n,this._n,this.persistence.getIndexManager()),this.Qe=t.getBundleCache(),this.xn.Vn(this.Mn)}return t.prototype.collectGarbage=function(t){var e=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary",(function(n){return t.collect(n,e.Fn)}))},t}();function Du(t,e,n,r){return new xu(t,e,n,r)}function ku(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r,i,o;return(0,dr.Jh)(this,(function(a){switch(a.label){case 0:return n=Cr(t),r=n._n,i=n.Mn,[4,n.persistence.runTransaction("Handle user change","readonly",(function(t){var o;return n._n.getAllMutationBatches(t).next((function(a){return o=a,r=n.persistence.getMutationQueue(e),i=new Tu(n.$n,r,n.persistence.getIndexManager()),r.getAllMutationBatches(t)})).next((function(e){for(var n=[],r=[],a=Yo(),s=0,u=o;s<u.length;s++){var c=u[s];n.push(c.batchId);for(var h=0,l=c.mutations;h<l.length;h++){var f=l[h];a=a.add(f.key)}}for(var p=0,d=e;p<d.length;p++){var g=d[p];r.push(g.batchId);for(var m=0,v=g.mutations;m<v.length;m++){var y=v[m];a=a.add(y.key)}}return i.pn(t,a).next((function(t){return{Ln:t,removedBatchIds:n,addedBatchIds:r}}))}))}))];case 1:return o=a.sent(),[2,(n._n=r,n.Mn=i,n.xn.Vn(n.Mn),o)]}}))}))}function Ru(t,e){var n=Cr(t);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(function(t){var r=e.batch.keys(),i=n.$n.newChangeBuffer({trackRemovals:!0});return function(t,e,n,r){var i=n.batch,o=i.keys(),a=hs.resolve();return o.forEach((function(t){a=a.next((function(){return r.getEntry(e,t)})).next((function(e){var o=n.docVersions.get(t);Tr(null!==o),e.version.compareTo(o)<0&&(i.applyToRemoteDocument(e,n),e.isValidDocument()&&r.addEntry(e,n.commitVersion))}))})),a.next((function(){return t._n.removeMutationBatch(e,i)}))}(n,t,e,i).next((function(){return i.apply(t)})).next((function(){return n._n.performConsistencyCheck(t)})).next((function(){return n.Mn.pn(t,r)}))}))}function Ou(t){var e=Cr(t);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(function(t){return e.qe.getLastRemoteSnapshotVersion(t)}))}function Bu(t,e){var n=Cr(t),r=e.snapshotVersion,i=n.Fn;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(function(t){var o=n.$n.newChangeBuffer({trackRemovals:!0});i=n.Fn;var a=[];e.targetChanges.forEach((function(e,o){var s=i.get(o);if(s){a.push(n.qe.removeMatchingKeys(t,e.removedDocuments,o).next((function(){return n.qe.addMatchingKeys(t,e.addedDocuments,o)})));var u=e.resumeToken;if(u.approximateByteSize()>0){var c=s.withResumeToken(u,r).withSequenceNumber(t.currentSequenceNumber);i=i.insert(o,c),function(t,e,n){return Tr(e.resumeToken.approximateByteSize()>0),0===t.resumeToken.approximateByteSize()||e.snapshotVersion.toMicroseconds()-t.snapshotVersion.toMicroseconds()>=3e8||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0}(s,c,e)&&a.push(n.qe.updateTargetData(t,c))}}}));var s=Go();if(e.documentUpdates.forEach((function(r,i){e.resolvedLimboDocuments.has(r)&&a.push(n.persistence.referenceDelegate.updateLimboDocument(t,r))})),a.push(Nu(t,o,e.documentUpdates,r,void 0).next((function(t){s=t}))),!r.isEqual(Br.min())){var u=n.qe.getLastRemoteSnapshotVersion(t).next((function(e){return n.qe.setTargetsMetadata(t,t.currentSequenceNumber,r)}));a.push(u)}return hs.waitFor(a).next((function(){return o.apply(t)})).next((function(){return n.Mn.En(t,s)})).next((function(){return s}))})).then((function(t){return n.Fn=i,t}))}function Nu(t,e,n,r,i){var o=Yo();return n.forEach((function(t){return o=o.add(t)})),e.getEntries(t,o).next((function(t){var o=Go();return n.forEach((function(n,a){var s=t.get(n),u=(null==i?void 0:i.get(n))||r;a.isNoDocument()&&a.version.isEqual(Br.min())?(e.removeEntry(n,u),o=o.insert(n,a)):!s.isValidDocument()||a.version.compareTo(s.version)>0||0===a.version.compareTo(s.version)&&s.hasPendingWrites?(e.addEntry(a,u),o=o.insert(n,a)):br("LocalStore","Ignoring outdated watch update for ",n,". Current version:",s.version," Watch version:",a.version)})),o}))}function Pu(t,e){var n=Cr(t);return n.persistence.runTransaction("Get next mutation batch","readonly",(function(t){return void 0===e&&(e=-1),n._n.getNextMutationBatchAfterBatchId(t,e)}))}function Mu(t,e){var n=Cr(t);return n.persistence.runTransaction("Allocate target","readwrite",(function(t){var r;return n.qe.getTargetData(t,e).next((function(i){return i?(r=i,hs.resolve(r)):n.qe.allocateTargetId(t).next((function(i){return r=new Es(e,i,0,t.currentSequenceNumber),n.qe.addTargetData(t,r).next((function(){return r}))}))}))})).then((function(t){var r=n.Fn.get(t.targetId);return(null===r||t.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.Fn=n.Fn.insert(t.targetId,t),n.kn.set(e,t.targetId)),t}))}function Lu(t,e,n){return(0,dr.mG)(this,void 0,void 0,(function(){var r,i,o,a;return(0,dr.Jh)(this,(function(s){switch(s.label){case 0:r=Cr(t),i=r.Fn.get(e),o=n?"readwrite":"readwrite-primary",s.label=1;case 1:return s.trys.push([1,4,,5]),n?[3,3]:[4,r.persistence.runTransaction("Release target",o,(function(t){return r.persistence.referenceDelegate.removeTarget(t,i)}))];case 2:s.sent(),s.label=3;case 3:return[3,5];case 4:if(!gs(a=s.sent()))throw a;return br("LocalStore","Failed to update sequence numbers for target "+e+": "+a),[3,5];case 5:return r.Fn=r.Fn.remove(e),r.kn.delete(i.target),[2]}}))}))}function Uu(t,e,n){var r=Cr(t),i=Br.min(),o=Yo();return r.persistence.runTransaction("Execute query","readonly",(function(t){return function(t,e,n){var r=Cr(t),i=r.kn.get(n);return void 0!==i?hs.resolve(r.Fn.get(i)):r.qe.getTargetData(e,n)}(r,t,zi(e)).next((function(e){if(e)return i=e.lastLimboFreeSnapshotVersion,r.qe.getMatchingKeysForTargetId(t,e.targetId).next((function(t){o=t}))})).next((function(){return r.xn.getDocumentsMatchingQuery(t,e,n?i:Br.min(),n?o:Yo())})).next((function(t){return{documents:t,Bn:o}}))}))}function Fu(t,e){var n=Cr(t),r=Cr(n.qe),i=n.Fn.get(e);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",(function(t){return r.lt(t,e).next((function(t){return t?t.target:null}))}))}function Qu(t){var e=Cr(t);return e.persistence.runTransaction("Get new document changes","readonly",(function(t){return function(t,e,n){var r=Cr(t),i=Go(),o=xs(n),a=gu(e),s=IDBKeyRange.lowerBound(o,!0);return a.Ot({index:Xa.readTimeIndex,range:s},(function(t,e){var n=Cs(r.R,e);i=i.insert(n.key,n),o=e.readTime})).next((function(){return{wn:i,readTime:Ds(o)}}))}(e.$n,t,e.On)})).then((function(t){var n=t.wn,r=t.readTime;return e.On=r,n}))}function ju(t){return(0,dr.mG)(this,void 0,void 0,(function(){var e;return(0,dr.Jh)(this,(function(n){return[2,(e=Cr(t)).persistence.runTransaction("Synchronize last document change read time","readonly",(function(t){return function(t){var e=gu(t),n=Br.min();return e.Ot({index:Xa.readTimeIndex,reverse:!0},(function(t,e,r){e.readTime&&(n=Ds(e.readTime)),r.done()})).next((function(){return n}))}(t)})).then((function(t){e.On=t}))]}))}))}function qu(t,e,n,r){return(0,dr.mG)(this,void 0,void 0,(function(){var i,o,a,s,u,c,h,l,f,p;return(0,dr.Jh)(this,(function(d){switch(d.label){case 0:for(i=Cr(t),o=Yo(),a=Go(),s=Ko(),u=0,c=n;u<c.length;u++)h=c[u],l=e.qn(h.metadata.name),h.document&&(o=o.add(l)),a=a.insert(l,e.Un(h)),s=s.insert(l,e.Qn(h.metadata.readTime));return f=i.$n.newChangeBuffer({trackRemovals:!0}),[4,Mu(i,function(t){return zi(Ui(Ur.fromString("__bundle__/docs/"+t)))}(r))];case 1:return p=d.sent(),[2,i.persistence.runTransaction("Apply bundle documents","readwrite",(function(t){return Nu(t,f,a,Br.min(),s).next((function(e){return f.apply(t),e})).next((function(e){return i.qe.removeMatchingKeysForTargetId(t,p.targetId).next((function(){return i.qe.addMatchingKeys(t,o,p.targetId)})).next((function(){return i.Mn.En(t,e)})).next((function(){return e}))}))}))]}}))}))}function Gu(t,e,n){return void 0===n&&(n=Yo()),(0,dr.mG)(this,void 0,void 0,(function(){var r,i;return(0,dr.Jh)(this,(function(o){switch(o.label){case 0:return[4,Mu(t,zi(Ps(e.bundledQuery)))];case 1:return r=o.sent(),[2,(i=Cr(t)).persistence.runTransaction("Save named query","readwrite",(function(t){var o=pa(e.readTime);if(r.snapshotVersion.compareTo(o)>=0)return i.Qe.saveNamedQuery(t,e);var a=r.withResumeToken(qr.EMPTY_BYTE_STRING,o);return i.Fn=i.Fn.insert(a.targetId,a),i.qe.updateTargetData(t,a).next((function(){return i.qe.removeMatchingKeysForTargetId(t,r.targetId)})).next((function(){return i.qe.addMatchingKeys(t,n,r.targetId)})).next((function(){return i.Qe.saveNamedQuery(t,e)}))}))]}}))}))}var Vu=function(){function t(t){this.R=t,this.Kn=new Map,this.jn=new Map}return t.prototype.getBundleMetadata=function(t,e){return hs.resolve(this.Kn.get(e))},t.prototype.saveBundleMetadata=function(t,e){var n;return this.Kn.set(e.id,{id:(n=e).id,version:n.version,createTime:pa(n.createTime)}),hs.resolve()},t.prototype.getNamedQuery=function(t,e){return hs.resolve(this.jn.get(e))},t.prototype.saveNamedQuery=function(t,e){return this.jn.set(e.name,function(t){return{name:t.name,query:Ps(t.bundledQuery),readTime:pa(t.readTime)}}(e)),hs.resolve()},t}(),zu=function(){function t(){this.Wn=new Qo(Hu.Gn),this.zn=new Qo(Hu.Hn)}return t.prototype.isEmpty=function(){return this.Wn.isEmpty()},t.prototype.addReference=function(t,e){var n=new Hu(t,e);this.Wn=this.Wn.add(n),this.zn=this.zn.add(n)},t.prototype.Jn=function(t,e){var n=this;t.forEach((function(t){return n.addReference(t,e)}))},t.prototype.removeReference=function(t,e){this.Yn(new Hu(t,e))},t.prototype.Xn=function(t,e){var n=this;t.forEach((function(t){return n.removeReference(t,e)}))},t.prototype.Zn=function(t){var e=this,n=new $r(new Ur([])),r=new Hu(n,t),i=new Hu(n,t+1),o=[];return this.zn.forEachInRange([r,i],(function(t){e.Yn(t),o.push(t.key)})),o},t.prototype.ts=function(){var t=this;this.Wn.forEach((function(e){return t.Yn(e)}))},t.prototype.Yn=function(t){this.Wn=this.Wn.delete(t),this.zn=this.zn.delete(t)},t.prototype.es=function(t){var e=new $r(new Ur([])),n=new Hu(e,t),r=new Hu(e,t+1),i=Yo();return this.zn.forEachInRange([n,r],(function(t){i=i.add(t.key)})),i},t.prototype.containsKey=function(t){var e=new Hu(t,0),n=this.Wn.firstAfterOrEqual(e);return null!==n&&t.isEqual(n.key)},t}(),Hu=function(){function t(t,e){this.key=t,this.ns=e}return t.Gn=function(t,e){return $r.comparator(t.key,e.key)||Dr(t.ns,e.ns)},t.Hn=function(t,e){return Dr(t.ns,e.ns)||$r.comparator(t.key,e.key)},t}(),Ku=function(){function t(t,e){this.Ut=t,this.referenceDelegate=e,this._n=[],this.ss=1,this.rs=new Qo(Hu.Gn)}return t.prototype.checkEmpty=function(t){return hs.resolve(0===this._n.length)},t.prototype.addMutationBatch=function(t,e,n,r){var i=this.ss;this.ss++,this._n.length>0&&this._n[this._n.length-1];var o=new _s(i,e,n,r);this._n.push(o);for(var a=0,s=r;a<s.length;a++){var u=s[a];this.rs=this.rs.add(new Hu(u.key,i)),this.Ut.addToCollectionParentIndex(t,u.key.path.popLast())}return hs.resolve(o)},t.prototype.lookupMutationBatch=function(t,e){return hs.resolve(this.os(e))},t.prototype.getNextMutationBatchAfterBatchId=function(t,e){var n=e+1,r=this.cs(n),i=r<0?0:r;return hs.resolve(this._n.length>i?this._n[i]:null)},t.prototype.getHighestUnacknowledgedBatchId=function(){return hs.resolve(0===this._n.length?-1:this.ss-1)},t.prototype.getAllMutationBatches=function(t){return hs.resolve(this._n.slice())},t.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,e){var n=this,r=new Hu(e,0),i=new Hu(e,Number.POSITIVE_INFINITY),o=[];return this.rs.forEachInRange([r,i],(function(t){var e=n.os(t.ns);o.push(e)})),hs.resolve(o)},t.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,e){var n=this,r=new Qo(Dr);return e.forEach((function(t){var e=new Hu(t,0),i=new Hu(t,Number.POSITIVE_INFINITY);n.rs.forEachInRange([e,i],(function(t){r=r.add(t.ns)}))})),hs.resolve(this.us(r))},t.prototype.getAllMutationBatchesAffectingQuery=function(t,e){var n=e.path,r=n.length+1,i=n;$r.isDocumentKey(i)||(i=i.child(""));var o=new Hu(new $r(i),0),a=new Qo(Dr);return this.rs.forEachWhile((function(t){var e=t.key.path;return!!n.isPrefixOf(e)&&(e.length===r&&(a=a.add(t.ns)),!0)}),o),hs.resolve(this.us(a))},t.prototype.us=function(t){var e=this,n=[];return t.forEach((function(t){var r=e.os(t);null!==r&&n.push(r)})),n},t.prototype.removeMutationBatch=function(t,e){var n=this;Tr(0===this.hs(e.batchId,"removed")),this._n.shift();var r=this.rs;return hs.forEach(e.mutations,(function(i){var o=new Hu(i.key,e.batchId);return r=r.delete(o),n.referenceDelegate.markPotentiallyOrphaned(t,i.key)})).next((function(){n.rs=r}))},t.prototype.Gt=function(t){},t.prototype.containsKey=function(t,e){var n=new Hu(e,0),r=this.rs.firstAfterOrEqual(n);return hs.resolve(e.isEqual(r&&r.key))},t.prototype.performConsistencyCheck=function(t){return this._n.length,hs.resolve()},t.prototype.hs=function(t,e){return this.cs(t)},t.prototype.cs=function(t){return 0===this._n.length?0:t-this._n[0].batchId},t.prototype.os=function(t){var e=this.cs(t);return e<0||e>=this._n.length?null:this._n[e]},t}(),Wu=function(){function t(t,e){this.Ut=t,this.ls=e,this.docs=new Lo($r.comparator),this.size=0}return t.prototype.addEntry=function(t,e,n){var r=e.key,i=this.docs.get(r),o=i?i.size:0,a=this.ls(e);return this.docs=this.docs.insert(r,{document:e.clone(),size:a,readTime:n}),this.size+=a-o,this.Ut.addToCollectionParentIndex(t,r.path.popLast())},t.prototype.removeEntry=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},t.prototype.getEntry=function(t,e){var n=this.docs.get(e);return hs.resolve(n?n.document.clone():gi.newInvalidDocument(e))},t.prototype.getEntries=function(t,e){var n=this,r=Go();return e.forEach((function(t){var e=n.docs.get(t);r=r.insert(t,e?e.document.clone():gi.newInvalidDocument(t))})),hs.resolve(r)},t.prototype.getDocumentsMatchingQuery=function(t,e,n){for(var r=Go(),i=new $r(e.path.child("")),o=this.docs.getIteratorFrom(i);o.hasNext();){var a=o.getNext(),s=a.key,u=a.value,c=u.document,h=u.readTime;if(!e.path.isPrefixOf(s.path))break;h.compareTo(n)<=0||Ji(e,c)&&(r=r.insert(c.key,c.clone()))}return hs.resolve(r)},t.prototype.fs=function(t,e){return hs.forEach(this.docs,(function(t){return e(t)}))},t.prototype.newChangeBuffer=function(t){return new Yu(this)},t.prototype.getSize=function(t){return hs.resolve(this.size)},t}(),Yu=function(t){function e(e){var n=this;return(n=t.call(this)||this).Ie=e,n}return(0,dr.ZT)(e,t),e.prototype.applyChanges=function(t){var e=this,n=[];return this.changes.forEach((function(r,i){i.document.isValidDocument()?n.push(e.Ie.addEntry(t,i.document,e.getReadTime(r))):e.Ie.removeEntry(r)})),hs.waitFor(n)},e.prototype.getFromCache=function(t,e){return this.Ie.getEntry(t,e)},e.prototype.getAllFromCache=function(t,e){return this.Ie.getEntries(t,e)},e}(lu),Ju=function(){function t(t){this.persistence=t,this.ds=new hu((function(t){return yi(t)}),Ai),this.lastRemoteSnapshotVersion=Br.min(),this.highestTargetId=0,this.ws=0,this._s=new zu,this.targetCount=0,this.ys=Zs.Jt()}return t.prototype.forEachTarget=function(t,e){return this.ds.forEach((function(t,n){return e(n)})),hs.resolve()},t.prototype.getLastRemoteSnapshotVersion=function(t){return hs.resolve(this.lastRemoteSnapshotVersion)},t.prototype.getHighestSequenceNumber=function(t){return hs.resolve(this.ws)},t.prototype.allocateTargetId=function(t){return this.highestTargetId=this.ys.next(),hs.resolve(this.highestTargetId)},t.prototype.setTargetsMetadata=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.ws&&(this.ws=e),hs.resolve()},t.prototype.te=function(t){this.ds.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.ys=new Zs(e),this.highestTargetId=e),t.sequenceNumber>this.ws&&(this.ws=t.sequenceNumber)},t.prototype.addTargetData=function(t,e){return this.te(e),this.targetCount+=1,hs.resolve()},t.prototype.updateTargetData=function(t,e){return this.te(e),hs.resolve()},t.prototype.removeTargetData=function(t,e){return this.ds.delete(e.target),this._s.Zn(e.targetId),this.targetCount-=1,hs.resolve()},t.prototype.removeTargets=function(t,e,n){var r=this,i=0,o=[];return this.ds.forEach((function(a,s){s.sequenceNumber<=e&&null===n.get(s.targetId)&&(r.ds.delete(a),o.push(r.removeMatchingKeysForTargetId(t,s.targetId)),i++)})),hs.waitFor(o).next((function(){return i}))},t.prototype.getTargetCount=function(t){return hs.resolve(this.targetCount)},t.prototype.getTargetData=function(t,e){var n=this.ds.get(e)||null;return hs.resolve(n)},t.prototype.addMatchingKeys=function(t,e,n){return this._s.Jn(e,n),hs.resolve()},t.prototype.removeMatchingKeys=function(t,e,n){this._s.Xn(e,n);var r=this.persistence.referenceDelegate,i=[];return r&&e.forEach((function(e){i.push(r.markPotentiallyOrphaned(t,e))})),hs.waitFor(i)},t.prototype.removeMatchingKeysForTargetId=function(t,e){return this._s.Zn(e),hs.resolve()},t.prototype.getMatchingKeysForTargetId=function(t,e){var n=this._s.es(e);return hs.resolve(n)},t.prototype.containsKey=function(t,e){return hs.resolve(this._s.containsKey(e))},t}(),Xu=function(){function t(t,e){var n=this;this.gs={},this.Ne=new gr(0),this.xe=!1,this.xe=!0,this.referenceDelegate=t(this),this.qe=new Ju(this),this.Ut=new Fs,this.Ue=function(t,e){return new Wu(t,(function(t){return n.referenceDelegate.ps(t)}))}(this.Ut),this.R=new Ts(e),this.Qe=new Vu(this.R)}return t.prototype.start=function(){return Promise.resolve()},t.prototype.shutdown=function(){return this.xe=!1,Promise.resolve()},Object.defineProperty(t.prototype,"started",{get:function(){return this.xe},enumerable:!1,configurable:!0}),t.prototype.setDatabaseDeletedListener=function(){},t.prototype.setNetworkEnabled=function(){},t.prototype.getIndexManager=function(){return this.Ut},t.prototype.getMutationQueue=function(t){var e=this.gs[t.toKey()];return e||(e=new Ku(this.Ut,this.referenceDelegate),this.gs[t.toKey()]=e),e},t.prototype.getTargetCache=function(){return this.qe},t.prototype.getRemoteDocumentCache=function(){return this.Ue},t.prototype.getBundleCache=function(){return this.Qe},t.prototype.runTransaction=function(t,e,n){var r=this;br("MemoryPersistence","Starting transaction:",t);var i=new Zu(this.Ne.next());return this.referenceDelegate.Es(),n(i).next((function(t){return r.referenceDelegate.Ts(i).next((function(){return t}))})).toPromise().then((function(t){return i.raiseOnCommittedEvent(),t}))},t.prototype.Is=function(t,e){return hs.or(Object.values(this.gs).map((function(n){return function(){return n.containsKey(t,e)}})))},t}(),Zu=function(t){function e(e){var n=this;return(n=t.call(this)||this).currentSequenceNumber=e,n}return(0,dr.ZT)(e,t),e}(us),$u=function(){function t(t){this.persistence=t,this.As=new zu,this.Rs=null}return t.bs=function(e){return new t(e)},Object.defineProperty(t.prototype,"vs",{get:function(){if(this.Rs)return this.Rs;throw Er()},enumerable:!1,configurable:!0}),t.prototype.addReference=function(t,e,n){return this.As.addReference(n,e),this.vs.delete(n.toString()),hs.resolve()},t.prototype.removeReference=function(t,e,n){return this.As.removeReference(n,e),this.vs.add(n.toString()),hs.resolve()},t.prototype.markPotentiallyOrphaned=function(t,e){return this.vs.add(e.toString()),hs.resolve()},t.prototype.removeTarget=function(t,e){var n=this;this.As.Zn(e.targetId).forEach((function(t){return n.vs.add(t.toString())}));var r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(t,e.targetId).next((function(t){t.forEach((function(t){return n.vs.add(t.toString())}))})).next((function(){return r.removeTargetData(t,e)}))},t.prototype.Es=function(){this.Rs=new Set},t.prototype.Ts=function(t){var e=this,n=this.persistence.getRemoteDocumentCache().newChangeBuffer();return hs.forEach(this.vs,(function(r){var i=$r.fromPath(r);return e.Ps(t,i).next((function(t){t||n.removeEntry(i)}))})).next((function(){return e.Rs=null,n.apply(t)}))},t.prototype.updateLimboDocument=function(t,e){var n=this;return this.Ps(t,e).next((function(t){t?n.vs.delete(e.toString()):n.vs.add(e.toString())}))},t.prototype.ps=function(t){return 0},t.prototype.Ps=function(t,e){var n=this;return hs.or([function(){return hs.resolve(n.As.containsKey(e))},function(){return n.persistence.getTargetCache().containsKey(t,e)},function(){return n.persistence.Is(t,e)}])},t}(),tc=function(){function t(t){this.uid=t}return t.prototype.isAuthenticated=function(){return null!=this.uid},t.prototype.toKey=function(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"},t.prototype.isEqual=function(t){return t.uid===this.uid},t}();function ec(t,e){return"firestore_clients_"+t+"_"+e}function nc(t,e,n){var r="firestore_mutations_"+t+"_"+n;return e.isAuthenticated()&&(r+="_"+e.uid),r}function rc(t,e){return"firestore_targets_"+t+"_"+e}tc.UNAUTHENTICATED=new tc(null),tc.GOOGLE_CREDENTIALS=new tc("google-credentials-uid"),tc.FIRST_PARTY=new tc("first-party-uid");var ic=function(){function t(t,e,n,r){this.user=t,this.batchId=e,this.state=n,this.error=r}return t.Vs=function(e,n,r){var i,o=JSON.parse(r),a="object"==typeof o&&-1!==["pending","acknowledged","rejected"].indexOf(o.state)&&(void 0===o.error||"object"==typeof o.error);return a&&o.error&&(a="string"==typeof o.error.message&&"string"==typeof o.error.code)&&(i=new vr(o.error.code,o.error.message)),a?new t(e,n,o.state,i):(wr("SharedClientState","Failed to parse mutation state for ID '"+n+"': "+r),null)},t.prototype.Ss=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},t}(),oc=function(){function t(t,e,n){this.targetId=t,this.state=e,this.error=n}return t.Vs=function(e,n){var r,i=JSON.parse(n),o="object"==typeof i&&-1!==["not-current","current","rejected"].indexOf(i.state)&&(void 0===i.error||"object"==typeof i.error);return o&&i.error&&(o="string"==typeof i.error.message&&"string"==typeof i.error.code)&&(r=new vr(i.error.code,i.error.message)),o?new t(e,i.state,r):(wr("SharedClientState","Failed to parse target state for ID '"+e+"': "+n),null)},t.prototype.Ss=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},t}(),ac=function(){function t(t,e){this.clientId=t,this.activeTargetIds=e}return t.Vs=function(e,n){for(var r=JSON.parse(n),i="object"==typeof r&&r.activeTargetIds instanceof Array,o=Xo(),a=0;i&&a<r.activeTargetIds.length;++a)i=Zr(r.activeTargetIds[a]),o=o.add(r.activeTargetIds[a]);return i?new t(e,o):(wr("SharedClientState","Failed to parse client data for instance '"+e+"': "+n),null)},t}(),sc=function(){function t(t,e){this.clientId=t,this.onlineState=e}return t.Vs=function(e){var n=JSON.parse(e);return"object"==typeof n&&-1!==["Unknown","Online","Offline"].indexOf(n.onlineState)&&"string"==typeof n.clientId?new t(n.clientId,n.onlineState):(wr("SharedClientState","Failed to parse online state: "+e),null)},t}(),uc=function(){function t(){this.activeTargetIds=Xo()}return t.prototype.Ds=function(t){this.activeTargetIds=this.activeTargetIds.add(t)},t.prototype.Cs=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},t.prototype.Ss=function(){var t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)},t}(),cc=function(){function t(t,e,n,r,i){this.window=t,this.Se=e,this.persistenceKey=n,this.Ns=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.xs=this.Fs.bind(this),this.ks=new Lo(Dr),this.started=!1,this.Os=[];var o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.$s=ec(this.persistenceKey,this.Ns),this.Ms=function(t){return"firestore_sequence_number_"+t}(this.persistenceKey),this.ks=this.ks.insert(this.Ns,new uc),this.Ls=new RegExp("^firestore_clients_"+o+"_([^_]*)$"),this.Bs=new RegExp("^firestore_mutations_"+o+"_(\\d+)(?:_(.*))?$"),this.qs=new RegExp("^firestore_targets_"+o+"_(\\d+)$"),this.Us=function(t){return"firestore_online_state_"+t}(this.persistenceKey),this.Qs=function(t){return"firestore_bundle_loaded_"+t}(this.persistenceKey),this.window.addEventListener("storage",this.xs)}return t.yt=function(t){return!(!t||!t.localStorage)},t.prototype.start=function(){return(0,dr.mG)(this,void 0,void 0,(function(){var t,e,n,r,i,o,a,s,u,c,h,l=this;return(0,dr.Jh)(this,(function(f){switch(f.label){case 0:return[4,this.syncEngine.fn()];case 1:for(t=f.sent(),e=0,n=t;e<n.length;e++)(r=n[e])!==this.Ns&&(i=this.getItem(ec(this.persistenceKey,r)))&&(o=ac.Vs(r,i))&&(this.ks=this.ks.insert(o.clientId,o));for(this.Ks(),(a=this.storage.getItem(this.Us))&&(s=this.js(a))&&this.Ws(s),u=0,c=this.Os;u<c.length;u++)h=c[u],this.Fs(h);return this.Os=[],this.window.addEventListener("unload",(function(){return l.shutdown()})),this.started=!0,[2]}}))}))},t.prototype.writeSequenceNumber=function(t){this.setItem(this.Ms,JSON.stringify(t))},t.prototype.getAllActiveQueryTargets=function(){return this.Gs(this.ks)},t.prototype.isActiveQueryTarget=function(t){var e=!1;return this.ks.forEach((function(n,r){r.activeTargetIds.has(t)&&(e=!0)})),e},t.prototype.addPendingMutation=function(t){this.zs(t,"pending")},t.prototype.updateMutationState=function(t,e,n){this.zs(t,e,n),this.Hs(t)},t.prototype.addLocalQueryTarget=function(t){var e="not-current";if(this.isActiveQueryTarget(t)){var n=this.storage.getItem(rc(this.persistenceKey,t));if(n){var r=oc.Vs(t,n);r&&(e=r.state)}}return this.Js.Ds(t),this.Ks(),e},t.prototype.removeLocalQueryTarget=function(t){this.Js.Cs(t),this.Ks()},t.prototype.isLocalQueryTarget=function(t){return this.Js.activeTargetIds.has(t)},t.prototype.clearQueryState=function(t){this.removeItem(rc(this.persistenceKey,t))},t.prototype.updateQueryState=function(t,e,n){this.Ys(t,e,n)},t.prototype.handleUserChange=function(t,e,n){var r=this;e.forEach((function(t){r.Hs(t)})),this.currentUser=t,n.forEach((function(t){r.addPendingMutation(t)}))},t.prototype.setOnlineState=function(t){this.Xs(t)},t.prototype.notifyBundleLoaded=function(){this.Zs()},t.prototype.shutdown=function(){this.started&&(this.window.removeEventListener("storage",this.xs),this.removeItem(this.$s),this.started=!1)},t.prototype.getItem=function(t){var e=this.storage.getItem(t);return br("SharedClientState","READ",t,e),e},t.prototype.setItem=function(t,e){br("SharedClientState","SET",t,e),this.storage.setItem(t,e)},t.prototype.removeItem=function(t){br("SharedClientState","REMOVE",t),this.storage.removeItem(t)},t.prototype.Fs=function(t){var e=this,n=t;if(n.storageArea===this.storage){if(br("SharedClientState","EVENT",n.key,n.newValue),n.key===this.$s)return void wr("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Se.enqueueRetryable((function(){return(0,dr.mG)(e,void 0,void 0,(function(){var t,e,r,i,o,a;return(0,dr.Jh)(this,(function(s){if(this.started){if(null!==n.key)if(this.Ls.test(n.key)){if(null==n.newValue)return t=this.ti(n.key),[2,this.ei(t,null)];if(e=this.ni(n.key,n.newValue))return[2,this.ei(e.clientId,e)]}else if(this.Bs.test(n.key)){if(null!==n.newValue&&(r=this.si(n.key,n.newValue)))return[2,this.ii(r)]}else if(this.qs.test(n.key)){if(null!==n.newValue&&(i=this.ri(n.key,n.newValue)))return[2,this.oi(i)]}else if(n.key===this.Us){if(null!==n.newValue&&(o=this.js(n.newValue)))return[2,this.Ws(o)]}else if(n.key===this.Ms)(a=function(t){var e=gr.o;if(null!=t)try{var n=JSON.parse(t);Tr("number"==typeof n),e=n}catch(t){wr("SharedClientState","Failed to read sequence number from WebStorage",t)}return e}(n.newValue))!==gr.o&&this.sequenceNumberHandler(a);else if(n.key===this.Qs)return[2,this.syncEngine.ci()]}else this.Os.push(n);return[2]}))}))}))}},Object.defineProperty(t.prototype,"Js",{get:function(){return this.ks.get(this.Ns)},enumerable:!1,configurable:!0}),t.prototype.Ks=function(){this.setItem(this.$s,this.Js.Ss())},t.prototype.zs=function(t,e,n){var r=new ic(this.currentUser,t,e,n),i=nc(this.persistenceKey,this.currentUser,t);this.setItem(i,r.Ss())},t.prototype.Hs=function(t){var e=nc(this.persistenceKey,this.currentUser,t);this.removeItem(e)},t.prototype.Xs=function(t){var e={clientId:this.Ns,onlineState:t};this.storage.setItem(this.Us,JSON.stringify(e))},t.prototype.Ys=function(t,e,n){var r=rc(this.persistenceKey,t),i=new oc(t,e,n);this.setItem(r,i.Ss())},t.prototype.Zs=function(){this.setItem(this.Qs,"value-not-used")},t.prototype.ti=function(t){var e=this.Ls.exec(t);return e?e[1]:null},t.prototype.ni=function(t,e){var n=this.ti(t);return ac.Vs(n,e)},t.prototype.si=function(t,e){var n=this.Bs.exec(t),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return ic.Vs(new tc(i),r,e)},t.prototype.ri=function(t,e){var n=this.qs.exec(t),r=Number(n[1]);return oc.Vs(r,e)},t.prototype.js=function(t){return sc.Vs(t)},t.prototype.ii=function(t){return(0,dr.mG)(this,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(e){return t.user.uid===this.currentUser.uid?[2,this.syncEngine.ui(t.batchId,t.state,t.error)]:(br("SharedClientState","Ignoring mutation for non-active user "+t.user.uid),[2])}))}))},t.prototype.oi=function(t){return this.syncEngine.ai(t.targetId,t.state,t.error)},t.prototype.ei=function(t,e){var n=this,r=e?this.ks.insert(t,e):this.ks.remove(t),i=this.Gs(this.ks),o=this.Gs(r),a=[],s=[];return o.forEach((function(t){i.has(t)||a.push(t)})),i.forEach((function(t){o.has(t)||s.push(t)})),this.syncEngine.hi(a,s).then((function(){n.ks=r}))},t.prototype.Ws=function(t){this.ks.get(t.clientId)&&this.onlineStateHandler(t.onlineState)},t.prototype.Gs=function(t){var e=Xo();return t.forEach((function(t,n){e=e.unionWith(n.activeTargetIds)})),e},t}(),hc=function(){function t(){this.li=new uc,this.fi={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}return t.prototype.addPendingMutation=function(t){},t.prototype.updateMutationState=function(t,e,n){},t.prototype.addLocalQueryTarget=function(t){return this.li.Ds(t),this.fi[t]||"not-current"},t.prototype.updateQueryState=function(t,e,n){this.fi[t]=e},t.prototype.removeLocalQueryTarget=function(t){this.li.Cs(t)},t.prototype.isLocalQueryTarget=function(t){return this.li.activeTargetIds.has(t)},t.prototype.clearQueryState=function(t){delete this.fi[t]},t.prototype.getAllActiveQueryTargets=function(){return this.li.activeTargetIds},t.prototype.isActiveQueryTarget=function(t){return this.li.activeTargetIds.has(t)},t.prototype.start=function(){return this.li=new uc,Promise.resolve()},t.prototype.handleUserChange=function(t,e,n){},t.prototype.setOnlineState=function(t){},t.prototype.shutdown=function(){},t.prototype.writeSequenceNumber=function(t){},t.prototype.notifyBundleLoaded=function(){},t}(),lc=function(){function t(){}return t.prototype.di=function(t){},t.prototype.shutdown=function(){},t}(),fc=function(){function t(){var t=this;this.wi=function(){return t._i()},this.mi=function(){return t.yi()},this.gi=[],this.pi()}return t.prototype.di=function(t){this.gi.push(t)},t.prototype.shutdown=function(){window.removeEventListener("online",this.wi),window.removeEventListener("offline",this.mi)},t.prototype.pi=function(){window.addEventListener("online",this.wi),window.addEventListener("offline",this.mi)},t.prototype._i=function(){br("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(var t=0,e=this.gi;t<e.length;t++)(0,e[t])(0)},t.prototype.yi=function(){br("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(var t=0,e=this.gi;t<e.length;t++)(0,e[t])(1)},t.yt=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},t}(),pc={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"},dc=function(){function t(t){this.Ei=t.Ei,this.Ti=t.Ti}return t.prototype.Ii=function(t){this.Ai=t},t.prototype.Ri=function(t){this.bi=t},t.prototype.onMessage=function(t){this.vi=t},t.prototype.close=function(){this.Ti()},t.prototype.send=function(t){this.Ei(t)},t.prototype.Pi=function(){this.Ai()},t.prototype.Vi=function(t){this.bi(t)},t.prototype.Si=function(t){this.vi(t)},t}(),gc=function(t){function e(e){var n=this;return(n=t.call(this,e)||this).forceLongPolling=e.forceLongPolling,n.autoDetectLongPolling=e.autoDetectLongPolling,n}return(0,dr.ZT)(e,t),e.prototype.ki=function(t,e,n,r){return new Promise((function(i,o){var a=new pr;a.listenOnce(cr.COMPLETE,(function(){try{switch(a.getLastErrorCode()){case ur.NO_ERROR:var e=a.getResponseJson();br("Connection","XHR received:",JSON.stringify(e)),i(e);break;case ur.TIMEOUT:br("Connection",'RPC "'+t+'" timed out'),o(new vr(mr.DEADLINE_EXCEEDED,"Request time out"));break;case ur.HTTP_ERROR:var n=a.getStatus();if(br("Connection",'RPC "'+t+'" failed with status:',n,"response text:",a.getResponseText()),n>0){var r=a.getResponseJson().error;if(r&&r.status&&r.message){var s=function(t){var e=t.toLowerCase().replace(/_/g,"-");return Object.values(mr).indexOf(e)>=0?e:mr.UNKNOWN}(r.status);o(new vr(s,r.message))}else o(new vr(mr.UNKNOWN,"Server responded with status "+a.getStatus()))}else o(new vr(mr.UNAVAILABLE,"Connection failed."));break;default:Er()}}finally{br("Connection",'RPC "'+t+'" completed.')}}));var s=JSON.stringify(r);a.send(e,"POST",s,n,15)}))},e.prototype.$i=function(t,e){var n=[this.Di,"/","google.firestore.v1.Firestore","/",t,"/channel"],r=ar(),o=sr(),a={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:"projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling};this.Fi(a.initMessageHeaders,e),(0,i.uI)()||(0,i.b$)()||(0,i.d)()||(0,i.w1)()||(0,i.Mn)()||(0,i.ru)()||(a.httpHeadersOverwriteParam="$httpHeaders");var s=n.join("");br("Connection","Creating WebChannel: "+s,a);var u=r.createWebChannel(s,a),c=!1,h=!1,l=new dc({Ei:function(t){h?br("Connection","Not sending because WebChannel is closed:",t):(c||(br("Connection","Opening WebChannel transport."),u.open(),c=!0),br("Connection","WebChannel sending:",t),u.send(t))},Ti:function(){return u.close()}}),f=function(t,e,n){t.listen(e,(function(t){try{n(t)}catch(t){setTimeout((function(){throw t}),0)}}))};return f(u,fr.EventType.OPEN,(function(){h||br("Connection","WebChannel transport opened.")})),f(u,fr.EventType.CLOSE,(function(){h||(h=!0,br("Connection","WebChannel transport closed"),l.Vi())})),f(u,fr.EventType.ERROR,(function(t){h||(h=!0,_r("Connection","WebChannel transport errored:",t),l.Vi(new vr(mr.UNAVAILABLE,"The operation could not be completed")))})),f(u,fr.EventType.MESSAGE,(function(t){var e;if(!h){var n=t.data[0];Tr(!!n);var r=n,i=r.error||(null===(e=r[0])||void 0===e?void 0:e.error);if(i){br("Connection","WebChannel received error:",i);var o=i.status,a=function(t){var e=ko[t];if(void 0!==e)return Mo(e)}(o),s=i.message;void 0===a&&(a=mr.INTERNAL,s="Unknown error status: "+o+" with message "+i.message),h=!0,l.Vi(new vr(a,s)),u.close()}else br("Connection","WebChannel received:",n),l.Si(n)}})),f(o,hr.STAT_EVENT,(function(t){t.stat===lr.PROXY?br("Connection","Detected buffering proxy"):t.stat===lr.NOPROXY&&br("Connection","Detected no buffering proxy")})),setTimeout((function(){l.Pi()}),0),l},e}(function(){function t(t){this.databaseInfo=t,this.databaseId=t.databaseId;var e=t.ssl?"https":"http";this.Di=e+"://"+t.host,this.Ci="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}return t.prototype.Ni=function(t,e,n,r){var i=this.xi(t,e);br("RestConnection","Sending: ",i,n);var o={};return this.Fi(o,r),this.ki(t,i,o,n).then((function(t){return br("RestConnection","Received: ",t),t}),(function(e){throw _r("RestConnection",t+" failed with error: ",e,"url: ",i,"request:",n),e}))},t.prototype.Oi=function(t,e,n,r){return this.Ni(t,e,n,r)},t.prototype.Fi=function(t,e){if(t["X-Goog-Api-Client"]="gl-js/ fire/8.3.3",t["X-Firebase-GMPID"]=this.databaseInfo.appId,t["Content-Type"]="text/plain",e)for(var n in e.authHeaders)e.authHeaders.hasOwnProperty(n)&&(t[n]=e.authHeaders[n])},t.prototype.xi=function(t,e){var n=pc[t];return this.Di+"/v1/"+e+":"+n},t}());function mc(){return"undefined"!=typeof window?window:null}function vc(){return"undefined"!=typeof document?document:null}function yc(t){return new ca(t,!0)}var Ac=function(){function t(t,e,n,r,i){void 0===n&&(n=1e3),void 0===r&&(r=1.5),void 0===i&&(i=6e4),this.Se=t,this.timerId=e,this.Mi=n,this.Li=r,this.Bi=i,this.qi=0,this.Ui=null,this.Qi=Date.now(),this.reset()}return t.prototype.reset=function(){this.qi=0},t.prototype.Ki=function(){this.qi=this.Bi},t.prototype.ji=function(t){var e=this;this.cancel();var n=Math.floor(this.qi+this.Wi()),r=Math.max(0,Date.now()-this.Qi),i=Math.max(0,n-r);i>0&&br("ExponentialBackoff","Backing off for "+i+" ms (base delay: "+this.qi+" ms, delay with jitter: "+n+" ms, last attempt: "+r+" ms ago)"),this.Ui=this.Se.enqueueAfterDelay(this.timerId,i,(function(){return e.Qi=Date.now(),t()})),this.qi*=this.Li,this.qi<this.Mi&&(this.qi=this.Mi),this.qi>this.Bi&&(this.qi=this.Bi)},t.prototype.Gi=function(){null!==this.Ui&&(this.Ui.skipDelay(),this.Ui=null)},t.prototype.cancel=function(){null!==this.Ui&&(this.Ui.cancel(),this.Ui=null)},t.prototype.Wi=function(){return(Math.random()-.5)*this.qi},t}(),bc=function(){function t(t,e,n,r,i,o){this.Se=t,this.zi=n,this.Hi=r,this.Ji=i,this.listener=o,this.state=0,this.Yi=0,this.Xi=null,this.stream=null,this.Zi=new Ac(t,e)}return t.prototype.tr=function(){return 1===this.state||2===this.state||4===this.state},t.prototype.er=function(){return 2===this.state},t.prototype.start=function(){3!==this.state?this.auth():this.nr()},t.prototype.stop=function(){return(0,dr.mG)(this,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(t){switch(t.label){case 0:return this.tr()?[4,this.close(0)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.sr=function(){this.state=0,this.Zi.reset()},t.prototype.ir=function(){var t=this;this.er()&&null===this.Xi&&(this.Xi=this.Se.enqueueAfterDelay(this.zi,6e4,(function(){return t.rr()})))},t.prototype.cr=function(t){this.ur(),this.stream.send(t)},t.prototype.rr=function(){return(0,dr.mG)(this,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(t){return this.er()?[2,this.close(0)]:[2]}))}))},t.prototype.ur=function(){this.Xi&&(this.Xi.cancel(),this.Xi=null)},t.prototype.close=function(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(n){switch(n.label){case 0:return this.ur(),this.Zi.cancel(),this.Yi++,3!==t?this.Zi.reset():e&&e.code===mr.RESOURCE_EXHAUSTED?(wr(e.toString()),wr("Using maximum backoff delay to prevent overloading the backend."),this.Zi.Ki()):e&&e.code===mr.UNAUTHENTICATED&&this.Ji.invalidateToken(),null!==this.stream&&(this.ar(),this.stream.close(),this.stream=null),this.state=t,[4,this.listener.Ri(e)];case 1:return n.sent(),[2]}}))}))},t.prototype.ar=function(){},t.prototype.auth=function(){var t=this;this.state=1;var e=this.hr(this.Yi),n=this.Yi;this.Ji.getToken().then((function(e){t.Yi===n&&t.lr(e)}),(function(n){e((function(){var e=new vr(mr.UNKNOWN,"Fetching auth token failed: "+n.message);return t.dr(e)}))}))},t.prototype.lr=function(t){var e=this,n=this.hr(this.Yi);this.stream=this.wr(t),this.stream.Ii((function(){n((function(){return e.state=2,e.listener.Ii()}))})),this.stream.Ri((function(t){n((function(){return e.dr(t)}))})),this.stream.onMessage((function(t){n((function(){return e.onMessage(t)}))}))},t.prototype.nr=function(){var t=this;this.state=4,this.Zi.ji((function(){return(0,dr.mG)(t,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(t){return this.state=0,this.start(),[2]}))}))}))},t.prototype.dr=function(t){return br("PersistentStream","close with error: "+t),this.stream=null,this.close(3,t)},t.prototype.hr=function(t){var e=this;return function(n){e.Se.enqueueAndForget((function(){return e.Yi===t?n():(br("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())}))}},t}(),wc=function(t){function e(e,n,r,i,o){var a=this;return(a=t.call(this,e,"listen_stream_connection_backoff","listen_stream_idle",n,r,o)||this).R=i,a}return(0,dr.ZT)(e,t),e.prototype.wr=function(t){return this.Hi.$i("Listen",t)},e.prototype.onMessage=function(t){this.Zi.reset();var e=function(t,e){var n;if("targetChange"in e){e.targetChange;var r=function(t){return"NO_CHANGE"===t?0:"ADD"===t?1:"REMOVE"===t?2:"CURRENT"===t?3:"RESET"===t?4:Er()}(e.targetChange.targetChangeType||"NO_CHANGE"),i=e.targetChange.targetIds||[],o=function(t,e){return t.I?(Tr(void 0===e||"string"==typeof e),qr.fromBase64String(e||"")):(Tr(void 0===e||e instanceof Uint8Array),qr.fromUint8Array(e||new Uint8Array))}(t,e.targetChange.resumeToken),a=(s=e.targetChange.cause)&&function(t){var e=void 0===t.code?mr.UNKNOWN:Mo(t.code);return new vr(e,t.message||"")}(s);n=new na(r,i,o,a||null)}else if("documentChange"in e){e.documentChange,(r=e.documentChange).document,r.document.name,r.document.updateTime,i=va(t,r.document.name),o=pa(r.document.updateTime);var s=new pi({mapValue:{fields:r.document.fields}}),u=(a=gi.newFoundDocument(i,o,s),r.targetIds||[]),c=r.removedTargetIds||[];n=new ta(u,c,a.key,a)}else if("documentDelete"in e)e.documentDelete,(r=e.documentDelete).document,i=va(t,r.document),o=r.readTime?pa(r.readTime):Br.min(),s=gi.newNoDocument(i,o),a=r.removedTargetIds||[],n=new ta([],a,s.key,s);else if("documentRemove"in e)e.documentRemove,(r=e.documentRemove).document,i=va(t,r.document),o=r.removedTargetIds||[],n=new ta([],o,i,null);else{if(!("filter"in e))return Er();e.filter;var h=e.filter;h.targetId,r=h.count||0,i=new No(r),o=h.targetId,n=new ea(o,i)}return n}(this.R,t),n=function(t){if(!("targetChange"in t))return Br.min();var e=t.targetChange;return e.targetIds&&e.targetIds.length?Br.min():e.readTime?pa(e.readTime):Br.min()}(t);return this.listener._r(e,n)},e.prototype.mr=function(t){var e={};e.database=ba(this.R),e.addTarget=function(t,e){var n,r=e.target;return(n=bi(r)?{documents:Ca(t,r)}:{query:Sa(t,r)}).targetId=e.targetId,e.resumeToken.approximateByteSize()>0?n.resumeToken=la(t,e.resumeToken):e.snapshotVersion.compareTo(Br.min())>0&&(n.readTime=ha(t,e.snapshotVersion.toTimestamp())),n}(this.R,t);var n=function(t,e){var n=function(t,e){switch(e){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return Er()}}(0,e.purpose);return null==n?null:{"goog-listen-tags":n}}(this.R,t);n&&(e.labels=n),this.cr(e)},e.prototype.yr=function(t){var e={};e.database=ba(this.R),e.removeTarget=t,this.cr(e)},e}(bc),_c=function(t){function e(e,n,r,i,o){var a=this;return(a=t.call(this,e,"write_stream_connection_backoff","write_stream_idle",n,r,o)||this).R=i,a.gr=!1,a}return(0,dr.ZT)(e,t),Object.defineProperty(e.prototype,"pr",{get:function(){return this.gr},enumerable:!1,configurable:!0}),e.prototype.start=function(){this.gr=!1,this.lastStreamToken=void 0,t.prototype.start.call(this)},e.prototype.ar=function(){this.gr&&this.Er([])},e.prototype.wr=function(t){return this.Hi.$i("Write",t)},e.prototype.onMessage=function(t){if(Tr(!!t.streamToken),this.lastStreamToken=t.streamToken,this.gr){this.Zi.reset();var e=function(t,e){return t&&t.length>0?(Tr(void 0!==e),t.map((function(t){return function(t,e){var n=t.updateTime?pa(t.updateTime):pa(e);return n.isEqual(Br.min())&&(n=pa(e)),new mo(n,t.transformResults||[])}(t,e)}))):[]}(t.writeResults,t.commitTime),n=pa(t.commitTime);return this.listener.Tr(n,e)}return Tr(!t.writeResults||0===t.writeResults.length),this.gr=!0,this.listener.Ir()},e.prototype.Ar=function(){var t={};t.database=ba(this.R),this.cr(t)},e.prototype.Er=function(t){var e=this,n={streamToken:this.lastStreamToken,writes:t.map((function(t){return Ea(e.R,t)}))};this.cr(n)},e}(bc),Ic=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).credentials=e,i.Hi=n,i.R=r,i.Rr=!1,i}return(0,dr.ZT)(e,t),e.prototype.br=function(){if(this.Rr)throw new vr(mr.FAILED_PRECONDITION,"The client has already been terminated.")},e.prototype.Ni=function(t,e,n){var r=this;return this.br(),this.credentials.getToken().then((function(i){return r.Hi.Ni(t,e,n,i)})).catch((function(t){throw t.code===mr.UNAUTHENTICATED&&r.credentials.invalidateToken(),t}))},e.prototype.Oi=function(t,e,n){var r=this;return this.br(),this.credentials.getToken().then((function(i){return r.Hi.Oi(t,e,n,i)})).catch((function(t){throw t.code===mr.UNAUTHENTICATED&&r.credentials.invalidateToken(),t}))},e.prototype.terminate=function(){this.Rr=!1},e}((function(){})),Ec=function(){function t(t,e){this.asyncQueue=t,this.onlineStateHandler=e,this.state="Unknown",this.vr=0,this.Pr=null,this.Vr=!0}return t.prototype.Sr=function(){var t=this;0===this.vr&&(this.Dr("Unknown"),this.Pr=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(function(){return t.Pr=null,t.Cr("Backend didn't respond within 10 seconds."),t.Dr("Offline"),Promise.resolve()})))},t.prototype.Nr=function(t){"Online"===this.state?this.Dr("Unknown"):(this.vr++,this.vr>=1&&(this.Fr(),this.Cr("Connection failed 1 times. Most recent error: "+t.toString()),this.Dr("Offline")))},t.prototype.set=function(t){this.Fr(),this.vr=0,"Online"===t&&(this.Vr=!1),this.Dr(t)},t.prototype.Dr=function(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))},t.prototype.Cr=function(t){var e="Could not reach Cloud Firestore backend. "+t+"\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.";this.Vr?(wr(e),this.Vr=!1):br("OnlineStateTracker",e)},t.prototype.Fr=function(){null!==this.Pr&&(this.Pr.cancel(),this.Pr=null)},t}(),Tc=function(t,e,n,r,i){var o=this;this.localStore=t,this.datastore=e,this.asyncQueue=n,this.remoteSyncer={},this.kr=[],this.Or=new Map,this.$r=new Set,this.Mr=[],this.Lr=i,this.Lr.di((function(t){n.enqueueAndForget((function(){return(0,dr.mG)(o,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(t){switch(t.label){case 0:return Nc(this)?(br("RemoteStore","Restarting streams for network reachability change."),[4,function(t){return(0,dr.mG)(this,void 0,void 0,(function(){var e;return(0,dr.Jh)(this,(function(n){switch(n.label){case 0:return(e=Cr(t)).$r.add(4),[4,Sc(e)];case 1:return n.sent(),e.Br.set("Unknown"),e.$r.delete(4),[4,Cc(e)];case 2:return n.sent(),[2]}}))}))}(this)]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))}))})),this.Br=new Ec(n,r)};function Cc(t){return(0,dr.mG)(this,void 0,void 0,(function(){var e,n;return(0,dr.Jh)(this,(function(r){switch(r.label){case 0:if(!Nc(t))return[3,4];e=0,n=t.Mr,r.label=1;case 1:return e<n.length?[4,(0,n[e])(!0)]:[3,4];case 2:r.sent(),r.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))}function Sc(t){return(0,dr.mG)(this,void 0,void 0,(function(){var e,n;return(0,dr.Jh)(this,(function(r){switch(r.label){case 0:e=0,n=t.Mr,r.label=1;case 1:return e<n.length?[4,(0,n[e])(!1)]:[3,4];case 2:r.sent(),r.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))}function xc(t,e){var n=Cr(t);n.Or.has(e.targetId)||(n.Or.set(e.targetId,e),Bc(n)?Oc(n):Yc(n).er()&&kc(n,e))}function Dc(t,e){var n=Cr(t),r=Yc(n);n.Or.delete(e),r.er()&&Rc(n,e),0===n.Or.size&&(r.er()?r.ir():Nc(n)&&n.Br.set("Unknown"))}function kc(t,e){t.qr.U(e.targetId),Yc(t).mr(e)}function Rc(t,e){t.qr.U(e),Yc(t).yr(e)}function Oc(t){t.qr=new ia({getRemoteKeysForTarget:function(e){return t.remoteSyncer.getRemoteKeysForTarget(e)},lt:function(e){return t.Or.get(e)||null}}),Yc(t).start(),t.Br.Sr()}function Bc(t){return Nc(t)&&!Yc(t).tr()&&t.Or.size>0}function Nc(t){return 0===Cr(t).$r.size}function Pc(t){t.qr=void 0}function Mc(t){return(0,dr.mG)(this,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(e){return t.Or.forEach((function(e,n){kc(t,e)})),[2]}))}))}function Lc(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(n){return Pc(t),Bc(t)?(t.Br.Nr(e),Oc(t)):t.Br.set("Unknown"),[2]}))}))}function Uc(t,e,n){return(0,dr.mG)(this,void 0,void 0,(function(){var r,i,o;return(0,dr.Jh)(this,(function(a){switch(a.label){case 0:if(t.Br.set("Online"),!(e instanceof na&&2===e.state&&e.cause))return[3,6];a.label=1;case 1:return a.trys.push([1,3,,5]),[4,function(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r,i,o;return(0,dr.Jh)(this,(function(a){switch(a.label){case 0:n=e.cause,r=0,i=e.targetIds,a.label=1;case 1:return r<i.length?(o=i[r],t.Or.has(o)?[4,t.remoteSyncer.rejectListen(o,n)]:[3,3]):[3,5];case 2:a.sent(),t.Or.delete(o),t.qr.removeTarget(o),a.label=3;case 3:a.label=4;case 4:return r++,[3,1];case 5:return[2]}}))}))}(t,e)];case 2:return a.sent(),[3,5];case 3:return r=a.sent(),br("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),r),[4,Fc(t,r)];case 4:return a.sent(),[3,5];case 5:return[3,13];case 6:if(e instanceof ta?t.qr.X(e):e instanceof ea?t.qr.rt(e):t.qr.et(e),n.isEqual(Br.min()))return[3,13];a.label=7;case 7:return a.trys.push([7,11,,13]),[4,Ou(t.localStore)];case 8:return i=a.sent(),n.compareTo(i)>=0?[4,function(t,e){var n=t.qr.ut(e);return n.targetChanges.forEach((function(n,r){if(n.resumeToken.approximateByteSize()>0){var i=t.Or.get(r);i&&t.Or.set(r,i.withResumeToken(n.resumeToken,e))}})),n.targetMismatches.forEach((function(e){var n=t.Or.get(e);if(n){t.Or.set(e,n.withResumeToken(qr.EMPTY_BYTE_STRING,n.snapshotVersion)),Rc(t,e);var r=new Es(n.target,e,1,n.sequenceNumber);kc(t,r)}})),t.remoteSyncer.applyRemoteEvent(n)}(t,n)]:[3,10];case 9:a.sent(),a.label=10;case 10:return[3,13];case 11:return br("RemoteStore","Failed to raise snapshot:",o=a.sent()),[4,Fc(t,o)];case 12:return a.sent(),[3,13];case 13:return[2]}}))}))}function Fc(t,e,n){return(0,dr.mG)(this,void 0,void 0,(function(){var r=this;return(0,dr.Jh)(this,(function(i){switch(i.label){case 0:if(!gs(e))throw e;return t.$r.add(1),[4,Sc(t)];case 1:return i.sent(),t.Br.set("Offline"),n||(n=function(){return Ou(t.localStore)}),t.asyncQueue.enqueueRetryable((function(){return(0,dr.mG)(r,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(e){switch(e.label){case 0:return br("RemoteStore","Retrying IndexedDB access"),[4,n()];case 1:return e.sent(),t.$r.delete(1),[4,Cc(t)];case 2:return e.sent(),[2]}}))}))})),[2]}}))}))}function Qc(t,e){return e().catch((function(n){return Fc(t,n,e)}))}function jc(t){return(0,dr.mG)(this,void 0,void 0,(function(){var e,n,r,i,o;return(0,dr.Jh)(this,(function(a){switch(a.label){case 0:e=Cr(t),n=Jc(e),r=e.kr.length>0?e.kr[e.kr.length-1].batchId:-1,a.label=1;case 1:if(!function(t){return Nc(t)&&t.kr.length<10}(e))return[3,7];a.label=2;case 2:return a.trys.push([2,4,,6]),[4,Pu(e.localStore,r)];case 3:return null===(i=a.sent())?(0===e.kr.length&&n.ir(),[3,7]):(r=i.batchId,function(t,e){t.kr.push(e);var n=Jc(t);n.er()&&n.pr&&n.Er(e.mutations)}(e,i),[3,6]);case 4:return o=a.sent(),[4,Fc(e,o)];case 5:return a.sent(),[3,6];case 6:return[3,1];case 7:return qc(e)&&Gc(e),[2]}}))}))}function qc(t){return Nc(t)&&!Jc(t).tr()&&t.kr.length>0}function Gc(t){Jc(t).start()}function Vc(t){return(0,dr.mG)(this,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(e){return Jc(t).Ar(),[2]}))}))}function zc(t){return(0,dr.mG)(this,void 0,void 0,(function(){var e,n,r,i;return(0,dr.Jh)(this,(function(o){for(e=Jc(t),n=0,r=t.kr;n<r.length;n++)i=r[n],e.Er(i.mutations);return[2]}))}))}function Hc(t,e,n){return(0,dr.mG)(this,void 0,void 0,(function(){var r,i;return(0,dr.Jh)(this,(function(o){switch(o.label){case 0:return r=t.kr.shift(),i=Is.from(r,e,n),[4,Qc(t,(function(){return t.remoteSyncer.applySuccessfulWrite(i)}))];case 1:return o.sent(),[4,jc(t)];case 2:return o.sent(),[2]}}))}))}function Kc(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(n){switch(n.label){case 0:return e&&Jc(t).pr?[4,function(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r;return(0,dr.Jh)(this,(function(i){switch(i.label){case 0:return Po(r=e.code)&&r!==mr.ABORTED?(n=t.kr.shift(),Jc(t).sr(),[4,Qc(t,(function(){return t.remoteSyncer.rejectFailedWrite(n.batchId,e)}))]):[3,3];case 1:return i.sent(),[4,jc(t)];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))}(t,e)]:[3,2];case 1:n.sent(),n.label=2;case 2:return qc(t)&&Gc(t),[2]}}))}))}function Wc(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n;return(0,dr.Jh)(this,(function(r){switch(r.label){case 0:return n=Cr(t),e?(n.$r.delete(2),[4,Cc(n)]):[3,2];case 1:return r.sent(),[3,5];case 2:return e?[3,4]:(n.$r.add(2),[4,Sc(n)]);case 3:r.sent(),n.Br.set("Unknown"),r.label=4;case 4:r.label=5;case 5:return[2]}}))}))}function Yc(t){var e=this;return t.Ur||(t.Ur=function(t,e,n){var r=Cr(t);return r.br(),new wc(e,r.Hi,r.credentials,r.R,n)}(t.datastore,t.asyncQueue,{Ii:Mc.bind(null,t),Ri:Lc.bind(null,t),_r:Uc.bind(null,t)}),t.Mr.push((function(n){return(0,dr.mG)(e,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(e){switch(e.label){case 0:return n?(t.Ur.sr(),Bc(t)?Oc(t):t.Br.set("Unknown"),[3,3]):[3,1];case 1:return[4,t.Ur.stop()];case 2:e.sent(),Pc(t),e.label=3;case 3:return[2]}}))}))}))),t.Ur}function Jc(t){var e=this;return t.Qr||(t.Qr=function(t,e,n){var r=Cr(t);return r.br(),new _c(e,r.Hi,r.credentials,r.R,n)}(t.datastore,t.asyncQueue,{Ii:Vc.bind(null,t),Ri:Kc.bind(null,t),Ir:zc.bind(null,t),Tr:Hc.bind(null,t)}),t.Mr.push((function(n){return(0,dr.mG)(e,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(e){switch(e.label){case 0:return n?(t.Qr.sr(),[4,jc(t)]):[3,2];case 1:return e.sent(),[3,4];case 2:return[4,t.Qr.stop()];case 3:e.sent(),t.kr.length>0&&(br("RemoteStore","Stopping write stream with "+t.kr.length+" pending writes"),t.kr=[]),e.label=4;case 4:return[2]}}))}))}))),t.Qr}var Xc=function(){function t(t,e,n,r,i){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new cs,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((function(t){}))}return t.createAndSchedule=function(e,n,r,i,o){var a=new t(e,n,Date.now()+r,i,o);return a.start(r),a},t.prototype.start=function(t){var e=this;this.timerHandle=setTimeout((function(){return e.handleDelayElapsed()}),t)},t.prototype.skipDelay=function(){return this.handleDelayElapsed()},t.prototype.cancel=function(t){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new vr(mr.CANCELLED,"Operation cancelled"+(t?": "+t:""))))},t.prototype.handleDelayElapsed=function(){var t=this;this.asyncQueue.enqueueAndForget((function(){return null!==t.timerHandle?(t.clearTimeout(),t.op().then((function(e){return t.deferred.resolve(e)}))):Promise.resolve()}))},t.prototype.clearTimeout=function(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)},t}();function Zc(t,e){if(wr("AsyncQueue",e+": "+t),gs(t))return new vr(mr.UNAVAILABLE,e+": "+t);throw t}var $c=function(){function t(t){this.comparator=t?function(e,n){return t(e,n)||$r.comparator(e.key,n.key)}:function(t,e){return $r.comparator(t.key,e.key)},this.keyedMap=zo(),this.sortedSet=new Lo(this.comparator)}return t.emptySet=function(e){return new t(e.comparator)},t.prototype.has=function(t){return null!=this.keyedMap.get(t)},t.prototype.get=function(t){return this.keyedMap.get(t)},t.prototype.first=function(){return this.sortedSet.minKey()},t.prototype.last=function(){return this.sortedSet.maxKey()},t.prototype.isEmpty=function(){return this.sortedSet.isEmpty()},t.prototype.indexOf=function(t){var e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1},Object.defineProperty(t.prototype,"size",{get:function(){return this.sortedSet.size},enumerable:!1,configurable:!0}),t.prototype.forEach=function(t){this.sortedSet.inorderTraversal((function(e,n){return t(e),!1}))},t.prototype.add=function(t){var e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))},t.prototype.delete=function(t){var e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this},t.prototype.isEqual=function(e){if(!(e instanceof t))return!1;if(this.size!==e.size)return!1;for(var n=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();n.hasNext();){var i=n.getNext().key,o=r.getNext().key;if(!i.isEqual(o))return!1}return!0},t.prototype.toString=function(){var t=[];return this.forEach((function(e){t.push(e.toString())})),0===t.length?"DocumentSet ()":"DocumentSet (\n "+t.join(" \n")+"\n)"},t.prototype.copy=function(e,n){var r=new t;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=n,r},t}(),th=function(){function t(){this.Kr=new Lo($r.comparator)}return t.prototype.track=function(t){var e=t.doc.key,n=this.Kr.get(e);n?0!==t.type&&3===n.type?this.Kr=this.Kr.insert(e,t):3===t.type&&1!==n.type?this.Kr=this.Kr.insert(e,{type:n.type,doc:t.doc}):2===t.type&&2===n.type?this.Kr=this.Kr.insert(e,{type:2,doc:t.doc}):2===t.type&&0===n.type?this.Kr=this.Kr.insert(e,{type:0,doc:t.doc}):1===t.type&&0===n.type?this.Kr=this.Kr.remove(e):1===t.type&&2===n.type?this.Kr=this.Kr.insert(e,{type:1,doc:n.doc}):0===t.type&&1===n.type?this.Kr=this.Kr.insert(e,{type:2,doc:t.doc}):Er():this.Kr=this.Kr.insert(e,t)},t.prototype.jr=function(){var t=[];return this.Kr.inorderTraversal((function(e,n){t.push(n)})),t},t}(),eh=function(){function t(t,e,n,r,i,o,a,s){this.query=t,this.docs=e,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=o,this.syncStateChanged=a,this.excludesMetadataChanges=s}return t.fromInitialDocuments=function(e,n,r,i){var o=[];return n.forEach((function(t){o.push({type:0,doc:t})})),new t(e,n,$c.emptySet(n),o,r,i,!0,!1)},Object.defineProperty(t.prototype,"hasPendingWrites",{get:function(){return!this.mutatedKeys.isEmpty()},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){if(!(this.fromCache===t.fromCache&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&Ki(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;var e=this.docChanges,n=t.docChanges;if(e.length!==n.length)return!1;for(var r=0;r<e.length;r++)if(e[r].type!==n[r].type||!e[r].doc.isEqual(n[r].doc))return!1;return!0},t}(),nh=function(){this.Wr=void 0,this.listeners=[]},rh=function(){this.queries=new hu((function(t){return Wi(t)}),Ki),this.onlineState="Unknown",this.Gr=new Set};function ih(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r,i,o,a,s,u;return(0,dr.Jh)(this,(function(c){switch(c.label){case 0:if(n=Cr(t),r=e.query,i=!1,(o=n.queries.get(r))||(i=!0,o=new nh),!i)return[3,4];c.label=1;case 1:return c.trys.push([1,3,,4]),a=o,[4,n.onListen(r)];case 2:return a.Wr=c.sent(),[3,4];case 3:return s=c.sent(),u=Zc(s,"Initialization of query '"+Yi(e.query)+"' failed"),[2,void e.onError(u)];case 4:return n.queries.set(r,o),o.listeners.push(e),e.zr(n.onlineState),o.Wr&&e.Hr(o.Wr)&&uh(n),[2]}}))}))}function oh(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r,i,o,a;return(0,dr.Jh)(this,(function(s){return n=Cr(t),r=e.query,i=!1,(o=n.queries.get(r))&&(a=o.listeners.indexOf(e))>=0&&(o.listeners.splice(a,1),i=0===o.listeners.length),i?[2,(n.queries.delete(r),n.onUnlisten(r))]:[2]}))}))}function ah(t,e){for(var n=Cr(t),r=!1,i=0,o=e;i<o.length;i++){var a=o[i],s=a.query,u=n.queries.get(s);if(u){for(var c=0,h=u.listeners;c<h.length;c++)h[c].Hr(a)&&(r=!0);u.Wr=a}}r&&uh(n)}function sh(t,e,n){var r=Cr(t),i=r.queries.get(e);if(i)for(var o=0,a=i.listeners;o<a.length;o++)a[o].onError(n);r.queries.delete(e)}function uh(t){t.Gr.forEach((function(t){t.next()}))}var ch=function(){function t(t,e,n){this.query=t,this.Jr=e,this.Yr=!1,this.Xr=null,this.onlineState="Unknown",this.options=n||{}}return t.prototype.Hr=function(t){if(!this.options.includeMetadataChanges){for(var e=[],n=0,r=t.docChanges;n<r.length;n++){var i=r[n];3!==i.type&&e.push(i)}t=new eh(t.query,t.docs,t.oldDocs,e,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0)}var o=!1;return this.Yr?this.Zr(t)&&(this.Jr.next(t),o=!0):this.eo(t,this.onlineState)&&(this.no(t),o=!0),this.Xr=t,o},t.prototype.onError=function(t){this.Jr.error(t)},t.prototype.zr=function(t){this.onlineState=t;var e=!1;return this.Xr&&!this.Yr&&this.eo(this.Xr,t)&&(this.no(this.Xr),e=!0),e},t.prototype.eo=function(t,e){if(!t.fromCache)return!0;var n="Offline"!==e;return!(this.options.so&&n||t.docs.isEmpty()&&"Offline"!==e)},t.prototype.Zr=function(t){if(t.docChanges.length>0)return!0;var e=this.Xr&&this.Xr.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&!0===this.options.includeMetadataChanges},t.prototype.no=function(t){t=eh.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache),this.Yr=!0,this.Jr.next(t)},t}(),hh=function(){function t(t,e){this.payload=t,this.byteLength=e}return t.prototype.io=function(){return"metadata"in this.payload},t}(),lh=function(){function t(t){this.R=t}return t.prototype.qn=function(t){return va(this.R,t)},t.prototype.Un=function(t){return t.metadata.exists?Ia(this.R,t.document,!1):gi.newNoDocument(this.qn(t.metadata.name),this.Qn(t.metadata.readTime))},t.prototype.Qn=function(t){return pa(t)},t}();!function(){function t(t,e,n){this.ro=t,this.localStore=e,this.R=n,this.queries=[],this.documents=[],this.progress=fh(t)}t.prototype.oo=function(t){this.progress.bytesLoaded+=t.byteLength;var e=this.progress.documentsLoaded;return t.payload.namedQuery?this.queries.push(t.payload.namedQuery):t.payload.documentMetadata?(this.documents.push({metadata:t.payload.documentMetadata}),t.payload.documentMetadata.exists||++e):t.payload.document&&(this.documents[this.documents.length-1].document=t.payload.document,++e),e!==this.progress.documentsLoaded?(this.progress.documentsLoaded=e,Object.assign({},this.progress)):null},t.prototype.co=function(t){for(var e=new Map,n=new lh(this.R),r=0,i=t;r<i.length;r++){var o=i[r];if(o.metadata.queries)for(var a=n.qn(o.metadata.name),s=0,u=o.metadata.queries;s<u.length;s++){var c=u[s],h=(e.get(c)||Yo()).add(a);e.set(c,h)}}return e},t.prototype.complete=function(){return(0,dr.mG)(this,void 0,void 0,(function(){var t,e,n,r,i;return(0,dr.Jh)(this,(function(o){switch(o.label){case 0:return[4,qu(this.localStore,new lh(this.R),this.documents,this.ro.id)];case 1:t=o.sent(),e=this.co(this.documents),n=0,r=this.queries,o.label=2;case 2:return n<r.length?(i=r[n],[4,Gu(this.localStore,i,e.get(i.name))]):[3,5];case 3:o.sent(),o.label=4;case 4:return n++,[3,2];case 5:return[2,(this.progress.taskState="Success",new Eu(Object.assign({},this.progress),t))]}}))}))}}();function fh(t){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:t.totalDocuments,totalBytes:t.totalBytes}}var ph=function(t){this.key=t},dh=function(t){this.key=t},gh=function(){function t(t,e){this.query=t,this.uo=e,this.ao=null,this.current=!1,this.ho=Yo(),this.mutatedKeys=Yo(),this.lo=Xi(t),this.fo=new $c(this.lo)}return Object.defineProperty(t.prototype,"wo",{get:function(){return this.uo},enumerable:!1,configurable:!0}),t.prototype._o=function(t,e){var n=this,r=e?e.mo:new th,i=e?e.fo:this.fo,o=e?e.mutatedKeys:this.mutatedKeys,a=i,s=!1,u=Fi(this.query)&&i.size===this.query.limit?i.last():null,c=Qi(this.query)&&i.size===this.query.limit?i.first():null;if(t.inorderTraversal((function(t,e){var h=i.get(t),l=Ji(n.query,e)?e:null,f=!!h&&n.mutatedKeys.has(h.key),p=!!l&&(l.hasLocalMutations||n.mutatedKeys.has(l.key)&&l.hasCommittedMutations),d=!1;h&&l?h.data.isEqual(l.data)?f!==p&&(r.track({type:3,doc:l}),d=!0):n.yo(h,l)||(r.track({type:2,doc:l}),d=!0,(u&&n.lo(l,u)>0||c&&n.lo(l,c)<0)&&(s=!0)):!h&&l?(r.track({type:0,doc:l}),d=!0):h&&!l&&(r.track({type:1,doc:h}),d=!0,(u||c)&&(s=!0)),d&&(l?(a=a.add(l),o=p?o.add(t):o.delete(t)):(a=a.delete(t),o=o.delete(t)))})),Fi(this.query)||Qi(this.query))for(;a.size>this.query.limit;){var h=Fi(this.query)?a.last():a.first();a=a.delete(h.key),o=o.delete(h.key),r.track({type:1,doc:h})}return{fo:a,mo:r,Nn:s,mutatedKeys:o}},t.prototype.yo=function(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations},t.prototype.applyChanges=function(t,e,n){var r=this,i=this.fo;this.fo=t.fo,this.mutatedKeys=t.mutatedKeys;var o=t.mo.jr();o.sort((function(t,e){return function(t,e){var n=function(t){switch(t){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return Er()}};return n(t)-n(e)}(t.type,e.type)||r.lo(t.doc,e.doc)})),this.po(n);var a=e?this.Eo():[],s=0===this.ho.size&&this.current?1:0,u=s!==this.ao;return this.ao=s,0!==o.length||u?{snapshot:new eh(this.query,t.fo,i,o,t.mutatedKeys,0===s,u,!1),To:a}:{To:a}},t.prototype.zr=function(t){return this.current&&"Offline"===t?(this.current=!1,this.applyChanges({fo:this.fo,mo:new th,mutatedKeys:this.mutatedKeys,Nn:!1},!1)):{To:[]}},t.prototype.Io=function(t){return!this.uo.has(t)&&!!this.fo.has(t)&&!this.fo.get(t).hasLocalMutations},t.prototype.po=function(t){var e=this;t&&(t.addedDocuments.forEach((function(t){return e.uo=e.uo.add(t)})),t.modifiedDocuments.forEach((function(t){})),t.removedDocuments.forEach((function(t){return e.uo=e.uo.delete(t)})),this.current=t.current)},t.prototype.Eo=function(){var t=this;if(!this.current)return[];var e=this.ho;this.ho=Yo(),this.fo.forEach((function(e){t.Io(e.key)&&(t.ho=t.ho.add(e.key))}));var n=[];return e.forEach((function(e){t.ho.has(e)||n.push(new dh(e))})),this.ho.forEach((function(t){e.has(t)||n.push(new ph(t))})),n},t.prototype.Ao=function(t){this.uo=t.Bn,this.ho=Yo();var e=this._o(t.documents);return this.applyChanges(e,!0)},t.prototype.Ro=function(){return eh.fromInitialDocuments(this.query,this.fo,this.mutatedKeys,0===this.ao)},t}(),mh=function(t,e,n){this.query=t,this.targetId=e,this.view=n},vh=function(t){this.key=t,this.bo=!1},yh=function(){function t(t,e,n,r,i,o){this.localStore=t,this.remoteStore=e,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=o,this.vo={},this.Po=new hu((function(t){return Wi(t)}),Ki),this.Vo=new Map,this.So=new Set,this.Do=new Lo($r.comparator),this.Co=new Map,this.No=new zu,this.xo={},this.Fo=new Map,this.ko=Zs.Yt(),this.onlineState="Unknown",this.Oo=void 0}return Object.defineProperty(t.prototype,"isPrimaryClient",{get:function(){return!0===this.Oo},enumerable:!1,configurable:!0}),t}();function Ah(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r,i,o,a,s;return(0,dr.Jh)(this,(function(u){switch(u.label){case 0:return n=Wh(t),(o=n.Po.get(e))?(r=o.targetId,n.sharedClientState.addLocalQueryTarget(r),i=o.view.Ro(),[3,4]):[3,1];case 1:return[4,Mu(n.localStore,zi(e))];case 2:return a=u.sent(),s=n.sharedClientState.addLocalQueryTarget(a.targetId),r=a.targetId,[4,bh(n,e,r,"current"===s)];case 3:i=u.sent(),n.isPrimaryClient&&xc(n.remoteStore,a),u.label=4;case 4:return[2,i]}}))}))}function bh(t,e,n,r){return(0,dr.mG)(this,void 0,void 0,(function(){var i,o,a,s,u,c;return(0,dr.Jh)(this,(function(h){switch(h.label){case 0:return t.$o=function(e,n,r){return function(t,e,n,r){return(0,dr.mG)(this,void 0,void 0,(function(){var i,o,a;return(0,dr.Jh)(this,(function(s){switch(s.label){case 0:return(i=e.view._o(n)).Nn?[4,Uu(t.localStore,e.query,!1).then((function(t){var n=t.documents;return e.view._o(n,i)}))]:[3,2];case 1:i=s.sent(),s.label=2;case 2:return o=r&&r.targetChanges.get(e.targetId),a=e.view.applyChanges(i,t.isPrimaryClient,o),[2,(Bh(t,e.targetId,a.To),a.snapshot)]}}))}))}(t,e,n,r)},[4,Uu(t.localStore,e,!0)];case 1:return i=h.sent(),o=new gh(e,i.Bn),a=o._o(i.documents),s=$o.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==t.onlineState),u=o.applyChanges(a,t.isPrimaryClient,s),Bh(t,n,u.To),c=new mh(e,n,o),[2,(t.Po.set(e,c),t.Vo.has(n)?t.Vo.get(n).push(e):t.Vo.set(n,[e]),u.snapshot)]}}))}))}function wh(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r,i;return(0,dr.Jh)(this,(function(o){switch(o.label){case 0:return n=Cr(t),r=n.Po.get(e),(i=n.Vo.get(r.targetId)).length>1?[2,(n.Vo.set(r.targetId,i.filter((function(t){return!Ki(t,e)}))),void n.Po.delete(e))]:n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(r.targetId),n.sharedClientState.isActiveQueryTarget(r.targetId)?[3,2]:[4,Lu(n.localStore,r.targetId,!1).then((function(){n.sharedClientState.clearQueryState(r.targetId),Dc(n.remoteStore,r.targetId),Rh(n,r.targetId)})).catch(ru)]):[3,3];case 1:o.sent(),o.label=2;case 2:return[3,5];case 3:return Rh(n,r.targetId),[4,Lu(n.localStore,r.targetId,!0)];case 4:o.sent(),o.label=5;case 5:return[2]}}))}))}function _h(t,e,n){return(0,dr.mG)(this,void 0,void 0,(function(){var r,i,o,a;return(0,dr.Jh)(this,(function(s){switch(s.label){case 0:r=Yh(t),s.label=1;case 1:return s.trys.push([1,5,,6]),[4,function(t,e){var n,r=Cr(t),i=Or.now(),o=e.reduce((function(t,e){return t.add(e.key)}),Yo());return r.persistence.runTransaction("Locally write mutations","readwrite",(function(t){return r.Mn.pn(t,o).next((function(o){n=o;for(var a=[],s=0,u=e;s<u.length;s++){var c=u[s],h=_o(c,n.get(c.key));null!=h&&a.push(new Co(c.key,h,di(h.toProto().mapValue),vo.exists(!0)))}return r._n.addMutationBatch(t,i,a,e)}))})).then((function(t){return t.applyToLocalDocumentSet(n),{batchId:t.batchId,changes:n}}))}(r.localStore,e)];case 2:return i=s.sent(),r.sharedClientState.addPendingMutation(i.batchId),function(t,e,n){var r=t.xo[t.currentUser.toKey()];r||(r=new Lo(Dr)),r=r.insert(e,n),t.xo[t.currentUser.toKey()]=r}(r,i.batchId,n),[4,Mh(r,i.changes)];case 3:return s.sent(),[4,jc(r.remoteStore)];case 4:return s.sent(),[3,6];case 5:return o=s.sent(),a=Zc(o,"Failed to persist write"),n.reject(a),[3,6];case 6:return[2]}}))}))}function Ih(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r;return(0,dr.Jh)(this,(function(i){switch(i.label){case 0:n=Cr(t),i.label=1;case 1:return i.trys.push([1,4,,6]),[4,Bu(n.localStore,e)];case 2:return r=i.sent(),e.targetChanges.forEach((function(t,e){var r=n.Co.get(e);r&&(Tr(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1),t.addedDocuments.size>0?r.bo=!0:t.modifiedDocuments.size>0?Tr(r.bo):t.removedDocuments.size>0&&(Tr(r.bo),r.bo=!1))})),[4,Mh(n,r,e)];case 3:return i.sent(),[3,6];case 4:return[4,ru(i.sent())];case 5:return i.sent(),[3,6];case 6:return[2]}}))}))}function Eh(t,e,n){var r=Cr(t);if(r.isPrimaryClient&&0===n||!r.isPrimaryClient&&1===n){var i=[];r.Po.forEach((function(t,n){var r=n.view.zr(e);r.snapshot&&i.push(r.snapshot)})),function(t,e){var n=Cr(t);n.onlineState=e;var r=!1;n.queries.forEach((function(t,n){for(var i=0,o=n.listeners;i<o.length;i++)o[i].zr(e)&&(r=!0)})),r&&uh(n)}(r.eventManager,e),i.length&&r.vo._r(i),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}function Th(t,e,n){return(0,dr.mG)(this,void 0,void 0,(function(){var r,i,o,a,s,u;return(0,dr.Jh)(this,(function(c){switch(c.label){case 0:return(r=Cr(t)).sharedClientState.updateQueryState(e,"rejected",n),i=r.Co.get(e),(o=i&&i.key)?(a=(a=new Lo($r.comparator)).insert(o,gi.newNoDocument(o,Br.min())),s=Yo().add(o),u=new Zo(Br.min(),new Map,new Qo(Dr),a,s),[4,Ih(r,u)]):[3,2];case 1:return c.sent(),r.Do=r.Do.remove(o),r.Co.delete(e),Ph(r),[3,4];case 2:return[4,Lu(r.localStore,e,!1).then((function(){return Rh(r,e,n)})).catch(ru)];case 3:c.sent(),c.label=4;case 4:return[2]}}))}))}function Ch(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r,i;return(0,dr.Jh)(this,(function(o){switch(o.label){case 0:n=Cr(t),r=e.batch.batchId,o.label=1;case 1:return o.trys.push([1,4,,6]),[4,Ru(n.localStore,e)];case 2:return i=o.sent(),kh(n,r,null),Dh(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),[4,Mh(n,i)];case 3:return o.sent(),[3,6];case 4:return[4,ru(o.sent())];case 5:return o.sent(),[3,6];case 6:return[2]}}))}))}function Sh(t,e,n){return(0,dr.mG)(this,void 0,void 0,(function(){var r,i;return(0,dr.Jh)(this,(function(o){switch(o.label){case 0:r=Cr(t),o.label=1;case 1:return o.trys.push([1,4,,6]),[4,function(t,e){var n=Cr(t);return n.persistence.runTransaction("Reject batch","readwrite-primary",(function(t){var r;return n._n.lookupMutationBatch(t,e).next((function(e){return Tr(null!==e),r=e.keys(),n._n.removeMutationBatch(t,e)})).next((function(){return n._n.performConsistencyCheck(t)})).next((function(){return n.Mn.pn(t,r)}))}))}(r.localStore,e)];case 2:return i=o.sent(),kh(r,e,n),Dh(r,e),r.sharedClientState.updateMutationState(e,"rejected",n),[4,Mh(r,i)];case 3:return o.sent(),[3,6];case 4:return[4,ru(o.sent())];case 5:return o.sent(),[3,6];case 6:return[2]}}))}))}function xh(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r,i,o,a;return(0,dr.Jh)(this,(function(s){switch(s.label){case 0:Nc((n=Cr(t)).remoteStore)||br("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled."),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,function(t){var e=Cr(t);return e.persistence.runTransaction("Get highest unacknowledged batch id","readonly",(function(t){return e._n.getHighestUnacknowledgedBatchId(t)}))}(n.localStore)];case 2:return-1===(r=s.sent())?[2,void e.resolve()]:((i=n.Fo.get(r)||[]).push(e),n.Fo.set(r,i),[3,4]);case 3:return o=s.sent(),a=Zc(o,"Initialization of waitForPendingWrites() operation failed"),e.reject(a),[3,4];case 4:return[2]}}))}))}function Dh(t,e){(t.Fo.get(e)||[]).forEach((function(t){t.resolve()})),t.Fo.delete(e)}function kh(t,e,n){var r=Cr(t),i=r.xo[r.currentUser.toKey()];if(i){var o=i.get(e);o&&(n?o.reject(n):o.resolve(),i=i.remove(e)),r.xo[r.currentUser.toKey()]=i}}function Rh(t,e,n){void 0===n&&(n=null),t.sharedClientState.removeLocalQueryTarget(e);for(var r=0,i=t.Vo.get(e);r<i.length;r++){var o=i[r];t.Po.delete(o),n&&t.vo.Mo(o,n)}t.Vo.delete(e),t.isPrimaryClient&&t.No.Zn(e).forEach((function(e){t.No.containsKey(e)||Oh(t,e)}))}function Oh(t,e){t.So.delete(e.path.canonicalString());var n=t.Do.get(e);null!==n&&(Dc(t.remoteStore,n),t.Do=t.Do.remove(e),t.Co.delete(n),Ph(t))}function Bh(t,e,n){for(var r=0,i=n;r<i.length;r++){var o=i[r];o instanceof ph?(t.No.addReference(o.key,e),Nh(t,o)):o instanceof dh?(br("SyncEngine","Document no longer in limbo: "+o.key),t.No.removeReference(o.key,e),t.No.containsKey(o.key)||Oh(t,o.key)):Er()}}function Nh(t,e){var n=e.key,r=n.path.canonicalString();t.Do.get(n)||t.So.has(r)||(br("SyncEngine","New document in limbo: "+n),t.So.add(r),Ph(t))}function Ph(t){for(;t.So.size>0&&t.Do.size<t.maxConcurrentLimboResolutions;){var e=t.So.values().next().value;t.So.delete(e);var n=new $r(Ur.fromString(e)),r=t.ko.next();t.Co.set(r,new vh(n)),t.Do=t.Do.insert(n,r),xc(t.remoteStore,new Es(zi(Ui(n.path)),r,2,gr.o))}}function Mh(t,e,n){return(0,dr.mG)(this,void 0,void 0,(function(){var r,i,o,a;return(0,dr.Jh)(this,(function(s){switch(s.label){case 0:return r=Cr(t),i=[],o=[],a=[],r.Po.isEmpty()?[3,3]:(r.Po.forEach((function(t,s){a.push(r.$o(s,e,n).then((function(t){if(t){r.isPrimaryClient&&r.sharedClientState.updateQueryState(s.targetId,t.fromCache?"not-current":"current"),i.push(t);var e=Cu.Pn(s.targetId,t);o.push(e)}})))})),[4,Promise.all(a)]);case 1:return s.sent(),r.vo._r(i),[4,function(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r,i,o,a,s,u,c,h;return(0,dr.Jh)(this,(function(l){switch(l.label){case 0:n=Cr(t),l.label=1;case 1:return l.trys.push([1,3,,4]),[4,n.persistence.runTransaction("notifyLocalViewChanges","readwrite",(function(t){return hs.forEach(e,(function(e){return hs.forEach(e.bn,(function(r){return n.persistence.referenceDelegate.addReference(t,e.targetId,r)})).next((function(){return hs.forEach(e.vn,(function(r){return n.persistence.referenceDelegate.removeReference(t,e.targetId,r)}))}))}))}))];case 2:return l.sent(),[3,4];case 3:if(!gs(r=l.sent()))throw r;return br("LocalStore","Failed to update sequence numbers: "+r),[3,4];case 4:for(i=0,o=e;i<o.length;i++)a=o[i],s=a.targetId,a.fromCache||(u=n.Fn.get(s),c=u.snapshotVersion,h=u.withLastLimboFreeSnapshotVersion(c),n.Fn=n.Fn.insert(s,h));return[2]}}))}))}(r.localStore,o)];case 2:s.sent(),s.label=3;case 3:return[2]}}))}))}function Lh(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r;return(0,dr.Jh)(this,(function(i){switch(i.label){case 0:return(n=Cr(t)).currentUser.isEqual(e)?[3,3]:(br("SyncEngine","User change. New user:",e.toKey()),[4,ku(n.localStore,e)]);case 1:return r=i.sent(),n.currentUser=e,function(t,e){t.Fo.forEach((function(t){t.forEach((function(t){t.reject(new vr(mr.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))}))})),t.Fo.clear()}(n),n.sharedClientState.handleUserChange(e,r.removedBatchIds,r.addedBatchIds),[4,Mh(n,r.Ln)];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))}function Uh(t,e){var n=Cr(t),r=n.Co.get(e);if(r&&r.bo)return Yo().add(r.key);var i=Yo(),o=n.Vo.get(e);if(!o)return i;for(var a=0,s=o;a<s.length;a++){var u=s[a],c=n.Po.get(u);i=i.unionWith(c.view.wo)}return i}function Fh(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r,i;return(0,dr.Jh)(this,(function(o){switch(o.label){case 0:return[4,Uu((n=Cr(t)).localStore,e.query,!0)];case 1:return r=o.sent(),i=e.view.Ao(r),[2,(n.isPrimaryClient&&Bh(n,e.targetId,i.To),i)]}}))}))}function Qh(t){return(0,dr.mG)(this,void 0,void 0,(function(){var e;return(0,dr.Jh)(this,(function(n){return[2,Qu((e=Cr(t)).localStore).then((function(t){return Mh(e,t)}))]}))}))}function jh(t,e,n,r){return(0,dr.mG)(this,void 0,void 0,(function(){var i,o;return(0,dr.Jh)(this,(function(a){switch(a.label){case 0:return[4,function(t,e){var n=Cr(t),r=Cr(n._n);return n.persistence.runTransaction("Lookup mutation documents","readonly",(function(t){return r.jt(t,e).next((function(e){return e?n.Mn.pn(t,e):hs.resolve(null)}))}))}((i=Cr(t)).localStore,e)];case 1:return null===(o=a.sent())?[3,6]:"pending"!==n?[3,3]:[4,jc(i.remoteStore)];case 2:return a.sent(),[3,4];case 3:"acknowledged"===n||"rejected"===n?(kh(i,e,r||null),Dh(i,e),function(t,e){Cr(Cr(t)._n).Gt(e)}(i.localStore,e)):Er(),a.label=4;case 4:return[4,Mh(i,o)];case 5:return a.sent(),[3,7];case 6:br("SyncEngine","Cannot apply mutation batch with id: "+e),a.label=7;case 7:return[2]}}))}))}function qh(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r,i,o,a,s,u,c;return(0,dr.Jh)(this,(function(h){switch(h.label){case 0:return Wh(n=Cr(t)),Yh(n),!0!==e||!0===n.Oo?[3,3]:(r=n.sharedClientState.getAllActiveQueryTargets(),[4,Gh(n,r.toArray())]);case 1:return i=h.sent(),n.Oo=!0,[4,Wc(n.remoteStore,!0)];case 2:for(h.sent(),o=0,a=i;o<a.length;o++)s=a[o],xc(n.remoteStore,s);return[3,7];case 3:return!1!==e||!1===n.Oo?[3,7]:(u=[],c=Promise.resolve(),n.Vo.forEach((function(t,e){n.sharedClientState.isLocalQueryTarget(e)?u.push(e):c=c.then((function(){return Rh(n,e),Lu(n.localStore,e,!0)})),Dc(n.remoteStore,e)})),[4,c]);case 4:return h.sent(),[4,Gh(n,u)];case 5:return h.sent(),function(t){var e=Cr(t);e.Co.forEach((function(t,n){Dc(e.remoteStore,n)})),e.No.ts(),e.Co=new Map,e.Do=new Lo($r.comparator)}(n),n.Oo=!1,[4,Wc(n.remoteStore,!1)];case 6:h.sent(),h.label=7;case 7:return[2]}}))}))}function Gh(t,e,n){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r,i,o,a,s,u,c,h,l,f,p,d,g;return(0,dr.Jh)(this,(function(m){switch(m.label){case 0:n=Cr(t),r=[],i=[],o=0,a=e,m.label=1;case 1:return o<a.length?(s=a[o],u=void 0,(c=n.Vo.get(s))&&0!==c.length?[4,Mu(n.localStore,zi(c[0]))]:[3,7]):[3,13];case 2:u=m.sent(),h=0,l=c,m.label=3;case 3:return h<l.length?(f=l[h],p=n.Po.get(f),[4,Fh(n,p)]):[3,6];case 4:(d=m.sent()).snapshot&&i.push(d.snapshot),m.label=5;case 5:return h++,[3,3];case 6:return[3,11];case 7:return[4,Fu(n.localStore,s)];case 8:return g=m.sent(),[4,Mu(n.localStore,g)];case 9:return u=m.sent(),[4,bh(n,Vh(g),s,!1)];case 10:m.sent(),m.label=11;case 11:r.push(u),m.label=12;case 12:return o++,[3,1];case 13:return[2,(n.vo._r(i),r)]}}))}))}function Vh(t){return Li(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,"F",t.startAt,t.endAt)}function zh(t){var e=Cr(t);return Cr(Cr(e.localStore).persistence).fn()}function Hh(t,e,n,r){return(0,dr.mG)(this,void 0,void 0,(function(){var i,o,a;return(0,dr.Jh)(this,(function(s){switch(s.label){case 0:return(i=Cr(t)).Oo?(br("SyncEngine","Ignoring unexpected query state notification."),[3,8]):[3,1];case 1:if(!i.Vo.has(e))return[3,8];switch(n){case"current":case"not-current":return[3,2];case"rejected":return[3,5]}return[3,7];case 2:return[4,Qu(i.localStore)];case 3:return o=s.sent(),a=Zo.createSynthesizedRemoteEventForCurrentChange(e,"current"===n),[4,Mh(i,o,a)];case 4:return s.sent(),[3,8];case 5:return[4,Lu(i.localStore,e,!0)];case 6:return s.sent(),Rh(i,e,r),[3,8];case 7:Er(),s.label=8;case 8:return[2]}}))}))}function Kh(t,e,n){return(0,dr.mG)(this,void 0,void 0,(function(){var r,i,o,a,s,u,c,h,l,f;return(0,dr.Jh)(this,(function(p){switch(p.label){case 0:if(!(r=Wh(t)).Oo)return[3,10];i=0,o=e,p.label=1;case 1:return i<o.length?(a=o[i],r.Vo.has(a)?(br("SyncEngine","Adding an already active target "+a),[3,5]):[4,Fu(r.localStore,a)]):[3,6];case 2:return s=p.sent(),[4,Mu(r.localStore,s)];case 3:return u=p.sent(),[4,bh(r,Vh(s),u.targetId,!1)];case 4:p.sent(),xc(r.remoteStore,u),p.label=5;case 5:return i++,[3,1];case 6:c=function(t){return(0,dr.Jh)(this,(function(e){switch(e.label){case 0:return r.Vo.has(t)?[4,Lu(r.localStore,t,!1).then((function(){Dc(r.remoteStore,t),Rh(r,t)})).catch(ru)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))},h=0,l=n,p.label=7;case 7:return h<l.length?(f=l[h],[5,c(f)]):[3,10];case 8:p.sent(),p.label=9;case 9:return h++,[3,7];case 10:return[2]}}))}))}function Wh(t){var e=Cr(t);return e.remoteStore.remoteSyncer.applyRemoteEvent=Ih.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=Uh.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=Th.bind(null,e),e.vo._r=ah.bind(null,e.eventManager),e.vo.Mo=sh.bind(null,e.eventManager),e}function Yh(t){var e=Cr(t);return e.remoteStore.remoteSyncer.applySuccessfulWrite=Ch.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=Sh.bind(null,e),e}var Jh=function(){function t(){this.synchronizeTabs=!1}return t.prototype.initialize=function(t){return(0,dr.mG)(this,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(e){switch(e.label){case 0:return this.R=yc(t.databaseInfo.databaseId),this.sharedClientState=this.Bo(t),this.persistence=this.qo(t),[4,this.persistence.start()];case 1:return e.sent(),this.gcScheduler=this.Uo(t),this.localStore=this.Qo(t),[2]}}))}))},t.prototype.Uo=function(t){return null},t.prototype.Qo=function(t){return Du(this.persistence,new Su,t.initialUser,this.R)},t.prototype.qo=function(t){return new Xu($u.bs,this.R)},t.prototype.Bo=function(t){return new hc},t.prototype.terminate=function(){return(0,dr.mG)(this,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(t){switch(t.label){case 0:return this.gcScheduler&&this.gcScheduler.stop(),[4,this.sharedClientState.shutdown()];case 1:return t.sent(),[4,this.persistence.shutdown()];case 2:return t.sent(),[2]}}))}))},t}(),Xh=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).Ko=e,i.cacheSizeBytes=n,i.forceOwnership=r,i.synchronizeTabs=!1,i}return(0,dr.ZT)(e,t),e.prototype.initialize=function(e){return(0,dr.mG)(this,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(n){switch(n.label){case 0:return[4,t.prototype.initialize.call(this,e)];case 1:return n.sent(),[4,ju(this.localStore)];case 2:return n.sent(),[4,this.Ko.initialize(this,e)];case 3:return n.sent(),[4,Yh(this.Ko.syncEngine)];case 4:return n.sent(),[4,jc(this.Ko.remoteStore)];case 5:return n.sent(),[2]}}))}))},e.prototype.Qo=function(t){return Du(this.persistence,new Su,t.initialUser,this.R)},e.prototype.Uo=function(t){var e=this.persistence.referenceDelegate.garbageCollector;return new au(e,t.asyncQueue)},e.prototype.qo=function(t){var e=Iu(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?Vs.withCacheSize(this.cacheSizeBytes):Vs.DEFAULT;return new bu(this.synchronizeTabs,e,t.clientId,n,t.asyncQueue,mc(),vc(),this.R,this.sharedClientState,!!this.forceOwnership)},e.prototype.Bo=function(t){return new hc},e}(Jh),Zh=function(t){function e(e,n){var r=this;return(r=t.call(this,e,n,!1)||this).Ko=e,r.cacheSizeBytes=n,r.synchronizeTabs=!0,r}return(0,dr.ZT)(e,t),e.prototype.initialize=function(e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r=this;return(0,dr.Jh)(this,(function(i){switch(i.label){case 0:return[4,t.prototype.initialize.call(this,e)];case 1:return i.sent(),n=this.Ko.syncEngine,this.sharedClientState instanceof cc?(this.sharedClientState.syncEngine={ui:jh.bind(null,n),ai:Hh.bind(null,n),hi:Kh.bind(null,n),fn:zh.bind(null,n),ci:Qh.bind(null,n)},[4,this.sharedClientState.start()]):[3,3];case 2:i.sent(),i.label=3;case 3:return[4,this.persistence.He((function(t){return(0,dr.mG)(r,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(e){switch(e.label){case 0:return[4,qh(this.Ko.syncEngine,t)];case 1:return e.sent(),this.gcScheduler&&(t&&!this.gcScheduler.started?this.gcScheduler.start(this.localStore):t||this.gcScheduler.stop()),[2]}}))}))}))];case 4:return i.sent(),[2]}}))}))},e.prototype.Bo=function(t){var e=mc();if(!cc.yt(e))throw new vr(mr.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var n=Iu(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey);return new cc(e,t.asyncQueue,n,t.clientId,t.initialUser)},e}(Xh),$h=function(){function t(){}return t.prototype.initialize=function(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n=this;return(0,dr.Jh)(this,(function(r){switch(r.label){case 0:return this.localStore?[3,2]:(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(e),this.remoteStore=this.createRemoteStore(e),this.eventManager=this.createEventManager(e),this.syncEngine=this.createSyncEngine(e,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=function(t){return Eh(n.syncEngine,t,1)},this.remoteStore.remoteSyncer.handleCredentialChange=Lh.bind(null,this.syncEngine),[4,Wc(this.remoteStore,this.syncEngine.isPrimaryClient)]);case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},t.prototype.createEventManager=function(t){return new rh},t.prototype.createDatastore=function(t){var e,n=yc(t.databaseInfo.databaseId),r=(e=t.databaseInfo,new gc(e));return function(t,e,n){return new Ic(t,e,n)}(t.credentials,r,n)},t.prototype.createRemoteStore=function(t){var e,n,r,i,o,a=this;return e=this.localStore,n=this.datastore,r=t.asyncQueue,i=function(t){return Eh(a.syncEngine,t,0)},o=fc.yt()?new fc:new lc,new Tc(e,n,r,i,o)},t.prototype.createSyncEngine=function(t,e){return function(t,e,n,r,i,o,a){var s=new yh(t,e,n,r,i,o);return a&&(s.Oo=!0),s}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,e)},t.prototype.terminate=function(){return function(t){return(0,dr.mG)(this,void 0,void 0,(function(){var e;return(0,dr.Jh)(this,(function(n){switch(n.label){case 0:return e=Cr(t),br("RemoteStore","RemoteStore shutting down."),e.$r.add(5),[4,Sc(e)];case 1:return n.sent(),e.Lr.shutdown(),e.Br.set("Unknown"),[2]}}))}))}(this.remoteStore)},t}();var tl=function(){function t(t){this.observer=t,this.muted=!1}return t.prototype.next=function(t){this.observer.next&&this.jo(this.observer.next,t)},t.prototype.error=function(t){this.observer.error?this.jo(this.observer.error,t):console.error("Uncaught Error in snapshot listener:",t)},t.prototype.Wo=function(){this.muted=!0},t.prototype.jo=function(t,e){var n=this;this.muted||setTimeout((function(){n.muted||t(e)}),0)},t}(),el=(function(){function t(t,e){var n=this;this.Go=t,this.R=e,this.metadata=new cs,this.buffer=new Uint8Array,this.zo=new TextDecoder("utf-8"),this.Ho().then((function(t){t&&t.io()?n.metadata.resolve(t.payload.metadata):n.metadata.reject(new Error("The first element of the bundle is not a metadata, it is\n "+JSON.stringify(null==t?void 0:t.payload)))}),(function(t){return n.metadata.reject(t)}))}t.prototype.close=function(){return this.Go.cancel()},t.prototype.getMetadata=function(){return(0,dr.mG)(this,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(t){return[2,this.metadata.promise]}))}))},t.prototype.Lo=function(){return(0,dr.mG)(this,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(t){switch(t.label){case 0:return[4,this.getMetadata()];case 1:return[2,(t.sent(),this.Ho())]}}))}))},t.prototype.Ho=function(){return(0,dr.mG)(this,void 0,void 0,(function(){var t,e,n,r;return(0,dr.Jh)(this,(function(i){switch(i.label){case 0:return[4,this.Jo()];case 1:return null===(t=i.sent())?[2,null]:(e=this.zo.decode(t),n=Number(e),isNaN(n)&&this.Yo("length string ("+e+") is not valid number"),[4,this.Xo(n)]);case 2:return r=i.sent(),[2,new hh(JSON.parse(r),t.length+n)]}}))}))},t.prototype.Zo=function(){return this.buffer.findIndex((function(t){return t==="{".charCodeAt(0)}))},t.prototype.Jo=function(){return(0,dr.mG)(this,void 0,void 0,(function(){var t,e;return(0,dr.Jh)(this,(function(n){switch(n.label){case 0:return this.Zo()<0?[4,this.tc()]:[3,3];case 1:if(n.sent())return[3,3];n.label=2;case 2:return[3,0];case 3:return 0===this.buffer.length?[2,null]:((t=this.Zo())<0&&this.Yo("Reached the end of bundle when a length string is expected."),e=this.buffer.slice(0,t),[2,(this.buffer=this.buffer.slice(t),e)])}}))}))},t.prototype.Xo=function(t){return(0,dr.mG)(this,void 0,void 0,(function(){var e;return(0,dr.Jh)(this,(function(n){switch(n.label){case 0:return this.buffer.length<t?[4,this.tc()]:[3,3];case 1:n.sent()&&this.Yo("Reached the end of bundle when more is expected."),n.label=2;case 2:return[3,0];case 3:return e=this.zo.decode(this.buffer.slice(0,t)),[2,(this.buffer=this.buffer.slice(t),e)]}}))}))},t.prototype.Yo=function(t){throw this.Go.cancel(),new Error("Invalid bundle format: "+t)},t.prototype.tc=function(){return(0,dr.mG)(this,void 0,void 0,(function(){var t,e;return(0,dr.Jh)(this,(function(n){switch(n.label){case 0:return[4,this.Go.read()];case 1:return(t=n.sent()).done||((e=new Uint8Array(this.buffer.length+t.value.length)).set(this.buffer),e.set(t.value,this.buffer.length),this.buffer=e),[2,t.done]}}))}))}}(),function(){function t(t){this.datastore=t,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}return t.prototype.lookup=function(t){return(0,dr.mG)(this,void 0,void 0,(function(){var e,n=this;return(0,dr.Jh)(this,(function(r){switch(r.label){case 0:if(this.ensureCommitNotCalled(),this.mutations.length>0)throw new vr(mr.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");return[4,function(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r,i,o,a,s;return(0,dr.Jh)(this,(function(u){switch(u.label){case 0:return n=Cr(t),r=ba(n.R)+"/documents",i={documents:e.map((function(t){return ma(n.R,t)}))},[4,n.Oi("BatchGetDocuments",r,i)];case 1:return o=u.sent(),a=new Map,o.forEach((function(t){var e=function(t,e){return"found"in e?function(t,e){Tr(!!e.found),e.found.name,e.found.updateTime;var n=va(t,e.found.name),r=pa(e.found.updateTime),i=new pi({mapValue:{fields:e.found.fields}});return gi.newFoundDocument(n,r,i)}(t,e):"missing"in e?function(t,e){Tr(!!e.missing),Tr(!!e.readTime);var n=va(t,e.missing),r=pa(e.readTime);return gi.newNoDocument(n,r)}(t,e):Er()}(n.R,t);a.set(e.key.toString(),e)})),s=[],[2,(e.forEach((function(t){var e=a.get(t.toString());Tr(!!e),s.push(e)})),s)]}}))}))}(this.datastore,t)];case 1:return[2,((e=r.sent()).forEach((function(t){return n.recordVersion(t)})),e)]}}))}))},t.prototype.set=function(t,e){this.write(e.toMutation(t,this.precondition(t))),this.writtenDocs.add(t.toString())},t.prototype.update=function(t,e){try{this.write(e.toMutation(t,this.preconditionForUpdate(t)))}catch(t){this.lastWriteError=t}this.writtenDocs.add(t.toString())},t.prototype.delete=function(t){this.write(new Oo(t,this.precondition(t))),this.writtenDocs.add(t.toString())},t.prototype.commit=function(){return(0,dr.mG)(this,void 0,void 0,(function(){var t,e=this;return(0,dr.Jh)(this,(function(n){switch(n.label){case 0:if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;return t=this.readVersions,this.mutations.forEach((function(e){t.delete(e.key.toString())})),t.forEach((function(t,n){var r=$r.fromPath(n);e.mutations.push(new Bo(r,e.precondition(r)))})),[4,function(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r,i;return(0,dr.Jh)(this,(function(o){switch(o.label){case 0:return n=Cr(t),r=ba(n.R)+"/documents",i={writes:e.map((function(t){return Ea(n.R,t)}))},[4,n.Ni("Commit",r,i)];case 1:return o.sent(),[2]}}))}))}(this.datastore,this.mutations)];case 1:return n.sent(),this.committed=!0,[2]}}))}))},t.prototype.recordVersion=function(t){var e;if(t.isFoundDocument())e=t.version;else{if(!t.isNoDocument())throw Er();e=Br.min()}var n=this.readVersions.get(t.key.toString());if(n){if(!e.isEqual(n))throw new vr(mr.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(t.key.toString(),e)},t.prototype.precondition=function(t){var e=this.readVersions.get(t.toString());return!this.writtenDocs.has(t.toString())&&e?vo.updateTime(e):vo.none()},t.prototype.preconditionForUpdate=function(t){var e=this.readVersions.get(t.toString());if(!this.writtenDocs.has(t.toString())&&e){if(e.isEqual(Br.min()))throw new vr(mr.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return vo.updateTime(e)}return vo.exists(!0)},t.prototype.write=function(t){this.ensureCommitNotCalled(),this.mutations.push(t)},t.prototype.ensureCommitNotCalled=function(){},t}()),nl=function(){function t(t,e,n,r){this.asyncQueue=t,this.datastore=e,this.updateFunction=n,this.deferred=r,this.ec=5,this.Zi=new Ac(this.asyncQueue,"transaction_retry")}return t.prototype.run=function(){this.nc()},t.prototype.nc=function(){var t=this;this.Zi.ji((function(){return(0,dr.mG)(t,void 0,void 0,(function(){var t,e,n=this;return(0,dr.Jh)(this,(function(r){return t=new el(this.datastore),(e=this.sc(t))&&e.then((function(e){n.asyncQueue.enqueueAndForget((function(){return t.commit().then((function(){n.deferred.resolve(e)})).catch((function(t){n.ic(t)}))}))})).catch((function(t){n.ic(t)})),[2]}))}))}))},t.prototype.sc=function(t){try{var e=this.updateFunction(t);return!Jr(e)&&e.catch&&e.then?e:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.deferred.reject(t),null}},t.prototype.ic=function(t){var e=this;this.ec>0&&this.rc(t)?(this.ec-=1,this.asyncQueue.enqueueAndForget((function(){return e.nc(),Promise.resolve()}))):this.deferred.reject(t)},t.prototype.rc=function(t){if("FirebaseError"===t.name){var e=t.code;return"aborted"===e||"failed-precondition"===e||!Po(e)}return!1},t}(),rl=function(){function t(t,e,n){var r=this;this.credentials=t,this.asyncQueue=e,this.databaseInfo=n,this.user=tc.UNAUTHENTICATED,this.clientId=xr.u(),this.credentialListener=function(){},this.receivedInitialUser=new cs,this.credentials.setChangeListener((function(t){br("FirestoreClient","Received user=",t.uid),r.user=t,r.credentialListener(t),r.receivedInitialUser.resolve()}))}return t.prototype.getConfiguration=function(){return(0,dr.mG)(this,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(t){switch(t.label){case 0:return[4,this.receivedInitialUser.promise];case 1:return[2,(t.sent(),{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,credentials:this.credentials,initialUser:this.user,maxConcurrentLimboResolutions:100})]}}))}))},t.prototype.setCredentialChangeListener=function(t){var e=this;this.credentialListener=t,this.receivedInitialUser.promise.then((function(){return e.credentialListener(e.user)}))},t.prototype.verifyNotTerminated=function(){if(this.asyncQueue.isShuttingDown)throw new vr(mr.FAILED_PRECONDITION,"The client has already been terminated.")},t.prototype.terminate=function(){var t=this;this.asyncQueue.enterRestrictedMode();var e=new cs;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((function(){return(0,dr.mG)(t,void 0,void 0,(function(){var t,n;return(0,dr.Jh)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,5,,6]),this.onlineComponents?[4,this.onlineComponents.terminate()]:[3,2];case 1:r.sent(),r.label=2;case 2:return this.offlineComponents?[4,this.offlineComponents.terminate()]:[3,4];case 3:r.sent(),r.label=4;case 4:return this.credentials.removeChangeListener(),e.resolve(),[3,6];case 5:return t=r.sent(),n=Zc(t,"Failed to shutdown persistence"),e.reject(n),[3,6];case 6:return[2]}}))}))})),e.promise},t}();function il(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r,i=this;return(0,dr.Jh)(this,(function(o){switch(o.label){case 0:return t.asyncQueue.verifyOperationInProgress(),br("FirestoreClient","Initializing OfflineComponentProvider"),[4,t.getConfiguration()];case 1:return n=o.sent(),[4,e.initialize(n)];case 2:return o.sent(),r=n.initialUser,t.setCredentialChangeListener((function(n){r.isEqual(n)||(r=n,t.asyncQueue.enqueueRetryable((function(){return(0,dr.mG)(i,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(t){switch(t.label){case 0:return[4,ku(e.localStore,n)];case 1:return t.sent(),[2]}}))}))})))})),e.persistence.setDatabaseDeletedListener((function(){return t.terminate()})),t.offlineComponents=e,[2]}}))}))}function ol(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r;return(0,dr.Jh)(this,(function(i){switch(i.label){case 0:return t.asyncQueue.verifyOperationInProgress(),[4,al(t)];case 1:return n=i.sent(),br("FirestoreClient","Initializing OnlineComponentProvider"),[4,t.getConfiguration()];case 2:return r=i.sent(),[4,e.initialize(n,r)];case 3:return i.sent(),t.setCredentialChangeListener((function(n){return t.asyncQueue.enqueueRetryable((function(){return function(t,e){return(0,dr.mG)(this,void 0,void 0,(function(){var n,r;return(0,dr.Jh)(this,(function(i){switch(i.label){case 0:return(n=Cr(t)).asyncQueue.verifyOperationInProgress(),br("RemoteStore","RemoteStore received new credentials"),r=Nc(n),n.$r.add(3),[4,Sc(n)];case 1:return i.sent(),r&&n.Br.set("Unknown"),[4,n.remoteSyncer.handleCredentialChange(e)];case 2:return i.sent(),n.$r.delete(3),[4,Cc(n)];case 3:return i.sent(),[2]}}))}))}(e.remoteStore,n)}))})),t.onlineComponents=e,[2]}}))}))}function al(t){return(0,dr.mG)(this,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(e){switch(e.label){case 0:return t.offlineComponents?[3,2]:(br("FirestoreClient","Using default OfflineComponentProvider"),[4,il(t,new Jh)]);case 1:e.sent(),e.label=2;case 2:return[2,t.offlineComponents]}}))}))}function sl(t){return(0,dr.mG)(this,void 0,void 0,(function(){return(0,dr.Jh)(this,(function(e){switch(e.label){case 0:return t.onlineComponents?[3,2]:(br("FirestoreClient","Using default OnlineComponentProvider"),[4,ol(t,new $h)]);case 1:e.sent(),e.label=2;case 2:return[2,t.onlineComponents]}}))}))}function ul(t){return al(t).then((function(t){return t.persistence}))}function cl(t){return al(t).then((function(t){return t.localStore}))}function hl(t){return sl(t).then((function(t){return t.remoteStore}))}function ll(t){return sl(t).then((function(t){return t.syncEngine}))}function fl(t){return(0,dr.mG)(this,void 0,void 0,(function(){var e,n;return(0,dr.Jh)(this,(function(r){switch(r.label){case 0:return[4,sl(t)];case 1:return e=r.sent(),[2,((n=e.eventManager).onListen=Ah.bind(null,e.syncEngine),n.onUnlisten=wh.bind(null,e.syncEngine),n)]}}))}))}function pl(t,e,n){var r=this;void 0===n&&(n={});var i=new cs;return t.asyncQueue.enqueueAndForget((function(){return(0,dr.mG)(r,void 0,void 0,(function(){var r;return(0,dr.Jh)(this,(function(o){switch(o.label){case 0:return r=function(t,e,n,r,i){var o=new tl({next:function(o){e.enqueueAndForget((function(){return oh(t,a)}));var s=o.docs.has(n);!s&&o.fromCache?i.reject(new vr(mr.UNAVAILABLE,"Failed to get document because the client is offline.")):s&&o.fromCache&&r&&"server"===r.source?i.reject(new vr(mr.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):i.resolve(o)},error:function(t){return i.reject(t)}}),a=new ch(Ui(n.path),o,{includeMetadataChanges:!0,so:!0});return ih(t,a)},[4,fl(t)];case 1:return[2,r.apply(void 0,[o.sent(),t.asyncQueue,e,n,i])]}}))}))})),i.promise}function dl(t,e,n){var r=this;void 0===n&&(n={});var i=new cs;return t.asyncQueue.enqueueAndForget((function(){return(0,dr.mG)(r,void 0,void 0,(function(){var r;return(0,dr.Jh)(this,(function(o){switch(o.label){case 0:return r=function(t,e,n,r,i){var o=new tl({next:function(n){e.enqueueAndForget((function(){return oh(t,a)})),n.fromCache&&"server"===r.source?i.reject(new vr(mr.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):i.resolve(n)},error:function(t){return i.reject(t)}}),a=new ch(n,o,{includeMetadataChanges:!0,so:!0});return ih(t,a)},[4,fl(t)];case 1:return[2,r.apply(void 0,[o.sent(),t.asyncQueue,e,n,i])]}}))}))})),i.promise}var gl=function(t,e,n,r,i,o,a){this.databaseId=t,this.appId=e,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=o,this.autoDetectLongPolling=a},ml=function(){function t(t,e){this.projectId=t,this.database=e||"(default)"}return Object.defineProperty(t.prototype,"isDefaultDatabase",{get:function(){return"(default)"===this.database},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(e){return e instanceof t&&e.projectId===this.projectId&&e.database===this.database},t}(),vl=new Map,yl=function(t,e){this.user=e,this.type="OAuth",this.authHeaders={},this.authHeaders.Authorization="Bearer "+t},Al=function(){function t(){this.changeListener=null}return t.prototype.getToken=function(){return Promise.resolve(null)},t.prototype.invalidateToken=function(){},t.prototype.setChangeListener=function(t){this.changeListener=t,t(tc.UNAUTHENTICATED)},t.prototype.removeChangeListener=function(){this.changeListener=null},t}(),bl=function(){function t(t){var e=this;this.oc=null,this.currentUser=tc.UNAUTHENTICATED,this.receivedInitialUser=!1,this.cc=0,this.changeListener=null,this.forceRefresh=!1,this.oc=function(){e.cc++,e.currentUser=e.uc(),e.receivedInitialUser=!0,e.changeListener&&e.changeListener(e.currentUser)},this.cc=0,this.auth=t.getImmediate({optional:!0}),this.auth?this.auth.addAuthTokenListener(this.oc):(this.oc(null),t.get().then((function(t){e.auth=t,e.oc&&e.auth.addAuthTokenListener(e.oc)}),(function(){})))}return t.prototype.getToken=function(){var t=this,e=this.cc,n=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(n).then((function(n){return t.cc!==e?(br("FirebaseCredentialsProvider","getToken aborted due to token change."),t.getToken()):n?(Tr("string"==typeof n.accessToken),new yl(n.accessToken,t.currentUser)):null})):Promise.resolve(null)},t.prototype.invalidateToken=function(){this.forceRefresh=!0},t.prototype.setChangeListener=function(t){this.changeListener=t,this.receivedInitialUser&&t(this.currentUser)},t.prototype.removeChangeListener=function(){this.auth&&this.auth.removeAuthTokenListener(this.oc),this.oc=null,this.changeListener=null},t.prototype.uc=function(){var t=this.auth&&this.auth.getUid();return Tr(null===t||"string"==typeof t),new tc(t)},t}(),wl=function(){function t(t,e,n){this.ac=t,this.hc=e,this.lc=n,this.type="FirstParty",this.user=tc.FIRST_PARTY}return Object.defineProperty(t.prototype,"authHeaders",{get:function(){var t={"X-Goog-AuthUser":this.hc},e=this.ac.auth.getAuthHeaderValueForFirstParty([]);return e&&(t.Authorization=e),this.lc&&(t["X-Goog-Iam-Authorization-Token"]=this.lc),t},enumerable:!1,configurable:!0}),t}(),_l=function(){function t(t,e,n){this.ac=t,this.hc=e,this.lc=n}return t.prototype.getToken=function(){return Promise.resolve(new wl(this.ac,this.hc,this.lc))},t.prototype.setChangeListener=function(t){t(tc.FIRST_PARTY)},t.prototype.removeChangeListener=function(){},t.prototype.invalidateToken=function(){},t}();function Il(t,e,n){if(!n)throw new vr(mr.INVALID_ARGUMENT,"Function "+t+"() cannot be called with an empty "+e+".")}function El(t,e){if(void 0===e)return{merge:!1};if(void 0!==e.mergeFields&&void 0!==e.merge)throw new vr(mr.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');return e}function Tl(t,e,n,r){if(!0===e&&!0===r)throw new vr(mr.INVALID_ARGUMENT,t+" and "+n+" cannot be used together.")}function Cl(t){if(!$r.isDocumentKey(t))throw new vr(mr.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t+" has "+t.length+".")}function Sl(t){if($r.isDocumentKey(t))throw new vr(mr.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+t+" has "+t.length+".")}function xl(t){if(void 0===t)return"undefined";if(null===t)return"null";if("string"==typeof t)return t.length>20&&(t=t.substring(0,20)+"..."),JSON.stringify(t);if("number"==typeof t||"boolean"==typeof t)return""+t;if("object"==typeof t){if(t instanceof Array)return"an array";var e=function(t){if(t.constructor){var e=/function\s+([^\s(]+)\s*\(/.exec(t.constructor.toString());if(e&&e.length>1)return e[1]}return null}(t);return e?"a custom "+e+" object":"an object"}return"function"==typeof t?"a function":Er()}function Dl(t,e){if("_delegate"in t&&(t=t._delegate),!(t instanceof e)){if(e.name===t.constructor.name)throw new vr(mr.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");var n=xl(t);throw new vr(mr.INVALID_ARGUMENT,"Expected type '"+e.name+"', but it was: "+n)}return t}function kl(t,e){if(e<=0)throw new vr(mr.INVALID_ARGUMENT,"Function "+t+"() requires a positive number, but it was: "+e+".")}var Rl=function(){function t(t){var e;if(void 0===t.host){if(void 0!==t.ssl)throw new vr(mr.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=t.host,this.ssl=null===(e=t.ssl)||void 0===e||e;if(this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,void 0===t.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new vr(mr.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,Tl("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling)}return t.prototype.isEqual=function(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties},t}(),Ol=function(){function t(t,e){this._persistenceKey="(lite)",this._settings=new Rl({}),this._settingsFrozen=!1,t instanceof ml?(this._databaseId=t,this._credentials=new Al):(this._app=t,this._databaseId=function(t){if(!Object.prototype.hasOwnProperty.apply(t.options,["projectId"]))throw new vr(mr.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new ml(t.options.projectId)}(t),this._credentials=new bl(e))}return Object.defineProperty(t.prototype,"app",{get:function(){if(!this._app)throw new vr(mr.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_initialized",{get:function(){return this._settingsFrozen},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_terminated",{get:function(){return void 0!==this._terminateTask},enumerable:!1,configurable:!0}),t.prototype._setSettings=function(t){if(this._settingsFrozen)throw new vr(mr.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new Rl(t),void 0!==t.credentials&&(this._credentials=function(t){if(!t)return new Al;switch(t.type){case"gapi":var e=t.client;return Tr(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty)),new _l(e,t.sessionIndex||"0",t.iamToken||null);case"provider":return t.client;default:throw new vr(mr.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(t.credentials))},t.prototype._getSettings=function(){return this._settings},t.prototype._freezeSettings=function(){return this._settingsFrozen=!0,this._settings},t.prototype._delete=function(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask},t.prototype.toJSON=function(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}},t.prototype._terminate=function(){return this,(t=vl.get(this))&&(br("ComponentProvider","Removing Datastore"),vl.delete(this),t.terminate()),Promise.resolve();var t},t}(),Bl=function(){function t(t,e,n){this._converter=e,this._key=n,this.type="document",this.firestore=t}return Object.defineProperty(t.prototype,"_path",{get:function(){return this._key.path},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"path",{get:function(){return this._key.path.canonicalString()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return new Pl(this.firestore,this._converter,this._key.path.popLast())},enumerable:!1,configurable:!0}),t.prototype.withConverter=function(e){return new t(this.firestore,e,this._key)},t}(),Nl=function(){function t(t,e,n){this._converter=e,this._query=n,this.type="query",this.firestore=t}return t.prototype.withConverter=function(e){return new t(this.firestore,e,this._query)},t}(),Pl=function(t){function e(e,n,r){var i=this;return(i=t.call(this,e,n,Ui(r))||this).firestore=e,i._path=r,i.type="collection",i}return(0,dr.ZT)(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this._query.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this._query.path.canonicalString()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){var t=this._path.popLast();return t.isEmpty()?null:new Bl(this.firestore,null,new $r(t))},enumerable:!1,configurable:!0}),e.prototype.withConverter=function(t){return new e(this.firestore,t,this._path)},e}(Nl);function Ml(t,e){for(var n,r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];if(t=(0,i.m9)(t),Il("collection","path",e),t instanceof Ol)return Sl(n=Ur.fromString.apply(Ur,(0,dr.ev)([e],r))),new Pl(t,null,n);if(!(t instanceof Bl||t instanceof Pl))throw new vr(mr.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");return Sl(n=Ur.fromString.apply(Ur,(0,dr.ev)([t.path],r)).child(Ur.fromString(e))),new Pl(t.firestore,null,n)}function Ll(t,e){for(var n,r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];if(t=(0,i.m9)(t),1===arguments.length&&(e=xr.u()),Il("doc","path",e),t instanceof Ol)return Cl(n=Ur.fromString.apply(Ur,(0,dr.ev)([e],r))),new Bl(t,null,new $r(n));if(!(t instanceof Bl||t instanceof Pl))throw new vr(mr.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");return Cl(n=t._path.child(Ur.fromString.apply(Ur,(0,dr.ev)([e],r)))),new Bl(t.firestore,t instanceof Pl?t._converter:null,new $r(n))}function Ul(t,e){return t=(0,i.m9)(t),e=(0,i.m9)(e),(t instanceof Bl||t instanceof Pl)&&(e instanceof Bl||e instanceof Pl)&&t.firestore===e.firestore&&t.path===e.path&&t._converter===e._converter}function Fl(t,e){return t=(0,i.m9)(t),e=(0,i.m9)(e),t instanceof Nl&&e instanceof Nl&&t.firestore===e.firestore&&Ki(t._query,e._query)&&t._converter===e._converter}var Ql=function(){function t(){var t=this;this.fc=Promise.resolve(),this.dc=[],this.wc=!1,this._c=[],this.mc=null,this.yc=!1,this.gc=[],this.Zi=new Ac(this,"async_queue_retry"),this.Ec=function(){var e=vc();e&&br("AsyncQueue","Visibility state changed to "+e.visibilityState),t.Zi.Gi()};var e=vc();e&&"function"==typeof e.addEventListener&&e.addEventListener("visibilitychange",this.Ec)}return Object.defineProperty(t.prototype,"isShuttingDown",{get:function(){return this.wc},enumerable:!1,configurable:!0}),t.prototype.enqueueAndForget=function(t){this.enqueue(t)},t.prototype.enqueueAndForgetEvenWhileRestricted=function(t){this.Tc(),this.Ic(t)},t.prototype.enterRestrictedMode=function(){if(!this.wc){this.wc=!0;var t=vc();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.Ec)}},t.prototype.enqueue=function(t){return this.Tc(),this.wc?new Promise((function(t){})):this.Ic(t)},t.prototype.enqueueRetryable=function(t){var e=this;this.enqueueAndForget((function(){return e.dc.push(t),e.Ac()}))},t.prototype.Ac=function(){return(0,dr.mG)(this,void 0,void 0,(function(){var t,e=this;return(0,dr.Jh)(this,(function(n){switch(n.label){case 0:if(0===this.dc.length)return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.dc[0]()];case 2:return n.sent(),this.dc.shift(),this.Zi.reset(),[3,4];case 3:if(!gs(t=n.sent()))throw t;return br("AsyncQueue","Operation failed with retryable error: "+t),[3,4];case 4:this.dc.length>0&&this.Zi.ji((function(){return e.Ac()})),n.label=5;case 5:return[2]}}))}))},t.prototype.Ic=function(t){var e=this,n=this.fc.then((function(){return e.yc=!0,t().catch((function(t){throw e.mc=t,e.yc=!1,wr("INTERNAL UNHANDLED ERROR: ",function(t){var e=t.message||"";return t.stack&&(e=t.stack.includes(t.message)?t.stack:t.message+"\n"+t.stack),e}(t)),t})).then((function(t){return e.yc=!1,t}))}));return this.fc=n,n},t.prototype.enqueueAfterDelay=function(t,e,n){var r=this;this.Tc(),this.gc.indexOf(t)>-1&&(e=0);var i=Xc.createAndSchedule(this,t,e,n,(function(t){return r.Rc(t)}));return this._c.push(i),i},t.prototype.Tc=function(){this.mc&&Er()},t.prototype.verifyOperationInProgress=function(){},t.prototype.bc=function(){return(0,dr.mG)(this,void 0,void 0,(function(){var t;return(0,dr.Jh)(this,(function(e){switch(e.label){case 0:return[4,t=this.fc];case 1:e.sent(),e.label=2;case 2:if(t!==this.fc)return[3,0];e.label=3;case 3:return[2]}}))}))},t.prototype.vc=function(t){for(var e=0,n=this._c;e<n.length;e++)if(n[e].timerId===t)return!0;return!1},t.prototype.Pc=function(t){var e=this;return this.bc().then((function(){e._c.sort((function(t,e){return t.targetTimeMs-e.targetTimeMs}));for(var n=0,r=e._c;n<r.length;n++){var i=r[n];if(i.skipDelay(),"all"!==t&&i.timerId===t)break}return e.bc()}))},t.prototype.Vc=function(t){this.gc.push(t)},t.prototype.Rc=function(t){var e=this._c.indexOf(t);this._c.splice(e,1)},t}();function jl(t){return function(t,e){if("object"!=typeof t||null===t)return!1;for(var n=t,r=0,i=["next","error","complete"];r<i.length;r++){var o=i[r];if(o in n&&"function"==typeof n[o])return!0}return!1}(t)}!function(){function t(){this._progressObserver={},this._taskCompletionResolver=new cs,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}t.prototype.onProgress=function(t,e,n){this._progressObserver={next:t,error:e,complete:n}},t.prototype.catch=function(t){return this._taskCompletionResolver.promise.catch(t)},t.prototype.then=function(t,e){return this._taskCompletionResolver.promise.then(t,e)},t.prototype._completeWith=function(t){this._updateProgress(t),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(t)},t.prototype._failWith=function(t){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(t),this._taskCompletionResolver.reject(t)},t.prototype._updateProgress=function(t){this._lastProgress=t,this._progressObserver.next&&this._progressObserver.next(t)}}();var ql=function(t){function e(e,n){var r=this;return(r=t.call(this,e,n)||this)._queue=new Ql,r._persistenceKey="name"in e?e.name:"[DEFAULT]",r}return(0,dr.ZT)(e,t),e.prototype._terminate=function(){return this._firestoreClient||Vl(this),this._firestoreClient.terminate()},e}(Ol);function Gl(t){return t._firestoreClient||Vl(t),t._firestoreClient.verifyNotTerminated(),t._firestoreClient}function Vl(t){var e,n=t._freezeSettings(),r=function(t,e,n,r){return new gl(t,e,n,r.host,r.ssl,r.experimentalForceLongPolling,r.experimentalAutoDetectLongPolling)}(t._databaseId,(null===(e=t._app)||void 0===e?void 0:e.options.appId)||"",t._persistenceKey,n);t._firestoreClient=new rl(t._credentials,t._queue,r)}function zl(t,e,n){var r=this,i=new cs;return t.asyncQueue.enqueue((function(){return(0,dr.mG)(r,void 0,void 0,(function(){var r;return(0,dr.Jh)(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,il(t,n)];case 1:return o.sent(),[4,ol(t,e)];case 2:return o.sent(),i.resolve(),[3,4];case 3:if(!function(t){return"FirebaseError"===t.name?t.code===mr.FAILED_PRECONDITION||t.code===mr.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code}(r=o.sent()))throw r;return console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+r),i.reject(r),[3,4];case 4:return[2]}}))}))})).then((function(){return i.promise}))}function Hl(t){if(t._initialized||t._terminated)throw new vr(mr.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.")}var Kl=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=0;n<t.length;++n)if(0===t[n].length)throw new vr(mr.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new Qr(t)}return t.prototype.isEqual=function(t){return this._internalPath.isEqual(t._internalPath)},t}(),Wl=function(){function t(t){this._byteString=t}return t.fromBase64String=function(e){try{return new t(qr.fromBase64String(e))}catch(e){throw new vr(mr.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}},t.fromUint8Array=function(e){return new t(qr.fromUint8Array(e))},t.prototype.toBase64=function(){return this._byteString.toBase64()},t.prototype.toUint8Array=function(){return this._byteString.toUint8Array()},t.prototype.toString=function(){return"Bytes(base64: "+this.toBase64()+")"},t.prototype.isEqual=function(t){return this._byteString.isEqual(t._byteString)},t}(),Yl=function(t){this._methodName=t},Jl=function(){function t(t,e){if(!isFinite(t)||t<-90||t>90)throw new vr(mr.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new vr(mr.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}return Object.defineProperty(t.prototype,"latitude",{get:function(){return this._lat},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"longitude",{get:function(){return this._long},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){return this._lat===t._lat&&this._long===t._long},t.prototype.toJSON=function(){return{latitude:this._lat,longitude:this._long}},t.prototype._compareTo=function(t){return Dr(this._lat,t._lat)||Dr(this._long,t._long)},t}(),Xl=/^__.*__$/,Zl=function(){function t(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}return t.prototype.toMutation=function(t,e){return null!==this.fieldMask?new Co(t,this.data,this.fieldMask,e,this.fieldTransforms):new To(t,this.data,e,this.fieldTransforms)},t}(),$l=function(){function t(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}return t.prototype.toMutation=function(t,e){return new Co(t,this.data,this.fieldMask,e,this.fieldTransforms)},t}();function tf(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw Er()}}var ef=function(){function t(t,e,n,r,i,o){this.settings=t,this.databaseId=e,this.R=n,this.ignoreUndefinedProperties=r,void 0===i&&this.Sc(),this.fieldTransforms=i||[],this.fieldMask=o||[]}return Object.defineProperty(t.prototype,"path",{get:function(){return this.settings.path},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"Dc",{get:function(){return this.settings.Dc},enumerable:!1,configurable:!0}),t.prototype.Cc=function(e){return new t(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.R,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)},t.prototype.Nc=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.Cc({path:n,xc:!1});return r.Fc(t),r},t.prototype.kc=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.Cc({path:n,xc:!1});return r.Sc(),r},t.prototype.Oc=function(t){return this.Cc({path:void 0,xc:!0})},t.prototype.$c=function(t){return _f(t,this.settings.methodName,this.settings.Mc||!1,this.path,this.settings.Lc)},t.prototype.contains=function(t){return void 0!==this.fieldMask.find((function(e){return t.isPrefixOf(e)}))||void 0!==this.fieldTransforms.find((function(e){return t.isPrefixOf(e.field)}))},t.prototype.Sc=function(){if(this.path)for(var t=0;t<this.path.length;t++)this.Fc(this.path.get(t))},t.prototype.Fc=function(t){if(0===t.length)throw this.$c("Document fields must not be empty");if(tf(this.Dc)&&Xl.test(t))throw this.$c('Document fields cannot begin and end with "__"')},t}(),nf=function(){function t(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.R=n||yc(t)}return t.prototype.Bc=function(t,e,n,r){return void 0===r&&(r=!1),new ef({Dc:t,methodName:e,Lc:n,path:Qr.emptyPath(),xc:!1,Mc:r},this.databaseId,this.R,this.ignoreUndefinedProperties)},t}();function rf(t){var e=t._freezeSettings(),n=yc(t._databaseId);return new nf(t._databaseId,!!e.ignoreUndefinedProperties,n)}function of(t,e,n,r,i,o){void 0===o&&(o={});var a=t.Bc(o.merge||o.mergeFields?2:0,e,n,i);yf("Data must be an object, but it was:",a,r);var s,u,c=mf(r,a);if(o.merge)s=new jr(a.fieldMask),u=a.fieldTransforms;else if(o.mergeFields){for(var h=[],l=0,f=o.mergeFields;l<f.length;l++){var p=Af(e,f[l],n);if(!a.contains(p))throw new vr(mr.INVALID_ARGUMENT,"Field '"+p+"' is specified in your field mask but missing from your input data.");If(h,p)||h.push(p)}s=new jr(h),u=a.fieldTransforms.filter((function(t){return s.covers(t.field)}))}else s=null,u=a.fieldTransforms;return new Zl(new pi(c),s,u)}var af=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,dr.ZT)(e,t),e.prototype._toFieldTransform=function(t){if(2!==t.Dc)throw 1===t.Dc?t.$c(this._methodName+"() can only appear at the top level of your update data"):t.$c(this._methodName+"() cannot be used with set() unless you pass {merge:true}");return t.fieldMask.push(t.path),null},e.prototype.isEqual=function(t){return t instanceof e},e}(Yl);function sf(t,e,n){return new ef({Dc:3,Lc:e.settings.Lc,methodName:t._methodName,xc:n},e.databaseId,e.R,e.ignoreUndefinedProperties)}var uf=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,dr.ZT)(e,t),e.prototype._toFieldTransform=function(t){return new go(t.path,new ao)},e.prototype.isEqual=function(t){return t instanceof e},e}(Yl),cf=function(t){function e(e,n){var r=this;return(r=t.call(this,e)||this).qc=n,r}return(0,dr.ZT)(e,t),e.prototype._toFieldTransform=function(t){var e=sf(this,t,!0),n=this.qc.map((function(t){return gf(t,e)})),r=new so(n);return new go(t.path,r)},e.prototype.isEqual=function(t){return this===t},e}(Yl),hf=function(t){function e(e,n){var r=this;return(r=t.call(this,e)||this).qc=n,r}return(0,dr.ZT)(e,t),e.prototype._toFieldTransform=function(t){var e=sf(this,t,!0),n=this.qc.map((function(t){return gf(t,e)})),r=new co(n);return new go(t.path,r)},e.prototype.isEqual=function(t){return this===t},e}(Yl),lf=function(t){function e(e,n){var r=this;return(r=t.call(this,e)||this).Uc=n,r}return(0,dr.ZT)(e,t),e.prototype._toFieldTransform=function(t){var e=new lo(t.R,eo(t.R,this.Uc));return new go(t.path,e)},e.prototype.isEqual=function(t){return this===t},e}(Yl);function ff(t,e,n,r){var o=t.Bc(1,e,n);yf("Data must be an object, but it was:",o,r);var a=[],s=pi.empty();Pr(r,(function(t,r){var u=wf(e,t,n);r=(0,i.m9)(r);var c=o.kc(u);if(r instanceof af)a.push(u);else{var h=gf(r,c);null!=h&&(a.push(u),s.set(u,h))}}));var u=new jr(a);return new $l(s,u,o.fieldTransforms)}function pf(t,e,n,r,o,a){var s=t.Bc(1,e,n),u=[Af(e,r,n)],c=[o];if(a.length%2!=0)throw new vr(mr.INVALID_ARGUMENT,"Function "+e+"() needs to be called with an even number of arguments that alternate between field names and values.");for(var h=0;h<a.length;h+=2)u.push(Af(e,a[h])),c.push(a[h+1]);for(var l=[],f=pi.empty(),p=u.length-1;p>=0;--p)if(!If(l,u[p])){var d=u[p],g=c[p];g=(0,i.m9)(g);var m=s.kc(d);if(g instanceof af)l.push(d);else{var v=gf(g,m);null!=v&&(l.push(d),f.set(d,v))}}var y=new jr(l);return new $l(f,y,s.fieldTransforms)}function df(t,e,n,r){return void 0===r&&(r=!1),gf(n,t.Bc(r?4:3,e))}function gf(t,e){if(vf(t=(0,i.m9)(t)))return yf("Unsupported field value:",e,t),mf(t,e);if(t instanceof Yl)return function(t,e){if(!tf(e.Dc))throw e.$c(t._methodName+"() can only be used with update() and set()");if(!e.path)throw e.$c(t._methodName+"() is not currently supported inside arrays");var n=t._toFieldTransform(e);n&&e.fieldTransforms.push(n)}(t,e),null;if(void 0===t&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.settings.xc&&4!==e.Dc)throw e.$c("Nested arrays are not supported");return function(t,e){for(var n=[],r=0,i=0,o=t;i<o.length;i++){var a=gf(o[i],e.Oc(r));null==a&&(a={nullValue:"NULL_VALUE"}),n.push(a),r++}return{arrayValue:{values:n}}}(t,e)}return function(t,e){if(null===(t=(0,i.m9)(t)))return{nullValue:"NULL_VALUE"};if("number"==typeof t)return eo(e.R,t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){var n=Or.fromDate(t);return{timestampValue:ha(e.R,n)}}if(t instanceof Or)return n=new Or(t.seconds,1e3*Math.floor(t.nanoseconds/1e3)),{timestampValue:ha(e.R,n)};if(t instanceof Jl)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof Wl)return{bytesValue:la(e.R,t._byteString)};if(t instanceof Bl){n=e.databaseId;var r=t.firestore._databaseId;if(!r.isEqual(n))throw e.$c("Document reference is for database "+r.projectId+"/"+r.database+" but should be for database "+n.projectId+"/"+n.database);return{referenceValue:da(t.firestore._databaseId||e.databaseId,t._key.path)}}throw e.$c("Unsupported field value: "+xl(t))}(t,e)}function mf(t,e){var n={};return Mr(t)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):Pr(t,(function(t,r){var i=gf(r,e.Nc(t));null!=i&&(n[t]=i)})),{mapValue:{fields:n}}}function vf(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof Or||t instanceof Jl||t instanceof Wl||t instanceof Bl||t instanceof Yl)}function yf(t,e,n){if(!vf(n)||!function(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}(n)){var r=xl(n);throw"an object"===r?e.$c(t+" a custom object"):e.$c(t+" "+r)}}function Af(t,e,n){if((e=(0,i.m9)(e))instanceof Kl)return e._internalPath;if("string"==typeof e)return wf(t,e);throw _f("Field path arguments must be of type string or FieldPath.",t,!1,void 0,n)}var bf=new RegExp("[~\\*/\\[\\]]");function wf(t,e,n){if(e.search(bf)>=0)throw _f("Invalid field path ("+e+"). Paths must not contain '~', '*', '/', '[', or ']'",t,!1,void 0,n);try{return(new(Kl.bind.apply(Kl,(0,dr.ev)([void 0],e.split(".")))))._internalPath}catch(r){throw _f("Invalid field path ("+e+"). Paths must not be empty, begin with '.', end with '.', or contain '..'",t,!1,void 0,n)}}function _f(t,e,n,r,i){var o=r&&!r.isEmpty(),a=void 0!==i,s="Function "+e+"() called with invalid data";n&&(s+=" (via `toFirestore()`)");var u="";return(o||a)&&(u+=" (found",o&&(u+=" in field "+r),a&&(u+=" in document "+i),u+=")"),new vr(mr.INVALID_ARGUMENT,(s+=". ")+t+u)}function If(t,e){return t.some((function(t){return t.isEqual(e)}))}var Ef=function(){function t(t,e,n,r,i){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=r,this._converter=i}return Object.defineProperty(t.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ref",{get:function(){return new Bl(this._firestore,this._converter,this._key)},enumerable:!1,configurable:!0}),t.prototype.exists=function(){return null!==this._document},t.prototype.data=function(){if(this._document){if(this._converter){var t=new Tf(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.toProto())}},t.prototype.get=function(t){if(this._document){var e=this._document.data.field(Cf("DocumentSnapshot.get",t));if(null!==e)return this._userDataWriter.convertValue(e)}},t}(),Tf=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,dr.ZT)(e,t),e.prototype.data=function(){return t.prototype.data.call(this)},e}(Ef);function Cf(t,e){return"string"==typeof e?wf(t,e):e instanceof Kl?e._internalPath:e._delegate._internalPath}var Sf=function(){function t(t,e){this.hasPendingWrites=t,this.fromCache=e}return t.prototype.isEqual=function(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache},t}(),xf=function(t){function e(e,n,r,i,o,a){var s=this;return(s=t.call(this,e,n,r,i,a)||this)._firestore=e,s._firestoreImpl=e,s.metadata=o,s}return(0,dr.ZT)(e,t),e.prototype.exists=function(){return t.prototype.exists.call(this)},e.prototype.data=function(t){if(void 0===t&&(t={}),this._document){if(this._converter){var e=new Df(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(e,t)}return this._userDataWriter.convertValue(this._document.data.toProto(),t.serverTimestamps)}},e.prototype.get=function(t,e){if(void 0===e&&(e={}),this._document){var n=this._document.data.field(Cf("DocumentSnapshot.get",t));if(null!==n)return this._userDataWriter.convertValue(n,e.serverTimestamps)}},e}(Ef),Df=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,dr.ZT)(e,t),e.prototype.data=function(e){return void 0===e&&(e={}),t.prototype.data.call(this,e)},e}(xf),kf=function(){function t(t,e,n,r){this._firestore=t,this._userDataWriter=e,this._snapshot=r,this.metadata=new Sf(r.hasPendingWrites,r.fromCache),this.query=n}return Object.defineProperty(t.prototype,"docs",{get:function(){var t=[];return this.forEach((function(e){return t.push(e)})),t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this._snapshot.docs.size},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"empty",{get:function(){return 0===this.size},enumerable:!1,configurable:!0}),t.prototype.forEach=function(t,e){var n=this;this._snapshot.docs.forEach((function(r){t.call(e,new Df(n._firestore,n._userDataWriter,r.key,r,new Sf(n._snapshot.mutatedKeys.has(r.key),n._snapshot.fromCache),n.query._converter))}))},t.prototype.docChanges=function(t){void 0===t&&(t={});var e=!!t.includeMetadataChanges;if(e&&this._snapshot.excludesMetadataChanges)throw new vr(mr.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(t,e){if(t._snapshot.oldDocs.isEmpty()){var n=0;return t._snapshot.docChanges.map((function(e){var r=new Df(t._firestore,t._userDataWriter,e.doc.key,e.doc,new Sf(t._snapshot.mutatedKeys.has(e.doc.key),t._snapshot.fromCache),t.query._converter);return e.doc,{type:"added",doc:r,oldIndex:-1,newIndex:n++}}))}var r=t._snapshot.oldDocs;return t._snapshot.docChanges.filter((function(t){return e||3!==t.type})).map((function(e){var n=new Df(t._firestore,t._userDataWriter,e.doc.key,e.doc,new Sf(t._snapshot.mutatedKeys.has(e.doc.key),t._snapshot.fromCache),t.query._converter),i=-1,o=-1;return 0!==e.type&&(i=r.indexOf(e.doc.key),r=r.delete(e.doc.key)),1!==e.type&&(o=(r=r.add(e.doc)).indexOf(e.doc.key)),{type:Rf(e.type),doc:n,oldIndex:i,newIndex:o}}))}(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges},t}();function Rf(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return Er()}}function Of(t,e){return t instanceof xf&&e instanceof xf?t._firestore===e._firestore&&t._key.isEqual(e._key)&&(null===t._document?null===e._document:t._document.isEqual(e._document))&&t._converter===e._converter:t instanceof kf&&e instanceof kf&&t._firestore===e._firestore&&Fl(t.query,e.query)&&t.metadata.isEqual(e.metadata)&&t._snapshot.isEqual(e._snapshot)}function Bf(t){if(Qi(t)&&0===t.explicitOrderBy.length)throw new vr(mr.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}var Nf=function(){};function Pf(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0,i=e;r<i.length;r++){t=i[r]._apply(t)}return t}var Mf=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).Qc=e,i.Kc=n,i.jc=r,i.type="where",i}return(0,dr.ZT)(e,t),e.prototype._apply=function(t){var e=rf(t.firestore),n=function(t,e,n,r,i,o,a){var s;if(i.isKeyField()){if("array-contains"===o||"array-contains-any"===o)throw new vr(mr.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+o+"' queries on FieldPath.documentId().");if("in"===o||"not-in"===o){Gf(a,o);for(var u=[],c=0,h=a;c<h.length;c++){var l=h[c];u.push(qf(r,t,l))}s={arrayValue:{values:u}}}else s=qf(r,t,a)}else"in"!==o&&"not-in"!==o&&"array-contains-any"!==o||Gf(a,o),s=df(n,"where",a,"in"===o||"not-in"===o);var f=wi.create(i,o,s);return function(t,e){if(e.g()){var n=qi(t);if(null!==n&&!n.isEqual(e.field))throw new vr(mr.INVALID_ARGUMENT,"Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '"+n.toString()+"' and '"+e.field.toString()+"'");var r=ji(t);null!==r&&Vf(t,e.field,r)}var i=function(t,e){for(var n=0,r=t.filters;n<r.length;n++){var i=r[n];if(e.indexOf(i.op)>=0)return i.op}return null}(t,function(t){switch(t){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(null!==i)throw i===e.op?new vr(mr.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+e.op.toString()+"' filter."):new vr(mr.INVALID_ARGUMENT,"Invalid query. You cannot use '"+e.op.toString()+"' filters with '"+i.toString()+"' filters.")}(t,f),f}(t._query,0,e,t.firestore._databaseId,this.Qc,this.Kc,this.jc);return new Nl(t.firestore,t._converter,function(t,e){var n=t.filters.concat([e]);return new Mi(t.path,t.collectionGroup,t.explicitOrderBy.slice(),n,t.limit,t.limitType,t.startAt,t.endAt)}(t._query,n))},e}(Nf),Lf=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).Qc=e,r.Wc=n,r.type="orderBy",r}return(0,dr.ZT)(e,t),e.prototype._apply=function(t){var e=function(t,e,n){if(null!==t.startAt)throw new vr(mr.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==t.endAt)throw new vr(mr.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");var r=new Oi(e,n);return function(t,e){if(null===ji(t)){var n=qi(t);null!==n&&Vf(t,n,e.field)}}(t,r),r}(t._query,this.Qc,this.Wc);return new Nl(t.firestore,t._converter,function(t,e){var n=t.explicitOrderBy.concat([e]);return new Mi(t.path,t.collectionGroup,n,t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(t._query,e))},e}(Nf),Uf=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).type=e,i.Gc=n,i.zc=r,i}return(0,dr.ZT)(e,t),e.prototype._apply=function(t){return new Nl(t.firestore,t._converter,Hi(t._query,this.Gc,this.zc))},e}(Nf),Ff=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).type=e,i.Hc=n,i.Jc=r,i}return(0,dr.ZT)(e,t),e.prototype._apply=function(t){var e=jf(t,this.type,this.Hc,this.Jc);return new Nl(t.firestore,t._converter,function(t,e){return new Mi(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,e,t.endAt)}(t._query,e))},e}(Nf),Qf=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).type=e,i.Hc=n,i.Jc=r,i}return(0,dr.ZT)(e,t),e.prototype._apply=function(t){var e=jf(t,this.type,this.Hc,this.Jc);return new Nl(t.firestore,t._converter,function(t,e){return new Mi(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,e)}(t._query,e))},e}(Nf);function jf(t,e,n,r){if(n[0]=(0,i.m9)(n[0]),n[0]instanceof Ef)return function(t,e,n,r,i){if(!r)throw new vr(mr.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for "+n+"().");for(var o=[],a=0,s=Vi(t);a<s.length;a++){var u=s[a];if(u.field.isKeyField())o.push(si(e,r.key));else{var c=r.data.field(u.field);if(Kr(c))throw new vr(mr.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+u.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===c){var h=u.field.canonicalString();throw new vr(mr.INVALID_ARGUMENT,"Invalid query. You are trying to start or end a query using a document for which the field '"+h+"' (used as the orderBy) does not exist.")}o.push(c)}}return new ki(o,i)}(t._query,t.firestore._databaseId,e,n[0]._document,r);var o=rf(t.firestore);return function(t,e,n,r,i,o){var a=t.explicitOrderBy;if(i.length>a.length)throw new vr(mr.INVALID_ARGUMENT,"Too many arguments provided to "+r+"(). The number of arguments must be less than or equal to the number of orderBy() clauses");for(var s=[],u=0;u<i.length;u++){var c=i[u];if(a[u].field.isKeyField()){if("string"!=typeof c)throw new vr(mr.INVALID_ARGUMENT,"Invalid query. Expected a string for document ID in "+r+"(), but got a "+typeof c);if(!Gi(t)&&-1!==c.indexOf("/"))throw new vr(mr.INVALID_ARGUMENT,"Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to "+r+"() must be a plain document ID, but '"+c+"' contains a slash.");var h=t.path.child(Ur.fromString(c));if(!$r.isDocumentKey(h))throw new vr(mr.INVALID_ARGUMENT,"Invalid query. When querying a collection group and ordering by FieldPath.documentId(), the value passed to "+r+"() must result in a valid document path, but '"+h+"' is not because it contains an odd number of segments.");var l=new $r(h);s.push(si(e,l))}else{var f=df(n,r,c);s.push(f)}}return new ki(s,o)}(t._query,t.firestore._databaseId,o,e,n,r)}function qf(t,e,n){if("string"==typeof(n=(0,i.m9)(n))){if(""===n)throw new vr(mr.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!Gi(e)&&-1!==n.indexOf("/"))throw new vr(mr.INVALID_ARGUMENT,"Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '"+n+"' contains a '/' character.");var r=e.path.child(Ur.fromString(n));if(!$r.isDocumentKey(r))throw new vr(mr.INVALID_ARGUMENT,"Invalid query. When querying a collection group by FieldPath.documentId(), the value provided must result in a valid document path, but '"+r+"' is not because it has an odd number of segments ("+r.length+").");return si(t,new $r(r))}if(n instanceof Bl)return si(t,n._key);throw new vr(mr.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+xl(n)+".")}function Gf(t,e){if(!Array.isArray(t)||0===t.length)throw new vr(mr.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+e.toString()+"' filters.");if(t.length>10)throw new vr(mr.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters support a maximum of 10 elements in the value array.")}function Vf(t,e,n){if(!n.isEqual(e))throw new vr(mr.INVALID_ARGUMENT,"Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '"+e.toString()+"' and so you must also use '"+e.toString()+"' as your first argument to orderBy(), but your first orderBy() is on field '"+n.toString()+"' instead.")}var zf=function(){function t(){}return t.prototype.convertValue=function(t,e){switch(void 0===e&&(e="none"),ti(t)){case 0:return null;case 1:return t.booleanValue;case 2:return zr(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(Hr(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 10:return this.convertObject(t.mapValue,e);default:throw Er()}},t.prototype.convertObject=function(t,e){var n=this,r={};return Pr(t.fields||{},(function(t,i){r[t]=n.convertValue(i,e)})),r},t.prototype.convertGeoPoint=function(t){return new Jl(zr(t.latitude),zr(t.longitude))},t.prototype.convertArray=function(t,e){var n=this;return(t.values||[]).map((function(t){return n.convertValue(t,e)}))},t.prototype.convertServerTimestamp=function(t,e){switch(e){case"previous":var n=Wr(t);return null==n?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(Yr(t));default:return null}},t.prototype.convertTimestamp=function(t){var e=Vr(t);return new Or(e.seconds,e.nanos)},t.prototype.convertDocumentKey=function(t,e){var n=Ur.fromString(t);Tr(Fa(n));var r=new ml(n.get(1),n.get(3)),i=new $r(n.popFirst(5));return r.isEqual(e)||wr("Document "+i+" contains a document reference within a different database ("+r.projectId+"/"+r.database+") which is not supported. It will be treated as a reference in the current database ("+e.projectId+"/"+e.database+") instead."),i},t}();function Hf(t,e,n){return t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e}var Kf=function(t){function e(e){var n=this;return(n=t.call(this)||this).firestore=e,n}return(0,dr.ZT)(e,t),e.prototype.convertBytes=function(t){return new Wl(t)},e.prototype.convertReference=function(t){var e=this.convertDocumentKey(t,this.firestore._databaseId);return new Bl(this.firestore,null,e)},e}(zf),Wf=function(){function t(t,e){this._firestore=t,this._commitHandler=e,this._mutations=[],this._committed=!1,this._dataReader=rf(t)}return t.prototype.set=function(t,e,n){this._verifyNotCommitted();var r=Yf(t,this._firestore),i=Hf(r._converter,e,n),o=of(this._dataReader,"WriteBatch.set",r._key,i,null!==r._converter,n);return this._mutations.push(o.toMutation(r._key,vo.none())),this},t.prototype.update=function(t,e,n){for(var r=[],o=3;o<arguments.length;o++)r[o-3]=arguments[o];this._verifyNotCommitted();var a,s=Yf(t,this._firestore);return a="string"==typeof(e=(0,i.m9)(e))||e instanceof Kl?pf(this._dataReader,"WriteBatch.update",s._key,e,n,r):ff(this._dataReader,"WriteBatch.update",s._key,e),this._mutations.push(a.toMutation(s._key,vo.exists(!0))),this},t.prototype.delete=function(t){this._verifyNotCommitted();var e=Yf(t,this._firestore);return this._mutations=this._mutations.concat(new Oo(e._key,vo.none())),this},t.prototype.commit=function(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()},t.prototype._verifyNotCommitted=function(){if(this._committed)throw new vr(mr.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},t}();function Yf(t,e){if((t=(0,i.m9)(t)).firestore!==e)throw new vr(mr.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return t}var Jf=function(t){function e(e){var n=this;return(n=t.call(this)||this).firestore=e,n}return(0,dr.ZT)(e,t),e.prototype.convertBytes=function(t){return new Wl(t)},e.prototype.convertReference=function(t){var e=this.convertDocumentKey(t,this.firestore._databaseId);return new Bl(this.firestore,null,e)},e}(zf);function Xf(t,e,n){for(var r=[],o=3;o<arguments.length;o++)r[o-3]=arguments[o];t=Dl(t,Bl);var a=Dl(t.firestore,ql),s=rf(a);return $f(a,[("string"==typeof(e=(0,i.m9)(e))||e instanceof Kl?pf(s,"updateDoc",t._key,e,n,r):ff(s,"updateDoc",t._key,e)).toMutation(t._key,vo.exists(!0))])}function Zf(t){for(var e,n,r,o=[],a=1;a<arguments.length;a++)o[a-1]=arguments[a];t=(0,i.m9)(t);var s={includeMetadataChanges:!1},u=0;"object"!=typeof o[u]||jl(o[u])||(s=o[u],u++);var c,h,l,f={includeMetadataChanges:s.includeMetadataChanges};if(jl(o[u])){var p=o[u];o[u]=null===(e=p.next)||void 0===e?void 0:e.bind(p),o[u+1]=null===(n=p.error)||void 0===n?void 0:n.bind(p),o[u+2]=null===(r=p.complete)||void 0===r?void 0:r.bind(p)}if(t instanceof Bl)h=Dl(t.firestore,ql),l=Ui(t._key.path),c={next:function(e){o[u]&&o[u](tp(h,t,e))},error:o[u+1],complete:o[u+2]};else{var d=Dl(t,Nl);h=Dl(d.firestore,ql),l=d._query;var g=new Jf(h);c={next:function(t){o[u]&&o[u](new kf(h,g,d,t))},error:o[u+1],complete:o[u+2]},Bf(t._query)}return function(t,e,n,r){var i=this,o=new tl(r),a=new ch(e,o,n);return t.asyncQueue.enqueueAndForget((function(){return(0,dr.mG)(i,void 0,void 0,(function(){var e;return(0,dr.Jh)(this,(function(n){switch(n.label){case 0:return e=ih,[4,fl(t)];case 1:return[2,e.apply(void 0,[n.sent(),a])]}}))}))})),function(){o.Wo(),t.asyncQueue.enqueueAndForget((function(){return(0,dr.mG)(i,void 0,void 0,(function(){var e;return(0,dr.Jh)(this,(function(n){switch(n.label){case 0:return e=oh,[4,fl(t)];case 1:return[2,e.apply(void 0,[n.sent(),a])]}}))}))}))}}(Gl(h),l,f,c)}function $f(t,e){return function(t,e){var n=this,r=new cs;return t.asyncQueue.enqueueAndForget((function(){return(0,dr.mG)(n,void 0,void 0,(function(){var n;return(0,dr.Jh)(this,(function(i){switch(i.label){case 0:return n=_h,[4,ll(t)];case 1:return[2,n.apply(void 0,[i.sent(),e,r])]}}))}))})),r.promise}(Gl(t),e)}function tp(t,e,n){var r=n.docs.get(e._key),i=new Jf(t);return new xf(t,i,e._key,r,new Sf(n.hasPendingWrites,n.fromCache),e._converter)}var ep=function(t){function e(e,n){var r=this;return(r=t.call(this,e,n)||this)._firestore=e,r}return(0,dr.ZT)(e,t),e.prototype.get=function(e){var n=this,r=Yf(e,this._firestore),i=new Jf(this._firestore);return t.prototype.get.call(this,e).then((function(t){return new xf(n._firestore,i,r._key,t._document,new Sf(!1,!1),r._converter)}))},e}(function(){function t(t,e){this._firestore=t,this._transaction=e,this._dataReader=rf(t)}return t.prototype.get=function(t){var e=this,n=Yf(t,this._firestore),r=new Kf(this._firestore);return this._transaction.lookup([n._key]).then((function(t){if(!t||1!==t.length)return Er();var i=t[0];if(i.isFoundDocument())return new Ef(e._firestore,r,i.key,i,n._converter);if(i.isNoDocument())return new Ef(e._firestore,r,n._key,null,n._converter);throw Er()}))},t.prototype.set=function(t,e,n){var r=Yf(t,this._firestore),i=Hf(r._converter,e,n),o=of(this._dataReader,"Transaction.set",r._key,i,null!==r._converter,n);return this._transaction.set(r._key,o),this},t.prototype.update=function(t,e,n){for(var r=[],o=3;o<arguments.length;o++)r[o-3]=arguments[o];var a,s=Yf(t,this._firestore);return a="string"==typeof(e=(0,i.m9)(e))||e instanceof Kl?pf(this._dataReader,"Transaction.update",s._key,e,n,r):ff(this._dataReader,"Transaction.update",s._key,e),this._transaction.update(s._key,a),this},t.prototype.delete=function(t){var e=Yf(t,this._firestore);return this._transaction.delete(e._key),this},t}());function np(){if("undefined"==typeof Uint8Array)throw new vr(mr.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function rp(){if("undefined"==typeof atob)throw new vr(mr.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var ip=function(){function t(t){this._delegate=t}return t.fromBase64String=function(e){return rp(),new t(Wl.fromBase64String(e))},t.fromUint8Array=function(e){return np(),new t(Wl.fromUint8Array(e))},t.prototype.toBase64=function(){return rp(),this._delegate.toBase64()},t.prototype.toUint8Array=function(){return np(),this._delegate.toUint8Array()},t.prototype.isEqual=function(t){return this._delegate.isEqual(t._delegate)},t.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},t}(),op=function(){function t(){}return t.prototype.enableIndexedDbPersistence=function(t,e){return function(t,e){Hl(t=Dl(t,ql));var n=Gl(t),r=t._freezeSettings(),i=new $h;return zl(n,i,new Xh(i,r.cacheSizeBytes,null==e?void 0:e.forceOwnership))}(t._delegate,{forceOwnership:e})},t.prototype.enableMultiTabIndexedDbPersistence=function(t){return function(t){Hl(t=Dl(t,ql));var e=Gl(t),n=t._freezeSettings(),r=new $h;return zl(e,r,new Zh(r,n.cacheSizeBytes))}(t._delegate)},t.prototype.clearIndexedDbPersistence=function(t){return function(t){var e=this;if(t._initialized&&!t._terminated)throw new vr(mr.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");var n=new cs;return t._queue.enqueueAndForgetEvenWhileRestricted((function(){return(0,dr.mG)(e,void 0,void 0,(function(){var e;return(0,dr.Jh)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,function(t){return(0,dr.mG)(this,void 0,void 0,(function(){var e;return(0,dr.Jh)(this,(function(n){switch(n.label){case 0:return fs.yt()?(e=t+"main",[4,fs.delete(e)]):[2,Promise.resolve()];case 1:return n.sent(),[2]}}))}))}(Iu(t._databaseId,t._persistenceKey))];case 1:return r.sent(),n.resolve(),[3,3];case 2:return e=r.sent(),n.reject(e),[3,3];case 3:return[2]}}))}))})),n.promise}(t._delegate)},t}(),ap=function(){function t(t,e,n){var r=this;this._delegate=e,this.Yc=n,this.INTERNAL={delete:function(){return r.terminate()}},t instanceof ml||(this.Xc=t)}return Object.defineProperty(t.prototype,"_databaseId",{get:function(){return this._delegate._databaseId},enumerable:!1,configurable:!0}),t.prototype.settings=function(t){t.merge&&delete(t=Object.assign(Object.assign({},this._delegate._getSettings()),t)).merge,this._delegate._setSettings(t)},t.prototype.useEmulator=function(t,e){!function(t,e,n){var r=(t=Dl(t,Ol))._getSettings();"firestore.googleapis.com"!==r.host&&r.host!==e&&_r("Host has been set in both settings() and useEmulator(), emulator host will be used"),t._setSettings(Object.assign(Object.assign({},r),{host:e+":"+n,ssl:!1}))}(this._delegate,t,e)},t.prototype.enableNetwork=function(){return function(t){var e=this;return t.asyncQueue.enqueue((function(){return(0,dr.mG)(e,void 0,void 0,(function(){var e,n;return(0,dr.Jh)(this,(function(r){switch(r.label){case 0:return[4,ul(t)];case 1:return e=r.sent(),[4,hl(t)];case 2:return n=r.sent(),[2,(e.setNetworkEnabled(!0),function(t){var e=Cr(t);return e.$r.delete(0),Cc(e)}(n))]}}))}))}))}(Gl(Dl(this._delegate,ql)))},t.prototype.disableNetwork=function(){return function(t){var e=this;return t.asyncQueue.enqueue((function(){return(0,dr.mG)(e,void 0,void 0,(function(){var e,n;return(0,dr.Jh)(this,(function(r){switch(r.label){case 0:return[4,ul(t)];case 1:return e=r.sent(),[4,hl(t)];case 2:return n=r.sent(),[2,(e.setNetworkEnabled(!1),function(t){return(0,dr.mG)(this,void 0,void 0,(function(){var e;return(0,dr.Jh)(this,(function(n){switch(n.label){case 0:return(e=Cr(t)).$r.add(0),[4,Sc(e)];case 1:return n.sent(),e.Br.set("Offline"),[2]}}))}))}(n))]}}))}))}))}(Gl(Dl(this._delegate,ql)))},t.prototype.enablePersistence=function(t){var e=!1,n=!1;return t&&Tl("synchronizeTabs",e=!!t.synchronizeTabs,"experimentalForceOwningTab",n=!!t.experimentalForceOwningTab),e?this.Yc.enableMultiTabIndexedDbPersistence(this):this.Yc.enableIndexedDbPersistence(this,n)},t.prototype.clearPersistence=function(){return this.Yc.clearIndexedDbPersistence(this)},t.prototype.terminate=function(){return this.Xc&&(this.Xc._removeServiceInstance("firestore"),this.Xc._removeServiceInstance("firestore-exp")),this._delegate._delete()},t.prototype.waitForPendingWrites=function(){return function(t){var e=this,n=new cs;return t.asyncQueue.enqueueAndForget((function(){return(0,dr.mG)(e,void 0,void 0,(function(){var e;return(0,dr.Jh)(this,(function(r){switch(r.label){case 0:return e=xh,[4,ll(t)];case 1:return[2,e.apply(void 0,[r.sent(),n])]}}))}))})),n.promise}(Gl(Dl(this._delegate,ql)))},t.prototype.onSnapshotsInSync=function(t){return function(t,e){return function(t,e){var n=this,r=new tl(e);return t.asyncQueue.enqueueAndForget((function(){return(0,dr.mG)(n,void 0,void 0,(function(){var e;return(0,dr.Jh)(this,(function(n){switch(n.label){case 0:return e=function(t,e){Cr(t).Gr.add(e),e.next()},[4,fl(t)];case 1:return[2,e.apply(void 0,[n.sent(),r])]}}))}))})),function(){r.Wo(),t.asyncQueue.enqueueAndForget((function(){return(0,dr.mG)(n,void 0,void 0,(function(){var e;return(0,dr.Jh)(this,(function(n){switch(n.label){case 0:return e=function(t,e){Cr(t).Gr.delete(e)},[4,fl(t)];case 1:return[2,e.apply(void 0,[n.sent(),r])]}}))}))}))}}(Gl(t=Dl(t,ql)),jl(e)?e:{next:e})}(this._delegate,t)},Object.defineProperty(t.prototype,"app",{get:function(){if(!this.Xc)throw new vr(mr.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this.Xc},enumerable:!1,configurable:!0}),t.prototype.collection=function(t){try{return new bp(this,Ml(this._delegate,t))}catch(t){throw fp(t,"collection()","Firestore.collection()")}},t.prototype.doc=function(t){try{return new lp(this,Ll(this._delegate,t))}catch(t){throw fp(t,"doc()","Firestore.doc()")}},t.prototype.collectionGroup=function(t){try{return new vp(this,function(t,e){if(t=Dl(t,Ol),Il("collectionGroup","collection id",e),e.indexOf("/")>=0)throw new vr(mr.INVALID_ARGUMENT,"Invalid collection ID '"+e+"' passed to function collectionGroup(). Collection IDs must not contain '/'.");return new Nl(t,null,function(t){return new Mi(Ur.emptyPath(),t)}(e))}(this._delegate,t))}catch(t){throw fp(t,"collectionGroup()","Firestore.collectionGroup()")}},t.prototype.runTransaction=function(t){var e=this;return function(t,e){return function(t,e){var n=this,r=new cs;return t.asyncQueue.enqueueAndForget((function(){return(0,dr.mG)(n,void 0,void 0,(function(){var n;return(0,dr.Jh)(this,(function(i){switch(i.label){case 0:return[4,function(t){return sl(t).then((function(t){return t.datastore}))}(t)];case 1:return n=i.sent(),new nl(t.asyncQueue,n,e,r).run(),[2]}}))}))})),r.promise}(Gl(t),(function(n){return e(new ep(t,n))}))}(this._delegate,(function(n){return t(new up(e,n))}))},t.prototype.batch=function(){var t=this;return Gl(this._delegate),new cp(new Wf(this._delegate,(function(e){return $f(t._delegate,e)})))},t.prototype.loadBundle=function(t){throw new vr(mr.FAILED_PRECONDITION,'"loadBundle()" does not exist, have you imported "firebase/firestore/bundle"?')},t.prototype.namedQuery=function(t){throw new vr(mr.FAILED_PRECONDITION,'"namedQuery()" does not exist, have you imported "firebase/firestore/bundle"?')},t}(),sp=function(t){function e(e){var n=this;return(n=t.call(this)||this).firestore=e,n}return(0,dr.ZT)(e,t),e.prototype.convertBytes=function(t){return new ip(new Wl(t))},e.prototype.convertReference=function(t){var e=this.convertDocumentKey(t,this.firestore._databaseId);return lp.Zc(e,this.firestore,null)},e}(zf);var up=function(){function t(t,e){this._firestore=t,this._delegate=e,this._userDataWriter=new sp(t)}return t.prototype.get=function(t){var e=this,n=wp(t);return this._delegate.get(n).then((function(t){return new gp(e._firestore,new xf(e._firestore._delegate,e._userDataWriter,t._key,t._document,t.metadata,n._converter))}))},t.prototype.set=function(t,e,n){var r=wp(t);return n?(El("Transaction.set",n),this._delegate.set(r,e,n)):this._delegate.set(r,e),this},t.prototype.update=function(t,e,n){for(var r,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];var a=wp(t);return 2===arguments.length?this._delegate.update(a,e):(r=this._delegate).update.apply(r,(0,dr.ev)([a,e,n],i)),this},t.prototype.delete=function(t){var e=wp(t);return this._delegate.delete(e),this},t}(),cp=function(){function t(t){this._delegate=t}return t.prototype.set=function(t,e,n){var r=wp(t);return n?(El("WriteBatch.set",n),this._delegate.set(r,e,n)):this._delegate.set(r,e),this},t.prototype.update=function(t,e,n){for(var r,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];var a=wp(t);return 2===arguments.length?this._delegate.update(a,e):(r=this._delegate).update.apply(r,(0,dr.ev)([a,e,n],i)),this},t.prototype.delete=function(t){var e=wp(t);return this._delegate.delete(e),this},t.prototype.commit=function(){return this._delegate.commit()},t}(),hp=function(){function t(t,e,n){this._firestore=t,this._userDataWriter=e,this._delegate=n}return t.prototype.fromFirestore=function(t,e){var n=new Df(this._firestore._delegate,this._userDataWriter,t._key,t._document,t.metadata,null);return this._delegate.fromFirestore(new mp(this._firestore,n),null!=e?e:{})},t.prototype.toFirestore=function(t,e){return e?this._delegate.toFirestore(t,e):this._delegate.toFirestore(t)},t.tu=function(e,n){var r=t.eu,i=r.get(e);i||(i=new WeakMap,r.set(e,i));var o=i.get(n);return o||(o=new t(e,new sp(e),n),i.set(n,o)),o},t}();hp.eu=new WeakMap;var lp=function(){function t(t,e){this.firestore=t,this._delegate=e,this._userDataWriter=new sp(t)}return t.nu=function(e,n,r){if(e.length%2!=0)throw new vr(mr.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+e.canonicalString()+" has "+e.length);return new t(n,new Bl(n._delegate,r,new $r(e)))},t.Zc=function(e,n,r){return new t(n,new Bl(n._delegate,r,e))},Object.defineProperty(t.prototype,"id",{get:function(){return this._delegate.id},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return new bp(this.firestore,this._delegate.parent)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"path",{get:function(){return this._delegate.path},enumerable:!1,configurable:!0}),t.prototype.collection=function(t){try{return new bp(this.firestore,Ml(this._delegate,t))}catch(t){throw fp(t,"collection()","DocumentReference.collection()")}},t.prototype.isEqual=function(t){return(t=(0,i.m9)(t))instanceof Bl&&Ul(this._delegate,t)},t.prototype.set=function(t,e){e=El("DocumentReference.set",e);try{return function(t,e,n){t=Dl(t,Bl);var r=Dl(t.firestore,ql),i=Hf(t._converter,e,n);return $f(r,[of(rf(r),"setDoc",t._key,i,null!==t._converter,n).toMutation(t._key,vo.none())])}(this._delegate,t,e)}catch(t){throw fp(t,"setDoc()","DocumentReference.set()")}},t.prototype.update=function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];try{return 1===arguments.length?Xf(this._delegate,t):Xf.apply(void 0,(0,dr.ev)([this._delegate,t,e],n))}catch(t){throw fp(t,"updateDoc()","DocumentReference.update()")}},t.prototype.delete=function(){return $f(Dl((t=this._delegate).firestore,ql),[new Oo(t._key,vo.none())]);var t},t.prototype.onSnapshot=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=pp(e),i=dp(e,(function(e){return new gp(t.firestore,new xf(t.firestore._delegate,t._userDataWriter,e._key,e._document,e.metadata,t._delegate._converter))}));return Zf(this._delegate,r,i)},t.prototype.get=function(t){var e=this;return("cache"===(null==t?void 0:t.source)?function(t){t=Dl(t,Bl);var e=Dl(t.firestore,ql),n=Gl(e),r=new Jf(e);return function(t,e){var n=this,r=new cs;return t.asyncQueue.enqueueAndForget((function(){return(0,dr.mG)(n,void 0,void 0,(function(){var n;return(0,dr.Jh)(this,(function(i){switch(i.label){case 0:return n=function(t,e,n){return(0,dr.mG)(this,void 0,void 0,(function(){var r,i;return(0,dr.Jh)(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,function(t,e){var n=Cr(t);return n.persistence.runTransaction("read document","readonly",(function(t){return n.Mn.mn(t,e)}))}(t,e)];case 1:return(i=o.sent()).isFoundDocument()?n.resolve(i):i.isNoDocument()?n.resolve(null):n.reject(new vr(mr.UNAVAILABLE,"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)")),[3,3];case 2:return r=o.sent(),i=Zc(r,"Failed to get document '"+e+" from cache"),n.reject(i),[3,3];case 3:return[2]}}))}))},[4,cl(t)];case 1:return[2,n.apply(void 0,[i.sent(),e,r])]}}))}))})),r.promise}(n,t._key).then((function(n){return new xf(e,r,t._key,n,new Sf(null!==n&&n.hasLocalMutations,!0),t._converter)}))}(this._delegate):"server"===(null==t?void 0:t.source)?function(t){t=Dl(t,Bl);var e=Dl(t.firestore,ql);return pl(Gl(e),t._key,{source:"server"}).then((function(n){return tp(e,t,n)}))}(this._delegate):function(t){t=Dl(t,Bl);var e=Dl(t.firestore,ql);return pl(Gl(e),t._key).then((function(n){return tp(e,t,n)}))}(this._delegate)).then((function(t){return new gp(e.firestore,new xf(e.firestore._delegate,e._userDataWriter,t._key,t._document,t.metadata,e._delegate._converter))}))},t.prototype.withConverter=function(e){return new t(this.firestore,e?this._delegate.withConverter(hp.tu(this.firestore,e)):this._delegate.withConverter(null))},t}();function fp(t,e,n){return t.message=t.message.replace(e,n),t}function pp(t){for(var e=0,n=t;e<n.length;e++){var r=n[e];if("object"==typeof r&&!jl(r))return r}return{}}function dp(t,e){var n,r,i;return{next:function(t){i.next&&i.next(e(t))},error:null===(n=(i=jl(t[0])?t[0]:jl(t[1])?t[1]:"function"==typeof t[0]?{next:t[0],error:t[1],complete:t[2]}:{next:t[1],error:t[2],complete:t[3]}).error)||void 0===n?void 0:n.bind(i),complete:null===(r=i.complete)||void 0===r?void 0:r.bind(i)}}var gp=function(){function t(t,e){this._firestore=t,this._delegate=e}return Object.defineProperty(t.prototype,"ref",{get:function(){return new lp(this._firestore,this._delegate.ref)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"id",{get:function(){return this._delegate.id},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metadata",{get:function(){return this._delegate.metadata},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"exists",{get:function(){return this._delegate.exists()},enumerable:!1,configurable:!0}),t.prototype.data=function(t){return this._delegate.data(t)},t.prototype.get=function(t,e){return this._delegate.get(t,e)},t.prototype.isEqual=function(t){return Of(this._delegate,t._delegate)},t}(),mp=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,dr.ZT)(e,t),e.prototype.data=function(t){return this._delegate.data(t)},e}(gp),vp=function(){function t(t,e){this.firestore=t,this._delegate=e,this._userDataWriter=new sp(t)}return t.prototype.where=function(e,n,r){try{return new t(this.firestore,Pf(this._delegate,function(t,e,n){var r=e,i=Cf("where",t);return new Mf(i,r,n)}(e,n,r)))}catch(e){throw fp(e,/(orderBy|where)\(\)/,"Query.$1()")}},t.prototype.orderBy=function(e,n){try{return new t(this.firestore,Pf(this._delegate,function(t,e){void 0===e&&(e="asc");var n=e,r=Cf("orderBy",t);return new Lf(r,n)}(e,n)))}catch(e){throw fp(e,/(orderBy|where)\(\)/,"Query.$1()")}},t.prototype.limit=function(e){try{return new t(this.firestore,Pf(this._delegate,function(t){return kl("limit",t),new Uf("limit",t,"F")}(e)))}catch(e){throw fp(e,"limit()","Query.limit()")}},t.prototype.limitToLast=function(e){try{return new t(this.firestore,Pf(this._delegate,function(t){return kl("limitToLast",t),new Uf("limitToLast",t,"L")}(e)))}catch(e){throw fp(e,"limitToLast()","Query.limitToLast()")}},t.prototype.startAt=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return new t(this.firestore,Pf(this._delegate,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Ff("startAt",t,!0)}.apply(void 0,e)))}catch(e){throw fp(e,"startAt()","Query.startAt()")}},t.prototype.startAfter=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return new t(this.firestore,Pf(this._delegate,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Ff("startAfter",t,!1)}.apply(void 0,e)))}catch(e){throw fp(e,"startAfter()","Query.startAfter()")}},t.prototype.endBefore=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return new t(this.firestore,Pf(this._delegate,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Qf("endBefore",t,!0)}.apply(void 0,e)))}catch(e){throw fp(e,"endBefore()","Query.endBefore()")}},t.prototype.endAt=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return new t(this.firestore,Pf(this._delegate,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Qf("endAt",t,!1)}.apply(void 0,e)))}catch(e){throw fp(e,"endAt()","Query.endAt()")}},t.prototype.isEqual=function(t){return Fl(this._delegate,t._delegate)},t.prototype.get=function(t){var e=this;return("cache"===(null==t?void 0:t.source)?function(t){t=Dl(t,Nl);var e=Dl(t.firestore,ql),n=Gl(e),r=new Jf(e);return function(t,e){var n=this,r=new cs;return t.asyncQueue.enqueueAndForget((function(){return(0,dr.mG)(n,void 0,void 0,(function(){var n;return(0,dr.Jh)(this,(function(i){switch(i.label){case 0:return n=function(t,e,n){return(0,dr.mG)(this,void 0,void 0,(function(){var r,i,o,a,s;return(0,dr.Jh)(this,(function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),[4,Uu(t,e,!0)];case 1:return s=u.sent(),r=new gh(e,s.Bn),i=r._o(s.documents),o=r.applyChanges(i,!1),n.resolve(o.snapshot),[3,3];case 2:return a=u.sent(),s=Zc(a,"Failed to execute query '"+e+" against cache"),n.reject(s),[3,3];case 3:return[2]}}))}))},[4,cl(t)];case 1:return[2,n.apply(void 0,[i.sent(),e,r])]}}))}))})),r.promise}(n,t._query).then((function(n){return new kf(e,r,t,n)}))}(this._delegate):"server"===(null==t?void 0:t.source)?function(t){t=Dl(t,Nl);var e=Dl(t.firestore,ql),n=Gl(e),r=new Jf(e);return dl(n,t._query,{source:"server"}).then((function(n){return new kf(e,r,t,n)}))}(this._delegate):function(t){t=Dl(t,Nl);var e=Dl(t.firestore,ql),n=Gl(e),r=new Jf(e);return Bf(t._query),dl(n,t._query).then((function(n){return new kf(e,r,t,n)}))}(this._delegate)).then((function(t){return new Ap(e.firestore,new kf(e.firestore._delegate,e._userDataWriter,e._delegate,t._snapshot))}))},t.prototype.onSnapshot=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=pp(e),i=dp(e,(function(e){return new Ap(t.firestore,new kf(t.firestore._delegate,t._userDataWriter,t._delegate,e._snapshot))}));return Zf(this._delegate,r,i)},t.prototype.withConverter=function(e){return new t(this.firestore,e?this._delegate.withConverter(hp.tu(this.firestore,e)):this._delegate.withConverter(null))},t}(),yp=function(){function t(t,e){this._firestore=t,this._delegate=e}return Object.defineProperty(t.prototype,"type",{get:function(){return this._delegate.type},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"doc",{get:function(){return new mp(this._firestore,this._delegate.doc)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"oldIndex",{get:function(){return this._delegate.oldIndex},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"newIndex",{get:function(){return this._delegate.newIndex},enumerable:!1,configurable:!0}),t}(),Ap=function(){function t(t,e){this._firestore=t,this._delegate=e}return Object.defineProperty(t.prototype,"query",{get:function(){return new vp(this._firestore,this._delegate.query)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metadata",{get:function(){return this._delegate.metadata},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this._delegate.size},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"empty",{get:function(){return this._delegate.empty},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"docs",{get:function(){var t=this;return this._delegate.docs.map((function(e){return new mp(t._firestore,e)}))},enumerable:!1,configurable:!0}),t.prototype.docChanges=function(t){var e=this;return this._delegate.docChanges(t).map((function(t){return new yp(e._firestore,t)}))},t.prototype.forEach=function(t,e){var n=this;this._delegate.forEach((function(r){t.call(e,new mp(n._firestore,r))}))},t.prototype.isEqual=function(t){return Of(this._delegate,t._delegate)},t}(),bp=function(t){function e(e,n){var r=this;return(r=t.call(this,e,n)||this).firestore=e,r._delegate=n,r}return(0,dr.ZT)(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this._delegate.id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this._delegate.path},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){var t=this._delegate.parent;return t?new lp(this.firestore,t):null},enumerable:!1,configurable:!0}),e.prototype.doc=function(t){try{return new lp(this.firestore,void 0===t?Ll(this._delegate):Ll(this._delegate,t))}catch(t){throw fp(t,"doc()","CollectionReference.doc()")}},e.prototype.add=function(t){var e=this;return function(t,e){var n=Dl(t.firestore,ql),r=Ll(t),i=Hf(t._converter,e);return $f(n,[of(rf(t.firestore),"addDoc",r._key,i,null!==t._converter,{}).toMutation(r._key,vo.exists(!1))]).then((function(){return r}))}(this._delegate,t).then((function(t){return new lp(e.firestore,t)}))},e.prototype.isEqual=function(t){return Ul(this._delegate,t._delegate)},e.prototype.withConverter=function(t){return new e(this.firestore,t?this._delegate.withConverter(hp.tu(this.firestore,t)):this._delegate.withConverter(null))},e}(vp);function wp(t){return Dl(t,Bl)}var _p=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._delegate=new(Kl.bind.apply(Kl,(0,dr.ev)([void 0],t)))}return t.documentId=function(){return new t(Qr.keyField().canonicalString())},t.prototype.isEqual=function(t){return(t=(0,i.m9)(t))instanceof Kl&&this._delegate._internalPath.isEqual(t._internalPath)},t}(),Ip=function(){function t(t){this._delegate=t}return t.serverTimestamp=function(){var e=new uf("serverTimestamp");return e._methodName="FieldValue.serverTimestamp",new t(e)},t.delete=function(){var e=new af("deleteField");return e._methodName="FieldValue.delete",new t(e)},t.arrayUnion=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new cf("arrayUnion",t)}.apply(void 0,e);return r._methodName="FieldValue.arrayUnion",new t(r)},t.arrayRemove=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new hf("arrayRemove",t)}.apply(void 0,e);return r._methodName="FieldValue.arrayRemove",new t(r)},t.increment=function(e){var n=function(t){return new lf("increment",t)}(e);return n._methodName="FieldValue.increment",new t(n)},t.prototype.isEqual=function(t){return this._delegate.isEqual(t._delegate)},t}();var Ep,Tp=n(3537),Cp={Firestore:ap,GeoPoint:Jl,Timestamp:Or,Blob:ip,Transaction:up,WriteBatch:cp,DocumentReference:lp,DocumentSnapshot:gp,Query:vp,QueryDocumentSnapshot:mp,QuerySnapshot:Ap,CollectionReference:bp,FieldPath:_p,FieldValue:Ip,setLogLevel:function(t){var e;e=t,yr.setLogLevel(e)},CACHE_SIZE_UNLIMITED:-1};(function(t,e){t.INTERNAL.registerComponent(new Tp.wA("firestore",(function(t){return function(t,e){return new ap(t,new ql(t,e),new op)}(t.getProvider("app").getImmediate(),t.getProvider("auth-internal"))}),"PUBLIC").setServiceProps(Object.assign({},Cp)))})(Ep=r.Z),Ep.registerVersion("@firebase/firestore","2.2.3")},2164:function(t,e,n){"use strict";n.r(e);var r=n(9609),i=n(1191),o=n(6287),a=n(3537),s="firebasestorage.googleapis.com",u="storageBucket",c=function(t){function e(n,r){var i=t.call(this,h(n),"Firebase Storage: "+r+" ("+h(n)+")")||this;return i.customData={serverResponse:null},Object.setPrototypeOf(i,e.prototype),i}return(0,i.ZT)(e,t),e.prototype._codeEquals=function(t){return h(t)===this.code},Object.defineProperty(e.prototype,"message",{get:function(){return this.customData.serverResponse?this.message+"\n"+this.customData.serverResponse:this.message},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"serverResponse",{get:function(){return this.customData.serverResponse},set:function(t){this.customData.serverResponse=t},enumerable:!1,configurable:!0}),e}(o.ZR);function h(t){return"storage/"+t}function l(){return new c("unknown","An unknown error occurred, please check the error payload for server response.")}function f(){return new c("canceled","User canceled the upload/download.")}function p(){return new c("cannot-slice-blob","Cannot slice blob for upload. Please retry the upload.")}function d(t){return new c("invalid-argument",t)}function g(){return new c("app-deleted","The Firebase app was deleted.")}function m(t){return new c("invalid-root-operation","The operation '"+t+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}function v(t,e){return new c("invalid-format","String does not match format '"+t+"': "+e)}function y(t){throw new c("internal-error","Internal error: "+t)}var A={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"},b=function(t,e){this.data=t,this.contentType=e||null};function w(t,e){switch(t){case A.RAW:return new b(_(e));case A.BASE64:case A.BASE64URL:return new b(I(t,e));case A.DATA_URL:return new b((n=new E(e)).base64?I(A.BASE64,n.rest):function(t){var e;try{e=decodeURIComponent(t)}catch(t){throw v(A.DATA_URL,"Malformed data URL.")}return _(e)}(n.rest),function(t){var e=new E(t);return e.contentType}(e))}var n;throw l()}function _(t){for(var e=[],n=0;n<t.length;n++){var r=t.charCodeAt(n);if(r<=127)e.push(r);else if(r<=2047)e.push(192|r>>6,128|63&r);else if(55296==(64512&r))if(n<t.length-1&&56320==(64512&t.charCodeAt(n+1)))r=65536|(1023&r)<<10|1023&t.charCodeAt(++n),e.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r);else e.push(239,191,189);else 56320==(64512&r)?e.push(239,191,189):e.push(224|r>>12,128|r>>6&63,128|63&r)}return new Uint8Array(e)}function I(t,e){switch(t){case A.BASE64:var n=-1!==e.indexOf("-"),r=-1!==e.indexOf("_");if(n||r)throw v(t,"Invalid character '"+(n?"-":"_")+"' found: is it base64url encoded?");break;case A.BASE64URL:var i=-1!==e.indexOf("+"),o=-1!==e.indexOf("/");if(i||o)throw v(t,"Invalid character '"+(i?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/")}var a;try{a=atob(e)}catch(e){throw v(t,"Invalid character found")}for(var s=new Uint8Array(a.length),u=0;u<a.length;u++)s[u]=a.charCodeAt(u);return s}var E=function(t){this.base64=!1,this.contentType=null;var e=t.match(/^data:([^,]+)?,/);if(null===e)throw v(A.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");var n=e[1]||null;null!=n&&(this.base64=(r=n,i=";base64",r.length>=i.length&&r.substring(r.length-i.length)===i),this.contentType=this.base64?n.substring(0,n.length-7):n),this.rest=t.substring(t.indexOf(",")+1);var r,i};var T,C={STATE_CHANGED:"state_changed"},S={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function x(t){switch(t){case"running":case"pausing":case"canceling":return S.RUNNING;case"paused":return S.PAUSED;case"success":return S.SUCCESS;case"canceled":return S.CANCELED;default:return S.ERROR}}!function(t){t[t.NO_ERROR=0]="NO_ERROR",t[t.NETWORK_ERROR=1]="NETWORK_ERROR",t[t.ABORT=2]="ABORT"}(T||(T={}));var D=function(){function t(){var t=this;this.sent_=!1,this.xhr_=new XMLHttpRequest,this.errorCode_=T.NO_ERROR,this.sendPromise_=new Promise((function(e){t.xhr_.addEventListener("abort",(function(){t.errorCode_=T.ABORT,e(t)})),t.xhr_.addEventListener("error",(function(){t.errorCode_=T.NETWORK_ERROR,e(t)})),t.xhr_.addEventListener("load",(function(){e(t)}))}))}return t.prototype.send=function(t,e,n,r){if(this.sent_)throw y("cannot .send() more than once");if(this.sent_=!0,this.xhr_.open(e,t,!0),void 0!==r)for(var i in r)r.hasOwnProperty(i)&&this.xhr_.setRequestHeader(i,r[i].toString());return void 0!==n?this.xhr_.send(n):this.xhr_.send(),this.sendPromise_},t.prototype.getErrorCode=function(){if(!this.sent_)throw y("cannot .getErrorCode() before sending");return this.errorCode_},t.prototype.getStatus=function(){if(!this.sent_)throw y("cannot .getStatus() before sending");try{return this.xhr_.status}catch(t){return-1}},t.prototype.getResponseText=function(){if(!this.sent_)throw y("cannot .getResponseText() before sending");return this.xhr_.responseText},t.prototype.abort=function(){this.xhr_.abort()},t.prototype.getResponseHeader=function(t){return this.xhr_.getResponseHeader(t)},t.prototype.addUploadProgressListener=function(t){null!=this.xhr_.upload&&this.xhr_.upload.addEventListener("progress",t)},t.prototype.removeUploadProgressListener=function(t){null!=this.xhr_.upload&&this.xhr_.upload.removeEventListener("progress",t)},t}(),k=function(){function t(){}return t.prototype.createXhrIo=function(){return new D},t}(),R=function(){function t(t,e){this.bucket=t,this.path_=e}return Object.defineProperty(t.prototype,"path",{get:function(){return this.path_},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isRoot",{get:function(){return 0===this.path.length},enumerable:!1,configurable:!0}),t.prototype.fullServerUrl=function(){var t=encodeURIComponent;return"/b/"+t(this.bucket)+"/o/"+t(this.path)},t.prototype.bucketOnlyServerUrl=function(){return"/b/"+encodeURIComponent(this.bucket)+"/o"},t.makeFromBucketSpec=function(e){var n;try{n=t.makeFromUrl(e)}catch(n){return new t(e,"")}if(""===n.path)return n;throw new c("invalid-default-bucket","Invalid default bucket '"+e+"'.")},t.makeFromUrl=function(e){var n=null,r="([A-Za-z0-9.\\-_]+)";var i=new RegExp("^gs://"+r+"(/(.*))?$","i");function o(t){t.path_=decodeURIComponent(t.path)}for(var a=s.replace(/[.]/g,"\\."),u=[{regex:i,indices:{bucket:1,path:3},postModify:function(t){"/"===t.path.charAt(t.path.length-1)&&(t.path_=t.path_.slice(0,-1))}},{regex:new RegExp("^https?://"+a+"/v[A-Za-z0-9_]+/b/"+r+"/o(/([^?#]*).*)?$","i"),indices:{bucket:1,path:3},postModify:o},{regex:new RegExp("^https?://(?:storage.googleapis.com|storage.cloud.google.com)/"+r+"/([^?#]*)","i"),indices:{bucket:1,path:2},postModify:o}],h=0;h<u.length;h++){var l=u[h],f=l.regex.exec(e);if(f){var p=f[l.indices.bucket],d=f[l.indices.path];d||(d=""),n=new t(p,d),l.postModify(n);break}}if(null==n)throw function(t){return new c("invalid-url","Invalid URL '"+t+"'.")}(e);return n},t}(),O=function(){function t(t){this.promise_=Promise.reject(t)}return t.prototype.getPromise=function(){return this.promise_},t.prototype.cancel=function(t){},t}();function B(t){return"string"==typeof t||t instanceof String}function N(t){return P()&&t instanceof Blob}function P(){return"undefined"!=typeof Blob}function M(t,e,n,r){if(r<e)throw d("Invalid value for '"+t+"'. Expected "+e+" or greater.");if(r>n)throw d("Invalid value for '"+t+"'. Expected "+n+" or less.")}function L(t){return"https://"+s+"/v0"+t}function U(t){var e=encodeURIComponent,n="?";for(var r in t){if(t.hasOwnProperty(r))n=n+(e(r)+"="+e(t[r]))+"&"}return n=n.slice(0,-1)}var F=function(){function t(t,e,n,r,i,o,a,s,u,c,h){var l=this;this.pendingXhr_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.url_=t,this.method_=e,this.headers_=n,this.body_=r,this.successCodes_=i.slice(),this.additionalRetryCodes_=o.slice(),this.callback_=a,this.errorCallback_=s,this.progressCallback_=c,this.timeout_=u,this.pool_=h,this.promise_=new Promise((function(t,e){l.resolve_=t,l.reject_=e,l.start_()}))}return t.prototype.start_=function(){var t=this;function e(e,n){var r,i=t.resolve_,o=t.reject_,a=n.xhr;if(n.wasSuccessCode)try{var s=t.callback_(a,a.getResponseText());void 0!==s?i(s):i()}catch(t){o(t)}else null!==a?((r=l()).serverResponse=a.getResponseText(),t.errorCallback_?o(t.errorCallback_(a,r)):o(r)):n.canceled?o(r=t.appDelete_?g():f()):o(r=new c("retry-limit-exceeded","Max retry time for operation exceeded, please try again."))}this.canceled_?e(0,new Q(!1,null,!0)):this.backoffId_=function(t,e,n){var r=1,o=null,a=!1,s=0;function u(){return 2===s}var c=!1;function h(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];c||(c=!0,e.apply(null,t))}function l(e){o=setTimeout((function(){o=null,t(f,u())}),e)}function f(t){for(var e,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];c||(t||u()||a?h.call.apply(h,(0,i.ev)([null,t],n)):(r<64&&(r*=2),1===s?(s=2,e=0):e=1e3*(r+Math.random()),l(e)))}var p=!1;function d(t){p||(p=!0,c||(null!==o?(t||(s=2),clearTimeout(o),l(0)):t||(s=1)))}return l(0),setTimeout((function(){a=!0,d(!0)}),n),d}((function(e,n){if(n)e(!1,new Q(!1,null,!0));else{var r=t.pool_.createXhrIo();t.pendingXhr_=r,null!==t.progressCallback_&&r.addUploadProgressListener(i),r.send(t.url_,t.method_,t.body_,t.headers_).then((function(n){null!==t.progressCallback_&&n.removeUploadProgressListener(i),t.pendingXhr_=null;var r=n.getErrorCode()===T.NO_ERROR,o=n.getStatus();if(r&&!t.isRetryStatusCode_(o)){var a=-1!==t.successCodes_.indexOf(o);e(!0,new Q(a,n))}else{var s=n.getErrorCode()===T.ABORT;e(!1,new Q(!1,null,s))}}))}function i(e){var n=e.loaded,r=e.lengthComputable?e.total:-1;null!==t.progressCallback_&&t.progressCallback_(n,r)}}),e,this.timeout_)},t.prototype.getPromise=function(){return this.promise_},t.prototype.cancel=function(t){this.canceled_=!0,this.appDelete_=t||!1,null!==this.backoffId_&&(0,this.backoffId_)(!1),null!==this.pendingXhr_&&this.pendingXhr_.abort()},t.prototype.isRetryStatusCode_=function(t){var e=t>=500&&t<600,n=-1!==[408,429].indexOf(t),r=-1!==this.additionalRetryCodes_.indexOf(t);return e||n||r},t}(),Q=function(t,e,n){this.wasSuccessCode=t,this.xhr=e,this.canceled=!!n};function j(){return"undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:void 0}function q(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=j();if(void 0!==n){for(var r=new n,i=0;i<t.length;i++)r.append(t[i]);return r.getBlob()}if(P())return new Blob(t);throw new c("unsupported-environment","This browser doesn't seem to support creating Blobs")}var G=function(){function t(t,e){var n=0,r="";N(t)?(this.data_=t,n=t.size,r=t.type):t instanceof ArrayBuffer?(e?this.data_=new Uint8Array(t):(this.data_=new Uint8Array(t.byteLength),this.data_.set(new Uint8Array(t))),n=this.data_.length):t instanceof Uint8Array&&(e?this.data_=t:(this.data_=new Uint8Array(t.length),this.data_.set(t)),n=t.length),this.size_=n,this.type_=r}return t.prototype.size=function(){return this.size_},t.prototype.type=function(){return this.type_},t.prototype.slice=function(e,n){if(N(this.data_)){var r=function(t,e,n){return t.webkitSlice?t.webkitSlice(e,n):t.mozSlice?t.mozSlice(e,n):t.slice?t.slice(e,n):null}(this.data_,e,n);return null===r?null:new t(r)}return new t(new Uint8Array(this.data_.buffer,e,n-e),!0)},t.getBlob=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(P()){var r=e.map((function(e){return e instanceof t?e.data_:e}));return new t(q.apply(null,r))}var i=e.map((function(t){return B(t)?w(A.RAW,t).data:t.data_})),o=0;i.forEach((function(t){o+=t.byteLength}));var a=new Uint8Array(o),s=0;return i.forEach((function(t){for(var e=0;e<t.length;e++)a[s++]=t[e]})),new t(a,!0)},t.prototype.uploadData=function(){return this.data_},t}();function V(t){var e,n;try{e=JSON.parse(t)}catch(t){return null}return"object"!=typeof(n=e)||Array.isArray(n)?null:e}function z(t){var e=t.lastIndexOf("/",t.length-2);return-1===e?t:t.slice(e+1)}function H(t,e){return e}var K=function(t,e,n,r){this.server=t,this.local=e||t,this.writable=!!n,this.xform=r||H},W=null;function Y(){if(W)return W;var t=[];t.push(new K("bucket")),t.push(new K("generation")),t.push(new K("metageneration")),t.push(new K("name","fullPath",!0));var e=new K("name");e.xform=function(t,e){return function(t){return!B(t)||t.length<2?t:z(t)}(e)},t.push(e);var n=new K("size");return n.xform=function(t,e){return void 0!==e?Number(e):e},t.push(n),t.push(new K("timeCreated")),t.push(new K("updated")),t.push(new K("md5Hash",null,!0)),t.push(new K("cacheControl",null,!0)),t.push(new K("contentDisposition",null,!0)),t.push(new K("contentEncoding",null,!0)),t.push(new K("contentLanguage",null,!0)),t.push(new K("contentType",null,!0)),t.push(new K("metadata","customMetadata",!0)),W=t}function J(t,e,n){for(var r={type:"file"},i=n.length,o=0;o<i;o++){var a=n[o];r[a.local]=a.xform(r,e[a.server])}return function(t,e){Object.defineProperty(t,"ref",{get:function(){var n=t.bucket,r=t.fullPath,i=new R(n,r);return e._makeStorageReference(i)}})}(r,t),r}function X(t,e,n){var r=V(e);return null===r?null:J(t,r,n)}function Z(t,e){for(var n={},r=e.length,i=0;i<r;i++){var o=e[i];o.writable&&(n[o.server]=t[o.local])}return JSON.stringify(n)}var $="prefixes",tt="items";function et(t,e,n){var r=V(n);return null===r?null:function(t,e,n){var r={prefixes:[],items:[],nextPageToken:n.nextPageToken};if(n[$])for(var i=0,o=n[$];i<o.length;i++){var a=o[i].replace(/\/$/,""),s=t._makeStorageReference(new R(e,a));r.prefixes.push(s)}if(n[tt])for(var u=0,c=n[tt];u<c.length;u++){var h=c[u];s=t._makeStorageReference(new R(e,h.name)),r.items.push(s)}return r}(t,e,r)}var nt=function(t,e,n,r){this.url=t,this.method=e,this.handler=n,this.timeout=r,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]};function rt(t){if(!t)throw l()}function it(t,e){return function(n,r){var i=X(t,r,e);return rt(null!==i),i}}function ot(t,e){return function(n,r){var i=X(t,r,e);return rt(null!==i),function(t,e){var n=V(e);if(null===n)return null;if(!B(n.downloadTokens))return null;var r=n.downloadTokens;if(0===r.length)return null;var i=encodeURIComponent;return r.split(",").map((function(e){var n=t.bucket,r=t.fullPath;return L("/b/"+i(n)+"/o/"+i(r))+U({alt:"media",token:e})}))[0]}(i,r)}}function at(t){return function(e,n){var r,i,o;return 401===e.getStatus()?r=new c("unauthenticated","User is not authenticated, please authenticate using Firebase Authentication and try again."):402===e.getStatus()?(o=t.bucket,r=new c("quota-exceeded","Quota for bucket '"+o+"' exceeded, please view quota on https://firebase.google.com/pricing/.")):403===e.getStatus()?(i=t.path,r=new c("unauthorized","User does not have permission to access '"+i+"'.")):r=n,r.serverResponse=n.serverResponse,r}}function st(t){var e=at(t);return function(n,r){var i,o=e(n,r);return 404===n.getStatus()&&(i=t.path,o=new c("object-not-found","Object '"+i+"' does not exist.")),o.serverResponse=r.serverResponse,o}}function ut(t,e,n){var r=L(e.fullServerUrl()),i=t.maxOperationRetryTime,o=new nt(r,"GET",it(t,n),i);return o.errorHandler=st(e),o}function ct(t,e,n,r,i){var o={};e.isRoot?o.prefix="":o.prefix=e.path+"/",n&&n.length>0&&(o.delimiter=n),r&&(o.pageToken=r),i&&(o.maxResults=i);var a=L(e.bucketOnlyServerUrl()),s=t.maxOperationRetryTime,u=new nt(a,"GET",function(t,e){return function(n,r){var i=et(t,e,r);return rt(null!==i),i}}(t,e.bucket),s);return u.urlParams=o,u.errorHandler=at(e),u}function ht(t,e,n){var r=Object.assign({},n);return r.fullPath=t.path,r.size=e.size(),r.contentType||(r.contentType=function(t,e){return t&&t.contentType||e&&e.type()||"application/octet-stream"}(null,e)),r}var lt=function(t,e,n,r){this.current=t,this.total=e,this.finalized=!!n,this.metadata=r||null};function ft(t,e){var n=null;try{n=t.getResponseHeader("X-Goog-Upload-Status")}catch(t){rt(!1)}return rt(!!n&&-1!==(e||["active"]).indexOf(n)),n}var pt=262144;function dt(t,e,n,r,i,o,a,s){var u=new lt(0,0);if(a?(u.current=a.current,u.total=a.total):(u.current=0,u.total=r.size()),r.size()!==u.total)throw new c("server-file-wrong-size","Server recorded incorrect upload file size, please retry the upload.");var h=u.total-u.current,l=h;i>0&&(l=Math.min(l,i));var f=u.current,d=f+l,g={"X-Goog-Upload-Command":l===h?"upload, finalize":"upload","X-Goog-Upload-Offset":u.current},m=r.slice(f,d);if(null===m)throw p();var v=e.maxUploadRetryTime,y=new nt(n,"POST",(function(t,n){var i,a=ft(t,["active","final"]),s=u.current+l,c=r.size();return i="final"===a?it(e,o)(t,n):null,new lt(s,c,"final"===a,i)}),v);return y.headers=g,y.body=m.uploadData(),y.progressCallback=s||null,y.errorHandler=at(t),y}var gt=function(t,e,n){if("function"==typeof t||null!=e||null!=n)this.next=t,this.error=e,this.complete=n;else{var r=t;this.next=r.next,this.error=r.error,this.complete=r.complete}};function mt(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];Promise.resolve().then((function(){return t.apply(void 0,e)}))}}var vt=function(){function t(t,e,n){var r=this;void 0===n&&(n=null),this._transferred=0,this._needToFetchStatus=!1,this._needToFetchMetadata=!1,this._observers=[],this._error=void 0,this._uploadUrl=void 0,this._request=void 0,this._chunkMultiplier=1,this._resolve=void 0,this._reject=void 0,this._ref=t,this._blob=e,this._metadata=n,this._mappings=Y(),this._resumable=this._shouldDoResumable(this._blob),this._state="running",this._errorHandler=function(t){r._request=void 0,r._chunkMultiplier=1,t._codeEquals("canceled")?(r._needToFetchStatus=!0,r.completeTransitions_()):(r._error=t,r._transition("error"))},this._metadataErrorHandler=function(t){r._request=void 0,t._codeEquals("canceled")?r.completeTransitions_():(r._error=t,r._transition("error"))},this._promise=new Promise((function(t,e){r._resolve=t,r._reject=e,r._start()})),this._promise.then(null,(function(){}))}return t.prototype._makeProgressCallback=function(){var t=this,e=this._transferred;return function(n){return t._updateProgress(e+n)}},t.prototype._shouldDoResumable=function(t){return t.size()>262144},t.prototype._start=function(){"running"===this._state&&void 0===this._request&&(this._resumable?void 0===this._uploadUrl?this._createResumable():this._needToFetchStatus?this._fetchStatus():this._needToFetchMetadata?this._fetchMetadata():this._continueUpload():this._oneShotUpload())},t.prototype._resolveToken=function(t){var e=this;this._ref.storage._getAuthToken().then((function(n){switch(e._state){case"running":t(n);break;case"canceling":e._transition("canceled");break;case"pausing":e._transition("paused")}}))},t.prototype._createResumable=function(){var t=this;this._resolveToken((function(e){var n=function(t,e,n,r,i){var o=e.bucketOnlyServerUrl(),a=ht(e,r,i),s={name:a.fullPath},u=L(o),c={"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":r.size(),"X-Goog-Upload-Header-Content-Type":a.contentType,"Content-Type":"application/json; charset=utf-8"},h=Z(a,n),l=t.maxUploadRetryTime,f=new nt(u,"POST",(function(t){var e;ft(t);try{e=t.getResponseHeader("X-Goog-Upload-URL")}catch(t){rt(!1)}return rt(B(e)),e}),l);return f.urlParams=s,f.headers=c,f.body=h,f.errorHandler=at(e),f}(t._ref.storage,t._ref._location,t._mappings,t._blob,t._metadata),r=t._ref.storage._makeRequest(n,e);t._request=r,r.getPromise().then((function(e){t._request=void 0,t._uploadUrl=e,t._needToFetchStatus=!1,t.completeTransitions_()}),t._errorHandler)}))},t.prototype._fetchStatus=function(){var t=this,e=this._uploadUrl;this._resolveToken((function(n){var r=function(t,e,n,r){var i=t.maxUploadRetryTime,o=new nt(n,"POST",(function(t){var e=ft(t,["active","final"]),n=null;try{n=t.getResponseHeader("X-Goog-Upload-Size-Received")}catch(t){rt(!1)}n||rt(!1);var i=Number(n);return rt(!isNaN(i)),new lt(i,r.size(),"final"===e)}),i);return o.headers={"X-Goog-Upload-Command":"query"},o.errorHandler=at(e),o}(t._ref.storage,t._ref._location,e,t._blob),i=t._ref.storage._makeRequest(r,n);t._request=i,i.getPromise().then((function(e){t._request=void 0,t._updateProgress(e.current),t._needToFetchStatus=!1,e.finalized&&(t._needToFetchMetadata=!0),t.completeTransitions_()}),t._errorHandler)}))},t.prototype._continueUpload=function(){var t=this,e=pt*this._chunkMultiplier,n=new lt(this._transferred,this._blob.size()),r=this._uploadUrl;this._resolveToken((function(i){var o;try{o=dt(t._ref._location,t._ref.storage,r,t._blob,e,t._mappings,n,t._makeProgressCallback())}catch(e){return t._error=e,void t._transition("error")}var a=t._ref.storage._makeRequest(o,i);t._request=a,a.getPromise().then((function(e){t._increaseMultiplier(),t._request=void 0,t._updateProgress(e.current),e.finalized?(t._metadata=e.metadata,t._transition("success")):t.completeTransitions_()}),t._errorHandler)}))},t.prototype._increaseMultiplier=function(){pt*this._chunkMultiplier<33554432&&(this._chunkMultiplier*=2)},t.prototype._fetchMetadata=function(){var t=this;this._resolveToken((function(e){var n=ut(t._ref.storage,t._ref._location,t._mappings),r=t._ref.storage._makeRequest(n,e);t._request=r,r.getPromise().then((function(e){t._request=void 0,t._metadata=e,t._transition("success")}),t._metadataErrorHandler)}))},t.prototype._oneShotUpload=function(){var t=this;this._resolveToken((function(e){var n=function(t,e,n,r,i){var o=e.bucketOnlyServerUrl(),a={"X-Goog-Upload-Protocol":"multipart"},s=function(){for(var t="",e=0;e<2;e++)t+=Math.random().toString().slice(2);return t}();a["Content-Type"]="multipart/related; boundary="+s;var u=ht(e,r,i),c="--"+s+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+Z(u,n)+"\r\n--"+s+"\r\nContent-Type: "+u.contentType+"\r\n\r\n",h="\r\n--"+s+"--",l=G.getBlob(c,r,h);if(null===l)throw p();var f={name:u.fullPath},d=L(o),g=t.maxUploadRetryTime,m=new nt(d,"POST",it(t,n),g);return m.urlParams=f,m.headers=a,m.body=l.uploadData(),m.errorHandler=at(e),m}(t._ref.storage,t._ref._location,t._mappings,t._blob,t._metadata),r=t._ref.storage._makeRequest(n,e);t._request=r,r.getPromise().then((function(e){t._request=void 0,t._metadata=e,t._updateProgress(t._blob.size()),t._transition("success")}),t._errorHandler)}))},t.prototype._updateProgress=function(t){var e=this._transferred;this._transferred=t,this._transferred!==e&&this._notifyObservers()},t.prototype._transition=function(t){if(this._state!==t)switch(t){case"canceling":case"pausing":this._state=t,void 0!==this._request&&this._request.cancel();break;case"running":var e="paused"===this._state;this._state=t,e&&(this._notifyObservers(),this._start());break;case"paused":case"error":case"success":this._state=t,this._notifyObservers();break;case"canceled":this._error=f(),this._state=t,this._notifyObservers()}},t.prototype.completeTransitions_=function(){switch(this._state){case"pausing":this._transition("paused");break;case"canceling":this._transition("canceled");break;case"running":this._start()}},Object.defineProperty(t.prototype,"snapshot",{get:function(){var t=x(this._state);return{bytesTransferred:this._transferred,totalBytes:this._blob.size(),state:t,metadata:this._metadata,task:this,ref:this._ref}},enumerable:!1,configurable:!0}),t.prototype.on=function(t,e,n,r){var i=this,o=new gt(e,n,r);return this._addObserver(o),function(){i._removeObserver(o)}},t.prototype.then=function(t,e){return this._promise.then(t,e)},t.prototype.catch=function(t){return this.then(null,t)},t.prototype._addObserver=function(t){this._observers.push(t),this._notifyObserver(t)},t.prototype._removeObserver=function(t){var e=this._observers.indexOf(t);-1!==e&&this._observers.splice(e,1)},t.prototype._notifyObservers=function(){var t=this;this._finishPromise(),this._observers.slice().forEach((function(e){t._notifyObserver(e)}))},t.prototype._finishPromise=function(){if(void 0!==this._resolve){var t=!0;switch(x(this._state)){case S.SUCCESS:mt(this._resolve.bind(null,this.snapshot))();break;case S.CANCELED:case S.ERROR:mt(this._reject.bind(null,this._error))();break;default:t=!1}t&&(this._resolve=void 0,this._reject=void 0)}},t.prototype._notifyObserver=function(t){switch(x(this._state)){case S.RUNNING:case S.PAUSED:t.next&&mt(t.next.bind(t,this.snapshot))();break;case S.SUCCESS:t.complete&&mt(t.complete.bind(t))();break;case S.CANCELED:case S.ERROR:default:t.error&&mt(t.error.bind(t,this._error))()}},t.prototype.resume=function(){var t="paused"===this._state||"pausing"===this._state;return t&&this._transition("running"),t},t.prototype.pause=function(){var t="running"===this._state;return t&&this._transition("pausing"),t},t.prototype.cancel=function(){var t="running"===this._state||"pausing"===this._state;return t&&this._transition("canceling"),t},t}(),yt=function(){function t(t,e){this._service=t,this._location=e instanceof R?e:R.makeFromUrl(e)}return t.prototype.toString=function(){return"gs://"+this._location.bucket+"/"+this._location.path},t.prototype._newRef=function(e,n){return new t(e,n)},Object.defineProperty(t.prototype,"root",{get:function(){var t=new R(this._location.bucket,"");return this._newRef(this._service,t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bucket",{get:function(){return this._location.bucket},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fullPath",{get:function(){return this._location.path},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return z(this._location.path)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"storage",{get:function(){return this._service},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){var e=function(t){if(0===t.length)return null;var e=t.lastIndexOf("/");return-1===e?"":t.slice(0,e)}(this._location.path);if(null===e)return null;var n=new R(this._location.bucket,e);return new t(this._service,n)},enumerable:!1,configurable:!0}),t.prototype._throwIfRoot=function(t){if(""===this._location.path)throw m(t)},t}();function At(t){var e={prefixes:[],items:[]};return bt(t,e).then((function(){return e}))}function bt(t,e,n){return(0,i.mG)(this,void 0,void 0,(function(){var r,o,a;return(0,i.Jh)(this,(function(i){switch(i.label){case 0:return[4,wt(t,{pageToken:n})];case 1:return r=i.sent(),(o=e.prefixes).push.apply(o,r.prefixes),(a=e.items).push.apply(a,r.items),null==r.nextPageToken?[3,3]:[4,bt(t,e,r.nextPageToken)];case 2:i.sent(),i.label=3;case 3:return[2]}}))}))}function wt(t,e){return(0,i.mG)(this,void 0,void 0,(function(){var n,r,o;return(0,i.Jh)(this,(function(i){switch(i.label){case 0:return null!=e&&"number"==typeof e.maxResults&&M("options.maxResults",1,1e3,e.maxResults),[4,t.storage._getAuthToken()];case 1:return n=i.sent(),r=e||{},o=ct(t.storage,t._location,"/",r.pageToken,r.maxResults),[2,t.storage._makeRequest(o,n).getPromise()]}}))}))}function _t(t,e){return(0,i.mG)(this,void 0,void 0,(function(){var n,r;return(0,i.Jh)(this,(function(i){switch(i.label){case 0:return t._throwIfRoot("updateMetadata"),[4,t.storage._getAuthToken()];case 1:return n=i.sent(),r=function(t,e,n,r){var i=L(e.fullServerUrl()),o=Z(n,r),a=t.maxOperationRetryTime,s=new nt(i,"PATCH",it(t,r),a);return s.headers={"Content-Type":"application/json; charset=utf-8"},s.body=o,s.errorHandler=st(e),s}(t.storage,t._location,e,Y()),[2,t.storage._makeRequest(r,n).getPromise()]}}))}))}function It(t){return(0,i.mG)(this,void 0,void 0,(function(){var e,n;return(0,i.Jh)(this,(function(r){switch(r.label){case 0:return t._throwIfRoot("getDownloadURL"),[4,t.storage._getAuthToken()];case 1:return e=r.sent(),n=function(t,e,n){var r=L(e.fullServerUrl()),i=t.maxOperationRetryTime,o=new nt(r,"GET",ot(t,n),i);return o.errorHandler=st(e),o}(t.storage,t._location,Y()),[2,t.storage._makeRequest(n,e).getPromise().then((function(t){if(null===t)throw new c("no-download-url","The given file does not have any download URLs.");return t}))]}}))}))}function Et(t){return(0,i.mG)(this,void 0,void 0,(function(){var e,n;return(0,i.Jh)(this,(function(r){switch(r.label){case 0:return t._throwIfRoot("deleteObject"),[4,t.storage._getAuthToken()];case 1:return e=r.sent(),n=function(t,e){var n=L(e.fullServerUrl()),r=t.maxOperationRetryTime,i=new nt(n,"DELETE",(function(t,e){}),r);return i.successCodes=[200,204],i.errorHandler=st(e),i}(t.storage,t._location),[2,t.storage._makeRequest(n,e).getPromise()]}}))}))}function Tt(t,e){var n=function(t,e){var n=e.split("/").filter((function(t){return t.length>0})).join("/");return 0===t.length?n:t+"/"+n}(t._location.path,e),r=new R(t._location.bucket,n);return new yt(t.storage,r)}function Ct(t){return/^[A-Za-z]+:\/\//.test(t)}function St(t,e){if(t instanceof Dt){var n=t;if(null==n._bucket)throw new c("no-default-bucket","No default bucket found. Did you set the '"+u+"' property when initializing the app?");var r=new yt(n,n._bucket);return null!=e?St(r,e):r}if(void 0!==e){if(e.includes(".."))throw d('`path` param cannot contain ".."');return Tt(t,e)}return t}function xt(t,e){if(e&&Ct(e)){if(t instanceof Dt)return new yt(t,e);throw d("To use ref(service, url), the first argument must be a Storage instance.")}return St(t,e)}var Dt=function(){function t(t,e,n,r,i){var o,a;this.app=t,this._authProvider=e,this._pool=n,this._url=r,this._firebaseVersion=i,this._bucket=null,this._appId=null,this._deleted=!1,this._maxOperationRetryTime=12e4,this._maxUploadRetryTime=6e5,this._requests=new Set,this._bucket=null!=r?R.makeFromBucketSpec(r):(o=this.app.options,null==(a=null==o?void 0:o[u])?null:R.makeFromBucketSpec(a))}return Object.defineProperty(t.prototype,"maxUploadRetryTime",{get:function(){return this._maxUploadRetryTime},set:function(t){M("time",0,Number.POSITIVE_INFINITY,t),this._maxUploadRetryTime=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxOperationRetryTime",{get:function(){return this._maxOperationRetryTime},set:function(t){M("time",0,Number.POSITIVE_INFINITY,t),this._maxOperationRetryTime=t},enumerable:!1,configurable:!0}),t.prototype._getAuthToken=function(){return(0,i.mG)(this,void 0,void 0,(function(){var t,e;return(0,i.Jh)(this,(function(n){switch(n.label){case 0:return(t=this._authProvider.getImmediate({optional:!0}))?[4,t.getToken()]:[3,2];case 1:if(null!==(e=n.sent()))return[2,e.accessToken];n.label=2;case 2:return[2,null]}}))}))},t.prototype._delete=function(){return this._deleted=!0,this._requests.forEach((function(t){return t.cancel()})),this._requests.clear(),Promise.resolve()},t.prototype._makeStorageReference=function(t){return new yt(this,t)},t.prototype._makeRequest=function(t,e){var n=this;if(this._deleted)return new O(g());var r=function(t,e,n,r,i){var o=U(t.urlParams),a=t.url+o,s=Object.assign({},t.headers);return function(t,e){e&&(t["X-Firebase-GMPID"]=e)}(s,e),function(t,e){null!==e&&e.length>0&&(t.Authorization="Firebase "+e)}(s,n),function(t,e){t["X-Firebase-Storage-Version"]="webjs/"+(null!=e?e:"AppManager")}(s,i),new F(a,t.method,s,t.body,t.successCodes,t.additionalRetryCodes,t.handler,t.errorHandler,t.timeout,t.progressCallback,r)}(t,this._appId,e,this._pool,this._firebaseVersion);return this._requests.add(r),r.getPromise().then((function(){return n._requests.delete(r)}),(function(){return n._requests.delete(r)})),r},t}();function kt(t,e,n){return function(t,e,n){return t._throwIfRoot("uploadBytesResumable"),new vt(t,new G(e),n)}(t=(0,o.m9)(t),e,n)}function Rt(t){return function(t){return(0,i.mG)(this,void 0,void 0,(function(){var e,n;return(0,i.Jh)(this,(function(r){switch(r.label){case 0:return t._throwIfRoot("getMetadata"),[4,t.storage._getAuthToken()];case 1:return e=r.sent(),n=ut(t.storage,t._location,Y()),[2,t.storage._makeRequest(n,e).getPromise()]}}))}))}(t=(0,o.m9)(t))}function Ot(t,e){return xt(t=(0,o.m9)(t),e)}var Bt,Nt,Pt=function(){function t(t,e,n){this._delegate=t,this.task=e,this.ref=n}return Object.defineProperty(t.prototype,"bytesTransferred",{get:function(){return this._delegate.bytesTransferred},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metadata",{get:function(){return this._delegate.metadata},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._delegate.state},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalBytes",{get:function(){return this._delegate.totalBytes},enumerable:!1,configurable:!0}),t}(),Mt=function(){function t(t,e){this._delegate=t,this._ref=e,this.cancel=this._delegate.cancel.bind(this._delegate),this.catch=this._delegate.catch.bind(this._delegate),this.pause=this._delegate.pause.bind(this._delegate),this.resume=this._delegate.resume.bind(this._delegate)}return Object.defineProperty(t.prototype,"snapshot",{get:function(){return new Pt(this._delegate.snapshot,this,this._ref)},enumerable:!1,configurable:!0}),t.prototype.then=function(t,e){var n=this;return this._delegate.then((function(e){if(t)return t(new Pt(e,n,n._ref))}),e)},t.prototype.on=function(t,e,n,r){var i=this,o=void 0;return e&&(o="function"==typeof e?function(t){return e(new Pt(t,i,i._ref))}:{next:e.next?function(t){return e.next(new Pt(t,i,i._ref))}:void 0,complete:e.complete||void 0,error:e.error||void 0}),this._delegate.on(t,o,n||void 0,r||void 0)},t}(),Lt=function(){function t(t,e){this._delegate=t,this._service=e}return Object.defineProperty(t.prototype,"prefixes",{get:function(){var t=this;return this._delegate.prefixes.map((function(e){return new Ut(e,t._service)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"items",{get:function(){var t=this;return this._delegate.items.map((function(e){return new Ut(e,t._service)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nextPageToken",{get:function(){return this._delegate.nextPageToken||null},enumerable:!1,configurable:!0}),t}(),Ut=function(){function t(t,e){this._delegate=t,this.storage=e}return Object.defineProperty(t.prototype,"name",{get:function(){return this._delegate.name},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bucket",{get:function(){return this._delegate.bucket},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fullPath",{get:function(){return this._delegate.fullPath},enumerable:!1,configurable:!0}),t.prototype.toString=function(){return this._delegate.toString()},t.prototype.child=function(e){var n=function(t,e){return Tt(t,e)}(this._delegate,e);return new t(n,this.storage)},Object.defineProperty(t.prototype,"root",{get:function(){return new t(this._delegate.root,this.storage)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){var e=this._delegate.parent;return null==e?null:new t(e,this.storage)},enumerable:!1,configurable:!0}),t.prototype.put=function(t,e){return this._throwIfRoot("put"),new Mt(kt(this._delegate,t,e),this)},t.prototype.putString=function(t,e,n){void 0===e&&(e=A.RAW),this._throwIfRoot("putString");var r=w(e,t),o=(0,i.pi)({},n);return null==o.contentType&&null!=r.contentType&&(o.contentType=r.contentType),new Mt(new vt(this._delegate,new G(r.data,!0),o),this)},t.prototype.listAll=function(){var t=this;return function(t){return At(t=(0,o.m9)(t))}(this._delegate).then((function(e){return new Lt(e,t.storage)}))},t.prototype.list=function(t){var e=this;return function(t,e){return wt(t=(0,o.m9)(t),e)}(this._delegate,t||void 0).then((function(t){return new Lt(t,e.storage)}))},t.prototype.getMetadata=function(){return Rt(this._delegate)},t.prototype.updateMetadata=function(t){return function(t,e){return _t(t=(0,o.m9)(t),e)}(this._delegate,t)},t.prototype.getDownloadURL=function(){return function(t){return It(t=(0,o.m9)(t))}(this._delegate)},t.prototype.delete=function(){return this._throwIfRoot("delete"),function(t){return Et(t=(0,o.m9)(t))}(this._delegate)},t.prototype._throwIfRoot=function(t){if(""===this._delegate._location.path)throw m(t)},t}(),Ft=function(){function t(t,e){var n=this;this.app=t,this._delegate=e,this.INTERNAL={delete:function(){return n._delegate._delete()}}}return Object.defineProperty(t.prototype,"maxOperationRetryTime",{get:function(){return this._delegate.maxOperationRetryTime},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxUploadRetryTime",{get:function(){return this._delegate.maxUploadRetryTime},enumerable:!1,configurable:!0}),t.prototype.ref=function(t){if(Ct(t))throw d("ref() expected a child path but got a URL, use refFromURL instead.");return new Ut(Ot(this._delegate,t),this)},t.prototype.refFromURL=function(t){if(!Ct(t))throw d("refFromURL() expected a full URL but got a child path, use ref() instead.");try{R.makeFromUrl(t)}catch(t){throw d("refFromUrl() expected a valid full URL but got an invalid one.")}return new Ut(Ot(this._delegate,t),this)},t.prototype.setMaxUploadRetryTime=function(t){this._delegate.maxUploadRetryTime=t},t.prototype.setMaxOperationRetryTime=function(t){this._delegate.maxOperationRetryTime=t},t}();function Qt(t,e){var n=e.instanceIdentifier,i=t.getProvider("app").getImmediate(),o=t.getProvider("auth-internal");return new Ft(i,new Dt(i,o,new k,n,r.Z.SDK_VERSION))}Bt=r.Z,Nt={TaskState:S,TaskEvent:C,StringFormat:A,Storage:Dt,Reference:Ut},Bt.INTERNAL.registerComponent(new a.wA("storage",Qt,"PUBLIC").setServiceProps(Nt).setMultipleInstances(!0)),Bt.registerVersion("@firebase/storage","0.4.7")},4881:function(t){t.exports=function(){function t(e,n,r){function i(a,s){if(!n[a]){if(!e[a]){if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[a]={exports:{}};e[a][0].call(c.exports,(function(t){return i(e[a][1][t]||t)}),c,c.exports,t,e,n,r)}return n[a].exports}for(var o=void 0,a=0;a<r.length;a++)i(r[a]);return i}return t}()({1:[function(t,e,n){"use strict";var r=t("inherits"),i=t("multimath"),o=t("./mm_unsharp_mask"),a=t("./mm_resize");function s(t){var e=t||[],n={js:e.indexOf("js")>=0,wasm:e.indexOf("wasm")>=0};i.call(this,n),this.features={js:n.js,wasm:n.wasm&&this.has_wasm()},this.use(o),this.use(a)}r(s,i),s.prototype.resizeAndUnsharp=function(t,e){var n=this.resize(t,e);return t.unsharpAmount&&this.unsharp_mask(n,t.toWidth,t.toHeight,t.unsharpAmount,t.unsharpRadius,t.unsharpThreshold),n},e.exports=s},{"./mm_resize":4,"./mm_unsharp_mask":9,inherits:19,multimath:20}],2:[function(t,e,n){"use strict";function r(t){return t<0?0:t>255?255:t}function i(t,e,n,i,o,a){var s,u,c,h,l,f,p,d,g,m,v,y=0,A=0;for(g=0;g<i;g++){for(l=0,m=0;m<o;m++){for(f=a[l++],p=a[l++],d=y+4*f|0,s=u=c=h=0;p>0;p--)h=h+(v=a[l++])*t[d+3]|0,c=c+v*t[d+2]|0,u=u+v*t[d+1]|0,s=s+v*t[d]|0,d=d+4|0;e[A+3]=r(h+8192>>14),e[A+2]=r(c+8192>>14),e[A+1]=r(u+8192>>14),e[A]=r(s+8192>>14),A=A+4*i|0}A=4*(g+1)|0,y=(g+1)*n*4|0}}function o(t,e,n,i,o,a){var s,u,c,h,l,f,p,d,g,m,v,y=0,A=0;for(g=0;g<i;g++){for(l=0,m=0;m<o;m++){for(f=a[l++],p=a[l++],d=y+4*f|0,s=u=c=h=0;p>0;p--)h=h+(v=a[l++])*t[d+3]|0,c=c+v*t[d+2]|0,u=u+v*t[d+1]|0,s=s+v*t[d]|0,d=d+4|0;e[A+3]=r(h+8192>>14),e[A+2]=r(c+8192>>14),e[A+1]=r(u+8192>>14),e[A]=r(s+8192>>14),A=A+4*i|0}A=4*(g+1)|0,y=(g+1)*n*4|0}}e.exports={convolveHorizontally:i,convolveVertically:o}},{}],3:[function(t,e,n){"use strict";e.exports="AGFzbQEAAAAADAZkeWxpbmsAAAAAAAEXA2AAAGAGf39/f39/AGAHf39/f39/fwACDwEDZW52Bm1lbW9yeQIAAAMEAwABAgYGAX8AQQALB1cFEV9fd2FzbV9jYWxsX2N0b3JzAAAIY29udm9sdmUAAQpjb252b2x2ZUhWAAIMX19kc29faGFuZGxlAwAYX193YXNtX2FwcGx5X2RhdGFfcmVsb2NzAAAK7AMDAwABC8YDAQ9/AkAgA0UNACAERQ0AA0AgDCENQQAhE0EAIQcDQCAHQQJqIQYCfyAHQQF0IAVqIgcuAQIiFEUEQEGAwAAhCEGAwAAhCUGAwAAhCkGAwAAhCyAGDAELIBIgBy4BAGohCEEAIQsgFCEHQQAhDiAGIQlBACEPQQAhEANAIAUgCUEBdGouAQAiESAAIAhBAnRqKAIAIgpBGHZsIBBqIRAgCkH/AXEgEWwgC2ohCyAKQRB2Qf8BcSARbCAPaiEPIApBCHZB/wFxIBFsIA5qIQ4gCEEBaiEIIAlBAWohCSAHQQFrIgcNAAsgC0GAQGshCCAOQYBAayEJIA9BgEBrIQogEEGAQGshCyAGIBRqCyEHIAEgDUECdGogCUEOdSIGQf8BIAZB/wFIGyIGQQAgBkEAShtBCHRBgP4DcSAKQQ51IgZB/wEgBkH/AUgbIgZBACAGQQBKG0EQdEGAgPwHcSALQQ51IgZB/wEgBkH/AUgbIgZBACAGQQBKG0EYdHJyIAhBDnUiBkH/ASAGQf8BSBsiBkEAIAZBAEobcjYCACADIA1qIQ0gE0EBaiITIARHDQALIAxBAWoiDCACbCESIAMgDEcNAAsLCx4AQQAgAiADIAQgBSAAEAEgAkEAIAQgBSAGIAEQAQs="},{}],4:[function(t,e,n){"use strict";e.exports={name:"resize",fn:t("./resize"),wasm_fn:t("./resize_wasm"),wasm_src:t("./convolve_wasm_base64")}},{"./convolve_wasm_base64":3,"./resize":5,"./resize_wasm":8}],5:[function(t,e,n){"use strict";var r=t("./resize_filter_gen"),i=t("./convolve").convolveHorizontally,o=t("./convolve").convolveVertically;function a(t,e,n){for(var r=3,i=e*n*4|0;r<i;)t[r]=255,r=r+4|0}e.exports=function(t){var e=t.src,n=t.width,s=t.height,u=t.toWidth,c=t.toHeight,h=t.scaleX||t.toWidth/t.width,l=t.scaleY||t.toHeight/t.height,f=t.offsetX||0,p=t.offsetY||0,d=t.dest||new Uint8Array(u*c*4),g=void 0===t.quality?3:t.quality,m=t.alpha||!1,v=r(g,n,u,h,f),y=r(g,s,c,l,p),A=new Uint8Array(u*s*4);return i(e,A,n,s,u,v),o(A,d,s,u,c,y),m||a(d,u,c),d}},{"./convolve":2,"./resize_filter_gen":6}],6:[function(t,e,n){"use strict";var r=t("./resize_filter_info"),i=14;function o(t){return Math.round(t*((1<<i)-1))}e.exports=function(t,e,n,i,a){var s,u,c,h,l,f,p,d,g,m,v,y,A,b,w,_,I,E=r[t].filter,T=1/i,C=Math.min(1,i),S=r[t].win/C,x=Math.floor(2*(S+1)),D=new Int16Array((x+2)*n),k=0,R=!D.subarray||!D.set;for(s=0;s<n;s++){for(u=(s+.5)*T+a,c=Math.max(0,Math.floor(u-S)),l=(h=Math.min(e-1,Math.ceil(u+S)))-c+1,f=new Float32Array(l),p=new Int16Array(l),d=0,g=c,m=0;g<=h;g++,m++)d+=v=E((g+.5-u)*C),f[m]=v;for(y=0,m=0;m<f.length;m++)y+=A=f[m]/d,p[m]=o(A);for(p[n>>1]+=o(1-y),b=0;b<p.length&&0===p[b];)b++;if(b<p.length){for(w=p.length-1;w>0&&0===p[w];)w--;if(_=c+b,I=w-b+1,D[k++]=_,D[k++]=I,R)for(m=b;m<=w;m++)D[k++]=p[m];else D.set(p.subarray(b,w+1),k),k+=I}else D[k++]=0,D[k++]=0}return D}},{"./resize_filter_info":7}],7:[function(t,e,n){"use strict";e.exports=[{win:.5,filter:function(t){return t>=-.5&&t<.5?1:0}},{win:1,filter:function(t){if(t<=-1||t>=1)return 0;if(t>-1.1920929e-7&&t<1.1920929e-7)return 1;var e=t*Math.PI;return Math.sin(e)/e*(.54+.46*Math.cos(e/1))}},{win:2,filter:function(t){if(t<=-2||t>=2)return 0;if(t>-1.1920929e-7&&t<1.1920929e-7)return 1;var e=t*Math.PI;return Math.sin(e)/e*Math.sin(e/2)/(e/2)}},{win:3,filter:function(t){if(t<=-3||t>=3)return 0;if(t>-1.1920929e-7&&t<1.1920929e-7)return 1;var e=t*Math.PI;return Math.sin(e)/e*Math.sin(e/3)/(e/3)}}]},{}],8:[function(t,e,n){"use strict";var r=t("./resize_filter_gen");function i(t,e,n){for(var r=3,i=e*n*4|0;r<i;)t[r]=255,r=r+4|0}function o(t){return new Uint8Array(t.buffer,0,t.byteLength)}var a=!0;try{a=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0]}catch(t){}function s(t,e,n){if(a)e.set(o(t),n);else for(var r=n,i=0;i<t.length;i++){var s=t[i];e[r++]=255&s,e[r++]=s>>8&255}}e.exports=function(t){var e=t.src,n=t.width,o=t.height,a=t.toWidth,u=t.toHeight,c=t.scaleX||t.toWidth/t.width,h=t.scaleY||t.toHeight/t.height,l=t.offsetX||0,f=t.offsetY||0,p=t.dest||new Uint8Array(a*u*4),d=void 0===t.quality?3:t.quality,g=t.alpha||!1,m=r(d,n,a,c,l),v=r(d,o,u,h,f),y=0,A=this.__align(y+Math.max(e.byteLength,p.byteLength)),b=this.__align(A+o*a*4),w=this.__align(b+m.byteLength),_=w+v.byteLength,I=this.__instance("resize",_),E=new Uint8Array(this.__memory.buffer),T=new Uint32Array(this.__memory.buffer),C=new Uint32Array(e.buffer);return T.set(C),s(m,E,b),s(v,E,w),(I.exports.convolveHV||I.exports._convolveHV)(b,w,A,n,o,a,u),new Uint32Array(p.buffer).set(new Uint32Array(this.__memory.buffer,0,u*a)),g||i(p,a,u),p}},{"./resize_filter_gen":6}],9:[function(t,e,n){"use strict";e.exports={name:"unsharp_mask",fn:t("./unsharp_mask"),wasm_fn:t("./unsharp_mask_wasm"),wasm_src:t("./unsharp_mask_wasm_base64")}},{"./unsharp_mask":10,"./unsharp_mask_wasm":11,"./unsharp_mask_wasm_base64":12}],10:[function(t,e,n){"use strict";var r=t("glur/mono16");function i(t,e,n){for(var r,i,o,a,s=e*n,u=new Uint16Array(s),c=0;c<s;c++)r=t[4*c],i=t[4*c+1],o=t[4*c+2],a=r>=i&&r>=o?r:i>=o&&i>=r?i:o,u[c]=a<<8;return u}e.exports=function(t,e,n,o,a,s){var u,c,h,l,f;if(!(0===o||a<.5)){a>2&&(a=2);var p=i(t,e,n),d=new Uint16Array(p);r(d,e,n,a);for(var g=o/100*4096+.5|0,m=s<<8,v=e*n,y=0;y<v;y++)l=(u=p[y])-d[y],Math.abs(l)>=m&&(h=((c=(c=(c=u+(g*l+2048>>12))>65280?65280:c)<0?0:c)<<12)/(u=0!==u?u:1)|0,t[f=4*y]=t[f]*h+2048>>12,t[f+1]=t[f+1]*h+2048>>12,t[f+2]=t[f+2]*h+2048>>12)}}},{"glur/mono16":18}],11:[function(t,e,n){"use strict";e.exports=function(t,e,n,r,i,o){if(!(0===r||i<.5)){i>2&&(i=2);var a=e*n,s=4*a,u=2*a,c=2*a,h=4*Math.max(e,n),l=32,f=0,p=s,d=p+u,g=d+c,m=g+c,v=m+h,y=this.__instance("unsharp_mask",s+u+2*c+h+l,{exp:Math.exp}),A=new Uint32Array(t.buffer);new Uint32Array(this.__memory.buffer).set(A);var b=y.exports.hsv_v16||y.exports._hsv_v16;b(f,p,e,n),(b=y.exports.blurMono16||y.exports._blurMono16)(p,d,g,m,v,e,n,i),(b=y.exports.unsharp||y.exports._unsharp)(f,f,p,d,e,n,r,o),A.set(new Uint32Array(this.__memory.buffer,0,a))}}},{}],12:[function(t,e,n){"use strict";e.exports="AGFzbQEAAAAADAZkeWxpbmsAAAAAAAE0B2AAAGAEf39/fwBgBn9/f39/fwBgCH9/f39/f39/AGAIf39/f39/f30AYAJ9fwBgAXwBfAIZAgNlbnYDZXhwAAYDZW52Bm1lbW9yeQIAAAMHBgAFAgQBAwYGAX8AQQALB4oBCBFfX3dhc21fY2FsbF9jdG9ycwABFl9fYnVpbGRfZ2F1c3NpYW5fY29lZnMAAg5fX2dhdXNzMTZfbGluZQADCmJsdXJNb25vMTYABAdoc3ZfdjE2AAUHdW5zaGFycAAGDF9fZHNvX2hhbmRsZQMAGF9fd2FzbV9hcHBseV9kYXRhX3JlbG9jcwABCsUMBgMAAQvWAQEHfCABRNuGukOCGvs/IAC7oyICRAAAAAAAAADAohAAIgW2jDgCFCABIAKaEAAiAyADoCIGtjgCECABRAAAAAAAAPA/IAOhIgQgBKIgAyACIAKgokQAAAAAAADwP6AgBaGjIgS2OAIAIAEgBSAEmqIiB7Y4AgwgASADIAJEAAAAAAAA8D+gIASioiIItjgCCCABIAMgAkQAAAAAAADwv6AgBKKiIgK2OAIEIAEgByAIoCAFRAAAAAAAAPA/IAahoCIDo7Y4AhwgASAEIAKgIAOjtjgCGAuGBQMGfwl8An0gAyoCDCEVIAMqAgghFiADKgIUuyERIAMqAhC7IRACQCAEQQFrIghBAEgiCQRAIAIhByAAIQYMAQsgAiAALwEAuCIPIAMqAhi7oiIMIBGiIg0gDCAQoiAPIAMqAgS7IhOiIhQgAyoCALsiEiAPoqCgoCIOtjgCACACQQRqIQcgAEECaiEGIAhFDQAgCEEBIAhBAUgbIgpBf3MhCwJ/IAQgCmtBAXFFBEAgDiENIAgMAQsgAiANIA4gEKIgFCASIAAvAQK4Ig+ioKCgIg22OAIEIAJBCGohByAAQQRqIQYgDiEMIARBAmsLIQIgC0EAIARrRg0AA0AgByAMIBGiIA0gEKIgDyAToiASIAYvAQC4Ig6ioKCgIgy2OAIAIAcgDSARoiAMIBCiIA4gE6IgEiAGLwECuCIPoqCgoCINtjgCBCAHQQhqIQcgBkEEaiEGIAJBAkohACACQQJrIQIgAA0ACwsCQCAJDQAgASAFIAhsQQF0aiIAAn8gBkECay8BACICuCINIBW7IhKiIA0gFrsiE6KgIA0gAyoCHLuiIgwgEKKgIAwgEaKgIg8gB0EEayIHKgIAu6AiDkQAAAAAAADwQWMgDkQAAAAAAAAAAGZxBEAgDqsMAQtBAAs7AQAgCEUNACAGQQRrIQZBACAFa0EBdCEBA0ACfyANIBKiIAJB//8DcbgiDSAToqAgDyIOIBCioCAMIBGioCIPIAdBBGsiByoCALugIgxEAAAAAAAA8EFjIAxEAAAAAAAAAABmcQRAIAyrDAELQQALIQMgBi8BACECIAAgAWoiACADOwEAIAZBAmshBiAIQQFKIQMgDiEMIAhBAWshCCADDQALCwvRAgIBfwd8AkAgB0MAAAAAWw0AIARE24a6Q4Ia+z8gB0MAAAA/l7ujIglEAAAAAAAAAMCiEAAiDLaMOAIUIAQgCZoQACIKIAqgIg22OAIQIAREAAAAAAAA8D8gCqEiCyALoiAKIAkgCaCiRAAAAAAAAPA/oCAMoaMiC7Y4AgAgBCAMIAuaoiIOtjgCDCAEIAogCUQAAAAAAADwP6AgC6KiIg+2OAIIIAQgCiAJRAAAAAAAAPC/oCALoqIiCbY4AgQgBCAOIA+gIAxEAAAAAAAA8D8gDaGgIgqjtjgCHCAEIAsgCaAgCqO2OAIYIAYEQANAIAAgBSAIbEEBdGogAiAIQQF0aiADIAQgBSAGEAMgCEEBaiIIIAZHDQALCyAFRQ0AQQAhCANAIAIgBiAIbEEBdGogASAIQQF0aiADIAQgBiAFEAMgCEEBaiIIIAVHDQALCwtxAQN/IAIgA2wiBQRAA0AgASAAKAIAIgRBEHZB/wFxIgIgAiAEQQh2Qf8BcSIDIAMgBEH/AXEiBEkbIAIgA0sbIgYgBiAEIAIgBEsbIAMgBEsbQQh0OwEAIAFBAmohASAAQQRqIQAgBUEBayIFDQALCwuZAgIDfwF8IAQgBWwhBAJ/IAazQwAAgEWUQwAAyEKVu0QAAAAAAADgP6AiC5lEAAAAAAAA4EFjBEAgC6oMAQtBgICAgHgLIQUgBARAIAdBCHQhCUEAIQYDQCAJIAIgBkEBdCIHai8BACIBIAMgB2ovAQBrIgcgB0EfdSIIaiAIc00EQCAAIAZBAnQiCGoiCiAFIAdsQYAQakEMdSABaiIHQYD+AyAHQYD+A0gbIgdBACAHQQBKG0EMdCABQQEgARtuIgEgCi0AAGxBgBBqQQx2OgAAIAAgCEEBcmoiByABIActAABsQYAQakEMdjoAACAAIAhBAnJqIgcgASAHLQAAbEGAEGpBDHY6AAALIAZBAWoiBiAERw0ACwsL"},{}],13:[function(t,e,n){"use strict";var r=100;function i(t,e){this.create=t,this.available=[],this.acquired={},this.lastId=1,this.timeoutId=0,this.idle=e||2e3}i.prototype.acquire=function(){var t,e=this;return 0!==this.available.length?t=this.available.pop():((t=this.create()).id=this.lastId++,t.release=function(){return e.release(t)}),this.acquired[t.id]=t,t},i.prototype.release=function(t){var e=this;delete this.acquired[t.id],t.lastUsed=Date.now(),this.available.push(t),0===this.timeoutId&&(this.timeoutId=setTimeout((function(){return e.gc()}),r))},i.prototype.gc=function(){var t=this,e=Date.now();this.available=this.available.filter((function(n){return!(e-n.lastUsed>t.idle&&(n.destroy(),1))})),0!==this.available.length?this.timeoutId=setTimeout((function(){return t.gc()}),r):this.timeoutId=0},e.exports=i},{}],14:[function(t,e,n){"use strict";var r=2;e.exports=function(t,e,n,i,o,a){var s=n/t,u=i/e,c=(2*a+r+1)/o;if(c>.5)return[[n,i]];var h=Math.ceil(Math.log(Math.min(s,u))/Math.log(c));if(h<=1)return[[n,i]];for(var l=[],f=0;f<h;f++){var p=Math.round(Math.pow(Math.pow(t,h-f-1)*Math.pow(n,f+1),1/h)),d=Math.round(Math.pow(Math.pow(e,h-f-1)*Math.pow(i,f+1),1/h));l.push([p,d])}return l}},{}],15:[function(t,e,n){"use strict";var r=1e-5;function i(t){var e=Math.round(t);return Math.abs(t-e)<r?e:Math.floor(t)}function o(t){var e=Math.round(t);return Math.abs(t-e)<r?e:Math.ceil(t)}e.exports=function(t){var e,n,r,a,s,u,c=t.toWidth/t.width,h=t.toHeight/t.height,l=i(t.srcTileSize*c)-2*t.destTileBorder,f=i(t.srcTileSize*h)-2*t.destTileBorder;if(l<1||f<1)throw new Error("Internal error in pica: target tile width/height is too small.");var p,d=[];for(a=0;a<t.toHeight;a+=f)for(r=0;r<t.toWidth;r+=l)(e=r-t.destTileBorder)<0&&(e=0),e+(s=r+l+t.destTileBorder-e)>=t.toWidth&&(s=t.toWidth-e),(n=a-t.destTileBorder)<0&&(n=0),n+(u=a+f+t.destTileBorder-n)>=t.toHeight&&(u=t.toHeight-n),p={toX:e,toY:n,toWidth:s,toHeight:u,toInnerX:r,toInnerY:a,toInnerWidth:l,toInnerHeight:f,offsetX:e/c-i(e/c),offsetY:n/h-i(n/h),scaleX:c,scaleY:h,x:i(e/c),y:i(n/h),width:o(s/c),height:o(u/h)},d.push(p);return d}},{}],16:[function(t,e,n){"use strict";function r(t){return Object.prototype.toString.call(t)}e.exports.isCanvas=function(t){var e=r(t);return"[object HTMLCanvasElement]"===e||"[object OffscreenCanvas]"===e||"[object Canvas]"===e},e.exports.isImage=function(t){return"[object HTMLImageElement]"===r(t)},e.exports.isImageBitmap=function(t){return"[object ImageBitmap]"===r(t)},e.exports.limiter=function(t){var e=0,n=[];function r(){e<t&&n.length&&(e++,n.shift()())}return function(t){return new Promise((function(i,o){n.push((function(){t().then((function(t){i(t),e--,r()}),(function(t){o(t),e--,r()}))})),r()}))}},e.exports.cib_quality_name=function(t){switch(t){case 0:return"pixelated";case 1:return"low";case 2:return"medium"}return"high"},e.exports.cib_support=function(t){return Promise.resolve().then((function(){if("undefined"==typeof createImageBitmap)return!1;var e=t(100,100);return createImageBitmap(e,0,0,100,100,{resizeWidth:10,resizeHeight:10,resizeQuality:"high"}).then((function(t){var n=10===t.width;return t.close(),e=null,n}))})).catch((function(){return!1}))},e.exports.worker_offscreen_canvas_support=function(){return new Promise((function(t,e){if("undefined"!=typeof OffscreenCanvas){var n=btoa("(".concat(i.toString(),")(self);")),r=new Worker("data:text/javascript;base64,".concat(n));r.onmessage=function(e){return t(e.data)},r.onerror=e}else t(!1);function i(t){"undefined"!=typeof createImageBitmap?Promise.resolve().then((function(){var t=new OffscreenCanvas(10,10);return t.getContext("2d").rect(0,0,1,1),createImageBitmap(t,0,0,1,1)})).then((function(){return t.postMessage(!0)}),(function(){return t.postMessage(!1)})):t.postMessage(!1)}})).then((function(t){return t}),(function(){return!1}))},e.exports.can_use_canvas=function(t){var e=!1;try{var n=t(2,1).getContext("2d"),r=n.createImageData(2,1);r.data[0]=12,r.data[1]=23,r.data[2]=34,r.data[3]=255,r.data[4]=45,r.data[5]=56,r.data[6]=67,r.data[7]=255,n.putImageData(r,0,0),r=null,12===(r=n.getImageData(0,0,2,1)).data[0]&&23===r.data[1]&&34===r.data[2]&&255===r.data[3]&&45===r.data[4]&&56===r.data[5]&&67===r.data[6]&&255===r.data[7]&&(e=!0)}catch(t){}return e},e.exports.cib_can_use_region=function(){return new Promise((function(t){if("undefined"!=typeof createImageBitmap){var e=new Image;e.src="data:image/jpeg;base64,/9j/4QBiRXhpZgAATU0AKgAAAAgABQESAAMAAAABAAYAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAAAAABIAAAAAQAAAEgAAAAB/9sAQwAEAwMEAwMEBAMEBQQEBQYKBwYGBgYNCQoICg8NEBAPDQ8OERMYFBESFxIODxUcFRcZGRsbGxAUHR8dGh8YGhsa/9sAQwEEBQUGBQYMBwcMGhEPERoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoa/8IAEQgAAQACAwERAAIRAQMRAf/EABQAAQAAAAAAAAAAAAAAAAAAAAf/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAF/P//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAQUCf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Bf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Bf//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEABj8Cf//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAT8hf//aAAwDAQACAAMAAAAQH//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Qf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Qf//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAT8Qf//Z",e.onload=function(){createImageBitmap(e,0,0,e.width,e.height).then((function(n){n.width===e.width&&n.height===e.height?t(!0):t(!1)}),(function(){return t(!1)}))},e.onerror=function(){return t(!1)}}else t(!1)}))}},{}],17:[function(t,e,n){"use strict";e.exports=function(){var e,n=t("./mathlib");onmessage=function(t){var r=t.data.opts,i=!1;if(!r.src&&r.srcBitmap){var o=new OffscreenCanvas(r.width,r.height),a=o.getContext("2d",{alpha:Boolean(r.alpha)});a.drawImage(r.srcBitmap,0,0),r.src=a.getImageData(0,0,r.width,r.height).data,o.width=o.height=0,o=null,r.srcBitmap.close(),r.srcBitmap=null}e||(e=new n(t.data.features));var s=e.resizeAndUnsharp(r);if(i){var u=new ImageData(new Uint8ClampedArray(s),r.toWidth,r.toHeight),c=new OffscreenCanvas(r.toWidth,r.toHeight);c.getContext("2d",{alpha:Boolean(r.alpha)}).putImageData(u,0,0),createImageBitmap(c).then((function(t){postMessage({bitmap:t},[t])}))}else postMessage({data:s},[s.buffer])}}},{"./mathlib":1}],18:[function(t,e,n){var r,i,o,a,s,u;function c(t){t<.5&&(t=.5);var e=Math.exp(.527076)/t,n=Math.exp(-e),c=Math.exp(-2*e),h=(1-n)*(1-n)/(1+2*e*n-c);return r=h,i=h*(e-1)*n,o=h*(e+1)*n,a=-h*c,s=2*n,u=-c,new Float32Array([r,i,o,a,s,u,(r+i)/(1-s-u),(o+a)/(1-s-u)])}function h(t,e,n,r,i,o){var a,s,u,c,h,l,f,p,d,g,m,v,y,A;for(d=0;d<o;d++){for(f=d,p=0,c=h=(a=t[l=d*i])*r[6],m=r[0],v=r[1],y=r[4],A=r[5],g=0;g<i;g++)u=(s=t[l])*m+a*v+c*y+h*A,h=c,c=u,a=s,n[p]=c,p++,l++;for(p--,f+=o*(i-1),c=h=(a=t[--l])*r[7],s=a,m=r[2],v=r[3],g=i-1;g>=0;g--)u=s*m+a*v+c*y+h*A,h=c,c=u,a=s,s=t[l],e[f]=n[p]+c,l--,p--,f-=o}}function l(t,e,n,r){if(r){var i=new Uint16Array(t.length),o=new Float32Array(Math.max(e,n)),a=c(r);h(t,i,o,a,e,n,r),h(i,t,o,a,n,e,r)}}e.exports=l},{}],19:[function(t,e,n){"function"==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}}},{}],20:[function(t,e,n){"use strict";var r=t("object-assign"),i=t("./lib/base64decode"),o=t("./lib/wa_detect"),a={js:!0,wasm:!0};function s(t){if(!(this instanceof s))return new s(t);var e=r({},a,t||{});if(this.options=e,this.__cache={},this.__init_promise=null,this.__modules=e.modules||{},this.__memory=null,this.__wasm={},this.__isLE=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0],!this.options.js&&!this.options.wasm)throw new Error('mathlib: at least "js" or "wasm" should be enabled')}s.prototype.has_wasm=o,s.prototype.use=function(t){return this.__modules[t.name]=t,this.options.wasm&&this.has_wasm()&&t.wasm_fn?this[t.name]=t.wasm_fn:this[t.name]=t.fn,this},s.prototype.init=function(){if(this.__init_promise)return this.__init_promise;if(!this.options.js&&this.options.wasm&&!this.has_wasm())return Promise.reject(new Error('mathlib: only "wasm" was enabled, but it\'s not supported'));var t=this;return this.__init_promise=Promise.all(Object.keys(t.__modules).map((function(e){var n=t.__modules[e];return t.options.wasm&&t.has_wasm()&&n.wasm_fn?t.__wasm[e]?null:WebAssembly.compile(t.__base64decode(n.wasm_src)).then((function(n){t.__wasm[e]=n})):null}))).then((function(){return t})),this.__init_promise},s.prototype.__base64decode=i,s.prototype.__reallocate=function(t){if(!this.__memory)return this.__memory=new WebAssembly.Memory({initial:Math.ceil(t/65536)}),this.__memory;var e=this.__memory.buffer.byteLength;return e<t&&this.__memory.grow(Math.ceil((t-e)/65536)),this.__memory},s.prototype.__instance=function(t,e,n){if(e&&this.__reallocate(e),!this.__wasm[t]){var i=this.__modules[t];this.__wasm[t]=new WebAssembly.Module(this.__base64decode(i.wasm_src))}if(!this.__cache[t]){var o={memoryBase:0,memory:this.__memory,tableBase:0,table:new WebAssembly.Table({initial:0,element:"anyfunc"})};this.__cache[t]=new WebAssembly.Instance(this.__wasm[t],{env:r(o,n||{})})}return this.__cache[t]},s.prototype.__align=function(t,e){var n=t%(e=e||8);return t+(n?e-n:0)},e.exports=s},{"./lib/base64decode":21,"./lib/wa_detect":22,"object-assign":23}],21:[function(t,e,n){"use strict";var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";e.exports=function(t){for(var e=t.replace(/[\r\n=]/g,""),n=e.length,i=new Uint8Array(3*n>>2),o=0,a=0,s=0;s<n;s++)s%4==0&&s&&(i[a++]=o>>16&255,i[a++]=o>>8&255,i[a++]=255&o),o=o<<6|r.indexOf(e.charAt(s));var u=n%4*6;return 0===u?(i[a++]=o>>16&255,i[a++]=o>>8&255,i[a++]=255&o):18===u?(i[a++]=o>>10&255,i[a++]=o>>2&255):12===u&&(i[a++]=o>>4&255),i}},{}],22:[function(t,e,n){"use strict";var r;e.exports=function(){if(void 0!==r)return r;if(r=!1,"undefined"==typeof WebAssembly)return r;try{var t=new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,127,1,127,3,2,1,0,5,3,1,0,1,7,8,1,4,116,101,115,116,0,0,10,16,1,14,0,32,0,65,1,54,2,0,32,0,40,2,0,11]),e=new WebAssembly.Module(t);return 0!==new WebAssembly.Instance(e,{}).exports.test(4)&&(r=!0),r}catch(t){}return r}},{}],23:[function(t,e,n){"use strict";var r=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;function a(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function s(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},n=0;n<10;n++)e["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(e).map((function(t){return e[t]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(t){r[t]=t})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(t){return!1}}e.exports=s()?Object.assign:function(t,e){for(var n,s,u=a(t),c=1;c<arguments.length;c++){for(var h in n=Object(arguments[c]))i.call(n,h)&&(u[h]=n[h]);if(r){s=r(n);for(var l=0;l<s.length;l++)o.call(n,s[l])&&(u[s[l]]=n[s[l]])}}return u}},{}],24:[function(t,e,n){var r=arguments[3],i=arguments[4],o=arguments[5],a=JSON.stringify;e.exports=function(t,e){for(var n,s=Object.keys(o),u=0,c=s.length;u<c;u++){var h=s[u],l=o[h].exports;if(l===t||l&&l.default===t){n=h;break}}if(!n){n=Math.floor(Math.pow(16,8)*Math.random()).toString(16);var f={};for(u=0,c=s.length;u<c;u++)f[h=s[u]]=h;i[n]=["function(require,module,exports){"+t+"(self); }",f]}var p=Math.floor(Math.pow(16,8)*Math.random()).toString(16),d={};d[n]=n,i[p]=["function(require,module,exports){var f = require("+a(n)+");(f.default ? f.default : f)(self);}",d];var g={};function m(t){for(var e in g[t]=!0,i[t][1]){var n=i[t][1][e];g[n]||m(n)}}m(p);var v="("+r+")({"+Object.keys(g).map((function(t){return a(t)+":["+i[t][0]+","+a(i[t][1])+"]"})).join(",")+"},{},["+a(p)+"])",y=window.URL||window.webkitURL||window.mozURL||window.msURL,A=new Blob([v],{type:"text/javascript"});if(e&&e.bare)return A;var b=y.createObjectURL(A),w=new Worker(b);return w.objectURL=b,w}},{}],"/index.js":[function(t,e,n){"use strict";function r(t,e){return u(t)||s(t,e)||o(t,e)||i()}function i(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(t,e){if(t){if("string"==typeof t)return a(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function s(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}function u(t){if(Array.isArray(t))return t}var c=t("object-assign"),h=t("webworkify"),l=t("./lib/mathlib"),f=t("./lib/pool"),p=t("./lib/utils"),d=t("./lib/worker"),g=t("./lib/stepper"),m=t("./lib/tiler"),v={},y=!1;try{"undefined"!=typeof navigator&&navigator.userAgent&&(y=navigator.userAgent.indexOf("Safari")>=0)}catch(t){}var A=1;"undefined"!=typeof navigator&&(A=Math.min(navigator.hardwareConcurrency||1,4));var b={tile:1024,concurrency:A,features:["js","wasm","ww"],idle:2e3,createCanvas:function(t,e){var n=document.createElement("canvas");return n.width=t,n.height=e,n}},w={quality:3,alpha:!1,unsharpAmount:0,unsharpRadius:0,unsharpThreshold:0},_=!1,I=!1,E=!1,T=!1,C=!1;function S(){return{value:h(d),destroy:function(){if(this.value.terminate(),"undefined"!=typeof window){var t=window.URL||window.webkitURL||window.mozURL||window.msURL;t&&t.revokeObjectURL&&this.value.objectURL&&t.revokeObjectURL(this.value.objectURL)}}}}function x(t){if(!(this instanceof x))return new x(t);this.options=c({},b,t||{});var e="lk_".concat(this.options.concurrency);this.__limit=v[e]||p.limiter(this.options.concurrency),v[e]||(v[e]=this.__limit),this.features={js:!1,wasm:!1,cib:!1,ww:!1},this.__workersPool=null,this.__requested_features=[],this.__mathlib=null}x.prototype.init=function(){var e=this;if(this.__initPromise)return this.__initPromise;if("undefined"!=typeof ImageData&&"undefined"!=typeof Uint8ClampedArray)try{new ImageData(new Uint8ClampedArray(400),10,10),_=!0}catch(t){}"undefined"!=typeof ImageBitmap&&(ImageBitmap.prototype&&ImageBitmap.prototype.close?I=!0:this.debug("ImageBitmap does not support .close(), disabled"));var n=this.options.features.slice();if(n.indexOf("all")>=0&&(n=["cib","wasm","js","ww"]),this.__requested_features=n,this.__mathlib=new l(n),n.indexOf("ww")>=0&&"undefined"!=typeof window&&"Worker"in window)try{t("webworkify")((function(){})).terminate(),this.features.ww=!0;var r="wp_".concat(JSON.stringify(this.options));v[r]?this.__workersPool=v[r]:(this.__workersPool=new f(S,this.options.idle),v[r]=this.__workersPool)}catch(t){}var i,o,a=this.__mathlib.init().then((function(t){c(e.features,t.features)}));i=I?p.cib_support(this.options.createCanvas).then((function(t){e.features.cib&&n.indexOf("cib")<0?e.debug("createImageBitmap() resize supported, but disabled by config"):n.indexOf("cib")>=0&&(e.features.cib=t)})):Promise.resolve(!1),E=p.can_use_canvas(this.options.createCanvas),o=(o=I&&_&&-1!==n.indexOf("ww")?p.worker_offscreen_canvas_support():Promise.resolve(!1)).then((function(t){T=t}));var s=p.cib_can_use_region().then((function(t){C=t}));return this.__initPromise=Promise.all([a,i,o,s]).then((function(){return e})),this.__initPromise},x.prototype.__invokeResize=function(t,e){var n=this;return e.__mathCache=e.__mathCache||{},Promise.resolve().then((function(){return n.features.ww?new Promise((function(r,i){var o=n.__workersPool.acquire();e.cancelToken&&e.cancelToken.catch((function(t){return i(t)})),o.value.onmessage=function(t){o.release(),t.data.err?i(t.data.err):r(t.data)};var a=[];t.src&&a.push(t.src.buffer),t.srcBitmap&&a.push(t.srcBitmap),o.value.postMessage({opts:t,features:n.__requested_features,preload:{wasm_nodule:n.__mathlib.__}},a)})):{data:n.__mathlib.resizeAndUnsharp(t,e.__mathCache)}}))},x.prototype.__extractTileData=function(t,e,n,r,i){if(this.features.ww&&T&&(p.isCanvas(e)||C))return this.debug("Create tile for OffscreenCanvas"),createImageBitmap(r.srcImageBitmap||e,t.x,t.y,t.width,t.height).then((function(t){return i.srcBitmap=t,i}));if(p.isCanvas(e))return r.srcCtx||(r.srcCtx=e.getContext("2d",{alpha:Boolean(n.alpha)})),this.debug("Get tile pixel data"),i.src=r.srcCtx.getImageData(t.x,t.y,t.width,t.height).data,i;this.debug("Draw tile imageBitmap/image to temporary canvas");var o=this.options.createCanvas(t.width,t.height),a=o.getContext("2d",{alpha:Boolean(n.alpha)});return a.globalCompositeOperation="copy",a.drawImage(r.srcImageBitmap||e,t.x,t.y,t.width,t.height,0,0,t.width,t.height),this.debug("Get tile pixel data"),i.src=a.getImageData(0,0,t.width,t.height).data,o.width=o.height=0,i},x.prototype.__landTileData=function(t,e,n){var r;if(this.debug("Convert raw rgba tile result to ImageData"),e.bitmap)return n.toCtx.drawImage(e.bitmap,t.toX,t.toY),null;if(_)r=new ImageData(new Uint8ClampedArray(e.data),t.toWidth,t.toHeight);else if((r=n.toCtx.createImageData(t.toWidth,t.toHeight)).data.set)r.data.set(e.data);else for(var i=r.data.length-1;i>=0;i--)r.data[i]=e.data[i];return this.debug("Draw tile"),y?n.toCtx.putImageData(r,t.toX,t.toY,t.toInnerX-t.toX,t.toInnerY-t.toY,t.toInnerWidth+1e-5,t.toInnerHeight+1e-5):n.toCtx.putImageData(r,t.toX,t.toY,t.toInnerX-t.toX,t.toInnerY-t.toY,t.toInnerWidth,t.toInnerHeight),null},x.prototype.__tileAndResize=function(t,e,n){var r=this,i={srcCtx:null,srcImageBitmap:null,isImageBitmapReused:!1,toCtx:null},o=function(e){return r.__limit((function(){if(n.canceled)return n.cancelToken;var o={width:e.width,height:e.height,toWidth:e.toWidth,toHeight:e.toHeight,scaleX:e.scaleX,scaleY:e.scaleY,offsetX:e.offsetX,offsetY:e.offsetY,quality:n.quality,alpha:n.alpha,unsharpAmount:n.unsharpAmount,unsharpRadius:n.unsharpRadius,unsharpThreshold:n.unsharpThreshold};return r.debug("Invoke resize math"),Promise.resolve(o).then((function(o){return r.__extractTileData(e,t,n,i,o)})).then((function(t){return r.debug("Invoke resize math"),r.__invokeResize(t,n)})).then((function(t){return n.canceled?n.cancelToken:(i.srcImageData=null,r.__landTileData(e,t,i))}))}))};return Promise.resolve().then((function(){if(i.toCtx=e.getContext("2d",{alpha:Boolean(n.alpha)}),p.isCanvas(t))return null;if(p.isImageBitmap(t))return i.srcImageBitmap=t,i.isImageBitmapReused=!0,null;if(p.isImage(t))return I?(r.debug("Decode image via createImageBitmap"),createImageBitmap(t).then((function(t){i.srcImageBitmap=t})).catch((function(t){return null}))):null;throw new Error('Pica: ".from" should be Image, Canvas or ImageBitmap')})).then((function(){if(n.canceled)return n.cancelToken;r.debug("Calculate tiles");var t=m({width:n.width,height:n.height,srcTileSize:r.options.tile,toWidth:n.toWidth,toHeight:n.toHeight,destTileBorder:n.__destTileBorder}).map((function(t){return o(t)}));function a(t){t.srcImageBitmap&&(t.isImageBitmapReused||t.srcImageBitmap.close(),t.srcImageBitmap=null)}return r.debug("Process tiles"),Promise.all(t).then((function(){return r.debug("Finished!"),a(i),e}),(function(t){throw a(i),t}))}))},x.prototype.__processStages=function(t,e,n,i){var o=this;if(i.canceled)return i.cancelToken;var a,s=r(t.shift(),2),u=s[0],h=s[1],l=0===t.length;return i=c({},i,{toWidth:u,toHeight:h,quality:l?i.quality:Math.min(1,i.quality)}),l||(a=this.options.createCanvas(u,h)),this.__tileAndResize(e,l?n:a,i).then((function(){return l?n:(i.width=u,i.height=h,o.__processStages(t,a,n,i))})).then((function(t){return a&&(a.width=a.height=0),t}))},x.prototype.__resizeViaCreateImageBitmap=function(t,e,n){var r=this,i=e.getContext("2d",{alpha:Boolean(n.alpha)});return this.debug("Resize via createImageBitmap()"),createImageBitmap(t,{resizeWidth:n.toWidth,resizeHeight:n.toHeight,resizeQuality:p.cib_quality_name(n.quality)}).then((function(t){if(n.canceled)return n.cancelToken;if(!n.unsharpAmount)return i.drawImage(t,0,0),t.close(),i=null,r.debug("Finished!"),e;r.debug("Unsharp result");var o=r.options.createCanvas(n.toWidth,n.toHeight),a=o.getContext("2d",{alpha:Boolean(n.alpha)});a.drawImage(t,0,0),t.close();var s=a.getImageData(0,0,n.toWidth,n.toHeight);return r.__mathlib.unsharp_mask(s.data,n.toWidth,n.toHeight,n.unsharpAmount,n.unsharpRadius,n.unsharpThreshold),i.putImageData(s,0,0),o.width=o.height=0,s=a=o=i=null,r.debug("Finished!"),e}))},x.prototype.resize=function(t,e,n){var r=this;this.debug("Start resize...");var i=c({},w);if(isNaN(n)?n&&(i=c(i,n)):i=c(i,{quality:n}),i.toWidth=e.width,i.toHeight=e.height,i.width=t.naturalWidth||t.width,i.height=t.naturalHeight||t.height,0===e.width||0===e.height)return Promise.reject(new Error("Invalid output size: ".concat(e.width,"x").concat(e.height)));i.unsharpRadius>2&&(i.unsharpRadius=2),i.canceled=!1,i.cancelToken&&(i.cancelToken=i.cancelToken.then((function(t){throw i.canceled=!0,t}),(function(t){throw i.canceled=!0,t})));var o=3;return i.__destTileBorder=Math.ceil(Math.max(o,2.5*i.unsharpRadius|0)),this.init().then((function(){if(i.canceled)return i.cancelToken;if(r.features.cib)return r.__resizeViaCreateImageBitmap(t,e,i);if(!E){var n=new Error("Pica: cannot use getImageData on canvas, make sure fingerprinting protection isn't enabled");throw n.code="ERR_GET_IMAGE_DATA",n}var o=g(i.width,i.height,i.toWidth,i.toHeight,r.options.tile,i.__destTileBorder);return r.__processStages(o,t,e,i)}))},x.prototype.resizeBuffer=function(t){var e=this,n=c({},w,t);return this.init().then((function(){return e.__mathlib.resizeAndUnsharp(n)}))},x.prototype.toBlob=function(t,e,n){return e=e||"image/png",new Promise((function(r){if(t.toBlob)t.toBlob((function(t){return r(t)}),e,n);else if(t.convertToBlob)r(t.convertToBlob({type:e,quality:n}));else{for(var i=atob(t.toDataURL(e,n).split(",")[1]),o=i.length,a=new Uint8Array(o),s=0;s<o;s++)a[s]=i.charCodeAt(s);r(new Blob([a],{type:e}))}}))},x.prototype.debug=function(){},e.exports=x},{"./lib/mathlib":1,"./lib/pool":13,"./lib/stepper":14,"./lib/tiler":15,"./lib/utils":16,"./lib/worker":17,"object-assign":23,webworkify:24}]},{},[])("/index.js")},1191:function(t,e,n){"use strict";n.d(e,{CR:function(){return c},Jh:function(){return s},XA:function(){return u},ZT:function(){return i},ev:function(){return h},mG:function(){return a},pi:function(){return o}});var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)};function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return o=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},o.apply(this,arguments)};function a(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}Object.create;function u(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function h(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}Object.create},100:function(t,e,n){"use strict";n.r(e);function r(t,e){var n={};return e.forEach((function(e){Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])})),n}var i={assign:function(t){for(var e,n=1;n<arguments.length;n++)for(var r in e=Object(arguments[n]))Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},pick:r,pick_pica_resize_options:function(t){return r(t,["alpha","unsharpAmount","unsharpRadius","unsharpThreshold","cancelToken"])}};function o(t){var e={exports:{}};return t(e,e.exports),e.exports}function a(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.')}var s=o((function(t,e){t.exports=function(){function t(e,n,r){function i(s,u){if(!n[s]){if(!e[s]){if(!u&&a)return a(s);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=n[s]={exports:{}};e[s][0].call(h.exports,(function(t){return i(e[s][1][t]||t)}),h,h.exports,t,e,n,r)}return n[s].exports}for(var o=a,s=0;s<r.length;s++)i(r[s]);return i}return t}()({1:[function(t,e,n){var r=t("inherits"),i=t("multimath"),o=t("./mm_unsharp_mask"),a=t("./mm_resize");function s(t){var e=t||[],n={js:e.indexOf("js")>=0,wasm:e.indexOf("wasm")>=0};i.call(this,n),this.features={js:n.js,wasm:n.wasm&&this.has_wasm()},this.use(o),this.use(a)}r(s,i),s.prototype.resizeAndUnsharp=function(t,e){var n=this.resize(t,e);return t.unsharpAmount&&this.unsharp_mask(n,t.toWidth,t.toHeight,t.unsharpAmount,t.unsharpRadius,t.unsharpThreshold),n},e.exports=s},{"./mm_resize":4,"./mm_unsharp_mask":9,inherits:19,multimath:20}],2:[function(t,e,n){function r(t){return t<0?0:t>255?255:t}function i(t,e,n,i,o,a){var s,u,c,h,l,f,p,d,g,m,v,y=0,A=0;for(g=0;g<i;g++){for(l=0,m=0;m<o;m++){for(f=a[l++],p=a[l++],d=y+4*f|0,s=u=c=h=0;p>0;p--)h=h+(v=a[l++])*t[d+3]|0,c=c+v*t[d+2]|0,u=u+v*t[d+1]|0,s=s+v*t[d]|0,d=d+4|0;e[A+3]=r(h+8192>>14),e[A+2]=r(c+8192>>14),e[A+1]=r(u+8192>>14),e[A]=r(s+8192>>14),A=A+4*i|0}A=4*(g+1)|0,y=(g+1)*n*4|0}}function o(t,e,n,i,o,a){var s,u,c,h,l,f,p,d,g,m,v,y=0,A=0;for(g=0;g<i;g++){for(l=0,m=0;m<o;m++){for(f=a[l++],p=a[l++],d=y+4*f|0,s=u=c=h=0;p>0;p--)h=h+(v=a[l++])*t[d+3]|0,c=c+v*t[d+2]|0,u=u+v*t[d+1]|0,s=s+v*t[d]|0,d=d+4|0;e[A+3]=r(h+8192>>14),e[A+2]=r(c+8192>>14),e[A+1]=r(u+8192>>14),e[A]=r(s+8192>>14),A=A+4*i|0}A=4*(g+1)|0,y=(g+1)*n*4|0}}e.exports={convolveHorizontally:i,convolveVertically:o}},{}],3:[function(t,e,n){e.exports="AGFzbQEAAAAADAZkeWxpbmsAAAAAAAEXA2AAAGAGf39/f39/AGAHf39/f39/fwACDwEDZW52Bm1lbW9yeQIAAAMEAwABAgYGAX8AQQALB1cFEV9fd2FzbV9jYWxsX2N0b3JzAAAIY29udm9sdmUAAQpjb252b2x2ZUhWAAIMX19kc29faGFuZGxlAwAYX193YXNtX2FwcGx5X2RhdGFfcmVsb2NzAAAK7AMDAwABC8YDAQ9/AkAgA0UNACAERQ0AA0AgDCENQQAhE0EAIQcDQCAHQQJqIQYCfyAHQQF0IAVqIgcuAQIiFEUEQEGAwAAhCEGAwAAhCUGAwAAhCkGAwAAhCyAGDAELIBIgBy4BAGohCEEAIQsgFCEHQQAhDiAGIQlBACEPQQAhEANAIAUgCUEBdGouAQAiESAAIAhBAnRqKAIAIgpBGHZsIBBqIRAgCkH/AXEgEWwgC2ohCyAKQRB2Qf8BcSARbCAPaiEPIApBCHZB/wFxIBFsIA5qIQ4gCEEBaiEIIAlBAWohCSAHQQFrIgcNAAsgC0GAQGshCCAOQYBAayEJIA9BgEBrIQogEEGAQGshCyAGIBRqCyEHIAEgDUECdGogCUEOdSIGQf8BIAZB/wFIGyIGQQAgBkEAShtBCHRBgP4DcSAKQQ51IgZB/wEgBkH/AUgbIgZBACAGQQBKG0EQdEGAgPwHcSALQQ51IgZB/wEgBkH/AUgbIgZBACAGQQBKG0EYdHJyIAhBDnUiBkH/ASAGQf8BSBsiBkEAIAZBAEobcjYCACADIA1qIQ0gE0EBaiITIARHDQALIAxBAWoiDCACbCESIAMgDEcNAAsLCx4AQQAgAiADIAQgBSAAEAEgAkEAIAQgBSAGIAEQAQs="},{}],4:[function(t,e,n){e.exports={name:"resize",fn:t("./resize"),wasm_fn:t("./resize_wasm"),wasm_src:t("./convolve_wasm_base64")}},{"./convolve_wasm_base64":3,"./resize":5,"./resize_wasm":8}],5:[function(t,e,n){var r=t("./resize_filter_gen"),i=t("./convolve").convolveHorizontally,o=t("./convolve").convolveVertically;function a(t,e,n){for(var r=3,i=e*n*4|0;r<i;)t[r]=255,r=r+4|0}e.exports=function(t){var e=t.src,n=t.width,s=t.height,u=t.toWidth,c=t.toHeight,h=t.scaleX||t.toWidth/t.width,l=t.scaleY||t.toHeight/t.height,f=t.offsetX||0,p=t.offsetY||0,d=t.dest||new Uint8Array(u*c*4),g=void 0===t.quality?3:t.quality,m=t.alpha||!1,v=r(g,n,u,h,f),y=r(g,s,c,l,p),A=new Uint8Array(u*s*4);return i(e,A,n,s,u,v),o(A,d,s,u,c,y),m||a(d,u,c),d}},{"./convolve":2,"./resize_filter_gen":6}],6:[function(t,e,n){var r=t("./resize_filter_info"),i=14;function o(t){return Math.round(t*((1<<i)-1))}e.exports=function(t,e,n,i,a){var s,u,c,h,l,f,p,d,g,m,v,y,A,b,w,_,I,E=r[t].filter,T=1/i,C=Math.min(1,i),S=r[t].win/C,x=Math.floor(2*(S+1)),D=new Int16Array((x+2)*n),k=0,R=!D.subarray||!D.set;for(s=0;s<n;s++){for(u=(s+.5)*T+a,c=Math.max(0,Math.floor(u-S)),l=(h=Math.min(e-1,Math.ceil(u+S)))-c+1,f=new Float32Array(l),p=new Int16Array(l),d=0,g=c,m=0;g<=h;g++,m++)d+=v=E((g+.5-u)*C),f[m]=v;for(y=0,m=0;m<f.length;m++)y+=A=f[m]/d,p[m]=o(A);for(p[n>>1]+=o(1-y),b=0;b<p.length&&0===p[b];)b++;if(b<p.length){for(w=p.length-1;w>0&&0===p[w];)w--;if(_=c+b,I=w-b+1,D[k++]=_,D[k++]=I,R)for(m=b;m<=w;m++)D[k++]=p[m];else D.set(p.subarray(b,w+1),k),k+=I}else D[k++]=0,D[k++]=0}return D}},{"./resize_filter_info":7}],7:[function(t,e,n){e.exports=[{win:.5,filter:function(t){return t>=-.5&&t<.5?1:0}},{win:1,filter:function(t){if(t<=-1||t>=1)return 0;if(t>-1.1920929e-7&&t<1.1920929e-7)return 1;var e=t*Math.PI;return Math.sin(e)/e*(.54+.46*Math.cos(e/1))}},{win:2,filter:function(t){if(t<=-2||t>=2)return 0;if(t>-1.1920929e-7&&t<1.1920929e-7)return 1;var e=t*Math.PI;return Math.sin(e)/e*Math.sin(e/2)/(e/2)}},{win:3,filter:function(t){if(t<=-3||t>=3)return 0;if(t>-1.1920929e-7&&t<1.1920929e-7)return 1;var e=t*Math.PI;return Math.sin(e)/e*Math.sin(e/3)/(e/3)}}]},{}],8:[function(t,e,n){var r=t("./resize_filter_gen");function i(t,e,n){for(var r=3,i=e*n*4|0;r<i;)t[r]=255,r=r+4|0}function o(t){return new Uint8Array(t.buffer,0,t.byteLength)}var a=!0;try{a=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0]}catch(t){}function s(t,e,n){if(a)e.set(o(t),n);else for(var r=n,i=0;i<t.length;i++){var s=t[i];e[r++]=255&s,e[r++]=s>>8&255}}e.exports=function(t){var e=t.src,n=t.width,o=t.height,a=t.toWidth,u=t.toHeight,c=t.scaleX||t.toWidth/t.width,h=t.scaleY||t.toHeight/t.height,l=t.offsetX||0,f=t.offsetY||0,p=t.dest||new Uint8Array(a*u*4),d=void 0===t.quality?3:t.quality,g=t.alpha||!1,m=r(d,n,a,c,l),v=r(d,o,u,h,f),y=0,A=this.__align(y+Math.max(e.byteLength,p.byteLength)),b=this.__align(A+o*a*4),w=this.__align(b+m.byteLength),_=w+v.byteLength,I=this.__instance("resize",_),E=new Uint8Array(this.__memory.buffer),T=new Uint32Array(this.__memory.buffer),C=new Uint32Array(e.buffer);return T.set(C),s(m,E,b),s(v,E,w),(I.exports.convolveHV||I.exports._convolveHV)(b,w,A,n,o,a,u),new Uint32Array(p.buffer).set(new Uint32Array(this.__memory.buffer,0,u*a)),g||i(p,a,u),p}},{"./resize_filter_gen":6}],9:[function(t,e,n){e.exports={name:"unsharp_mask",fn:t("./unsharp_mask"),wasm_fn:t("./unsharp_mask_wasm"),wasm_src:t("./unsharp_mask_wasm_base64")}},{"./unsharp_mask":10,"./unsharp_mask_wasm":11,"./unsharp_mask_wasm_base64":12}],10:[function(t,e,n){var r=t("glur/mono16");function i(t,e,n){for(var r,i,o,a,s=e*n,u=new Uint16Array(s),c=0;c<s;c++)r=t[4*c],i=t[4*c+1],o=t[4*c+2],a=r>=i&&r>=o?r:i>=o&&i>=r?i:o,u[c]=a<<8;return u}e.exports=function(t,e,n,o,a,s){var u,c,h,l,f;if(!(0===o||a<.5)){a>2&&(a=2);var p=i(t,e,n),d=new Uint16Array(p);r(d,e,n,a);for(var g=o/100*4096+.5|0,m=s<<8,v=e*n,y=0;y<v;y++)l=(u=p[y])-d[y],Math.abs(l)>=m&&(h=((c=(c=(c=u+(g*l+2048>>12))>65280?65280:c)<0?0:c)<<12)/(u=0!==u?u:1)|0,t[f=4*y]=t[f]*h+2048>>12,t[f+1]=t[f+1]*h+2048>>12,t[f+2]=t[f+2]*h+2048>>12)}}},{"glur/mono16":18}],11:[function(t,e,n){e.exports=function(t,e,n,r,i,o){if(!(0===r||i<.5)){i>2&&(i=2);var a=e*n,s=4*a,u=2*a,c=2*a,h=4*Math.max(e,n),l=32,f=0,p=s,d=p+u,g=d+c,m=g+c,v=m+h,y=this.__instance("unsharp_mask",s+u+2*c+h+l,{exp:Math.exp}),A=new Uint32Array(t.buffer);new Uint32Array(this.__memory.buffer).set(A);var b=y.exports.hsv_v16||y.exports._hsv_v16;b(f,p,e,n),(b=y.exports.blurMono16||y.exports._blurMono16)(p,d,g,m,v,e,n,i),(b=y.exports.unsharp||y.exports._unsharp)(f,f,p,d,e,n,r,o),A.set(new Uint32Array(this.__memory.buffer,0,a))}}},{}],12:[function(t,e,n){e.exports="AGFzbQEAAAAADAZkeWxpbmsAAAAAAAE0B2AAAGAEf39/fwBgBn9/f39/fwBgCH9/f39/f39/AGAIf39/f39/f30AYAJ9fwBgAXwBfAIZAgNlbnYDZXhwAAYDZW52Bm1lbW9yeQIAAAMHBgAFAgQBAwYGAX8AQQALB4oBCBFfX3dhc21fY2FsbF9jdG9ycwABFl9fYnVpbGRfZ2F1c3NpYW5fY29lZnMAAg5fX2dhdXNzMTZfbGluZQADCmJsdXJNb25vMTYABAdoc3ZfdjE2AAUHdW5zaGFycAAGDF9fZHNvX2hhbmRsZQMAGF9fd2FzbV9hcHBseV9kYXRhX3JlbG9jcwABCsUMBgMAAQvWAQEHfCABRNuGukOCGvs/IAC7oyICRAAAAAAAAADAohAAIgW2jDgCFCABIAKaEAAiAyADoCIGtjgCECABRAAAAAAAAPA/IAOhIgQgBKIgAyACIAKgokQAAAAAAADwP6AgBaGjIgS2OAIAIAEgBSAEmqIiB7Y4AgwgASADIAJEAAAAAAAA8D+gIASioiIItjgCCCABIAMgAkQAAAAAAADwv6AgBKKiIgK2OAIEIAEgByAIoCAFRAAAAAAAAPA/IAahoCIDo7Y4AhwgASAEIAKgIAOjtjgCGAuGBQMGfwl8An0gAyoCDCEVIAMqAgghFiADKgIUuyERIAMqAhC7IRACQCAEQQFrIghBAEgiCQRAIAIhByAAIQYMAQsgAiAALwEAuCIPIAMqAhi7oiIMIBGiIg0gDCAQoiAPIAMqAgS7IhOiIhQgAyoCALsiEiAPoqCgoCIOtjgCACACQQRqIQcgAEECaiEGIAhFDQAgCEEBIAhBAUgbIgpBf3MhCwJ/IAQgCmtBAXFFBEAgDiENIAgMAQsgAiANIA4gEKIgFCASIAAvAQK4Ig+ioKCgIg22OAIEIAJBCGohByAAQQRqIQYgDiEMIARBAmsLIQIgC0EAIARrRg0AA0AgByAMIBGiIA0gEKIgDyAToiASIAYvAQC4Ig6ioKCgIgy2OAIAIAcgDSARoiAMIBCiIA4gE6IgEiAGLwECuCIPoqCgoCINtjgCBCAHQQhqIQcgBkEEaiEGIAJBAkohACACQQJrIQIgAA0ACwsCQCAJDQAgASAFIAhsQQF0aiIAAn8gBkECay8BACICuCINIBW7IhKiIA0gFrsiE6KgIA0gAyoCHLuiIgwgEKKgIAwgEaKgIg8gB0EEayIHKgIAu6AiDkQAAAAAAADwQWMgDkQAAAAAAAAAAGZxBEAgDqsMAQtBAAs7AQAgCEUNACAGQQRrIQZBACAFa0EBdCEBA0ACfyANIBKiIAJB//8DcbgiDSAToqAgDyIOIBCioCAMIBGioCIPIAdBBGsiByoCALugIgxEAAAAAAAA8EFjIAxEAAAAAAAAAABmcQRAIAyrDAELQQALIQMgBi8BACECIAAgAWoiACADOwEAIAZBAmshBiAIQQFKIQMgDiEMIAhBAWshCCADDQALCwvRAgIBfwd8AkAgB0MAAAAAWw0AIARE24a6Q4Ia+z8gB0MAAAA/l7ujIglEAAAAAAAAAMCiEAAiDLaMOAIUIAQgCZoQACIKIAqgIg22OAIQIAREAAAAAAAA8D8gCqEiCyALoiAKIAkgCaCiRAAAAAAAAPA/oCAMoaMiC7Y4AgAgBCAMIAuaoiIOtjgCDCAEIAogCUQAAAAAAADwP6AgC6KiIg+2OAIIIAQgCiAJRAAAAAAAAPC/oCALoqIiCbY4AgQgBCAOIA+gIAxEAAAAAAAA8D8gDaGgIgqjtjgCHCAEIAsgCaAgCqO2OAIYIAYEQANAIAAgBSAIbEEBdGogAiAIQQF0aiADIAQgBSAGEAMgCEEBaiIIIAZHDQALCyAFRQ0AQQAhCANAIAIgBiAIbEEBdGogASAIQQF0aiADIAQgBiAFEAMgCEEBaiIIIAVHDQALCwtxAQN/IAIgA2wiBQRAA0AgASAAKAIAIgRBEHZB/wFxIgIgAiAEQQh2Qf8BcSIDIAMgBEH/AXEiBEkbIAIgA0sbIgYgBiAEIAIgBEsbIAMgBEsbQQh0OwEAIAFBAmohASAAQQRqIQAgBUEBayIFDQALCwuZAgIDfwF8IAQgBWwhBAJ/IAazQwAAgEWUQwAAyEKVu0QAAAAAAADgP6AiC5lEAAAAAAAA4EFjBEAgC6oMAQtBgICAgHgLIQUgBARAIAdBCHQhCUEAIQYDQCAJIAIgBkEBdCIHai8BACIBIAMgB2ovAQBrIgcgB0EfdSIIaiAIc00EQCAAIAZBAnQiCGoiCiAFIAdsQYAQakEMdSABaiIHQYD+AyAHQYD+A0gbIgdBACAHQQBKG0EMdCABQQEgARtuIgEgCi0AAGxBgBBqQQx2OgAAIAAgCEEBcmoiByABIActAABsQYAQakEMdjoAACAAIAhBAnJqIgcgASAHLQAAbEGAEGpBDHY6AAALIAZBAWoiBiAERw0ACwsL"},{}],13:[function(t,e,n){var r=100;function i(t,e){this.create=t,this.available=[],this.acquired={},this.lastId=1,this.timeoutId=0,this.idle=e||2e3}i.prototype.acquire=function(){var t,e=this;return 0!==this.available.length?t=this.available.pop():((t=this.create()).id=this.lastId++,t.release=function(){return e.release(t)}),this.acquired[t.id]=t,t},i.prototype.release=function(t){var e=this;delete this.acquired[t.id],t.lastUsed=Date.now(),this.available.push(t),0===this.timeoutId&&(this.timeoutId=setTimeout((function(){return e.gc()}),r))},i.prototype.gc=function(){var t=this,e=Date.now();this.available=this.available.filter((function(n){return!(e-n.lastUsed>t.idle&&(n.destroy(),1))})),0!==this.available.length?this.timeoutId=setTimeout((function(){return t.gc()}),r):this.timeoutId=0},e.exports=i},{}],14:[function(t,e,n){var r=2;e.exports=function(t,e,n,i,o,a){var s=n/t,u=i/e,c=(2*a+r+1)/o;if(c>.5)return[[n,i]];var h=Math.ceil(Math.log(Math.min(s,u))/Math.log(c));if(h<=1)return[[n,i]];for(var l=[],f=0;f<h;f++){var p=Math.round(Math.pow(Math.pow(t,h-f-1)*Math.pow(n,f+1),1/h)),d=Math.round(Math.pow(Math.pow(e,h-f-1)*Math.pow(i,f+1),1/h));l.push([p,d])}return l}},{}],15:[function(t,e,n){var r=1e-5;function i(t){var e=Math.round(t);return Math.abs(t-e)<r?e:Math.floor(t)}function o(t){var e=Math.round(t);return Math.abs(t-e)<r?e:Math.ceil(t)}e.exports=function(t){var e,n,r,a,s,u,c=t.toWidth/t.width,h=t.toHeight/t.height,l=i(t.srcTileSize*c)-2*t.destTileBorder,f=i(t.srcTileSize*h)-2*t.destTileBorder;if(l<1||f<1)throw new Error("Internal error in pica: target tile width/height is too small.");var p,d=[];for(a=0;a<t.toHeight;a+=f)for(r=0;r<t.toWidth;r+=l)(e=r-t.destTileBorder)<0&&(e=0),e+(s=r+l+t.destTileBorder-e)>=t.toWidth&&(s=t.toWidth-e),(n=a-t.destTileBorder)<0&&(n=0),n+(u=a+f+t.destTileBorder-n)>=t.toHeight&&(u=t.toHeight-n),p={toX:e,toY:n,toWidth:s,toHeight:u,toInnerX:r,toInnerY:a,toInnerWidth:l,toInnerHeight:f,offsetX:e/c-i(e/c),offsetY:n/h-i(n/h),scaleX:c,scaleY:h,x:i(e/c),y:i(n/h),width:o(s/c),height:o(u/h)},d.push(p);return d}},{}],16:[function(t,e,n){function r(t){return Object.prototype.toString.call(t)}e.exports.isCanvas=function(t){var e=r(t);return"[object HTMLCanvasElement]"===e||"[object OffscreenCanvas]"===e||"[object Canvas]"===e},e.exports.isImage=function(t){return"[object HTMLImageElement]"===r(t)},e.exports.isImageBitmap=function(t){return"[object ImageBitmap]"===r(t)},e.exports.limiter=function(t){var e=0,n=[];function r(){e<t&&n.length&&(e++,n.shift()())}return function(t){return new Promise((function(i,o){n.push((function(){t().then((function(t){i(t),e--,r()}),(function(t){o(t),e--,r()}))})),r()}))}},e.exports.cib_quality_name=function(t){switch(t){case 0:return"pixelated";case 1:return"low";case 2:return"medium"}return"high"},e.exports.cib_support=function(t){return Promise.resolve().then((function(){if("undefined"==typeof createImageBitmap)return!1;var e=t(100,100);return createImageBitmap(e,0,0,100,100,{resizeWidth:10,resizeHeight:10,resizeQuality:"high"}).then((function(t){var n=10===t.width;return t.close(),e=null,n}))})).catch((function(){return!1}))},e.exports.worker_offscreen_canvas_support=function(){return new Promise((function(t,e){if("undefined"!=typeof OffscreenCanvas){var n=btoa("(".concat(i.toString(),")(self);")),r=new Worker("data:text/javascript;base64,".concat(n));r.onmessage=function(e){return t(e.data)},r.onerror=e}else t(!1);function i(t){"undefined"!=typeof createImageBitmap?Promise.resolve().then((function(){var t=new OffscreenCanvas(10,10);return t.getContext("2d").rect(0,0,1,1),createImageBitmap(t,0,0,1,1)})).then((function(){return t.postMessage(!0)}),(function(){return t.postMessage(!1)})):t.postMessage(!1)}})).then((function(t){return t}),(function(){return!1}))},e.exports.can_use_canvas=function(t){var e=!1;try{var n=t(2,1).getContext("2d"),r=n.createImageData(2,1);r.data[0]=12,r.data[1]=23,r.data[2]=34,r.data[3]=255,r.data[4]=45,r.data[5]=56,r.data[6]=67,r.data[7]=255,n.putImageData(r,0,0),r=null,12===(r=n.getImageData(0,0,2,1)).data[0]&&23===r.data[1]&&34===r.data[2]&&255===r.data[3]&&45===r.data[4]&&56===r.data[5]&&67===r.data[6]&&255===r.data[7]&&(e=!0)}catch(t){}return e},e.exports.cib_can_use_region=function(){return new Promise((function(t){if("undefined"!=typeof createImageBitmap){var e=new Image;e.src="data:image/jpeg;base64,/9j/4QBiRXhpZgAATU0AKgAAAAgABQESAAMAAAABAAYAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAAAAABIAAAAAQAAAEgAAAAB/9sAQwAEAwMEAwMEBAMEBQQEBQYKBwYGBgYNCQoICg8NEBAPDQ8OERMYFBESFxIODxUcFRcZGRsbGxAUHR8dGh8YGhsa/9sAQwEEBQUGBQYMBwcMGhEPERoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoa/8IAEQgAAQACAwERAAIRAQMRAf/EABQAAQAAAAAAAAAAAAAAAAAAAAf/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAF/P//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAQUCf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Bf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Bf//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEABj8Cf//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAT8hf//aAAwDAQACAAMAAAAQH//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Qf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Qf//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAT8Qf//Z",e.onload=function(){createImageBitmap(e,0,0,e.width,e.height).then((function(n){n.width===e.width&&n.height===e.height?t(!0):t(!1)}),(function(){return t(!1)}))},e.onerror=function(){return t(!1)}}else t(!1)}))}},{}],17:[function(t,e,n){e.exports=function(){var e,n=t("./mathlib");onmessage=function(t){var r=t.data.opts,i=!1;if(!r.src&&r.srcBitmap){var o=new OffscreenCanvas(r.width,r.height),a=o.getContext("2d",{alpha:Boolean(r.alpha)});a.drawImage(r.srcBitmap,0,0),r.src=a.getImageData(0,0,r.width,r.height).data,o.width=o.height=0,o=null,r.srcBitmap.close(),r.srcBitmap=null,i=!0}e||(e=new n(t.data.features));var s=e.resizeAndUnsharp(r);if(i){var u=new ImageData(new Uint8ClampedArray(s),r.toWidth,r.toHeight),c=new OffscreenCanvas(r.toWidth,r.toHeight);c.getContext("2d",{alpha:Boolean(r.alpha)}).putImageData(u,0,0),createImageBitmap(c).then((function(t){postMessage({bitmap:t},[t])}))}else postMessage({data:s},[s.buffer])}}},{"./mathlib":1}],18:[function(t,e,n){var r,i,o,a,s,u;function c(t){t<.5&&(t=.5);var e=Math.exp(.527076)/t,n=Math.exp(-e),c=Math.exp(-2*e),h=(1-n)*(1-n)/(1+2*e*n-c);return r=h,i=h*(e-1)*n,o=h*(e+1)*n,a=-h*c,s=2*n,u=-c,new Float32Array([r,i,o,a,s,u,(r+i)/(1-s-u),(o+a)/(1-s-u)])}function h(t,e,n,r,i,o){var a,s,u,c,h,l,f,p,d,g,m,v,y,A;for(d=0;d<o;d++){for(f=d,p=0,c=h=(a=t[l=d*i])*r[6],m=r[0],v=r[1],y=r[4],A=r[5],g=0;g<i;g++)u=(s=t[l])*m+a*v+c*y+h*A,h=c,c=u,a=s,n[p]=c,p++,l++;for(p--,f+=o*(i-1),c=h=(a=t[--l])*r[7],s=a,m=r[2],v=r[3],g=i-1;g>=0;g--)u=s*m+a*v+c*y+h*A,h=c,c=u,a=s,s=t[l],e[f]=n[p]+c,l--,p--,f-=o}}function l(t,e,n,r){if(r){var i=new Uint16Array(t.length),o=new Float32Array(Math.max(e,n)),a=c(r);h(t,i,o,a,e,n),h(i,t,o,a,n,e)}}e.exports=l},{}],19:[function(t,e,n){"function"==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}}},{}],20:[function(t,e,n){var r=t("object-assign"),i=t("./lib/base64decode"),o=t("./lib/wa_detect"),a={js:!0,wasm:!0};function s(t){if(!(this instanceof s))return new s(t);var e=r({},a,t||{});if(this.options=e,this.__cache={},this.__init_promise=null,this.__modules=e.modules||{},this.__memory=null,this.__wasm={},this.__isLE=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0],!this.options.js&&!this.options.wasm)throw new Error('mathlib: at least "js" or "wasm" should be enabled')}s.prototype.has_wasm=o,s.prototype.use=function(t){return this.__modules[t.name]=t,this.options.wasm&&this.has_wasm()&&t.wasm_fn?this[t.name]=t.wasm_fn:this[t.name]=t.fn,this},s.prototype.init=function(){if(this.__init_promise)return this.__init_promise;if(!this.options.js&&this.options.wasm&&!this.has_wasm())return Promise.reject(new Error('mathlib: only "wasm" was enabled, but it\'s not supported'));var t=this;return this.__init_promise=Promise.all(Object.keys(t.__modules).map((function(e){var n=t.__modules[e];return t.options.wasm&&t.has_wasm()&&n.wasm_fn?t.__wasm[e]?null:WebAssembly.compile(t.__base64decode(n.wasm_src)).then((function(n){t.__wasm[e]=n})):null}))).then((function(){return t})),this.__init_promise},s.prototype.__base64decode=i,s.prototype.__reallocate=function(t){if(!this.__memory)return this.__memory=new WebAssembly.Memory({initial:Math.ceil(t/65536)}),this.__memory;var e=this.__memory.buffer.byteLength;return e<t&&this.__memory.grow(Math.ceil((t-e)/65536)),this.__memory},s.prototype.__instance=function(t,e,n){if(e&&this.__reallocate(e),!this.__wasm[t]){var i=this.__modules[t];this.__wasm[t]=new WebAssembly.Module(this.__base64decode(i.wasm_src))}if(!this.__cache[t]){var o={memoryBase:0,memory:this.__memory,tableBase:0,table:new WebAssembly.Table({initial:0,element:"anyfunc"})};this.__cache[t]=new WebAssembly.Instance(this.__wasm[t],{env:r(o,n||{})})}return this.__cache[t]},s.prototype.__align=function(t,e){var n=t%(e=e||8);return t+(n?e-n:0)},e.exports=s},{"./lib/base64decode":21,"./lib/wa_detect":22,"object-assign":23}],21:[function(t,e,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";e.exports=function(t){for(var e=t.replace(/[\r\n=]/g,""),n=e.length,i=new Uint8Array(3*n>>2),o=0,a=0,s=0;s<n;s++)s%4==0&&s&&(i[a++]=o>>16&255,i[a++]=o>>8&255,i[a++]=255&o),o=o<<6|r.indexOf(e.charAt(s));var u=n%4*6;return 0===u?(i[a++]=o>>16&255,i[a++]=o>>8&255,i[a++]=255&o):18===u?(i[a++]=o>>10&255,i[a++]=o>>2&255):12===u&&(i[a++]=o>>4&255),i}},{}],22:[function(t,e,n){var r;e.exports=function(){if(void 0!==r)return r;if(r=!1,"undefined"==typeof WebAssembly)return r;try{var t=new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,127,1,127,3,2,1,0,5,3,1,0,1,7,8,1,4,116,101,115,116,0,0,10,16,1,14,0,32,0,65,1,54,2,0,32,0,40,2,0,11]),e=new WebAssembly.Module(t);return 0!==new WebAssembly.Instance(e,{}).exports.test(4)&&(r=!0),r}catch(t){}return r}},{}],23:[function(t,e,n){var r=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;function a(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function s(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},n=0;n<10;n++)e["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(e).map((function(t){return e[t]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(t){r[t]=t})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(t){return!1}}e.exports=s()?Object.assign:function(t,e){for(var n,s,u=a(t),c=1;c<arguments.length;c++){for(var h in n=Object(arguments[c]))i.call(n,h)&&(u[h]=n[h]);if(r){s=r(n);for(var l=0;l<s.length;l++)o.call(n,s[l])&&(u[s[l]]=n[s[l]])}}return u}},{}],24:[function(t,e,n){var r=arguments[3],i=arguments[4],o=arguments[5],a=JSON.stringify;e.exports=function(t,e){for(var n,s=Object.keys(o),u=0,c=s.length;u<c;u++){var h=s[u],l=o[h].exports;if(l===t||l&&l.default===t){n=h;break}}if(!n){n=Math.floor(Math.pow(16,8)*Math.random()).toString(16);var f={};for(u=0,c=s.length;u<c;u++)f[h=s[u]]=h;i[n]=["function(require,module,exports){"+t+"(self); }",f]}var p=Math.floor(Math.pow(16,8)*Math.random()).toString(16),d={};d[n]=n,i[p]=["function(require,module,exports){var f = require("+a(n)+");(f.default ? f.default : f)(self);}",d];var g={};function m(t){for(var e in g[t]=!0,i[t][1]){var n=i[t][1][e];g[n]||m(n)}}m(p);var v="("+r+")({"+Object.keys(g).map((function(t){return a(t)+":["+i[t][0]+","+a(i[t][1])+"]"})).join(",")+"},{},["+a(p)+"])",y=window.URL||window.webkitURL||window.mozURL||window.msURL,A=new Blob([v],{type:"text/javascript"});if(e&&e.bare)return A;var b=y.createObjectURL(A),w=new Worker(b);return w.objectURL=b,w}},{}],"/index.js":[function(t,e,n){function r(t,e){return u(t)||s(t,e)||o(t,e)||i()}function i(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(t,e){if(t){if("string"==typeof t)return a(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function s(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0);}catch(t){s=!0,i=t}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}}function u(t){if(Array.isArray(t))return t}var c=t("object-assign"),h=t("webworkify"),l=t("./lib/mathlib"),f=t("./lib/pool"),p=t("./lib/utils"),d=t("./lib/worker"),g=t("./lib/stepper"),m=t("./lib/tiler"),v={},y=!1;try{"undefined"!=typeof navigator&&navigator.userAgent&&(y=navigator.userAgent.indexOf("Safari")>=0)}catch(t){}var A=1;"undefined"!=typeof navigator&&(A=Math.min(navigator.hardwareConcurrency||1,4));var b={tile:1024,concurrency:A,features:["js","wasm","ww"],idle:2e3,createCanvas:function(t,e){var n=document.createElement("canvas");return n.width=t,n.height=e,n}},w={quality:3,alpha:!1,unsharpAmount:0,unsharpRadius:0,unsharpThreshold:0},_=!1,I=!1,E=!1,T=!1,C=!1;function S(){return{value:h(d),destroy:function(){if(this.value.terminate(),"undefined"!=typeof window){var t=window.URL||window.webkitURL||window.mozURL||window.msURL;t&&t.revokeObjectURL&&this.value.objectURL&&t.revokeObjectURL(this.value.objectURL)}}}}function x(t){if(!(this instanceof x))return new x(t);this.options=c({},b,t||{});var e="lk_".concat(this.options.concurrency);this.__limit=v[e]||p.limiter(this.options.concurrency),v[e]||(v[e]=this.__limit),this.features={js:!1,wasm:!1,cib:!1,ww:!1},this.__workersPool=null,this.__requested_features=[],this.__mathlib=null}x.prototype.init=function(){var e=this;if(this.__initPromise)return this.__initPromise;if("undefined"!=typeof ImageData&&"undefined"!=typeof Uint8ClampedArray)try{new ImageData(new Uint8ClampedArray(400),10,10),_=!0}catch(t){}"undefined"!=typeof ImageBitmap&&(ImageBitmap.prototype&&ImageBitmap.prototype.close?I=!0:this.debug("ImageBitmap does not support .close(), disabled"));var n=this.options.features.slice();if(n.indexOf("all")>=0&&(n=["cib","wasm","js","ww"]),this.__requested_features=n,this.__mathlib=new l(n),n.indexOf("ww")>=0&&"undefined"!=typeof window&&"Worker"in window)try{t("webworkify")((function(){})).terminate(),this.features.ww=!0;var r="wp_".concat(JSON.stringify(this.options));v[r]?this.__workersPool=v[r]:(this.__workersPool=new f(S,this.options.idle),v[r]=this.__workersPool)}catch(t){}var i,o,a=this.__mathlib.init().then((function(t){c(e.features,t.features)}));i=I?p.cib_support(this.options.createCanvas).then((function(t){e.features.cib&&n.indexOf("cib")<0?e.debug("createImageBitmap() resize supported, but disabled by config"):n.indexOf("cib")>=0&&(e.features.cib=t)})):Promise.resolve(!1),E=p.can_use_canvas(this.options.createCanvas),o=(o=I&&_&&-1!==n.indexOf("ww")?p.worker_offscreen_canvas_support():Promise.resolve(!1)).then((function(t){T=t}));var s=p.cib_can_use_region().then((function(t){C=t}));return this.__initPromise=Promise.all([a,i,o,s]).then((function(){return e})),this.__initPromise},x.prototype.__invokeResize=function(t,e){var n=this;return e.__mathCache=e.__mathCache||{},Promise.resolve().then((function(){return n.features.ww?new Promise((function(r,i){var o=n.__workersPool.acquire();e.cancelToken&&e.cancelToken.catch((function(t){return i(t)})),o.value.onmessage=function(t){o.release(),t.data.err?i(t.data.err):r(t.data)};var a=[];t.src&&a.push(t.src.buffer),t.srcBitmap&&a.push(t.srcBitmap),o.value.postMessage({opts:t,features:n.__requested_features,preload:{wasm_nodule:n.__mathlib.__}},a)})):{data:n.__mathlib.resizeAndUnsharp(t,e.__mathCache)}}))},x.prototype.__extractTileData=function(t,e,n,r,i){if(this.features.ww&&T&&(p.isCanvas(e)||C))return this.debug("Create tile for OffscreenCanvas"),createImageBitmap(r.srcImageBitmap||e,t.x,t.y,t.width,t.height).then((function(t){return i.srcBitmap=t,i}));if(p.isCanvas(e))return r.srcCtx||(r.srcCtx=e.getContext("2d",{alpha:Boolean(n.alpha)})),this.debug("Get tile pixel data"),i.src=r.srcCtx.getImageData(t.x,t.y,t.width,t.height).data,i;this.debug("Draw tile imageBitmap/image to temporary canvas");var o=this.options.createCanvas(t.width,t.height),a=o.getContext("2d",{alpha:Boolean(n.alpha)});return a.globalCompositeOperation="copy",a.drawImage(r.srcImageBitmap||e,t.x,t.y,t.width,t.height,0,0,t.width,t.height),this.debug("Get tile pixel data"),i.src=a.getImageData(0,0,t.width,t.height).data,o.width=o.height=0,i},x.prototype.__landTileData=function(t,e,n){var r;if(this.debug("Convert raw rgba tile result to ImageData"),e.bitmap)return n.toCtx.drawImage(e.bitmap,t.toX,t.toY),null;if(_)r=new ImageData(new Uint8ClampedArray(e.data),t.toWidth,t.toHeight);else if((r=n.toCtx.createImageData(t.toWidth,t.toHeight)).data.set)r.data.set(e.data);else for(var i=r.data.length-1;i>=0;i--)r.data[i]=e.data[i];return this.debug("Draw tile"),y?n.toCtx.putImageData(r,t.toX,t.toY,t.toInnerX-t.toX,t.toInnerY-t.toY,t.toInnerWidth+1e-5,t.toInnerHeight+1e-5):n.toCtx.putImageData(r,t.toX,t.toY,t.toInnerX-t.toX,t.toInnerY-t.toY,t.toInnerWidth,t.toInnerHeight),null},x.prototype.__tileAndResize=function(t,e,n){var r=this,i={srcCtx:null,srcImageBitmap:null,isImageBitmapReused:!1,toCtx:null},o=function(e){return r.__limit((function(){if(n.canceled)return n.cancelToken;var o={width:e.width,height:e.height,toWidth:e.toWidth,toHeight:e.toHeight,scaleX:e.scaleX,scaleY:e.scaleY,offsetX:e.offsetX,offsetY:e.offsetY,quality:n.quality,alpha:n.alpha,unsharpAmount:n.unsharpAmount,unsharpRadius:n.unsharpRadius,unsharpThreshold:n.unsharpThreshold};return r.debug("Invoke resize math"),Promise.resolve(o).then((function(o){return r.__extractTileData(e,t,n,i,o)})).then((function(t){return r.debug("Invoke resize math"),r.__invokeResize(t,n)})).then((function(t){return n.canceled?n.cancelToken:(i.srcImageData=null,r.__landTileData(e,t,i))}))}))};return Promise.resolve().then((function(){if(i.toCtx=e.getContext("2d",{alpha:Boolean(n.alpha)}),p.isCanvas(t))return null;if(p.isImageBitmap(t))return i.srcImageBitmap=t,i.isImageBitmapReused=!0,null;if(p.isImage(t))return I?(r.debug("Decode image via createImageBitmap"),createImageBitmap(t).then((function(t){i.srcImageBitmap=t})).catch((function(t){return null}))):null;throw new Error('Pica: ".from" should be Image, Canvas or ImageBitmap')})).then((function(){if(n.canceled)return n.cancelToken;r.debug("Calculate tiles");var t=m({width:n.width,height:n.height,srcTileSize:r.options.tile,toWidth:n.toWidth,toHeight:n.toHeight,destTileBorder:n.__destTileBorder}).map((function(t){return o(t)}));function a(t){t.srcImageBitmap&&(t.isImageBitmapReused||t.srcImageBitmap.close(),t.srcImageBitmap=null)}return r.debug("Process tiles"),Promise.all(t).then((function(){return r.debug("Finished!"),a(i),e}),(function(t){throw a(i),t}))}))},x.prototype.__processStages=function(t,e,n,i){var o=this;if(i.canceled)return i.cancelToken;var a,s=r(t.shift(),2),u=s[0],h=s[1],l=0===t.length;return i=c({},i,{toWidth:u,toHeight:h,quality:l?i.quality:Math.min(1,i.quality)}),l||(a=this.options.createCanvas(u,h)),this.__tileAndResize(e,l?n:a,i).then((function(){return l?n:(i.width=u,i.height=h,o.__processStages(t,a,n,i))})).then((function(t){return a&&(a.width=a.height=0),t}))},x.prototype.__resizeViaCreateImageBitmap=function(t,e,n){var r=this,i=e.getContext("2d",{alpha:Boolean(n.alpha)});return this.debug("Resize via createImageBitmap()"),createImageBitmap(t,{resizeWidth:n.toWidth,resizeHeight:n.toHeight,resizeQuality:p.cib_quality_name(n.quality)}).then((function(t){if(n.canceled)return n.cancelToken;if(!n.unsharpAmount)return i.drawImage(t,0,0),t.close(),i=null,r.debug("Finished!"),e;r.debug("Unsharp result");var o=r.options.createCanvas(n.toWidth,n.toHeight),a=o.getContext("2d",{alpha:Boolean(n.alpha)});a.drawImage(t,0,0),t.close();var s=a.getImageData(0,0,n.toWidth,n.toHeight);return r.__mathlib.unsharp_mask(s.data,n.toWidth,n.toHeight,n.unsharpAmount,n.unsharpRadius,n.unsharpThreshold),i.putImageData(s,0,0),o.width=o.height=0,s=a=o=i=null,r.debug("Finished!"),e}))},x.prototype.resize=function(t,e,n){var r=this;this.debug("Start resize...");var i=c({},w);if(isNaN(n)?n&&(i=c(i,n)):i=c(i,{quality:n}),i.toWidth=e.width,i.toHeight=e.height,i.width=t.naturalWidth||t.width,i.height=t.naturalHeight||t.height,0===e.width||0===e.height)return Promise.reject(new Error("Invalid output size: ".concat(e.width,"x").concat(e.height)));i.unsharpRadius>2&&(i.unsharpRadius=2),i.canceled=!1,i.cancelToken&&(i.cancelToken=i.cancelToken.then((function(t){throw i.canceled=!0,t}),(function(t){throw i.canceled=!0,t})));var o=3;return i.__destTileBorder=Math.ceil(Math.max(o,2.5*i.unsharpRadius|0)),this.init().then((function(){if(i.canceled)return i.cancelToken;if(r.features.cib)return r.__resizeViaCreateImageBitmap(t,e,i);if(!E){var n=new Error("Pica: cannot use getImageData on canvas, make sure fingerprinting protection isn't enabled");throw n.code="ERR_GET_IMAGE_DATA",n}var o=g(i.width,i.height,i.toWidth,i.toHeight,r.options.tile,i.__destTileBorder);return r.__processStages(o,t,e,i)}))},x.prototype.resizeBuffer=function(t){var e=this,n=c({},w,t);return this.init().then((function(){return e.__mathlib.resizeAndUnsharp(n)}))},x.prototype.toBlob=function(t,e,n){return e=e||"image/png",new Promise((function(r){if(t.toBlob)t.toBlob((function(t){return r(t)}),e,n);else if(t.convertToBlob)r(t.convertToBlob({type:e,quality:n}));else{for(var i=atob(t.toDataURL(e,n).split(",")[1]),o=i.length,a=new Uint8Array(o),s=0;s<o;s++)a[s]=i.charCodeAt(s);r(new Blob([a],{type:e}))}}))},x.prototype.debug=function(){},e.exports=x},{"./lib/mathlib":1,"./lib/pool":13,"./lib/stepper":14,"./lib/tiler":15,"./lib/utils":16,"./lib/worker":17,"object-assign":23,webworkify:24}]},{},[])("/index.js")})),u=o((function(t){function e(t,e){var n=new Error(t);return n.code=e,n}function n(t){for(var e=t.toString(16).toUpperCase(),n=2-e.length;n>0;n--)e="0"+e;return"0x"+e}function r(t){try{return decodeURIComponent(escape(t))}catch(e){return t}}function i(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)}function o(t,n,r){this.input=t.subarray(n,r),this.start=n;var i=String.fromCharCode.apply(null,this.input.subarray(0,4));if("II*\0"!==i&&"MM\0*"!==i)throw e("invalid TIFF signature","EBADDATA");this.big_endian="M"===i[0]}o.prototype.each=function(t){this.aborted=!1;var e=this.read_uint32(4);for(this.ifds_to_read=[{id:0,offset:e}];this.ifds_to_read.length>0&&!this.aborted;){var n=this.ifds_to_read.shift();n.offset&&this.scan_ifd(n.id,n.offset,t)}},o.prototype.filter=function(t){var n={ifd0:{id:0,entries:[]}};this.each((function(e){(!1!==t(e)||e.is_subifd_link)&&(e.is_subifd_link&&1!==e.count&&4!==e.format||(n["ifd"+e.ifd]||(n["ifd"+e.ifd]={id:e.ifd,entries:[]}),n["ifd"+e.ifd].entries.push(e)))})),delete n.ifd1;var r=8;Object.keys(n).forEach((function(t){r+=2,n[t].entries.forEach((function(t){r+=12+(t.data_length>4?2*Math.ceil(t.data_length/2):0)})),r+=4})),this.output=new Uint8Array(r),this.output[0]=this.output[1]=(this.big_endian?"M":"I").charCodeAt(0),this.write_uint16(2,42);var i=8,o=this;if(this.write_uint32(4,i),Object.keys(n).forEach((function(t){n[t].written_offset=i;var e=i,r=e+2+12*n[t].entries.length+4;i=r,o.write_uint16(e,n[t].entries.length),n[t].entries.sort((function(t,e){return t.tag-e.tag})).forEach((function(t,r){var a=e+2+12*r;o.write_uint16(a,t.tag),o.write_uint16(a+2,t.format),o.write_uint32(a+4,t.count),t.is_subifd_link?n["ifd"+t.tag]&&(n["ifd"+t.tag].link_offset=a+8):t.data_length<=4?o.output.set(o.input.subarray(t.data_offset-o.start,t.data_offset-o.start+4),a+8):(o.write_uint32(a+8,i),o.output.set(o.input.subarray(t.data_offset-o.start,t.data_offset-o.start+t.data_length),i),i+=2*Math.ceil(t.data_length/2))}));var a=n["ifd"+(n[t].id+1)];a&&(a.link_offset=r-4)})),Object.keys(n).forEach((function(t){n[t].written_offset&&n[t].link_offset&&o.write_uint32(n[t].link_offset,n[t].written_offset)})),this.output.length!==i)throw e("internal error: incorrect buffer size allocated");return this.output},o.prototype.read_uint16=function(t){var n=this.input;if(t+2>n.length)throw e("unexpected EOF","EBADDATA");return this.big_endian?256*n[t]+n[t+1]:n[t]+256*n[t+1]},o.prototype.read_uint32=function(t){var n=this.input;if(t+4>n.length)throw e("unexpected EOF","EBADDATA");return this.big_endian?16777216*n[t]+65536*n[t+1]+256*n[t+2]+n[t+3]:n[t]+256*n[t+1]+65536*n[t+2]+16777216*n[t+3]},o.prototype.write_uint16=function(t,e){var n=this.output;this.big_endian?(n[t]=e>>>8&255,n[t+1]=255&e):(n[t]=255&e,n[t+1]=e>>>8&255)},o.prototype.write_uint32=function(t,e){var n=this.output;this.big_endian?(n[t]=e>>>24&255,n[t+1]=e>>>16&255,n[t+2]=e>>>8&255,n[t+3]=255&e):(n[t]=255&e,n[t+1]=e>>>8&255,n[t+2]=e>>>16&255,n[t+3]=e>>>24&255)},o.prototype.is_subifd_link=function(t,e){return 0===t&&34665===e||0===t&&34853===e||34665===t&&40965===e},o.prototype.exif_format_length=function(t){switch(t){case 1:case 2:case 6:case 7:return 1;case 3:case 8:return 2;case 4:case 9:case 11:return 4;case 5:case 10:case 12:return 8;default:return 0}},o.prototype.exif_format_read=function(t,e){var n;switch(t){case 1:case 2:return n=this.input[e];case 6:return(n=this.input[e])|33554430*(128&n);case 3:return n=this.read_uint16(e);case 8:return(n=this.read_uint16(e))|131070*(32768&n);case 4:return n=this.read_uint32(e);case 9:return 0|(n=this.read_uint32(e));default:return null}},o.prototype.scan_ifd=function(t,n,i){var o=this.read_uint16(n);n+=2;for(var a=0;a<o;a++){var s=this.read_uint16(n),u=this.read_uint16(n+2),c=this.read_uint32(n+4),h=this.exif_format_length(u),l=c*h,f=l<=4?n+8:this.read_uint32(n+8),p=!1;if(f+l>this.input.length)throw e("unexpected EOF","EBADDATA");for(var d=[],g=f,m=0;m<c;m++,g+=h){var v=this.exif_format_read(u,g);if(null===v){d=null;break}d.push(v)}if(Array.isArray(d)&&2===u){try{d=r(String.fromCharCode.apply(null,d))}catch(t){d=null}d&&"\0"===d[d.length-1]&&(d=d.slice(0,-1))}if(this.is_subifd_link(t,s)&&Array.isArray(d)&&Number.isInteger(d[0])&&d[0]>0&&(this.ifds_to_read.push({id:s,offset:d[0]}),p=!0),!1===i({is_big_endian:this.big_endian,ifd:t,tag:s,format:u,count:c,entry_offset:n+this.start,data_length:l,data_offset:f+this.start,value:d,is_subifd_link:p}))return void(this.aborted=!0);n+=12}0===t&&this.ifds_to_read.push({id:1,offset:this.read_uint32(n)})},t.exports.is_jpeg=function(t){return t.length>=4&&255===t[0]&&216===t[1]&&255===t[2]},t.exports.jpeg_segments_each=function(r,o){if(!i(r))throw e("Invalid argument (jpeg_bin), Uint8Array expected","EINVAL");if("function"!=typeof o)throw e("Invalid argument (on_segment), Function expected","EINVAL");if(!t.exports.is_jpeg(r))throw e("Unknown file format","ENOTJPEG");for(var a=0,s=r.length,u=!1;;){var c,h;if(a+1>=s)throw e("Unexpected EOF","EBADDATA");var l=r[a],f=r[a+1];if(255===l&&255===f)c=255,h=1;else if(255===l&&0!==f){if(h=2,208<=(c=f)&&c<=217||1===c);else{if(a+3>=s)throw e("Unexpected EOF","EBADDATA");if((h+=256*r[a+2]+r[a+3])<2)throw e("Invalid segment length","EBADDATA");if(a+h-1>=s)throw e("Unexpected EOF","EBADDATA")}u&&(c>=208&&c<=215||(u=!1)),218===c&&(u=!0)}else{if(!u)throw e("Unexpected byte at segment start: "+n(l)+" (offset "+n(a)+")","EBADDATA");for(var p=a+1;;p++){if(p>=s)throw e("Unexpected EOF","EBADDATA");if(255===r[p]){if(p+1>=s)throw e("Unexpected EOF","EBADDATA");if(0!==r[p+1]){c=0,h=p-a;break}}}}if(!1===o({code:c,offset:a,length:h}))break;if(217===c)break;a+=h}},t.exports.jpeg_segments_filter=function(n,r){if(!i(n))throw e("Invalid argument (jpeg_bin), Uint8Array expected","EINVAL");if("function"!=typeof r)throw e("Invalid argument (on_segment), Function expected","EINVAL");var o=[],a=0;t.exports.jpeg_segments_each(n,(function(t){var e=r(t);if(i(e))o.push({data:e}),a+=e.length;else if(Array.isArray(e))e.filter(i).forEach((function(t){o.push({data:t}),a+=t.length}));else if(!1!==e){var n={start:t.offset,end:t.offset+t.length};o.length>0&&o[o.length-1].end===n.start?o[o.length-1].end=n.end:o.push(n),a+=t.length}}));var s=new Uint8Array(a),u=0;return o.forEach((function(t){var e=t.data||n.subarray(t.start,t.end);s.set(e,u),u+=e.length})),s},t.exports.jpeg_exif_tags_each=function(n,r){if(!i(n))throw e("Invalid argument (jpeg_bin), Uint8Array expected","EINVAL");if("function"!=typeof r)throw e("Invalid argument (on_exif_entry), Function expected","EINVAL");t.exports.jpeg_segments_each(n,(function(t){return 218!==t.code&&(225===t.code&&t.length>=10&&69===n[t.offset+4]&&120===n[t.offset+5]&&105===n[t.offset+6]&&102===n[t.offset+7]&&0===n[t.offset+8]&&0===n[t.offset+9]?(new o(n,t.offset+10,t.offset+t.length).each(r),!1):void 0)}))},t.exports.jpeg_exif_tags_filter=function(n,r){if(!i(n))throw e("Invalid argument (jpeg_bin), Uint8Array expected","EINVAL");if("function"!=typeof r)throw e("Invalid argument (on_exif_entry), Function expected","EINVAL");var a=!1;return t.exports.jpeg_segments_filter(n,(function(t){if(!a&&(218===t.code&&(a=!0),225===t.code&&t.length>=10&&69===n[t.offset+4]&&120===n[t.offset+5]&&105===n[t.offset+6]&&102===n[t.offset+7]&&0===n[t.offset+8]&&0===n[t.offset+9])){var e=new o(n,t.offset+10,t.offset+t.length).filter(r);if(!e)return!1;var i=new Uint8Array(10);return i.set(n.slice(t.offset,t.offset+10)),i[2]=e.length+8>>>8&255,i[3]=e.length+8&255,a=!0,[i,e]}}))},t.exports.jpeg_add_comment=function(e,n){var r=!1,i=0;return t.exports.jpeg_segments_filter(e,(function(t){if(!(1===++i&&216===t.code||2===i&&224===t.code||r)){n=function(t){try{return unescape(encodeURIComponent(t))}catch(e){return t}}(n);var o=new Uint8Array(5+n.length),a=0;return o[a++]=255,o[a++]=254,o[a++]=n.length+3>>>8&255,o[a++]=n.length+3&255,n.split("").forEach((function(t){o[a++]=255&t.charCodeAt(0)})),o[a++]=0,r=!0,[o,e.subarray(t.offset,t.offset+t.length)]}}))}}));function c(t){return this._getUint8Array(t.blob).then((function(e){if(t.is_jpeg=u.is_jpeg(e),!t.is_jpeg)return Promise.resolve(t);t.orig_blob=t.blob;try{var n,r;if(u.jpeg_exif_tags_each(e,(function(e){if(0===e.ifd&&274===e.tag&&Array.isArray(e.value))return t.orientation=e.value[0]||1,n=e.is_big_endian,r=e.data_offset,!1})),r){var i=n?new Uint8Array([0,1]):new Uint8Array([1,0]);t.blob=new Blob([e.slice(0,r),i,e.slice(r+2)],{type:"image/jpeg"})}}catch(t){}return t}))}function h(t){if(!t.is_jpeg)return Promise.resolve(t);var e,n=t.orientation-1;if(!n)return Promise.resolve(t);var r=(e=4&n?this.pica.options.createCanvas(t.out_canvas.height,t.out_canvas.width):this.pica.options.createCanvas(t.out_canvas.width,t.out_canvas.height)).getContext("2d");return r.save(),1&n&&r.transform(-1,0,0,1,e.width,0),2&n&&r.transform(-1,0,0,-1,e.width,e.height),4&n&&r.transform(0,1,1,0,0,0),r.drawImage(t.out_canvas,0,0),r.restore(),t.out_canvas.width=t.out_canvas.height=0,t.out_canvas=e,Promise.resolve(t)}function l(t){return t.is_jpeg?Promise.all([this._getUint8Array(t.blob),this._getUint8Array(t.out_blob)]).then((function(e){var n=e[0],r=e[1];if(!u.is_jpeg(n))return Promise.resolve(t);var i=[];return u.jpeg_segments_each(n,(function(t){if(218===t.code)return!1;i.push(t)})),i=i.filter((function(t){return 226!==t.code&&(t.code>=224&&t.code<240||254===t.code)})).map((function(t){return n.slice(t.offset,t.offset+t.length)})),t.out_blob=new Blob([r.slice(0,2)].concat(i).concat([r.slice(20)]),{type:"image/jpeg"}),t})):Promise.resolve(t)}var f={jpeg_patch_exif:c,jpeg_rotate_canvas:h,jpeg_attach_orig_segments:l,assign:function(t){t.before("_blob_to_image",c),t.after("_transform",h),t.after("_create_blob",l)}};function p(t){if(!(this instanceof p))return new p(t);t=t||{},this.pica=t.pica||s({}),this.initialized=!1,this.utils=i}p.prototype.use=function(t){var e=[this].concat(Array.prototype.slice.call(arguments,1));return t.apply(t,e),this},p.prototype.init=function(){this.use(f.assign)},p.prototype.toBlob=function(t,e){var n={blob:t,opts:i.assign({max:1/0},e)};return this.initialized||(this.init(),this.initialized=!0),Promise.resolve(n).then(this._blob_to_image).then(this._calculate_size).then(this._transform).then(this._cleanup).then(this._create_blob).then((function(t){return t.out_canvas.width=t.out_canvas.height=0,t.out_blob}))},p.prototype.toCanvas=function(t,e){var n={blob:t,opts:i.assign({max:1/0},e)};return this.initialized||(this.init(),this.initialized=!0),Promise.resolve(n).then(this._blob_to_image).then(this._calculate_size).then(this._transform).then(this._cleanup).then((function(t){return t.out_canvas}))},p.prototype.before=function(t,e){if(!this[t])throw new Error('Method "'+t+'" does not exist');if("function"!=typeof e)throw new Error('Invalid argument "fn", function expected');var n=this[t],r=this;return this[t]=function(t){return e.call(r,t).then((function(t){return n.call(r,t)}))},this},p.prototype.after=function(t,e){if(!this[t])throw new Error('Method "'+t+'" does not exist');if("function"!=typeof e)throw new Error('Invalid argument "fn", function expected');var n=this[t],r=this;return this[t]=function(t){return n.call(r,t).then((function(t){return e.call(r,t)}))},this},p.prototype._blob_to_image=function(t){var e=window.URL||window.webkitURL||window.mozURL||window.msURL;return t.image=document.createElement("img"),t.image_url=e.createObjectURL(t.blob),t.image.src=t.image_url,new Promise((function(e,n){t.image.onerror=function(){n(new Error("ImageBlobReduce: failed to create Image() from blob"))},t.image.onload=function(){e(t)}}))},p.prototype._calculate_size=function(t){var e=t.opts.max/Math.max(t.image.width,t.image.height);return e>1&&(e=1),t.transform_width=Math.max(Math.round(t.image.width*e),1),t.transform_height=Math.max(Math.round(t.image.height*e),1),t.scale_factor=e,Promise.resolve(t)},p.prototype._transform=function(t){t.out_canvas=this.pica.options.createCanvas(t.transform_width,t.transform_height),t.transform_width=null,t.transform_height=null;var e={alpha:"image/png"===t.blob.type};return this.utils.assign(e,this.utils.pick_pica_resize_options(t.opts)),this.pica.resize(t.image,t.out_canvas,e).then((function(){return t}))},p.prototype._cleanup=function(t){t.image.src="",t.image=null;var e=window.URL||window.webkitURL||window.mozURL||window.msURL;return e.revokeObjectURL&&e.revokeObjectURL(t.image_url),t.image_url=null,Promise.resolve(t)},p.prototype._create_blob=function(t){return this.pica.toBlob(t.out_canvas,t.blob.type).then((function(e){return t.out_blob=e,t}))},p.prototype._getUint8Array=function(t){return t.arrayBuffer?t.arrayBuffer().then((function(t){return new Uint8Array(t)})):new Promise((function(e,n){var r=new FileReader;r.readAsArrayBuffer(t),r.onload=function(){e(new Uint8Array(r.result))},r.onerror=function(){n(new Error("ImageBlobReduce: failed to load data from input blob")),r.abort()},r.onabort=function(){n(new Error("ImageBlobReduce: failed to load data from input blob (aborted)"))}}))},p.pica=s;var d=p;e.default=d},9521:function(t,e,n){"use strict";n.r(e),n.d(e,{default:function(){return o}});var r=n(8950),i=n(2975),o=function(){var t=(0,r.Z)(i.mark((function t(){var e,n=arguments;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.length>0&&void 0!==n[0]?n[0]:[{}],t.abrupt("return",(Array.isArray(e)||(e=[e]),e[0].recursive=e[0].recursive||!1,new Promise((function(t,n){var r=document.createElement("input");r.type="file",r.webkitdirectory=!0;var i=function(e){"function"==typeof o&&o(),t(e)},o=e[0].legacySetup&&e[0].legacySetup(i,(function(){return o(n)}),r);r.addEventListener("change",(function(){var t=Array.from(r.files);e[0].recursive?e[0].recursive&&e[0].skipDirectory&&(t=t.filter((function(t){return t.webkitRelativePath.split("/").every((function(t){return!e[0].skipDirectory({name:t,kind:"directory"})}))}))):t=t.filter((function(t){return 2===t.webkitRelativePath.split("/").length})),i(t)})),r.click()}))));case 2:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}()},6474:function(t,e,n){"use strict";n.r(e),n.d(e,{default:function(){return u}});var r=n(1930),i=n(8950),o=n(2975);function a(t){function e(t){if(Object(t)!==t)return Promise.reject(new TypeError(t+" is not an object."));var e=t.done;return Promise.resolve(t.value).then((function(t){return{value:t,done:e}}))}return(a=function(t){this.s=t,this.n=t.next}).prototype={s:null,n:null,next:function(){return e(this.n.apply(this.s,arguments))},return:function(t){var n=this.s.return;return void 0===n?Promise.resolve({value:t,done:!0}):e(n.apply(this.s,arguments))},throw:function(t){var n=this.s.return;return void 0===n?Promise.reject(t):e(n.apply(this.s,arguments))}},new a(t)}var s=function(){var t=(0,i.Z)(o.mark((function t(e,n){var i,u,c,h,l,f,p,d,g,m,v=arguments;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=v.length>2&&void 0!==v[2]?v[2]:e.name,u=v.length>3?v[3]:void 0,c=[],h=[],f=!1,p=!1,t.prev=4,d=o.mark((function t(){var r,a;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=g.value,a="".concat(i,"/").concat(r.name),"file"===r.kind?h.push(r.getFile().then((function(t){return t.directoryHandle=e,t.handle=r,Object.defineProperty(t,"webkitRelativePath",{configurable:!0,enumerable:!0,get:function(){return a}})}))):"directory"!==r.kind||!n||u&&u(r)||c.push(s(r,n,a,u));case 2:case"end":return t.stop()}}),t)})),m=function(t){var e,n,r,i=2;for("undefined"!=typeof Symbol&&(n=Symbol.asyncIterator,r=Symbol.iterator);i--;){if(n&&null!=(e=t[n]))return e.call(t);if(r&&null!=(e=t[r]))return new a(e.call(t));n="@@asyncIterator",r="@@iterator"}throw new TypeError("Object is not async iterable")}(e.values());case 7:return t.next=9,m.next();case 9:if(!(f=!(g=t.sent).done)){t.next=14;break}return t.delegateYield(d(),"t0",11);case 11:f=!1,t.next=7;break;case 14:t.next=19;break;case 16:t.prev=16,t.t1=t.catch(4),p=!0,l=t.t1;case 19:if(t.prev=19,t.prev=20,t.t2=f&&null!=m.return,!t.t2){t.next=25;break}return t.next=25,m.return();case 25:if(t.prev=25,!p){t.next=28;break}throw l;case 28:return t.finish(25);case 29:return t.finish(19);case 30:return t.t3=[],t.t4=r.Z,t.next=34,Promise.all(c);case 34:return t.t5=t.sent.flat(),t.t6=(0,t.t4)(t.t5),t.t7=r.Z,t.next=39,Promise.all(h);case 39:return t.t8=t.sent,t.t9=(0,t.t7)(t.t8),t.abrupt("return",t.t3.concat.call(t.t3,t.t6,t.t9));case 42:case"end":return t.stop()}}),t,null,[[4,16,19,30],[20,,25,29]])})));return function(e,n){return t.apply(this,arguments)}}(),u=function(){var t=(0,i.Z)(o.mark((function t(){var e,n,r=arguments;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(e=r.length>0&&void 0!==r[0]?r[0]:{}).recursive=e.recursive||!1,t.next=4,window.showDirectoryPicker({id:e.id,startIn:e.startIn});case 4:return n=t.sent,t.abrupt("return",s(n,e.recursive,void 0,e.skipDirectory));case 6:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}()},2254:function(t,e,n){"use strict";n.r(e),n.d(e,{default:function(){return a}});var r=n(8950),i=n(2975),o=function(){var t=(0,r.Z)(i.mark((function t(e){var n;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getFile();case 2:return n=t.sent,t.abrupt("return",(n.handle=e,n));case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),a=function(){var t=(0,r.Z)(i.mark((function t(){var e,n,r,a,s=arguments;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=s.length>0&&void 0!==s[0]?s[0]:[{}],Array.isArray(e)||(e=[e]),n=[],e.forEach((function(t,e){n[e]={description:t.description||"",accept:{}},t.mimeTypes?t.mimeTypes.map((function(r){n[e].accept[r]=t.extensions||[]})):n[e].accept["*/*"]=t.extensions||[]})),t.next=6,window.showOpenFilePicker({id:e[0].id,startIn:e[0].startIn,types:n,multiple:e[0].multiple||!1,excludeAcceptAllOption:e[0].excludeAcceptAllOption||!1});case 6:return r=t.sent,t.next=9,Promise.all(r.map(o));case 9:return a=t.sent,t.abrupt("return",e[0].multiple?a:a[0]);case 11:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}()},3499:function(t,e,n){"use strict";n.r(e),n.d(e,{default:function(){return a}});var r=n(1930),i=n(8950),o=n(2975),a=function(){var t=(0,i.Z)(o.mark((function t(){var e,n=arguments;return o.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.length>0&&void 0!==n[0]?n[0]:[{}],t.abrupt("return",(Array.isArray(e)||(e=[e]),new Promise((function(t,n){var i=document.createElement("input");i.type="file";var o=[].concat((0,r.Z)(e.map((function(t){return t.mimeTypes||[]}))),(0,r.Z)(e.map((function(t){return t.extensions||[]})))).join();i.multiple=e[0].multiple||!1,i.accept=o||"";var a=function(e){"function"==typeof s&&s(),t(e)},s=e[0].legacySetup&&e[0].legacySetup(a,(function(){return s(n)}),i);i.addEventListener("change",(function(){a(i.multiple?Array.from(i.files):i.files[0])})),i.click()}))));case 2:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}()},6281:function(t,e,n){"use strict";n.r(e),n.d(e,{default:function(){return o}});var r=n(8950),i=n(2975),o=function(){var t=(0,r.Z)(i.mark((function t(e){var n,o,a,s,u,c=arguments;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=c.length>1&&void 0!==c[1]?c[1]:{},Array.isArray(n)&&(n=n[0]),o=document.createElement("a"),a=e,t.t0="body"in e,!t.t0){t.next=9;break}return t.next=8,function(){var t=(0,r.Z)(i.mark((function t(e,n){var o,a,s,u;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.getReader(),a=new ReadableStream({start:function(t){return function(){var e=(0,r.Z)(i.mark((function e(){return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",o.read().then((function(e){var r=e.done,i=e.value;if(!r)return t.enqueue(i),n();t.close()})));case 1:case"end":return e.stop()}}),e)})));function n(){return e.apply(this,arguments)}return n}()()}}),s=new Response(a),t.next=5,s.blob();case 5:return u=t.sent,t.abrupt("return",(o.releaseLock(),new Blob([u],{type:n})));case 7:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()(e.body,e.headers.get("content-type"));case 8:a=t.sent;case 9:return o.download=n.fileName||"Untitled",t.t1=URL,t.next=13,a;case 13:return t.t2=t.sent,o.href=t.t1.createObjectURL.call(t.t1,t.t2),s=function(){"function"==typeof u&&u()},u=n.legacySetup&&n.legacySetup(s,(function(){return u(reject)}),o),t.abrupt("return",(o.addEventListener("click",(function(){setTimeout((function(){return URL.revokeObjectURL(o.href)}),3e4),s()})),o.click(),null));case 17:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},9475:function(t,e,n){"use strict";n.r(e),n.d(e,{default:function(){return o}});var r=n(8950),i=n(2975),o=function(){var t=(0,r.Z)(i.mark((function t(e){var n,r,o,a,s,u,c,h,l,f=arguments;return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=f.length>1&&void 0!==f[1]?f[1]:[{}],r=f.length>2&&void 0!==f[2]?f[2]:null,o=f.length>3&&void 0!==f[3]&&f[3],a=f.length>4&&void 0!==f[4]?f[4]:null,Array.isArray(n)||(n=[n]),n[0].fileName=n[0].fileName||"Untitled",s=[],u=null,e instanceof Blob&&e.type?u=e.type:e.headers&&e.headers.get("content-type")&&(u=e.headers.get("content-type")),n.forEach((function(t,e){s[e]={description:t.description||"",accept:{}},t.mimeTypes?(0===e&&u&&t.mimeTypes.push(u),t.mimeTypes.map((function(n){s[e].accept[n]=t.extensions||[]}))):u&&(s[e].accept[u]=t.extensions||[])})),!r){t.next=17;break}return t.prev=8,t.next=11,r.getFile();case 11:t.next=17;break;case 13:if(t.prev=13,t.t0=t.catch(8),r=null,!o){t.next=17;break}throw t.t0;case 17:if(t.t1=r,t.t1){t.next=22;break}return t.next=21,window.showSaveFilePicker({suggestedName:n[0].fileName,id:n[0].id,startIn:n[0].startIn,types:s,excludeAcceptAllOption:n[0].excludeAcceptAllOption||!1});case 21:t.t1=t.sent;case 22:return c=t.t1,!r&&a&&a(),t.next=26,c.createWritable();case 26:if(h=t.sent,!("stream"in e)){t.next=32;break}return l=e.stream(),t.next=31,l.pipeTo(h);case 31:return t.abrupt("return",c);case 32:if(!("body"in e)){t.next=38;break}return t.next=35,e.body.pipeTo(h);case 35:t.t2=c,t.next=47;break;case 38:return t.t3=h,t.next=41,e;case 41:return t.t4=t.sent,t.next=44,t.t3.write.call(t.t3,t.t4);case 44:return t.next=46,h.close();case 46:t.t2=c;case 47:return t.abrupt("return",t.t2);case 48:case"end":return t.stop()}}),t,null,[[8,13]])})));return function(e){return t.apply(this,arguments)}}()}}]);