{"campaign_post_author":"","campaign_post_title":"","campaign_post_status":"publish","campaign_comment_status":"closed","campaign_ping_status":"closed","campaign_post_name":"","campaign_post_mime_type":"clone","campaign_post_type":"campaigns","campaign_comment_count":"0","campaign_meta":[{"meta_key":"_edit_lock","meta_value":"1564580947:154"},{"meta_key":"_edit_last","meta_value":"154"},{"meta_key":"page_repeater","meta_value":"a:2:{i:0;a:5:{s:9:\"page_name\";s:9:\"Home Page\";s:12:\"page_preview\";s:0:\"\";s:11:\"page_layout\";s:1812:\"{\"rows\":[{\"columns\":[{\"type\":\"13\",\"elements\":[{\"name\":\"Image\",\"type\":\"images\",\"ids\":\"\"}]},{\"type\":\"23\",\"elements\":[{\"name\":\"Spacer\",\"type\":\"spacers\",\"ids\":\"\"},{\"name\":\"Heading\",\"type\":\"headings\",\"ids\":\"\"},{\"name\":\"Button\",\"type\":\"buttons\",\"ids\":\"\"}]}],\"heading\":null,\"type\":\"row_13_23\",\"style\":\"regular\",\"padding_top\":\"30\",\"padding_bottom\":\"20\",\"hide_top_border\":\"true\",\"hide_bottom_border\":\"true\",\"title\":\"\",\"titletext\":\"\",\"name\":\"echo-top\",\"collapsemargins\":\"\",\"fromdate\":\"\",\"fromtime\":\"\",\"todate\":\"\",\"totime\":\"\",\"daterange\":\"\",\"userpastview\":\"\",\"visibility\":\"\",\"fluid\":\"\",\"hide_in_native\":\"\"},{\"columns\":[{\"type\":\"12\",\"elements\":[{\"name\":\"Heading\",\"type\":\"headings\",\"ids\":\"\"},{\"name\":\"Raw HTML - Echo Devs Only\",\"type\":\"rawhtmls\",\"ids\":\"\"}]},{\"type\":\"12\",\"elements\":[{\"name\":\"Heading\",\"type\":\"headings\",\"ids\":\"\"},{\"name\":\"Paragraph\",\"type\":\"paragraphs\",\"ids\":\"\"},{\"name\":\"Image Text Button\",\"type\":\"imagetexts\",\"ids\":\"\"},{\"name\":\"Image Text Button\",\"type\":\"imagetexts\",\"ids\":\"\"},{\"name\":\"Image Text Button\",\"type\":\"imagetexts\",\"ids\":\"\"},{\"name\":\"Button\",\"type\":\"buttons\",\"ids\":\"\"}]}],\"heading\":null,\"type\":\"row_12_12\",\"style\":\"regular\",\"padding_top\":\"0\",\"padding_bottom\":\"110\",\"hide_top_border\":\"true\",\"hide_bottom_border\":\"true\",\"title\":\"\",\"titletext\":\"\",\"name\":\"echo-stream\",\"collapsemargins\":\"\",\"fromdate\":\"\",\"fromtime\":\"\",\"todate\":\"\",\"totime\":\"\",\"daterange\":\"\",\"userpastview\":\"\",\"visibility\":\"\",\"fluid\":\"\",\"hide_in_native\":\"\"},{\"columns\":[{\"type\":\"1\",\"elements\":[{\"name\":\"Raw HTML - Echo Devs Only\",\"type\":\"rawhtmls\",\"ids\":\"\"}]}],\"heading\":null,\"type\":\"row_1\",\"style\":\"\",\"padding_top\":\"50\",\"padding_bottom\":\"20\",\"hide_top_border\":\"true\",\"hide_bottom_border\":\"true\",\"title\":\"\",\"titletext\":\"\",\"fromdate\":\"\",\"fromtime\":\"\",\"todate\":\"\",\"totime\":\"\",\"daterange\":\"\",\"userpastview\":\"\",\"visibility\":\"\",\"fluid\":\"\"}]}\";s:14:\"page_languages\";s:0:\"\";s:16:\"page_ui_elements\";s:1812:\"{\"rows\":[{\"columns\":[{\"type\":\"13\",\"elements\":[{\"name\":\"Image\",\"type\":\"images\",\"ids\":\"\"}]},{\"type\":\"23\",\"elements\":[{\"name\":\"Spacer\",\"type\":\"spacers\",\"ids\":\"\"},{\"name\":\"Heading\",\"type\":\"headings\",\"ids\":\"\"},{\"name\":\"Button\",\"type\":\"buttons\",\"ids\":\"\"}]}],\"heading\":null,\"type\":\"row_13_23\",\"style\":\"regular\",\"padding_top\":\"30\",\"padding_bottom\":\"20\",\"hide_top_border\":\"true\",\"hide_bottom_border\":\"true\",\"title\":\"\",\"titletext\":\"\",\"name\":\"echo-top\",\"collapsemargins\":\"\",\"fromdate\":\"\",\"fromtime\":\"\",\"todate\":\"\",\"totime\":\"\",\"daterange\":\"\",\"userpastview\":\"\",\"visibility\":\"\",\"fluid\":\"\",\"hide_in_native\":\"\"},{\"columns\":[{\"type\":\"12\",\"elements\":[{\"name\":\"Heading\",\"type\":\"headings\",\"ids\":\"\"},{\"name\":\"Raw HTML - Echo Devs Only\",\"type\":\"rawhtmls\",\"ids\":\"\"}]},{\"type\":\"12\",\"elements\":[{\"name\":\"Heading\",\"type\":\"headings\",\"ids\":\"\"},{\"name\":\"Paragraph\",\"type\":\"paragraphs\",\"ids\":\"\"},{\"name\":\"Image Text Button\",\"type\":\"imagetexts\",\"ids\":\"\"},{\"name\":\"Image Text Button\",\"type\":\"imagetexts\",\"ids\":\"\"},{\"name\":\"Image Text Button\",\"type\":\"imagetexts\",\"ids\":\"\"},{\"name\":\"Button\",\"type\":\"buttons\",\"ids\":\"\"}]}],\"heading\":null,\"type\":\"row_12_12\",\"style\":\"regular\",\"padding_top\":\"0\",\"padding_bottom\":\"110\",\"hide_top_border\":\"true\",\"hide_bottom_border\":\"true\",\"title\":\"\",\"titletext\":\"\",\"name\":\"echo-stream\",\"collapsemargins\":\"\",\"fromdate\":\"\",\"fromtime\":\"\",\"todate\":\"\",\"totime\":\"\",\"daterange\":\"\",\"userpastview\":\"\",\"visibility\":\"\",\"fluid\":\"\",\"hide_in_native\":\"\"},{\"columns\":[{\"type\":\"1\",\"elements\":[{\"name\":\"Raw HTML - Echo Devs Only\",\"type\":\"rawhtmls\",\"ids\":\"\"}]}],\"heading\":null,\"type\":\"row_1\",\"style\":\"\",\"padding_top\":\"50\",\"padding_bottom\":\"20\",\"hide_top_border\":\"true\",\"hide_bottom_border\":\"true\",\"title\":\"\",\"titletext\":\"\",\"fromdate\":\"\",\"fromtime\":\"\",\"todate\":\"\",\"totime\":\"\",\"daterange\":\"\",\"userpastview\":\"\",\"visibility\":\"\",\"fluid\":\"\"}]}\";}i:1;a:5:{s:9:\"page_name\";s:4:\"test\";s:14:\"page_languages\";s:0:\"\";s:16:\"page_ui_elements\";s:420:\"{\"rows\":[{\"columns\":[{\"type\":\"1\",\"elements\":[{\"name\":\"Heading\",\"type\":\"headings\",\"ids\":\"\"}]}],\"heading\":null,\"type\":\"row_1\",\"style\":\"\",\"padding_top\":\"50\",\"padding_bottom\":\"20\",\"hide_top_border\":\"true\",\"hide_bottom_border\":\"true\",\"title\":\"\",\"titletext\":\"\",\"name\":\"\",\"collapsemargins\":\"\",\"fromdate\":\"\",\"fromtime\":\"\",\"todate\":\"\",\"totime\":\"\",\"daterange\":\"\",\"userpastview\":\"\",\"visibility\":\"\",\"fluid\":\"\",\"hide_in_native\":\"\"}]}\";s:12:\"page_preview\";s:0:\"\";s:11:\"page_layout\";s:420:\"{\"rows\":[{\"columns\":[{\"type\":\"1\",\"elements\":[{\"name\":\"Heading\",\"type\":\"headings\",\"ids\":\"\"}]}],\"heading\":null,\"type\":\"row_1\",\"style\":\"\",\"padding_top\":\"50\",\"padding_bottom\":\"20\",\"hide_top_border\":\"true\",\"hide_bottom_border\":\"true\",\"title\":\"\",\"titletext\":\"\",\"name\":\"\",\"collapsemargins\":\"\",\"fromdate\":\"\",\"fromtime\":\"\",\"todate\":\"\",\"totime\":\"\",\"daterange\":\"\",\"userpastview\":\"\",\"visibility\":\"\",\"fluid\":\"\",\"hide_in_native\":\"\"}]}\";}}"},{"meta_key":"campaign_languages","meta_value":"a:2:{i:0;s:2:\"EN\";i:1;s:2:\"MX\";}"},{"meta_key":"campaign_data_caching_enabled","meta_value":"on"},{"meta_key":"campaign_template","meta_value":"angular"},{"meta_key":"default_lang","meta_value":"EN"},{"meta_key":"latest_language_edited","meta_value":"MX"},{"meta_key":"edit_element_index","meta_value":""}],"campaign_control_panel_settings":[[{"meta_key":"_wp_page_template","meta_value":"campaign_settings.php"},{"meta_key":"pagetitle","meta_value":"Sports Live Streams for Free at Betsson"},{"meta_key":"termsandconditions","meta_value":"<h3>General Terms & Conditions<\/h3>\r\n<ul class=\"fa fa-ul\">\r\n<li><i class=\"fa-li fa fa-check-circle-o\"><\/i>Your first term and condition here.<\/li>\r\n<li><i class=\"fa-li fa fa-check-circle-o\"><\/i>Your second term and condition here.<\/li>\r\n<li><i class=\"fa-li fa fa-check-circle-o\"><\/i>Your third term and condition here.<\/li>\r\n<\/ul>"},{"meta_key":"headerbuttons","meta_value":"a:1:{i:0;a:4:{s:11:\"buttonlabel\";s:1:\" \";s:10:\"buttonlink\";s:1:\" \";s:10:\"buttonsize\";s:3:\"sml\";s:11:\"buttonstyle\";s:3:\"std\";}}"},{"meta_key":"items","meta_value":"a:2:{i:0;a:5:{s:5:\"label\";s:1:\" \";s:4:\"link\";s:1:\" \";s:11:\"innerscroll\";b:0;s:9:\"newwindow\";b:0;s:5:\"popup\";b:0;}i:1;a:2:{s:5:\"label\";s:1:\" \";s:4:\"link\";s:1:\" \";}}"},{"meta_key":"_edit_lock","meta_value":"1556627955:154"},{"meta_key":"_edit_last","meta_value":"154"},{"meta_key":"h_lang_switcher_style","meta_value":"horizontal"},{"meta_key":"sidebuttons_right","meta_value":"a:1:{i:0;a:3:{s:10:\"buttonlink\";s:1:\" \";s:10:\"buttonsize\";s:3:\"sml\";s:11:\"buttonstyle\";s:3:\"std\";}}"},{"meta_key":"pagemetarobots","meta_value":"nofollow"},{"meta_key":"campaign_css","meta_value":"*::-moz-selection {\r\nbackground-color: rgba(255,255,255,0.29);\r\n}\r\n\r\n*::selection {\r\nbackground-color: rgba(255,255,255,0.29);\r\n}\r\n\r\n\/* DESKTOP background*\/\r\n\r\n.echo_wrapper {\r\nbackground: url('https:\/\/in.betsson.com\/wp-content\/uploads\/content\/betsson\/sites\/3\/2018\/02\/1746x900-v2.jpg');\r\nbackground-size: cover;\r\nbackground-attachment: fixed;\r\nbackground-repeat: no-repeat;\r\nbackground-position: center;\r\n}\r\n\r\n\/* MOBILE background*\/ \r\n\r\n@media (max-width: 480px) {\r\n.echo_wrapper {\r\nbackground: url('https:\/\/in.nordicbet.com\/wp-content\/uploads\/content\/nordicbet\/sites\/4\/2017\/10\/480x1200_THIS.jpg');\r\nbackground-size: cover;\r\nbackground-attachment: fixed;\r\nbackground-repeat: no-repeat;\r\nbackground-position: center top;\r\n}\r\n}\r\n\r\n\/* TABLET background & adjustments *\/\r\n\r\n@media (min-width: 480px) and (max-width: 992px) {\r\n.echo_wrapper {\r\nbackground: url('https:\/\/in.nordicbet.com\/wp-content\/uploads\/content\/nordicbet\/sites\/4\/2017\/10\/992x1200_THIS.jpg');\r\nbackground-size: cover;\r\nbackground-attachment: fixed;\r\nbackground-repeat: no-repeat;\r\nbackground-position: center top;\r\n}\r\n\r\nh4 {\r\ntext-align: center;\r\nfont-size: 1.65em;\r\n}\r\n\r\n.echo .match-time, .echo .match-teams {\r\nfont-size: 1em;\r\n}\r\n\r\n.echo section .echo-image-text.echo-ambassador h3 {\r\nmargin: 20px 0 14px 100px!important;\r\nfont-size: 1.2em;\r\n}\r\n#echo-stream .echo-btn {\r\ndisplay: block;\r\nwidth: 45%;\r\nmargin: 0 auto;\r\nmargin-top: 25px;\r\n}\r\n}\r\n\r\n\/* general *\/\r\n\r\n.echo section {\r\nbackground: transparent;\r\n}\r\n\r\n.echo .echo-header {\r\ndisplay: none;\r\n}\r\n\r\n#echo-top img {\r\nmax-width: 190px;\r\n}\r\n\r\n\/* columns background *\/\r\n\r\n.echo #echo-stream .echo-col-lg-6:nth-of-type(1) {\r\nbackground-color: rgba(0,0,0, 0.3);\r\npadding-top: 25px;\r\npadding-bottom: 25px;\r\n}\r\n\r\n.echo .echo-col-lg-6 {\r\npadding-right: 35px;\r\npadding-left: 35px;\r\n}\r\n\r\n\/* fonts *\/\r\n\r\n.echo section p, .echo section h1, .echo section h2, .echo section h3, .echo section .echo-image-text h3 {\r\ncolor: #fff;\r\n}\r\n\r\n.echo section h1 {\r\nfont-size: 2.8em;\r\nfont-weight: 800;\r\nline-height: 1.1em;\r\ntext-transform: uppercase;\r\n}\r\n\r\n.echo p .engagement {\r\ndisplay: block;\r\nfont-size: 1.5em;\r\nline-height: 1.4em;\r\nmargin-bottom: 32px;\r\n}\r\n\r\n\r\n.echo section .echo-image-text.echo-ambassador:hover h3 {\r\ncolor: #fff;\r\n}\r\n\r\n.echo section h4 {\r\ncolor: #f07d00;\r\nfont-size: 1.8em;\r\nfont-weight: 600;\r\n}\r\n\r\n\/* steps appearance *\/\r\n\r\n.echo section .echo-image-text {\r\nmargin: 0 0 15px;\r\n}\r\n\r\n.echo section .echo-image-text.echo-ambassador {\r\nmin-height: 0px;\r\n}\r\n\r\n.echo section .echo-image-text.echo-ambassador img {\r\nwidth: 8%;\r\n}\r\n\r\n.echo section .echo-image-text.echo-ambassador h3 {\r\nmargin: 8px 0 16px 80px;\r\ntext-transform: none;\r\nfont-size: 1.4em;\r\nfont-weight: 400;\r\n}\r\n\r\n\/* Live Stream Part *\/\r\n\r\n#echo-stream .echo-row {\r\npadding-left: 50px;\r\n}\r\n\r\n@media screen and (max-width: 1200px) {\r\n#echo-stream .echo-row {\r\npadding-left: 0px;\r\n}\r\n}\r\n\r\n.streams-container {\r\ndisplay: grid;\r\ngrid-template-columns: 1fr 1fr;\r\ngrid-gap: 10px 20px;\r\n}\r\n\r\n.match {\r\nflex-flow: row nowrap;\r\nmargin: 0;\r\n}\r\n\r\n.match-link-container {\r\npadding: 0 20px;\r\ndisplay: flex;\r\nalign-items: center;\r\n}\r\n\r\n.match-link-container i {\r\ncolor: #fff;\r\nfont-size: 1.65em;\r\n}\r\n\r\n.match-info {\r\ndisplay: flex;\r\nflex-flow: column nowrap;\r\nmin-height: 50px;\r\njustify-content: space-around;\r\n}\r\n\r\n.echo .match-time,.echo .match-teams {\r\nmargin: 0;\r\nfont-size: 1.4em;\r\n}\r\n\r\n.echo .match-time {\r\nfont-weight: 600;\r\n}\r\n\r\n.echo .match-time span {\r\npadding-left: 12px;\r\ncolor: #f07d00;\r\n}\r\n\r\n.echo .echo-btn {\r\nfont-family: 'Roboto', sans-serif!important;\r\ntext-transform: none;\r\n}\r\n\r\n.echo .echo-btn span {\r\nfont-weight: 400!important;\r\n}\r\n\r\n#echo-stream .echo-btn, #echo-top .echo-btn {\r\nmin-width: 230px;\r\npadding: 6px;\r\ntext-align: center;\r\nborder-radius: 7px;\r\n}\r\n\r\n@media (max-width: 480px) {\r\n\r\n#echo-top .echo-image {\r\nmargin-bottom: 7px;\r\n}\r\n\r\n#echo-top h1 {\r\ntext-align: center;\r\nfont-size: 1.61em;\r\nmargin-bottom: 1.5em;\r\n}\r\n\r\n#echo-stream .echo-col-lg-6:nth-of-type(2) {\r\nmargin-top: 35px;\r\n}\r\n\r\n#echo-stream .echo-btn, #echo-top .echo-btn {\r\ndisplay: block;\r\nmin-width: 68%;\r\nmargin: 0 auto;\r\n}\r\n\r\n#echo-stream .echo-btn:hover, #echo-top .echo-btn:hover {\r\nbackground: #f60;\r\n}\r\n\r\n.echo section .echo-image-text.echo-ambassador h3 {\r\nmargin: 0 0 22px 80px;\r\nfont-family: 'Roboto', Helvetica, arial, sans-serif;\r\ntext-transform: none;\r\nfont-size: 1.1em;\r\n}\r\n}\r\n\r\nfooter {\r\ndisplay: none !important;\r\n}\r\n\r\n.echo_wrapper {\r\nmin-height: 100vh;\r\n}\r\n\r\n#ls-container {\r\n    font-family: Helvetice, Arial, Helvetica, sans-serif;\r\n    color: #fff;\r\n    display: grid;\r\n    grid-template-columns: 1fr 1fr;\r\n    grid-gap: 8px 12px;\r\n}\r\n\r\n@media screen and (max-width: 520px) {\r\n    #ls-container {\r\n        grid-template-columns: 1fr;\r\n    }\r\n}\r\n\r\n.event-container {\r\n    display: grid;\r\n    -ms-grid-template-columns: 25px 1fr;\r\n    grid-template-columns: 25px 1fr;\r\n}\r\n\r\n.event-icon-container {\r\n    padding-top: 4px;\r\n}\r\n\r\n.event-icon-container>img {\r\n    width: 70%;\r\n}\r\n\r\n.event-dates-container {\r\n    padding: 4px 0;\r\n}\r\n\r\n.event-date {\r\n    font-weight: 600;\r\n}\r\n\r\n.event-time {\r\n    color: #f60;\r\n}\r\n\r\n.event-lineup {\r\n    font-weight: 300;\r\n}\r\n"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"termsandconditions_hide","meta_value":"on"},{"meta_key":"campaign_js","meta_value":"require=function(r,e,n){function t(n,o){function i(r){return t(i.resolve(r))}function f(e){return r[n][1][e]||e}if(!e[n]){if(!r[n]){var c=\"function\"==typeof require&&require;if(!o&&c)return c(n,!0);if(u)return u(n,!0);var l=new Error(\"Cannot find module '\"+n+\"'\");throw l.code=\"MODULE_NOT_FOUND\",l}i.resolve=f;var a=e[n]=new t.Module;r[n][0].call(a.exports,i,a,a.exports)}return e[n].exports}function o(){this.bundle=t,this.exports={}}var u=\"function\"==typeof require&&require;t.Module=o,t.modules=r,t.cache=e,t.parent=u;for(var i=0;i<n.length;i++)t(n[i]);return t}({11:[function(require,module,exports) {\r\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0});class e{constructor(e){this.data=e,this.name=e.en,this.sport=e.cri,this.league=0,this.iconSrc=t[e.cri]||t.default,this.month=e.sd.match(\/-\\d\\d\/)[0].replace(\/\\D\/,\"\").replace(\/^0\/,\"\"),this.day=e.sd.match(\/\\d\\d[A-Z]\/)[0].replace(\/\\D\/,\"\").replace(\/^0\/,\"\"),this.startTime=e.sd.match(\/\\d\\d:\\d\\d\/)[0],this.node=this.createNode()}createNode(){const e=document.createElement(\"div\");e.classList.add(\"event-container\");const t=document.createElement(\"div\");t.classList.add(\"event-icon-container\");const n=document.createElement(\"img\");n.setAttribute(\"src\",this.iconSrc),t.appendChild(n),e.appendChild(t);const s=document.createElement(\"div\");s.classList.add(\"event-info-container\");const c=document.createElement(\"div\");c.classList.add(\"event-date-container\");const a=document.createElement(\"span\");a.innerHTML=`${this.day}\/${this.month} \u2014 `,a.classList.add(\"event-date\"),c.appendChild(a);const d=document.createElement(\"span\");d.innerHTML=`${this.startTime}`,d.classList.add(\"event-time\"),c.appendChild(d),s.appendChild(c);const i=document.createElement(\"div\");i.classList.add(\"event-name-container\");const o=document.createElement(\"span\");return o.classList.add(\"event-name\"),o.innerHTML=this.name,i.appendChild(o),s.appendChild(i),e.appendChild(s),e}}const t={football:\"https:\/\/bpsh2.hs.llnwd.net\/e1\/echo-cdn-origin\/content\/nordicbet\/sites\/3\/2017\/10\/football.png\",\"ice-hockey\":\"https:\/\/in.betsson.com\/wp-content\/uploads\/content\/betsson\/sites\/3\/2018\/03\/hockey.png\",basketball:\"https:\/\/bpsh2.hs.llnwd.net\/e1\/echo-cdn-origin\/content\/nordicbet\/sites\/3\/2017\/10\/basketball.png\",baseball:\"https:\/\/bpsh2.hs.llnwd.net\/e1\/echo-cdn-origin\/content\/nordicbet\/sites\/3\/2017\/10\/baseball.png\",default:\"https:\/\/image.ibb.co\/jhejoL\/youtube.png\"};exports.default=e;\r\n},{}],20:[function(require,module,exports) {\r\n!function(t){\"use strict\";if(!t.fetch){var e={searchParams:\"URLSearchParams\"in t,iterable:\"Symbol\"in t&&\"iterator\"in Symbol,blob:\"FileReader\"in t&&\"Blob\"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:\"FormData\"in t,arrayBuffer:\"ArrayBuffer\"in t};if(e.arrayBuffer)var r=[\"[object Int8Array]\",\"[object Uint8Array]\",\"[object Uint8ClampedArray]\",\"[object Int16Array]\",\"[object Uint16Array]\",\"[object Int32Array]\",\"[object Uint32Array]\",\"[object Float32Array]\",\"[object Float64Array]\"],o=function(t){return t&&DataView.prototype.isPrototypeOf(t)},n=ArrayBuffer.isView||function(t){return t&&r.indexOf(Object.prototype.toString.call(t))>-1};f.prototype.append=function(t,e){t=a(t),e=h(e);var r=this.map[t];this.map[t]=r?r+\",\"+e:e},f.prototype.delete=function(t){delete this.map[a(t)]},f.prototype.get=function(t){return t=a(t),this.has(t)?this.map[t]:null},f.prototype.has=function(t){return this.map.hasOwnProperty(a(t))},f.prototype.set=function(t,e){this.map[a(t)]=h(e)},f.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},f.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),u(t)},f.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),u(t)},f.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),u(t)},e.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);var i=[\"DELETE\",\"GET\",\"HEAD\",\"OPTIONS\",\"POST\",\"PUT\"];b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},c.call(b.prototype),c.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},w.error=function(){var t=new w(null,{status:0,statusText:\"\"});return t.type=\"error\",t};var s=[301,302,303,307,308];w.redirect=function(t,e){if(-1===s.indexOf(e))throw new RangeError(\"Invalid status code\");return new w(null,{status:e,headers:{location:t}})},t.Headers=f,t.Request=b,t.Response=w,t.fetch=function(t,r){return new Promise(function(o,n){var i=new b(t,r),s=new XMLHttpRequest;s.onload=function(){var t,e,r={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||\"\",e=new f,t.replace(\/\\r?\\n[\\t ]+\/g,\" \").split(\/\\r?\\n\/).forEach(function(t){var r=t.split(\":\"),o=r.shift().trim();if(o){var n=r.join(\":\").trim();e.append(o,n)}}),e)};r.url=\"responseURL\"in s?s.responseURL:r.headers.get(\"X-Request-URL\");var n=\"response\"in s?s.response:s.responseText;o(new w(n,r))},s.onerror=function(){n(new TypeError(\"Network request failed\"))},s.ontimeout=function(){n(new TypeError(\"Network request failed\"))},s.open(i.method,i.url,!0),\"include\"===i.credentials?s.withCredentials=!0:\"omit\"===i.credentials&&(s.withCredentials=!1),\"responseType\"in s&&e.blob&&(s.responseType=\"blob\"),i.headers.forEach(function(t,e){s.setRequestHeader(e,t)}),s.send(void 0===i._bodyInit?null:i._bodyInit)})},t.fetch.polyfill=!0}function a(t){if(\"string\"!=typeof t&&(t=String(t)),\/[^a-z0-9\\-#$%&'*+.\\^_`|~]\/i.test(t))throw new TypeError(\"Invalid character in header field name\");return t.toLowerCase()}function h(t){return\"string\"!=typeof t&&(t=String(t)),t}function u(t){var r={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return e.iterable&&(r[Symbol.iterator]=function(){return r}),r}function f(t){this.map={},t instanceof f?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function d(t){if(t.bodyUsed)return Promise.reject(new TypeError(\"Already read\"));t.bodyUsed=!0}function y(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function l(t){var e=new FileReader,r=y(e);return e.readAsArrayBuffer(t),r}function p(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function c(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,t)if(\"string\"==typeof t)this._bodyText=t;else if(e.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(e.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(e.arrayBuffer&&e.blob&&o(t))this._bodyArrayBuffer=p(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!e.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t)&&!n(t))throw new Error(\"unsupported BodyInit type\");this._bodyArrayBuffer=p(t)}else this._bodyText=\"\";this.headers.get(\"content-type\")||(\"string\"==typeof t?this.headers.set(\"content-type\",\"text\/plain;charset=UTF-8\"):this._bodyBlob&&this._bodyBlob.type?this.headers.set(\"content-type\",this._bodyBlob.type):e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set(\"content-type\",\"application\/x-www-form-urlencoded;charset=UTF-8\"))},e.blob&&(this.blob=function(){var t=d(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error(\"could not read FormData body as blob\");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?d(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(l)}),this.text=function(){var t,e,r,o=d(this);if(o)return o;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=y(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),o=0;o<e.length;o++)r[o]=String.fromCharCode(e[o]);return r.join(\"\")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error(\"could not read FormData body as text\");return Promise.resolve(this._bodyText)},e.formData&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}function b(t,e){var r,o,n=(e=e||{}).body;if(t instanceof b){if(t.bodyUsed)throw new TypeError(\"Already read\");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new f(t.headers)),this.method=t.method,this.mode=t.mode,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||\"omit\",!e.headers&&this.headers||(this.headers=new f(e.headers)),this.method=(r=e.method||this.method||\"GET\",o=r.toUpperCase(),i.indexOf(o)>-1?o:r),this.mode=e.mode||this.mode||null,this.referrer=null,(\"GET\"===this.method||\"HEAD\"===this.method)&&n)throw new TypeError(\"Body not allowed for GET or HEAD requests\");this._initBody(n)}function m(t){var e=new FormData;return t.trim().split(\"&\").forEach(function(t){if(t){var r=t.split(\"=\"),o=r.shift().replace(\/\\+\/g,\" \"),n=r.join(\"=\").replace(\/\\+\/g,\" \");e.append(decodeURIComponent(o),decodeURIComponent(n))}}),e}function w(t,e){e||(e={}),this.type=\"default\",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText=\"statusText\"in e?e.statusText:\"OK\",this.headers=new f(e.headers),this.url=e.url||\"\",this._initBody(t)}}(\"undefined\"!=typeof self?self:this);\r\n},{}],18:[function(require,module,exports) {\r\nvar global = (1,eval)(\"this\");\r\nvar t=(0,eval)(\"this\");require(\"whatwg-fetch\");var n=setTimeout;function e(){}function r(t,n){return function(){t.apply(n,arguments)}}function o(t){if(!(this instanceof o))throw new TypeError(\"Promises must be constructed via new\");if(\"function\"!=typeof t)throw new TypeError(\"not a function\");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],s(t,this)}function i(t,n){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,o._immediateFn(function(){var e=1===t._state?n.onFulfilled:n.onRejected;if(null!==e){var r;try{r=e(t._value)}catch(t){return void c(n.promise,t)}u(n.promise,r)}else(1===t._state?u:c)(n.promise,t._value)})):t._deferreds.push(n)}function u(t,n){try{if(n===t)throw new TypeError(\"A promise cannot be resolved with itself.\");if(n&&(\"object\"==typeof n||\"function\"==typeof n)){var e=n.then;if(n instanceof o)return t._state=3,t._value=n,void f(t);if(\"function\"==typeof e)return void s(r(e,n),t)}t._state=1,t._value=n,f(t)}catch(n){c(t,n)}}function c(t,n){t._state=2,t._value=n,f(t)}function f(t){2===t._state&&0===t._deferreds.length&&o._immediateFn(function(){t._handled||o._unhandledRejectionFn(t._value)});for(var n=0,e=t._deferreds.length;n<e;n++)i(t,t._deferreds[n]);t._deferreds=null}function a(t,n,e){this.onFulfilled=\"function\"==typeof t?t:null,this.onRejected=\"function\"==typeof n?n:null,this.promise=e}function s(t,n){var e=!1;try{t(function(t){e||(e=!0,u(n,t))},function(t){e||(e=!0,c(n,t))})}catch(t){if(e)return;e=!0,c(n,t)}}o.prototype.catch=function(t){return this.then(null,t)},o.prototype.then=function(t,n){var r=new this.constructor(e);return i(this,new a(t,n,r)),r},o.prototype.finally=function(t){var n=this.constructor;return this.then(function(e){return n.resolve(t()).then(function(){return e})},function(e){return n.resolve(t()).then(function(){return n.reject(e)})})},o.all=function(t){return new o(function(n,e){if(!t||void 0===t.length)throw new TypeError(\"Promise.all accepts an array\");var r=Array.prototype.slice.call(t);if(0===r.length)return n([]);var o=r.length;function i(t,u){try{if(u&&(\"object\"==typeof u||\"function\"==typeof u)){var c=u.then;if(\"function\"==typeof c)return void c.call(u,function(n){i(t,n)},e)}r[t]=u,0==--o&&n(r)}catch(t){e(t)}}for(var u=0;u<r.length;u++)i(u,r[u])})},o.resolve=function(t){return t&&\"object\"==typeof t&&t.constructor===o?t:new o(function(n){n(t)})},o.reject=function(t){return new o(function(n,e){e(t)})},o.race=function(t){return new o(function(n,e){for(var r=0,o=t.length;r<o;r++)t[r].then(n,e)})},o._immediateFn=\"function\"==typeof setImmediate&&function(t){setImmediate(t)}||function(t){n(t,0)},o._unhandledRejectionFn=function(t){\"undefined\"!=typeof console&&console&&console.warn(\"Possible Unhandled Promise Rejection:\",t)};var l=function(){if(\"undefined\"!=typeof self)return self;if(\"undefined\"!=typeof window)return window;if(void 0!==t)return t;throw new Error(\"unable to locate global object\")}();function p(t,n){return t(n={exports:{}},n.exports),n.exports}l.Promise||(l.Promise=o);var h=p(function(t){var n=t.exports=\"undefined\"!=typeof window&&window.Math==Math?window:\"undefined\"!=typeof self&&self.Math==Math?self:Function(\"return this\")();\"number\"==typeof __g&&(__g=n)}),y=p(function(t){var n=t.exports={version:\"2.5.5\"};\"number\"==typeof __e&&(__e=n)}),v=y.version,d=function(t){return\"object\"==typeof t?null!==t:\"function\"==typeof t},g=function(t){if(!d(t))throw TypeError(t+\" is not an object!\");return t},m=function(t){try{return!!t()}catch(t){return!0}},b=!m(function(){return 7!=Object.defineProperty({},\"a\",{get:function(){return 7}}).a}),S=h.document,w=d(S)&&d(S.createElement),_=function(t){return w?S.createElement(t):{}},O=!b&&!m(function(){return 7!=Object.defineProperty(_(\"div\"),\"a\",{get:function(){return 7}}).a}),j=function(t,n){if(!d(t))return t;var e,r;if(n&&\"function\"==typeof(e=t.toString)&&!d(r=e.call(t)))return r;if(\"function\"==typeof(e=t.valueOf)&&!d(r=e.call(t)))return r;if(!n&&\"function\"==typeof(e=t.toString)&&!d(r=e.call(t)))return r;throw TypeError(\"Can't convert object to primitive value\")},P=Object.defineProperty,E=b?Object.defineProperty:function(t,n,e){if(g(t),n=j(n,!0),g(e),O)try{return P(t,n,e)}catch(t){}if(\"get\"in e||\"set\"in e)throw TypeError(\"Accessors not supported!\");return\"value\"in e&&(t[n]=e.value),t},T={f:E},A=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}},F=b?function(t,n,e){return T.f(t,n,A(1,e))}:function(t,n,e){return t[n]=e,t},L={}.hasOwnProperty,M=function(t,n){return L.call(t,n)},k=0,x=Math.random(),I=function(t){return\"Symbol(\".concat(void 0===t?\"\":t,\")_\",(++k+x).toString(36))},N=p(function(t){var n=I(\"src\"),e=Function.toString,r=(\"\"+e).split(\"toString\");y.inspectSource=function(t){return e.call(t)},(t.exports=function(t,e,o,i){var u=\"function\"==typeof o;u&&(M(o,\"name\")||F(o,\"name\",e)),t[e]!==o&&(u&&(M(o,n)||F(o,n,t[e]?\"\"+t[e]:r.join(String(e)))),t===h?t[e]=o:i?t[e]?t[e]=o:F(t,e,o):(delete t[e],F(t,e,o)))})(Function.prototype,\"toString\",function(){return\"function\"==typeof this&&this[n]||e.call(this)})}),C=function(t){if(\"function\"!=typeof t)throw TypeError(t+\" is not a function!\");return t},R=function(t,n,e){if(C(t),void 0===n)return t;switch(e){case 1:return function(e){return t.call(n,e)};case 2:return function(e,r){return t.call(n,e,r)};case 3:return function(e,r,o){return t.call(n,e,r,o)}}return function(){return t.apply(n,arguments)}},D=\"prototype\",G=function(t,n,e){var r,o,i,u,c=t&G.F,f=t&G.G,a=t&G.S,s=t&G.P,l=t&G.B,p=f?h:a?h[n]||(h[n]={}):(h[n]||{})[D],v=f?y:y[n]||(y[n]={}),d=v[D]||(v[D]={});for(r in f&&(e=n),e)i=((o=!c&&p&&void 0!==p[r])?p:e)[r],u=l&&o?R(i,h):s&&\"function\"==typeof i?R(Function.call,i):i,p&&N(p,r,i,t&G.U),v[r]!=i&&F(v,r,u),s&&d[r]!=i&&(d[r]=i)};h.core=y,G.F=1,G.G=2,G.S=4,G.P=8,G.B=16,G.W=32,G.U=64,G.R=128;var W=G,V={}.toString,z=function(t){return V.call(t).slice(8,-1)},K=Object(\"z\").propertyIsEnumerable(0)?Object:function(t){return\"String\"==z(t)?t.split(\"\"):Object(t)},H=function(t){if(null==t)throw TypeError(\"Can't call method on  \"+t);return t},J=function(t){return Object(H(t))},U=Math.ceil,q=Math.floor,B=function(t){return isNaN(t=+t)?0:(t>0?q:U)(t)},Y=Math.min,Q=function(t){return t>0?Y(B(t),9007199254740991):0},X=Array.isArray||function(t){return\"Array\"==z(t)},Z=\"__core-js_shared__\",$=h[Z]||(h[Z]={}),tt=function(t){return $[t]||($[t]={})},nt=p(function(t){var n=tt(\"wks\"),e=h.Symbol,r=\"function\"==typeof e;(t.exports=function(t){return n[t]||(n[t]=r&&e[t]||(r?e:I)(\"Symbol.\"+t))}).store=n}),et=nt(\"species\"),rt=function(t){var n;return X(t)&&(\"function\"!=typeof(n=t.constructor)||n!==Array&&!X(n.prototype)||(n=void 0),d(n)&&null===(n=n[et])&&(n=void 0)),void 0===n?Array:n},ot=function(t,n){return new(rt(t))(n)},it=function(t,n){var e=1==t,r=2==t,o=3==t,i=4==t,u=6==t,c=5==t||u,f=n||ot;return function(n,a,s){for(var l,p,h=J(n),y=K(h),v=R(a,s,3),d=Q(y.length),g=0,m=e?f(n,d):r?f(n,0):void 0;d>g;g++)if((c||g in y)&&(p=v(l=y[g],g,h),t))if(e)m[g]=p;else if(p)switch(t){case 3:return!0;case 5:return l;case 6:return g;case 2:m.push(l)}else if(i)return!1;return u?-1:o||i?i:m}},ut=nt(\"unscopables\"),ct=Array.prototype;null==ct[ut]&&F(ct,ut,{});var ft=function(t){ct[ut][t]=!0},at=it(5),st=\"find\",lt=!0;st in[]&&Array(1)[st](function(){lt=!1}),W(W.P+W.F*lt,\"Array\",{find:function(t){return at(this,t,arguments.length>1?arguments[1]:void 0)}}),ft(st);var pt=y.Array.find,ht=it(6),yt=\"findIndex\",vt=!0;yt in[]&&Array(1)[yt](function(){vt=!1}),W(W.P+W.F*vt,\"Array\",{findIndex:function(t){return ht(this,t,arguments.length>1?arguments[1]:void 0)}}),ft(yt);var dt=y.Array.findIndex,gt=function(t){return K(H(t))},mt=Math.max,bt=Math.min,St=function(t,n){return(t=B(t))<0?mt(t+n,0):bt(t,n)},wt=function(t){return function(n,e,r){var o,i=gt(n),u=Q(i.length),c=St(r,u);if(t&&e!=e){for(;u>c;)if((o=i[c++])!=o)return!0}else for(;u>c;c++)if((t||c in i)&&i[c]===e)return t||c||0;return!t&&-1}},_t=tt(\"keys\"),Ot=function(t){return _t[t]||(_t[t]=I(t))},jt=wt(!1),Pt=Ot(\"IE_PROTO\"),Et=function(t,n){var e,r=gt(t),o=0,i=[];for(e in r)e!=Pt&&M(r,e)&&i.push(e);for(;n.length>o;)M(r,e=n[o++])&&(~jt(i,e)||i.push(e));return i},Tt=\"constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf\".split(\",\"),At=Object.keys||function(t){return Et(t,Tt)},Ft=Object.getOwnPropertySymbols,Lt={f:Ft},Mt={}.propertyIsEnumerable,kt={f:Mt},xt=Object.assign,It=!xt||m(function(){var t={},n={},e=Symbol(),r=\"abcdefghijklmnopqrst\";return t[e]=7,r.split(\"\").forEach(function(t){n[t]=t}),7!=xt({},t)[e]||Object.keys(xt({},n)).join(\"\")!=r})?function(t,n){for(var e=J(t),r=arguments.length,o=1,i=Lt.f,u=kt.f;r>o;)for(var c,f=K(arguments[o++]),a=i?At(f).concat(i(f)):At(f),s=a.length,l=0;s>l;)u.call(f,c=a[l++])&&(e[c]=f[c]);return e}:xt;W(W.S+W.F,\"Object\",{assign:It});var Nt=y.Object.assign,Ct=nt(\"match\"),Rt=function(t){var n;return d(t)&&(void 0!==(n=t[Ct])?!!n:\"RegExp\"==z(t))},Dt=function(t,n,e){if(Rt(n))throw TypeError(\"String#\"+e+\" doesn't accept regex!\");return String(H(t))},Gt=nt(\"match\"),Wt=function(t){var n=\/.\/;try{\"\/.\/\"[t](n)}catch(e){try{return n[Gt]=!1,!\"\/.\/\"[t](n)}catch(t){}}return!0},Vt=\"startsWith\",zt=\"\"[Vt];W(W.P+W.F*Wt(Vt),\"String\",{startsWith:function(t){var n=Dt(this,t,Vt),e=Q(Math.min(arguments.length>1?arguments[1]:void 0,n.length)),r=String(t);return zt?zt.call(n,r,e):n.slice(e,e+r.length)===r}});var Kt=y.String.startsWith,Ht=function(t){var n=String(H(this)),e=\"\",r=B(t);if(r<0||r==1\/0)throw RangeError(\"Count can't be negative\");for(;r>0;(r>>>=1)&&(n+=n))1&r&&(e+=n);return e};W(W.P,\"String\",{repeat:Ht});var Jt=y.String.repeat,Ut=p(function(t){var n=I(\"meta\"),e=T.f,r=0,o=Object.isExtensible||function(){return!0},i=!m(function(){return o(Object.preventExtensions({}))}),u=function(t){e(t,n,{value:{i:\"O\"+ ++r,w:{}}})},c=t.exports={KEY:n,NEED:!1,fastKey:function(t,e){if(!d(t))return\"symbol\"==typeof t?t:(\"string\"==typeof t?\"S\":\"P\")+t;if(!M(t,n)){if(!o(t))return\"F\";if(!e)return\"E\";u(t)}return t[n].i},getWeak:function(t,e){if(!M(t,n)){if(!o(t))return!0;if(!e)return!1;u(t)}return t[n].w},onFreeze:function(t){return i&&c.NEED&&o(t)&&!M(t,n)&&u(t),t}}}),qt=Ut.KEY,Bt=Ut.NEED,Yt=Ut.fastKey,Qt=Ut.getWeak,Xt=Ut.onFreeze,Zt=T.f,$t=nt(\"toStringTag\"),tn=function(t,n,e){t&&!M(t=e?t:t.prototype,$t)&&Zt(t,$t,{configurable:!0,value:n})},nn=nt,en={f:nn},rn=!1,on=T.f,un=function(t){var n=y.Symbol||(y.Symbol=rn?{}:h.Symbol||{});\"_\"==t.charAt(0)||t in n||on(n,t,{value:en.f(t)})},cn=function(t){var n=At(t),e=Lt.f;if(e)for(var r,o=e(t),i=kt.f,u=0;o.length>u;)i.call(t,r=o[u++])&&n.push(r);return n},fn=b?Object.defineProperties:function(t,n){g(t);for(var e,r=At(n),o=r.length,i=0;o>i;)T.f(t,e=r[i++],n[e]);return t},an=h.document,sn=an&&an.documentElement,ln=Ot(\"IE_PROTO\"),pn=function(){},hn=\"prototype\",yn=function(){var t,n=_(\"iframe\"),e=Tt.length;for(n.style.display=\"none\",sn.appendChild(n),n.src=\"javascript:\",(t=n.contentWindow.document).open(),t.write(\"<script>document.F=Object<\\\/script>\"),t.close(),yn=t.F;e--;)delete yn[hn][Tt[e]];return yn()},vn=Object.create||function(t,n){var e;return null!==t?(pn[hn]=g(t),e=new pn,pn[hn]=null,e[ln]=t):e=yn(),void 0===n?e:fn(e,n)},dn=Tt.concat(\"length\",\"prototype\"),gn=Object.getOwnPropertyNames||function(t){return Et(t,dn)},mn={f:gn},bn=mn.f,Sn={}.toString,wn=\"object\"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],_n=function(t){try{return bn(t)}catch(t){return wn.slice()}},On=function(t){return wn&&\"[object Window]\"==Sn.call(t)?_n(t):bn(gt(t))},jn={f:On},Pn=Object.getOwnPropertyDescriptor,En=b?Pn:function(t,n){if(t=gt(t),n=j(n,!0),O)try{return Pn(t,n)}catch(t){}if(M(t,n))return A(!kt.f.call(t,n),t[n])},Tn={f:En},An=Ut.KEY,Fn=Tn.f,Ln=T.f,Mn=jn.f,kn=h.Symbol,xn=h.JSON,In=xn&&xn.stringify,Nn=\"prototype\",Cn=nt(\"_hidden\"),Rn=nt(\"toPrimitive\"),Dn={}.propertyIsEnumerable,Gn=tt(\"symbol-registry\"),Wn=tt(\"symbols\"),Vn=tt(\"op-symbols\"),zn=Object[Nn],Kn=\"function\"==typeof kn,Hn=h.QObject,Jn=!Hn||!Hn[Nn]||!Hn[Nn].findChild,Un=b&&m(function(){return 7!=vn(Ln({},\"a\",{get:function(){return Ln(this,\"a\",{value:7}).a}})).a})?function(t,n,e){var r=Fn(zn,n);r&&delete zn[n],Ln(t,n,e),r&&t!==zn&&Ln(zn,n,r)}:Ln,qn=function(t){var n=Wn[t]=vn(kn[Nn]);return n._k=t,n},Bn=Kn&&\"symbol\"==typeof kn.iterator?function(t){return\"symbol\"==typeof t}:function(t){return t instanceof kn},Yn=function(t,n,e){return t===zn&&Yn(Vn,n,e),g(t),n=j(n,!0),g(e),M(Wn,n)?(e.enumerable?(M(t,Cn)&&t[Cn][n]&&(t[Cn][n]=!1),e=vn(e,{enumerable:A(0,!1)})):(M(t,Cn)||Ln(t,Cn,A(1,{})),t[Cn][n]=!0),Un(t,n,e)):Ln(t,n,e)},Qn=function(t,n){g(t);for(var e,r=cn(n=gt(n)),o=0,i=r.length;i>o;)Yn(t,e=r[o++],n[e]);return t},Xn=function(t,n){return void 0===n?vn(t):Qn(vn(t),n)},Zn=function(t){var n=Dn.call(this,t=j(t,!0));return!(this===zn&&M(Wn,t)&&!M(Vn,t))&&(!(n||!M(this,t)||!M(Wn,t)||M(this,Cn)&&this[Cn][t])||n)},$n=function(t,n){if(t=gt(t),n=j(n,!0),t!==zn||!M(Wn,n)||M(Vn,n)){var e=Fn(t,n);return!e||!M(Wn,n)||M(t,Cn)&&t[Cn][n]||(e.enumerable=!0),e}},te=function(t){for(var n,e=Mn(gt(t)),r=[],o=0;e.length>o;)M(Wn,n=e[o++])||n==Cn||n==An||r.push(n);return r},ne=function(t){for(var n,e=t===zn,r=Mn(e?Vn:gt(t)),o=[],i=0;r.length>i;)!M(Wn,n=r[i++])||e&&!M(zn,n)||o.push(Wn[n]);return o};Kn||(N((kn=function(){if(this instanceof kn)throw TypeError(\"Symbol is not a constructor!\");var t=I(arguments.length>0?arguments[0]:void 0),n=function(e){this===zn&&n.call(Vn,e),M(this,Cn)&&M(this[Cn],t)&&(this[Cn][t]=!1),Un(this,t,A(1,e))};return b&&Jn&&Un(zn,t,{configurable:!0,set:n}),qn(t)})[Nn],\"toString\",function(){return this._k}),Tn.f=$n,T.f=Yn,mn.f=jn.f=te,kt.f=Zn,Lt.f=ne,b&&!rn&&N(zn,\"propertyIsEnumerable\",Zn,!0),en.f=function(t){return qn(nt(t))}),W(W.G+W.W+W.F*!Kn,{Symbol:kn});for(var ee=\"hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables\".split(\",\"),re=0;ee.length>re;)nt(ee[re++]);for(var oe=At(nt.store),ie=0;oe.length>ie;)un(oe[ie++]);W(W.S+W.F*!Kn,\"Symbol\",{for:function(t){return M(Gn,t+=\"\")?Gn[t]:Gn[t]=kn(t)},keyFor:function(t){if(!Bn(t))throw TypeError(t+\" is not a symbol!\");for(var n in Gn)if(Gn[n]===t)return n},useSetter:function(){Jn=!0},useSimple:function(){Jn=!1}}),W(W.S+W.F*!Kn,\"Object\",{create:Xn,defineProperty:Yn,defineProperties:Qn,getOwnPropertyDescriptor:$n,getOwnPropertyNames:te,getOwnPropertySymbols:ne}),xn&&W(W.S+W.F*(!Kn||m(function(){var t=kn();return\"[null]\"!=In([t])||\"{}\"!=In({a:t})||\"{}\"!=In(Object(t))})),\"JSON\",{stringify:function(t){for(var n,e,r=[t],o=1;arguments.length>o;)r.push(arguments[o++]);if(e=n=r[1],(d(n)||void 0!==t)&&!Bn(t))return X(n)||(n=function(t,n){if(\"function\"==typeof e&&(n=e.call(this,t,n)),!Bn(n))return n}),r[1]=n,In.apply(xn,r)}}),kn[Nn][Rn]||F(kn[Nn],Rn,kn[Nn].valueOf),tn(kn,\"Symbol\"),tn(Math,\"Math\",!0),tn(h.JSON,\"JSON\",!0);var ue=nt(\"toStringTag\"),ce=\"Arguments\"==z(function(){return arguments}()),fe=function(t,n){try{return t[n]}catch(t){}},ae=function(t){var n,e,r;return void 0===t?\"Undefined\":null===t?\"Null\":\"string\"==typeof(e=fe(n=Object(t),ue))?e:ce?z(n):\"Object\"==(r=z(n))&&\"function\"==typeof n.callee?\"Arguments\":r},se={};se[nt(\"toStringTag\")]=\"z\",se+\"\"!=\"[object z]\"&&N(Object.prototype,\"toString\",function(){return\"[object \"+ae(this)+\"]\"},!0),un(\"asyncIterator\"),un(\"observable\");var le=y.Symbol,pe=function(t){return function(n,e){var r,o,i=String(H(n)),u=B(e),c=i.length;return u<0||u>=c?t?\"\":void 0:(r=i.charCodeAt(u))<55296||r>56319||u+1===c||(o=i.charCodeAt(u+1))<56320||o>57343?t?i.charAt(u):r:t?i.slice(u,u+2):o-56320+(r-55296<<10)+65536}},he={},ye={};F(ye,nt(\"iterator\"),function(){return this});var ve=function(t,n,e){t.prototype=vn(ye,{next:A(1,e)}),tn(t,n+\" Iterator\")},de=Ot(\"IE_PROTO\"),ge=Object.prototype,me=Object.getPrototypeOf||function(t){return t=J(t),M(t,de)?t[de]:\"function\"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?ge:null},be=nt(\"iterator\"),Se=!([].keys&&\"next\"in[].keys()),we=\"@@iterator\",_e=\"keys\",Oe=\"values\",je=function(){return this},Pe=function(t,n,e,r,o,i,u){ve(e,n,r);var c,f,a,s=function(t){if(!Se&&t in y)return y[t];switch(t){case _e:case Oe:return function(){return new e(this,t)}}return function(){return new e(this,t)}},l=n+\" Iterator\",p=o==Oe,h=!1,y=t.prototype,v=y[be]||y[we]||o&&y[o],d=v||s(o),g=o?p?s(\"entries\"):d:void 0,m=\"Array\"==n&&y.entries||v;if(m&&(a=me(m.call(new t)))!==Object.prototype&&a.next&&(tn(a,l,!0),rn||\"function\"==typeof a[be]||F(a,be,je)),p&&v&&v.name!==Oe&&(h=!0,d=function(){return v.call(this)}),rn&&!u||!Se&&!h&&y[be]||F(y,be,d),he[n]=d,he[l]=je,o)if(c={values:p?d:s(Oe),keys:i?d:s(_e),entries:g},u)for(f in c)f in y||N(y,f,c[f]);else W(W.P+W.F*(Se||h),n,c);return c},Ee=pe(!0);Pe(String,\"String\",function(t){this._t=String(t),this._i=0},function(){var t,n=this._t,e=this._i;return e>=n.length?{value:void 0,done:!0}:(t=Ee(n,e),this._i+=t.length,{value:t,done:!1})});var Te=function(t,n){return{value:n,done:!!t}},Ae=Pe(Array,\"Array\",function(t,n){this._t=gt(t),this._i=0,this._k=n},function(){var t=this._t,n=this._k,e=this._i++;return!t||e>=t.length?(this._t=void 0,Te(1)):Te(0,\"keys\"==n?e:\"values\"==n?t[e]:[e,t[e]])},\"values\");he.Arguments=he.Array,ft(\"keys\"),ft(\"values\"),ft(\"entries\");for(var Fe=nt(\"iterator\"),Le=nt(\"toStringTag\"),Me=he.Array,ke={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},xe=At(ke),Ie=0;Ie<xe.length;Ie++){var Ne,Ce=xe[Ie],Re=ke[Ce],De=h[Ce],Ge=De&&De.prototype;if(Ge&&(Ge[Fe]||F(Ge,Fe,Me),Ge[Le]||F(Ge,Le,Ce),he[Ce]=Me,Re))for(Ne in Ae)Ge[Ne]||N(Ge,Ne,Ae[Ne],!0)}var We=en.f(\"iterator\");\r\n},{\"whatwg-fetch\":20}],22:[function(require,module,exports) {\r\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.__extends=e,exports.__rest=n,exports.__decorate=o,exports.__param=a,exports.__metadata=c,exports.__awaiter=i,exports.__generator=u,exports.__exportStar=f,exports.__values=l,exports.__read=s,exports.__spread=p,exports.__await=y,exports.__asyncGenerator=_,exports.__asyncDelegator=h,exports.__asyncValues=b,exports.__makeTemplateObject=v,exports.__importStar=d,exports.__importDefault=w;var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};function e(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var r=exports.__assign=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t};function n(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&\"function\"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r}function o(t,e,r,n){var o,a=arguments.length,c=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if(\"object\"==typeof Reflect&&\"function\"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,n);else for(var i=t.length-1;i>=0;i--)(o=t[i])&&(c=(a<3?o(c):a>3?o(e,r,c):o(e,r))||c);return a>3&&c&&Object.defineProperty(e,r,c),c}function a(t,e){return function(r,n){e(r,n,t)}}function c(t,e){if(\"object\"==typeof Reflect&&\"function\"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function i(t,e,r,n){return new(r||(r=Promise))(function(o,a){function c(t){try{u(n.next(t))}catch(t){a(t)}}function i(t){try{u(n.throw(t))}catch(t){a(t)}}function u(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(c,i)}u((n=n.apply(t,e||[])).next())})}function u(t,e){var r,n,o,a,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:i(0),throw:i(1),return:i(2)},\"function\"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(a){return function(i){return function(a){if(r)throw new TypeError(\"Generator is already executing.\");for(;c;)try{if(r=1,n&&(o=n[2&a[0]?\"return\":a[0]?\"throw\":\"next\"])&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[0,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,n=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=e.call(t,c)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,i])}}}function f(t,e){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}function l(t){var e=\"function\"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}function s(t,e){var r=\"function\"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),c=[];try{for(;(void 0===e||e-- >0)&&!(n=a.next()).done;)c.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return c}function p(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(s(arguments[e]));return t}function y(t){return this instanceof y?(this.v=t,this):new y(t)}function _(t,e,r){if(!Symbol.asyncIterator)throw new TypeError(\"Symbol.asyncIterator is not defined.\");var n,o=r.apply(t,e||[]),a=[];return n={},c(\"next\"),c(\"throw\"),c(\"return\"),n[Symbol.asyncIterator]=function(){return this},n;function c(t){o[t]&&(n[t]=function(e){return new Promise(function(r,n){a.push([t,e,r,n])>1||i(t,e)})})}function i(t,e){try{(r=o[t](e)).value instanceof y?Promise.resolve(r.value.v).then(u,f):l(a[0][2],r)}catch(t){l(a[0][3],t)}var r}function u(t){i(\"next\",t)}function f(t){i(\"throw\",t)}function l(t,e){t(e),a.shift(),a.length&&i(a[0][0],a[0][1])}}function h(t){var e,r;return e={},n(\"next\"),n(\"throw\",function(t){throw t}),n(\"return\"),e[Symbol.iterator]=function(){return this},e;function n(n,o){t[n]&&(e[n]=function(e){return(r=!r)?{value:y(t[n](e)),done:\"return\"===n}:o?o(e):e})}}function b(t){if(!Symbol.asyncIterator)throw new TypeError(\"Symbol.asyncIterator is not defined.\");var e=t[Symbol.asyncIterator];return e?e.call(t):\"function\"==typeof l?l(t):t[Symbol.iterator]()}function v(t,e){return Object.defineProperty?Object.defineProperty(t,\"raw\",{value:e}):t.raw=e,t}function d(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function w(t){return t&&t.__esModule?t:{default:t}}\r\n},{}],24:[function(require,module,exports) {\r\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0});var t=require(\"tslib\"),r={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:\"${JSCORE_VERSION}\"},e=function(t,r){if(!t)throw o(r)},o=function(t){return new Error(\"Firebase Database (\"+r.SDK_VERSION+\") INTERNAL ASSERT FAILED: \"+t)},n=function(t){for(var r=[],e=0,o=0;o<t.length;o++){var n=t.charCodeAt(o);n<128?r[e++]=n:n<2048?(r[e++]=n>>6|192,r[e++]=63&n|128):55296==(64512&n)&&o+1<t.length&&56320==(64512&t.charCodeAt(o+1))?(n=65536+((1023&n)<<10)+(1023&t.charCodeAt(++o)),r[e++]=n>>18|240,r[e++]=n>>12&63|128,r[e++]=n>>6&63|128,r[e++]=63&n|128):(r[e++]=n>>12|224,r[e++]=n>>6&63|128,r[e++]=63&n|128)}return r},i=function(t){for(var r=[],e=0,o=0;e<t.length;){var n=t[e++];if(n<128)r[o++]=String.fromCharCode(n);else if(n>191&&n<224){var i=t[e++];r[o++]=String.fromCharCode((31&n)<<6|63&i)}else if(n>239&&n<365){var a=((7&n)<<18|(63&(i=t[e++]))<<12|(63&(s=t[e++]))<<6|63&t[e++])-65536;r[o++]=String.fromCharCode(55296+(a>>10)),r[o++]=String.fromCharCode(56320+(1023&a))}else{i=t[e++];var s=t[e++];r[o++]=String.fromCharCode((15&n)<<12|(63&i)<<6|63&s)}}return r.join(\"\")},a={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+\"+\/=\"},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+\"-_.\"},HAS_NATIVE_SUPPORT:\"function\"==typeof atob,encodeByteArray:function(t,r){if(!Array.isArray(t))throw Error(\"encodeByteArray takes an array as a parameter\");this.init_();for(var e=r?this.byteToCharMapWebSafe_:this.byteToCharMap_,o=[],n=0;n<t.length;n+=3){var i=t[n],a=n+1<t.length,s=a?t[n+1]:0,c=n+2<t.length,h=c?t[n+2]:0,u=i>>2,f=(3&i)<<4|s>>4,p=(15&s)<<2|h>>6,l=63&h;c||(l=64,a||(p=64)),o.push(e[u],e[f],e[p],e[l])}return o.join(\"\")},encodeString:function(t,r){return this.HAS_NATIVE_SUPPORT&&!r?btoa(t):this.encodeByteArray(n(t),r)},decodeString:function(t,r){return this.HAS_NATIVE_SUPPORT&&!r?atob(t):i(this.decodeStringToByteArray(t,r))},decodeStringToByteArray:function(t,r){this.init_();for(var e=r?this.charToByteMapWebSafe_:this.charToByteMap_,o=[],n=0;n<t.length;){var i=e[t.charAt(n++)],a=n<t.length?e[t.charAt(n)]:0,s=++n<t.length?e[t.charAt(n)]:64,c=++n<t.length?e[t.charAt(n)]:64;if(++n,null==i||null==a||null==s||null==c)throw Error();var h=i<<2|a>>4;if(o.push(h),64!=s){var u=a<<4&240|s>>2;if(o.push(u),64!=c){var f=s<<6&192|c;o.push(f)}}}return o},init_:function(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(var t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}},s=function(t){var r=n(t);return a.encodeByteArray(r,!0)},c=function(t){try{return a.decodeString(t,!0)}catch(t){console.error(\"base64Decode failed: \",t)}return null};function h(t){return u(void 0,t)}function u(t,r){if(!(r instanceof Object))return r;switch(r.constructor){case Date:return new Date(r.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return r}for(var e in r)r.hasOwnProperty(e)&&(t[e]=u(t[e],r[e]));return t}function f(t,r,e){t[r]=e}var p=function(){function t(){var t=this;this.promise=new Promise(function(r,e){t.resolve=r,t.reject=e})}return t.prototype.wrapCallback=function(t){var r=this;return function(e,o){e?r.reject(e):r.resolve(o),\"function\"==typeof t&&(r.promise.catch(function(){}),1===t.length?t(e):t(e,o))}},t}(),l=function(){return\"undefined\"!=typeof navigator&&\"string\"==typeof navigator.userAgent?navigator.userAgent:\"\"},v=function(){return\"undefined\"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&\/ios|iphone|ipod|ipad|android|blackberry|iemobile\/i.test(l())},d=function(){return\"object\"==typeof navigator&&\"ReactNative\"===navigator.product},b=function(){return!0===r.NODE_CLIENT||!0===r.NODE_ADMIN},y=\"FirebaseError\",_=Error.captureStackTrace;function E(t){var r=_;return _=t,r}var g=function(){return function(t,r){if(this.code=t,this.message=r,_)_(this,S.prototype.create);else try{throw Error.apply(this,arguments)}catch(t){this.name=y,Object.defineProperty(this,\"stack\",{get:function(){return t.stack}})}}}();g.prototype=Object.create(Error.prototype),g.prototype.constructor=g,g.prototype.name=y;var S=function(){function t(t,r,e){this.service=t,this.serviceName=r,this.errors=e,this.pattern=\/\\{\\$([^}]+)}\/g}return t.prototype.create=function(t,r){void 0===r&&(r={});var e,o=this.errors[t],n=this.service+\"\/\"+t;e=void 0===o?\"Error\":o.replace(this.pattern,function(t,e){var o=r[e];return void 0!==o?o.toString():\"<\"+e+\"?>\"}),e=this.serviceName+\": \"+e+\" (\"+n+\").\";var i=new g(n,e);for(var a in r)r.hasOwnProperty(a)&&\"_\"!==a.slice(-1)&&(i[a]=r[a]);return i},t}();function A(t){return JSON.parse(t)}function x(t){return JSON.stringify(t)}var C=function(t){var r={},e={},o={},n=\"\";try{var i=t.split(\".\");r=A(c(i[0])||\"\"),e=A(c(i[1])||\"\"),n=i[2],o=e.d||{},delete e.d}catch(t){}return{header:r,claims:e,data:o,signature:n}},m=function(t){var r,e,o=C(t).claims,n=Math.floor((new Date).getTime()\/1e3);return\"object\"==typeof o&&(o.hasOwnProperty(\"nbf\")?r=o.nbf:o.hasOwnProperty(\"iat\")&&(r=o.iat),e=o.hasOwnProperty(\"exp\")?o.exp:r+86400),n&&r&&e&&n>=r&&n<=e},O=function(t){var r=C(t).claims;return\"object\"==typeof r&&r.hasOwnProperty(\"iat\")?r.iat:null},w=function(t){var r=C(t).claims;return!!r&&\"object\"==typeof r&&r.hasOwnProperty(\"iat\")},N=function(t){var r=C(t).claims;return\"object\"==typeof r&&!0===r.admin},T=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},D=function(t,r){if(Object.prototype.hasOwnProperty.call(t,r))return t[r]},k=function(t,r){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&r(e,t[e])},M=function(t,r){return k(r,function(r,e){t[r]=e}),t},j=function(t){return M({},t)},P=function(t){return\"object\"==typeof t&&null!==t},B=function(t){for(var r in t)return!1;return!0},V=function(t){var r=0;for(var e in t)r++;return r},I=function(t,r,e){var o={};for(var n in t)o[n]=r.call(e,t[n],n,t);return o},L=function(t,r,e){for(var o in t)if(r.call(e,t[o],o,t))return o},W=function(t,r,e){var o=L(t,r,e);return o&&t[o]},R=function(t){for(var r in t)return r},z=function(t){var r=[],e=0;for(var o in t)r[e++]=t[o];return r},F=function(t,r){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&!r(e,t[e]))return!1;return!0},U=function(t){var r=[];return k(t,function(t,e){Array.isArray(e)?e.forEach(function(e){r.push(encodeURIComponent(t)+\"=\"+encodeURIComponent(e))}):r.push(encodeURIComponent(t)+\"=\"+encodeURIComponent(e))}),r.length?\"&\"+r.join(\"&\"):\"\"},K=function(t){var r={};return t.replace(\/^\\?\/,\"\").split(\"&\").forEach(function(t){if(t){var e=t.split(\"=\");r[e[0]]=e[1]}}),r},q=function(){return function(){this.blockSize=-1}}(),H=function(r){function e(){var t=r.call(this)||this;t.chain_=[],t.buf_=[],t.W_=[],t.pad_=[],t.inbuf_=0,t.total_=0,t.blockSize=64,t.pad_[0]=128;for(var e=1;e<t.blockSize;++e)t.pad_[e]=0;return t.reset(),t}return t.__extends(e,r),e.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},e.prototype.compress_=function(t,r){r||(r=0);var e=this.W_;if(\"string\"==typeof t)for(var o=0;o<16;o++)e[o]=t.charCodeAt(r)<<24|t.charCodeAt(r+1)<<16|t.charCodeAt(r+2)<<8|t.charCodeAt(r+3),r+=4;else for(o=0;o<16;o++)e[o]=t[r]<<24|t[r+1]<<16|t[r+2]<<8|t[r+3],r+=4;for(o=16;o<80;o++){var n=e[o-3]^e[o-8]^e[o-14]^e[o-16];e[o]=4294967295&(n<<1|n>>>31)}var i,a,s=this.chain_[0],c=this.chain_[1],h=this.chain_[2],u=this.chain_[3],f=this.chain_[4];for(o=0;o<80;o++){o<40?o<20?(i=u^c&(h^u),a=1518500249):(i=c^h^u,a=1859775393):o<60?(i=c&h|u&(c|h),a=2400959708):(i=c^h^u,a=3395469782);n=(s<<5|s>>>27)+i+f+a+e[o]&4294967295;f=u,u=h,h=4294967295&(c<<30|c>>>2),c=s,s=n}this.chain_[0]=this.chain_[0]+s&4294967295,this.chain_[1]=this.chain_[1]+c&4294967295,this.chain_[2]=this.chain_[2]+h&4294967295,this.chain_[3]=this.chain_[3]+u&4294967295,this.chain_[4]=this.chain_[4]+f&4294967295},e.prototype.update=function(t,r){if(null!=t){void 0===r&&(r=t.length);for(var e=r-this.blockSize,o=0,n=this.buf_,i=this.inbuf_;o<r;){if(0==i)for(;o<=e;)this.compress_(t,o),o+=this.blockSize;if(\"string\"==typeof t){for(;o<r;)if(n[i]=t.charCodeAt(o),++o,++i==this.blockSize){this.compress_(n),i=0;break}}else for(;o<r;)if(n[i]=t[o],++o,++i==this.blockSize){this.compress_(n),i=0;break}}this.inbuf_=i,this.total_+=r}},e.prototype.digest=function(){var t=[],r=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(var e=this.blockSize-1;e>=56;e--)this.buf_[e]=255&r,r\/=256;this.compress_(this.buf_);var o=0;for(e=0;e<5;e++)for(var n=24;n>=0;n-=8)t[o]=this.chain_[e]>>n&255,++o;return t},e}(q);function J(t,r){var e=new G(t,r);return e.subscribe.bind(e)}var G=function(){function t(t,r){var e=this;this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=r,this.task.then(function(){t(e)}).catch(function(t){e.error(t)})}return t.prototype.next=function(t){this.forEachObserver(function(r){r.next(t)})},t.prototype.error=function(t){this.forEachObserver(function(r){r.error(t)}),this.close(t)},t.prototype.complete=function(){this.forEachObserver(function(t){t.complete()}),this.close()},t.prototype.subscribe=function(t,r,e){var o,n=this;if(void 0===t&&void 0===r&&void 0===e)throw new Error(\"Missing Observer.\");void 0===(o=Q(t,[\"next\",\"error\",\"complete\"])?t:{next:t,error:r,complete:e}).next&&(o.next=X),void 0===o.error&&(o.error=X),void 0===o.complete&&(o.complete=X);var i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(function(){try{n.finalError?o.error(n.finalError):o.complete()}catch(t){}}),this.observers.push(o),i},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 r=0;r<this.observers.length;r++)this.sendOne(r,t)},t.prototype.sendOne=function(t,r){var e=this;this.task.then(function(){if(void 0!==e.observers&&void 0!==e.observers[t])try{r(e.observers[t])}catch(t){\"undefined\"!=typeof console&&console.error&&console.error(t)}})},t.prototype.close=function(t){var r=this;this.finalized||(this.finalized=!0,void 0!==t&&(this.finalError=t),this.task.then(function(){r.observers=void 0,r.onNoObservers=void 0}))},t}();function $(t,r){return function(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];Promise.resolve(!0).then(function(){t.apply(void 0,e)}).catch(function(t){r&&r(t)})}}function Q(t,r){if(\"object\"!=typeof t||null===t)return!1;for(var e=0,o=r;e<o.length;e++){var n=o[e];if(n in t&&\"function\"==typeof t[n])return!0}return!1}function X(){}var Y=function(t,r,e,o){var n;if(o<r?n=\"at least \"+r:o>e&&(n=0===e?\"none\":\"no more than \"+e),n)throw new Error(t+\" failed: Was called with \"+o+(1===o?\" argument.\":\" arguments.\")+\" Expects \"+n+\".\")};function Z(t,r,e){var o=\"\";switch(r){case 1:o=e?\"first\":\"First\";break;case 2:o=e?\"second\":\"Second\";break;case 3:o=e?\"third\":\"Third\";break;case 4:o=e?\"fourth\":\"Fourth\";break;default:throw new Error(\"errorPrefix called with argumentNumber > 4.  Need to update it?\")}var n=t+\" failed: \";return n+=o+\" argument \"}function tt(t,r,e,o){if((!o||e)&&\"string\"!=typeof e)throw new Error(Z(t,r,o)+\"must be a valid firebase namespace.\")}function rt(t,r,e,o){if((!o||e)&&\"function\"!=typeof e)throw new Error(Z(t,r,o)+\"must be a valid function.\")}function et(t,r,e,o){if((!o||e)&&(\"object\"!=typeof e||null===e))throw new Error(Z(t,r,o)+\"must be a valid context object.\")}var ot=function(t){for(var r=[],o=0,n=0;n<t.length;n++){var i=t.charCodeAt(n);if(i>=55296&&i<=56319){var a=i-55296;e(++n<t.length,\"Surrogate pair missing trail surrogate.\"),i=65536+(a<<10)+(t.charCodeAt(n)-56320)}i<128?r[o++]=i:i<2048?(r[o++]=i>>6|192,r[o++]=63&i|128):i<65536?(r[o++]=i>>12|224,r[o++]=i>>6&63|128,r[o++]=63&i|128):(r[o++]=i>>18|240,r[o++]=i>>12&63|128,r[o++]=i>>6&63|128,r[o++]=63&i|128)}return r},nt=function(t){for(var r=0,e=0;e<t.length;e++){var o=t.charCodeAt(e);o<128?r++:o<2048?r+=2:o>=55296&&o<=56319?(r+=4,e++):r+=3}return r};exports.assert=e,exports.assertionError=o,exports.base64=a,exports.base64Decode=c,exports.base64Encode=s,exports.CONSTANTS=r,exports.deepCopy=h,exports.deepExtend=u,exports.patchProperty=f,exports.Deferred=p,exports.getUA=l,exports.isMobileCordova=v,exports.isNodeSdk=b,exports.isReactNative=d,exports.ErrorFactory=S,exports.FirebaseError=g,exports.patchCapture=E,exports.jsonEval=A,exports.stringify=x,exports.decode=C,exports.isAdmin=N,exports.issuedAtTime=O,exports.isValidFormat=w,exports.isValidTimestamp=m,exports.clone=j,exports.contains=T,exports.every=F,exports.extend=M,exports.findKey=L,exports.findValue=W,exports.forEach=k,exports.getAnyKey=R,exports.getCount=V,exports.getValues=z,exports.isEmpty=B,exports.isNonNullObject=P,exports.map=I,exports.safeGet=D,exports.querystring=U,exports.querystringDecode=K,exports.Sha1=H,exports.async=$,exports.createSubscribe=J,exports.errorPrefix=Z,exports.validateArgCount=Y,exports.validateCallback=rt,exports.validateContextObject=et,exports.validateNamespace=tt,exports.stringLength=nt,exports.stringToByteArray=ot;\r\n},{\"tslib\":22}],19:[function(require,module,exports) {\r\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0});var e=require(\"@firebase\/util\"),t=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n=\"[DEFAULT]\",i=[],r=function(){function t(t,n,r){this.firebase_=r,this.isDeleted_=!1,this.services_={},this.name_=n.name,this._automaticDataCollectionEnabled=n.automaticDataCollectionEnabled||!1,this.options_=e.deepCopy(t),this.INTERNAL={getUid:function(){return null},getToken:function(){return Promise.resolve(null)},addAuthTokenListener:function(e){i.push(e),setTimeout(function(){return e(null)},0)},removeAuthTokenListener:function(e){i=i.filter(function(t){return t!==e})}}}return Object.defineProperty(t.prototype,\"automaticDataCollectionEnabled\",{get:function(){return this.checkDestroyed_(),this._automaticDataCollectionEnabled},set:function(e){this.checkDestroyed_(),this._automaticDataCollectionEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,\"name\",{get:function(){return this.checkDestroyed_(),this.name_},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,\"options\",{get:function(){return this.checkDestroyed_(),this.options_},enumerable:!0,configurable:!0}),t.prototype.delete=function(){var e=this;return new Promise(function(t){e.checkDestroyed_(),t()}).then(function(){e.firebase_.INTERNAL.removeApp(e.name_);var t=[];return Object.keys(e.services_).forEach(function(n){Object.keys(e.services_[n]).forEach(function(i){t.push(e.services_[n][i])})}),Promise.all(t.map(function(e){return e.INTERNAL.delete()}))}).then(function(){e.isDeleted_=!0,e.services_={}})},t.prototype._getService=function(e,t){if(void 0===t&&(t=n),this.checkDestroyed_(),this.services_[e]||(this.services_[e]={}),!this.services_[e][t]){var i=t!==n?t:void 0,r=this.firebase_.INTERNAL.factories[e](this,this.extendApp.bind(this),i);this.services_[e][t]=r}return this.services_[e][t]},t.prototype.extendApp=function(t){var n=this;e.deepExtend(this,t),t.INTERNAL&&t.INTERNAL.addAuthTokenListener&&(i.forEach(function(e){n.INTERNAL.addAuthTokenListener(e)}),i=[])},t.prototype.checkDestroyed_=function(){this.isDeleted_&&o(\"app-deleted\",{name:this.name_})},t}();function a(){var i={},s={},c={},p={__esModule:!0,initializeApp:function(e,a){void 0===a&&(a={});if(\"object\"!=typeof a||null===a){var s=a;a={name:s}}var c=a;void 0===c.name&&(c.name=n);var u=c.name;\"string\"==typeof u&&u||o(\"bad-app-name\",{name:u+\"\"});t(i,u)&&o(\"duplicate-app\",{name:u});var d=new r(e,c,p);return i[u]=d,l(d,\"create\"),d},app:u,apps:null,Promise:Promise,SDK_VERSION:\"5.5.0\",INTERNAL:{registerService:function(t,n,i,a,l){s[t]&&o(\"duplicate-service\",{name:t});s[t]=n,a&&(c[t]=a,d().forEach(function(e){a(\"create\",e)}));var f=function(e){return void 0===e&&(e=u()),\"function\"!=typeof e[t]&&o(\"invalid-app-argument\",{name:t}),e[t]()};void 0!==i&&e.deepExtend(f,i);return p[t]=f,r.prototype[t]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return this._getService.bind(this,t).apply(this,l?e:[])},f},createFirebaseNamespace:a,extendNamespace:function(t){e.deepExtend(p,t)},createSubscribe:e.createSubscribe,ErrorFactory:e.ErrorFactory,removeApp:function(e){l(i[e],\"delete\"),delete i[e]},factories:s,useAsService:f,Promise:Promise,deepExtend:e.deepExtend}};function u(e){return t(i,e=e||n)||o(\"no-app\",{name:e}),i[e]}function d(){return Object.keys(i).map(function(e){return i[e]})}function l(e,t){Object.keys(s).forEach(function(n){var i=f(e,n);null!==i&&c[i]&&c[i](t,e)})}function f(e,t){if(\"serverAuth\"===t)return null;var n=t;e.options;return n}return e.patchProperty(p,\"default\",p),Object.defineProperty(p,\"apps\",{get:d}),e.patchProperty(u,\"App\",r),p}function o(e,t){throw c.create(e,t)}r.prototype.name&&r.prototype.options||r.prototype.delete||console.log(\"dc\");var s={\"no-app\":\"No Firebase App '{$name}' has been created - call Firebase App.initializeApp()\",\"bad-app-name\":\"Illegal App name: '{$name}\",\"duplicate-app\":\"Firebase App named '{$name}' already exists\",\"app-deleted\":\"Firebase App named '{$name}' already deleted\",\"duplicate-service\":\"Firebase service named '{$name}' already registered\",\"sa-not-supported\":\"Initializing the Firebase SDK with a service account is only allowed in a Node.js environment. On client devices, you should instead initialize the SDK with an api key and auth domain\",\"invalid-app-argument\":\"firebase.{$name}() takes either no argument or a Firebase App instance.\"},c=new e.ErrorFactory(\"app\",\"Firebase\",s),p=a();exports.firebase=p,exports.default=p;\r\n},{\"@firebase\/util\":24}],16:[function(require,module,exports) {\r\n\"use strict\";function e(e){return e&&\"object\"==typeof e&&\"default\"in e?e.default:e}require(\"@firebase\/polyfill\");var r=e(require(\"@firebase\/app\"));module.exports=r;\r\n},{\"@firebase\/polyfill\":18,\"@firebase\/app\":19}],23:[function(require,module,exports) {\r\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0});var e,o=[];!function(e){e[e.DEBUG=0]=\"DEBUG\",e[e.VERBOSE=1]=\"VERBOSE\",e[e.INFO=2]=\"INFO\",e[e.WARN=3]=\"WARN\",e[e.ERROR=4]=\"ERROR\",e[e.SILENT=5]=\"SILENT\"}(e||(exports.LogLevel=e={}));var t=e.INFO,n=function(o,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(!(t<o.logLevel)){var l=(new Date).toISOString();switch(t){case e.DEBUG:case e.VERBOSE:console.log.apply(console,[\"[\"+l+\"]  \"+o.name+\":\"].concat(n));break;case e.INFO:console.info.apply(console,[\"[\"+l+\"]  \"+o.name+\":\"].concat(n));break;case e.WARN:console.warn.apply(console,[\"[\"+l+\"]  \"+o.name+\":\"].concat(n));break;case e.ERROR:console.error.apply(console,[\"[\"+l+\"]  \"+o.name+\":\"].concat(n));break;default:throw new Error(\"Attempted to log a message with an invalid logType (value: \"+t+\")\")}}},r=function(){function r(e){this.name=e,this._logLevel=t,this._logHandler=n,o.push(this)}return Object.defineProperty(r.prototype,\"logLevel\",{get:function(){return this._logLevel},set:function(o){if(!(o in e))throw new TypeError(\"Invalid value assigned to `logLevel`\");this._logLevel=o},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,\"logHandler\",{get:function(){return this._logHandler},set:function(e){if(\"function\"!=typeof e)throw new TypeError(\"Value assigned to `logHandler` must be a function\");this._logHandler=e},enumerable:!0,configurable:!0}),r.prototype.debug=function(){for(var o=[],t=0;t<arguments.length;t++)o[t]=arguments[t];this._logHandler.apply(this,[this,e.DEBUG].concat(o))},r.prototype.log=function(){for(var o=[],t=0;t<arguments.length;t++)o[t]=arguments[t];this._logHandler.apply(this,[this,e.VERBOSE].concat(o))},r.prototype.info=function(){for(var o=[],t=0;t<arguments.length;t++)o[t]=arguments[t];this._logHandler.apply(this,[this,e.INFO].concat(o))},r.prototype.warn=function(){for(var o=[],t=0;t<arguments.length;t++)o[t]=arguments[t];this._logHandler.apply(this,[this,e.WARN].concat(o))},r.prototype.error=function(){for(var o=[],t=0;t<arguments.length;t++)o[t]=arguments[t];this._logHandler.apply(this,[this,e.ERROR].concat(o))},r}();function l(e){o.forEach(function(o){o.logLevel=e})}exports.setLogLevel=l,exports.Logger=r,exports.LogLevel=e;\r\n},{}],21:[function(require,module,exports) {\r\nvar global = (1,eval)(\"this\");\r\nvar t=(0,eval)(\"this\");Object.defineProperty(exports,\"__esModule\",{value:!0});var i,n=\"undefined\"!=typeof window?window:void 0!==t?t:\"undefined\"!=typeof self?self:{},e=e||{},s=n;function h(t){return\"string\"==typeof t}function r(t,i){t=t.split(\".\"),i=i||s;for(var n=0;n<t.length;n++)if(null==(i=i[t[n]]))return null;return i}function o(){}function a(t){var i=typeof t;if(\"object\"==i){if(!t)return\"null\";if(t instanceof Array)return\"array\";if(t instanceof Object)return i;var n=Object.prototype.toString.call(t);if(\"[object Window]\"==n)return\"object\";if(\"[object Array]\"==n||\"number\"==typeof t.length&&void 0!==t.splice&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable(\"splice\"))return\"array\";if(\"[object Function]\"==n||void 0!==t.call&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable(\"call\"))return\"function\"}else if(\"function\"==i&&void 0===t.call)return\"object\";return i}function c(t){return\"array\"==a(t)}function u(t){var i=a(t);return\"array\"==i||\"object\"==i&&\"number\"==typeof t.length}function f(t){return\"function\"==a(t)}function l(t){var i=typeof t;return\"object\"==i&&null!=t||\"function\"==i}var d=\"closure_uid_\"+(1e9*Math.random()>>>0),p=0;function g(t,i,n){return t.call.apply(t.bind,arguments)}function b(t,i,n){if(!t)throw Error();if(2<arguments.length){var e=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,e),t.apply(i,n)}}return function(){return t.apply(i,arguments)}}function v(t,i,n){return(v=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf(\"native code\")?g:b).apply(null,arguments)}function y(t,i){var n=Array.prototype.slice.call(arguments,1);return function(){var i=n.slice();return i.push.apply(i,arguments),t.apply(this,i)}}var m=Date.now||function(){return+new Date};function w(t,i){function n(){}n.prototype=i.prototype,t.L=i.prototype,t.prototype=new n,t.prototype.constructor=t,t.mh=function(t,n,e){for(var s=Array(arguments.length-2),h=2;h<arguments.length;h++)s[h-2]=arguments[h];return i.prototype[n].apply(t,s)}}function T(t){if(Error.captureStackTrace)Error.captureStackTrace(this,T);else{var i=Error().stack;i&&(this.stack=i)}t&&(this.message=String(t))}function E(t,i){for(var n=\"\",e=(t=t.split(\"%s\")).length-1,s=0;s<e;s++)n+=t[s]+(s<i.length?i[s]:\"%s\");T.call(this,n+t[e])}function C(t,i){throw new E(\"Failure\"+(t?\": \"+t:\"\"),Array.prototype.slice.call(arguments,1))}function S(){0!=I&&(P[this[d]||(this[d]=++p)]=this),this.Ka=this.Ka,this.Qa=this.Qa}w(T,Error),T.prototype.name=\"CustomError\",w(E,T),E.prototype.name=\"AssertionError\";var I=0,P={};S.prototype.Ka=!1,S.prototype.bb=function(){if(!this.Ka&&(this.Ka=!0,this.F(),0!=I)){var t=this[d]||(this[d]=++p);if(0!=I&&this.Qa&&0<this.Qa.length)throw Error(this+\" did not empty its onDisposeCallbacks queue. This probably means it overrode dispose() or disposeInternal() without calling the superclass' method.\");delete P[t]}},S.prototype.F=function(){if(this.Qa)for(;this.Qa.length;)this.Qa.shift()()};var O=Array.prototype.indexOf?function(t,i){return Array.prototype.indexOf.call(t,i,void 0)}:function(t,i){if(h(t))return h(i)&&1==i.length?t.indexOf(i,0):-1;for(var n=0;n<t.length;n++)if(n in t&&t[n]===i)return n;return-1},x=Array.prototype.lastIndexOf?function(t,i){return Array.prototype.lastIndexOf.call(t,i,t.length-1)}:function(t,i){var n=t.length-1;if(0>n&&(n=Math.max(0,t.length+n)),h(t))return h(i)&&1==i.length?t.lastIndexOf(i,n):-1;for(;0<=n;n--)if(n in t&&t[n]===i)return n;return-1},M=Array.prototype.forEach?function(t,i,n){Array.prototype.forEach.call(t,i,n)}:function(t,i,n){for(var e=t.length,s=h(t)?t.split(\"\"):t,r=0;r<e;r++)r in s&&i.call(n,s[r],r,t)},R=Array.prototype.some?function(t,i){return Array.prototype.some.call(t,i,void 0)}:function(t,i){for(var n=t.length,e=h(t)?t.split(\"\"):t,s=0;s<n;s++)if(s in e&&i.call(void 0,e[s],s,t))return!0;return!1};function X(t){t:{for(var i=In,n=t.length,e=h(t)?t.split(\"\"):t,s=0;s<n;s++)if(s in e&&i.call(void 0,e[s],s,t)){i=s;break t}i=-1}return 0>i?null:h(t)?t.charAt(i):t[i]}function k(t){if(!c(t))for(var i=t.length-1;0<=i;i--)delete t[i];t.length=0}function L(t,i){var n;return(n=0<=(i=O(t,i)))&&Array.prototype.splice.call(t,i,1),n}function A(t){return Array.prototype.concat.apply([],arguments)}function H(t){var i=t.length;if(0<i){for(var n=Array(i),e=0;e<i;e++)n[e]=t[e];return n}return[]}function j(t){return\/^[\\s\\xa0]*$\/.test(t)}var D,N=String.prototype.trim?function(t){return t.trim()}:function(t){return\/^[\\s\\xa0]*([\\s\\S]*?)[\\s\\xa0]*$\/.exec(t)[1]};function F(t,i){return t<i?-1:t>i?1:0}t:{var U=s.navigator;if(U){var q=U.userAgent;if(q){D=q;break t}}D=\"\"}function K(t){return-1!=D.indexOf(t)}function W(t,i,n){for(var e in t)i.call(n,t[e],e,t)}function B(t){var i,n=[],e=0;for(i in t)n[e++]=t[i];return n}function G(t){var i,n=[],e=0;for(i in t)n[e++]=i;return n}function Y(t){var i,n={};for(i in t)n[i]=t[i];return n}var J=\"constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf\".split(\" \");function _(t,i){for(var n,e,s=1;s<arguments.length;s++){for(n in e=arguments[s])t[n]=e[n];for(var h=0;h<J.length;h++)n=J[h],Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}}function V(t){return V[\" \"](t),t}function $(t,i){var n=ct;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=i(t)}V[\" \"]=o;var Z,z=K(\"Opera\"),Q=K(\"Trident\")||K(\"MSIE\"),tt=K(\"Edge\"),it=tt||Q,nt=K(\"Gecko\")&&!(-1!=D.toLowerCase().indexOf(\"webkit\")&&!K(\"Edge\"))&&!(K(\"Trident\")||K(\"MSIE\"))&&!K(\"Edge\"),et=-1!=D.toLowerCase().indexOf(\"webkit\")&&!K(\"Edge\");function st(){var t=s.document;return t?t.documentMode:void 0}t:{var ht=\"\",rt=function(){var t=D;return nt?\/rv:([^\\);]+)(\\)|;)\/.exec(t):tt?\/Edge\\\/([\\d\\.]+)\/.exec(t):Q?\/\\b(?:MSIE|rv)[: ]([^\\);]+)(\\)|;)\/.exec(t):et?\/WebKit\\\/(\\S+)\/.exec(t):z?\/(?:Version)[ \\\/]?(\\S+)\/.exec(t):void 0}();if(rt&&(ht=rt?rt[1]:\"\"),Q){var ot=st();if(null!=ot&&ot>parseFloat(ht)){Z=String(ot);break t}}Z=ht}var at,ct={};function ut(t){return $(t,function(){for(var i=0,n=N(String(Z)).split(\".\"),e=N(String(t)).split(\".\"),s=Math.max(n.length,e.length),h=0;0==i&&h<s;h++){var r=n[h]||\"\",o=e[h]||\"\";do{if(r=\/(\\d*)(\\D*)(.*)\/.exec(r)||[\"\",\"\",\"\",\"\"],o=\/(\\d*)(\\D*)(.*)\/.exec(o)||[\"\",\"\",\"\",\"\"],0==r[0].length&&0==o[0].length)break;i=F(0==r[1].length?0:parseInt(r[1],10),0==o[1].length?0:parseInt(o[1],10))||F(0==r[2].length,0==o[2].length)||F(r[2],o[2]),r=r[3],o=o[3]}while(0==i)}return 0<=i})}var ft=s.document;at=ft&&Q?st()||(\"CSS1Compat\"==ft.compatMode?parseInt(Z,10):5):void 0;var lt=Object.freeze||function(t){return t},dt=!Q||9<=Number(at),pt=Q&&!ut(\"9\"),gt=function(){if(!s.addEventListener||!Object.defineProperty)return!1;var t=!1,i=Object.defineProperty({},\"passive\",{get:function(){t=!0}});try{s.addEventListener(\"test\",o,i),s.removeEventListener(\"test\",o,i)}catch(t){}return t}();function bt(t,i){this.type=t,this.currentTarget=this.target=i,this.defaultPrevented=this.Ea=!1,this.Be=!0}function vt(t,i){bt.call(this,t?t.type:\"\"),this.relatedTarget=this.currentTarget=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=this.offsetY=this.offsetX=0,this.key=\"\",this.charCode=this.keyCode=0,this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType=\"\",this.fb=null,t&&this.Kf(t,i)}bt.prototype.stopPropagation=function(){this.Ea=!0},bt.prototype.preventDefault=function(){this.defaultPrevented=!0,this.Be=!1},w(vt,bt);var yt=lt({2:\"touch\",3:\"pen\",4:\"mouse\"});vt.prototype.Kf=function(t,i){var n=this.type=t.type,e=t.changedTouches?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.currentTarget=i,i=t.relatedTarget){if(nt){t:{try{V(i.nodeName);var s=!0;break t}catch(t){}s=!1}s||(i=null)}}else\"mouseover\"==n?i=t.fromElement:\"mouseout\"==n&&(i=t.toElement);this.relatedTarget=i,null===e?(this.offsetX=et||void 0!==t.offsetX?t.offsetX:t.layerX,this.offsetY=et||void 0!==t.offsetY?t.offsetY:t.layerY,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.clientX=void 0!==e.clientX?e.clientX:e.pageX,this.clientY=void 0!==e.clientY?e.clientY:e.pageY,this.screenX=e.screenX||0,this.screenY=e.screenY||0),this.button=t.button,this.keyCode=t.keyCode||0,this.key=t.key||\"\",this.charCode=t.charCode||(\"keypress\"==n?t.keyCode:0),this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType=h(t.pointerType)?t.pointerType:yt[t.pointerType]||\"\",this.state=t.state,this.fb=t,t.defaultPrevented&&this.preventDefault()},vt.prototype.stopPropagation=function(){vt.L.stopPropagation.call(this),this.fb.stopPropagation?this.fb.stopPropagation():this.fb.cancelBubble=!0},vt.prototype.preventDefault=function(){vt.L.preventDefault.call(this);var t=this.fb;if(t.preventDefault)t.preventDefault();else if(t.returnValue=!1,pt)try{(t.ctrlKey||112<=t.keyCode&&123>=t.keyCode)&&(t.keyCode=-1)}catch(t){}};var mt=\"closure_listenable_\"+(1e6*Math.random()|0);function wt(t){return!(!t||!t[mt])}var Tt=0;function Et(t,i,n,e,s){this.listener=t,this.proxy=null,this.src=i,this.type=n,this.capture=!!e,this.Ob=s,this.key=++Tt,this.Sa=this.Eb=!1}function Ct(t){this.src=t,this.J={},this.xb=0}function St(t,i,n,e){for(var s=0;s<t.length;++s){var h=t[s];if(!h.Sa&&h.listener==i&&h.capture==!!n&&h.Ob==e)return s}return-1}Et.prototype.Vb=function(){this.Sa=!0,this.Ob=this.src=this.proxy=this.listener=null},(i=Ct.prototype).add=function(t,i,n,e,s){var h=t.toString();(t=this.J[h])||(t=this.J[h]=[],this.xb++);var r=St(t,i,e,s);return-1<r?(i=t[r],n||(i.Eb=!1)):((i=new Et(i,this.src,h,!!e,s)).Eb=n,t.push(i)),i},i.remove=function(t,i,n,e){if(!((t=t.toString())in this.J))return!1;var s=this.J[t];return-1<(i=St(s,i,n,e))&&(s[i].Vb(),Array.prototype.splice.call(s,i,1),0==s.length&&(delete this.J[t],this.xb--),!0)},i.ye=function(t){var i=t.type;i in this.J&&L(this.J[i],t)&&(t.Vb(),0==this.J[i].length&&(delete this.J[i],this.xb--))},i.pb=function(t){var i;for(i in t=t&&t.toString(),this.J)if(!t||i==t){for(var n=this.J[i],e=0;e<n.length;e++)n[e].Vb();delete this.J[i],this.xb--}},i.jb=function(t,i,n,e){var s=-1;return(t=this.J[t.toString()])&&(s=St(t,i,n,e)),-1<s?t[s]:null};var It=\"closure_lm_\"+(1e6*Math.random()|0),Pt={};function Ot(t,i,n,e,s){if(e&&e.once)return Rt(t,i,n,e,s);if(c(i)){for(var h=0;h<i.length;h++)Ot(t,i[h],n,e,s);return null}return n=Ft(n),wt(t)?t.nb(i,n,l(e)?!!e.capture:!!e,s):xt(t,i,n,!1,e,s)}function xt(t,i,n,e,s,h){if(!i)throw Error(\"Invalid event type\");var r=l(s)?!!s.capture:!!s,o=Dt(t);if(o||(t[It]=o=new Ct(t)),(n=o.add(i,n,e,r,h)).proxy)return n;if(e=Mt(),n.proxy=e,e.src=t,e.listener=n,t.addEventListener)gt||(s=r),void 0===s&&(s=!1),t.addEventListener(i.toString(),e,s);else if(t.attachEvent)t.attachEvent(Lt(i.toString()),e);else{if(!t.addListener||!t.removeListener)throw Error(\"addEventListener and attachEvent are unavailable.\");t.addListener(e)}return n}function Mt(){var t=jt,i=dt?function(n){return t.call(i.src,i.listener,n)}:function(n){if(!(n=t.call(i.src,i.listener,n)))return n};return i}function Rt(t,i,n,e,s){if(c(i)){for(var h=0;h<i.length;h++)Rt(t,i[h],n,e,s);return null}return n=Ft(n),wt(t)?t.Oc(i,n,l(e)?!!e.capture:!!e,s):xt(t,i,n,!0,e,s)}function Xt(t,i,n,e,s){if(c(i))for(var h=0;h<i.length;h++)Xt(t,i[h],n,e,s);else e=l(e)?!!e.capture:!!e,n=Ft(n),wt(t)?t.ed(i,n,e,s):t&&(t=Dt(t))&&(i=t.jb(i,n,e,s))&&kt(i)}function kt(t){if(\"number\"!=typeof t&&t&&!t.Sa){var i=t.src;if(wt(i))i.Le(t);else{var n=t.type,e=t.proxy;i.removeEventListener?i.removeEventListener(n,e,t.capture):i.detachEvent?i.detachEvent(Lt(n),e):i.addListener&&i.removeListener&&i.removeListener(e),(n=Dt(i))?(n.ye(t),0==n.xb&&(n.src=null,i[It]=null)):t.Vb()}}}function Lt(t){return t in Pt?Pt[t]:Pt[t]=\"on\"+t}function At(t,i,n,e){var s=!0;if((t=Dt(t))&&(i=t.J[i.toString()]))for(i=i.concat(),t=0;t<i.length;t++){var h=i[t];h&&h.capture==n&&!h.Sa&&(h=Ht(h,e),s=s&&!1!==h)}return s}function Ht(t,i){var n=t.listener,e=t.Ob||t.src;return t.Eb&&kt(t),n.call(e,i)}function jt(t,i){if(t.Sa)return!0;if(!dt){var n=i||r(\"window.event\");i=new vt(n,this);var e=!0;if(!(0>n.keyCode||null!=n.returnValue)){t:{var s=!1;if(0==n.keyCode)try{n.keyCode=-1;break t}catch(t){s=!0}(s||null==n.returnValue)&&(n.returnValue=!0)}for(n=[],s=i.currentTarget;s;s=s.parentNode)n.push(s);for(t=t.type,s=n.length-1;!i.Ea&&0<=s;s--){i.currentTarget=n[s];var h=At(n[s],t,!0,i);e=e&&h}for(s=0;!i.Ea&&s<n.length;s++)i.currentTarget=n[s],h=At(n[s],t,!1,i),e=e&&h}return e}return Ht(t,new vt(i,this))}function Dt(t){return(t=t[It])instanceof Ct?t:null}var Nt=\"__closure_events_fn_\"+(1e9*Math.random()>>>0);function Ft(t){return f(t)?t:(t[Nt]||(t[Nt]=function(i){return t.handleEvent(i)}),t[Nt])}function Ut(){S.call(this),this.ka=new Ct(this),this.Pe=this,this.Uc=null}w(Ut,S),Ut.prototype[mt]=!0,(i=Ut.prototype).addEventListener=function(t,i,n,e){Ot(this,t,i,n,e)},i.removeEventListener=function(t,i,n,e){Xt(this,t,i,n,e)},i.dispatchEvent=function(t){var i,n=this.Uc;if(n)for(i=[];n;n=n.Uc)i.push(n);n=this.Pe;var e=t.type||t;if(h(t))t=new bt(t,n);else if(t instanceof bt)t.target=t.target||n;else{var s=t;_(t=new bt(e,n),s)}if(s=!0,i)for(var r=i.length-1;!t.Ea&&0<=r;r--){var o=t.currentTarget=i[r];s=o.Lb(e,!0,t)&&s}if(t.Ea||(s=(o=t.currentTarget=n).Lb(e,!0,t)&&s,t.Ea||(s=o.Lb(e,!1,t)&&s)),i)for(r=0;!t.Ea&&r<i.length;r++)s=(o=t.currentTarget=i[r]).Lb(e,!1,t)&&s;return s},i.F=function(){Ut.L.F.call(this),this.pg(),this.Uc=null},i.nb=function(t,i,n,e){return this.ka.add(String(t),i,!1,n,e)},i.Oc=function(t,i,n,e){return this.ka.add(String(t),i,!0,n,e)},i.ed=function(t,i,n,e){this.ka.remove(String(t),i,n,e)},i.Le=function(t){this.ka.ye(t)},i.pg=function(){this.ka&&this.ka.pb(void 0)},i.Lb=function(t,i,n){if(!(t=this.ka.J[String(t)]))return!0;t=t.concat();for(var e=!0,s=0;s<t.length;++s){var h=t[s];if(h&&!h.Sa&&h.capture==i){var r=h.listener,o=h.Ob||h.src;h.Eb&&this.Le(h),e=!1!==r.call(o,n)&&e}}return e&&0!=n.Be},i.jb=function(t,i,n,e){return this.ka.jb(String(t),i,n,e)};var qt=s.JSON.stringify;function Kt(t,i){this.Sf=100,this.ef=t,this.ug=i,this.Zb=0,this.Pb=null}function Wt(){this.lc=this.Va=null}Kt.prototype.get=function(){if(0<this.Zb){this.Zb--;var t=this.Pb;this.Pb=t.next,t.next=null}else t=this.ef();return t},Kt.prototype.put=function(t){this.ug(t),this.Zb<this.Sf&&(this.Zb++,t.next=this.Pb,this.Pb=t)};var Bt,Gt,Yt=new Kt(function(){return new Jt},function(t){t.reset()});function Jt(){this.next=this.scope=this.Gc=null}function _t(t){s.setTimeout(function(){throw t},0)}function Vt(){var t=s.MessageChannel;if(void 0===t&&\"undefined\"!=typeof window&&window.postMessage&&window.addEventListener&&!K(\"Presto\")&&(t=function(){var t=document.createElement(\"IFRAME\");t.style.display=\"none\",t.src=\"\",document.documentElement.appendChild(t);var i=t.contentWindow;(t=i.document).open(),t.write(\"\"),t.close();var n=\"callImmediate\"+Math.random(),e=\"file:\"==i.location.protocol?\"*\":i.location.protocol+\"\/\/\"+i.location.host;t=v(function(t){\"*\"!=e&&t.origin!=e||t.data!=n||this.port1.onmessage()},this),i.addEventListener(\"message\",t,!1),this.port1={},this.port2={postMessage:function(){i.postMessage(n,e)}}}),void 0!==t&&!K(\"Trident\")&&!K(\"MSIE\")){var i=new t,n={},e=n;return i.port1.onmessage=function(){if(void 0!==n.next){var t=(n=n.next).rd;n.rd=null,t()}},function(t){e.next={rd:t},e=e.next,i.port2.postMessage(0)}}return\"undefined\"!=typeof document&&\"onreadystatechange\"in document.createElement(\"SCRIPT\")?function(t){var i=document.createElement(\"SCRIPT\");i.onreadystatechange=function(){i.onreadystatechange=null,i.parentNode.removeChild(i),i=null,t(),t=null},document.documentElement.appendChild(i)}:function(t){s.setTimeout(t,0)}}function $t(){if(s.Promise&&s.Promise.resolve){var t=s.Promise.resolve(void 0);Gt=function(){t.then(Qt)}}else Gt=function(){var t=Qt;!f(s.setImmediate)||s.Window&&s.Window.prototype&&!K(\"Edge\")&&s.Window.prototype.setImmediate==s.setImmediate?(Bt||(Bt=Vt()),Bt(t)):s.setImmediate(t)}}Wt.prototype.add=function(t,i){var n=this.Af();n.set(t,i),this.lc?this.lc.next=n:this.Va=n,this.lc=n},Wt.prototype.remove=function(){var t=null;return this.Va&&(t=this.Va,this.Va=this.Va.next,this.Va||(this.lc=null),t.next=null),t},Wt.prototype.wg=function(t){Yt.put(t)},Wt.prototype.Af=function(){return Yt.get()},Jt.prototype.set=function(t,i){this.Gc=t,this.scope=i,this.next=null},Jt.prototype.reset=function(){this.next=this.scope=this.Gc=null};var Zt=!1,zt=new Wt;function Qt(){for(var t;t=zt.remove();){try{t.Gc.call(t.scope)}catch(t){_t(t)}zt.wg(t)}Zt=!1}function ti(t,i){Ut.call(this),this.Na=t||1,this.wb=i||s,this.nd=v(this.Rg,this),this.ie=m()}function ii(t,i,n){if(f(t))n&&(t=v(t,n));else{if(!t||\"function\"!=typeof t.handleEvent)throw Error(\"Invalid listener argument\");t=v(t.handleEvent,t)}return 2147483647<Number(i)?-1:s.setTimeout(t,i||0)}function ni(t,i,n){S.call(this),this.Uf=null!=n?v(t,n):t,this.Na=i,this.Xe=v(this.fg,this),this.qc=[]}function ei(t){S.call(this),this.i=t,this.o={}}w(ti,Ut),(i=ti.prototype).enabled=!1,i.B=null,i.setInterval=function(t){this.Na=t,this.B&&this.enabled?(this.stop(),this.start()):this.B&&this.stop()},i.Rg=function(){if(this.enabled){var t=m()-this.ie;0<t&&t<.8*this.Na?this.B=this.wb.setTimeout(this.nd,this.Na-t):(this.B&&(this.wb.clearTimeout(this.B),this.B=null),this.ff(),this.enabled&&(this.stop(),this.start()))}},i.ff=function(){this.dispatchEvent(\"tick\")},i.start=function(){this.enabled=!0,this.B||(this.B=this.wb.setTimeout(this.nd,this.Na),this.ie=m())},i.stop=function(){this.enabled=!1,this.B&&(this.wb.clearTimeout(this.B),this.B=null)},i.F=function(){ti.L.F.call(this),this.stop(),delete this.wb},w(ni,S),(i=ni.prototype).Ta=!1,i.ob=0,i.B=null,i.mf=function(t){this.qc=arguments,this.B||this.ob?this.Ta=!0:this.Cc()},i.stop=function(){this.B&&(s.clearTimeout(this.B),this.B=null,this.Ta=!1,this.qc=[])},i.pause=function(){this.ob++},i.resume=function(){this.ob--,this.ob||!this.Ta||this.B||(this.Ta=!1,this.Cc())},i.F=function(){ni.L.F.call(this),this.stop()},i.fg=function(){this.B=null,this.Ta&&!this.ob&&(this.Ta=!1,this.Cc())},i.Cc=function(){this.B=ii(this.Xe,this.Na),this.Uf.apply(null,this.qc)},w(ei,S);var si=[];function hi(t,i,n){this.reset(t,i,n,void 0,void 0)}function ri(t){this.pe=t,this.Zd=this.uc=this.mb=this.$b=null}function oi(t,i){this.name=t,this.value=i}(i=ei.prototype).nb=function(t,i,n,e){return this.Tf(t,i,n,e)},i.Tf=function(t,i,n,e){c(i)||(i&&(si[0]=i.toString()),i=si);for(var s=0;s<i.length;s++){var h=Ot(t,i[s],n||this.handleEvent,e||!1,this.i||this);if(!h)break;this.o[h.key]=h}return this},i.Oc=function(t,i,n,e){return this.je(t,i,n,e)},i.je=function(t,i,n,e,s){if(c(i))for(var h=0;h<i.length;h++)this.je(t,i[h],n,e,s);else{if(!(t=Rt(t,i,n||this.handleEvent,e,s||this.i||this)))return this;this.o[t.key]=t}return this},i.ed=function(t,i,n,e,s){if(c(i))for(var h=0;h<i.length;h++)this.ed(t,i[h],n,e,s);else n=n||this.handleEvent,e=l(e)?!!e.capture:!!e,s=s||this.i||this,n=Ft(n),e=!!e,(i=wt(t)?t.jb(i,n,e,s):t&&(t=Dt(t))?t.jb(i,n,e,s):null)&&(kt(i),delete this.o[i.key])},i.pb=function(){W(this.o,function(t,i){this.o.hasOwnProperty(i)&&kt(t)},this),this.o={}},i.F=function(){ei.L.F.call(this),this.pb()},i.handleEvent=function(){throw Error(\"EventHandler.handleEvent not implemented\")},hi.prototype.Md=null,hi.prototype.reset=function(t,i,n,e,s){this.mb=t,delete this.Md},hi.prototype.Bg=function(t){this.Md=t},hi.prototype.Ge=function(t){this.mb=t},oi.prototype.toString=function(){return this.name};var ai=new oi(\"SEVERE\",1e3),ci=new oi(\"WARNING\",900),ui=new oi(\"INFO\",800),fi=new oi(\"CONFIG\",700),li=new oi(\"FINE\",500);(i=ri.prototype).getName=function(){return this.pe},i.getParent=function(){return this.$b},i.pf=function(){return this.uc||(this.uc={}),this.uc},i.Ge=function(t){this.mb=t},i.Qd=function(){return this.mb?this.mb:this.$b?this.$b.Qd():(C(\"Root logger has no level set.\"),null)},i.Pf=function(t){return t.value>=this.Qd().value},i.log=function(t,i,n){this.Pf(t)&&(f(i)&&(i=i()),this.gf(this.uf(t,i,n)))},i.uf=function(t,i,n){return t=new hi(t,String(i),this.pe),n&&t.Bg(n),t},i.ca=function(t,i){this.log(ai,t,i)},i.T=function(t,i){this.log(ci,t,i)},i.info=function(t,i){this.log(ui,t,i)},i.lf=function(t){this.log(li,t,void 0)},i.gf=function(t){for(var i=this;i;)i.We(t),i=i.getParent()},i.We=function(t){if(this.Zd)for(var i,n=0;i=this.Zd[n];n++)i(t)},i.Fg=function(t){this.$b=t},i.Qe=function(t,i){this.pf()[t]=i};var di={},pi=null;function gi(t){var i;if(pi||(pi=new ri(\"\"),di[\"\"]=pi,pi.Ge(fi)),!(i=di[t])){i=new ri(t);var n=t.lastIndexOf(\".\"),e=t.substr(n+1);(n=gi(t.substr(0,n))).Qe(e,i),i.Fg(n),di[t]=i}return i}function bi(t,i){t&&t.info(i,void 0)}function vi(t,i){t&&t.lf(i)}function yi(){this.s=gi(\"goog.labs.net.webChannel.WebChannelDebug\"),this.Wc=!0}(i=yi.prototype).Id=function(){this.Wc=!1},i.Tg=function(t,i,n,e,s){var h=this;this.info(function(){return\"XMLHTTP REQ (\"+n+\") [attempt \"+e+\"]: \"+t+\"\\n\"+i+\"\\n\"+h.Xf(s)})},i.Ug=function(t,i,n,e,s,h){this.info(function(){return\"XMLHTTP RESP (\"+n+\") [ attempt \"+e+\"]: \"+t+\"\\n\"+i+\"\\n\"+s+\" \"+h})},i.Wa=function(t,i,n){var e=this;this.info(function(){return\"XMLHTTP TEXT (\"+t+\"): \"+e.ng(i)+(n?\" \"+n:\"\")})},i.Sg=function(t){this.info(function(){return\"TIMEOUT: \"+t})},i.debug=function(t){vi(this.s,t)},i.cb=function(t,i){var n=this.s;n&&n.ca(i||\"Exception\",t)},i.info=function(t){bi(this.s,t)},i.T=function(t){var i=this.s;i&&i.T(t,void 0)},i.ca=function(t){var i=this.s;i&&i.ca(t,void 0)},i.ng=function(t){if(!this.Wc)return t;if(!t)return null;try{var i=JSON.parse(t);if(i)for(var n=0;n<i.length;n++)c(i[n])&&this.Wf(i[n]);return qt(i)}catch(i){return this.debug(\"Exception parsing expected JS array - probably was not JS\"),t}},i.Wf=function(t){if(!(2>t.length||(t=t[1],!c(t)||1>t.length))){var i=t[0];if(\"noop\"!=i&&\"stop\"!=i&&\"close\"!=i)for(i=1;i<t.length;i++)t[i]=\"\"}},i.Xf=function(t){if(!this.Wc)return t;if(!t)return null;var i=\"\";t=t.split(\"&\");for(var n=0;n<t.length;n++){var e=t[n].split(\"=\");if(1<e.length){var s=e[0];e=e[1];var h=s.split(\"_\");i=2<=h.length&&\"type\"==h[1]?i+(s+\"=\")+e+\"&\":i+(s+\"=redacted&\")}}return i};var mi=new Ut;function wi(t){bt.call(this,\"serverreachability\",t)}function Ti(t){mi.dispatchEvent(new wi(mi,t))}function Ei(t,i){bt.call(this,\"statevent\",t),this.stat=i}function Ci(t){mi.dispatchEvent(new Ei(mi,t))}function Si(t,i,n){bt.call(this,\"timingevent\",t),this.size=i,this.rtt=n}function Ii(t,i,n){mi.dispatchEvent(new Si(mi,t,i,n))}function Pi(t,i){if(!f(t))throw Error(\"Fn must not be null and must be a function\");return s.setTimeout(function(){t()},i)}w(wi,bt),w(Ei,bt),w(Si,bt);var Oi={NO_ERROR:0,Vg:1,bh:2,ah:3,Yg:4,$g:5,dh:6,Ne:7,TIMEOUT:8,gh:9},xi={Xg:\"complete\",kh:\"success\",Oe:\"error\",Ne:\"abort\",ih:\"ready\",jh:\"readystatechange\",TIMEOUT:\"timeout\",eh:\"incrementaldata\",hh:\"progress\",Zg:\"downloadprogress\",lh:\"uploadprogress\"};function Mi(){}function Ri(){}Mi.prototype.pd=null,Mi.prototype.Vd=function(){return this.pd||(this.pd=this.Mf())};var Xi,ki={OPEN:\"a\",Wg:\"b\",Oe:\"c\",fh:\"d\"};function Li(){bt.call(this,\"d\")}function Ai(){bt.call(this,\"c\")}function Hi(){}function ji(t,i,n,e,s){this.b=t,this.a=i,this.ra=n,this.R=e,this.Xc=s||1,this.Fc=new ei(this),this.Ua=Di,t=it?125:void 0,this.Vc=new ti(t),this.A=null,this.S=!1,this.Da=this.pa=this.ua=this.ic=this.qb=this.hd=this.Ga=null,this.ba=[],this.h=null,this.Bb=0,this.I=this.Fa=null,this.w=-1,this.Za=!1,this.Ra=0,this.ac=null,this.lb=this.Ed=this.yc=!1}w(Li,bt),w(Ai,bt),w(Hi,Mi),Hi.prototype.Dd=function(){var t=this.Wd();return t?new ActiveXObject(t):new XMLHttpRequest},Hi.prototype.Mf=function(){var t={};return this.Wd()&&(t[0]=!0,t[1]=!0),t},Hi.prototype.Wd=function(){if(!this.be&&\"undefined\"==typeof XMLHttpRequest&&\"undefined\"!=typeof ActiveXObject){for(var t=[\"MSXML2.XMLHTTP.6.0\",\"MSXML2.XMLHTTP.3.0\",\"MSXML2.XMLHTTP\",\"Microsoft.XMLHTTP\"],i=0;i<t.length;i++){var n=t[i];try{return new ActiveXObject(n),this.be=n}catch(t){}}throw Error(\"Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed\")}return this.be},Xi=new Hi;var Di=45e3;function Ni(t,i){switch(t){case 0:return\"Non-200 return code (\"+i+\")\";case 1:return\"XMLHTTP failure (no data)\";case 2:return\"HttpConnection timeout\";default:return\"Unknown error\"}}var Fi={},Ui={};function qi(t){if(t.H&&\"function\"==typeof t.H)return t.H();if(h(t))return t.split(\"\");if(u(t)){for(var i=[],n=t.length,e=0;e<n;e++)i.push(t[e]);return i}return B(t)}function Ki(t,i,n){if(t.forEach&&\"function\"==typeof t.forEach)t.forEach(i,n);else if(u(t)||h(t))M(t,i,n);else{if(t.W&&\"function\"==typeof t.W)var e=t.W();else if(t.H&&\"function\"==typeof t.H)e=void 0;else if(u(t)||h(t)){e=[];for(var s=t.length,r=0;r<s;r++)e.push(r)}else e=G(t);r=(s=qi(t)).length;for(var o=0;o<r;o++)i.call(n,s[o],e&&e[o],t)}}function Wi(t,i){this.D={},this.o=[],this.j=0;var n=arguments.length;if(1<n){if(n%2)throw Error(\"Uneven number of arguments\");for(var e=0;e<n;e+=2)this.set(arguments[e],arguments[e+1])}else t&&this.addAll(t)}function Bi(t,i){return Object.prototype.hasOwnProperty.call(t,i)}(i=ji.prototype).ga=function(t){this.A=t},i.setTimeout=function(t){this.Ua=t},i.He=function(t){this.Ra=t},i.Gg=function(t){this.ba=t},i.la=function(){return this.ba},i.kd=function(t,i){this.ic=1,this.ua=t.clone().Ub(),this.Da=i,this.yc=!0,this.Ce(null)},i.jd=function(t,i,n){this.ic=1,this.ua=t.clone().Ub(),this.Da=null,this.yc=i,this.Ce(n)},i.Ce=function(t){this.qb=m(),this.eb(),this.pa=this.ua.clone(),this.pa.dc(\"t\",this.Xc),this.Bb=0,this.h=this.b.Jb(this.b.fc()?t:null),0<this.Ra&&(this.ac=new ni(v(this.Me,this,this.h),this.Ra)),this.Fc.nb(this.h,\"readystatechange\",this.mg),t=this.A?Y(this.A):{},this.Da?(this.Fa||(this.Fa=\"POST\"),t[\"Content-Type\"]=\"application\/x-www-form-urlencoded\",this.h.send(this.pa,this.Fa,this.Da,t)):(this.Fa=\"GET\",this.h.send(this.pa,this.Fa,null,t)),Ti(1),this.a.Tg(this.Fa,this.pa,this.R,this.Xc,this.Da)},i.mg=function(t){t=t.target;var i=this.ac;i&&3==t.ma()?(this.a.debug(\"Throttling readystatechange.\"),i.mf()):this.Me(t)},i.Me=function(t){try{t==this.h?this.hg():this.a.T(\"Called back with an unexpected xmlhttp\")}catch(t){if(this.a.debug(\"Failed call to OnXmlHttpReadyStateChanged_\"),this.h&&this.h.ya()){var i=this;this.a.cb(t,function(){return\"ResponseText: \"+i.h.ya()})}else this.a.cb(t,\"No response text\")}},i.hg=function(){var t=this.h.ma(),i=this.h.Ud(),n=this.h.za();if(!(3>t||3==t&&!it&&!this.h.ya())){this.Za||4!=t||7==i||Ti(8==i||0>=n?3:2),this.Fb();var e=this.h.za();if(this.w=e,!(i=this.h.ya())){var s=this;this.a.debug(function(){return\"No response text for uri \"+s.pa+\" status \"+e})}if(this.S=200==e,this.a.Ug(this.Fa,this.pa,this.R,this.Xc,t,e),this.S){if(this.Ig()){if(!(n=this.sf()))return this.S=!1,this.I=3,Ci(12),this.a.T(\"XMLHTTP Missing X_HTTP_INITIAL_RESPONSE (\"+this.R+\")\"),this.Ia(),void this.Kb();this.a.Wa(this.R,n,\"Initial handshake response via X-HTTP-Initial-Response\"),this.lb=!0,this.Yc(n)}this.yc?(this.Fd(t,i),it&&this.S&&3==t&&this.Ng()):(this.a.Wa(this.R,i,null),this.Yc(i)),4==t&&this.Ia(),this.S&&!this.Za&&(4==t?this.b.Tc(this):(this.S=!1,this.eb()))}else 400==e&&0<i.indexOf(\"Unknown SID\")?(this.I=3,Ci(12),this.a.T(\"XMLHTTP Unknown SID (\"+this.R+\")\")):(this.I=0,Ci(13),this.a.T(\"XMLHTTP Bad status \"+e+\" (\"+this.R+\")\")),this.Ia(),this.Kb()}},i.Ig=function(){return this.Ed&&!this.lb},i.sf=function(){if(this.h){var t=this.h.kb(\"X-HTTP-Initial-Response\");if(t&&!j(t))return t}return null},i.Ag=function(){this.Ed=!0},i.Fd=function(t,i){for(var n=!0;!this.Za&&this.Bb<i.length;){var e=this.vf(i);if(e==Ui){4==t&&(this.I=4,Ci(14),n=!1),this.a.Wa(this.R,null,\"[Incomplete Response]\");break}if(e==Fi){this.I=4,Ci(15),this.a.Wa(this.R,i,\"[Invalid Chunk]\"),n=!1;break}this.a.Wa(this.R,e,null),this.Yc(e)}4==t&&0==i.length&&(this.I=1,Ci(16),n=!1),this.S=this.S&&n,n||(this.a.Wa(this.R,i,\"[Invalid Chunked Response]\"),this.Ia(),this.Kb())},i.kg=function(){if(this.h){var t=this.h.ma(),i=this.h.ya();this.Bb<i.length&&(this.Fb(),this.Fd(t,i),this.S&&4!=t&&this.eb())}},i.Ng=function(){this.Fc.nb(this.Vc,\"tick\",this.kg),this.Vc.start()},i.vf=function(t){var i=this.Bb,n=t.indexOf(\"\\n\",i);return-1==n?Ui:(i=Number(t.substring(i,n)),isNaN(i)?Fi:(n+=1)+i>t.length?Ui:(t=t.substr(n,i),this.Bb=n+i,t))},i.yg=function(t){this.ic=2,this.ua=t.clone().Ub(),t=!1,s.navigator&&s.navigator.sendBeacon&&(t=s.navigator.sendBeacon(this.ua.toString(),\"\")),!t&&s.Image&&((new Image).src=this.ua,t=!0),t||(this.h=this.b.Jb(null),this.h.send(this.ua)),this.qb=m(),this.eb()},i.cancel=function(){this.Za=!0,this.Ia()},i.tg=function(t){t&&this.setTimeout(t),this.Ga&&(this.Fb(),this.eb())},i.eb=function(){this.hd=m()+this.Ua,this.Ke(this.Ua)},i.Ke=function(t){if(null!=this.Ga)throw Error(\"WatchDog timer not null\");this.Ga=Pi(v(this.gg,this),t)},i.Fb=function(){this.Ga&&(s.clearTimeout(this.Ga),this.Ga=null)},i.gg=function(){this.Ga=null;var t=m();0<=t-this.hd?this.Df():(this.a.T(\"WatchDog timer called too early\"),this.Ke(this.hd-t))},i.Df=function(){this.S&&this.a.ca(\"Received watchdog timeout even though request loaded successfully\"),this.a.Sg(this.pa),2!=this.ic&&(Ti(3),Ci(17)),this.Ia(),this.I=2,this.Kb()},i.Kb=function(){this.b.de()||this.Za||this.b.Tc(this)},i.Ia=function(){this.Fb();var t=this.ac;t&&\"function\"==typeof t.bb&&t.bb(),this.ac=null,this.Vc.stop(),this.Fc.pb(),this.h&&(t=this.h,this.h=null,t.abort(),t.bb())},i.Hc=function(){return this.I},i.Yc=function(t){try{this.b.ue(this,t),Ti(4)}catch(t){this.a.cb(t,\"Error in httprequest callback\")}},(i=Wi.prototype).C=function(){return this.j},i.H=function(){this.wc();for(var t=[],i=0;i<this.o.length;i++)t.push(this.D[this.o[i]]);return t},i.W=function(){return this.wc(),this.o.concat()},i.va=function(t){return Bi(this.D,t)},i.X=function(){return 0==this.j},i.clear=function(){this.D={},this.j=this.o.length=0},i.remove=function(t){return!!Bi(this.D,t)&&(delete this.D[t],this.j--,this.o.length>2*this.j&&this.wc(),!0)},i.wc=function(){if(this.j!=this.o.length){for(var t=0,i=0;t<this.o.length;){var n=this.o[t];Bi(this.D,n)&&(this.o[i++]=n),t++}this.o.length=i}if(this.j!=this.o.length){var e={};for(i=t=0;t<this.o.length;)Bi(e,n=this.o[t])||(this.o[i++]=n,e[n]=1),t++;this.o.length=i}},i.get=function(t,i){return Bi(this.D,t)?this.D[t]:i},i.set=function(t,i){Bi(this.D,t)||(this.j++,this.o.push(t)),this.D[t]=i},i.addAll=function(t){if(t instanceof Wi)for(var i=t.W(),n=0;n<i.length;n++)this.set(i[n],t.get(i[n]));else for(i in t)this.set(i,t[i])},i.forEach=function(t,i){for(var n=this.W(),e=0;e<n.length;e++){var s=n[e],h=this.get(s);t.call(i,h,s,this)}},i.clone=function(){return new Wi(this)};var Gi=\/^(?:([^:\/?#.]+):)?(?:\\\/\\\/(?:([^\/?#]*)@)?([^\/#?]*?)(?::([0-9]+))?(?=[\/#?]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$\/;function Yi(t,i){if(t){t=t.split(\"&\");for(var n=0;n<t.length;n++){var e=t[n].indexOf(\"=\"),s=null;if(0<=e){var h=t[n].substring(0,e);s=t[n].substring(e+1)}else h=t[n];i(h,s?decodeURIComponent(s.replace(\/\\+\/g,\" \")):\"\")}}}function Ji(t,i){var n;this.xa=this.zb=this.qa=\"\",this.Ca=null,this.ib=this.K=\"\",this.O=this.Qf=!1,t instanceof Ji?(this.O=void 0!==i?i:t.O,this.tb(t.qa),this.cd(t.zb),this.rb(t.xa),this.sb(t.Ca),this.ec(t.K),this.bd(t.P.clone()),this.$c(t.ib)):t&&(n=String(t).match(Gi))?(this.O=!!i,this.tb(n[1]||\"\",!0),this.cd(n[2]||\"\",!0),this.rb(n[3]||\"\",!0),this.sb(n[4]),this.ec(n[5]||\"\",!0),this.bd(n[6]||\"\",!0),this.$c(n[7]||\"\",!0)):(this.O=!!i,this.P=new hn(null,this.O))}function _i(t){return t instanceof Ji?t.clone():new Ji(t,void 0)}function Vi(t,i,n,e){var s=new Ji(null,void 0);return t&&s.tb(t),i&&s.rb(i),n&&s.sb(n),e&&s.ec(e),s}function $i(t,i){return t?i?decodeURI(t.replace(\/%25\/g,\"%2525\")):decodeURIComponent(t):\"\"}function Zi(t,i,n){return h(t)?(t=encodeURI(t).replace(i,zi),n&&(t=t.replace(\/%25([0-9a-fA-F]{2})\/g,\"%$1\")),t):null}function zi(t){return\"%\"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}(i=Ji.prototype).toString=function(){var t=[],i=this.qa;i&&t.push(Zi(i,Qi,!0),\":\");var n=this.xa;return(n||\"file\"==i)&&(t.push(\"\/\/\"),(i=this.zb)&&t.push(Zi(i,Qi,!0),\"@\"),t.push(encodeURIComponent(String(n)).replace(\/%25([0-9a-fA-F]{2})\/g,\"%$1\")),null!=(n=this.Ca)&&t.push(\":\",String(n))),(n=this.K)&&(this.Ic()&&\"\/\"!=n.charAt(0)&&t.push(\"\/\"),t.push(Zi(n,\"\/\"==n.charAt(0)?nn:tn,!0))),(n=this.Rd())&&t.push(\"?\",n),(n=this.ib)&&t.push(\"#\",Zi(n,sn)),t.join(\"\")},i.resolve=function(t){var i=this.clone(),n=t.Hf();n?i.tb(t.qa):n=t.If(),n?i.cd(t.zb):n=t.Ic(),n?i.rb(t.xa):n=t.Ff();var e=t.K;if(n)i.sb(t.Ca);else if(n=t.ae()){if(\"\/\"!=e.charAt(0))if(this.Ic()&&!this.ae())e=\"\/\"+e;else{var s=i.K.lastIndexOf(\"\/\");-1!=s&&(e=i.K.substr(0,s+1)+e)}if(\"..\"==(s=e)||\".\"==s)e=\"\";else if(-1!=s.indexOf(\".\/\")||-1!=s.indexOf(\"\/.\")){e=0==s.lastIndexOf(\"\/\",0),s=s.split(\"\/\");for(var h=[],r=0;r<s.length;){var o=s[r++];\".\"==o?e&&r==s.length&&h.push(\"\"):\"..\"==o?((1<h.length||1==h.length&&\"\"!=h[0])&&h.pop(),e&&r==s.length&&h.push(\"\")):(h.push(o),e=!0)}e=h.join(\"\/\")}else e=s}return n?i.ec(e):n=t.Gf(),n?i.bd(t.P.clone()):n=t.Ef(),n&&i.$c(t.ib),i},i.clone=function(){return new Ji(this)},i.tb=function(t,i){this.U(),(this.qa=i?$i(t,!0):t)&&(this.qa=this.qa.replace(\/:$\/,\"\"))},i.Hf=function(){return!!this.qa},i.cd=function(t,i){this.U(),this.zb=i?$i(t):t},i.If=function(){return!!this.zb},i.rb=function(t,i){this.U(),this.xa=i?$i(t,!0):t},i.Ic=function(){return!!this.xa},i.sb=function(t){if(this.U(),t){if(t=Number(t),isNaN(t)||0>t)throw Error(\"Bad port number \"+t);this.Ca=t}else this.Ca=null},i.Ff=function(){return null!=this.Ca},i.ec=function(t,i){this.U(),this.K=i?$i(t,!0):t},i.ae=function(){return!!this.K},i.Gf=function(){return\"\"!==this.P.toString()},i.bd=function(t,i){this.U(),t instanceof hn?(this.P=t,this.P.ad(this.O)):(i||(t=Zi(t,en)),this.P=new hn(t,this.O))},i.Rd=function(){return this.P.toString()},i.getQuery=function(){return this.Rd()},i.l=function(t,i){this.U(),this.P.set(t,i)},i.dc=function(t,i){this.U(),c(i)||(i=[String(i)]),this.P.Ie(t,i)},i.$c=function(t,i){this.U(),this.ib=i?$i(t):t},i.Ef=function(){return!!this.ib},i.Ub=function(){return this.U(),this.l(\"zx\",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^m()).toString(36)),this},i.removeParameter=function(t){return this.U(),this.P.remove(t),this},i.U=function(){if(this.Qf)throw Error(\"Tried to modify a read-only Uri\")},i.ad=function(t){this.O=t,this.P&&this.P.ad(t)};var Qi=\/[#\\\/\\?@]\/g,tn=\/[#\\?:]\/g,nn=\/[#\\?]\/g,en=\/[#\\?@]\/g,sn=\/#\/g;function hn(t,i){this.j=this.m=null,this.ja=t||null,this.O=!!i}function rn(){}function on(){}function an(t,i){this.b=t,this.a=i,this.f=this.A=null,this.bc=!1,this.K=null,this.w=-1,this.Ad=this.na=null}function cn(){this.od=this.$d=null}function un(t){this.D=new Wi,t&&this.addAll(t)}function fn(t){var i=typeof t;return\"object\"==i&&t||\"function\"==i?\"o\"+(t[d]||(t[d]=++p)):i.substr(0,1)+t}function ln(t,i){this.Pc=t,this.map=i,this.context=null}function dn(t){this.me=t||pn,s.PerformanceNavigationTiming?t=0<(t=s.performance.getEntriesByType(\"navigation\")).length&&(\"hq\"==t[0].nextHopProtocol||\"h2\"==t[0].nextHopProtocol):t=!!(s.vc&&s.vc.ke&&s.vc.ke()&&s.vc.ke().nh),this.Xb=t?this.me:1,this.v=null,1<this.Xb&&(this.v=new un),this.f=null,this.ba=[]}(i=hn.prototype).$=function(){if(!this.m&&(this.m=new Wi,this.j=0,this.ja)){var t=this;Yi(this.ja,function(i,n){t.add(decodeURIComponent(i.replace(\/\\+\/g,\" \")),n)})}},i.C=function(){return this.$(),this.j},i.add=function(t,i){this.$(),this.Oa(),t=this.Ma(t);var n=this.m.get(t);return n||this.m.set(t,n=[]),n.push(i),this.j+=1,this},i.remove=function(t){return this.$(),t=this.Ma(t),!!this.m.va(t)&&(this.Oa(),this.j-=this.m.get(t).length,this.m.remove(t))},i.clear=function(){this.Oa(),this.m=null,this.j=0},i.X=function(){return this.$(),0==this.j},i.va=function(t){return this.$(),t=this.Ma(t),this.m.va(t)},i.forEach=function(t,i){this.$(),this.m.forEach(function(n,e){M(n,function(n){t.call(i,n,e,this)},this)},this)},i.W=function(){this.$();for(var t=this.m.H(),i=this.m.W(),n=[],e=0;e<i.length;e++)for(var s=t[e],h=0;h<s.length;h++)n.push(i[e]);return n},i.H=function(t){this.$();var i=[];if(h(t))this.va(t)&&(i=A(i,this.m.get(this.Ma(t))));else{t=this.m.H();for(var n=0;n<t.length;n++)i=A(i,t[n])}return i},i.set=function(t,i){return this.$(),this.Oa(),t=this.Ma(t),this.va(t)&&(this.j-=this.m.get(t).length),this.m.set(t,[i]),this.j+=1,this},i.get=function(t,i){return t&&0<(t=this.H(t)).length?String(t[0]):i},i.Ie=function(t,i){this.remove(t),0<i.length&&(this.Oa(),this.m.set(this.Ma(t),H(i)),this.j+=i.length)},i.toString=function(){if(this.ja)return this.ja;if(!this.m)return\"\";for(var t=[],i=this.m.W(),n=0;n<i.length;n++){var e=i[n],s=encodeURIComponent(String(e));e=this.H(e);for(var h=0;h<e.length;h++){var r=s;\"\"!==e[h]&&(r+=\"=\"+encodeURIComponent(String(e[h]))),t.push(r)}}return this.ja=t.join(\"&\")},i.Oa=function(){this.ja=null},i.clone=function(){var t=new hn;return t.ja=this.ja,this.m&&(t.m=this.m.clone(),t.j=this.j),t},i.Ma=function(t){return t=String(t),this.O&&(t=t.toLowerCase()),t},i.ad=function(t){t&&!this.O&&(this.$(),this.Oa(),this.m.forEach(function(t,i){var n=i.toLowerCase();i!=n&&(this.remove(i),this.Ie(n,t))},this)),this.O=t},i.extend=function(t){for(var i=0;i<arguments.length;i++)Ki(arguments[i],function(t,i){this.add(i,t)},this)},w(on,rn),(i=an.prototype).g=null,i.ga=function(t){this.A=t},i.connect=function(t){this.K=t,t=this.b.Sd(this.K),Ci(3);var i=this.b.Ib.$d;null!=i?(this.na=this.b.$a(i[0]),this.g=1,this.xd()):(t.dc(\"MODE\",\"init\"),!this.b.ta&&this.b.aa&&t.dc(\"X-HTTP-Session-Id\",this.b.aa),this.f=new ji(this,this.a,void 0,void 0,void 0),this.f.ga(this.A),this.f.jd(t,!1,null),this.g=0)},i.xd=function(){this.a.debug(\"TestConnection: starting stage 2\");var t=this.b.Ib.od;if(null!=t)this.a.debug(function(){return\"Buffered\"}),Ci(4),t?(Ci(10),this.b.ub(this,!1)):(Ci(11),this.b.ub(this,!0));else{this.f=new ji(this,this.a,void 0,void 0,void 0),this.f.ga(this.A);var i=this.b.Pd(this.na,this.K);Ci(4),i.dc(\"TYPE\",\"xmlhttp\");var n=this.b.aa,e=this.b.Kc;n&&e&&i.l(n,e),this.f.jd(i,!1,this.na)}},i.Jb=function(t){return this.b.Jb(t)},i.abort=function(){this.f&&(this.f.cancel(),this.f=null),this.w=-1},i.de=function(){return!1},i.ue=function(t,i){if(this.w=t.w,0==this.g)if(this.a.debug(\"TestConnection: Got data for stage 1\"),this.pc(t),i){try{var n=this.b.kc.zc(i)}catch(t){return this.a.cb(t),void this.b.dd(this)}this.na=this.b.$a(n[0])}else this.a.debug(\"TestConnection: Null responseText\"),this.b.dd(this);else 1==this.g&&(this.bc?Ci(6):\"11111\"==i?(Ci(5),this.bc=!0,this.Ze()&&(this.w=200,this.f.cancel(),this.a.debug(\"Test connection succeeded; using streaming connection\"),Ci(11),this.b.ub(this,!0))):(Ci(7),this.bc=!1))},i.Tc=function(){this.w=this.f.w,this.f.S?0==this.g?(this.g=1,this.a.debug(\"TestConnection: request complete for initial check\"),this.xd()):1==this.g&&(this.a.debug(\"TestConnection: request complete for stage 2\"),this.bc?(this.a.debug(\"Test connection succeeded; using streaming connection\"),Ci(11),this.b.ub(this,!0)):(this.a.debug(\"Test connection failed; not using streaming\"),Ci(10),this.b.ub(this,!1))):(this.a.debug(\"TestConnection: request failed, in state \"+this.g),0==this.g?Ci(8):1==this.g&&Ci(9),this.b.dd(this))},i.pc=function(t){if(!this.b.ta&&(t=t.h)){var i=t.kb(\"X-Client-Wire-Protocol\");this.Ad=i||null,this.b.aa&&((t=t.kb(\"X-HTTP-Session-Id\"))?this.b.Fe(t):this.a.T(\"Missing X_HTTP_SESSION_ID in the handshake response\"))}},i.fc=function(){return this.b.fc()},i.Ba=function(){return this.b.Ba()},i.Ze=function(){return!Q||10<=Number(at)},(i=un.prototype).C=function(){return this.D.C()},i.add=function(t){this.D.set(fn(t),t)},i.addAll=function(t){for(var i=(t=qi(t)).length,n=0;n<i;n++)this.add(t[n])},i.pb=function(t){for(var i=(t=qi(t)).length,n=0;n<i;n++)this.remove(t[n])},i.remove=function(t){return this.D.remove(fn(t))},i.clear=function(){this.D.clear()},i.X=function(){return this.D.X()},i.contains=function(t){return this.D.va(fn(t))},i.H=function(){return this.D.H()},i.clone=function(){return new un(this)};var pn=10;function gn(){this.xg=this.rg=void 0}function bn(){this.jg=new gn}function vn(t,i){var n=new yi;n.debug(\"TestLoadImage: loading \"+t);var e=new Image;e.onload=y(yn,n,e,\"TestLoadImage: loaded\",!0,i),e.onerror=y(yn,n,e,\"TestLoadImage: error\",!1,i),e.onabort=y(yn,n,e,\"TestLoadImage: abort\",!1,i),e.ontimeout=y(yn,n,e,\"TestLoadImage: timeout\",!1,i),s.setTimeout(function(){e.ontimeout&&e.ontimeout()},1e4),e.src=t}function yn(t,i,n,e,s){try{t.debug(n),i.onload=null,i.onerror=null,i.onabort=null,i.ontimeout=null,s(e)}catch(i){t.cb(i)}}(i=dn.prototype).ld=function(t){this.v||-1==t.indexOf(\"spdy\")&&-1==t.indexOf(\"quic\")&&-1==t.indexOf(\"h2\")||(this.Xb=this.me,this.v=new un,this.f&&(this.oc(this.f),this.f=null))},i.ee=function(){return!!this.f||!!this.v&&this.v.C()>=this.Xb},i.xf=function(){return this.f?1:this.v?this.v.C():0},i.Jc=function(t){return this.f?this.f==t:!!this.v&&this.v.contains(t)},i.oc=function(t){this.v?this.v.add(t):this.f=t},i.ze=function(t){this.f&&this.f==t?this.f=null:this.v&&this.v.contains(t)&&this.v.remove(t)},i.cancel=function(){this.ba=this.la(),this.f?(this.f.cancel(),this.f=null):this.v&&!this.v.X()&&(M(this.v.H(),function(t){t.cancel()}),this.v.clear())},i.la=function(){if(null!=this.f)return this.ba.concat(this.f.la());if(null!=this.v&&!this.v.X()){var t=this.ba;return M(this.v.H(),function(i){t=t.concat(i.la())}),t}return H(this.ba)},i.Re=function(t){this.ba=this.ba.concat(t)},i.$e=function(){this.ba.length=0},gn.prototype.stringify=function(t){return s.JSON.stringify(t,this.rg)},gn.prototype.parse=function(t){return s.JSON.parse(t,this.xg)},bn.prototype.hf=function(t,i,n){var e=n||\"\";try{Ki(t,function(t,n){var s=t;l(t)&&(s=qt(t)),i.push(e+n+\"=\"+encodeURIComponent(s))})}catch(t){throw i.push(e+\"type=\"+encodeURIComponent(\"_badmap\")),t}},bn.prototype.jf=function(t,i,n){for(var e=-1;;){var s=[\"count=\"+i];-1==e?0<i?(e=t[0].Pc,s.push(\"ofs=\"+e)):e=0:s.push(\"ofs=\"+e);for(var h=!0,r=0;r<i;r++){var o=t[r].Pc,a=t[r].map;if(0>(o-=e))e=Math.max(0,t[r].Pc-100),h=!1;else try{this.hf(a,s,\"req\"+o+\"_\")}catch(t){n&&n(a)}}if(h)return s.join(\"&\")}},bn.prototype.zc=function(t){return this.jg.parse(t)};var mn=s.JSON.parse;function wn(t){Ut.call(this),this.headers=new Wi,this.Xa=t||null,this.ha=!1,this.mc=this.c=null,this.ge=this.Tb=\"\",this.Pa=0,this.I=\"\",this.Aa=this.Lc=this.Qb=this.Ec=!1,this.vb=0,this.hc=null,this.Ae=Tn,this.jc=this.lg=this.Ab=!1}w(wn,Ut);var Tn=\"\";wn.prototype.s=gi(\"goog.net.XhrIo\");var En=\/^https?$\/i,Cn=[\"POST\",\"PUT\"];function Sn(t){return Q&&ut(9)&&\"number\"==typeof t.timeout&&void 0!==t.ontimeout}function In(t){return\"content-type\"==t.toLowerCase()}function Pn(t,i){return{type:i,lengthComputable:t.lengthComputable,loaded:t.loaded,total:t.total}}function On(t){var i=\"\";return W(t,function(t,n){i+=n,i+=\":\",i+=t,i+=\"\\r\\n\"}),i}function xn(t,i,n){t:{for(e in n){var e=!1;break t}e=!0}if(e)return t;if(n=On(n),h(t)){if(i=encodeURIComponent(String(i)),i+=n=null!=n?\"=\"+encodeURIComponent(String(n)):\"\"){if(0>(n=t.indexOf(\"#\"))&&(n=t.length),0>(e=t.indexOf(\"?\"))||e>n){e=n;var s=\"\"}else s=t.substring(e+1,n);n=(t=[t.substr(0,e),s,t.substr(n)])[1],t[1]=i?n?n+\"&\"+i:i:n,t=t[0]+(t[1]?\"?\"+t[1]:\"\")+t[2]}return t}return t.l(i,n),t}function Mn(t){this.Bd=22,this.De=0,this.M=[],this.a=new yi,this.Ib=new cn,this.na=this.md=this.hb=this.K=this.u=this.Kc=this.aa=this.gb=this.N=this.Rb=this.A=null,this.Te=!0,this.ag=this.Yb=0,this.kf=!!r(\"internalChannelParams.failFast\",t),this.fd=this.Ja=this.wa=this.ia=this.ea=this.i=null,this.Se=!0,this.w=this.he=this.Sb=-1,this.rc=this.Ha=this.La=0,this.Ve=r(\"internalChannelParams.baseRetryDelayMs\",t)||5e3,this.vg=r(\"internalChannelParams.retryDelaySeedMs\",t)||1e4,this.nf=r(\"internalChannelParams.forwardChannelMaxRetries\",t)||2,this.Od=r(\"internalChannelParams.forwardChannelRequestTimeoutMs\",t)||2e4,this.Xa=t&&t.oh||void 0,this.Db=void 0,this.Ra=0,this.gc=t&&t.supportsCrossDomainXhr||!1,this.ra=\"\",this.G=new dn(t&&t.concurrentRequestLimit),this.kc=new bn,this.ta=!t||void 0===t.backgroundChannelTest||t.backgroundChannelTest,(this.Nd=t&&t.fastHandshake||!1)&&!this.ta&&(this.a.T(\"Force backgroundChannelTest when fastHandshake is enabled.\"),this.ta=!0),t&&t.Id&&this.a.Id()}function Rn(){}function Xn(t){for(var i=arguments[0],n=1;n<arguments.length;n++){var e,s=arguments[n];if(0==s.lastIndexOf(\"\/\",0))i=s;else(e=\"\"==i)||(e=0<=(e=i.length-1)&&i.indexOf(\"\/\",e)==e),i=e?i+s:i+\"\/\"+s}return i}function kn(){if(Q&&!(10<=Number(at)))throw Error(\"Environmental error: no available transport.\")}function Ln(t,i){Ut.call(this),this.b=new Mn(i),this.yb=t,this.Qg=i&&i.testUrl?i.testUrl:Xn(this.yb,\"test\"),this.s=gi(\"goog.labs.net.webChannel.WebChannelBaseTransport\"),this.Rc=i&&i.messageUrlParams||null,t=i&&i.messageHeaders||null,i&&i.clientProtocolHeaderRequired&&(t?t[\"X-Client-Protocol\"]=\"webchannel\":t={\"X-Client-Protocol\":\"webchannel\"}),this.b.ga(t),t=i&&i.initMessageHeaders||null,i&&i.messageContentType&&(t?t[\"X-WebChannel-Content-Type\"]=i.messageContentType:t={\"X-WebChannel-Content-Type\":i.messageContentType}),i&&i.zd&&(t?t[\"X-WebChannel-Client-Profile\"]=i.zd:t={\"X-WebChannel-Client-Profile\":i.zd}),this.b.Eg(t),(t=i&&i.httpHeadersOverwriteParam)&&!j(t)&&this.b.Cg(t),this.Og=i&&i.supportsCrossDomainXhr||!1,this.zg=i&&i.sendRawJson||!1,(i=i&&i.httpSessionIdParam)&&!j(i)&&(this.b.Dg(i),null!==(t=this.Rc)&&i in t&&(i in(t=this.Rc)&&delete t[i],(t=this.s)&&t.T(\"Ignore httpSessionIdParam also specified with messageUrlParams: \"+i,void 0))),this.vd=new jn(this)}function An(t){Li.call(this);var i=t.__sm__;if(i){t:{for(var n in i){t=n;break t}t=void 0}(this.ne=t)&&(t=this.ne,i=null!==i&&t in i?i[t]:void 0),this.data=i}else this.data=t}function Hn(t){Ai.call(this),this.status=1,this.errorCode=t}function jn(t){this.b=t}(i=wn.prototype).Je=function(t){this.Ab=t},i.send=function(t,i,n,e){if(this.c)throw Error(\"[goog.net.XhrIo] Object is active with another request=\"+this.Tb+\"; newUri=\"+t);i=i?i.toUpperCase():\"GET\",this.Tb=t,this.I=\"\",this.Pa=0,this.ge=i,this.Ec=!1,this.ha=!0,this.c=this.df(),this.mc=this.Xa?this.Xa.Vd():Xi.Vd(),this.c.onreadystatechange=v(this.te,this),this.lg&&\"onprogress\"in this.c&&(this.c.onprogress=v(function(t){this.re(t,!0)},this),this.c.upload&&(this.c.upload.onprogress=v(this.re,this)));try{vi(this.s,this.da(\"Opening Xhr\")),this.Lc=!0,this.c.open(i,String(t),!0),this.Lc=!1}catch(t){return vi(this.s,this.da(\"Error opening Xhr: \"+t.message)),void this.Ld(t)}t=n||\"\";var h=this.headers.clone();e&&Ki(e,function(t,i){h.set(i,t)}),e=X(h.W()),n=s.FormData&&t instanceof s.FormData,!(0<=O(Cn,i))||e||n||h.set(\"Content-Type\",\"application\/x-www-form-urlencoded;charset=utf-8\"),h.forEach(function(t,i){this.c.setRequestHeader(i,t)},this),this.Ae&&(this.c.responseType=this.Ae),\"withCredentials\"in this.c&&this.c.withCredentials!==this.Ab&&(this.c.withCredentials=this.Ab);try{this.yd(),0<this.vb&&(this.jc=Sn(this.c),vi(this.s,this.da(\"Will abort after \"+this.vb+\"ms if incomplete, xhr2 \"+this.jc)),this.jc?(this.c.timeout=this.vb,this.c.ontimeout=v(this.Ua,this)):this.hc=ii(this.Ua,this.vb,this)),vi(this.s,this.da(\"Sending request\")),this.Qb=!0,this.c.send(t),this.Qb=!1}catch(t){vi(this.s,this.da(\"Send error: \"+t.message)),this.Ld(t)}},i.df=function(){return this.Xa?this.Xa.Dd():Xi.Dd()},i.Ua=function(){void 0!==e&&this.c&&(this.I=\"Timed out after \"+this.vb+\"ms, aborting\",this.Pa=8,vi(this.s,this.da(this.I)),this.dispatchEvent(\"timeout\"),this.abort(8))},i.Ld=function(t){this.ha=!1,this.c&&(this.Aa=!0,this.c.abort(),this.Aa=!1),this.I=t,this.Pa=5,this.Jd(),this.Gb()},i.Jd=function(){this.Ec||(this.Ec=!0,this.dispatchEvent(\"complete\"),this.dispatchEvent(\"error\"))},i.abort=function(t){this.c&&this.ha&&(vi(this.s,this.da(\"Aborting\")),this.ha=!1,this.Aa=!0,this.c.abort(),this.Aa=!1,this.Pa=t||7,this.dispatchEvent(\"complete\"),this.dispatchEvent(\"abort\"),this.Gb())},i.F=function(){this.c&&(this.ha&&(this.ha=!1,this.Aa=!0,this.c.abort(),this.Aa=!1),this.Gb(!0)),wn.L.F.call(this)},i.te=function(){this.Ka||(this.Lc||this.Qb||this.Aa?this.se():this.eg())},i.eg=function(){this.se()},i.se=function(){if(this.ha&&void 0!==e)if(this.mc[1]&&4==this.ma()&&2==this.za())vi(this.s,this.da(\"Local request error detected and ignored\"));else if(this.Qb&&4==this.ma())ii(this.te,0,this);else if(this.dispatchEvent(\"readystatechange\"),this.Mc()){vi(this.s,this.da(\"Request complete\")),this.ha=!1;try{this.Rf()?(this.dispatchEvent(\"complete\"),this.dispatchEvent(\"success\")):(this.Pa=6,this.I=this.Yd()+\" [\"+this.za()+\"]\",this.Jd())}finally{this.Gb()}}},i.re=function(t,i){this.dispatchEvent(Pn(t,\"progress\")),this.dispatchEvent(Pn(t,i?\"downloadprogress\":\"uploadprogress\"))},i.Gb=function(t){if(this.c){this.yd();var i=this.c,n=this.mc[0]?o:null;this.mc=this.c=null,t||this.dispatchEvent(\"ready\");try{i.onreadystatechange=n}catch(i){(t=this.s)&&t.ca(\"Problem encountered resetting onreadystatechange: \"+i.message,void 0)}}},i.yd=function(){this.c&&this.jc&&(this.c.ontimeout=null),this.hc&&(s.clearTimeout(this.hc),this.hc=null)},i.Ba=function(){return!!this.c},i.Mc=function(){return 4==this.ma()},i.Rf=function(){var t=this.za();t:switch(t){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var i=!0;break t;default:i=!1}return i||0===t&&!this.Of()},i.Of=function(){var t=String(this.Tb).match(Gi)[1]||null;return!t&&s.self&&s.self.location&&(t=(t=s.self.location.protocol).substr(0,t.length-1)),En.test(t?t.toLowerCase():\"\")},i.ma=function(){return this.c?this.c.readyState:0},i.za=function(){try{return 2<this.ma()?this.c.status:-1}catch(t){return-1}},i.Yd=function(){try{return 2<this.ma()?this.c.statusText:\"\"}catch(t){return vi(this.s,\"Can not get status: \"+t.message),\"\"}},i.ya=function(){try{return this.c?this.c.responseText:\"\"}catch(t){return vi(this.s,\"Can not get responseText: \"+t.message),\"\"}},i.yf=function(t){if(this.c){var i=this.c.responseText;return t&&0==i.indexOf(t)&&(i=i.substring(t.length)),mn(i)}},i.getResponseHeader=function(t){if(this.c&&this.Mc())return null===(t=this.c.getResponseHeader(t))?void 0:t},i.getAllResponseHeaders=function(){return this.c&&this.Mc()&&this.c.getAllResponseHeaders()||\"\"},i.kb=function(t){return this.c?this.c.getResponseHeader(t):null},i.Ud=function(){return this.Pa},i.Hc=function(){return h(this.I)?this.I:String(this.I)},i.da=function(t){return t+\" [\"+this.ge+\" \"+this.Tb+\" \"+this.za()+\"]\"},(i=Mn.prototype).tc=8,i.g=1,i.connect=function(t,i,n,e,s){this.a.debug(\"connect()\"),Ci(0),this.K=i,this.gb=n||{},e&&void 0!==s&&(this.gb.OSID=e,this.gb.OAID=s),this.ta&&(this.a.debug(\"connect() bypassed channel-test.\"),this.Ib.$d=[],this.Ib.od=!1),this.bf(t)},i.disconnect=function(){if(this.a.debug(\"disconnect()\"),this.qd(),3==this.g){var t=this.Yb++,i=this.hb.clone();i.l(\"SID\",this.ra),i.l(\"RID\",t),i.l(\"TYPE\",\"terminate\"),this.Ya(i),new ji(this,this.a,this.ra,t,void 0).yg(i)}this.qe()},i.bf=function(t){this.a.debug(\"connectTest_()\"),this.Ja=new an(this,this.a),null===this.N&&this.Ja.ga(this.A);var i=t;this.N&&this.A&&(i=xn(t,this.N,this.A)),this.Ja.connect(i)},i.af=function(){this.a.debug(\"connectChannel_()\"),this.hb=this.Sd(this.K),this.Dc()},i.qd=function(){this.Ja&&(this.Ja.abort(),this.Ja=null),this.u&&(this.u.cancel(),this.u=null),this.ia&&(s.clearTimeout(this.ia),this.ia=null),this.Hb(),this.G.cancel(),this.ea&&(s.clearTimeout(this.ea),this.ea=null)},i.ga=function(t){this.A=t},i.Eg=function(t){this.Rb=t},i.Cg=function(t){this.N=t},i.Dg=function(t){this.aa=t},i.Fe=function(t){this.Kc=t},i.He=function(t){this.Ra=t},i.Hg=function(){this.gc=!0},i.Ee=function(t){this.i=t},i.Nf=function(){return!this.fd},i.Zc=function(t){1e3==this.M.length&&this.a.ca(function(){return\"Already have 1000 queued maps upon queueing \"+qt(t)}),this.M.push(new ln(this.ag++,t)),3==this.g&&this.Dc()},i.qf=function(){return this.kf?0:this.nf},i.de=function(){return 0==this.g},i.getState=function(){return this.g},i.Dc=function(){this.G.ee()||this.ea||(this.ea=Pi(v(this.we,this),0),this.La=0)},i.Yf=function(t){return this.G.xf()>=this.G.Xb-(this.ea?1:0)?(this.a.ca(\"Unexpected retry request is scheduled.\"),!1):this.ea?(this.a.debug(\"Use the retry request that is already scheduled.\"),this.M=t.la().concat(this.M),!0):!(1==this.g||2==this.g||this.La>=this.qf())&&(this.a.debug(\"Going to retry POST\"),this.ea=Pi(v(this.we,this,t),this.Xd(this.La)),this.La++,!0)},i.we=function(t){this.ea=null,this.Mg(t)},i.Mg=function(t){this.a.debug(\"startForwardChannel_\"),1==this.g?t?this.a.ca(\"Not supposed to retry the open\"):(this.ig(),this.g=2):3==this.g&&(t?this.le(t):0==this.M.length?this.a.debug(\"startForwardChannel_ returned: nothing to send\"):this.G.ee()?this.a.ca(\"startForwardChannel_ returned: connection already in progress\"):(this.le(),this.a.debug(\"startForwardChannel_ finished, sent request\")))},i.ig=function(){this.a.debug(\"open_()\"),this.Yb=Math.floor(1e5*Math.random());var t=this.Yb++,i=new ji(this,this.a,\"\",t,void 0),n=this.A;this.Rb&&(n?_(n=Y(n),this.Rb):n=this.Rb),null===this.N&&i.ga(n);var e=this.Hd(i),s=this.hb.clone();s.l(\"RID\",t),0<this.Bd&&s.l(\"CVER\",this.Bd),this.ta&&this.aa&&s.l(\"X-HTTP-Session-Id\",this.aa),this.Ya(s),this.N&&n&&xn(s,this.N,n),this.G.oc(i),this.Nd?(s.l(\"$req\",e),s.l(\"SID\",\"null\"),i.Ag(),i.kd(s,null)):i.kd(s,e)},i.le=function(t){var i=t?t.R:this.Yb++,n=this.hb.clone();n.l(\"SID\",this.ra),n.l(\"RID\",i),n.l(\"AID\",this.Sb),this.Ya(n),this.N&&this.A&&xn(n,this.N,this.A),i=new ji(this,this.a,this.ra,i,this.La+1),null===this.N&&i.ga(this.A),t&&this.sg(t),t=this.Hd(i),i.setTimeout(Math.round(.5*this.Od)+Math.round(.5*this.Od*Math.random())),this.G.oc(i),i.kd(n,t)},i.Ya=function(t){this.i&&Ki({},function(i,n){t.l(n,i)})},i.Hd=function(t){var i=Math.min(this.M.length,1e3),n=this.i?v(this.i.Ue,this.i,this):null;return n=this.kc.jf(this.M,i,n),t.Gg(this.M.splice(0,i)),n},i.sg=function(t){this.M=t.la().concat(this.M)},i.Kd=function(){if(!this.u&&!this.ia){this.rc=1;var t=this.ve;Gt||$t(),Zt||(Gt(),Zt=!0),zt.add(t,this),this.Ha=0}},i.Qc=function(){return this.u||this.ia?(this.a.ca(\"Request already in progress\"),!1):!(3<=this.Ha)&&(this.a.debug(\"Going to retry GET\"),this.rc++,this.ia=Pi(v(this.ve,this),this.Xd(this.Ha)),this.Ha++,!0)},i.ve=function(){this.ia=null,this.Kg()},i.Kg=function(){this.a.debug(\"Creating new HttpRequest\"),this.u=new ji(this,this.a,this.ra,\"rpc\",this.rc),null===this.N&&this.u.ga(this.A),this.u.He(this.Ra);var t=this.md.clone();t.l(\"RID\",\"rpc\"),t.l(\"SID\",this.ra),t.l(\"CI\",this.fd?\"0\":\"1\"),t.l(\"AID\",this.Sb),this.Ya(t),t.l(\"TYPE\",\"xmlhttp\"),this.N&&this.A&&xn(t,this.N,this.A),this.Db&&this.u.setTimeout(this.Db),this.u.jd(t,!0,this.na),this.a.debug(\"New Request created\")},i.ub=function(t,i){this.a.debug(\"Test Connection Finished\");var n=t.Ad;n&&this.G.ld(n),this.fd=this.Se&&i,this.w=t.w,this.af()},i.dd=function(t){this.a.debug(\"Test Connection Failed\"),this.w=t.w,this.sa(2)},i.ue=function(t,i){if(0!=this.g&&(this.u==t||this.G.Jc(t)))if(this.w=t.w,!t.lb&&this.G.Jc(t)&&3==this.g){try{var n=this.kc.zc(i)}catch(t){n=null}c(n)&&3==n.length?this.Cf(n,t):(this.a.debug(\"Bad POST response data returned\"),this.sa(11))}else(t.lb||this.u==t)&&this.Hb(),j(i)||(n=this.kc.zc(i),this.dg(n,t))},i.Cf=function(t,i){0==t[0]?this.Bf(i):(this.he=t[1],0<(i=this.he-this.Sb)&&(t=t[2],this.a.debug(t+\" bytes (in \"+i+\" arrays) are outstanding on the BackChannel\"),this.Jg(t)&&!this.wa&&(this.wa=Pi(v(this.bg,this),6e3))))},i.Bf=function(t){if(this.a.debug(\"Server claims our backchannel is missing.\"),this.ia)this.a.debug(\"But we are currently starting the request.\");else{if(this.u){if(!(this.u.qb+3e3<t.qb))return;this.Hb(),this.u.cancel(),this.u=null}else this.a.T(\"We do not have a BackChannel established\");this.Qc(),Ci(18)}},i.Jg=function(t){return 37500>t&&!this.Nf()&&0==this.Ha},i.$a=function(t){return this.Te?this.i?this.i.$a(t):t:null},i.bg=function(){null!=this.wa&&(this.wa=null,this.u.cancel(),this.u=null,this.Qc(),Ci(19))},i.Hb=function(){null!=this.wa&&(s.clearTimeout(this.wa),this.wa=null)},i.Tc=function(t){this.a.debug(\"Request complete\");var i=null;if(this.u==t){this.Hb(),this.u=null;var n=2}else{if(!this.G.Jc(t))return;i=t.la(),this.G.ze(t),n=1}if(this.w=t.w,0!=this.g)if(t.S)1==n?(Ii(t.Da?t.Da.length:0,m()-t.qb,this.La),this.Dc()):this.Kd();else{var e=t.Hc();if(3==e||0==e&&0<this.w)this.a.debug(\"Not retrying due to error type\");else{var s=this;if(this.a.debug(function(){return\"Maybe retrying, last error: \"+Ni(e,s.w)}),1==n&&this.Yf(t)||2==n&&this.Qc())return;this.a.debug(\"Exceeded max number of retries\")}switch(i&&0<i.length&&this.G.Re(i),this.a.debug(\"Error: HTTP request failed\"),e){case 1:this.sa(5);break;case 4:this.sa(10);break;case 3:this.sa(6);break;default:this.sa(2)}}},i.Xd=function(t){var i=this.Ve+Math.floor(Math.random()*this.vg);return this.Ba()||(this.a.debug(\"Inactive channel\"),i*=2),i*t},i.pc=function(t){if(this.ta&&(t=t.h)){var i=t.kb(\"X-Client-Wire-Protocol\");i&&this.G.ld(i),this.aa&&((t=t.kb(\"X-HTTP-Session-Id\"))?(this.Fe(t),this.hb.l(this.aa,t)):this.a.T(\"Missing X_HTTP_SESSION_ID in the handshake response\"))}},i.dg=function(t,i){for(var n=this.i&&this.i.sc?[]:null,e=0;e<t.length;e++){var s=t[e];if(this.Sb=s[0],s=s[1],2==this.g)if(\"c\"==s[0]){this.ra=s[1],this.na=this.$a(s[2]);var h=s[3];null!=h&&(this.tc=h,this.a.info(\"VER=\"+this.tc)),null!=(h=s[4])&&(this.De=h,this.a.info(\"SVER=\"+this.De)),null!=(s=s[5])&&\"number\"==typeof s&&0<s&&(this.Db=s*=1.5,this.a.info(\"backChannelRequestTimeoutMs_=\"+s)),this.pc(i),this.g=3,this.i&&this.i.wd(),this.Lg(i)}else\"stop\"!=s[0]&&\"close\"!=s[0]||this.sa(7);else 3==this.g&&(\"stop\"==s[0]||\"close\"==s[0]?(n&&0!=n.length&&(this.i.sc(this,n),n.length=0),\"stop\"==s[0]?this.sa(7):this.disconnect()):\"noop\"!=s[0]&&(n?n.push(s):this.i&&this.i.ud(s)),this.Ha=0)}n&&0!=n.length&&this.i.sc(this,n)},i.Lg=function(t){this.md=this.Pd(this.na,this.K),t.lb?(this.a.debug(\"Upgrade the handshake request to a backchannel.\"),this.G.ze(t),t.tg(this.Db),this.u=t):this.Kd()},i.sa=function(t){if(this.a.info(\"Error code \"+t),2==t){var i=null;this.i&&(i=null);var n=v(this.Pg,this);i||(i=new Ji(\"\/\/www.google.com\/images\/cleardot.gif\"),s.location&&\"http\"==s.location.protocol||i.tb(\"https\"),i.Ub()),vn(i.toString(),n)}else Ci(2);this.cg(t)},i.Pg=function(t){t?(this.a.info(\"Successfully pinged google.com\"),Ci(2)):(this.a.info(\"Failed to ping google.com\"),Ci(1))},i.cg=function(t){this.a.debug(\"HttpChannel: error - \"+t),this.g=0,this.i&&this.i.td(t),this.qe(),this.qd()},i.qe=function(){if(this.g=0,this.w=-1,this.i){var t=this.G.la();if(0!=t.length||0!=this.M.length){var i=this;this.a.debug(function(){return\"Number of undelivered maps, pending: \"+t.length+\", outgoing: \"+i.M.length}),this.G.$e(),H(this.M),this.M.length=0}this.i.sd()}},i.Sd=function(t){return t=this.Cd(null,t),this.a.debug(\"GetForwardChannelUri: \"+t),t},i.Pd=function(t,i){return t=this.Cd(this.fc()?t:null,i),this.a.debug(\"GetBackChannelUri: \"+t),t},i.Cd=function(t,i){var n=_i(i);if(\"\"!=n.xa)t&&n.rb(t+\".\"+n.xa),n.sb(n.Ca);else{var e=s.location;n=Vi(e.protocol,t?t+\".\"+e.hostname:e.hostname,+e.port,i)}return this.gb&&W(this.gb,function(t,i){n.l(i,t)}),t=this.aa,i=this.Kc,t&&i&&n.l(t,i),n.l(\"VER\",this.tc),this.Ya(n),n},i.Jb=function(t){if(t&&!this.gc)throw Error(\"Can't create secondary domain capable XhrIo object.\");return(t=new wn(this.Xa)).Je(this.gc),t},i.Ba=function(){return!!this.i&&this.i.Ba()},i.fc=function(){return this.gc},(i=Rn.prototype).sc=null,i.wd=function(){},i.ud=function(){},i.td=function(){},i.sd=function(){},i.Ba=function(){return!0},i.Ue=function(){},i.$a=function(t){return t},kn.prototype.cf=function(t,i){return new Ln(t,i)},w(Ln,Ut),(i=Ln.prototype).addEventListener=function(t,i,n,e){Ln.L.addEventListener.call(this,t,i,n,e)},i.removeEventListener=function(t,i,n,e){Ln.L.removeEventListener.call(this,t,i,n,e)},i.open=function(){this.b.Ee(this.vd),this.Og&&this.b.Hg(),this.b.connect(this.Qg,this.yb,this.Rc||void 0)},i.close=function(){this.b.disconnect()},i.send=function(t){if(h(t)){var i={};i.__data__=t,this.b.Zc(i)}else this.zg?((i={}).__data__=qt(t),this.b.Zc(i)):this.b.Zc(t)},i.F=function(){this.b.Ee(null),delete this.vd,this.b.disconnect(),delete this.b,Ln.L.F.call(this)},w(An,Li),w(Hn,Ai),w(jn,Rn),jn.prototype.wd=function(){bi(this.b.s,\"WebChannel opened on \"+this.b.yb),this.b.dispatchEvent(\"a\")},jn.prototype.ud=function(t){this.b.dispatchEvent(new An(t))},jn.prototype.td=function(t){bi(this.b.s,\"WebChannel aborted on \"+this.b.yb+\" due to channel error: \"+t),this.b.dispatchEvent(new Hn(t))},jn.prototype.sd=function(){bi(this.b.s,\"WebChannel closed on \"+this.b.yb),this.b.dispatchEvent(\"b\")};var Dn=y(function(t,i){function n(){}n.prototype=t.prototype;var e=new n;return t.apply(e,Array.prototype.slice.call(arguments,1)),e},kn);function Nn(){this.V=[],this.Z=[]}function Fn(t,i){if(S.call(this),this.oe=t||0,this.Wb=i||10,this.oe>this.Wb)throw Error(Un);this.fa=new Nn,this.oa=new un,this.Ac=0,this.Nc=null,this.Cb()}(i=Nn.prototype).Vf=function(){0==this.V.length&&(this.V=this.Z,this.V.reverse(),this.Z=[])},i.enqueue=function(t){this.Z.push(t)},i.ab=function(){return this.Vf(),this.V.pop()},i.C=function(){return this.V.length+this.Z.length},i.X=function(){return 0==this.V.length&&0==this.Z.length},i.clear=function(){this.V=[],this.Z=[]},i.contains=function(t){return 0<=O(this.V,t)||0<=O(this.Z,t)},i.remove=function(t){var i=this.V,n=x(i,t);return 0<=n?(Array.prototype.splice.call(i,n,1),i=!0):i=!1,i||L(this.Z,t)},i.H=function(){for(var t=[],i=this.V.length-1;0<=i;--i)t.push(this.V[i]);var n=this.Z.length;for(i=0;i<n;++i)t.push(this.Z[i]);return t},w(Fn,S);var Un=\"[goog.structs.Pool] Min can not be greater than max\";function qn(t,i){this.fe=t,this.gd=i}function Kn(t){this.Y=[],t&&this.Lf(t)}function Wn(){Kn.call(this)}function Bn(t,i){this.Gd=void 0,this.cc=new Wn,Fn.call(this,t,i)}function Gn(t,i,n,e){this.Jf=t,this.Ab=!!e,Bn.call(this,i,n)}(i=Fn.prototype).Mb=function(){var t=m();if(!(null!=this.Nc&&t-this.Nc<this.Ac)){var i=this.qg();return i&&(this.Nc=t,this.oa.add(i)),i}},i.og=function(t){return!!this.oa.remove(t)&&(this.nc(t),!0)},i.qg=function(){for(var t;0<this.Td()&&(t=this.fa.ab(),!this.Sc(t));)this.Cb();return!t&&this.C()<this.Wb&&(t=this.xc()),t},i.nc=function(t){this.oa.remove(t),this.Sc(t)&&this.C()<this.Wb?this.fa.enqueue(t):this.Bc(t)},i.Cb=function(){for(var t=this.fa;this.C()<this.oe;)t.enqueue(this.xc());for(;this.C()>this.Wb&&0<this.Td();)this.Bc(t.ab())},i.xc=function(){return{}},i.Bc=function(t){if(\"function\"==typeof t.bb)t.bb();else for(var i in t)t[i]=null},i.Sc=function(t){return\"function\"!=typeof t.Ye||t.Ye()},i.contains=function(t){return this.fa.contains(t)||this.oa.contains(t)},i.C=function(){return this.fa.C()+this.oa.C()},i.rf=function(){return this.oa.C()},i.Td=function(){return this.fa.C()},i.X=function(){return this.fa.X()&&this.oa.X()},i.F=function(){if(Fn.L.F.call(this),0<this.rf())throw Error(\"[goog.structs.Pool] Objects not released\");delete this.oa;for(var t=this.fa;!t.X();)this.Bc(t.ab());delete this.fa},qn.prototype.getKey=function(){return this.fe},qn.prototype.clone=function(){return new qn(this.fe,this.gd)},(i=Kn.prototype).ce=function(t,i){var n=this.Y;n.push(new qn(t,i)),this.$f(n.length-1)},i.Lf=function(t){if(t instanceof Kn){var i=t.W();if(t=t.H(),0>=this.C()){for(var n=this.Y,e=0;e<i.length;e++)n.push(new qn(i[e],t[e]));return}}else i=G(t),t=B(t);for(e=0;e<i.length;e++)this.ce(i[e],t[e])},i.remove=function(){var t=this.Y,i=t.length,n=t[0];if(!(0>=i))return 1==i?k(t):(t[0]=t.pop(),this.Zf()),n.gd},i.Zf=function(){for(var t=0,i=this.Y,n=i.length,e=i[t];t<n>>1;){var s=this.tf(t),h=this.zf(t);if(i[s=h<n&&i[h].getKey()<i[s].getKey()?h:s].getKey()>e.getKey())break;i[t]=i[s],t=s}i[t]=e},i.$f=function(t){for(var i=this.Y,n=i[t];0<t;){var e=this.wf(t);if(!(i[e].getKey()>n.getKey()))break;i[t]=i[e],t=e}i[t]=n},i.tf=function(t){return 2*t+1},i.zf=function(t){return 2*t+2},i.wf=function(t){return t-1>>1},i.H=function(){for(var t=this.Y,i=[],n=t.length,e=0;e<n;e++)i.push(t[e].gd);return i},i.W=function(){for(var t=this.Y,i=[],n=t.length,e=0;e<n;e++)i.push(t[e].getKey());return i},i.va=function(t){return R(this.Y,function(i){return i.getKey()==t})},i.clone=function(){return new Kn(this)},i.C=function(){return this.Y.length},i.X=function(){return 0==this.Y.length},i.clear=function(){k(this.Y)},w(Wn,Kn),Wn.prototype.enqueue=function(t,i){this.ce(t,i)},Wn.prototype.ab=function(){return this.remove()},w(Bn,Fn),(i=Bn.prototype).Mb=function(t,i){if(!t)return(t=Bn.L.Mb.call(this))&&this.Ac&&(this.Gd=s.setTimeout(v(this.Nb,this),this.Ac)),t;this.cc.enqueue(void 0!==i?i:100,t),this.Nb()},i.Nb=function(){for(var t=this.cc;0<t.C();){var i=this.Mb();if(!i)break;t.ab().apply(this,[i])}},i.nc=function(t){Bn.L.nc.call(this,t),this.Nb()},i.Cb=function(){Bn.L.Cb.call(this),this.Nb()},i.F=function(){Bn.L.F.call(this),s.clearTimeout(this.Gd),this.cc.clear(),this.cc=null},w(Gn,Bn),Gn.prototype.xc=function(){var t=new wn,i=this.Jf;return i&&i.forEach(function(i,n){t.headers.set(n,i)}),this.Ab&&t.Je(!0),t},Gn.prototype.Sc=function(t){return!t.Ka&&!t.Ba()},kn.prototype.createWebChannel=kn.prototype.cf,Ln.prototype.send=Ln.prototype.send,Ln.prototype.open=Ln.prototype.open,Ln.prototype.close=Ln.prototype.close,Oi.NO_ERROR=0,Oi.TIMEOUT=8,Oi.HTTP_ERROR=6,xi.COMPLETE=\"complete\",Ri.EventType=ki,ki.OPEN=\"a\",ki.CLOSE=\"b\",ki.ERROR=\"c\",ki.MESSAGE=\"d\",Ut.prototype.listen=Ut.prototype.nb,Gn.prototype.getObject=Gn.prototype.Mb,Gn.prototype.releaseObject=Gn.prototype.og,wn.prototype.listenOnce=wn.prototype.Oc,wn.prototype.getLastError=wn.prototype.Hc,wn.prototype.getLastErrorCode=wn.prototype.Ud,wn.prototype.getStatus=wn.prototype.za,wn.prototype.getStatusText=wn.prototype.Yd,wn.prototype.getResponseJson=wn.prototype.yf,wn.prototype.getResponseText=wn.prototype.ya,wn.prototype.getResponseText=wn.prototype.ya,wn.prototype.send=wn.prototype.send;var Yn={createWebChannelTransport:Dn,ErrorCode:Oi,EventType:xi,WebChannel:Ri,XhrIoPool:Gn},Jn=Yn.createWebChannelTransport,_n=Yn.ErrorCode,Vn=Yn.EventType,$n=Yn.WebChannel,Zn=Yn.XhrIoPool;exports.default=Yn,exports.createWebChannelTransport=Jn,exports.ErrorCode=_n,exports.EventType=Vn,exports.WebChannel=$n,exports.XhrIoPool=Zn;\r\n},{}],17:[function(require,module,exports) {\r\n\"use strict\";function e(e){return e&&\"object\"==typeof e&&\"default\"in e?e.default:e}Object.defineProperty(exports,\"__esModule\",{value:!0});var t,n=e(require(\"@firebase\/app\")),r=require(\"@firebase\/logger\"),i=require(\"tslib\"),o=require(\"@firebase\/webchannel-wrapper\"),a=n.SDK_VERSION,s=new r.Logger(\"@firebase\/firestore\");function u(){return s.logLevel===r.LogLevel.DEBUG?t.DEBUG:s.logLevel===r.LogLevel.SILENT?t.SILENT:t.ERROR}function c(e){switch(e){case t.DEBUG:s.logLevel=r.LogLevel.DEBUG;break;case t.ERROR:s.logLevel=r.LogLevel.ERROR;break;case t.SILENT:s.logLevel=r.LogLevel.SILENT;break;default:s.error(\"Firestore (\"+a+\"): Invalid value passed to `setLogLevel`\")}}function h(e,t){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];if(s.logLevel<=r.LogLevel.DEBUG){var o=n.map(f);s.debug.apply(s,[\"Firestore (\"+a+\") [\"+e+\"]: \"+t].concat(o))}}function l(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(s.logLevel<=r.LogLevel.ERROR){var i=t.map(f);s.error.apply(s,[\"Firestore (\"+a+\"): \"+e].concat(i))}}function f(e){if(\"string\"==typeof e)return e;var t=m.getPlatform();try{return t.formatJSON(e)}catch(t){return e}}function d(e){var t=\"FIRESTORE (\"+a+\") INTERNAL ASSERTION FAILED: \"+e;throw l(t),new Error(t)}function p(e,t){e||d(t)}!function(e){e[e.DEBUG=0]=\"DEBUG\",e[e.ERROR=1]=\"ERROR\",e[e.SILENT=2]=\"SILENT\"}(t||(t={}));var m=function(){function e(){}return e.setPlatform=function(t){e.platform&&d(\"Platform already defined\"),e.platform=t},e.getPlatform=function(){return e.platform||d(\"Platform not set\"),e.platform},e}();function y(){return m.getPlatform().emptyByteString}var g={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\"},v=function(e){function t(t,n){var r=e.call(this,n)||this;return r.code=t,r.message=n,r.name=\"FirebaseError\",r.toString=function(){return r.name+\": [code=\"+r.code+\"]: \"+r.message},r}return i.__extends(t,e),t}(Error);function w(e,t){function n(){var e=\"This constructor is private.\";throw t&&(e+=\" \",e+=t),new v(g.INVALID_ARGUMENT,e)}for(var r in n.prototype=e.prototype,e)e.hasOwnProperty(r)&&(n[r]=e[r]);return n}function b(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function S(e,t){return void 0!==e?e:t}function T(e,t){for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var r=Number(n);isNaN(r)||t(r,e[n])}}function E(e){var t=[];return I(e,function(e,n){return t.push(n)}),t}function I(e,t){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function D(e){for(var t in p(null!=e&&\"object\"==typeof e,\"isEmpty() expects object parameter.\"),e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function C(e){p(e&&\"object\"==typeof e,\"shallowCopy() expects object parameter.\");var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}function _(e,t,n){if(t.length!==n)throw new v(g.INVALID_ARGUMENT,\"Function \"+e+\"() requires \"+G(n,\"argument\")+\", but was called with \"+G(t.length,\"argument\")+\".\")}function N(e,t,n){if(t.length<n)throw new v(g.INVALID_ARGUMENT,\"Function \"+e+\"() requires at least \"+G(n,\"argument\")+\", but was called with \"+G(t.length,\"argument\")+\".\")}function A(e,t,n,r){if(t.length<n||t.length>r)throw new v(g.INVALID_ARGUMENT,\"Function \"+e+\"() requires between \"+n+\" and \"+r+\" arguments, but was called with \"+G(t.length,\"argument\")+\".\")}function k(e,t,n,r){if(!(t instanceof Array)||t.length<r)throw new v(g.INVALID_ARGUMENT,\"Function \"+e+\"() requires its \"+n+\" argument to be an array with at least \"+G(r,\"element\")+\".\")}function R(e,t,n,r){V(e,t,j(n)+\" argument\",r)}function M(e,t,n,r){void 0!==r&&R(e,t,n,r)}function O(e,t,n,r){V(e,t,n+\" option\",r)}function P(e,t,n,r){void 0!==r&&O(e,t,n,r)}function L(e,t,n,r,i){if(!(r instanceof Array))throw new v(g.INVALID_ARGUMENT,\"Function \"+e+\"() requires its \"+t+\" option to be an array, but it was: \"+U(r));for(var o=0;o<r.length;++o)if(!i(r[o]))throw new v(g.INVALID_ARGUMENT,\"Function \"+e+\"() requires all \"+t+\" elements to be \"+n+\", but the value at index \"+o+\" was: \"+U(r[o]))}function x(e,t,n,r,i){void 0!==r&&L(e,t,n,r,i)}function q(e,t,n,r,i){for(var o=[],a=0,s=i;a<s.length;a++){var u=s[a];if(u===r)return;o.push(U(u))}var c=U(r);throw new v(g.INVALID_ARGUMENT,\"Invalid value \"+c+\" provided to function \"+e+'() for option \"'+n+'\". Acceptable values: '+o.join(\", \"))}function F(e,t,n,r,i){void 0!==r&&q(e,t,n,r,i)}function V(e,t,n,r){if(!(\"object\"===t?B(r):\"non-empty string\"===t?\"string\"==typeof r&&\"\"!==r:typeof r===t)){var i=U(r);throw new v(g.INVALID_ARGUMENT,\"Function \"+e+\"() requires its \"+n+\" to be of type \"+t+\", but it was: \"+i)}}function B(e){return\"object\"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}function U(e){if(void 0===e)return\"undefined\";if(null===e)return\"null\";if(\"string\"==typeof e)return e.length>20&&(e=e.substring(0,20)+\"...\"),JSON.stringify(e);if(\"number\"==typeof e||\"boolean\"==typeof e)return\"\"+e;if(\"object\"==typeof e){if(e instanceof Array)return\"an array\";var t=Q(e);return t?\"a custom \"+t+\" object\":\"an object\"}return\"function\"==typeof e?\"a function\":d(\"Unknown wrong type: \"+typeof e)}function Q(e){if(e.constructor){var t=\/function\\s+([^\\s(]+)\\s*\\(\/.exec(e.constructor.toString());if(t&&t.length>1)return t[1]}return null}function K(e,t,n){if(void 0===n)throw new v(g.INVALID_ARGUMENT,\"Function \"+e+\"() requires a valid \"+j(t)+\" argument, but it was undefined.\")}function W(e,t,n){I(t,function(t,r){if(n.indexOf(t)<0)throw new v(g.INVALID_ARGUMENT,\"Unknown option '\"+t+\"' passed to function \"+e+\"(). Available options: \"+n.join(\", \"))})}function z(e,t,n,r){var i=U(r);return new v(g.INVALID_ARGUMENT,\"Function \"+e+\"() requires its \"+j(n)+\" argument to be a \"+t+\", but it was: \"+i)}function j(e){switch(e){case 1:return\"first\";case 2:return\"second\";case 3:return\"third\";default:return e+\"th\"}}function G(e,t){return e+\" \"+t+(1===e?\"\":\"s\")}var H=function(){function e(){}return e.newId=function(){for(var e=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\",t=\"\",n=0;n<20;n++)t+=e.charAt(Math.floor(Math.random()*e.length));return p(20===t.length,\"Invalid auto ID: \"+t),t},e}();function Y(e,t){return e<t?-1:e>t?1:0}function J(e,t){return null!=e?!(!t||!e.isEqual(t)):e===t}function X(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!e[n].isEqual(t[n]))return!1;return!0}function Z(e){return e+\"\\0\"}function $(){if(\"undefined\"==typeof Uint8Array)throw new v(g.UNIMPLEMENTED,\"Uint8Arrays are not available in this environment.\")}function ee(){if(!m.getPlatform().base64Available)throw new v(g.UNIMPLEMENTED,\"Blobs are unavailable in Firestore in this environment.\")}var te,ne,re=function(){function e(e){ee(),this._binaryString=e}return e.fromBase64String=function(t){_(\"Blob.fromBase64String\",arguments,1),R(\"Blob.fromBase64String\",\"string\",1,t),ee();try{return new e(m.getPlatform().atob(t))}catch(e){throw new v(g.INVALID_ARGUMENT,\"Failed to construct Blob from Base64 string: \"+e)}},e.fromUint8Array=function(t){if(_(\"Blob.fromUint8Array\",arguments,1),$(),!(t instanceof Uint8Array))throw z(\"Blob.fromUint8Array\",\"Uint8Array\",1,t);return new e(Array.prototype.map.call(t,function(e){return String.fromCharCode(e)}).join(\"\"))},e.prototype.toBase64=function(){return _(\"Blob.toBase64\",arguments,0),ee(),m.getPlatform().btoa(this._binaryString)},e.prototype.toUint8Array=function(){_(\"Blob.toUint8Array\",arguments,0),$();for(var e=new Uint8Array(this._binaryString.length),t=0;t<this._binaryString.length;t++)e[t]=this._binaryString.charCodeAt(t);return e},e.prototype.toString=function(){return\"Blob(base64: \"+this.toBase64()+\")\"},e.prototype.isEqual=function(e){return this._binaryString===e._binaryString},e.prototype._compareTo=function(e){return Y(this._binaryString,e._binaryString)},e}(),ie=w(re,\"Use Blob.fromUint8Array() or Blob.fromBase64String() instead.\"),oe=function(){function e(e,t){if(_(\"GeoPoint\",arguments,2),R(\"GeoPoint\",\"number\",1,e),R(\"GeoPoint\",\"number\",2,t),!isFinite(e)||e<-90||e>90)throw new v(g.INVALID_ARGUMENT,\"Latitude must be a number between -90 and 90, but was: \"+e);if(!isFinite(t)||t<-180||t>180)throw new v(g.INVALID_ARGUMENT,\"Longitude must be a number between -180 and 180, but was: \"+t);this._lat=e,this._long=t}return Object.defineProperty(e.prototype,\"latitude\",{get:function(){return this._lat},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,\"longitude\",{get:function(){return this._long},enumerable:!0,configurable:!0}),e.prototype.isEqual=function(e){return this._lat===e._lat&&this._long===e._long},e.prototype._compareTo=function(e){return Y(this._lat,e._lat)||Y(this._long,e._long)},e}(),ae=function(){function e(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new v(g.INVALID_ARGUMENT,\"Timestamp nanoseconds out of range: \"+t);if(t>=1e9)throw new v(g.INVALID_ARGUMENT,\"Timestamp nanoseconds out of range: \"+t);if(e<-62135596800)throw new v(g.INVALID_ARGUMENT,\"Timestamp seconds out of range: \"+e);if(e>=253402300800)throw new v(g.INVALID_ARGUMENT,\"Timestamp seconds out of range: \"+e)}return e.now=function(){return e.fromMillis(Date.now())},e.fromDate=function(t){return e.fromMillis(t.getTime())},e.fromMillis=function(t){var n=Math.floor(t\/1e3);return new e(n,1e6*(t-1e3*n))},e.prototype.toDate=function(){return new Date(this.toMillis())},e.prototype.toMillis=function(){return 1e3*this.seconds+this.nanoseconds\/1e6},e.prototype._compareTo=function(e){return this.seconds===e.seconds?Y(this.nanoseconds,e.nanoseconds):Y(this.seconds,e.seconds)},e.prototype.isEqual=function(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds},e.prototype.toString=function(){return\"Timestamp(seconds=\"+this.seconds+\", nanoseconds=\"+this.nanoseconds+\")\"},e}(),se=function(){return function(e,t,n,r){this.databaseId=e,this.persistenceKey=t,this.host=n,this.ssl=r}}(),ue=\"(default)\",ce=function(){function e(e,t){this.projectId=e,this.database=t||ue}return Object.defineProperty(e.prototype,\"isDefaultDatabase\",{get:function(){return this.database===ue},enumerable:!0,configurable:!0}),e.prototype.isEqual=function(t){return t instanceof e&&t.projectId===this.projectId&&t.database===this.database},e.prototype.compareTo=function(e){return Y(this.projectId,e.projectId)||Y(this.database,e.database)},e}(),he=\"__name__\",le=function(){function e(e,t,n){this.init(e,t,n)}return e.prototype.init=function(e,t,n){void 0===t?t=0:t>e.length&&d(\"offset \"+t+\" out of range \"+e.length),void 0===n?n=e.length-t:n>e.length-t&&d(\"length \"+n+\" out of range \"+(e.length-t)),this.segments=e,this.offset=t,this.len=n},e.prototype.construct=function(e,t,n){var r=Object.create(Object.getPrototypeOf(this));return r.init(e,t,n),r},Object.defineProperty(e.prototype,\"length\",{get:function(){return this.len},enumerable:!0,configurable:!0}),e.prototype.isEqual=function(t){return 0===e.comparator(this,t)},e.prototype.child=function(t){var n=this.segments.slice(this.offset,this.limit());return t instanceof e?t.forEach(function(e){n.push(e)}):\"string\"==typeof t?n.push(t):d(\"Unknown parameter type for Path.child(): \"+t),this.construct(n)},e.prototype.limit=function(){return this.offset+this.length},e.prototype.popFirst=function(e){return e=void 0===e?1:e,p(this.length>=e,\"Can't call popFirst() with less segments\"),this.construct(this.segments,this.offset+e,this.length-e)},e.prototype.popLast=function(){return p(!this.isEmpty(),\"Can't call popLast() on empty path\"),this.construct(this.segments,this.offset,this.length-1)},e.prototype.firstSegment=function(){return p(!this.isEmpty(),\"Can't call firstSegment() on empty path\"),this.segments[this.offset]},e.prototype.lastSegment=function(){return p(!this.isEmpty(),\"Can't call lastSegment() on empty path\"),this.segments[this.limit()-1]},e.prototype.get=function(e){return p(e<this.length,\"Index out of range\"),this.segments[this.offset+e]},e.prototype.isEmpty=function(){return 0===this.length},e.prototype.isPrefixOf=function(e){if(e.length<this.length)return!1;for(var t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0},e.prototype.isImmediateParentOf=function(e){if(this.length+1!==e.length)return!1;for(var t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0},e.prototype.forEach=function(e){for(var t=this.offset,n=this.limit();t<n;t++)e(this.segments[t])},e.prototype.toArray=function(){return this.segments.slice(this.offset,this.limit())},e.comparator=function(e,t){for(var n=Math.min(e.length,t.length),r=0;r<n;r++){var i=e.get(r),o=t.get(r);if(i<o)return-1;if(i>o)return 1}return e.length<t.length?-1:e.length>t.length?1:0},e}(),fe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i.__extends(t,e),t.prototype.canonicalString=function(){return this.toArray().join(\"\/\")},t.prototype.toString=function(){return this.canonicalString()},t.fromString=function(e){if(e.indexOf(\"\/\/\")>=0)throw new v(g.INVALID_ARGUMENT,\"Invalid path (\"+e+\"). Paths must not contain \/\/ in them.\");return new t(e.split(\"\/\").filter(function(e){return e.length>0}))},t.EMPTY_PATH=new t([]),t}(le),de=\/^[_a-zA-Z][_a-zA-Z0-9]*$\/,pe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i.__extends(t,e),t.isValidIdentifier=function(e){return de.test(e)},t.prototype.canonicalString=function(){return this.toArray().map(function(e){return e=e.replace(\"\\\\\",\"\\\\\\\\\").replace(\"`\",\"\\\\`\"),t.isValidIdentifier(e)||(e=\"`\"+e+\"`\"),e}).join(\".\")},t.prototype.toString=function(){return this.canonicalString()},t.prototype.isKeyField=function(){return 1===this.length&&this.get(0)===he},t.keyField=function(){return new t([he])},t.fromServerFormat=function(e){for(var n=[],r=\"\",i=0,o=function(){if(0===r.length)throw new v(g.INVALID_ARGUMENT,\"Invalid field path (\"+e+\"). Paths must not be empty, begin with '.', end with '.', or contain '..'\");n.push(r),r=\"\"},a=!1;i<e.length;){var s=e[i];if(\"\\\\\"===s){if(i+1===e.length)throw new v(g.INVALID_ARGUMENT,\"Path has trailing escape character: \"+e);var u=e[i+1];if(\"\\\\\"!==u&&\".\"!==u&&\"`\"!==u)throw new v(g.INVALID_ARGUMENT,\"Path has invalid escape sequence: \"+e);r+=u,i+=2}else\"`\"===s?(a=!a,i++):\".\"!==s||a?(r+=s,i++):(o(),i++)}if(o(),a)throw new v(g.INVALID_ARGUMENT,\"Unterminated ` in path: \"+e);return new t(n)},t.EMPTY_PATH=new t([]),t}(le),me=function(){function e(t){this.path=t,p(e.isDocumentKey(t),\"Invalid DocumentKey with an odd number of segments: \"+t.toArray().join(\"\/\"))}return e.prototype.isEqual=function(e){return null!==e&&0===fe.comparator(this.path,e.path)},e.prototype.toString=function(){return this.path.toString()},e.comparator=function(e,t){return fe.comparator(e.path,t.path)},e.isDocumentKey=function(e){return e.length%2==0},e.fromSegments=function(t){return new e(new fe(t.slice()))},e.fromPathString=function(t){return new e(fe.fromString(t))},e.EMPTY=new e(new fe([])),e}(),ye=function(){function e(e,t){this.key=e,this.version=t}return e.compareByKey=function(e,t){return me.comparator(e.key,t.key)},e}(),ge=function(e){function t(t,n,r,i){var o=e.call(this,t,n)||this;return o.data=r,o.hasLocalMutations=!!i.hasLocalMutations,o.hasCommittedMutations=!!i.hasCommittedMutations,o}return i.__extends(t,e),t.prototype.field=function(e){return this.data.field(e)},t.prototype.fieldValue=function(e){var t=this.field(e);return t?t.value():void 0},t.prototype.value=function(){return this.data.value()},t.prototype.isEqual=function(e){return e instanceof t&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.data.isEqual(e.data)&&this.hasLocalMutations===e.hasLocalMutations&&this.hasCommittedMutations===e.hasCommittedMutations},t.prototype.toString=function(){return\"Document(\"+this.key+\", \"+this.version+\", \"+this.data.toString()+\", {hasLocalMutations: \"+this.hasLocalMutations+\"}), {hasCommittedMutations: \"+this.hasCommittedMutations+\"})\"},Object.defineProperty(t.prototype,\"hasPendingWrites\",{get:function(){return this.hasLocalMutations||this.hasCommittedMutations},enumerable:!0,configurable:!0}),t.compareByField=function(e,t,n){var r=t.field(e),i=n.field(e);return void 0!==r&&void 0!==i?r.compareTo(i):d(\"Trying to compare documents on fields that don't exist\")},t}(ye),ve=function(e){function t(t,n,r){var i=e.call(this,t,n)||this;return i.hasCommittedMutations=!(!r||!r.hasCommittedMutations),i}return i.__extends(t,e),t.prototype.toString=function(){return\"NoDocument(\"+this.key+\", \"+this.version+\")\"},Object.defineProperty(t.prototype,\"hasPendingWrites\",{get:function(){return this.hasCommittedMutations},enumerable:!0,configurable:!0}),t.prototype.isEqual=function(e){return e instanceof t&&e.hasCommittedMutations===this.hasCommittedMutations&&e.version.isEqual(this.version)&&e.key.isEqual(this.key)},t}(ye),we=function(e){function t(t,n){return e.call(this,t,n)||this}return i.__extends(t,e),t.prototype.toString=function(){return\"UnknownDocument(\"+this.key+\", \"+this.version+\")\"},Object.defineProperty(t.prototype,\"hasPendingWrites\",{get:function(){return!0},enumerable:!0,configurable:!0}),t.prototype.isEqual=function(e){return e instanceof t&&e.version.isEqual(this.version)&&e.key.isEqual(this.key)},t}(ye),be=function(){function e(e,t){this.comparator=e,this.root=t||Te.EMPTY}return e.prototype.insert=function(t,n){return new e(this.comparator,this.root.insert(t,n,this.comparator).copy(null,null,Te.BLACK,null,null))},e.prototype.remove=function(t){return new e(this.comparator,this.root.remove(t,this.comparator).copy(null,null,Te.BLACK,null,null))},e.prototype.get=function(e){for(var t=this.root;!t.isEmpty();){var n=this.comparator(e,t.key);if(0===n)return t.value;n<0?t=t.left:n>0&&(t=t.right)}return null},e.prototype.indexOf=function(e){for(var t=0,n=this.root;!n.isEmpty();){var r=this.comparator(e,n.key);if(0===r)return t+n.left.size;r<0?n=n.left:(t+=n.left.size+1,n=n.right)}return-1},e.prototype.isEmpty=function(){return this.root.isEmpty()},Object.defineProperty(e.prototype,\"size\",{get:function(){return this.root.size},enumerable:!0,configurable:!0}),e.prototype.minKey=function(){return this.root.minKey()},e.prototype.maxKey=function(){return this.root.maxKey()},e.prototype.inorderTraversal=function(e){return this.root.inorderTraversal(e)},e.prototype.forEach=function(e){this.inorderTraversal(function(t,n){return e(t,n),!1})},e.prototype.reverseTraversal=function(e){return this.root.reverseTraversal(e)},e.prototype.getIterator=function(){return new Se(this.root,null,this.comparator,!1)},e.prototype.getIteratorFrom=function(e){return new Se(this.root,e,this.comparator,!1)},e.prototype.getReverseIterator=function(){return new Se(this.root,null,this.comparator,!0)},e.prototype.getReverseIteratorFrom=function(e){return new Se(this.root,e,this.comparator,!0)},e.prototype[Symbol.iterator]=function(){var e=this.getIterator();return{next:function(){return e.hasNext()?{done:!1,value:e.getNext()}:{done:!0,value:{}}}}},e}(),Se=function(){function e(e,t,n,r){this.isReverse=r,this.nodeStack=[];for(var i=1;!e.isEmpty();)if(i=t?n(e.key,t):1,r&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(0===i){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}return e.prototype.getNext=function(){p(this.nodeStack.length>0,\"getNext() called on iterator when hasNext() is false.\");var e=this.nodeStack.pop(),t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t},e.prototype.hasNext=function(){return this.nodeStack.length>0},e.prototype.peek=function(){if(0===this.nodeStack.length)return null;var e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}},e}(),Te=function(){function e(t,n,r,i,o){this.key=t,this.value=n,this.color=null!=r?r:e.RED,this.left=null!=i?i:e.EMPTY,this.right=null!=o?o:e.EMPTY,this.size=this.left.size+1+this.right.size}return e.prototype.copy=function(t,n,r,i,o){return new e(null!=t?t:this.key,null!=n?n:this.value,null!=r?r:this.color,null!=i?i:this.left,null!=o?o:this.right)},e.prototype.isEmpty=function(){return!1},e.prototype.inorderTraversal=function(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)},e.prototype.reverseTraversal=function(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)},e.prototype.min=function(){return this.left.isEmpty()?this:this.left.min()},e.prototype.minKey=function(){return this.min().key},e.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},e.prototype.insert=function(e,t,n){var r=this,i=n(e,r.key);return(r=i<0?r.copy(null,null,null,r.left.insert(e,t,n),null):0===i?r.copy(null,t,null,null,null):r.copy(null,null,null,null,r.right.insert(e,t,n))).fixUp()},e.prototype.removeMin=function(){if(this.left.isEmpty())return e.EMPTY;var t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),(t=t.copy(null,null,null,t.left.removeMin(),null)).fixUp()},e.prototype.remove=function(t,n){var r,i=this;if(n(t,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(t,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(t,i.key)){if(i.right.isEmpty())return e.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(t,n))}return i.fixUp()},e.prototype.isRed=function(){return this.color},e.prototype.fixUp=function(){var e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e},e.prototype.moveRedLeft=function(){var e=this.colorFlip();return e.right.left.isRed()&&(e=(e=(e=e.copy(null,null,null,null,e.right.rotateRight())).rotateLeft()).colorFlip()),e},e.prototype.moveRedRight=function(){var e=this.colorFlip();return e.left.left.isRed()&&(e=(e=e.rotateRight()).colorFlip()),e},e.prototype.rotateLeft=function(){var t=this.copy(null,null,e.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)},e.prototype.rotateRight=function(){var t=this.copy(null,null,e.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)},e.prototype.colorFlip=function(){var e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)},e.prototype.checkMaxDepth=function(){var e=this.check();return Math.pow(2,e)<=this.size+1},e.prototype.check=function(){if(this.isRed()&&this.left.isRed())throw d(\"Red node has red child(\"+this.key+\",\"+this.value+\")\");if(this.right.isRed())throw d(\"Right child of (\"+this.key+\",\"+this.value+\") is red\");var e=this.left.check();if(e!==this.right.check())throw d(\"Black depths differ\");return e+(this.isRed()?0:1)},e.EMPTY=null,e.RED=!0,e.BLACK=!1,e}(),Ee=function(){function e(){this.size=0}return e.prototype.copy=function(e,t,n,r,i){return this},e.prototype.insert=function(e,t,n){return new Te(e,t)},e.prototype.remove=function(e,t){return this},e.prototype.isEmpty=function(){return!0},e.prototype.inorderTraversal=function(e){return!1},e.prototype.reverseTraversal=function(e){return!1},e.prototype.minKey=function(){return null},e.prototype.maxKey=function(){return null},e.prototype.isRed=function(){return!1},e.prototype.checkMaxDepth=function(){return!0},e.prototype.check=function(){return 0},e}();Te.EMPTY=new Ee,function(e){e[e.NullValue=0]=\"NullValue\",e[e.BooleanValue=1]=\"BooleanValue\",e[e.NumberValue=2]=\"NumberValue\",e[e.TimestampValue=3]=\"TimestampValue\",e[e.StringValue=4]=\"StringValue\",e[e.BlobValue=5]=\"BlobValue\",e[e.RefValue=6]=\"RefValue\",e[e.GeoPointValue=7]=\"GeoPointValue\",e[e.ArrayValue=8]=\"ArrayValue\",e[e.ObjectValue=9]=\"ObjectValue\"}(te||(te={})),function(e){e[e.Default=0]=\"Default\",e[e.Estimate=1]=\"Estimate\",e[e.Previous=2]=\"Previous\"}(ne||(ne={}));var Ie=function(){function e(e,t){this.serverTimestampBehavior=e,this.timestampsInSnapshots=t}return e.fromSnapshotOptions=function(t,n){switch(t.serverTimestamps){case\"estimate\":return new e(ne.Estimate,n);case\"previous\":return new e(ne.Previous,n);case\"none\":case void 0:return new e(ne.Default,n);default:return d(\"fromSnapshotOptions() called with invalid options.\")}},e}(),De=function(){function e(){}return e.prototype.toString=function(){var e=this.value();return null===e?\"null\":e.toString()},e.prototype.defaultCompareTo=function(e){return p(this.typeOrder!==e.typeOrder,\"Default compareTo should not be used for values of same type.\"),Y(this.typeOrder,e.typeOrder)},e}(),Ce=function(e){function t(){var t=e.call(this)||this;return t.typeOrder=te.NullValue,t.internalValue=null,t}return i.__extends(t,e),t.prototype.value=function(e){return null},t.prototype.isEqual=function(e){return e instanceof t},t.prototype.compareTo=function(e){return e instanceof t?0:this.defaultCompareTo(e)},t.INSTANCE=new t,t}(De),_e=function(e){function t(t){var n=e.call(this)||this;return n.internalValue=t,n.typeOrder=te.BooleanValue,n}return i.__extends(t,e),t.prototype.value=function(e){return this.internalValue},t.prototype.isEqual=function(e){return e instanceof t&&this.internalValue===e.internalValue},t.prototype.compareTo=function(e){return e instanceof t?Y(this,e):this.defaultCompareTo(e)},t.of=function(e){return e?t.TRUE:t.FALSE},t.TRUE=new t(!0),t.FALSE=new t(!1),t}(De),Ne=function(e){function t(t){var n=e.call(this)||this;return n.internalValue=t,n.typeOrder=te.NumberValue,n}return i.__extends(t,e),t.prototype.value=function(e){return this.internalValue},t.prototype.compareTo=function(e){return e instanceof t?Ae(this.internalValue,e.internalValue):this.defaultCompareTo(e)},t}(De);function Ae(e,t){return e<t?-1:e>t?1:e===t?0:isNaN(e)?isNaN(t)?0:-1:1}function ke(e,t){return e===t?0!==e||1\/e==1\/t:e!=e&&t!=t}var Re=function(e){function t(t){return e.call(this,t)||this}return i.__extends(t,e),t.prototype.isEqual=function(e){return e instanceof t&&ke(this.internalValue,e.internalValue)},t}(Ne),Me=function(e){function t(t){var n=e.call(this,t)||this;return n.internalValue=t,n}return i.__extends(t,e),t.prototype.isEqual=function(e){return e instanceof t&&ke(this.internalValue,e.internalValue)},t.NAN=new t(NaN),t.POSITIVE_INFINITY=new t(1\/0),t.NEGATIVE_INFINITY=new t(-1\/0),t}(Ne),Oe=function(e){function t(t){var n=e.call(this)||this;return n.internalValue=t,n.typeOrder=te.StringValue,n}return i.__extends(t,e),t.prototype.value=function(e){return this.internalValue},t.prototype.isEqual=function(e){return e instanceof t&&this.internalValue===e.internalValue},t.prototype.compareTo=function(e){return e instanceof t?Y(this.internalValue,e.internalValue):this.defaultCompareTo(e)},t}(De),Pe=function(e){function t(t){var n=e.call(this)||this;return n.internalValue=t,n.typeOrder=te.TimestampValue,n}return i.__extends(t,e),t.prototype.value=function(e){return e&&e.timestampsInSnapshots?this.internalValue:this.internalValue.toDate()},t.prototype.isEqual=function(e){return e instanceof t&&this.internalValue.isEqual(e.internalValue)},t.prototype.compareTo=function(e){return e instanceof t?this.internalValue._compareTo(e.internalValue):e instanceof Le?-1:this.defaultCompareTo(e)},t}(De),Le=function(e){function t(t,n){var r=e.call(this)||this;return r.localWriteTime=t,r.previousValue=n,r.typeOrder=te.TimestampValue,r}return i.__extends(t,e),t.prototype.value=function(e){return e&&e.serverTimestampBehavior===ne.Estimate?new Pe(this.localWriteTime).value(e):e&&e.serverTimestampBehavior===ne.Previous&&this.previousValue?this.previousValue.value(e):null},t.prototype.isEqual=function(e){return e instanceof t&&this.localWriteTime.isEqual(e.localWriteTime)},t.prototype.compareTo=function(e){return e instanceof t?this.localWriteTime._compareTo(e.localWriteTime):e instanceof Pe?1:this.defaultCompareTo(e)},t.prototype.toString=function(){return\"<ServerTimestamp localTime=\"+this.localWriteTime.toString()+\">\"},t}(De),xe=function(e){function t(t){var n=e.call(this)||this;return n.internalValue=t,n.typeOrder=te.BlobValue,n}return i.__extends(t,e),t.prototype.value=function(e){return this.internalValue},t.prototype.isEqual=function(e){return e instanceof t&&this.internalValue.isEqual(e.internalValue)},t.prototype.compareTo=function(e){return e instanceof t?this.internalValue._compareTo(e.internalValue):this.defaultCompareTo(e)},t}(De),qe=function(e){function t(t,n){var r=e.call(this)||this;return r.databaseId=t,r.key=n,r.typeOrder=te.RefValue,r}return i.__extends(t,e),t.prototype.value=function(e){return this.key},t.prototype.isEqual=function(e){return e instanceof t&&(this.key.isEqual(e.key)&&this.databaseId.isEqual(e.databaseId))},t.prototype.compareTo=function(e){if(e instanceof t){var n=this.databaseId.compareTo(e.databaseId);return 0!==n?n:me.comparator(this.key,e.key)}return this.defaultCompareTo(e)},t}(De),Fe=function(e){function t(t){var n=e.call(this)||this;return n.internalValue=t,n.typeOrder=te.GeoPointValue,n}return i.__extends(t,e),t.prototype.value=function(e){return this.internalValue},t.prototype.isEqual=function(e){return e instanceof t&&this.internalValue.isEqual(e.internalValue)},t.prototype.compareTo=function(e){return e instanceof t?this.internalValue._compareTo(e.internalValue):this.defaultCompareTo(e)},t}(De),Ve=function(e){function t(t){var n=e.call(this)||this;return n.internalValue=t,n.typeOrder=te.ObjectValue,n}return i.__extends(t,e),t.prototype.value=function(e){var t={};return this.internalValue.inorderTraversal(function(n,r){t[n]=r.value(e)}),t},t.prototype.forEach=function(e){this.internalValue.inorderTraversal(e)},t.prototype.isEqual=function(e){if(e instanceof t){for(var n=this.internalValue.getIterator(),r=e.internalValue.getIterator();n.hasNext()&&r.hasNext();){var i=n.getNext(),o=r.getNext();if(i.key!==o.key||!i.value.isEqual(o.value))return!1}return!n.hasNext()&&!r.hasNext()}return!1},t.prototype.compareTo=function(e){if(e instanceof t){for(var n=this.internalValue.getIterator(),r=e.internalValue.getIterator();n.hasNext()&&r.hasNext();){var i=n.getNext(),o=r.getNext(),a=Y(i.key,o.key)||i.value.compareTo(o.value);if(a)return a}return Y(n.hasNext(),r.hasNext())}return this.defaultCompareTo(e)},t.prototype.set=function(e,n){if(p(!e.isEmpty(),\"Cannot set field for empty path on ObjectValue\"),1===e.length)return this.setChild(e.firstSegment(),n);var r=this.child(e.firstSegment());r instanceof t||(r=t.EMPTY);var i=r.set(e.popFirst(),n);return this.setChild(e.firstSegment(),i)},t.prototype.delete=function(e){if(p(!e.isEmpty(),\"Cannot delete field for empty path on ObjectValue\"),1===e.length)return new t(this.internalValue.remove(e.firstSegment()));var n=this.child(e.firstSegment());if(n instanceof t){var r=n.delete(e.popFirst());return new t(this.internalValue.insert(e.firstSegment(),r))}return this},t.prototype.contains=function(e){return void 0!==this.field(e)},t.prototype.field=function(e){p(!e.isEmpty(),\"Can't get field of empty path\");var n=this;return e.forEach(function(e){n=n instanceof t&&n.internalValue.get(e)||void 0}),n},t.prototype.toString=function(){return JSON.stringify(this.value())},t.prototype.child=function(e){return this.internalValue.get(e)||void 0},t.prototype.setChild=function(e,n){return new t(this.internalValue.insert(e,n))},t.EMPTY=new t(new be(Y)),t}(De),Be=function(e){function t(t){var n=e.call(this)||this;return n.internalValue=t,n.typeOrder=te.ArrayValue,n}return i.__extends(t,e),t.prototype.value=function(e){return this.internalValue.map(function(t){return t.value(e)})},t.prototype.forEach=function(e){this.internalValue.forEach(e)},t.prototype.isEqual=function(e){if(e instanceof t){if(this.internalValue.length!==e.internalValue.length)return!1;for(var n=0;n<this.internalValue.length;n++)if(!this.internalValue[n].isEqual(e.internalValue[n]))return!1;return!0}return!1},t.prototype.compareTo=function(e){if(e instanceof t){for(var n=Math.min(this.internalValue.length,e.internalValue.length),r=0;r<n;r++){var i=this.internalValue[r].compareTo(e.internalValue[r]);if(i)return i}return Y(this.internalValue.length,e.internalValue.length)}return this.defaultCompareTo(e)},t.prototype.toString=function(){return JSON.stringify(this.value())},t}(De),Ue=Number,Qe=Ue.MIN_SAFE_INTEGER||-(Math.pow(2,53)-1),Ke=Ue.MAX_SAFE_INTEGER||Math.pow(2,53)-1,We=Ue.isInteger||function(e){return\"number\"==typeof e&&isFinite(e)&&Math.floor(e)===e};function ze(e){return null==e}function je(e){return We(e)&&e<=Ke&&e>=Qe}var Ge,He=function(){function e(e,t,n,r,i,o){void 0===t&&(t=[]),void 0===n&&(n=[]),void 0===r&&(r=null),void 0===i&&(i=null),void 0===o&&(o=null),this.path=e,this.explicitOrderBy=t,this.filters=n,this.limit=r,this.startAt=i,this.endAt=o,this.memoizedCanonicalId=null,this.memoizedOrderBy=null,this.startAt&&this.assertValidBound(this.startAt),this.endAt&&this.assertValidBound(this.endAt)}return e.atPath=function(t){return new e(t)},Object.defineProperty(e.prototype,\"orderBy\",{get:function(){if(null===this.memoizedOrderBy){var e=this.getInequalityFilterField(),t=this.getFirstOrderByField();if(null!==e&&null===t)e.isKeyField()?this.memoizedOrderBy=[rt]:this.memoizedOrderBy=[new nt(e),rt];else{p(null===e||null!==t&&e.isEqual(t),\"First orderBy should match inequality field.\"),this.memoizedOrderBy=[];for(var n=!1,r=0,i=this.explicitOrderBy;r<i.length;r++){var o=i[r];this.memoizedOrderBy.push(o),o.field.isKeyField()&&(n=!0)}if(!n){var a=this.explicitOrderBy.length>0?this.explicitOrderBy[this.explicitOrderBy.length-1].dir:et.ASCENDING;this.memoizedOrderBy.push(a===et.ASCENDING?rt:it)}}}return this.memoizedOrderBy},enumerable:!0,configurable:!0}),e.prototype.addFilter=function(t){p(null==this.getInequalityFilterField()||!(t instanceof Xe)||!t.isInequality()||t.field.isEqual(this.getInequalityFilterField()),\"Query must only have one inequality field.\"),p(!me.isDocumentKey(this.path),\"No filtering allowed for document query\");var n=this.filters.concat([t]);return new e(this.path,this.explicitOrderBy.slice(),n,this.limit,this.startAt,this.endAt)},e.prototype.addOrderBy=function(t){p(!me.isDocumentKey(this.path),\"No ordering allowed for document query\"),p(!this.startAt&&!this.endAt,\"Bounds must be set after orderBy\");var n=this.explicitOrderBy.concat([t]);return new e(this.path,n,this.filters.slice(),this.limit,this.startAt,this.endAt)},e.prototype.withLimit=function(t){return new e(this.path,this.explicitOrderBy.slice(),this.filters.slice(),t,this.startAt,this.endAt)},e.prototype.withStartAt=function(t){return new e(this.path,this.explicitOrderBy.slice(),this.filters.slice(),this.limit,t,this.endAt)},e.prototype.withEndAt=function(t){return new e(this.path,this.explicitOrderBy.slice(),this.filters.slice(),this.limit,this.startAt,t)},e.prototype.canonicalId=function(){if(null===this.memoizedCanonicalId){var e=this.path.canonicalString();e+=\"|f:\";for(var t=0,n=this.filters;t<n.length;t++){e+=n[t].canonicalId(),e+=\",\"}e+=\"|ob:\";for(var r=0,i=this.orderBy;r<i.length;r++){e+=i[r].canonicalId(),e+=\",\"}ze(this.limit)||(e+=\"|l:\",e+=this.limit),this.startAt&&(e+=\"|lb:\",e+=this.startAt.canonicalId()),this.endAt&&(e+=\"|ub:\",e+=this.endAt.canonicalId()),this.memoizedCanonicalId=e}return this.memoizedCanonicalId},e.prototype.toString=function(){var e=\"Query(\"+this.path.canonicalString();return this.filters.length>0&&(e+=\", filters: [\"+this.filters.join(\", \")+\"]\"),ze(this.limit)||(e+=\", limit: \"+this.limit),this.explicitOrderBy.length>0&&(e+=\", orderBy: [\"+this.explicitOrderBy.join(\", \")+\"]\"),this.startAt&&(e+=\", startAt: \"+this.startAt.canonicalId()),this.endAt&&(e+=\", endAt: \"+this.endAt.canonicalId()),e+\")\"},e.prototype.isEqual=function(e){if(this.limit!==e.limit)return!1;if(this.orderBy.length!==e.orderBy.length)return!1;for(var t=0;t<this.orderBy.length;t++)if(!this.orderBy[t].isEqual(e.orderBy[t]))return!1;if(this.filters.length!==e.filters.length)return!1;for(t=0;t<this.filters.length;t++)if(!this.filters[t].isEqual(e.filters[t]))return!1;return!!this.path.isEqual(e.path)&&(!(null!==this.startAt?!this.startAt.isEqual(e.startAt):null!==e.startAt)&&(null!==this.endAt?this.endAt.isEqual(e.endAt):null===e.endAt))},e.prototype.docComparator=function(e,t){for(var n=!1,r=0,i=this.orderBy;r<i.length;r++){var o=i[r],a=o.compare(e,t);if(0!==a)return a;n=n||o.field.isKeyField()}return p(n,\"orderBy used that doesn't compare on key field\"),0},e.prototype.matches=function(e){return this.matchesAncestor(e)&&this.matchesOrderBy(e)&&this.matchesFilters(e)&&this.matchesBounds(e)},e.prototype.hasLimit=function(){return!ze(this.limit)},e.prototype.getFirstOrderByField=function(){return this.explicitOrderBy.length>0?this.explicitOrderBy[0].field:null},e.prototype.getInequalityFilterField=function(){for(var e=0,t=this.filters;e<t.length;e++){var n=t[e];if(n instanceof Xe&&n.isInequality())return n.field}return null},e.prototype.hasArrayContainsFilter=function(){return void 0!==this.filters.find(function(e){return e instanceof Xe&&e.op===Je.ARRAY_CONTAINS})},e.prototype.isDocumentQuery=function(){return me.isDocumentKey(this.path)&&0===this.filters.length},e.prototype.matchesAncestor=function(e){var t=e.key.path;return me.isDocumentKey(this.path)?this.path.isEqual(t):this.path.isPrefixOf(t)&&this.path.length===t.length-1},e.prototype.matchesOrderBy=function(e){for(var t=0,n=this.explicitOrderBy;t<n.length;t++){var r=n[t];if(!r.field.isKeyField()&&void 0===e.field(r.field))return!1}return!0},e.prototype.matchesFilters=function(e){for(var t=0,n=this.filters;t<n.length;t++){if(!n[t].matches(e))return!1}return!0},e.prototype.matchesBounds=function(e){return!(this.startAt&&!this.startAt.sortsBeforeDocument(this.orderBy,e))&&(!this.endAt||!this.endAt.sortsBeforeDocument(this.orderBy,e))},e.prototype.assertValidBound=function(e){p(e.position.length<=this.orderBy.length,\"Bound is longer than orderBy\")},e}(),Ye=function(){function e(){}return e.create=function(e,t,n){if(n.isEqual(Ce.INSTANCE)){if(t!==Je.EQUAL)throw new v(g.INVALID_ARGUMENT,\"Invalid query. You can only perform equals comparisons on null.\");return new Ze(e)}if(n.isEqual(Me.NAN)){if(t!==Je.EQUAL)throw new v(g.INVALID_ARGUMENT,\"Invalid query. You can only perform equals comparisons on NaN.\");return new $e(e)}return new Xe(e,t,n)},e}(),Je=function(){function e(e){this.name=e}return e.fromString=function(t){switch(t){case\"<\":return e.LESS_THAN;case\"<=\":return e.LESS_THAN_OR_EQUAL;case\"==\":return e.EQUAL;case\">=\":return e.GREATER_THAN_OR_EQUAL;case\">\":return e.GREATER_THAN;case\"array-contains\":return e.ARRAY_CONTAINS;default:return d(\"Unknown relation: \"+t)}},e.prototype.toString=function(){return this.name},e.prototype.isEqual=function(e){return this.name===e.name},e.LESS_THAN=new e(\"<\"),e.LESS_THAN_OR_EQUAL=new e(\"<=\"),e.EQUAL=new e(\"==\"),e.GREATER_THAN=new e(\">\"),e.GREATER_THAN_OR_EQUAL=new e(\">=\"),e.ARRAY_CONTAINS=new e(\"array-contains\"),e}(),Xe=function(e){function t(t,n,r){var i=e.call(this)||this;return i.field=t,i.op=n,i.value=r,i}return i.__extends(t,e),t.prototype.matches=function(e){if(this.field.isKeyField()){p(this.value instanceof qe,\"Comparing on key, but filter value not a RefValue\"),p(this.op!==Je.ARRAY_CONTAINS,\"array-contains queries don't make sense on document keys.\");var t=this.value,n=me.comparator(e.key,t.key);return this.matchesComparison(n)}var r=e.field(this.field);return void 0!==r&&this.matchesValue(r)},t.prototype.matchesValue=function(e){var t=this;return this.op===Je.ARRAY_CONTAINS?e instanceof Be&&void 0!==e.internalValue.find(function(e){return e.isEqual(t.value)}):this.value.typeOrder===e.typeOrder&&this.matchesComparison(e.compareTo(this.value))},t.prototype.matchesComparison=function(e){switch(this.op){case Je.LESS_THAN:return e<0;case Je.LESS_THAN_OR_EQUAL:return e<=0;case Je.EQUAL:return 0===e;case Je.GREATER_THAN:return e>0;case Je.GREATER_THAN_OR_EQUAL:return e>=0;default:return d(\"Unknown relation op\"+this.op)}},t.prototype.isInequality=function(){return this.op!==Je.EQUAL&&this.op!==Je.ARRAY_CONTAINS},t.prototype.canonicalId=function(){return this.field.canonicalString()+this.op.toString()+this.value.toString()},t.prototype.isEqual=function(e){return e instanceof t&&(this.op.isEqual(e.op)&&this.field.isEqual(e.field)&&this.value.isEqual(e.value))},t.prototype.toString=function(){return this.field.canonicalString()+\" \"+this.op+\" \"+this.value.value()},t}(Ye),Ze=function(e){function t(t){var n=e.call(this)||this;return n.field=t,n}return i.__extends(t,e),t.prototype.matches=function(e){var t=e.field(this.field);return void 0!==t&&null===t.value()},t.prototype.canonicalId=function(){return this.field.canonicalString()+\" IS null\"},t.prototype.toString=function(){return this.field.canonicalString()+\" IS null\"},t.prototype.isEqual=function(e){return e instanceof t&&this.field.isEqual(e.field)},t}(Ye),$e=function(e){function t(t){var n=e.call(this)||this;return n.field=t,n}return i.__extends(t,e),t.prototype.matches=function(e){var t=e.field(this.field),n=t&&t.value();return\"number\"==typeof n&&isNaN(n)},t.prototype.canonicalId=function(){return this.field.canonicalString()+\" IS NaN\"},t.prototype.toString=function(){return this.field.canonicalString()+\" IS NaN\"},t.prototype.isEqual=function(e){return e instanceof t&&this.field.isEqual(e.field)},t}(Ye),et=function(){function e(e){this.name=e}return e.prototype.toString=function(){return this.name},e.ASCENDING=new e(\"asc\"),e.DESCENDING=new e(\"desc\"),e}(),tt=function(){function e(e,t){this.position=e,this.before=t}return e.prototype.canonicalId=function(){for(var e=this.before?\"b:\":\"a:\",t=0,n=this.position;t<n.length;t++){e+=n[t].toString()}return e},e.prototype.sortsBeforeDocument=function(e,t){p(this.position.length<=e.length,\"Bound has more components than query's orderBy\");for(var n=0,r=0;r<this.position.length;r++){var i=e[r],o=this.position[r];if(i.field.isKeyField())p(o instanceof qe,\"Bound has a non-key value where the key path is being used.\"),n=me.comparator(o.key,t.key);else{var a=t.field(i.field);p(void 0!==a,\"Field should exist since document matched the orderBy already.\"),n=o.compareTo(a)}if(i.dir===et.DESCENDING&&(n*=-1),0!==n)break}return this.before?n<=0:n<0},e.prototype.isEqual=function(e){if(null===e)return!1;if(this.before!==e.before||this.position.length!==e.position.length)return!1;for(var t=0;t<this.position.length;t++){var n=this.position[t],r=e.position[t];return n.isEqual(r)}return!0},e}(),nt=function(){function e(e,t){this.field=e,void 0===t&&(t=et.ASCENDING),this.dir=t,this.isKeyOrderBy=e.isKeyField()}return e.prototype.compare=function(e,t){var n=this.isKeyOrderBy?ge.compareByKey(e,t):ge.compareByField(this.field,e,t);switch(this.dir){case et.ASCENDING:return n;case et.DESCENDING:return-1*n;default:return d(\"Unknown direction: \"+this.dir)}},e.prototype.canonicalId=function(){return this.field.canonicalString()+this.dir.toString()},e.prototype.toString=function(){return this.field.canonicalString()+\" (\"+this.dir+\")\"},e.prototype.isEqual=function(e){return this.dir===e.dir&&this.field.isEqual(e.field)},e}(),rt=new nt(pe.keyField(),et.ASCENDING),it=new nt(pe.keyField(),et.DESCENDING),ot=function(){function e(e){this.timestamp=e}return e.fromMicroseconds=function(t){var n=Math.floor(t\/1e6);return new e(new ae(n,t%1e6*1e3))},e.fromTimestamp=function(t){return new e(t)},e.forDeletedDoc=function(){return e.MIN},e.prototype.compareTo=function(e){return this.timestamp._compareTo(e.timestamp)},e.prototype.isEqual=function(e){return this.timestamp.isEqual(e.timestamp)},e.prototype.toMicroseconds=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds\/1e3},e.prototype.toString=function(){return\"SnapshotVersion(\"+this.timestamp.toString()+\")\"},e.prototype.toTimestamp=function(){return this.timestamp},e.MIN=new e(new ae(0,0)),e}();!function(e){e[e.Listen=0]=\"Listen\",e[e.ExistenceFilterMismatch=1]=\"ExistenceFilterMismatch\",e[e.LimboResolution=2]=\"LimboResolution\"}(Ge||(Ge={}));var at,st=function(){function e(e,t,n,r,i,o){void 0===i&&(i=ot.MIN),void 0===o&&(o=y()),this.query=e,this.targetId=t,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.resumeToken=o}return e.prototype.copy=function(t){return new e(this.query,this.targetId,this.purpose,void 0===t.sequenceNumber?this.sequenceNumber:t.sequenceNumber,void 0===t.snapshotVersion?this.snapshotVersion:t.snapshotVersion,void 0===t.resumeToken?this.resumeToken:t.resumeToken)},e.prototype.isEqual=function(e){return this.targetId===e.targetId&&this.purpose===e.purpose&&this.sequenceNumber===e.sequenceNumber&&this.snapshotVersion.isEqual(e.snapshotVersion)&&this.resumeToken===e.resumeToken&&this.query.isEqual(e.query)},e}(),ut=function(){function e(e){this.fields=e}return e.prototype.covers=function(e){for(var t=0,n=this.fields;t<n.length;t++){if(n[t].isPrefixOf(e))return!0}return!1},e.prototype.isEqual=function(e){return X(this.fields,e.fields)},e}(),ct=function(){function e(e,t){this.field=e,this.transform=t}return e.prototype.isEqual=function(e){return this.field.isEqual(e.field)&&this.transform.isEqual(e.transform)},e}(),ht=function(){return function(e,t){this.version=e,this.transformResults=t}}();!function(e){e[e.Set=0]=\"Set\",e[e.Patch=1]=\"Patch\",e[e.Transform=2]=\"Transform\",e[e.Delete=3]=\"Delete\"}(at||(at={}));var lt=function(){function e(e,t){this.updateTime=e,this.exists=t,p(void 0===e||void 0===t,'Precondition can specify \"exists\" or \"updateTime\" but not both')}return e.exists=function(t){return new e(void 0,t)},e.updateTime=function(t){return new e(t)},Object.defineProperty(e.prototype,\"isNone\",{get:function(){return void 0===this.updateTime&&void 0===this.exists},enumerable:!0,configurable:!0}),e.prototype.isValidFor=function(e){return void 0!==this.updateTime?e instanceof ge&&e.version.isEqual(this.updateTime):void 0!==this.exists?this.exists===e instanceof ge:(p(this.isNone,\"Precondition should be empty\"),!0)},e.prototype.isEqual=function(e){return J(this.updateTime,e.updateTime)&&this.exists===e.exists},e.NONE=new e,e}(),ft=function(){function e(){}return e.prototype.verifyKeyMatches=function(e){null!=e&&p(e.key.isEqual(this.key),\"Can only apply a mutation to a document with the same key\")},e.getPostMutationVersion=function(e){return e instanceof ge?e.version:ot.MIN},e}(),dt=function(e){function t(t,n,r){var i=e.call(this)||this;return i.key=t,i.value=n,i.precondition=r,i.type=at.Set,i}return i.__extends(t,e),t.prototype.applyToRemoteDocument=function(e,t){this.verifyKeyMatches(e),p(null==t.transformResults,\"Transform results received by SetMutation.\");var n=t.version;return new ge(this.key,n,this.value,{hasCommittedMutations:!0})},t.prototype.applyToLocalView=function(e,t,n){if(this.verifyKeyMatches(e),!this.precondition.isValidFor(e))return e;var r=ft.getPostMutationVersion(e);return new ge(this.key,r,this.value,{hasLocalMutations:!0})},t.prototype.isEqual=function(e){return e instanceof t&&this.key.isEqual(e.key)&&this.value.isEqual(e.value)&&this.precondition.isEqual(e.precondition)},t}(ft),pt=function(e){function t(t,n,r,i){var o=e.call(this)||this;return o.key=t,o.data=n,o.fieldMask=r,o.precondition=i,o.type=at.Patch,o}return i.__extends(t,e),t.prototype.applyToRemoteDocument=function(e,t){if(this.verifyKeyMatches(e),p(null==t.transformResults,\"Transform results received by PatchMutation.\"),!this.precondition.isValidFor(e))return new we(this.key,t.version);var n=this.patchDocument(e);return new ge(this.key,t.version,n,{hasCommittedMutations:!0})},t.prototype.applyToLocalView=function(e,t,n){if(this.verifyKeyMatches(e),!this.precondition.isValidFor(e))return e;var r=ft.getPostMutationVersion(e),i=this.patchDocument(e);return new ge(this.key,r,i,{hasLocalMutations:!0})},t.prototype.isEqual=function(e){return e instanceof t&&this.key.isEqual(e.key)&&this.fieldMask.isEqual(e.fieldMask)&&this.precondition.isEqual(e.precondition)},t.prototype.patchDocument=function(e){var t;return t=e instanceof ge?e.data:Ve.EMPTY,this.patchObject(t)},t.prototype.patchObject=function(e){for(var t=0,n=this.fieldMask.fields;t<n.length;t++){var r=n[t];if(!r.isEmpty()){var i=this.data.field(r);e=void 0!==i?e.set(r,i):e.delete(r)}}return e},t}(ft),mt=function(e){function t(t,n){var r=e.call(this)||this;return r.key=t,r.fieldTransforms=n,r.type=at.Transform,r.precondition=lt.exists(!0),r}return i.__extends(t,e),t.prototype.applyToRemoteDocument=function(e,t){if(this.verifyKeyMatches(e),p(null!=t.transformResults,\"Transform results missing for TransformMutation.\"),!this.precondition.isValidFor(e))return new we(this.key,t.version);var n=this.requireDocument(e),r=this.serverTransformResults(e,t.transformResults),i=t.version,o=this.transformObject(n.data,r);return new ge(this.key,i,o,{hasCommittedMutations:!0})},t.prototype.applyToLocalView=function(e,t,n){if(this.verifyKeyMatches(e),!this.precondition.isValidFor(e))return e;var r=this.requireDocument(e),i=this.localTransformResults(n,t),o=this.transformObject(r.data,i);return new ge(this.key,r.version,o,{hasLocalMutations:!0})},t.prototype.isEqual=function(e){return e instanceof t&&this.key.isEqual(e.key)&&X(this.fieldTransforms,e.fieldTransforms)&&this.precondition.isEqual(e.precondition)},t.prototype.requireDocument=function(e){p(e instanceof ge,\"Unknown MaybeDocument type \"+e);var t=e;return p(t.key.isEqual(this.key),\"Can only transform a document with the same key\"),t},t.prototype.serverTransformResults=function(e,t){var n=[];p(this.fieldTransforms.length===t.length,\"server transform result count (\"+t.length+\") should match field transform count (\"+this.fieldTransforms.length+\")\");for(var r=0;r<t.length;r++){var i=this.fieldTransforms[r],o=i.transform,a=null;e instanceof ge&&(a=e.field(i.field)||null),n.push(o.applyToRemoteDocument(a,t[r]))}return n},t.prototype.localTransformResults=function(e,t){for(var n=[],r=0,i=this.fieldTransforms;r<i.length;r++){var o=i[r],a=o.transform,s=null;t instanceof ge&&(s=t.field(o.field)||null),n.push(a.applyToLocalView(s,e))}return n},t.prototype.transformObject=function(e,t){p(t.length===this.fieldTransforms.length,\"TransformResults length mismatch.\");for(var n=0;n<this.fieldTransforms.length;n++){var r=this.fieldTransforms[n].field;e=e.set(r,t[n])}return e},t}(ft),yt=function(e){function t(t,n){var r=e.call(this)||this;return r.key=t,r.precondition=n,r.type=at.Delete,r}return i.__extends(t,e),t.prototype.applyToRemoteDocument=function(e,t){return this.verifyKeyMatches(e),p(null==t.transformResults,\"Transform results received by DeleteMutation.\"),new ve(this.key,t.version,{hasCommittedMutations:!0})},t.prototype.applyToLocalView=function(e,t,n){return this.verifyKeyMatches(e),this.precondition.isValidFor(e)?(e&&p(e.key.isEqual(this.key),\"Can only apply mutation to document with same key\"),new ve(this.key,ot.forDeletedDoc())):e},t.prototype.isEqual=function(e){return e instanceof t&&this.key.isEqual(e.key)&&this.precondition.isEqual(e.precondition)},t}(ft),gt=function(){function e(){}return e.prototype.applyToLocalView=function(e,t){return new Le(t,e)},e.prototype.applyToRemoteDocument=function(e,t){return t},e.prototype.isEqual=function(t){return t instanceof e},e.instance=new e,e}(),vt=function(){function e(e){this.elements=e}return e.prototype.applyToLocalView=function(e,t){return this.apply(e)},e.prototype.applyToRemoteDocument=function(e,t){return this.apply(e)},e.prototype.apply=function(e){for(var t=bt(e),n=function(e){t.find(function(t){return t.isEqual(e)})||t.push(e)},r=0,i=this.elements;r<i.length;r++){n(i[r])}return new Be(t)},e.prototype.isEqual=function(t){return t instanceof e&&X(t.elements,this.elements)},e}(),wt=function(){function e(e){this.elements=e}return e.prototype.applyToLocalView=function(e,t){return this.apply(e)},e.prototype.applyToRemoteDocument=function(e,t){return this.apply(e)},e.prototype.apply=function(e){for(var t=bt(e),n=function(e){t=t.filter(function(t){return!t.isEqual(e)})},r=0,i=this.elements;r<i.length;r++){n(i[r])}return new Be(t)},e.prototype.isEqual=function(t){return t instanceof e&&X(t.elements,this.elements)},e}();function bt(e){return e instanceof Be?e.internalValue.slice():[]}var St,Tt=function(){function e(e){this.count=e}return e.prototype.isEqual=function(e){return e&&e.count===this.count},e}();function Et(e){switch(e){case g.OK:return d(\"Treated status OK as error\");case g.CANCELLED:case g.UNKNOWN:case g.DEADLINE_EXCEEDED:case g.RESOURCE_EXHAUSTED:case g.INTERNAL:case g.UNAVAILABLE:case g.UNAUTHENTICATED:return!1;case g.INVALID_ARGUMENT:case g.NOT_FOUND:case g.ALREADY_EXISTS:case g.PERMISSION_DENIED:case g.FAILED_PRECONDITION:case g.ABORTED:case g.OUT_OF_RANGE:case g.UNIMPLEMENTED:case g.DATA_LOSS:return!0;default:return d(\"Unknown status code: \"+e)}}function It(e){var t=St[e];if(void 0!==t)return Dt(t)}function Dt(e){if(void 0===e)return l(\"GRPC error has no .code\"),g.UNKNOWN;switch(e){case St.OK:return g.OK;case St.CANCELLED:return g.CANCELLED;case St.UNKNOWN:return g.UNKNOWN;case St.DEADLINE_EXCEEDED:return g.DEADLINE_EXCEEDED;case St.RESOURCE_EXHAUSTED:return g.RESOURCE_EXHAUSTED;case St.INTERNAL:return g.INTERNAL;case St.UNAVAILABLE:return g.UNAVAILABLE;case St.UNAUTHENTICATED:return g.UNAUTHENTICATED;case St.INVALID_ARGUMENT:return g.INVALID_ARGUMENT;case St.NOT_FOUND:return g.NOT_FOUND;case St.ALREADY_EXISTS:return g.ALREADY_EXISTS;case St.PERMISSION_DENIED:return g.PERMISSION_DENIED;case St.FAILED_PRECONDITION:return g.FAILED_PRECONDITION;case St.ABORTED:return g.ABORTED;case St.OUT_OF_RANGE:return g.OUT_OF_RANGE;case St.UNIMPLEMENTED:return g.UNIMPLEMENTED;case St.DATA_LOSS:return g.DATA_LOSS;default:return d(\"Unknown status code: \"+e)}}function Ct(e){if(void 0===e)return St.OK;switch(e){case g.OK:return St.OK;case g.CANCELLED:return St.CANCELLED;case g.UNKNOWN:return St.UNKNOWN;case g.DEADLINE_EXCEEDED:return St.DEADLINE_EXCEEDED;case g.RESOURCE_EXHAUSTED:return St.RESOURCE_EXHAUSTED;case g.INTERNAL:return St.INTERNAL;case g.UNAVAILABLE:return St.UNAVAILABLE;case g.UNAUTHENTICATED:return St.UNAUTHENTICATED;case g.INVALID_ARGUMENT:return St.INVALID_ARGUMENT;case g.NOT_FOUND:return St.NOT_FOUND;case g.ALREADY_EXISTS:return St.ALREADY_EXISTS;case g.PERMISSION_DENIED:return St.PERMISSION_DENIED;case g.FAILED_PRECONDITION:return St.FAILED_PRECONDITION;case g.ABORTED:return St.ABORTED;case g.OUT_OF_RANGE:return St.OUT_OF_RANGE;case g.UNIMPLEMENTED:return St.UNIMPLEMENTED;case g.DATA_LOSS:return St.DATA_LOSS;default:return d(\"Unknown status code: \"+e)}}function _t(e){switch(e){case 200:return g.OK;case 400:return g.INVALID_ARGUMENT;case 401:return g.UNAUTHENTICATED;case 403:return g.PERMISSION_DENIED;case 404:return g.NOT_FOUND;case 409:return g.ABORTED;case 416:return g.OUT_OF_RANGE;case 429:return g.RESOURCE_EXHAUSTED;case 499:return g.CANCELLED;case 500:return g.UNKNOWN;case 501:return g.UNIMPLEMENTED;case 503:return g.UNAVAILABLE;case 504:return g.DEADLINE_EXCEEDED;default:return e>=200&&e<300?g.OK:e>=400&&e<500?g.FAILED_PRECONDITION:e>=500&&e<600?g.INTERNAL:g.UNKNOWN}}!function(e){e[e.OK=0]=\"OK\",e[e.CANCELLED=1]=\"CANCELLED\",e[e.UNKNOWN=2]=\"UNKNOWN\",e[e.INVALID_ARGUMENT=3]=\"INVALID_ARGUMENT\",e[e.DEADLINE_EXCEEDED=4]=\"DEADLINE_EXCEEDED\",e[e.NOT_FOUND=5]=\"NOT_FOUND\",e[e.ALREADY_EXISTS=6]=\"ALREADY_EXISTS\",e[e.PERMISSION_DENIED=7]=\"PERMISSION_DENIED\",e[e.UNAUTHENTICATED=16]=\"UNAUTHENTICATED\",e[e.RESOURCE_EXHAUSTED=8]=\"RESOURCE_EXHAUSTED\",e[e.FAILED_PRECONDITION=9]=\"FAILED_PRECONDITION\",e[e.ABORTED=10]=\"ABORTED\",e[e.OUT_OF_RANGE=11]=\"OUT_OF_RANGE\",e[e.UNIMPLEMENTED=12]=\"UNIMPLEMENTED\",e[e.INTERNAL=13]=\"INTERNAL\",e[e.UNAVAILABLE=14]=\"UNAVAILABLE\",e[e.DATA_LOSS=15]=\"DATA_LOSS\"}(St||(St={}));var Nt=function(){function e(e){this.comparator=e,this.data=new be(this.comparator)}return e.fromMapKeys=function(t){var n=new e(t.comparator);return t.forEach(function(e){n=n.add(e)}),n},e.prototype.has=function(e){return null!==this.data.get(e)},e.prototype.first=function(){return this.data.minKey()},e.prototype.last=function(){return this.data.maxKey()},Object.defineProperty(e.prototype,\"size\",{get:function(){return this.data.size},enumerable:!0,configurable:!0}),e.prototype.indexOf=function(e){return this.data.indexOf(e)},e.prototype.forEach=function(e){this.data.inorderTraversal(function(t,n){return e(t),!1})},e.prototype.forEachInRange=function(e,t){for(var n=this.data.getIteratorFrom(e[0]);n.hasNext();){var r=n.getNext();if(this.comparator(r.key,e[1])>=0)return;t(r.key)}},e.prototype.forEachWhile=function(e,t){var n;for(n=void 0!==t?this.data.getIteratorFrom(t):this.data.getIterator();n.hasNext();){if(!e(n.getNext().key))return}},e.prototype.firstAfterOrEqual=function(e){var t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null},e.prototype.add=function(e){return this.copy(this.data.remove(e).insert(e,!0))},e.prototype.delete=function(e){return this.has(e)?this.copy(this.data.remove(e)):this},e.prototype.isEmpty=function(){return this.data.isEmpty()},e.prototype.unionWith=function(e){var t=this;return e.forEach(function(e){t=t.add(e)}),t},e.prototype.isEqual=function(t){if(!(t instanceof e))return!1;if(this.size!==t.size)return!1;for(var n=this.data.getIterator(),r=t.data.getIterator();n.hasNext();){var i=n.getNext().key,o=r.getNext().key;if(0!==this.comparator(i,o))return!1}return!0},e.prototype.toArray=function(){var e=[];return this.forEach(function(t){e.push(t)}),e},e.prototype.toString=function(){var e=[];return this.forEach(function(t){return e.push(t)}),\"SortedSet(\"+e.toString()+\")\"},e.prototype[Symbol.iterator]=function(){var e=this.data.getIterator();return{next:function(){return e.hasNext()?{done:!1,value:e.getNext().key}:{done:!0,value:{}}}}},e.prototype.copy=function(t){var n=new e(this.comparator);return n.data=t,n},e}(),At=new be(me.comparator);function kt(){return At}var Rt=new be(me.comparator);function Mt(){return Rt}var Ot=new be(me.comparator);function Pt(){return Ot}var Lt=new Nt(me.comparator);function xt(){return Lt}var qt=new Nt(Y);function Ft(){return qt}var Vt,Bt,Ut=function(){function e(e){this.comparator=e?function(t,n){return e(t,n)||me.comparator(t.key,n.key)}:function(e,t){return me.comparator(e.key,t.key)},this.keyedMap=Mt(),this.sortedSet=new be(this.comparator)}return e.emptySet=function(t){return new e(t.comparator)},e.prototype.has=function(e){return null!=this.keyedMap.get(e)},e.prototype.get=function(e){return this.keyedMap.get(e)},e.prototype.first=function(){return this.sortedSet.minKey()},e.prototype.last=function(){return this.sortedSet.maxKey()},e.prototype.isEmpty=function(){return this.sortedSet.isEmpty()},e.prototype.indexOf=function(e){var t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1},Object.defineProperty(e.prototype,\"size\",{get:function(){return this.sortedSet.size},enumerable:!0,configurable:!0}),e.prototype.forEach=function(e){this.sortedSet.inorderTraversal(function(t,n){return e(t),!1})},e.prototype.add=function(e){var t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))},e.prototype.delete=function(e){var t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this},e.prototype.isEqual=function(t){if(!(t instanceof e))return!1;if(this.size!==t.size)return!1;for(var n=this.sortedSet.getIterator(),r=t.sortedSet.getIterator();n.hasNext();){var i=n.getNext().key,o=r.getNext().key;if(!i.isEqual(o))return!1}return!0},e.prototype.toString=function(){var e=[];return this.forEach(function(t){e.push(t.toString())}),0===e.length?\"DocumentSet ()\":\"DocumentSet (\\n  \"+e.join(\"  \\n\")+\"\\n)\"},e.prototype.copy=function(t,n){var r=new e;return r.comparator=this.comparator,r.keyedMap=t,r.sortedSet=n,r},e}();!function(e){e[e.Added=0]=\"Added\",e[e.Removed=1]=\"Removed\",e[e.Modified=2]=\"Modified\",e[e.Metadata=3]=\"Metadata\"}(Vt||(Vt={})),function(e){e[e.Local=0]=\"Local\",e[e.Synced=1]=\"Synced\"}(Bt||(Bt={}));var Qt,Kt=function(){function e(){this.changeMap=new be(me.comparator)}return e.prototype.track=function(e){var t=e.doc.key,n=this.changeMap.get(t);n?e.type!==Vt.Added&&n.type===Vt.Metadata?this.changeMap=this.changeMap.insert(t,e):e.type===Vt.Metadata&&n.type!==Vt.Removed?this.changeMap=this.changeMap.insert(t,{type:n.type,doc:e.doc}):e.type===Vt.Modified&&n.type===Vt.Modified?this.changeMap=this.changeMap.insert(t,{type:Vt.Modified,doc:e.doc}):e.type===Vt.Modified&&n.type===Vt.Added?this.changeMap=this.changeMap.insert(t,{type:Vt.Added,doc:e.doc}):e.type===Vt.Removed&&n.type===Vt.Added?this.changeMap=this.changeMap.remove(t):e.type===Vt.Removed&&n.type===Vt.Modified?this.changeMap=this.changeMap.insert(t,{type:Vt.Removed,doc:n.doc}):e.type===Vt.Added&&n.type===Vt.Removed?this.changeMap=this.changeMap.insert(t,{type:Vt.Modified,doc:e.doc}):d(\"unsupported combination of changes: \"+JSON.stringify(e)+\" after \"+JSON.stringify(n)):this.changeMap=this.changeMap.insert(t,e)},e.prototype.getChanges=function(){var e=[];return this.changeMap.inorderTraversal(function(t,n){e.push(n)}),e},e}(),Wt=function(){function e(e,t,n,r,i,o,a,s){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=o,this.syncStateChanged=a,this.excludesMetadataChanges=s}return e.fromInitialDocuments=function(t,n,r,i){var o=[];return n.forEach(function(e){o.push({type:Vt.Added,doc:e})}),new e(t,n,Ut.emptySet(n),o,r,i,!0,!1)},Object.defineProperty(e.prototype,\"hasPendingWrites\",{get:function(){return!this.mutatedKeys.isEmpty()},enumerable:!0,configurable:!0}),e.prototype.isEqual=function(e){if(!(this.fromCache===e.fromCache&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&this.query.isEqual(e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;var t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(var r=0;r<t.length;r++)if(t[r].type!==n[r].type||!t[r].doc.isEqual(n[r].doc))return!1;return!0},e}(),zt=function(){function e(e,t,n,r,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}return e.createSynthesizedRemoteEventForCurrentChange=function(t,n){var r,i=((r={})[t]=jt.createSynthesizedTargetChangeForCurrentChange(t,n),r);return new e(ot.MIN,i,Ft(),kt(),xt())},e}(),jt=function(){function e(e,t,n,r,i){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}return e.createSynthesizedTargetChangeForCurrentChange=function(t,n){return new e(y(),n,xt(),xt(),xt())},e}(),Gt=function(){return function(e,t,n,r){this.updatedTargetIds=e,this.removedTargetIds=t,this.key=n,this.newDoc=r}}(),Ht=function(){return function(e,t){this.targetId=e,this.existenceFilter=t}}();!function(e){e[e.NoChange=0]=\"NoChange\",e[e.Added=1]=\"Added\",e[e.Removed=2]=\"Removed\",e[e.Current=3]=\"Current\",e[e.Reset=4]=\"Reset\"}(Qt||(Qt={}));var Yt=function(){return function(e,t,n,r){void 0===n&&(n=y()),void 0===r&&(r=null),this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}}(),Jt=function(){function e(){this.pendingResponses=0,this.documentChanges=$t(),this._resumeToken=y(),this._current=!1,this._hasPendingChanges=!0}return Object.defineProperty(e.prototype,\"current\",{get:function(){return this._current},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,\"resumeToken\",{get:function(){return this._resumeToken},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,\"isPending\",{get:function(){return 0!==this.pendingResponses},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,\"hasPendingChanges\",{get:function(){return this._hasPendingChanges},enumerable:!0,configurable:!0}),e.prototype.updateResumeToken=function(e){e.length>0&&(this._hasPendingChanges=!0,this._resumeToken=e)},e.prototype.toTargetChange=function(){var e=xt(),t=xt(),n=xt();return this.documentChanges.forEach(function(r,i){switch(i){case Vt.Added:e=e.add(r);break;case Vt.Modified:t=t.add(r);break;case Vt.Removed:n=n.add(r);break;default:d(\"Encountered invalid change type: \"+i)}}),new jt(this._resumeToken,this._current,e,t,n)},e.prototype.clearPendingChanges=function(){this._hasPendingChanges=!1,this.documentChanges=$t()},e.prototype.addDocumentChange=function(e,t){this._hasPendingChanges=!0,this.documentChanges=this.documentChanges.insert(e,t)},e.prototype.removeDocumentChange=function(e){this._hasPendingChanges=!0,this.documentChanges=this.documentChanges.remove(e)},e.prototype.recordPendingTargetRequest=function(){this.pendingResponses+=1},e.prototype.recordTargetResponse=function(){this.pendingResponses-=1},e.prototype.markCurrent=function(){this._hasPendingChanges=!0,this._current=!0},e}(),Xt=function(){function e(e){this.metadataProvider=e,this.targetStates={},this.pendingDocumentUpdates=kt(),this.pendingDocumentTargetMapping=Zt(),this.pendingTargetResets=new Nt(Y)}return e.prototype.handleDocumentChange=function(e){for(var t=0,n=e.updatedTargetIds;t<n.length;t++){var r=n[t];e.newDoc instanceof ge?this.addDocumentToTarget(r,e.newDoc):e.newDoc instanceof ve&&this.removeDocumentFromTarget(r,e.key,e.newDoc)}for(var i=0,o=e.removedTargetIds;i<o.length;i++){r=o[i];this.removeDocumentFromTarget(r,e.key,e.newDoc)}},e.prototype.handleTargetChange=function(e){var t=this;this.forEachTarget(e,function(n){var r=t.ensureTargetState(n);switch(e.state){case Qt.NoChange:t.isActiveTarget(n)&&r.updateResumeToken(e.resumeToken);break;case Qt.Added:r.recordTargetResponse(),r.isPending||r.clearPendingChanges(),r.updateResumeToken(e.resumeToken);break;case Qt.Removed:r.recordTargetResponse(),r.isPending||t.removeTarget(n),p(!e.cause,\"WatchChangeAggregator does not handle errored targets\");break;case Qt.Current:t.isActiveTarget(n)&&(r.markCurrent(),r.updateResumeToken(e.resumeToken));break;case Qt.Reset:t.isActiveTarget(n)&&(t.resetTarget(n),r.updateResumeToken(e.resumeToken));break;default:d(\"Unknown target watch change state: \"+e.state)}})},e.prototype.forEachTarget=function(e,t){e.targetIds.length>0?e.targetIds.forEach(t):T(this.targetStates,t)},e.prototype.handleExistenceFilter=function(e){var t=e.targetId,n=e.existenceFilter.count,r=this.queryDataForActiveTarget(t);if(r){var i=r.query;if(i.isDocumentQuery())if(0===n){var o=new me(i.path);this.removeDocumentFromTarget(t,o,new ve(o,ot.forDeletedDoc()))}else p(1===n,\"Single document existence filter with count: \"+n);else this.getCurrentDocumentCountForTarget(t)!==n&&(this.resetTarget(t),this.pendingTargetResets=this.pendingTargetResets.add(t))}},e.prototype.createRemoteEvent=function(e){var t=this,n={};T(this.targetStates,function(r,i){var o=t.queryDataForActiveTarget(r);if(o){if(i.current&&o.query.isDocumentQuery()){var a=new me(o.query.path);null!==t.pendingDocumentUpdates.get(a)||t.targetContainsDocument(r,a)||t.removeDocumentFromTarget(r,a,new ve(a,e))}i.hasPendingChanges&&(n[r]=i.toTargetChange(),i.clearPendingChanges())}});var r=xt();this.pendingDocumentTargetMapping.forEach(function(e,n){var i=!0;n.forEachWhile(function(e){var n=t.queryDataForActiveTarget(e);return!n||n.purpose===Ge.LimboResolution||(i=!1,!1)}),i&&(r=r.add(e))});var i=new zt(e,n,this.pendingTargetResets,this.pendingDocumentUpdates,r);return this.pendingDocumentUpdates=kt(),this.pendingDocumentTargetMapping=Zt(),this.pendingTargetResets=new Nt(Y),i},e.prototype.addDocumentToTarget=function(e,t){if(this.isActiveTarget(e)){var n=this.targetContainsDocument(e,t.key)?Vt.Modified:Vt.Added;this.ensureTargetState(e).addDocumentChange(t.key,n),this.pendingDocumentUpdates=this.pendingDocumentUpdates.insert(t.key,t),this.pendingDocumentTargetMapping=this.pendingDocumentTargetMapping.insert(t.key,this.ensureDocumentTargetMapping(t.key).add(e))}},e.prototype.removeDocumentFromTarget=function(e,t,n){if(this.isActiveTarget(e)){var r=this.ensureTargetState(e);this.targetContainsDocument(e,t)?r.addDocumentChange(t,Vt.Removed):r.removeDocumentChange(t),this.pendingDocumentTargetMapping=this.pendingDocumentTargetMapping.insert(t,this.ensureDocumentTargetMapping(t).delete(e)),n&&(this.pendingDocumentUpdates=this.pendingDocumentUpdates.insert(t,n))}},e.prototype.removeTarget=function(e){delete this.targetStates[e]},e.prototype.getCurrentDocumentCountForTarget=function(e){var t=this.ensureTargetState(e).toTargetChange();return this.metadataProvider.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size},e.prototype.recordPendingTargetRequest=function(e){this.ensureTargetState(e).recordPendingTargetRequest()},e.prototype.ensureTargetState=function(e){return this.targetStates[e]||(this.targetStates[e]=new Jt),this.targetStates[e]},e.prototype.ensureDocumentTargetMapping=function(e){var t=this.pendingDocumentTargetMapping.get(e);return t||(t=new Nt(Y),this.pendingDocumentTargetMapping=this.pendingDocumentTargetMapping.insert(e,t)),t},e.prototype.isActiveTarget=function(e){return null!==this.queryDataForActiveTarget(e)},e.prototype.queryDataForActiveTarget=function(e){var t=this.targetStates[e];return t&&t.isPending?null:this.metadataProvider.getQueryDataForTarget(e)},e.prototype.resetTarget=function(e){var t=this;p(!this.targetStates[e].isPending,\"Should only reset active targets\"),this.targetStates[e]=new Jt,this.metadataProvider.getRemoteKeysForTarget(e).forEach(function(n){t.removeDocumentFromTarget(e,n,null)})},e.prototype.targetContainsDocument=function(e,t){return this.metadataProvider.getRemoteKeysForTarget(e).has(t)},e}();function Zt(){return new be(me.comparator)}function $t(){return new be(me.comparator)}var en=function(){var e={};return e[et.ASCENDING.name]=\"ASCENDING\",e[et.DESCENDING.name]=\"DESCENDING\",e}(),tn=function(){var e={};return e[Je.LESS_THAN.name]=\"LESS_THAN\",e[Je.LESS_THAN_OR_EQUAL.name]=\"LESS_THAN_OR_EQUAL\",e[Je.GREATER_THAN.name]=\"GREATER_THAN\",e[Je.GREATER_THAN_OR_EQUAL.name]=\"GREATER_THAN_OR_EQUAL\",e[Je.EQUAL.name]=\"EQUAL\",e[Je.ARRAY_CONTAINS.name]=\"ARRAY_CONTAINS\",e}(),nn=new RegExp(\/^\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d(?:\\.(\\d+))?Z$\/);function rn(e,t){p(!ze(e),t+\" is missing\")}function on(e){return\"number\"==typeof e?e:\"string\"==typeof e?Number(e):d(\"can't parse \"+e)}var an=function(){function e(e,t){this.databaseId=e,this.options=t}return e.prototype.emptyByteString=function(){return this.options.useProto3Json?\"\":new Uint8Array(0)},e.prototype.unsafeCastProtoByteString=function(e){return e},e.prototype.fromRpcStatus=function(e){var t=void 0===e.code?g.UNKNOWN:Dt(e.code);return new v(t,e.message||\"\")},e.prototype.toInt32Value=function(e){return ze(e)?void 0:{value:e}},e.prototype.fromInt32Value=function(e){var t;return ze(t=\"object\"==typeof e?e.value:e)?null:t},e.prototype.toTimestamp=function(e){return{seconds:e.seconds,nanos:e.nanoseconds}},e.prototype.fromTimestamp=function(e){if(\"string\"==typeof e)return this.fromIso8601String(e);p(!!e,\"Cannot deserialize null or undefined timestamp.\");var t=on(e.seconds||\"0\"),n=e.nanos||0;return new ae(t,n)},e.prototype.fromIso8601String=function(e){var t=0,n=nn.exec(e);if(p(!!n,\"invalid timestamp: \"+e),n[1]){var r=n[1];r=(r+\"000000000\").substr(0,9),t=Number(r)}var i=new Date(e),o=Math.floor(i.getTime()\/1e3);return new ae(o,t)},e.prototype.toBytes=function(e){return this.options.useProto3Json?e.toBase64():this.unsafeCastProtoByteString(e.toUint8Array())},e.prototype.fromBlob=function(e){return\"string\"==typeof e?(p(this.options.useProto3Json,\"Expected bytes to be passed in as Uint8Array, but got a string instead.\"),re.fromBase64String(e)):(p(!this.options.useProto3Json,\"Expected bytes to be passed in as string, but got something else instead.\"),re.fromUint8Array(e))},e.prototype.toVersion=function(e){return this.toTimestamp(e.toTimestamp())},e.prototype.fromVersion=function(e){return p(!!e,\"Trying to deserialize version that isn't set\"),ot.fromTimestamp(this.fromTimestamp(e))},e.prototype.toResourceName=function(e,t){return this.fullyQualifiedPrefixPath(e).child(\"documents\").child(t).canonicalString()},e.prototype.fromResourceName=function(e){var t=fe.fromString(e);return p(this.isValidResourceName(t),\"Tried to deserialize invalid key \"+t.toString()),t},e.prototype.toName=function(e){return this.toResourceName(this.databaseId,e.path)},e.prototype.fromName=function(e){var t=this.fromResourceName(e);return p(t.get(1)===this.databaseId.projectId,\"Tried to deserialize key from different project: \"+t.get(1)+\" vs \"+this.databaseId.projectId),p(!t.get(3)&&!this.databaseId.database||t.get(3)===this.databaseId.database,\"Tried to deserialize key from different database: \"+t.get(3)+\" vs \"+this.databaseId.database),new me(this.extractLocalPathFromResourceName(t))},e.prototype.toQueryPath=function(e){return 0===e.length?this.encodedDatabaseId:this.toResourceName(this.databaseId,e)},e.prototype.fromQueryPath=function(e){var t=this.fromResourceName(e);return 4===t.length?fe.EMPTY_PATH:this.extractLocalPathFromResourceName(t)},Object.defineProperty(e.prototype,\"encodedDatabaseId\",{get:function(){return new fe([\"projects\",this.databaseId.projectId,\"databases\",this.databaseId.database]).canonicalString()},enumerable:!0,configurable:!0}),e.prototype.fullyQualifiedPrefixPath=function(e){return new fe([\"projects\",e.projectId,\"databases\",e.database])},e.prototype.extractLocalPathFromResourceName=function(e){return p(e.length>4&&\"documents\"===e.get(4),\"tried to deserialize invalid key \"+e.toString()),e.popFirst(5)},e.prototype.isValidResourceName=function(e){return e.length>=4&&\"projects\"===e.get(0)&&\"databases\"===e.get(2)},e.prototype.toValue=function(e){if(e instanceof Ce)return{nullValue:\"NULL_VALUE\"};if(e instanceof _e)return{booleanValue:e.value()};if(e instanceof Re)return{integerValue:\"\"+e.value()};if(e instanceof Me){var t=e.value();if(this.options.useProto3Json){if(isNaN(t))return{doubleValue:\"NaN\"};if(t===1\/0)return{doubleValue:\"Infinity\"};if(t===-1\/0)return{doubleValue:\"-Infinity\"}}return{doubleValue:e.value()}}return e instanceof Oe?{stringValue:e.value()}:e instanceof Ve?{mapValue:this.toMapValue(e)}:e instanceof Be?{arrayValue:this.toArrayValue(e)}:e instanceof Pe?{timestampValue:this.toTimestamp(e.internalValue)}:e instanceof Fe?{geoPointValue:{latitude:e.value().latitude,longitude:e.value().longitude}}:e instanceof xe?{bytesValue:this.toBytes(e.value())}:e instanceof qe?{referenceValue:this.toResourceName(e.databaseId,e.key.path)}:d(\"Unknown FieldValue \"+JSON.stringify(e))},e.prototype.fromValue=function(e){var t=this,n=e.value_type;if(sn(e,n,\"nullValue\"))return Ce.INSTANCE;if(sn(e,n,\"booleanValue\"))return _e.of(e.booleanValue);if(sn(e,n,\"integerValue\"))return new Re(on(e.integerValue));if(sn(e,n,\"doubleValue\")){if(this.options.useProto3Json){if(\"NaN\"===e.doubleValue)return Me.NAN;if(\"Infinity\"===e.doubleValue)return Me.POSITIVE_INFINITY;if(\"-Infinity\"===e.doubleValue)return Me.NEGATIVE_INFINITY}return new Me(e.doubleValue)}if(sn(e,n,\"stringValue\"))return new Oe(e.stringValue);if(sn(e,n,\"mapValue\"))return this.fromFields(e.mapValue.fields||{});if(sn(e,n,\"arrayValue\")){rn(e.arrayValue,\"arrayValue\");var r=e.arrayValue.values||[];return new Be(r.map(function(e){return t.fromValue(e)}))}if(sn(e,n,\"timestampValue\"))return rn(e.timestampValue,\"timestampValue\"),new Pe(this.fromTimestamp(e.timestampValue));if(sn(e,n,\"geoPointValue\")){rn(e.geoPointValue,\"geoPointValue\");var i=e.geoPointValue.latitude||0,o=e.geoPointValue.longitude||0;return new Fe(new oe(i,o))}if(sn(e,n,\"bytesValue\")){rn(e.bytesValue,\"bytesValue\");var a=this.fromBlob(e.bytesValue);return new xe(a)}if(sn(e,n,\"referenceValue\")){rn(e.referenceValue,\"referenceValue\");var s=this.fromResourceName(e.referenceValue),u=new ce(s.get(1),s.get(3)),c=new me(this.extractLocalPathFromResourceName(s));return new qe(u,c)}return d(\"Unknown Value proto \"+JSON.stringify(e))},e.prototype.toMutationDocument=function(e,t){return{name:this.toName(e),fields:this.toFields(t)}},e.prototype.toDocument=function(e){return p(!e.hasLocalMutations,\"Can't serialize documents with mutations.\"),{name:this.toName(e.key),fields:this.toFields(e.data),updateTime:this.toTimestamp(e.version.toTimestamp())}},e.prototype.fromDocument=function(e,t){return new ge(this.fromName(e.name),this.fromVersion(e.updateTime),this.fromFields(e.fields||{}),{hasCommittedMutations:!!t})},e.prototype.toFields=function(e){var t=this,n={};return e.forEach(function(e,r){n[e]=t.toValue(r)}),n},e.prototype.fromFields=function(e){var t=this,n=e,r=Ve.EMPTY;return I(n,function(e,n){r=r.set(new pe([e]),t.fromValue(n))}),r},e.prototype.toMapValue=function(e){return{fields:this.toFields(e)}},e.prototype.toArrayValue=function(e){var t=this,n=[];return e.forEach(function(e){n.push(t.toValue(e))}),{values:n}},e.prototype.fromFound=function(e){p(!!e.found,\"Tried to deserialize a found document from a missing document.\"),rn(e.found.name,\"doc.found.name\"),rn(e.found.updateTime,\"doc.found.updateTime\");var t=this.fromName(e.found.name),n=this.fromVersion(e.found.updateTime),r=this.fromFields(e.found.fields||{});return new ge(t,n,r,{})},e.prototype.fromMissing=function(e){p(!!e.missing,\"Tried to deserialize a missing document from a found document.\"),p(!!e.readTime,\"Tried to deserialize a missing document without a read time.\");var t=this.fromName(e.missing),n=this.fromVersion(e.readTime);return new ve(t,n)},e.prototype.fromMaybeDocument=function(e){var t=e.result;return sn(e,t,\"found\")?this.fromFound(e):sn(e,t,\"missing\")?this.fromMissing(e):d(\"invalid batch get response: \"+JSON.stringify(e))},e.prototype.toWatchTargetChangeState=function(e){switch(e){case Qt.Added:return\"ADD\";case Qt.Current:return\"CURRENT\";case Qt.NoChange:return\"NO_CHANGE\";case Qt.Removed:return\"REMOVE\";case Qt.Reset:return\"RESET\";default:return d(\"Unknown WatchTargetChangeState: \"+e)}},e.prototype.toTestWatchChange=function(e){if(e instanceof Ht)return{filter:{count:e.existenceFilter.count,targetId:e.targetId}};if(e instanceof Gt){if(e.newDoc instanceof ge){var t=e.newDoc;return{documentChange:{document:{name:this.toName(t.key),fields:this.toFields(t.data),updateTime:this.toVersion(t.version)},targetIds:e.updatedTargetIds,removedTargetIds:e.removedTargetIds}}}if(e.newDoc instanceof ve){t=e.newDoc;return{documentDelete:{document:this.toName(t.key),readTime:this.toVersion(t.version),removedTargetIds:e.removedTargetIds}}}if(null===e.newDoc)return{documentRemove:{document:this.toName(e.key),removedTargetIds:e.removedTargetIds}}}if(e instanceof Yt){var n=void 0;return e.cause&&(n={code:Ct(e.cause.code),message:e.cause.message}),{targetChange:{targetChangeType:this.toWatchTargetChangeState(e.state),targetIds:e.targetIds,resumeToken:this.unsafeCastProtoByteString(e.resumeToken),cause:n}}}return d(\"Unrecognized watch change: \"+JSON.stringify(e))},e.prototype.fromWatchChange=function(e){var t,n=e.response_type;if(sn(e,n,\"targetChange\")){rn(e.targetChange,\"targetChange\");var r=this.fromWatchTargetChangeState(e.targetChange.targetChangeType||\"NO_CHANGE\"),i=e.targetChange.targetIds||[],o=e.targetChange.resumeToken||this.emptyByteString(),a=e.targetChange.cause,s=a&&this.fromRpcStatus(a);t=new Yt(r,i,o,s||null)}else if(sn(e,n,\"documentChange\")){rn(e.documentChange,\"documentChange\"),rn(e.documentChange.document,\"documentChange.name\"),rn(e.documentChange.document.name,\"documentChange.document.name\"),rn(e.documentChange.document.updateTime,\"documentChange.document.updateTime\");var u=e.documentChange,c=this.fromName(u.document.name),h=this.fromVersion(u.document.updateTime),l=this.fromFields(u.document.fields||{}),f=new ge(c,h,l,{}),p=u.targetIds||[],m=u.removedTargetIds||[];t=new Gt(p,m,f.key,f)}else if(sn(e,n,\"documentDelete\")){rn(e.documentDelete,\"documentDelete\"),rn(e.documentDelete.document,\"documentDelete.document\");var y=e.documentDelete;c=this.fromName(y.document),h=y.readTime?this.fromVersion(y.readTime):ot.forDeletedDoc(),f=new ve(c,h),m=y.removedTargetIds||[];t=new Gt([],m,f.key,f)}else if(sn(e,n,\"documentRemove\")){rn(e.documentRemove,\"documentRemove\"),rn(e.documentRemove.document,\"documentRemove\");var g=e.documentRemove;c=this.fromName(g.document),m=g.removedTargetIds||[];t=new Gt([],m,c,null)}else{if(!sn(e,n,\"filter\"))return d(\"Unknown change type \"+JSON.stringify(e));rn(e.filter,\"filter\"),rn(e.filter.targetId,\"filter.targetId\");var v=e.filter,w=v.count||0,b=new Tt(w),S=v.targetId;t=new Ht(S,b)}return t},e.prototype.fromWatchTargetChangeState=function(e){return\"NO_CHANGE\"===e?Qt.NoChange:\"ADD\"===e?Qt.Added:\"REMOVE\"===e?Qt.Removed:\"CURRENT\"===e?Qt.Current:\"RESET\"===e?Qt.Reset:d(\"Got unexpected TargetChange.state: \"+e)},e.prototype.versionFromListenResponse=function(e){if(!sn(e,e.response_type,\"targetChange\"))return ot.MIN;var t=e.targetChange;return t.targetIds&&t.targetIds.length?ot.MIN:t.readTime?this.fromVersion(t.readTime):ot.MIN},e.prototype.toMutation=function(e){var t,n=this;if(e instanceof dt)t={update:this.toMutationDocument(e.key,e.value)};else if(e instanceof yt)t={delete:this.toName(e.key)};else if(e instanceof pt)t={update:this.toMutationDocument(e.key,e.data),updateMask:this.toDocumentMask(e.fieldMask)};else{if(!(e instanceof mt))return d(\"Unknown mutation type \"+e.type);t={transform:{document:this.toName(e.key),fieldTransforms:e.fieldTransforms.map(function(e){return n.toFieldTransform(e)})}}}return e.precondition.isNone||(t.currentDocument=this.toPrecondition(e.precondition)),t},e.prototype.fromMutation=function(e){var t=this,n=e.currentDocument?this.fromPrecondition(e.currentDocument):lt.NONE;if(e.update){rn(e.update.name,\"name\");var r=this.fromName(e.update.name),i=this.fromFields(e.update.fields||{});if(e.updateMask){var o=this.fromDocumentMask(e.updateMask);return new pt(r,i,o,n)}return new dt(r,i,n)}if(e.delete){r=this.fromName(e.delete);return new yt(r,n)}if(e.transform){r=this.fromName(e.transform.document);var a=e.transform.fieldTransforms.map(function(e){return t.fromFieldTransform(e)});return p(!0===n.exists,'Transforms only support precondition \"exists == true\"'),new mt(r,a)}return d(\"unknown mutation proto: \"+JSON.stringify(e))},e.prototype.toPrecondition=function(e){return p(!e.isNone,\"Can't serialize an empty precondition\"),void 0!==e.updateTime?{updateTime:this.toVersion(e.updateTime)}:void 0!==e.exists?{exists:e.exists}:d(\"Unknown precondition\")},e.prototype.fromPrecondition=function(e){return void 0!==e.updateTime?lt.updateTime(this.fromVersion(e.updateTime)):void 0!==e.exists?lt.exists(e.exists):lt.NONE},e.prototype.fromWriteResult=function(e,t){var n=this,r=e.updateTime?this.fromVersion(e.updateTime):this.fromVersion(t),i=null;return e.transformResults&&e.transformResults.length>0&&(i=e.transformResults.map(function(e){return n.fromValue(e)})),new ht(r,i)},e.prototype.fromWriteResults=function(e,t){var n=this;return e&&e.length>0?(p(void 0!==t,\"Received a write result without a commit time\"),e.map(function(e){return n.fromWriteResult(e,t)})):[]},e.prototype.toFieldTransform=function(e){var t=this,n=e.transform;if(n instanceof gt)return{fieldPath:e.field.canonicalString(),setToServerValue:\"REQUEST_TIME\"};if(n instanceof vt)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:n.elements.map(function(e){return t.toValue(e)})}};if(n instanceof wt)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:n.elements.map(function(e){return t.toValue(e)})}};throw d(\"Unknown transform: \"+e.transform)},e.prototype.fromFieldTransform=function(e){var t=this,n=e.transform_type,r=null;if(sn(e,n,\"setToServerValue\"))p(\"REQUEST_TIME\"===e.setToServerValue,\"Unknown server value transform proto: \"+JSON.stringify(e)),r=gt.instance;else if(sn(e,n,\"appendMissingElements\")){var i=e.appendMissingElements.values||[];r=new vt(i.map(function(e){return t.fromValue(e)}))}else if(sn(e,n,\"removeAllFromArray\")){i=e.removeAllFromArray.values||[];r=new wt(i.map(function(e){return t.fromValue(e)}))}else d(\"Unknown transform proto: \"+JSON.stringify(e));var o=pe.fromServerFormat(e.fieldPath);return new ct(o,r)},e.prototype.toDocumentsTarget=function(e){return{documents:[this.toQueryPath(e.path)]}},e.prototype.fromDocumentsTarget=function(e){var t=e.documents.length;p(1===t,\"DocumentsTarget contained other than 1 document: \"+t);var n=e.documents[0];return He.atPath(this.fromQueryPath(n))},e.prototype.toQueryTarget=function(e){var t={structuredQuery:{}};if(e.path.isEmpty())t.parent=this.toQueryPath(fe.EMPTY_PATH);else{var n=e.path;p(n.length%2!=0,\"Document queries with filters are not supported.\"),t.parent=this.toQueryPath(n.popLast()),t.structuredQuery.from=[{collectionId:n.lastSegment()}]}var r=this.toFilter(e.filters);r&&(t.structuredQuery.where=r);var i=this.toOrder(e.orderBy);i&&(t.structuredQuery.orderBy=i);var o=this.toInt32Value(e.limit);return void 0!==o&&(t.structuredQuery.limit=o),e.startAt&&(t.structuredQuery.startAt=this.toCursor(e.startAt)),e.endAt&&(t.structuredQuery.endAt=this.toCursor(e.endAt)),t},e.prototype.fromQueryTarget=function(e){var t=this.fromQueryPath(e.parent),n=e.structuredQuery,r=n.from?n.from.length:0;if(r>0){p(1===r,\"StructuredQuery.from with more than one collection is not supported.\");var i=n.from[0];t=t.child(i.collectionId)}var o=[];n.where&&(o=this.fromFilter(n.where));var a=[];n.orderBy&&(a=this.fromOrder(n.orderBy));var s=null;n.limit&&(s=this.fromInt32Value(n.limit));var u=null;n.startAt&&(u=this.fromCursor(n.startAt));var c=null;return n.endAt&&(c=this.fromCursor(n.endAt)),new He(t,a,o,s,u,c)},e.prototype.toListenRequestLabels=function(e){var t=this.toLabel(e.purpose);return null==t?null:{\"goog-listen-tags\":t}},e.prototype.toLabel=function(e){switch(e){case Ge.Listen:return null;case Ge.ExistenceFilterMismatch:return\"existence-filter-mismatch\";case Ge.LimboResolution:return\"limbo-document\";default:return d(\"Unrecognized query purpose: \"+e)}},e.prototype.toTarget=function(e){var t,n=e.query;return(t=n.isDocumentQuery()?{documents:this.toDocumentsTarget(n)}:{query:this.toQueryTarget(n)}).targetId=e.targetId,e.resumeToken.length>0&&(t.resumeToken=this.unsafeCastProtoByteString(e.resumeToken)),t},e.prototype.toFilter=function(e){var t=this;if(0!==e.length){var n=e.map(function(e){return e instanceof Xe?t.toRelationFilter(e):t.toUnaryFilter(e)});return 1===n.length?n[0]:{compositeFilter:{op:\"AND\",filters:n}}}},e.prototype.fromFilter=function(e){var t=this;return e?void 0!==e.unaryFilter?[this.fromUnaryFilter(e)]:void 0!==e.fieldFilter?[this.fromRelationFilter(e)]:void 0!==e.compositeFilter?e.compositeFilter.filters.map(function(e){return t.fromFilter(e)}).reduce(function(e,t){return e.concat(t)}):d(\"Unknown filter: \"+JSON.stringify(e)):[]},e.prototype.toOrder=function(e){var t=this;if(0!==e.length)return e.map(function(e){return t.toPropertyOrder(e)})},e.prototype.fromOrder=function(e){var t=this;return e.map(function(e){return t.fromPropertyOrder(e)})},e.prototype.toCursor=function(e){var t=this;return{before:e.before,values:e.position.map(function(e){return t.toValue(e)})}},e.prototype.fromCursor=function(e){var t=this,n=!!e.before,r=e.values.map(function(e){return t.fromValue(e)});return new tt(r,n)},e.prototype.toDirection=function(e){return en[e.name]},e.prototype.fromDirection=function(e){switch(e){case\"ASCENDING\":return et.ASCENDING;case\"DESCENDING\":return et.DESCENDING;default:return}},e.prototype.toOperatorName=function(e){return tn[e.name]},e.prototype.fromOperatorName=function(e){switch(e){case\"EQUAL\":return Je.EQUAL;case\"GREATER_THAN\":return Je.GREATER_THAN;case\"GREATER_THAN_OR_EQUAL\":return Je.GREATER_THAN_OR_EQUAL;case\"LESS_THAN\":return Je.LESS_THAN;case\"LESS_THAN_OR_EQUAL\":return Je.LESS_THAN_OR_EQUAL;case\"ARRAY_CONTAINS\":return Je.ARRAY_CONTAINS;case\"OPERATOR_UNSPECIFIED\":return d(\"Unspecified relation\");default:return d(\"Unknown relation\")}},e.prototype.toFieldPathReference=function(e){return{fieldPath:e.canonicalString()}},e.prototype.fromFieldPathReference=function(e){return pe.fromServerFormat(e.fieldPath)},e.prototype.toPropertyOrder=function(e){return{field:this.toFieldPathReference(e.field),direction:this.toDirection(e.dir)}},e.prototype.fromPropertyOrder=function(e){return new nt(this.fromFieldPathReference(e.field),this.fromDirection(e.direction))},e.prototype.toRelationFilter=function(e){return e instanceof Xe?{fieldFilter:{field:this.toFieldPathReference(e.field),op:this.toOperatorName(e.op),value:this.toValue(e.value)}}:d(\"Unrecognized filter: \"+JSON.stringify(e))},e.prototype.fromRelationFilter=function(e){return new Xe(this.fromFieldPathReference(e.fieldFilter.field),this.fromOperatorName(e.fieldFilter.op),this.fromValue(e.fieldFilter.value))},e.prototype.toUnaryFilter=function(e){return e instanceof $e?{unaryFilter:{field:this.toFieldPathReference(e.field),op:\"IS_NAN\"}}:e instanceof Ze?{unaryFilter:{field:this.toFieldPathReference(e.field),op:\"IS_NULL\"}}:d(\"Unrecognized filter: \"+JSON.stringify(e))},e.prototype.fromUnaryFilter=function(e){switch(e.unaryFilter.op){case\"IS_NAN\":var t=this.fromFieldPathReference(e.unaryFilter.field);return new $e(t);case\"IS_NULL\":var n=this.fromFieldPathReference(e.unaryFilter.field);return new Ze(n);case\"OPERATOR_UNSPECIFIED\":return d(\"Unspecified filter\");default:return d(\"Unknown filter\")}},e.prototype.toDocumentMask=function(e){return{fieldPaths:e.fields.map(function(e){return e.canonicalString()})}},e.prototype.fromDocumentMask=function(e){var t=(e.fieldPaths||[]).map(function(e){return pe.fromServerFormat(e)});return new ut(t)},e}();function sn(e,t,n){return t===n||!t&&n in e}var un=function(){return\"object\"==typeof navigator&&\"ReactNative\"===navigator.product},cn=\"FirebaseError\",hn=Error.captureStackTrace,ln=function(){return function(e,t){if(this.code=e,this.message=t,hn)hn(this,fn.prototype.create);else try{throw Error.apply(this,arguments)}catch(e){this.name=cn,Object.defineProperty(this,\"stack\",{get:function(){return e.stack}})}}}();ln.prototype=Object.create(Error.prototype),ln.prototype.constructor=ln,ln.prototype.name=cn;var fn=function(){function e(e,t,n){this.service=e,this.serviceName=t,this.errors=n,this.pattern=\/\\{\\$([^}]+)}\/g}return e.prototype.create=function(e,t){void 0===t&&(t={});var n,r=this.errors[e],i=this.service+\"\/\"+e;n=void 0===r?\"Error\":r.replace(this.pattern,function(e,n){var r=t[n];return void 0!==r?r.toString():\"<\"+n+\"?>\"}),n=this.serviceName+\": \"+n+\" (\"+i+\").\";var o=new ln(i,n);for(var a in t)t.hasOwnProperty(a)&&\"_\"!==a.slice(-1)&&(o[a]=t[a]);return o},e}(),dn=function(){return function(){this.blockSize=-1}}(),pn=function(e){function t(){var t=e.call(this)||this;t.chain_=[],t.buf_=[],t.W_=[],t.pad_=[],t.inbuf_=0,t.total_=0,t.blockSize=64,t.pad_[0]=128;for(var n=1;n<t.blockSize;++n)t.pad_[n]=0;return t.reset(),t}return i.__extends(t,e),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(e,t){t||(t=0);var n=this.W_;if(\"string\"==typeof e)for(var r=0;r<16;r++)n[r]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(r=0;r<16;r++)n[r]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],t+=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(e,t){if(null!=e){void 0===t&&(t=e.length);for(var n=t-this.blockSize,r=0,i=this.buf_,o=this.inbuf_;r<t;){if(0==o)for(;r<=n;)this.compress_(e,r),r+=this.blockSize;if(\"string\"==typeof e){for(;r<t;)if(i[o]=e.charCodeAt(r),++r,++o==this.blockSize){this.compress_(i),o=0;break}}else for(;r<t;)if(i[o]=e[r],++r,++o==this.blockSize){this.compress_(i),o=0;break}}this.inbuf_=o,this.total_+=t}},t.prototype.digest=function(){var e=[],t=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&t,t\/=256;this.compress_(this.buf_);var r=0;for(n=0;n<5;n++)for(var i=24;i>=0;i-=8)e[r]=this.chain_[n]>>i&255,++r;return e},t}(dn),mn=function(){function e(e){this.sendFn=e.sendFn,this.closeFn=e.closeFn}return e.prototype.onOpen=function(e){p(!this.wrappedOnOpen,\"Called onOpen on stream twice!\"),this.wrappedOnOpen=e},e.prototype.onClose=function(e){p(!this.wrappedOnClose,\"Called onClose on stream twice!\"),this.wrappedOnClose=e},e.prototype.onMessage=function(e){p(!this.wrappedOnMessage,\"Called onMessage on stream twice!\"),this.wrappedOnMessage=e},e.prototype.close=function(){this.closeFn()},e.prototype.send=function(e){this.sendFn(e)},e.prototype.callOnOpen=function(){p(void 0!==this.wrappedOnOpen,\"Cannot call onOpen because no callback was set\"),this.wrappedOnOpen()},e.prototype.callOnClose=function(e){p(void 0!==this.wrappedOnClose,\"Cannot call onClose because no callback was set\"),this.wrappedOnClose(e)},e.prototype.callOnMessage=function(e){p(void 0!==this.wrappedOnMessage,\"Cannot call onMessage because no callback was set\"),this.wrappedOnMessage(e)},e}(),yn=\"Connection\",gn=\"google.firestore.v1beta1.Firestore\",vn=\"v1beta1\",wn={BatchGetDocuments:\"batchGet\",Commit:\"commit\"},bn=\"gl-js\/ fire\/\"+a,Sn=15,Tn=function(){function e(e){this.databaseId=e.databaseId,this.pool=new o.XhrIoPool;var t=e.ssl?\"https\":\"http\";this.baseUrl=t+\":\/\/\"+e.host}return e.prototype.modifyHeadersForRequest=function(e,t){if(t)for(var n in t.authHeaders)t.authHeaders.hasOwnProperty(n)&&(e[n]=t.authHeaders[n]);e[\"X-Goog-Api-Client\"]=bn},e.prototype.invokeRPC=function(e,t,n){var r=this,i=this.makeUrl(e);return new Promise(function(a,s){r.pool.getObject(function(u){u.listenOnce(o.EventType.COMPLETE,function(){try{switch(u.getLastErrorCode()){case o.ErrorCode.NO_ERROR:var t=u.getResponseJson();h(yn,\"XHR received:\",JSON.stringify(t)),a(t);break;case o.ErrorCode.TIMEOUT:h(yn,'RPC \"'+e+'\" timed out'),s(new v(g.DEADLINE_EXCEEDED,\"Request time out\"));break;case o.ErrorCode.HTTP_ERROR:var n=u.getStatus();h(yn,'RPC \"'+e+'\" failed with status:',n,\"response text:\",u.getResponseText()),n>0?s(new v(_t(n),\"Server responded with status \"+u.getStatusText())):(h(yn,'RPC \"'+e+'\" failed'),s(new v(g.UNAVAILABLE,\"Connection failed.\")));break;default:d('RPC \"'+e+'\" failed with unanticipated webchannel error '+u.getLastErrorCode()+\": \"+u.getLastError()+\", giving up.\")}}finally{h(yn,'RPC \"'+e+'\" completed.'),r.pool.releaseObject(u)}});var c=JSON.stringify(t);h(yn,\"XHR sending: \",i+\" \"+c);var l={\"Content-Type\":\"text\/plain\"};r.modifyHeadersForRequest(l,n),u.send(i,\"POST\",c,l,Sn)})})},e.prototype.invokeStreamingRPC=function(e,t,n){return this.invokeRPC(e,t,n)},e.prototype.openStream=function(e,t){var n=[this.baseUrl,\"\/\",gn,\"\/\",e,\"\/channel\"],r=o.createWebChannelTransport(),i={backgroundChannelTest:!0,httpSessionIdParam:\"gsessionid\",initMessageHeaders:{},messageUrlParams:{database:\"projects\/\"+this.databaseId.projectId+\"\/databases\/\"+this.databaseId.database},sendRawJson:!0,supportsCrossDomainXhr:!0};this.modifyHeadersForRequest(i.initMessageHeaders,t),un()||(i.httpHeadersOverwriteParam=\"$httpHeaders\");var a=n.join(\"\");h(yn,\"Creating WebChannel: \"+a+\" \"+i);var s=r.createWebChannel(a,i),u=!1,c=!1,l=new mn({sendFn:function(e){c?h(yn,\"Not sending because WebChannel is closed:\",e):(u||(h(yn,\"Opening WebChannel transport.\"),s.open(),u=!0),h(yn,\"WebChannel sending:\",e),s.send(e))},closeFn:function(){return s.close()}}),f=function(e,t){s.listen(e,function(e){try{t(e)}catch(e){setTimeout(function(){throw e},0)}})};return f(o.WebChannel.EventType.OPEN,function(){c||h(yn,\"WebChannel transport opened.\")}),f(o.WebChannel.EventType.CLOSE,function(){c||(c=!0,h(yn,\"WebChannel transport closed\"),l.callOnClose())}),f(o.WebChannel.EventType.ERROR,function(e){c||(c=!0,h(yn,\"WebChannel transport errored:\",e),l.callOnClose(new v(g.UNAVAILABLE,\"The operation could not be completed\")))}),f(o.WebChannel.EventType.MESSAGE,function(e){if(!c){var t=e.data[0];p(!!t,\"Got a webchannel message without data.\");var n=t.error||t[0]&&t[0].error;if(n){h(yn,\"WebChannel received error:\",n);var r=n.status,i=It(r),o=n.message;void 0===i&&(i=g.INTERNAL,o=\"Unknown error status: \"+r+\" with message \"+n.message),c=!0,l.callOnClose(new v(i,o)),s.close()}else h(yn,\"WebChannel received:\",t),l.callOnMessage(t)}}),setTimeout(function(){l.callOnOpen()},0),l},e.prototype.makeUrl=function(e){var t=wn[e];p(void 0!==t,\"Unknown REST mapping for: \"+e);var n=[this.baseUrl,\"\/\",vn];return n.push(\"\/projects\/\"),n.push(this.databaseId.projectId),n.push(\"\/databases\/\"),n.push(this.databaseId.database),n.push(\"\/documents\"),n.push(\":\"),n.push(t),n.join(\"\")},e}(),En=function(){function e(){this.emptyByteString=\"\",this.base64Available=\"undefined\"!=typeof atob}return Object.defineProperty(e.prototype,\"document\",{get:function(){return\"undefined\"!=typeof document?document:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,\"window\",{get:function(){return\"undefined\"!=typeof window?window:null},enumerable:!0,configurable:!0}),e.prototype.loadConnection=function(e){return Promise.resolve(new Tn(e))},e.prototype.newSerializer=function(e){return new an(e,{useProto3Json:!0})},e.prototype.formatJSON=function(e){return JSON.stringify(e)},e.prototype.atob=function(e){return atob(e)},e.prototype.btoa=function(e){return btoa(e)},e}();m.setPlatform(new En);var In,Dn=function(){function e(e,t){var n=this;this.previousValue=e,t&&(t.sequenceNumberHandler=function(e){return n.setPreviousValue(e)},this.writeNewSequenceNumber=function(e){return t.writeSequenceNumber(e)})}return e.prototype.setPreviousValue=function(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue},e.prototype.next=function(){var e=++this.previousValue;return this.writeNewSequenceNumber&&this.writeNewSequenceNumber(e),e},e.INVALID=-1,e}(),Cn=function(){return function(){var e=this;this.promise=new Promise(function(t,n){e.resolve=t,e.reject=n})}}();!function(e){e.All=\"all\",e.ListenStreamIdle=\"listen_stream_idle\",e.ListenStreamConnectionBackoff=\"listen_stream_connection_backoff\",e.WriteStreamIdle=\"write_stream_idle\",e.WriteStreamConnectionBackoff=\"write_stream_connection_backoff\",e.OnlineStateTimeout=\"online_state_timeout\",e.ClientMetadataRefresh=\"client_metadata_refresh\"}(In||(In={}));var _n=function(){function e(e,t,n,r,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new Cn,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.catch=this.deferred.promise.catch.bind(this.deferred.promise),this.deferred.promise.catch(function(e){})}return e.createAndSchedule=function(t,n,r,i,o){var a=new e(t,n,Date.now()+r,i,o);return a.start(r),a},e.prototype.start=function(e){var t=this;this.timerHandle=setTimeout(function(){return t.handleDelayElapsed()},e)},e.prototype.skipDelay=function(){return this.handleDelayElapsed()},e.prototype.cancel=function(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new v(g.CANCELLED,\"Operation cancelled\"+(e?\": \"+e:\"\"))))},e.prototype.handleDelayElapsed=function(){var e=this;this.asyncQueue.enqueueAndForget(function(){return null!==e.timerHandle?(e.clearTimeout(),e.op().then(function(t){return e.deferred.resolve(t)})):Promise.resolve()})},e.prototype.clearTimeout=function(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)},e}(),Nn=function(){function e(){this.tail=Promise.resolve(),this.delayedOperations=[],this.operationInProgress=!1}return e.prototype.enqueueAndForget=function(e){this.enqueue(e)},e.prototype.enqueue=function(e){var t=this;this.verifyNotFailed();var n=this.tail.then(function(){return t.operationInProgress=!0,e().catch(function(e){t.failure=e,t.operationInProgress=!1;var n=e.stack||e.message||\"\";throw l(\"INTERNAL UNHANDLED ERROR: \",n),n.indexOf(\"Firestore Test Simulated Error\")<0&&setTimeout(function(){throw e},0),e}).then(function(e){return t.operationInProgress=!1,e})});return this.tail=n,n},e.prototype.enqueueAfterDelay=function(e,t,n){var r=this;this.verifyNotFailed(),p(t>=0,\"Attempted to schedule an operation with a negative delay of \"+t),p(!this.containsDelayedOperation(e),\"Attempted to schedule multiple operations with timer id \"+e+\".\");var i=_n.createAndSchedule(this,e,t,n,function(e){return r.removeDelayedOperation(e)});return this.delayedOperations.push(i),i},e.prototype.verifyNotFailed=function(){this.failure&&d(\"AsyncQueue is already failed: \"+(this.failure.stack||this.failure.message))},e.prototype.verifyOperationInProgress=function(){p(this.operationInProgress,\"verifyOpInProgress() called when no op in progress on this queue.\")},e.prototype.drain=function(){return this.enqueue(function(){return Promise.resolve()})},e.prototype.containsDelayedOperation=function(e){return this.delayedOperations.findIndex(function(t){return t.timerId===e})>=0},e.prototype.runDelayedOperationsEarly=function(e){var t=this;return this.drain().then(function(){p(e===In.All||t.containsDelayedOperation(e),\"Attempted to drain to missing operation \"+e),t.delayedOperations.sort(function(e,t){return e.targetTimeMs-t.targetTimeMs});for(var n=0,r=t.delayedOperations;n<r.length;n++){var i=r[n];if(i.skipDelay(),e!==In.All&&i.timerId===e)break}return t.drain()})},e.prototype.removeDelayedOperation=function(e){var t=this.delayedOperations.indexOf(e);p(t>=0,\"Delayed operation not found.\"),this.delayedOperations.splice(t,1)},e}(),An=\"\u0001\",kn=\"\u0001\",Rn=\"\u0010\",Mn=\"\u0011\";function On(e){for(var t=\"\",n=0;n<e.length;n++)t.length>0&&(t=Ln(t)),t=Pn(e.get(n),t);return Ln(t)}function Pn(e,t){for(var n=t,r=e.length,i=0;i<r;i++){var o=e.charAt(i);switch(o){case\"\\0\":n+=An+Rn;break;case An:n+=An+Mn;break;default:n+=o}}return n}function Ln(e){return e+An+kn}function xn(e){var t=e.length;if(p(t>=2,\"Invalid path \"+e),2===t)return p(e.charAt(0)===An&&e.charAt(1)===kn,\"Non-empty path \"+e+\" had length 2\"),fe.EMPTY_PATH;for(var n=t-2,r=[],i=\"\",o=0;o<t;){var a=e.indexOf(An,o);switch((a<0||a>n)&&d('Invalid encoded resource path: \"'+e+'\"'),e.charAt(a+1)){case kn:var s=e.substring(o,a),u=void 0;0===i.length?u=s:(u=i+=s,i=\"\"),r.push(u);break;case Rn:i+=e.substring(o,a),i+=\"\\0\";break;case Mn:i+=e.substring(o,a+1);break;default:d('Invalid encoded resource path: \"'+e+'\"')}o=a+2}return new fe(r)}var qn=-1,Fn=function(){function e(e,t,n){this.batchId=e,this.localWriteTime=t,this.mutations=n}return e.prototype.applyToRemoteDocument=function(e,t,n){t&&p(t.key.isEqual(e),\"applyToRemoteDocument: key \"+e+\" should match maybeDoc key\\n        \"+t.key);var r=n.mutationResults;p(r.length===this.mutations.length,\"Mismatch between mutations length\\n      (\"+this.mutations.length+\") and mutation results length\\n      (\"+r.length+\").\");for(var i=0;i<this.mutations.length;i++){var o=this.mutations[i];if(o.key.isEqual(e)){var a=r[i];t=o.applyToRemoteDocument(t,a)}}return t},e.prototype.applyToLocalView=function(e,t){t&&p(t.key.isEqual(e),\"applyToLocalDocument: key \"+e+\" should match maybeDoc key\\n        \"+t.key);for(var n=t,r=0;r<this.mutations.length;r++){var i=this.mutations[r];i.key.isEqual(e)&&(t=i.applyToLocalView(t,n,this.localWriteTime))}return t},e.prototype.keys=function(){for(var e=xt(),t=0,n=this.mutations;t<n.length;t++){var r=n[t];e=e.add(r.key)}return e},e.prototype.isEqual=function(e){return this.batchId===e.batchId&&X(this.mutations,e.mutations)},e.prototype.isTombstone=function(){return 0===this.mutations.length},e.prototype.toTombstone=function(){return new e(this.batchId,this.localWriteTime,[])},e}(),Vn=function(){function e(e,t,n,r,i){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.streamToken=r,this.docVersions=i}return e.from=function(t,n,r,i){p(t.mutations.length===r.length,\"Mutations sent \"+t.mutations.length+\" must equal results received \"+r.length);for(var o=Pt(),a=t.mutations,s=0;s<a.length;s++)o=o.insert(a[s].key,r[s].version);return new e(t,n,r,i,o)},e}(),Bn=function(){function e(e){var t=this;this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(function(e){t.isDone=!0,t.result=e,t.nextCallback&&t.nextCallback(e)},function(e){t.isDone=!0,t.error=e,t.catchCallback&&t.catchCallback(e)})}return e.prototype.catch=function(e){return this.next(void 0,e)},e.prototype.next=function(t,n){var r=this;return this.callbackAttached&&d(\"Called next() or catch() twice for PersistencePromise\"),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(t,this.result):new e(function(e,i){r.nextCallback=function(n){r.wrapSuccess(t,n).next(e,i)},r.catchCallback=function(t){r.wrapFailure(n,t).next(e,i)}})},e.prototype.toPromise=function(){var e=this;return new Promise(function(t,n){e.next(t,n)})},e.prototype.wrapUserFunction=function(t){try{var n=t();return n instanceof e?n:e.resolve(n)}catch(t){return e.reject(t)}},e.prototype.wrapSuccess=function(t,n){return t?this.wrapUserFunction(function(){return t(n)}):e.resolve(n)},e.prototype.wrapFailure=function(t,n){return t?this.wrapUserFunction(function(){return t(n)}):e.reject(n)},e.resolve=function(t){return new e(function(e,n){e(t)})},e.reject=function(t){return new e(function(e,n){n(t)})},e.waitFor=function(t){var n=t[Symbol.iterator]();return new e(function(e,t){for(var r=0,i=0,o=n.next();!o.done;)++r,o.value.next(function(){++i,o.done&&i===r&&e()},function(e){return t(e)}),o=n.next();i===r&&e()})},e.map=function(t){for(var n=[],r=[],i=t[Symbol.iterator](),o=i.next(),a=0,s=function(){var e=o.value,t=a;r.push(e.next(function(e){n[t]=e})),o=i.next(),++a};!o.done;)s();return e.waitFor(r).next(function(){return n})},e.or=function(t){for(var n=e.resolve(!1),r=function(t){n=n.next(function(n){return n?e.resolve(n):t()})},i=0,o=t;i<o.length;i++){r(o[i])}return n},e.forEach=function(e,t){for(var n=e[Symbol.iterator](),r=[],i=n.next();!i.done;){var o=i.value;r.push(t(o)),i=n.next()}return this.waitFor(r)},e}(),Un=function(){function e(e){this.mapKeyFn=e,this.inner={}}return e.prototype.get=function(e){var t=this.mapKeyFn(e),n=this.inner[t];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(a.isEqual(e))return s}},e.prototype.has=function(e){return void 0!==this.get(e)},e.prototype.set=function(e,t){var n=this.mapKeyFn(e),r=this.inner[n];if(void 0!==r){for(var i=0;i<r.length;i++)if(r[i][0].isEqual(e))return void(r[i]=[e,t]);r.push([e,t])}else this.inner[n]=[[e,t]]},e.prototype.delete=function(e){var t=this.mapKeyFn(e),n=this.inner[t];if(void 0===n)return!1;for(var r=0;r<n.length;r++)if(n[r][0].isEqual(e))return 1===n.length?delete this.inner[t]:n.splice(r,1),!0;return!1},e.prototype.forEach=function(e){I(this.inner,function(t,n){for(var r=0,i=n;r<i.length;r++){var o=i[r],a=o[0],s=o[1];e(a,s)}})},e.prototype.isEmpty=function(){return D(this.inner)},e.prototype[Symbol.iterator]=function(){var e=[];return this.forEach(function(t,n){return e.push({key:t,value:n})}),e[Symbol.iterator]()},e}(),Qn=function(){function e(){this.changes=kt(),this.documentSizes=new Un(function(e){return e.toString()})}return e.prototype.addEntry=function(e){var t=this.assertChanges();this.changes=t.insert(e.key,e)},e.prototype.getEntry=function(e,t){var n=this,r=this.assertChanges().get(t);return r?Bn.resolve(r):this.getFromCache(e,t).next(function(e){return null===e?(n.documentSizes.set(t,0),null):(n.documentSizes.set(t,e.size),e.maybeDocument)})},e.prototype.apply=function(e){var t=this.applyChanges(e);return this.changes=null,t},e.prototype.assertChanges=function(){return p(null!==this.changes,\"Changes have already been applied.\"),this.changes},e}(),Kn=\"SimpleDb\",Wn=function(){function e(e){this.db=e}return e.openOrCreate=function(t,n,r){return p(e.isAvailable(),\"IndexedDB not supported in current environment.\"),h(Kn,\"Opening database:\",t),new Bn(function(i,o){var a=window.indexedDB.open(t,n);a.onsuccess=function(t){var n=t.target.result;i(new e(n))},a.onblocked=function(){o(new v(g.FAILED_PRECONDITION,\"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed.\"))},a.onerror=function(e){o(e.target.error)},a.onupgradeneeded=function(e){h(Kn,'Database \"'+t+'\" requires upgrade from version:',e.oldVersion);var n=e.target.result,i=new jn(a.transaction);r.createOrUpgrade(n,i,e.oldVersion,ir).next(function(){h(Kn,\"Database upgrade to version \"+ir+\" complete\")})}}).toPromise()},e.delete=function(e){return h(Kn,\"Removing database:\",e),Hn(window.indexedDB.deleteDatabase(e)).toPromise()},e.isAvailable=function(){if(\"undefined\"==typeof window||null==window.indexedDB)return!1;if(void 0===window.navigator)return!1;var e=window.navigator.userAgent;return!(e.indexOf(\"MSIE \")>0||e.indexOf(\"Trident\/\")>0||e.indexOf(\"Edge\/\")>0)},e.getStore=function(e,t){return e.store(t)},e.prototype.runTransaction=function(e,t,n){var r=jn.open(this.db,e,t),i=n(r).catch(function(e){r.abort(e)}).toPromise();return r.completionPromise.then(function(){return i})},e.prototype.close=function(){this.db.close()},e}(),zn=function(){function e(e){this.dbCursor=e,this.shouldStop=!1,this.nextKey=null}return Object.defineProperty(e.prototype,\"isDone\",{get:function(){return this.shouldStop},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,\"skipToKey\",{get:function(){return this.nextKey},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,\"cursor\",{set:function(e){this.dbCursor=e},enumerable:!0,configurable:!0}),e.prototype.done=function(){this.shouldStop=!0},e.prototype.skip=function(e){this.nextKey=e},e.prototype.delete=function(){return Hn(this.dbCursor.delete())},e}(),jn=function(){function e(e){var t=this;this.transaction=e,this.aborted=!1,this.completionDeferred=new Cn,this.transaction.oncomplete=function(){t.completionDeferred.resolve()},this.transaction.onabort=function(){e.error?t.completionDeferred.reject(e.error):t.completionDeferred.resolve()},this.transaction.onerror=function(e){t.completionDeferred.reject(e.target.error)}}return e.open=function(t,n,r){return new e(t.transaction(r,n))},Object.defineProperty(e.prototype,\"completionPromise\",{get:function(){return this.completionDeferred.promise},enumerable:!0,configurable:!0}),e.prototype.abort=function(e){e&&this.completionDeferred.reject(e),this.aborted||(h(Kn,\"Aborting transaction:\",e?e.message:\"Client-initiated abort\"),this.aborted=!0,this.transaction.abort())},e.prototype.store=function(e){var t=this.transaction.objectStore(e);return p(!!t,\"Object store not part of transaction: \"+e),new Gn(t)},e}(),Gn=function(){function e(e){this.store=e}return e.prototype.put=function(e,t){var n;return void 0!==t?(h(Kn,\"PUT\",this.store.name,e,t),n=this.store.put(t,e)):(h(Kn,\"PUT\",this.store.name,\"<auto-key>\",e),n=this.store.put(e)),Hn(n)},e.prototype.add=function(e){return h(Kn,\"ADD\",this.store.name,e,e),Hn(this.store.add(e))},e.prototype.get=function(e){var t=this;return Hn(this.store.get(e)).next(function(n){return void 0===n&&(n=null),h(Kn,\"GET\",t.store.name,e,n),n})},e.prototype.delete=function(e){return h(Kn,\"DELETE\",this.store.name,e),Hn(this.store.delete(e))},e.prototype.count=function(){return h(Kn,\"COUNT\",this.store.name),Hn(this.store.count())},e.prototype.loadAll=function(e,t){var n=this.cursor(this.options(e,t)),r=[];return this.iterateCursor(n,function(e,t){r.push(t)}).next(function(){return r})},e.prototype.deleteAll=function(e,t){h(Kn,\"DELETE ALL\",this.store.name);var n=this.options(e,t);n.keysOnly=!1;var r=this.cursor(n);return this.iterateCursor(r,function(e,t,n){return n.delete()})},e.prototype.iterate=function(e,t){var n;t?n=e:(n={},t=e);var r=this.cursor(n);return this.iterateCursor(r,t)},e.prototype.iterateSerial=function(e){var t=this.cursor({});return new Bn(function(n,r){t.onerror=function(e){r(e.target.error)},t.onsuccess=function(t){var r=t.target.result;r?e(r.primaryKey,r.value).next(function(e){e?r.continue():n()}):n()}})},e.prototype.iterateCursor=function(e,t){var n=[];return new Bn(function(r,i){e.onerror=function(e){i(e.target.error)},e.onsuccess=function(e){var i=e.target.result;if(i){var o=new zn(i),a=t(i.primaryKey,i.value,o);if(a instanceof Bn){var s=a.catch(function(e){return o.done(),Bn.reject(e)});n.push(s)}o.isDone?r():null===o.skipToKey?i.continue():i.continue(o.skipToKey)}else r()}}).next(function(){return Bn.waitFor(n)})},e.prototype.options=function(e,t){var n=void 0;return void 0!==e&&(\"string\"==typeof e?n=e:(p(void 0===t,\"3rd argument must not be defined if 2nd is a range.\"),t=e)),{index:n,range:t}},e.prototype.cursor=function(e){var t=\"next\";if(e.reverse&&(t=\"prev\"),e.index){var n=this.store.index(e.index);return e.keysOnly?n.openKeyCursor(e.range,t):n.openCursor(e.range,t)}return this.store.openCursor(e.range,t)},e}();function Hn(e){return new Bn(function(t,n){e.onsuccess=function(e){var n=e.target.result;t(n)},e.onerror=function(e){n(e.target.error)}})}var Yn=\"The remote document changelog no longer contains all changes for all local query views. It may be necessary to rebuild these views.\",Jn=function(){function e(e,t){this.serializer=e,this.keepDocumentChangeLog=t,this._lastProcessedDocumentChangeId=0}return Object.defineProperty(e.prototype,\"lastProcessedDocumentChangeId\",{get:function(){return this._lastProcessedDocumentChangeId},enumerable:!0,configurable:!0}),e.prototype.start=function(e){var t=Wn.getStore(e,Cr.store);return this.synchronizeLastDocumentChangeId(t)},e.prototype.addEntries=function(e,t,n){var r=[];if(t.length>0){for(var i=er(e),o=xt(),a=0,s=t;a<s.length;a++){var u=s[a],c=u.key,h=u.doc;r.push(i.put(nr(c),h)),o=o.add(c)}this.keepDocumentChangeLog&&r.push(tr(e).put({changes:this.serializer.toDbResourcePaths(o)})),r.push(this.updateSize(e,n))}return Bn.waitFor(r)},e.prototype.removeEntry=function(e,t){var n=er(e),r=nr(t);return n.get(r).next(function(e){return e?n.delete(r).next(function(){return rr(e)}):Bn.resolve(0)})},e.prototype.getEntry=function(e,t){var n=this;return er(e).get(nr(t)).next(function(e){return e?n.serializer.fromDbRemoteDocument(e):null})},e.prototype.getSizedEntry=function(e,t){var n=this;return er(e).get(nr(t)).next(function(e){return e?{maybeDocument:n.serializer.fromDbRemoteDocument(e),size:rr(e)}:null})},e.prototype.getDocumentsMatchingQuery=function(e,t){var n=this,r=Mt(),i=t.path.toArray(),o=IDBKeyRange.lowerBound(i);return er(e).iterate({range:o},function(e,i,o){var a=n.serializer.fromDbRemoteDocument(i);t.path.isPrefixOf(a.key.path)?a instanceof ge&&t.matches(a)&&(r=r.insert(a.key,a)):o.done()}).next(function(){return r})},e.prototype.getNewDocumentChanges=function(e){var t=this;p(this.keepDocumentChangeLog,\"Can only call getNewDocumentChanges() when document change log is enabled\");var n=xt(),r=kt(),i=IDBKeyRange.lowerBound(this._lastProcessedDocumentChangeId+1),o=!0,a=tr(e);return a.iterate({range:i},function(e,r){if(o&&(o=!1,t._lastProcessedDocumentChangeId+1!==r.id))return t.synchronizeLastDocumentChangeId(a).next(function(){return Bn.reject(new v(g.DATA_LOSS,Yn))});n=n.unionWith(t.serializer.fromDbResourcePaths(r.changes)),t._lastProcessedDocumentChangeId=r.id}).next(function(){var i=[];return n.forEach(function(n){i.push(t.getEntry(e,n).next(function(e){var t=e||new ve(n,ot.forDeletedDoc());r=r.insert(n,t)}))}),Bn.waitFor(i)}).next(function(){return r})},e.prototype.removeDocumentChangesThroughChangeId=function(e,t){var n=IDBKeyRange.upperBound(t);return tr(e).delete(n)},e.prototype.synchronizeLastDocumentChangeId=function(e){var t=this;return this._lastProcessedDocumentChangeId=0,e.iterate({keysOnly:!0,reverse:!0},function(e,n,r){t._lastProcessedDocumentChangeId=e,r.done()})},e.prototype.newChangeBuffer=function(){return new Zn(this)},e.prototype.getSize=function(e){return this.getMetadata(e).next(function(e){return e.byteSize})},e.prototype.getMetadata=function(e){return Xn(e).get(vr.key).next(function(e){return p(!!e,\"Missing document cache metadata\"),e})},e.prototype.setMetadata=function(e,t){return Xn(e).put(vr.key,t)},e.prototype.updateSize=function(e,t){var n=this;return this.getMetadata(e).next(function(r){return r.byteSize+=t,n.setMetadata(e,r)})},e}();function Xn(e){return di.getStore(e,vr.store)}var Zn=function(e){function t(t){var n=e.call(this)||this;return n.documentCache=t,n}return i.__extends(t,e),t.prototype.applyChanges=function(e){var t=this,n=this.assertChanges(),r=0,i=[];return n.forEach(function(e,n){var o=t.documentCache.serializer.toDbRemoteDocument(n),a=t.documentSizes.get(e);p(void 0!==a,\"Attempting to change document \"+e.toString()+\" without having read it first\");var s=rr(o);r+=s-a,i.push({key:e,doc:o})}),this.documentCache.addEntries(e,i,r)},t.prototype.getFromCache=function(e,t){return this.documentCache.getSizedEntry(e,t)},t}(Qn);function $n(e){return e.code===g.DATA_LOSS&&e.message===Yn}function er(e){return di.getStore(e,gr.store)}function tr(e){return di.getStore(e,Cr.store)}function nr(e){return e.path.toArray()}function rr(e){var t;if(e.document)t=e.document;else if(e.unknownDocument)t=e.unknownDocument;else{if(!e.noDocument)throw d(\"Unknown remote document type\");t=e.noDocument}return JSON.stringify(t).length}var ir=6,or=function(){function e(e){this.serializer=e}return e.prototype.createOrUpgrade=function(e,t,n,r){var i=this;p(n<r&&n>=0&&r<=ir,\"Unexpected schema upgrade from v\"+n+\" to v{toVersion}.\"),n<1&&r>=1&&(ur(e),lr(e),Er(e),pr(e));var o=Bn.resolve();return n<3&&r>=3&&(0!==n&&(Ir(e),Er(e)),o=o.next(function(){return Dr(t)})),n<4&&r>=4&&(0!==n&&(o=o.next(function(){return fr(e,t)})),o=o.next(function(){Ar(e),_r(e)})),n<5&&r>=5&&(o=o.next(function(){return i.removeAcknowledgedMutations(t)})),n<6&&r>=6&&(o=o.next(function(){return wr(e),i.addDocumentGlobal(t)})),o},e.prototype.addDocumentGlobal=function(e){var t=0;return e.store(gr.store).iterate(function(e,n){t+=rr(n)}).next(function(){var n=new vr(t);return e.store(vr.store).put(vr.key,n)})},e.prototype.removeAcknowledgedMutations=function(e){var t=this,n=e.store(cr.store),r=e.store(hr.store);return n.loadAll().next(function(n){return Bn.forEach(n,function(n){var i=IDBKeyRange.bound([n.userId,qn],[n.userId,n.lastAcknowledgedBatchId]);return r.loadAll(hr.userMutationsIndex,i).next(function(r){return Bn.forEach(r,function(r){p(r.userId===n.userId,\"Cannot process batch \"+r.batchId+\" from unexpected user\");var i=t.serializer.fromDbMutationBatch(r);return Fr(e,n.userId,i).next()})})})})},e}(),ar=function(){return function(e,t){this.seconds=e,this.nanoseconds=t}}(),sr=function(){function e(e,t,n){this.ownerId=e,this.allowTabSynchronization=t,this.leaseTimestampMs=n}return e.store=\"owner\",e.key=\"owner\",e}();function ur(e){e.createObjectStore(sr.store)}var cr=function(){function e(e,t,n){this.userId=e,this.lastAcknowledgedBatchId=t,this.lastStreamToken=n}return e.store=\"mutationQueues\",e.keyPath=\"userId\",e}(),hr=function(){function e(e,t,n,r){this.userId=e,this.batchId=t,this.localWriteTimeMs=n,this.mutations=r}return e.store=\"mutations\",e.keyPath=\"batchId\",e.userMutationsIndex=\"userMutationsIndex\",e.userMutationsKeyPath=[\"userId\",\"batchId\"],e}();function lr(e){e.createObjectStore(cr.store,{keyPath:cr.keyPath}),e.createObjectStore(hr.store,{keyPath:hr.keyPath,autoIncrement:!0}).createIndex(hr.userMutationsIndex,hr.userMutationsKeyPath,{unique:!0}),e.createObjectStore(dr.store)}function fr(e,t){return t.store(hr.store).loadAll().next(function(n){e.deleteObjectStore(hr.store),e.createObjectStore(hr.store,{keyPath:hr.keyPath,autoIncrement:!0}).createIndex(hr.userMutationsIndex,hr.userMutationsKeyPath,{unique:!0});var r=t.store(hr.store),i=n.map(function(e){return r.put(e)});return Bn.waitFor(i)})}var dr=function(){function e(){}return e.prefixForUser=function(e){return[e]},e.prefixForPath=function(e,t){return[e,On(t)]},e.key=function(e,t,n){return[e,On(t),n]},e.store=\"documentMutations\",e.PLACEHOLDER=new e,e}();function pr(e){e.createObjectStore(gr.store)}var mr=function(){return function(e,t){this.path=e,this.readTime=t}}(),yr=function(){return function(e,t){this.path=e,this.version=t}}(),gr=function(){function e(e,t,n,r){this.unknownDocument=e,this.noDocument=t,this.document=n,this.hasCommittedMutations=r}return e.store=\"remoteDocuments\",e}(),vr=function(){function e(e){this.byteSize=e}return e.store=\"remoteDocumentGlobal\",e.key=\"remoteDocumentGlobalKey\",e}();function wr(e){e.createObjectStore(vr.store)}var br=function(){function e(e,t,n,r,i,o){this.targetId=e,this.canonicalId=t,this.readTime=n,this.resumeToken=r,this.lastListenSequenceNumber=i,this.query=o}return e.store=\"targets\",e.keyPath=\"targetId\",e.queryTargetsIndexName=\"queryTargetsIndex\",e.queryTargetsKeyPath=[\"canonicalId\",\"targetId\"],e}(),Sr=function(){function e(e,t,n){this.targetId=e,this.path=t,this.sequenceNumber=n,p(0===e==(void 0!==n),\"A target-document row must either have targetId == 0 and a defined sequence number, or a non-zero targetId and no sequence number\")}return e.store=\"targetDocuments\",e.keyPath=[\"targetId\",\"path\"],e.documentTargetsIndex=\"documentTargetsIndex\",e.documentTargetsKeyPath=[\"path\",\"targetId\"],e}(),Tr=function(){function e(e,t,n,r){this.highestTargetId=e,this.highestListenSequenceNumber=t,this.lastRemoteSnapshotVersion=n,this.targetCount=r}return e.key=\"targetGlobalKey\",e.store=\"targetGlobal\",e}();function Er(e){e.createObjectStore(Sr.store,{keyPath:Sr.keyPath}).createIndex(Sr.documentTargetsIndex,Sr.documentTargetsKeyPath,{unique:!0}),e.createObjectStore(br.store,{keyPath:br.keyPath}).createIndex(br.queryTargetsIndexName,br.queryTargetsKeyPath,{unique:!0}),e.createObjectStore(Tr.store)}function Ir(e){e.deleteObjectStore(Sr.store),e.deleteObjectStore(br.store),e.deleteObjectStore(Tr.store)}function Dr(e){var t=e.store(Tr.store),n=new Tr(0,0,ot.MIN.toTimestamp(),0);return t.put(Tr.key,n)}var Cr=function(){function e(e){this.changes=e}return e.store=\"remoteDocumentChanges\",e.keyPath=\"id\",e}();function _r(e){e.createObjectStore(Cr.store,{keyPath:\"id\",autoIncrement:!0})}var Nr=function(){function e(e,t,n,r,i){this.clientId=e,this.updateTimeMs=t,this.networkEnabled=n,this.inForeground=r,this.lastProcessedDocumentChangeId=i}return e.store=\"clientMetadata\",e.keyPath=\"clientId\",e}();function Ar(e){e.createObjectStore(Nr.store,{keyPath:Nr.keyPath})}var kr=[cr.store,hr.store,dr.store,gr.store,br.store,sr.store,Tr.store,Sr.store],Rr=kr,Mr=Rr.concat([Nr.store,Cr.store]),Or=Mr.concat([vr.store]),Pr=Or,Lr=function(){function e(e,t,n){this.userId=e,this.serializer=t,this.referenceDelegate=n,this.documentKeysByBatchId={}}return e.forUser=function(t,n,r){return p(\"\"!==t.uid,\"UserID must not be an empty string.\"),new e(t.isAuthenticated()?t.uid:\"\",n,r)},e.prototype.checkEmpty=function(e){var t=!0,n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return Br(e).iterate({index:hr.userMutationsIndex,range:n},function(e,n,r){t=!1,r.done()}).next(function(){return t})},e.prototype.acknowledgeBatch=function(e,t,n){return this.getMutationQueueMetadata(e).next(function(r){var i=t.batchId;return p(i>r.lastAcknowledgedBatchId,\"Mutation batchIDs must be acknowledged in order\"),r.lastAcknowledgedBatchId=i,r.lastStreamToken=Vr(n),Qr(e).put(r)})},e.prototype.getLastStreamToken=function(e){return this.getMutationQueueMetadata(e).next(function(e){return e.lastStreamToken})},e.prototype.setLastStreamToken=function(e,t){return this.getMutationQueueMetadata(e).next(function(n){return n.lastStreamToken=Vr(t),Qr(e).put(n)})},e.prototype.addMutationBatch=function(e,t,n){var r=this,i=Ur(e),o=Br(e);return o.add({}).next(function(e){p(\"number\"==typeof e,\"Auto-generated key is not a number\");var a=new Fn(e,t,n),s=r.serializer.toDbMutationBatch(r.userId,a);r.documentKeysByBatchId[e]=a.keys();for(var u=[],c=0,h=n;c<h.length;c++){var l=h[c],f=dr.key(r.userId,l.key.path,e);u.push(o.put(s)),u.push(i.put(f,dr.PLACEHOLDER))}return Bn.waitFor(u).next(function(){return a})})},e.prototype.lookupMutationBatch=function(e,t){var n=this;return Br(e).get(t).next(function(e){return e?(p(e.userId===n.userId,\"Unexpected user '\"+e.userId+\"' for mutation batch \"+t),n.serializer.fromDbMutationBatch(e)):null})},e.prototype.lookupMutationKeys=function(e,t){var n=this;return this.documentKeysByBatchId[t]?Bn.resolve(this.documentKeysByBatchId[t]):this.lookupMutationBatch(e,t).next(function(e){if(e){var r=e.keys();return n.documentKeysByBatchId[t]=r,r}return null})},e.prototype.getNextMutationBatchAfterBatchId=function(e,t){var n=this;return this.getMutationQueueMetadata(e).next(function(r){var i=Math.max(t,r.lastAcknowledgedBatchId)+1,o=IDBKeyRange.lowerBound([n.userId,i]),a=null;return Br(e).iterate({index:hr.userMutationsIndex,range:o},function(e,t,r){t.userId===n.userId&&(p(t.batchId>=i,\"Should have found mutation after \"+i),a=n.serializer.fromDbMutationBatch(t)),r.done()}).next(function(){return a})})},e.prototype.getAllMutationBatches=function(e){var t=this,n=IDBKeyRange.bound([this.userId,qn],[this.userId,Number.POSITIVE_INFINITY]);return Br(e).loadAll(hr.userMutationsIndex,n).next(function(e){return e.map(function(e){return t.serializer.fromDbMutationBatch(e)})})},e.prototype.getAllMutationBatchesAffectingDocumentKey=function(e,t){var n=this,r=dr.prefixForPath(this.userId,t.path),i=IDBKeyRange.lowerBound(r),o=[];return Ur(e).iterate({range:i},function(r,i,a){var s=r[0],u=r[1],c=r[2],h=xn(u);if(s===n.userId&&t.path.isEqual(h))return Br(e).get(c).next(function(e){if(!e)throw d(\"Dangling document-mutation reference found: \"+r+\" which points to \"+c);p(e.userId===n.userId,\"Unexpected user '\"+e.userId+\"' for mutation batch \"+c),o.push(n.serializer.fromDbMutationBatch(e))});a.done()}).next(function(){return o})},e.prototype.getAllMutationBatchesAffectingDocumentKeys=function(e,t){var n=this,r=new Nt(Y),i=[];return t.forEach(function(t){var o=dr.prefixForPath(n.userId,t.path),a=IDBKeyRange.lowerBound(o),s=Ur(e).iterate({range:a},function(e,i,o){var a=e[0],s=e[1],u=e[2],c=xn(s);a===n.userId&&t.path.isEqual(c)?r=r.add(u):o.done()});i.push(s)}),Bn.waitFor(i).next(function(){return n.lookupMutationBatches(e,r)})},e.prototype.getAllMutationBatchesAffectingQuery=function(e,t){var n=this;p(!t.isDocumentQuery(),\"Document queries shouldn't go down this path\");var r=t.path,i=r.length+1,o=dr.prefixForPath(this.userId,r),a=IDBKeyRange.lowerBound(o),s=new Nt(Y);return Ur(e).iterate({range:a},function(e,t,o){var a=e[0],u=e[1],c=e[2],h=xn(u);a===n.userId&&r.isPrefixOf(h)?h.length===i&&(s=s.add(c)):o.done()}).next(function(){return n.lookupMutationBatches(e,s)})},e.prototype.lookupMutationBatches=function(e,t){var n=this,r=[],i=[];return t.forEach(function(t){i.push(Br(e).get(t).next(function(e){if(null===e)throw d(\"Dangling document-mutation reference found, which points to \"+t);p(e.userId===n.userId,\"Unexpected user '\"+e.userId+\"' for mutation batch \"+t),r.push(n.serializer.fromDbMutationBatch(e))}))}),Bn.waitFor(i).next(function(){return r})},e.prototype.removeMutationBatch=function(e,t){var n=this;return Fr(e.simpleDbTransaction,this.userId,t).next(function(r){return n.removeCachedMutationKeys(t.batchId),Bn.forEach(r,function(t){return n.referenceDelegate.removeMutationReference(e,t)})})},e.prototype.removeCachedMutationKeys=function(e){delete this.documentKeysByBatchId[e]},e.prototype.performConsistencyCheck=function(e){var t=this;return this.checkEmpty(e).next(function(n){if(!n)return Bn.resolve();var r=IDBKeyRange.lowerBound(dr.prefixForUser(t.userId)),i=[];return Ur(e).iterate({range:r},function(e,n,r){if(e[0]===t.userId){var o=xn(e[1]);i.push(o)}else r.done()}).next(function(){p(0===i.length,\"Document leak -- detected dangling mutation references when queue is empty. Dangling keys: \"+i.map(function(e){return e.canonicalString()}))})})},e.prototype.containsKey=function(e,t){return xr(e,this.userId,t)},e.prototype.getMutationQueueMetadata=function(e){var t=this;return Qr(e).get(this.userId).next(function(e){return e||new cr(t.userId,qn,\"\")})},e}();function xr(e,t,n){var r=dr.prefixForPath(t,n.path),i=r[1],o=IDBKeyRange.lowerBound(r),a=!1;return Ur(e).iterate({range:o,keysOnly:!0},function(e,n,r){var o=e[0],s=e[1];e[2];o===t&&s===i&&(a=!0),r.done()}).next(function(){return a})}function qr(e,t){var n=!1;return Qr(e).iterateSerial(function(r){return xr(e,r,t).next(function(e){return e&&(n=!0),Bn.resolve(!e)})}).next(function(){return n})}function Fr(e,t,n){var r=e.store(hr.store),i=e.store(dr.store),o=[],a=IDBKeyRange.only(n.batchId),s=0,u=r.iterate({range:a},function(e,t,n){return s++,n.delete()});o.push(u.next(function(){p(1===s,\"Dangling document-mutation reference found: Missing batch \"+n.batchId)}));for(var c=[],h=0,l=n.mutations;h<l.length;h++){var f=l[h],d=dr.key(t,f.key.path,n.batchId);o.push(i.delete(d)),c.push(f.key)}return Bn.waitFor(o).next(function(){return c})}function Vr(e){return e instanceof Uint8Array?(p(!1,\"Persisting non-string stream tokens is only supported with mock persistence.\"),e.toString()):e}function Br(e){return di.getStore(e,hr.store)}function Ur(e){return di.getStore(e,dr.store)}function Qr(e){return di.getStore(e,cr.store)}var Kr,Wr=1;!function(e){e[e.QueryCache=0]=\"QueryCache\",e[e.SyncEngine=1]=\"SyncEngine\"}(Kr||(Kr={}));var zr=function(){function e(e,t){this.generatorId=e,p((e&Wr)===e,\"Generator ID \"+e+\" contains more than \"+Wr+\" reserved bits\"),this.seek(void 0!==t?t:this.generatorId)}return e.prototype.next=function(){var e=this.nextId;return this.nextId+=1<<Wr,e},e.prototype.after=function(e){return this.seek(e+(1<<Wr)),this.next()},e.prototype.seek=function(e){p((e&Wr)===this.generatorId,\"Cannot supply target ID from different generator ID\"),this.nextId=e},e.forQueryCache=function(){return new e(Kr.QueryCache,2)},e.forSyncEngine=function(){return new e(Kr.SyncEngine)},e}(),jr=function(){function e(e,t){this.referenceDelegate=e,this.serializer=t,this.targetIdGenerator=zr.forQueryCache()}return e.prototype.allocateTargetId=function(e){var t=this;return this.retrieveMetadata(e).next(function(n){return n.highestTargetId=t.targetIdGenerator.after(n.highestTargetId),t.saveMetadata(e,n).next(function(){return n.highestTargetId})})},e.prototype.getLastRemoteSnapshotVersion=function(e){return this.retrieveMetadata(e).next(function(e){return ot.fromTimestamp(new ae(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds))})},e.prototype.getHighestSequenceNumber=function(e){return Jr(e.simpleDbTransaction)},e.prototype.setTargetsMetadata=function(e,t,n){var r=this;return this.retrieveMetadata(e).next(function(i){return i.highestListenSequenceNumber=t,n&&(i.lastRemoteSnapshotVersion=n.toTimestamp()),t>i.highestListenSequenceNumber&&(i.highestListenSequenceNumber=t),r.saveMetadata(e,i)})},e.prototype.addQueryData=function(e,t){var n=this;return this.saveQueryData(e,t).next(function(){return n.retrieveMetadata(e).next(function(r){return r.targetCount+=1,n.updateMetadataFromQueryData(t,r),n.saveMetadata(e,r)})})},e.prototype.updateQueryData=function(e,t){return this.saveQueryData(e,t)},e.prototype.removeQueryData=function(e,t){var n=this;return this.removeMatchingKeysForTargetId(e,t.targetId).next(function(){return Gr(e).delete(t.targetId)}).next(function(){return n.retrieveMetadata(e)}).next(function(t){return p(t.targetCount>0,\"Removing from an empty query cache\"),t.targetCount-=1,n.saveMetadata(e,t)})},e.prototype.removeTargets=function(e,t,n){var r=this,i=0,o=[];return Gr(e).iterate(function(a,s){var u=r.serializer.fromDbTarget(s);u.sequenceNumber<=t&&void 0===n[u.targetId]&&(i++,o.push(r.removeQueryData(e,u)))}).next(function(){return Bn.waitFor(o)}).next(function(){return i})},e.prototype.forEachTarget=function(e,t){var n=this;return Gr(e).iterate(function(e,r){var i=n.serializer.fromDbTarget(r);t(i)})},e.prototype.retrieveMetadata=function(e){return Yr(e.simpleDbTransaction)},e.prototype.saveMetadata=function(e,t){return Hr(e).put(Tr.key,t)},e.prototype.saveQueryData=function(e,t){return Gr(e).put(this.serializer.toDbTarget(t))},e.prototype.updateMetadataFromQueryData=function(e,t){var n=!1;return e.targetId>t.highestTargetId&&(t.highestTargetId=e.targetId,n=!0),e.sequenceNumber>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=e.sequenceNumber,n=!0),n},e.prototype.getQueryCount=function(e){return this.retrieveMetadata(e).next(function(e){return e.targetCount})},e.prototype.getQueryData=function(e,t){var n=this,r=t.canonicalId(),i=IDBKeyRange.bound([r,Number.NEGATIVE_INFINITY],[r,Number.POSITIVE_INFINITY]),o=null;return Gr(e).iterate({range:i,index:br.queryTargetsIndexName},function(e,r,i){var a=n.serializer.fromDbTarget(r);t.isEqual(a.query)&&(o=a,i.done())}).next(function(){return o})},e.prototype.addMatchingKeys=function(e,t,n){var r=this,i=[],o=Xr(e);return t.forEach(function(t){var a=On(t.path);i.push(o.put(new Sr(n,a))),i.push(r.referenceDelegate.addReference(e,t))}),Bn.waitFor(i)},e.prototype.removeMatchingKeys=function(e,t,n){var r=this,i=Xr(e);return Bn.forEach(t,function(t){var o=On(t.path);return Bn.waitFor([i.delete([n,o]),r.referenceDelegate.removeReference(e,t)])})},e.prototype.removeMatchingKeysForTargetId=function(e,t){var n=Xr(e),r=IDBKeyRange.bound([t],[t+1],!1,!0);return n.delete(r)},e.prototype.getMatchingKeysForTargetId=function(e,t){var n=IDBKeyRange.bound([t],[t+1],!1,!0),r=Xr(e),i=xt();return r.iterate({range:n,keysOnly:!0},function(e,t,n){var r=xn(e[1]),o=new me(r);i=i.add(o)}).next(function(){return i})},e.prototype.containsKey=function(e,t){var n=On(t.path),r=IDBKeyRange.bound([n],[Z(n)],!1,!0),i=0;return Xr(e).iterate({index:Sr.documentTargetsIndex,keysOnly:!0,range:r},function(e,t,n){var r=e[0];e[1];0!==r&&(i++,n.done())}).next(function(){return i>0})},e.prototype.getQueryDataForTarget=function(e,t){var n=this;return Gr(e).get(t).next(function(e){return e?n.serializer.fromDbTarget(e):null})},e}();function Gr(e){return di.getStore(e,br.store)}function Hr(e){return di.getStore(e,Tr.store)}function Yr(e){return Wn.getStore(e,Tr.store).get(Tr.key).next(function(e){return p(null!==e,\"Missing metadata row.\"),e})}function Jr(e){return Yr(e).next(function(e){return e.highestListenSequenceNumber})}function Xr(e){return di.getStore(e,Sr.store)}var Zr=function(){function e(e){this.remoteSerializer=e}return e.prototype.fromDbRemoteDocument=function(e){if(e.document)return this.remoteSerializer.fromDocument(e.document,!!e.hasCommittedMutations);if(e.noDocument){var t=me.fromSegments(e.noDocument.path),n=this.fromDbTimestamp(e.noDocument.readTime);return new ve(t,n,{hasCommittedMutations:!!e.hasCommittedMutations})}if(e.unknownDocument){t=me.fromSegments(e.unknownDocument.path),n=this.fromDbTimestamp(e.unknownDocument.version);return new we(t,n)}return d(\"Unexpected DbRemoteDocument\")},e.prototype.toDbRemoteDocument=function(e){if(e instanceof ge){var t=this.remoteSerializer.toDocument(e),n=e.hasCommittedMutations;return new gr(null,null,t,n)}if(e instanceof ve){var r=e.key.path.toArray(),i=this.toDbTimestamp(e.version);n=e.hasCommittedMutations;return new gr(null,new mr(r,i),null,n)}if(e instanceof we){r=e.key.path.toArray(),i=this.toDbTimestamp(e.version);return new gr(new yr(r,i),null,null,!0)}return d(\"Unexpected MaybeDocumment\")},e.prototype.toDbTimestamp=function(e){var t=e.toTimestamp();return new ar(t.seconds,t.nanoseconds)},e.prototype.fromDbTimestamp=function(e){var t=new ae(e.seconds,e.nanoseconds);return ot.fromTimestamp(t)},e.prototype.toDbMutationBatch=function(e,t){var n=this,r=t.mutations.map(function(e){return n.remoteSerializer.toMutation(e)});return new hr(e,t.batchId,t.localWriteTime.toMillis(),r)},e.prototype.fromDbMutationBatch=function(e){var t=this,n=e.mutations.map(function(e){return t.remoteSerializer.fromMutation(e)}),r=ae.fromMillis(e.localWriteTimeMs);return new Fn(e.batchId,r,n)},e.prototype.toDbResourcePaths=function(e){var t=[];return e.forEach(function(e){t.push(On(e.path))}),t},e.prototype.fromDbResourcePaths=function(e){for(var t=xt(),n=0,r=e;n<r.length;n++){var i=r[n];t=t.add(new me(xn(i)))}return t},e.prototype.fromDbTarget=function(e){var t,n=this.fromDbTimestamp(e.readTime);return t=$r(e.query)?this.remoteSerializer.fromDocumentsTarget(e.query):this.remoteSerializer.fromQueryTarget(e.query),new st(t,e.targetId,Ge.Listen,e.lastListenSequenceNumber,n,e.resumeToken)},e.prototype.toDbTarget=function(e){p(Ge.Listen===e.purpose,\"Only queries with purpose \"+Ge.Listen+\" may be stored, got \"+e.purpose);var t,n,r=this.toDbTimestamp(e.snapshotVersion);return t=e.query.isDocumentQuery()?this.remoteSerializer.toDocumentsTarget(e.query):this.remoteSerializer.toQueryTarget(e.query),e.resumeToken instanceof Uint8Array?(p(!1,\"Persisting non-string stream tokens is only supported with mock persistence .\"),n=e.resumeToken.toString()):n=e.resumeToken,new br(e.targetId,e.query.canonicalId(),r,n,e.sequenceNumber,t)},e}();function $r(e){return void 0!==e.documents}function ei(e,t){var n=e[0],r=e[1],i=t[0],o=t[1],a=Y(n,i);return 0===a?Y(r,o):a}var ti=function(){function e(e){this.maxElements=e,this.buffer=new Nt(ei),this.previousIndex=0}return e.prototype.nextIndex=function(){return++this.previousIndex},e.prototype.addElement=function(e){var t=[e,this.nextIndex()];if(this.buffer.size<this.maxElements)this.buffer=this.buffer.add(t);else{var n=this.buffer.last();ei(t,n)<0&&(this.buffer=this.buffer.delete(n).add(t))}},Object.defineProperty(e.prototype,\"maxValue\",{get:function(){return this.buffer.last()[0]},enumerable:!0,configurable:!0}),e}(),ni=function(){function e(e){this.delegate=e}return e.prototype.calculateTargetCount=function(e,t){return this.delegate.getTargetCount(e).next(function(e){return Math.floor(t\/100*e)})},e.prototype.nthSequenceNumber=function(e,t){var n=this;if(0===t)return Bn.resolve(Dn.INVALID);var r=new ti(t);return this.delegate.forEachTarget(e,function(e){return r.addElement(e.sequenceNumber)}).next(function(){return n.delegate.forEachOrphanedDocumentSequenceNumber(e,function(e){return r.addElement(e)})}).next(function(){return r.maxValue})},e.prototype.removeTargets=function(e,t,n){return this.delegate.removeTargets(e,t,n)},e.prototype.removeOrphanedDocuments=function(e,t){return this.delegate.removeOrphanedDocuments(e,t)},e}(),ri=function(){return function(){}}(),ii=\"IndexedDbPersistence\",oi=18e5,ai=5e3,si=4e3,ui=\"The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.\",ci=\"Another tab has exclusive access to the persistence layer. To allow shared access, make sure to invoke `enablePersistence()` with `experimentalTabSynchronization:true` in all tabs.\",hi=\"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.\",li=\"firestore_zombie\",fi=function(e){function t(t,n){var r=e.call(this)||this;return r.simpleDbTransaction=t,r.currentSequenceNumber=n,r}return i.__extends(t,e),t}(ri),di=function(){function e(t,n,r,i,o,a){if(this.persistenceKey=t,this.clientId=n,this.queue=i,this.multiClientParams=a,this._started=!1,this.isPrimary=!1,this.networkEnabled=!0,this.inForeground=!1,this.lastGarbageCollectionTime=Number.NEGATIVE_INFINITY,this.primaryStateListener=function(e){return Promise.resolve()},!e.isAvailable())throw new v(g.UNIMPLEMENTED,hi);if(this.referenceDelegate=new gi(this),this.dbName=t+e.MAIN_DATABASE,this.serializer=new Zr(o),this.document=r.document,this.allowTabSynchronization=void 0!==a,this.queryCache=new jr(this.referenceDelegate,this.serializer),this.remoteDocumentCache=new Jn(this.serializer,this.allowTabSynchronization),!r.window||!r.window.localStorage)throw new v(g.UNIMPLEMENTED,\"IndexedDB persistence is only available on platforms that support LocalStorage.\");this.window=r.window,this.webStorage=this.window.localStorage}return e.getStore=function(e,t){if(e instanceof fi)return Wn.getStore(e.simpleDbTransaction,t);throw d(\"IndexedDbPersistence must use instances of IndexedDbTransaction\")},e.createIndexedDbPersistence=function(t,n,r,o,a){return i.__awaiter(this,void 0,void 0,function(){var s;return i.__generator(this,function(i){switch(i.label){case 0:return[4,(s=new e(t,n,r,o,a)).start()];case 1:return i.sent(),[2,s]}})})},e.createMultiClientIndexedDbPersistence=function(t,n,r,o,a,s){return i.__awaiter(this,void 0,void 0,function(){var u;return i.__generator(this,function(i){switch(i.label){case 0:return[4,(u=new e(t,n,r,o,a,s)).start()];case 1:return i.sent(),[2,u]}})})},e.prototype.start=function(){var e=this;return p(!this.started,\"IndexedDbPersistence double-started!\"),p(null!==this.window,\"Expected 'window' to be defined\"),Wn.openOrCreate(this.dbName,ir,new or(this.serializer)).then(function(t){e.simpleDb=t}).then(function(){return e.startRemoteDocumentCache()}).then(function(){return e.attachVisibilityHandler(),e.attachWindowUnloadHook(),e.updateClientMetadataAndTryBecomePrimary().then(function(){return e.scheduleClientMetadataAndPrimaryLeaseRefreshes()})}).then(function(){return e.simpleDb.runTransaction(\"readonly\",[Tr.store],function(t){return Jr(t).next(function(t){var n=e.multiClientParams?e.multiClientParams.sequenceNumberSyncer:void 0;e.listenSequence=new Dn(t,n)})})}).then(function(){e._started=!0}).catch(function(t){return e.simpleDb&&e.simpleDb.close(),Promise.reject(t)})},e.prototype.startRemoteDocumentCache=function(){var e=this;return this.simpleDb.runTransaction(\"readonly\",Pr,function(t){return e.remoteDocumentCache.start(t)})},e.prototype.setPrimaryStateListener=function(e){var t=this;return this.primaryStateListener=function(n){return i.__awaiter(t,void 0,void 0,function(){return i.__generator(this,function(t){return this.started?[2,e(n)]:[2]})})},e(this.isPrimary)},e.prototype.setNetworkEnabled=function(e){var t=this;this.networkEnabled!==e&&(this.networkEnabled=e,this.queue.enqueueAndForget(function(){return i.__awaiter(t,void 0,void 0,function(){return i.__generator(this,function(e){switch(e.label){case 0:return this.started?[4,this.updateClientMetadataAndTryBecomePrimary()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})}))},e.prototype.updateClientMetadataAndTryBecomePrimary=function(){var e=this;return this.simpleDb.runTransaction(\"readwrite\",Pr,function(t){return yi(t).put(new Nr(e.clientId,Date.now(),e.networkEnabled,e.inForeground,e.remoteDocumentCache.lastProcessedDocumentChangeId)).next(function(){if(e.isPrimary)return e.verifyPrimaryLease(t).next(function(t){t||(e.isPrimary=!1,e.queue.enqueueAndForget(function(){return e.primaryStateListener(!1)}))})}).next(function(){return e.canActAsPrimary(t)}).next(function(n){var r=e.isPrimary;return e.isPrimary=n,r!==e.isPrimary&&e.queue.enqueueAndForget(function(){return e.primaryStateListener(e.isPrimary)}),r&&!e.isPrimary?e.releasePrimaryLeaseIfHeld(t):e.isPrimary?e.acquireOrExtendPrimaryLease(t):void 0})})},e.prototype.verifyPrimaryLease=function(e){var t=this;return mi(e).get(sr.key).next(function(e){return Bn.resolve(t.isLocalClient(e))})},e.prototype.removeClientMetadata=function(e){return yi(e).delete(this.clientId)},e.prototype.maybeGarbageCollectMultiClientState=function(){return i.__awaiter(this,void 0,void 0,function(){var t,n,r=this;return i.__generator(this,function(i){switch(i.label){case 0:return!this.isPrimary||this.isWithinAge(this.lastGarbageCollectionTime,oi)?[3,2]:(this.lastGarbageCollectionTime=Date.now(),n=[],[4,this.runTransaction(\"maybeGarbageCollectMultiClientState\",\"readwrite-primary\",function(i){var o=e.getStore(i,Nr.store);return o.loadAll().next(function(e){t=r.filterActiveClients(e,oi),n=e.filter(function(e){return-1===t.indexOf(e)})}).next(function(){return Bn.forEach(n,function(e){return o.delete(e.clientId)})}).next(function(){if((t=t.filter(function(e){return e.clientId!==r.clientId})).length>0){var e=t.map(function(e){return e.lastProcessedDocumentChangeId||0}),n=Math.min.apply(Math,e);return r.remoteDocumentCache.removeDocumentChangesThroughChangeId(i,n)}})})]);case 1:i.sent(),n.forEach(function(e){r.window.localStorage.removeItem(r.zombiedClientLocalStorageKey(e.clientId))}),i.label=2;case 2:return[2]}})})},e.prototype.scheduleClientMetadataAndPrimaryLeaseRefreshes=function(){var e=this;this.clientMetadataRefresher=this.queue.enqueueAfterDelay(In.ClientMetadataRefresh,si,function(){return e.updateClientMetadataAndTryBecomePrimary().then(function(){return e.maybeGarbageCollectMultiClientState()}).then(function(){return e.scheduleClientMetadataAndPrimaryLeaseRefreshes()})})},e.prototype.isLocalClient=function(e){return!!e&&e.ownerId===this.clientId},e.prototype.canActAsPrimary=function(e){var t=this;return mi(e).get(sr.key).next(function(n){if(null!==n&&t.isWithinAge(n.leaseTimestampMs,ai)&&!t.isClientZombied(n.ownerId)){if(t.isLocalClient(n)&&t.networkEnabled)return!0;if(!t.isLocalClient(n)){if(!n.allowTabSynchronization)throw new v(g.FAILED_PRECONDITION,ci);return!1}}return!(!t.networkEnabled||!t.inForeground)||yi(e).loadAll().next(function(e){return void 0===t.filterActiveClients(e,ai).find(function(e){if(t.clientId!==e.clientId){var n=!t.networkEnabled&&e.networkEnabled,r=!t.inForeground&&e.inForeground,i=t.networkEnabled===e.networkEnabled;if(n||r&&i)return!0}return!1})})}).next(function(e){return t.isPrimary!==e&&h(ii,\"Client \"+(e?\"is\":\"is not\")+\" eligible for a primary lease.\"),e})},e.prototype.shutdown=function(e){return i.__awaiter(this,void 0,void 0,function(){var t=this;return i.__generator(this,function(n){switch(n.label){case 0:return this._started=!1,this.markClientZombied(),this.clientMetadataRefresher&&this.clientMetadataRefresher.cancel(),this.detachVisibilityHandler(),this.detachWindowUnloadHook(),[4,this.simpleDb.runTransaction(\"readwrite\",[sr.store,Nr.store],function(e){return t.releasePrimaryLeaseIfHeld(e).next(function(){return t.removeClientMetadata(e)})})];case 1:return n.sent(),this.simpleDb.close(),this.removeClientZombiedEntry(),e?[4,Wn.delete(this.dbName)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}})})},e.prototype.filterActiveClients=function(e,t){var n=this;return e.filter(function(e){return n.isWithinAge(e.updateTimeMs,t)&&!n.isClientZombied(e.clientId)})},e.prototype.getActiveClients=function(){var e=this;return this.simpleDb.runTransaction(\"readonly\",[Nr.store],function(t){return yi(t).loadAll().next(function(t){return e.filterActiveClients(t,oi).map(function(e){return e.clientId})})})},Object.defineProperty(e.prototype,\"started\",{get:function(){return this._started},enumerable:!0,configurable:!0}),e.prototype.getMutationQueue=function(e){return p(this.started,\"Cannot initialize MutationQueue before persistence is started.\"),Lr.forUser(e,this.serializer,this.referenceDelegate)},e.prototype.getQueryCache=function(){return p(this.started,\"Cannot initialize QueryCache before persistence is started.\"),this.queryCache},e.prototype.getRemoteDocumentCache=function(){return p(this.started,\"Cannot initialize RemoteDocumentCache before persistence is started.\"),this.remoteDocumentCache},e.prototype.runTransaction=function(e,t,n){var r=this;return h(ii,\"Starting transaction:\",e),this.simpleDb.runTransaction(\"readonly\"===t?\"readonly\":\"readwrite\",Pr,function(i){return\"readwrite-primary\"===t?r.verifyPrimaryLease(i).next(function(t){if(!t)throw l(\"Failed to obtain primary lease for action '\"+e+\"'.\"),r.isPrimary=!1,r.queue.enqueueAndForget(function(){return r.primaryStateListener(!1)}),new v(g.FAILED_PRECONDITION,ui);return n(new fi(i,r.listenSequence.next()))}).next(function(e){return r.acquireOrExtendPrimaryLease(i).next(function(){return e})}):r.verifyAllowTabSynchronization(i).next(function(){return n(new fi(i,r.listenSequence.next()))})})},e.prototype.verifyAllowTabSynchronization=function(e){var t=this;return mi(e).get(sr.key).next(function(e){if(null!==e&&t.isWithinAge(e.leaseTimestampMs,ai)&&!t.isClientZombied(e.ownerId)&&!t.isLocalClient(e)&&!e.allowTabSynchronization)throw new v(g.FAILED_PRECONDITION,ci)})},e.prototype.acquireOrExtendPrimaryLease=function(e){var t=new sr(this.clientId,this.allowTabSynchronization,Date.now());return mi(e).put(sr.key,t)},e.isAvailable=function(){return Wn.isAvailable()},e.buildStoragePrefix=function(e){var t=e.databaseId.projectId;return e.databaseId.isDefaultDatabase||(t+=\".\"+e.databaseId.database),\"firestore\/\"+e.persistenceKey+\"\/\"+t+\"\/\"},e.prototype.releasePrimaryLeaseIfHeld=function(e){var t=this,n=mi(e);return n.get(sr.key).next(function(e){return t.isLocalClient(e)?(h(ii,\"Releasing primary lease.\"),n.delete(sr.key)):Bn.resolve()})},e.prototype.isWithinAge=function(e,t){var n=Date.now();return!(e<n-t)&&(!(e>n)||(l(\"Detected an update time that is in the future: \"+e+\" > \"+n),!1))},e.prototype.attachVisibilityHandler=function(){var e=this;null!==this.document&&\"function\"==typeof this.document.addEventListener&&(this.documentVisibilityHandler=function(){e.queue.enqueueAndForget(function(){return e.inForeground=\"visible\"===e.document.visibilityState,e.updateClientMetadataAndTryBecomePrimary()})},this.document.addEventListener(\"visibilitychange\",this.documentVisibilityHandler),this.inForeground=\"visible\"===this.document.visibilityState)},e.prototype.detachVisibilityHandler=function(){this.documentVisibilityHandler&&(p(null!==this.document&&\"function\"==typeof this.document.addEventListener,\"Expected 'document.addEventListener' to be a function\"),this.document.removeEventListener(\"visibilitychange\",this.documentVisibilityHandler),this.documentVisibilityHandler=null)},e.prototype.attachWindowUnloadHook=function(){var e=this;\"function\"==typeof this.window.addEventListener&&(this.windowUnloadHandler=function(){e.markClientZombied(),e.queue.enqueueAndForget(function(){return e.shutdown()})},this.window.addEventListener(\"unload\",this.windowUnloadHandler))},e.prototype.detachWindowUnloadHook=function(){this.windowUnloadHandler&&(p(\"function\"==typeof this.window.removeEventListener,\"Expected 'window.removeEventListener' to be a function\"),this.window.removeEventListener(\"unload\",this.windowUnloadHandler),this.windowUnloadHandler=null)},e.prototype.isClientZombied=function(e){try{var t=null!==this.webStorage.getItem(this.zombiedClientLocalStorageKey(e));return h(ii,\"Client '\"+e+\"' \"+(t?\"is\":\"is not\")+\" zombied in LocalStorage\"),t}catch(e){return l(ii,\"Failed to get zombied client id.\",e),!1}},e.prototype.markClientZombied=function(){try{this.webStorage.setItem(this.zombiedClientLocalStorageKey(this.clientId),String(Date.now()))}catch(e){l(\"Failed to set zombie client id.\",e)}},e.prototype.removeClientZombiedEntry=function(){try{this.webStorage.removeItem(this.zombiedClientLocalStorageKey(this.clientId))}catch(e){}},e.prototype.zombiedClientLocalStorageKey=function(e){return li+\"_\"+this.persistenceKey+\"_\"+e},e.MAIN_DATABASE=\"main\",e}();function pi(e){return e.code===g.FAILED_PRECONDITION&&e.message===ui}function mi(e){return e.store(sr.store)}function yi(e){return e.store(Nr.store)}var gi=function(){function e(e){this.db=e,this.garbageCollector=new ni(this)}return e.prototype.getTargetCount=function(e){return this.db.getQueryCache().getQueryCount(e)},e.prototype.forEachTarget=function(e,t){return this.db.getQueryCache().forEachTarget(e,t)},e.prototype.forEachOrphanedDocumentSequenceNumber=function(e,t){return this.forEachOrphanedDocument(e,function(e,n){return t(n)})},e.prototype.setInMemoryPins=function(e){this.inMemoryPins=e},e.prototype.addReference=function(e,t){return bi(e,t)},e.prototype.removeReference=function(e,t){return bi(e,t)},e.prototype.removeTargets=function(e,t,n){return this.db.getQueryCache().removeTargets(e,t,n)},e.prototype.removeMutationReference=function(e,t){return bi(e,t)},e.prototype.isPinned=function(e,t){return this.inMemoryPins.containsKey(t)?Bn.resolve(!0):qr(e,t)},e.prototype.removeOrphanedDocuments=function(e,t){var n=this,r=0,i=0,o=[];return this.forEachOrphanedDocument(e,function(a,s){if(s<=t){var u=n.isPinned(e,a).next(function(t){if(!t)return r++,n.removeOrphanedDocument(e,a).next(function(e){i+=e})});o.push(u)}}).next(function(){return Bn.waitFor(o)}).next(function(){return n.db.getRemoteDocumentCache().updateSize(e,-i)}).next(function(){return r})},e.prototype.removeOrphanedDocument=function(e,t){var n=0,r=this.db.getRemoteDocumentCache();return Bn.waitFor([Xr(e).delete(vi(t)),r.removeEntry(e,t).next(function(e){n+=e})]).next(function(){return n})},e.prototype.removeTarget=function(e,t){var n=t.copy({sequenceNumber:e.currentSequenceNumber});return this.db.getQueryCache().updateQueryData(e,n)},e.prototype.updateLimboDocument=function(e,t){return bi(e,t)},e.prototype.forEachOrphanedDocument=function(e,t){var n,r=Xr(e),i=Dn.INVALID;return r.iterate({index:Sr.documentTargetsIndex},function(e,r){var o=e[0],a=(e[1],r.path),s=r.sequenceNumber;0===o?(i!==Dn.INVALID&&t(new me(xn(n)),i),i=s,n=a):i=Dn.INVALID}).next(function(){i!==Dn.INVALID&&t(new me(xn(n)),i)})},e}();function vi(e){return[0,On(e.path)]}function wi(e,t){return new Sr(0,On(e.path),t)}function bi(e,t){return Xr(e).put(wi(t,e.currentSequenceNumber))}var Si=function(){function e(e,t){this.remoteDocumentCache=e,this.mutationQueue=t}return e.prototype.getDocument=function(e,t){var n=this;return this.mutationQueue.getAllMutationBatchesAffectingDocumentKey(e,t).next(function(r){return n.getDocumentInternal(e,t,r)})},e.prototype.getDocumentInternal=function(e,t,n){return this.remoteDocumentCache.getEntry(e,t).next(function(e){for(var r=0,i=n;r<i.length;r++){e=i[r].applyToLocalView(t,e)}return e})},e.prototype.getDocuments=function(e,t){var n=this;return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(function(r){var i=[],o=kt();return t.forEach(function(t){i.push(n.getDocumentInternal(e,t,r).next(function(e){e||(e=new ve(t,ot.forDeletedDoc())),o=o.insert(t,e)}))}),Bn.waitFor(i).next(function(){return o})})},e.prototype.getDocumentsMatchingQuery=function(e,t){return me.isDocumentKey(t.path)?this.getDocumentsMatchingDocumentQuery(e,t.path):this.getDocumentsMatchingCollectionQuery(e,t)},e.prototype.getDocumentsMatchingDocumentQuery=function(e,t){return this.getDocument(e,new me(t)).next(function(e){var t=Mt();return e instanceof ge&&(t=t.insert(e.key,e)),t})},e.prototype.getDocumentsMatchingCollectionQuery=function(e,t){var n,r=this;return this.remoteDocumentCache.getDocumentsMatchingQuery(e,t).next(function(i){return n=i,r.mutationQueue.getAllMutationBatchesAffectingQuery(e,t)}).next(function(e){for(var r=0,i=e;r<i.length;r++)for(var o=i[r],a=0,s=o.mutations;a<s.length;a++){var u=s[a],c=u.key;if(t.path.isImmediateParentOf(c.path)){var h=n.get(c),l=u.applyToLocalView(h,h,o.localWriteTime);n=l instanceof ge?n.insert(c,l):n.remove(c)}}}).next(function(){return n.forEach(function(e,r){t.matches(r)||(n=n.remove(e))}),n})},e}(),Ti=function(){function e(){this.refsByKey=new Nt(Ei.compareByKey),this.refsByTarget=new Nt(Ei.compareByTargetId)}return e.prototype.isEmpty=function(){return this.refsByKey.isEmpty()},e.prototype.addReference=function(e,t){var n=new Ei(e,t);this.refsByKey=this.refsByKey.add(n),this.refsByTarget=this.refsByTarget.add(n)},e.prototype.addReferences=function(e,t){var n=this;e.forEach(function(e){return n.addReference(e,t)})},e.prototype.removeReference=function(e,t){this.removeRef(new Ei(e,t))},e.prototype.removeReferences=function(e,t){var n=this;e.forEach(function(e){return n.removeReference(e,t)})},e.prototype.removeReferencesForId=function(e){var t=this,n=me.EMPTY,r=new Ei(n,e),i=new Ei(n,e+1),o=[];return this.refsByTarget.forEachInRange([r,i],function(e){t.removeRef(e),o.push(e.key)}),o},e.prototype.removeAllReferences=function(){var e=this;this.refsByKey.forEach(function(t){return e.removeRef(t)})},e.prototype.removeRef=function(e){this.refsByKey=this.refsByKey.delete(e),this.refsByTarget=this.refsByTarget.delete(e)},e.prototype.referencesForId=function(e){var t=me.EMPTY,n=new Ei(t,e),r=new Ei(t,e+1),i=xt();return this.refsByTarget.forEachInRange([n,r],function(e){i=i.add(e.key)}),i},e.prototype.containsKey=function(e){var t=new Ei(e,0),n=this.refsByKey.firstAfterOrEqual(t);return null!==n&&e.isEqual(n.key)},e}(),Ei=function(){function e(e,t){this.key=e,this.targetOrBatchId=t}return e.compareByKey=function(e,t){return me.comparator(e.key,t.key)||Y(e.targetOrBatchId,t.targetOrBatchId)},e.compareByTargetId=function(e,t){return Y(e.targetOrBatchId,t.targetOrBatchId)||me.comparator(e.key,t.key)},e}(),Ii=\"LocalStore\",Di=function(){function e(e,t){this.persistence=e,this.localViewReferences=new Ti,this.queryDataByTarget={},p(e.started,\"LocalStore was passed an unstarted persistence implementation\"),this.persistence.referenceDelegate.setInMemoryPins(this.localViewReferences),this.mutationQueue=e.getMutationQueue(t),this.remoteDocuments=e.getRemoteDocumentCache(),this.queryCache=e.getQueryCache(),this.localDocuments=new Si(this.remoteDocuments,this.mutationQueue)}return e.prototype.handleUserChange=function(e){var t=this;return this.persistence.runTransaction(\"Handle user change\",\"readonly\",function(n){var r;return t.mutationQueue.getAllMutationBatches(n).next(function(i){return r=i,t.mutationQueue=t.persistence.getMutationQueue(e),t.localDocuments=new Si(t.remoteDocuments,t.mutationQueue),t.mutationQueue.getAllMutationBatches(n)}).next(function(e){for(var i=[],o=[],a=xt(),s=0,u=r;s<u.length;s++){var c=u[s];i.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 d=0,p=e;d<p.length;d++){c=p[d];o.push(c.batchId);for(var m=0,y=c.mutations;m<y.length;m++){f=y[m];a=a.add(f.key)}}return t.localDocuments.getDocuments(n,a).next(function(e){return{affectedDocuments:e,removedBatchIds:i,addedBatchIds:o}})})})},e.prototype.localWrite=function(e){var t=this;return this.persistence.runTransaction(\"Locally write mutations\",\"readwrite\",function(n){var r,i=ae.now();return t.mutationQueue.addMutationBatch(n,i,e).next(function(e){var i=(r=e).keys();return t.localDocuments.getDocuments(n,i)}).next(function(e){return{batchId:r.batchId,changes:e}})})},e.prototype.lookupMutationDocuments=function(e){var t=this;return this.persistence.runTransaction(\"Lookup mutation documents\",\"readonly\",function(n){return t.mutationQueue.lookupMutationKeys(n,e).next(function(e){return e?t.localDocuments.getDocuments(n,e):Bn.resolve(null)})})},e.prototype.acknowledgeBatch=function(e){var t=this;return this.persistence.runTransaction(\"Acknowledge batch\",\"readwrite-primary\",function(n){var r=e.batch.keys(),i=t.remoteDocuments.newChangeBuffer();return t.mutationQueue.acknowledgeBatch(n,e.batch,e.streamToken).next(function(){return t.applyWriteToRemoteDocuments(n,e,i)}).next(function(){return i.apply(n)}).next(function(){return t.mutationQueue.performConsistencyCheck(n)}).next(function(){return t.localDocuments.getDocuments(n,r)})})},e.prototype.rejectBatch=function(e){var t=this;return this.persistence.runTransaction(\"Reject batch\",\"readwrite-primary\",function(n){var r;return t.mutationQueue.lookupMutationBatch(n,e).next(function(e){return p(null!==e,\"Attempt to reject nonexistent batch!\"),r=e.keys(),t.mutationQueue.removeMutationBatch(n,e)}).next(function(){return t.mutationQueue.performConsistencyCheck(n)}).next(function(){return t.localDocuments.getDocuments(n,r)})})},e.prototype.getLastStreamToken=function(){var e=this;return this.persistence.runTransaction(\"Get last stream token\",\"readonly\",function(t){return e.mutationQueue.getLastStreamToken(t)})},e.prototype.setLastStreamToken=function(e){var t=this;return this.persistence.runTransaction(\"Set last stream token\",\"readwrite-primary\",function(n){return t.mutationQueue.setLastStreamToken(n,e)})},e.prototype.getLastRemoteSnapshotVersion=function(){var e=this;return this.persistence.runTransaction(\"Get last remote snapshot version\",\"readonly\",function(t){return e.queryCache.getLastRemoteSnapshotVersion(t)})},e.prototype.applyRemoteEvent=function(t){var n=this,r=this.remoteDocuments.newChangeBuffer();return this.persistence.runTransaction(\"Apply remote event\",\"readwrite-primary\",function(i){var o=[],a=xt();T(t.targetChanges,function(r,s){var u=n.queryDataByTarget[r];if(u){s.addedDocuments.forEach(function(e){a=a.add(e)}),s.modifiedDocuments.forEach(function(e){a=a.add(e)}),o.push(n.queryCache.removeMatchingKeys(i,s.removedDocuments,r).next(function(){return n.queryCache.addMatchingKeys(i,s.addedDocuments,r)}));var c=s.resumeToken;if(c.length>0){var h=u;u=u.copy({resumeToken:c,snapshotVersion:t.snapshotVersion}),n.queryDataByTarget[r]=u,e.shouldPersistQueryData(h,u,s)&&o.push(n.queryCache.updateQueryData(i,u))}}});var s=xt();t.documentUpdates.forEach(function(e,u){s=s.add(e),o.push(r.getEntry(i,e).next(function(t){null==t||u.version.isEqual(ot.MIN)||a.has(u.key)&&!t.hasPendingWrites||u.version.compareTo(t.version)>=0?r.addEntry(u):h(Ii,\"Ignoring outdated watch update for \",e,\". Current version:\",t.version,\" Watch version:\",u.version)})),t.resolvedLimboDocuments.has(e)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(i,e))});var u=t.snapshotVersion;if(!u.isEqual(ot.MIN)){var c=n.queryCache.getLastRemoteSnapshotVersion(i).next(function(e){return p(u.compareTo(e)>=0,\"Watch stream reverted to previous snapshot?? \"+u+\" < \"+e),n.queryCache.setTargetsMetadata(i,i.currentSequenceNumber,u)});o.push(c)}return Bn.waitFor(o).next(function(){return r.apply(i)}).next(function(){return n.localDocuments.getDocuments(i,s)})})},e.shouldPersistQueryData=function(e,t,n){return 0!==t.resumeToken.length&&(0===e.resumeToken.length||(t.snapshotVersion.toMicroseconds()-e.snapshotVersion.toMicroseconds()>=this.RESUME_TOKEN_MAX_AGE_MICROS||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0))},e.prototype.notifyLocalViewChanges=function(e){var t=this;return this.persistence.runTransaction(\"notifyLocalViewChanges\",\"readwrite\",function(n){return Bn.forEach(e,function(e){return t.localViewReferences.addReferences(e.addedKeys,e.targetId),t.localViewReferences.removeReferences(e.removedKeys,e.targetId),Bn.forEach(e.removedKeys,function(e){return t.persistence.referenceDelegate.removeReference(n,e)})})})},e.prototype.nextMutationBatch=function(e){var t=this;return this.persistence.runTransaction(\"Get next mutation batch\",\"readonly\",function(n){return void 0===e&&(e=qn),t.mutationQueue.getNextMutationBatchAfterBatchId(n,e)})},e.prototype.readDocument=function(e){var t=this;return this.persistence.runTransaction(\"read document\",\"readonly\",function(n){return t.localDocuments.getDocument(n,e)})},e.prototype.allocateQuery=function(e){var t=this;return this.persistence.runTransaction(\"Allocate query\",\"readwrite\",function(n){var r;return t.queryCache.getQueryData(n,e).next(function(i){return i?(r=i,Bn.resolve()):t.queryCache.allocateTargetId(n).next(function(i){return r=new st(e,i,Ge.Listen,n.currentSequenceNumber),t.queryCache.addQueryData(n,r)})}).next(function(){return p(!t.queryDataByTarget[r.targetId],\"Tried to allocate an already allocated query: \"+e),t.queryDataByTarget[r.targetId]=r,r})})},e.prototype.releaseQuery=function(e,t){var n=this,r=t?\"readwrite\":\"readwrite-primary\";return this.persistence.runTransaction(\"Release query\",r,function(r){return n.queryCache.getQueryData(r,e).next(function(i){p(null!=i,\"Tried to release nonexistent query: \"+e);var o=i.targetId,a=n.queryDataByTarget[o],s=n.localViewReferences.removeReferencesForId(o);return delete n.queryDataByTarget[o],t?Bn.resolve():Bn.forEach(s,function(e){return n.persistence.referenceDelegate.removeReference(r,e)}).next(function(){return n.persistence.referenceDelegate.removeTarget(r,a)})})})},e.prototype.executeQuery=function(e){var t=this;return this.persistence.runTransaction(\"Execute query\",\"readonly\",function(n){return t.localDocuments.getDocumentsMatchingQuery(n,e)})},e.prototype.remoteDocumentKeys=function(e){var t=this;return this.persistence.runTransaction(\"Remote document keys\",\"readonly\",function(n){return t.queryCache.getMatchingKeysForTargetId(n,e)})},e.prototype.getActiveClients=function(){return this.persistence.getActiveClients()},e.prototype.removeCachedMutationBatchMetadata=function(e){this.mutationQueue.removeCachedMutationKeys(e)},e.prototype.setNetworkEnabled=function(e){this.persistence.setNetworkEnabled(e)},e.prototype.applyWriteToRemoteDocuments=function(e,t,n){var r=this,i=t.batch,o=i.keys(),a=Bn.resolve();return o.forEach(function(r){a=a.next(function(){return n.getEntry(e,r)}).next(function(e){var o=e,a=t.docVersions.get(r);p(null!==a,\"ackVersions should contain every doc in the write.\"),(!o||o.version.compareTo(a)<0)&&((o=i.applyToRemoteDocument(r,o,t))?n.addEntry(o):p(!e,\"Mutation batch \"+i+\" applied to document \"+e+\" resulted in null\"))})}),a.next(function(){return r.mutationQueue.removeMutationBatch(e,i)})},e.prototype.getQueryForTarget=function(e){var t=this;return this.queryDataByTarget[e]?Promise.resolve(this.queryDataByTarget[e].query):this.persistence.runTransaction(\"Get query data\",\"readonly\",function(n){return t.queryCache.getQueryDataForTarget(n,e).next(function(e){return e?e.query:null})})},e.prototype.getNewDocumentChanges=function(){var e=this;return this.persistence.runTransaction(\"Get new document changes\",\"readonly\",function(t){return e.remoteDocuments.getNewDocumentChanges(t)})},e.RESUME_TOKEN_MAX_AGE_MICROS=3e8,e}(),Ci=function(){function e(e){this.referenceDelegate=e,this.mutationQueue=[],this.nextBatchId=1,this.highestAcknowledgedBatchId=qn,this.lastStreamToken=y(),this.batchesByDocumentKey=new Nt(Ei.compareByKey)}return e.prototype.checkEmpty=function(e){return Bn.resolve(0===this.mutationQueue.length)},e.prototype.acknowledgeBatch=function(e,t,n){var r=t.batchId;p(r>this.highestAcknowledgedBatchId,\"Mutation batchIDs must be acknowledged in order\");var i=this.indexOfExistingBatchId(r,\"acknowledged\"),o=this.mutationQueue[i];return p(r===o.batchId,\"Queue ordering failure: expected batch \"+r+\", got batch \"+o.batchId),p(!o.isTombstone(),\"Can't acknowledge a previously removed batch\"),this.highestAcknowledgedBatchId=r,this.lastStreamToken=n,Bn.resolve()},e.prototype.getLastStreamToken=function(e){return Bn.resolve(this.lastStreamToken)},e.prototype.setLastStreamToken=function(e,t){return this.lastStreamToken=t,Bn.resolve()},e.prototype.addMutationBatch=function(e,t,n){p(0!==n.length,\"Mutation batches should not be empty\");var r=this.nextBatchId;(this.nextBatchId++,this.mutationQueue.length>0)&&p(this.mutationQueue[this.mutationQueue.length-1].batchId<r,\"Mutation batchIDs must be monotonically increasing order\");var i=new Fn(r,t,n);this.mutationQueue.push(i);for(var o=0,a=n;o<a.length;o++){var s=a[o];this.batchesByDocumentKey=this.batchesByDocumentKey.add(new Ei(s.key,r))}return Bn.resolve(i)},e.prototype.lookupMutationBatch=function(e,t){return Bn.resolve(this.findMutationBatch(t))},e.prototype.lookupMutationKeys=function(e,t){var n=this.findMutationBatch(t);return p(null!=n,\"Failed to find local mutation batch.\"),Bn.resolve(n.isTombstone()?null:n.keys())},e.prototype.getNextMutationBatchAfterBatchId=function(e,t){for(var n=this.mutationQueue.length,r=Math.max(t,this.highestAcknowledgedBatchId)+1,i=this.indexOfBatchId(r),o=i<0?0:i;o<n;o++){var a=this.mutationQueue[o];if(!a.isTombstone())return Bn.resolve(a)}return Bn.resolve(null)},e.prototype.getAllMutationBatches=function(e){return Bn.resolve(this.getAllLiveMutationBatchesBeforeIndex(this.mutationQueue.length))},e.prototype.getAllMutationBatchesAffectingDocumentKey=function(e,t){var n=this,r=new Ei(t,0),i=new Ei(t,Number.POSITIVE_INFINITY),o=[];return this.batchesByDocumentKey.forEachInRange([r,i],function(e){p(t.isEqual(e.key),\"Should only iterate over a single key's batches\");var r=n.findMutationBatch(e.targetOrBatchId);p(null!==r,\"Batches in the index must exist in the main table\"),o.push(r)}),Bn.resolve(o)},e.prototype.getAllMutationBatchesAffectingDocumentKeys=function(e,t){var n=this,r=new Nt(Y);return t.forEach(function(e){var t=new Ei(e,0),i=new Ei(e,Number.POSITIVE_INFINITY);n.batchesByDocumentKey.forEachInRange([t,i],function(t){p(e.isEqual(t.key),\"For each key, should only iterate over a single key's batches\"),r=r.add(t.targetOrBatchId)})}),Bn.resolve(this.findMutationBatches(r))},e.prototype.getAllMutationBatchesAffectingQuery=function(e,t){var n=t.path,r=n.length+1,i=n;me.isDocumentKey(i)||(i=i.child(\"\"));var o=new Ei(new me(i),0),a=new Nt(Y);return this.batchesByDocumentKey.forEachWhile(function(e){var t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(a=a.add(e.targetOrBatchId)),!0)},o),Bn.resolve(this.findMutationBatches(a))},e.prototype.findMutationBatches=function(e){var t=this,n=[];return e.forEach(function(e){var r=t.findMutationBatch(e);null!==r&&n.push(r)}),n},e.prototype.removeMutationBatch=function(e,t){var n=this,r=this.indexOfExistingBatchId(t.batchId,\"removed\");if(p(this.mutationQueue[r].batchId===t.batchId,\"Removed batches must exist in the queue\"),0===r){for(var i=1;i<this.mutationQueue.length;i++){if(!this.mutationQueue[i].isTombstone())break}this.mutationQueue.splice(0,i)}else this.mutationQueue[r]=this.mutationQueue[r].toTombstone();var o=this.batchesByDocumentKey;return Bn.forEach(t.mutations,function(r){var i=new Ei(r.key,t.batchId);return o=o.delete(i),n.referenceDelegate.removeMutationReference(e,r.key)}).next(function(){n.batchesByDocumentKey=o})},e.prototype.removeCachedMutationKeys=function(e){},e.prototype.containsKey=function(e,t){var n=new Ei(t,0),r=this.batchesByDocumentKey.firstAfterOrEqual(n);return Bn.resolve(t.isEqual(r&&r.key))},e.prototype.performConsistencyCheck=function(e){return 0===this.mutationQueue.length&&p(this.batchesByDocumentKey.isEmpty(),\"Document leak -- detected dangling mutation references when queue is empty.\"),Bn.resolve()},e.prototype.getAllLiveMutationBatchesBeforeIndex=function(e){for(var t=[],n=0;n<e;n++){var r=this.mutationQueue[n];r.isTombstone()||t.push(r)}return t},e.prototype.indexOfExistingBatchId=function(e,t){var n=this.indexOfBatchId(e);return p(n>=0&&n<this.mutationQueue.length,\"Batches must exist to be \"+t),n},e.prototype.indexOfBatchId=function(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId},e.prototype.findMutationBatch=function(e){var t=this.indexOfBatchId(e);if(t<0||t>=this.mutationQueue.length)return null;var n=this.mutationQueue[t];return p(n.batchId===e,\"If found batch must match\"),n.isTombstone()?null:n},e}(),_i=function(){function e(e){this.persistence=e,this.queries=new Un(function(e){return e.canonicalId()}),this.lastRemoteSnapshotVersion=ot.MIN,this.highestTargetId=0,this.highestSequenceNumber=0,this.references=new Ti,this.targetCount=0,this.targetIdGenerator=zr.forQueryCache()}return e.prototype.getTargetCount=function(e){return Bn.resolve(this.targetCount)},e.prototype.forEachTarget=function(e,t){return this.queries.forEach(function(e,n){return t(n)}),Bn.resolve()},e.prototype.getLastRemoteSnapshotVersion=function(e){return Bn.resolve(this.lastRemoteSnapshotVersion)},e.prototype.getHighestSequenceNumber=function(e){return Bn.resolve(this.highestSequenceNumber)},e.prototype.allocateTargetId=function(e){var t=this.targetIdGenerator.after(this.highestTargetId);return this.highestTargetId=t,Bn.resolve(t)},e.prototype.setTargetsMetadata=function(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.highestSequenceNumber&&(this.highestSequenceNumber=t),Bn.resolve()},e.prototype.saveQueryData=function(e){this.queries.set(e.query,e);var t=e.targetId;t>this.highestTargetId&&(this.highestTargetId=t),e.sequenceNumber>this.highestSequenceNumber&&(this.highestSequenceNumber=e.sequenceNumber)},e.prototype.addQueryData=function(e,t){return p(!this.queries.has(t.query),\"Adding a query that already exists\"),this.saveQueryData(t),this.targetCount+=1,Bn.resolve()},e.prototype.updateQueryData=function(e,t){return p(this.queries.has(t.query),\"Updating a non-existent query\"),this.saveQueryData(t),Bn.resolve()},e.prototype.removeQueryData=function(e,t){return p(this.targetCount>0,\"Removing a target from an empty cache\"),p(this.queries.has(t.query),\"Removing a non-existent target from the cache\"),this.queries.delete(t.query),this.references.removeReferencesForId(t.targetId),this.targetCount-=1,Bn.resolve()},e.prototype.removeTargets=function(e,t,n){var r=this,i=0,o=[];return this.queries.forEach(function(a,s){s.sequenceNumber<=t&&!n[s.targetId]&&(r.queries.delete(a),o.push(r.removeMatchingKeysForTargetId(e,s.targetId)),i++)}),Bn.waitFor(o).next(function(){return i})},e.prototype.getQueryCount=function(e){return Bn.resolve(this.targetCount)},e.prototype.getQueryData=function(e,t){var n=this.queries.get(t)||null;return Bn.resolve(n)},e.prototype.getQueryDataForTarget=function(e,t){return d(\"Not yet implemented.\")},e.prototype.addMatchingKeys=function(e,t,n){this.references.addReferences(t,n);var r=this.persistence.referenceDelegate,i=[];return r&&t.forEach(function(t){i.push(r.addReference(e,t))}),Bn.waitFor(i)},e.prototype.removeMatchingKeys=function(e,t,n){this.references.removeReferences(t,n);var r=this.persistence.referenceDelegate,i=[];return r&&t.forEach(function(t){i.push(r.removeReference(e,t))}),Bn.waitFor(i)},e.prototype.removeMatchingKeysForTargetId=function(e,t){return this.references.removeReferencesForId(t),Bn.resolve()},e.prototype.getMatchingKeysForTargetId=function(e,t){var n=this.references.referencesForId(t);return Bn.resolve(n)},e.prototype.containsKey=function(e,t){return Bn.resolve(this.references.containsKey(t))},e}();function Ni(){return new be(me.comparator)}var Ai,ki=function(){function e(e){this.sizer=e,this.docs=Ni(),this.newDocumentChanges=xt(),this.size=0}return e.prototype.addEntries=function(e,t,n){for(var r=0,i=t;r<i.length;r++){var o=i[r],a=o.maybeDocument.key;this.docs=this.docs.insert(a,o),this.newDocumentChanges=this.newDocumentChanges.add(a)}return this.size+=n,Bn.resolve()},e.prototype.removeEntry=function(e,t){var n=this.docs.get(t);return n?(this.docs=this.docs.remove(t),this.size-=n.size,Bn.resolve(n.size)):Bn.resolve(0)},e.prototype.getEntry=function(e,t){var n=this.docs.get(t);return Bn.resolve(n?n.maybeDocument:null)},e.prototype.getSizedEntry=function(e,t){return Bn.resolve(this.docs.get(t))},e.prototype.getDocumentsMatchingQuery=function(e,t){for(var n=Mt(),r=new me(t.path.child(\"\")),i=this.docs.getIteratorFrom(r);i.hasNext();){var o=i.getNext(),a=o.key,s=o.value.maybeDocument;if(!t.path.isPrefixOf(a.path))break;s instanceof ge&&t.matches(s)&&(n=n.insert(s.key,s))}return Bn.resolve(n)},e.prototype.forEachDocumentKey=function(e,t){return Bn.forEach(this.docs,function(e){return t(e.key)})},e.prototype.getNewDocumentChanges=function(e){var t=this,n=kt();return this.newDocumentChanges.forEach(function(e){var r=t.docs.get(e),i=r?r.maybeDocument:new ve(e,ot.forDeletedDoc());n=n.insert(e,i)}),this.newDocumentChanges=xt(),Bn.resolve(n)},e.prototype.newChangeBuffer=function(){return new Ri(this.sizer,this)},e.prototype.getSize=function(e){return Bn.resolve(this.size)},e}(),Ri=function(e){function t(t,n){var r=e.call(this)||this;return r.sizer=t,r.documentCache=n,r}return i.__extends(t,e),t.prototype.applyChanges=function(e){var t=this,n=this.assertChanges(),r=0,i=[];return n.forEach(function(e,n){var o=t.documentSizes.get(e);p(void 0!==o,\"Attempting to change document \"+e.toString()+\" without having read it first\");var a=t.sizer(n);r+=a-o,i.push({maybeDocument:n,size:a})}),this.documentCache.addEntries(e,i,r)},t.prototype.getFromCache=function(e,t){return this.documentCache.getSizedEntry(e,t)},t}(Qn),Mi=\"MemoryPersistence\",Oi=function(){function e(e,t,n){var r=this;this.clientId=e,this.mutationQueues={},this.listenSequence=new Dn(0),this._started=!1,this._started=!0,this.referenceDelegate=t?new Li(this):new xi(this,new Zr(n)),this.queryCache=new _i(this);this.remoteDocumentCache=new ki(function(e){return r.referenceDelegate.documentSize(e)})}return e.createLruPersistence=function(t,n){return new e(t,!1,n)},e.createEagerPersistence=function(t,n){return new e(t,!0,n)},e.prototype.shutdown=function(e){return this._started=!1,Promise.resolve()},Object.defineProperty(e.prototype,\"started\",{get:function(){return this._started},enumerable:!0,configurable:!0}),e.prototype.getActiveClients=function(){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(e){return[2,[this.clientId]]})})},e.prototype.setPrimaryStateListener=function(e){return e(!0)},e.prototype.setNetworkEnabled=function(e){},e.prototype.getMutationQueue=function(e){var t=this.mutationQueues[e.toKey()];return t||(t=new Ci(this.referenceDelegate),this.mutationQueues[e.toKey()]=t),t},e.prototype.getQueryCache=function(){return this.queryCache},e.prototype.getRemoteDocumentCache=function(){return this.remoteDocumentCache},e.prototype.runTransaction=function(e,t,n){var r=this;h(Mi,\"Starting transaction:\",e);var i=new Pi(this.listenSequence.next());return this.referenceDelegate.onTransactionStarted(),n(i).next(function(e){return r.referenceDelegate.onTransactionCommitted(i).next(function(){return e})}).toPromise()},e.prototype.mutationQueuesContainKey=function(e,t){return Bn.or(E(this.mutationQueues).map(function(n){return function(){return n.containsKey(e,t)}}))},e}(),Pi=function(){return function(e){this.currentSequenceNumber=e}}(),Li=function(){function e(e){this.persistence=e}return e.prototype.setInMemoryPins=function(e){this.inMemoryPins=e},e.prototype.addReference=function(e,t){return this.orphanedDocuments.delete(t),Bn.resolve()},e.prototype.removeReference=function(e,t){return this.orphanedDocuments.add(t),Bn.resolve()},e.prototype.removeMutationReference=function(e,t){return this.orphanedDocuments.add(t),Bn.resolve()},e.prototype.removeTarget=function(e,t){var n=this,r=this.persistence.getQueryCache();return r.getMatchingKeysForTargetId(e,t.targetId).next(function(e){e.forEach(function(e){return n.orphanedDocuments.add(e)})}).next(function(){return r.removeQueryData(e,t)})},e.prototype.onTransactionStarted=function(){this.orphanedDocuments=new Set},e.prototype.onTransactionCommitted=function(e){var t=this,n=this.persistence.getRemoteDocumentCache();return Bn.forEach(this.orphanedDocuments,function(r){return t.isReferenced(e,r).next(function(t){if(!t)return n.removeEntry(e,r).next()})})},e.prototype.updateLimboDocument=function(e,t){var n=this;return this.isReferenced(e,t).next(function(e){e?n.orphanedDocuments.delete(t):n.orphanedDocuments.add(t)})},e.prototype.documentSize=function(e){return 0},e.prototype.isReferenced=function(e,t){var n=this;return Bn.or([function(){return n.persistence.getQueryCache().containsKey(e,t)},function(){return n.persistence.mutationQueuesContainKey(e,t)},function(){return Bn.resolve(n.inMemoryPins.containsKey(t))}])},e}(),xi=function(){function e(e,t){this.persistence=e,this.serializer=t,this.orphanedSequenceNumbers=new Un(function(e){return On(e.path)}),this.garbageCollector=new ni(this)}return e.prototype.onTransactionStarted=function(){},e.prototype.onTransactionCommitted=function(e){return Bn.resolve()},e.prototype.forEachTarget=function(e,t){return this.persistence.getQueryCache().forEachTarget(e,t)},e.prototype.getTargetCount=function(e){return this.persistence.getQueryCache().getTargetCount(e)},e.prototype.forEachOrphanedDocumentSequenceNumber=function(e,t){var n=this;return Bn.forEach(this.orphanedSequenceNumbers,function(r){var i=r.key,o=r.value;return n.isPinned(e,i,o).next(function(e){return e?Bn.resolve():t(o)})})},e.prototype.setInMemoryPins=function(e){this.inMemoryPins=e},e.prototype.removeTargets=function(e,t,n){return this.persistence.getQueryCache().removeTargets(e,t,n)},e.prototype.removeOrphanedDocuments=function(e,t){var n=this,r=0,i=this.persistence.getRemoteDocumentCache();return i.forEachDocumentKey(e,function(o){return n.isPinned(e,o,t).next(function(t){return t?Bn.resolve():(r++,i.removeEntry(e,o).next())})}).next(function(){return r})},e.prototype.removeMutationReference=function(e,t){return this.orphanedSequenceNumbers.set(t,e.currentSequenceNumber),Bn.resolve()},e.prototype.removeTarget=function(e,t){var n=t.copy({sequenceNumber:e.currentSequenceNumber});return this.persistence.getQueryCache().updateQueryData(e,n)},e.prototype.addReference=function(e,t){return this.orphanedSequenceNumbers.set(t,e.currentSequenceNumber),Bn.resolve()},e.prototype.removeReference=function(e,t){return this.orphanedSequenceNumbers.set(t,e.currentSequenceNumber),Bn.resolve()},e.prototype.updateLimboDocument=function(e,t){return this.orphanedSequenceNumbers.set(t,e.currentSequenceNumber),Bn.resolve()},e.prototype.documentSize=function(e){var t,n=this.serializer.toDbRemoteDocument(e);if(n.document)t=n.document;else if(n.unknownDocument)t=n.unknownDocument;else{if(!n.noDocument)throw d(\"Unknown remote document type\");t=n.noDocument}return JSON.stringify(t).length},e.prototype.isPinned=function(e,t,n){var r=this;return Bn.or([function(){return r.persistence.mutationQueuesContainKey(e,t)},function(){return Bn.resolve(r.inMemoryPins.containsKey(t))},function(){return r.persistence.getQueryCache().containsKey(e,t)},function(){var e=r.orphanedSequenceNumbers.get(t);return Bn.resolve(void 0!==e&&e>n)}])},e}(),qi=\"ExponentialBackoff\",Fi=function(){function e(e,t,n,r,i){this.queue=e,this.timerId=t,this.initialDelayMs=n,this.backoffFactor=r,this.maxDelayMs=i,this.timerPromise=null,this.lastAttemptTime=Date.now(),this.reset()}return e.prototype.reset=function(){this.currentBaseMs=0},e.prototype.resetToMax=function(){this.currentBaseMs=this.maxDelayMs},e.prototype.backoffAndRun=function(e){var t=this;this.cancel();var n=Math.floor(this.currentBaseMs+this.jitterDelayMs()),r=Math.max(0,Date.now()-this.lastAttemptTime),i=Math.max(0,n-r);this.currentBaseMs>0&&h(qi,\"Backing off for \"+i+\" ms (base delay: \"+this.currentBaseMs+\" ms, delay with jitter: \"+n+\" ms, last attempt: \"+r+\" ms ago)\"),this.timerPromise=this.queue.enqueueAfterDelay(this.timerId,i,function(){return t.lastAttemptTime=Date.now(),e()}),this.currentBaseMs*=this.backoffFactor,this.currentBaseMs<this.initialDelayMs&&(this.currentBaseMs=this.initialDelayMs),this.currentBaseMs>this.maxDelayMs&&(this.currentBaseMs=this.maxDelayMs)},e.prototype.cancel=function(){null!==this.timerPromise&&(this.timerPromise.cancel(),this.timerPromise=null)},e.prototype.jitterDelayMs=function(){return(Math.random()-.5)*this.currentBaseMs},e}(),Vi=\"PersistentStream\";!function(e){e[e.Initial=0]=\"Initial\",e[e.Starting=1]=\"Starting\",e[e.Open=2]=\"Open\",e[e.Error=3]=\"Error\",e[e.Backoff=4]=\"Backoff\"}(Ai||(Ai={}));var Bi,Ui,Qi=1e3,Ki=6e4,Wi=1.5,zi=6e4,ji=function(){function e(e,t,n,r,i,o){this.queue=e,this.idleTimerId=n,this.connection=r,this.credentialsProvider=i,this.listener=o,this.state=Ai.Initial,this.closeCount=0,this.idleTimer=null,this.stream=null,this.backoff=new Fi(e,t,Qi,Wi,Ki)}return e.prototype.isStarted=function(){return this.state===Ai.Starting||this.state===Ai.Open||this.state===Ai.Backoff},e.prototype.isOpen=function(){return this.state===Ai.Open},e.prototype.start=function(){this.state!==Ai.Error?(p(this.state===Ai.Initial,\"Already started\"),this.auth()):this.performBackoff()},e.prototype.stop=function(){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(e){switch(e.label){case 0:return this.isStarted()?[4,this.close(Ai.Initial)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})},e.prototype.inhibitBackoff=function(){p(!this.isStarted(),\"Can only inhibit backoff in a stopped state\"),this.state=Ai.Initial,this.backoff.reset()},e.prototype.markIdle=function(){var e=this;this.isOpen()&&null===this.idleTimer&&(this.idleTimer=this.queue.enqueueAfterDelay(this.idleTimerId,zi,function(){return e.handleIdleCloseTimer()}))},e.prototype.sendRequest=function(e){this.cancelIdleCheck(),this.stream.send(e)},e.prototype.handleIdleCloseTimer=function(){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(e){return this.isOpen()?[2,this.close(Ai.Initial)]:[2]})})},e.prototype.cancelIdleCheck=function(){this.idleTimer&&(this.idleTimer.cancel(),this.idleTimer=null)},e.prototype.close=function(e,t){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(n){switch(n.label){case 0:return p(this.isStarted(),\"Only started streams should be closed.\"),p(e===Ai.Error||ze(t),\"Can't provide an error when not in an error state.\"),this.cancelIdleCheck(),this.backoff.cancel(),this.closeCount++,e!==Ai.Error?this.backoff.reset():t&&t.code===g.RESOURCE_EXHAUSTED?(l(t.toString()),l(\"Using maximum backoff delay to prevent overloading the backend.\"),this.backoff.resetToMax()):t&&t.code===g.UNAUTHENTICATED&&this.credentialsProvider.invalidateToken(),null!==this.stream&&(this.tearDown(),this.stream.close(),this.stream=null),this.state=e,[4,this.listener.onClose(t)];case 1:return n.sent(),[2]}})})},e.prototype.tearDown=function(){},e.prototype.auth=function(){var e=this;p(this.state===Ai.Initial,\"Must be in initial state to auth\"),this.state=Ai.Starting;var t=this.getCloseGuardedDispatcher(this.closeCount),n=this.closeCount;this.credentialsProvider.getToken().then(function(t){e.closeCount===n&&e.startStream(t)},function(n){t(function(){var t=new v(g.UNKNOWN,\"Fetching auth token failed: \"+n.message);return e.handleStreamClose(t)})})},e.prototype.startStream=function(e){var t=this;p(this.state===Ai.Starting,\"Trying to start stream in a non-starting state\");var n=this.getCloseGuardedDispatcher(this.closeCount);this.stream=this.startRpc(e),this.stream.onOpen(function(){n(function(){return p(t.state===Ai.Starting,\"Expected stream to be in state Starting, but was \"+t.state),t.state=Ai.Open,t.listener.onOpen()})}),this.stream.onClose(function(e){n(function(){return t.handleStreamClose(e)})}),this.stream.onMessage(function(e){n(function(){return t.onMessage(e)})})},e.prototype.performBackoff=function(){var e=this;p(this.state===Ai.Error,\"Should only perform backoff when in Error state\"),this.state=Ai.Backoff,this.backoff.backoffAndRun(function(){return i.__awaiter(e,void 0,void 0,function(){return i.__generator(this,function(e){return p(this.state===Ai.Backoff,\"Backoff elapsed but state is now: \"+this.state),this.state=Ai.Initial,this.start(),p(this.isStarted(),\"PersistentStream should have started\"),[2]})})})},e.prototype.handleStreamClose=function(e){return p(this.isStarted(),\"Can't handle server close on non-started stream\"),h(Vi,\"close with error: \"+e),this.stream=null,this.close(Ai.Error,e)},e.prototype.getCloseGuardedDispatcher=function(e){var t=this;return function(n){t.queue.enqueueAndForget(function(){return t.closeCount===e?n():(h(Vi,\"stream callback skipped by getCloseGuardedDispatcher.\"),Promise.resolve())})}},e}(),Gi=function(e){function t(t,n,r,i,o){var a=e.call(this,t,In.ListenStreamConnectionBackoff,In.ListenStreamIdle,n,r,o)||this;return a.serializer=i,a}return i.__extends(t,e),t.prototype.startRpc=function(e){return this.connection.openStream(\"Listen\",e)},t.prototype.onMessage=function(e){this.backoff.reset();var t=this.serializer.fromWatchChange(e),n=this.serializer.versionFromListenResponse(e);return this.listener.onWatchChange(t,n)},t.prototype.watch=function(e){var t={};t.database=this.serializer.encodedDatabaseId,t.addTarget=this.serializer.toTarget(e);var n=this.serializer.toListenRequestLabels(e);n&&(t.labels=n),this.sendRequest(t)},t.prototype.unwatch=function(e){var t={};t.database=this.serializer.encodedDatabaseId,t.removeTarget=e,this.sendRequest(t)},t}(ji),Hi=function(e){function t(t,n,r,i,o){var a=e.call(this,t,In.WriteStreamConnectionBackoff,In.WriteStreamIdle,n,r,o)||this;return a.serializer=i,a.handshakeComplete_=!1,a}return i.__extends(t,e),Object.defineProperty(t.prototype,\"handshakeComplete\",{get:function(){return this.handshakeComplete_},enumerable:!0,configurable:!0}),t.prototype.start=function(){this.handshakeComplete_=!1,e.prototype.start.call(this)},t.prototype.tearDown=function(){this.handshakeComplete_&&this.writeMutations([])},t.prototype.startRpc=function(e){return this.connection.openStream(\"Write\",e)},t.prototype.onMessage=function(e){if(p(!!e.streamToken,\"Got a write response without a stream token\"),this.lastStreamToken=e.streamToken,this.handshakeComplete_){this.backoff.reset();var t=this.serializer.fromWriteResults(e.writeResults,e.commitTime),n=this.serializer.fromVersion(e.commitTime);return this.listener.onMutationResult(n,t)}return p(!e.writeResults||0===e.writeResults.length,\"Got mutation results for handshake\"),this.handshakeComplete_=!0,this.listener.onHandshakeComplete()},t.prototype.writeHandshake=function(){p(this.isOpen(),\"Writing handshake requires an opened stream\"),p(!this.handshakeComplete_,\"Handshake already completed\");var e={};e.database=this.serializer.encodedDatabaseId,this.sendRequest(e)},t.prototype.writeMutations=function(e){var t=this;p(this.isOpen(),\"Writing mutations requires an opened stream\"),p(this.handshakeComplete_,\"Handshake must be complete before writing mutations\"),p(this.lastStreamToken.length>0,\"Trying to write mutation without a token\");var n={streamToken:this.lastStreamToken,writes:e.map(function(e){return t.serializer.toMutation(e)})};this.sendRequest(n)},t}(ji),Yi=function(){function e(e,t,n,r){this.queue=e,this.connection=t,this.credentials=n,this.serializer=r}return e.prototype.newPersistentWriteStream=function(e){return new Hi(this.queue,this.connection,this.credentials,this.serializer,e)},e.prototype.newPersistentWatchStream=function(e){return new Gi(this.queue,this.connection,this.credentials,this.serializer,e)},e.prototype.commit=function(e){var t=this,n={database:this.serializer.encodedDatabaseId,writes:e.map(function(e){return t.serializer.toMutation(e)})};return this.invokeRPC(\"Commit\",n).then(function(e){return t.serializer.fromWriteResults(e.writeResults,e.commitTime)})},e.prototype.lookup=function(e){var t=this,n={database:this.serializer.encodedDatabaseId,documents:e.map(function(e){return t.serializer.toName(e)})};return this.invokeStreamingRPC(\"BatchGetDocuments\",n).then(function(n){var r=kt();n.forEach(function(e){var n=t.serializer.fromMaybeDocument(e);r=r.insert(n.key,n)});var i=[];return e.forEach(function(e){var t=r.get(e);p(!!t,\"Missing entity in write response for \"+e),i.push(t)}),i})},e.prototype.invokeRPC=function(e,t){var n=this;return this.credentials.getToken().then(function(r){return n.connection.invokeRPC(e,t,r)}).catch(function(e){throw e.code===g.UNAUTHENTICATED&&n.credentials.invalidateToken(),e})},e.prototype.invokeStreamingRPC=function(e,t){var n=this;return this.credentials.getToken().then(function(r){return n.connection.invokeStreamingRPC(e,t,r)}).catch(function(e){throw e.code===g.UNAUTHENTICATED&&n.credentials.invalidateToken(),e})},e}(),Ji=function(){function e(e){this.datastore=e,this.readVersions=Pt(),this.mutations=[],this.committed=!1}return e.prototype.recordVersion=function(e){var t;if(e instanceof ge)t=e.version;else{if(!(e instanceof ve))throw d(\"Document in a transaction was a \"+e.constructor.name);t=ot.forDeletedDoc()}var n=this.readVersions.get(e.key);if(null!==n){if(!t.isEqual(n))throw new v(g.ABORTED,\"Document version changed between two reads.\")}else this.readVersions=this.readVersions.insert(e.key,t)},e.prototype.lookup=function(e){var t=this;return this.committed?Promise.reject(\"Transaction has already completed.\"):this.mutations.length>0?Promise.reject(\"Transactions lookups are invalid after writes.\"):this.datastore.lookup(e).then(function(e){return e.forEach(function(e){e instanceof ve||e instanceof ge?t.recordVersion(e):d(\"Document in a transaction was a \"+e.constructor.name)}),e})},e.prototype.write=function(e){if(this.committed)throw new v(g.FAILED_PRECONDITION,\"Transaction has already completed.\");this.mutations=this.mutations.concat(e)},e.prototype.precondition=function(e){var t=this.readVersions.get(e);return t?lt.updateTime(t):lt.NONE},e.prototype.preconditionForUpdate=function(e){var t=this.readVersions.get(e);if(t&&t.isEqual(ot.forDeletedDoc()))throw new v(g.FAILED_PRECONDITION,\"Can't update a document that doesn't exist.\");return t?lt.updateTime(t):lt.exists(!0)},e.prototype.set=function(e,t){this.write(t.toMutations(e,this.precondition(e)))},e.prototype.update=function(e,t){this.write(t.toMutations(e,this.preconditionForUpdate(e)))},e.prototype.delete=function(e){this.write([new yt(e,this.precondition(e))]),this.readVersions=this.readVersions.insert(e,ot.forDeletedDoc())},e.prototype.commit=function(){var e=this,t=this.readVersions;return this.mutations.forEach(function(e){t=t.remove(e.key)}),t.isEmpty()?this.datastore.commit(this.mutations).then(function(){e.committed=!0}):Promise.reject(Error(\"Every document read in a transaction must also be written.\"))},e}();!function(e){e[e.Unknown=0]=\"Unknown\",e[e.Online=1]=\"Online\",e[e.Offline=2]=\"Offline\"}(Bi||(Bi={})),function(e){e[e.RemoteStore=0]=\"RemoteStore\",e[e.SharedClientState=1]=\"SharedClientState\"}(Ui||(Ui={}));var Xi=\"OnlineStateTracker\",Zi=1,$i=1e4,eo=function(){function e(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state=Bi.Unknown,this.watchStreamFailures=0,this.onlineStateTimer=null,this.shouldWarnClientIsOffline=!0}return e.prototype.handleWatchStreamStart=function(){var e=this;0===this.watchStreamFailures&&(this.setAndBroadcast(Bi.Unknown),p(null===this.onlineStateTimer,\"onlineStateTimer shouldn't be started yet\"),this.onlineStateTimer=this.asyncQueue.enqueueAfterDelay(In.OnlineStateTimeout,$i,function(){return e.onlineStateTimer=null,p(e.state===Bi.Unknown,\"Timer should be canceled if we transitioned to a different state.\"),e.logClientOfflineWarningIfNecessary(\"Backend didn't respond within \"+$i\/1e3+\" seconds.\"),e.setAndBroadcast(Bi.Offline),Promise.resolve()}))},e.prototype.handleWatchStreamFailure=function(e){this.state===Bi.Online?(this.setAndBroadcast(Bi.Unknown),p(0===this.watchStreamFailures,\"watchStreamFailures must be 0\"),p(null===this.onlineStateTimer,\"onlineStateTimer must be null\")):(this.watchStreamFailures++,this.watchStreamFailures>=Zi&&(this.clearOnlineStateTimer(),this.logClientOfflineWarningIfNecessary(\"Connection failed \"+Zi+\" times. Most recent error: \"+e.toString()),this.setAndBroadcast(Bi.Offline)))},e.prototype.set=function(e){this.clearOnlineStateTimer(),this.watchStreamFailures=0,e===Bi.Online&&(this.shouldWarnClientIsOffline=!1),this.setAndBroadcast(e)},e.prototype.setAndBroadcast=function(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))},e.prototype.logClientOfflineWarningIfNecessary=function(e){var t=\"Could not reach Cloud Firestore backend. \"+e+\"\\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.shouldWarnClientIsOffline?(l(t),this.shouldWarnClientIsOffline=!1):h(Xi,t)},e.prototype.clearOnlineStateTimer=function(){null!==this.onlineStateTimer&&(this.onlineStateTimer.cancel(),this.onlineStateTimer=null)},e}(),to=\"RemoteStore\",no=10,ro=function(){function e(e,t,n,r){this.localStore=e,this.datastore=t,this.writePipeline=[],this.listenTargets={},this.watchChangeAggregator=null,this.networkEnabled=!1,this.isPrimary=!1,this.onlineStateTracker=new eo(n,r),this.watchStream=this.datastore.newPersistentWatchStream({onOpen:this.onWatchStreamOpen.bind(this),onClose:this.onWatchStreamClose.bind(this),onWatchChange:this.onWatchStreamChange.bind(this)}),this.writeStream=this.datastore.newPersistentWriteStream({onOpen:this.onWriteStreamOpen.bind(this),onClose:this.onWriteStreamClose.bind(this),onHandshakeComplete:this.onWriteHandshakeComplete.bind(this),onMutationResult:this.onMutationResult.bind(this)})}return e.prototype.start=function(){return this.enableNetwork()},e.prototype.enableNetwork=function(){return i.__awaiter(this,void 0,void 0,function(){var e;return i.__generator(this,function(t){switch(t.label){case 0:return this.networkEnabled=!0,this.canUseNetwork()?(e=this.writeStream,[4,this.localStore.getLastStreamToken()]):[3,3];case 1:return e.lastStreamToken=t.sent(),this.shouldStartWatchStream()?this.startWatchStream():this.onlineStateTracker.set(Bi.Unknown),[4,this.fillWritePipeline()];case 2:t.sent(),t.label=3;case 3:return[2]}})})},e.prototype.disableNetwork=function(){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(e){switch(e.label){case 0:return this.networkEnabled=!1,[4,this.disableNetworkInternal()];case 1:return e.sent(),this.onlineStateTracker.set(Bi.Offline),[2]}})})},e.prototype.disableNetworkInternal=function(){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(e){switch(e.label){case 0:return[4,this.writeStream.stop()];case 1:return e.sent(),[4,this.watchStream.stop()];case 2:return e.sent(),this.writePipeline.length>0&&(h(to,\"Stopping write stream with \"+this.writePipeline.length+\" pending writes\"),this.writePipeline=[]),this.cleanUpWatchStreamState(),[2]}})})},e.prototype.shutdown=function(){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(e){switch(e.label){case 0:return h(to,\"RemoteStore shutting down.\"),this.networkEnabled=!1,[4,this.disableNetworkInternal()];case 1:return e.sent(),this.onlineStateTracker.set(Bi.Unknown),[2]}})})},e.prototype.listen=function(e){p(!b(this.listenTargets,e.targetId),\"listen called with duplicate targetId!\"),this.listenTargets[e.targetId]=e,this.shouldStartWatchStream()?this.startWatchStream():this.watchStream.isOpen()&&this.sendWatchRequest(e)},e.prototype.unlisten=function(e){p(b(this.listenTargets,e),\"unlisten called without assigned target ID!\"),delete this.listenTargets[e],this.watchStream.isOpen()&&this.sendUnwatchRequest(e),D(this.listenTargets)&&(this.watchStream.isOpen()?this.watchStream.markIdle():this.canUseNetwork()&&this.onlineStateTracker.set(Bi.Unknown))},e.prototype.getQueryDataForTarget=function(e){return this.listenTargets[e]||null},e.prototype.getRemoteKeysForTarget=function(e){return this.syncEngine.getRemoteKeysForTarget(e)},e.prototype.sendWatchRequest=function(e){this.watchChangeAggregator.recordPendingTargetRequest(e.targetId),this.watchStream.watch(e)},e.prototype.sendUnwatchRequest=function(e){this.watchChangeAggregator.recordPendingTargetRequest(e),this.watchStream.unwatch(e)},e.prototype.startWatchStream=function(){p(this.shouldStartWatchStream(),\"startWatchStream() called when shouldStartWatchStream() is false.\"),this.watchChangeAggregator=new Xt(this),this.watchStream.start(),this.onlineStateTracker.handleWatchStreamStart()},e.prototype.shouldStartWatchStream=function(){return this.canUseNetwork()&&!this.watchStream.isStarted()&&!D(this.listenTargets)},e.prototype.canUseNetwork=function(){return this.isPrimary&&this.networkEnabled},e.prototype.cleanUpWatchStreamState=function(){this.watchChangeAggregator=null},e.prototype.onWatchStreamOpen=function(){return i.__awaiter(this,void 0,void 0,function(){var e=this;return i.__generator(this,function(t){return T(this.listenTargets,function(t,n){e.sendWatchRequest(n)}),[2]})})},e.prototype.onWatchStreamClose=function(e){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(t){return void 0===e&&p(!this.shouldStartWatchStream(),\"Watch stream was stopped gracefully while still needed.\"),this.cleanUpWatchStreamState(),this.shouldStartWatchStream()?(this.onlineStateTracker.handleWatchStreamFailure(e),this.startWatchStream()):this.onlineStateTracker.set(Bi.Unknown),[2]})})},e.prototype.onWatchStreamChange=function(e,t){return i.__awaiter(this,void 0,void 0,function(){var n;return i.__generator(this,function(r){switch(r.label){case 0:return this.onlineStateTracker.set(Bi.Online),e instanceof Yt&&e.state===Qt.Removed&&e.cause?[2,this.handleTargetError(e)]:(e instanceof Gt?this.watchChangeAggregator.handleDocumentChange(e):e instanceof Ht?this.watchChangeAggregator.handleExistenceFilter(e):(p(e instanceof Yt,\"Expected watchChange to be an instance of WatchTargetChange\"),this.watchChangeAggregator.handleTargetChange(e)),t.isEqual(ot.MIN)?[3,3]:[4,this.localStore.getLastRemoteSnapshotVersion()]);case 1:return n=r.sent(),t.compareTo(n)>=0?[4,this.raiseWatchSnapshot(t)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}})})},e.prototype.raiseWatchSnapshot=function(e){var t=this;p(!e.isEqual(ot.MIN),\"Can't raise event for unknown SnapshotVersion\");var n=this.watchChangeAggregator.createRemoteEvent(e);return T(n.targetChanges,function(n,r){if(r.resumeToken.length>0){var i=t.listenTargets[n];i&&(t.listenTargets[n]=i.copy({resumeToken:r.resumeToken,snapshotVersion:e}))}}),n.targetMismatches.forEach(function(e){var n=t.listenTargets[e];if(n){t.listenTargets[e]=n.copy({resumeToken:y()}),t.sendUnwatchRequest(e);var r=new st(n.query,e,Ge.ExistenceFilterMismatch,n.sequenceNumber);t.sendWatchRequest(r)}}),this.syncEngine.applyRemoteEvent(n)},e.prototype.handleTargetError=function(e){var t=this;p(!!e.cause,\"Handling target error without a cause\");var n=e.cause,r=Promise.resolve();return e.targetIds.forEach(function(e){r=r.then(function(){return i.__awaiter(t,void 0,void 0,function(){return i.__generator(this,function(t){return b(this.listenTargets,e)?(delete this.listenTargets[e],this.watchChangeAggregator.removeTarget(e),[2,this.syncEngine.rejectListen(e,n)]):[2]})})})}),r},e.prototype.fillWritePipeline=function(){return i.__awaiter(this,void 0,void 0,function(){var e,t;return i.__generator(this,function(n){switch(n.label){case 0:return this.canAddToWritePipeline()?(e=this.writePipeline.length>0?this.writePipeline[this.writePipeline.length-1].batchId:qn,[4,this.localStore.nextMutationBatch(e)]):[3,4];case 1:return null!==(t=n.sent())?[3,2]:(0===this.writePipeline.length&&this.writeStream.markIdle(),[3,4]);case 2:return this.addToWritePipeline(t),[4,this.fillWritePipeline()];case 3:n.sent(),n.label=4;case 4:return this.shouldStartWriteStream()&&this.startWriteStream(),[2]}})})},e.prototype.canAddToWritePipeline=function(){return this.canUseNetwork()&&this.writePipeline.length<no},e.prototype.outstandingWrites=function(){return this.writePipeline.length},e.prototype.addToWritePipeline=function(e){p(this.canAddToWritePipeline(),\"addToWritePipeline called when pipeline is full\"),this.writePipeline.push(e),this.writeStream.isOpen()&&this.writeStream.handshakeComplete&&this.writeStream.writeMutations(e.mutations)},e.prototype.shouldStartWriteStream=function(){return this.canUseNetwork()&&!this.writeStream.isStarted()&&this.writePipeline.length>0},e.prototype.startWriteStream=function(){p(this.shouldStartWriteStream(),\"startWriteStream() called when shouldStartWriteStream() is false.\"),this.writeStream.start()},e.prototype.onWriteStreamOpen=function(){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(e){return this.writeStream.writeHandshake(),[2]})})},e.prototype.onWriteHandshakeComplete=function(){var e=this;return this.localStore.setLastStreamToken(this.writeStream.lastStreamToken).then(function(){for(var t=0,n=e.writePipeline;t<n.length;t++){var r=n[t];e.writeStream.writeMutations(r.mutations)}}).catch(function(t){return e.ignoreIfPrimaryLeaseLoss(t)})},e.prototype.ignoreIfPrimaryLeaseLoss=function(e){if(!pi(e))throw e;h(to,\"Unexpectedly lost primary lease\")},e.prototype.onMutationResult=function(e,t){var n=this;p(this.writePipeline.length>0,\"Got result for empty write pipeline\");var r=this.writePipeline.shift(),i=Vn.from(r,e,t,this.writeStream.lastStreamToken);return this.syncEngine.applySuccessfulWrite(i).then(function(){return n.fillWritePipeline()})},e.prototype.onWriteStreamClose=function(e){return i.__awaiter(this,void 0,void 0,function(){var t=this;return i.__generator(this,function(n){return void 0===e&&p(!this.shouldStartWriteStream(),\"Write stream was stopped gracefully while still needed.\"),e&&this.writePipeline.length>0?(void 0,[2,(this.writeStream.handshakeComplete?this.handleWriteError(e):this.handleHandshakeError(e)).then(function(){t.shouldStartWriteStream()&&t.startWriteStream()})]):[2]})})},e.prototype.handleHandshakeError=function(e){return i.__awaiter(this,void 0,void 0,function(){var t=this;return i.__generator(this,function(n){return Et(e.code)||e.code===g.ABORTED?(h(to,\"RemoteStore error before completed handshake; resetting stream token: \",this.writeStream.lastStreamToken),this.writeStream.lastStreamToken=y(),[2,this.localStore.setLastStreamToken(y()).catch(function(e){return t.ignoreIfPrimaryLeaseLoss(e)})]):[2]})})},e.prototype.handleWriteError=function(e){return i.__awaiter(this,void 0,void 0,function(){var t,n=this;return i.__generator(this,function(r){return Et(e.code)?(t=this.writePipeline.shift(),this.writeStream.inhibitBackoff(),[2,this.syncEngine.rejectFailedWrite(t.batchId,e).then(function(){return n.fillWritePipeline()})]):[2]})})},e.prototype.createTransaction=function(){return new Ji(this.datastore)},e.prototype.handleCredentialChange=function(){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(e){switch(e.label){case 0:return this.canUseNetwork()?(h(to,\"RemoteStore restarting streams for new credential\"),this.networkEnabled=!1,[4,this.disableNetworkInternal()]):[3,3];case 1:return e.sent(),this.onlineStateTracker.set(Bi.Unknown),[4,this.enableNetwork()];case 2:e.sent(),e.label=3;case 3:return[2]}})})},e.prototype.applyPrimaryState=function(e){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(t){switch(t.label){case 0:return this.isPrimary=e,e&&this.networkEnabled?[4,this.enableNetwork()]:[3,2];case 1:return t.sent(),[3,4];case 2:return e?[3,4]:[4,this.disableNetworkInternal()];case 3:t.sent(),this.onlineStateTracker.set(Bi.Unknown),t.label=4;case 4:return[2]}})})},e}(),io=function(){return function(){this.listeners=[]}}(),oo=function(){function e(e){this.syncEngine=e,this.queries=new Un(function(e){return e.canonicalId()}),this.onlineState=Bi.Unknown,this.syncEngine.subscribe(this)}return e.prototype.listen=function(e){var t=e.query,n=!1,r=this.queries.get(t);return r||(n=!0,r=new io,this.queries.set(t,r)),r.listeners.push(e),e.applyOnlineStateChange(this.onlineState),r.viewSnap&&e.onViewSnapshot(r.viewSnap),n?this.syncEngine.listen(t).then(function(e){return r.targetId=e,e}):Promise.resolve(r.targetId)},e.prototype.unlisten=function(e){return i.__awaiter(this,void 0,void 0,function(){var t,n,r,o;return i.__generator(this,function(i){return t=e.query,n=!1,(r=this.queries.get(t))&&(o=r.listeners.indexOf(e))>=0&&(r.listeners.splice(o,1),n=0===r.listeners.length),n?(this.queries.delete(t),[2,this.syncEngine.unlisten(t)]):[2]})})},e.prototype.onWatchChange=function(e){for(var t=0,n=e;t<n.length;t++){var r=n[t],i=r.query,o=this.queries.get(i);if(o){for(var a=0,s=o.listeners;a<s.length;a++){s[a].onViewSnapshot(r)}o.viewSnap=r}}},e.prototype.onWatchError=function(e,t){var n=this.queries.get(e);if(n)for(var r=0,i=n.listeners;r<i.length;r++){i[r].onError(t)}this.queries.delete(e)},e.prototype.onOnlineStateChange=function(e){this.onlineState=e,this.queries.forEach(function(t,n){for(var r=0,i=n.listeners;r<i.length;r++){i[r].applyOnlineStateChange(e)}})},e}(),ao=function(){function e(e,t,n){this.query=e,this.queryObserver=t,this.raisedInitialEvent=!1,this.onlineState=Bi.Unknown,this.options=n||{}}return e.prototype.onViewSnapshot=function(e){if(p(e.docChanges.length>0||e.syncStateChanged,\"We got a new snapshot with no changes?\"),!this.options.includeMetadataChanges){for(var t=[],n=0,r=e.docChanges;n<r.length;n++){var i=r[n];i.type!==Vt.Metadata&&t.push(i)}e=new Wt(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0)}this.raisedInitialEvent?this.shouldRaiseEvent(e)&&this.queryObserver.next(e):this.shouldRaiseInitialEvent(e,this.onlineState)&&this.raiseInitialEvent(e),this.snap=e},e.prototype.onError=function(e){this.queryObserver.error(e)},e.prototype.applyOnlineStateChange=function(e){this.onlineState=e,this.snap&&!this.raisedInitialEvent&&this.shouldRaiseInitialEvent(this.snap,e)&&this.raiseInitialEvent(this.snap)},e.prototype.shouldRaiseInitialEvent=function(e,t){if(p(!this.raisedInitialEvent,\"Determining whether to raise first event but already had first event\"),!e.fromCache)return!0;var n=t!==Bi.Offline;return this.options.waitForSyncWhenOnline&&n?(p(e.fromCache,\"Waiting for sync, but snapshot is not from cache\"),!1):!e.docs.isEmpty()||t===Bi.Offline},e.prototype.shouldRaiseEvent=function(e){if(e.docChanges.length>0)return!0;var t=this.snap&&this.snap.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges},e.prototype.raiseInitialEvent=function(e){p(!this.raisedInitialEvent,\"Trying to raise initial events for second time\"),e=Wt.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache),this.raisedInitialEvent=!0,this.queryObserver.next(e)},e}(),so=function(){function e(e,t,n){this.targetId=e,this.addedKeys=t,this.removedKeys=n}return e.fromSnapshot=function(t,n){for(var r=xt(),i=xt(),o=0,a=n.docChanges;o<a.length;o++){var s=a[o];switch(s.type){case Vt.Added:r=r.add(s.doc.key);break;case Vt.Removed:i=i.add(s.doc.key)}}return new e(t,r,i)},e}(),uo=function(){return function(e){this.key=e}}(),co=function(){return function(e){this.key=e}}(),ho=function(){function e(e,t){this.query=e,this._syncedDocuments=t,this.syncState=null,this.current=!1,this.limboDocuments=xt(),this.mutatedKeys=xt(),this.documentSet=new Ut(e.docComparator.bind(e))}return Object.defineProperty(e.prototype,\"syncedDocuments\",{get:function(){return this._syncedDocuments},enumerable:!0,configurable:!0}),e.prototype.computeDocChanges=function(e,t){var n=this,r=t?t.changeSet:new Kt,i=t?t.documentSet:this.documentSet,o=t?t.mutatedKeys:this.mutatedKeys,a=i,s=!1,u=this.query.hasLimit()&&i.size===this.query.limit?i.last():null;if(e.inorderTraversal(function(e,t){var c=i.get(e),h=t instanceof ge?t:null;h&&(p(e.isEqual(h.key),\"Mismatching keys found in document changes: \"+e+\" != \"+h.key),h=n.query.matches(h)?h:null);var l=!!c&&n.mutatedKeys.has(c.key),f=!!h&&(h.hasLocalMutations||n.mutatedKeys.has(h.key)&&h.hasCommittedMutations),d=!1;c&&h?c.data.isEqual(h.data)?l!==f&&(r.track({type:Vt.Metadata,doc:h}),d=!0):n.shouldWaitForSyncedDocument(c,h)||(r.track({type:Vt.Modified,doc:h}),d=!0,u&&n.query.docComparator(h,u)>0&&(s=!0)):!c&&h?(r.track({type:Vt.Added,doc:h}),d=!0):c&&!h&&(r.track({type:Vt.Removed,doc:c}),d=!0,u&&(s=!0));d&&(h?(a=a.add(h),o=f?o.add(e):o.delete(e)):(a=a.delete(e),o=o.delete(e)))}),this.query.hasLimit())for(;a.size>this.query.limit;){var c=a.last();a=a.delete(c.key),o=o.delete(c.key),r.track({type:Vt.Removed,doc:c})}return p(!s||!t,\"View was refilled using docs that themselves needed refilling.\"),{documentSet:a,changeSet:r,needsRefill:s,mutatedKeys:o}},e.prototype.shouldWaitForSyncedDocument=function(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations},e.prototype.applyChanges=function(e,t,n){var r=this;p(!e.needsRefill,\"Cannot apply changes that need a refill\");var i=this.documentSet;this.documentSet=e.documentSet,this.mutatedKeys=e.mutatedKeys;var o=e.changeSet.getChanges();o.sort(function(e,t){return lo(e.type,t.type)||r.query.docComparator(e.doc,t.doc)}),this.applyTargetChange(n);var a=t?this.updateLimboDocuments():[],s=0===this.limboDocuments.size&&this.current?Bt.Synced:Bt.Local,u=s!==this.syncState;return this.syncState=s,0!==o.length||u?{snapshot:new Wt(this.query,e.documentSet,i,o,e.mutatedKeys,s===Bt.Local,u,!1),limboChanges:a}:{limboChanges:a}},e.prototype.applyOnlineStateChange=function(e){return this.current&&e===Bi.Offline?(this.current=!1,this.applyChanges({documentSet:this.documentSet,changeSet:new Kt,mutatedKeys:this.mutatedKeys,needsRefill:!1},!1)):{limboChanges:[]}},e.prototype.shouldBeInLimbo=function(e){return!this._syncedDocuments.has(e)&&(!!this.documentSet.has(e)&&!this.documentSet.get(e).hasLocalMutations)},e.prototype.applyTargetChange=function(e){var t=this;e&&(e.addedDocuments.forEach(function(e){return t._syncedDocuments=t._syncedDocuments.add(e)}),e.modifiedDocuments.forEach(function(e){return p(t._syncedDocuments.has(e),\"Modified document \"+e+\" not found in view.\")}),e.removedDocuments.forEach(function(e){return t._syncedDocuments=t._syncedDocuments.delete(e)}),this.current=e.current)},e.prototype.updateLimboDocuments=function(){var e=this;if(!this.current)return[];var t=this.limboDocuments;this.limboDocuments=xt(),this.documentSet.forEach(function(t){e.shouldBeInLimbo(t.key)&&(e.limboDocuments=e.limboDocuments.add(t.key))});var n=[];return t.forEach(function(t){e.limboDocuments.has(t)||n.push(new co(t))}),this.limboDocuments.forEach(function(e){t.has(e)||n.push(new uo(e))}),n},e.prototype.synchronizeWithPersistedState=function(e,t){this._syncedDocuments=t,this.limboDocuments=xt();var n=this.computeDocChanges(e);return this.applyChanges(n,!0)},e.prototype.computeInitialSnapshot=function(){return Wt.fromInitialDocuments(this.query,this.documentSet,this.mutatedKeys,this.syncState===Bt.Local)},e}();function lo(e,t){var n=function(e){switch(e){case Vt.Added:return 1;case Vt.Modified:case Vt.Metadata:return 2;case Vt.Removed:return 0;default:return d(\"Unknown ChangeType: \"+e)}};return n(e)-n(t)}var fo=\"SyncEngine\",po=function(){return function(e,t,n){this.query=e,this.targetId=t,this.view=n}}(),mo=function(){return function(e){this.key=e}}(),yo=function(){function e(e,t,n,r){this.localStore=e,this.remoteStore=t,this.sharedClientState=n,this.currentUser=r,this.syncEngineListener=null,this.queryViewsByQuery=new Un(function(e){return e.canonicalId()}),this.queryViewsByTarget={},this.limboTargetsByKey=new be(me.comparator),this.limboResolutionsByTarget={},this.limboDocumentRefs=new Ti,this.mutationUserCallbacks={},this.limboTargetIdGenerator=zr.forSyncEngine(),this.isPrimary=void 0,this.onlineState=Bi.Unknown}return Object.defineProperty(e.prototype,\"isPrimaryClient\",{get:function(){return!0===this.isPrimary},enumerable:!0,configurable:!0}),e.prototype.subscribe=function(e){p(null!==e,\"SyncEngine listener cannot be null\"),p(null===this.syncEngineListener,\"SyncEngine already has a subscriber.\"),this.syncEngineListener=e},e.prototype.listen=function(e){return i.__awaiter(this,void 0,void 0,function(){var t,n,r,o,a;return i.__generator(this,function(i){switch(i.label){case 0:return this.assertSubscribed(\"listen()\"),(r=this.queryViewsByQuery.get(e))?(t=r.targetId,this.sharedClientState.addLocalQueryTarget(t),n=r.view.computeInitialSnapshot(),[3,4]):[3,1];case 1:return[4,this.localStore.allocateQuery(e)];case 2:return o=i.sent(),a=this.sharedClientState.addLocalQueryTarget(o.targetId),t=o.targetId,[4,this.initializeViewAndComputeSnapshot(o,\"current\"===a)];case 3:n=i.sent(),this.isPrimary&&this.remoteStore.listen(o),i.label=4;case 4:return this.syncEngineListener.onWatchChange([n]),[2,t]}})})},e.prototype.initializeViewAndComputeSnapshot=function(e,t){var n=this,r=e.query;return this.localStore.executeQuery(r).then(function(i){return n.localStore.remoteDocumentKeys(e.targetId).then(function(o){var a=new ho(r,o),s=a.computeDocChanges(i),u=jt.createSynthesizedTargetChangeForCurrentChange(e.targetId,t&&n.onlineState!==Bi.Offline),c=a.applyChanges(s,!0===n.isPrimary,u);p(0===c.limboChanges.length,\"View returned limbo docs before target ack from the server.\"),p(!!c.snapshot,\"applyChanges for new view should always return a snapshot\");var h=new po(r,e.targetId,a);return n.queryViewsByQuery.set(r,h),n.queryViewsByTarget[e.targetId]=h,c.snapshot})})},e.prototype.synchronizeViewAndComputeSnapshot=function(e){var t=this;return this.localStore.executeQuery(e.query).then(function(n){return t.localStore.remoteDocumentKeys(e.targetId).then(function(r){return i.__awaiter(t,void 0,void 0,function(){var t;return i.__generator(this,function(i){return t=e.view.synchronizeWithPersistedState(n,r),this.isPrimary&&this.updateTrackedLimbos(e.targetId,t.limboChanges),[2,t]})})})})},e.prototype.unlisten=function(e){return i.__awaiter(this,void 0,void 0,function(){var t,n=this;return i.__generator(this,function(r){switch(r.label){case 0:return this.assertSubscribed(\"unlisten()\"),p(!!(t=this.queryViewsByQuery.get(e)),\"Trying to unlisten on query not found:\"+e),this.isPrimary?(this.sharedClientState.removeLocalQueryTarget(t.targetId),this.sharedClientState.isActiveQueryTarget(t.targetId)?[3,2]:[4,this.localStore.releaseQuery(e,!1).then(function(){n.sharedClientState.clearQueryState(t.targetId),n.remoteStore.unlisten(t.targetId),n.removeAndCleanupQuery(t)}).catch(function(e){return n.ignoreIfPrimaryLeaseLoss(e)})]):[3,3];case 1:r.sent(),r.label=2;case 2:return[3,5];case 3:return this.removeAndCleanupQuery(t),[4,this.localStore.releaseQuery(e,!0)];case 4:r.sent(),r.label=5;case 5:return[2]}})})},e.prototype.write=function(e,t){var n=this;return this.assertSubscribed(\"write()\"),this.localStore.localWrite(e).then(function(e){return n.sharedClientState.addPendingMutation(e.batchId),n.addMutationCallback(e.batchId,t),n.emitNewSnapsAndNotifyLocalStore(e.changes)}).then(function(){return n.remoteStore.fillWritePipeline()})},e.prototype.wrapUpdateFunctionError=function(e){return e},e.prototype.runTransaction=function(e,t){var n=this;void 0===t&&(t=5),p(t>=0,\"Got negative number of retries for transaction.\");var r=this.remoteStore.createTransaction();return function(){try{var t=e(r);return!ze(t)&&t.catch&&t.then?t.catch(function(e){return Promise.reject(n.wrapUpdateFunctionError(e))}):Promise.reject(Error(\"Transaction callback must return a Promise\"))}catch(e){return Promise.reject(n.wrapUpdateFunctionError(e))}}().then(function(i){return r.commit().then(function(){return i}).catch(function(r){return 0===t?Promise.reject(r):n.runTransaction(e,t-1)})})},e.prototype.applyRemoteEvent=function(e){var t=this;return this.assertSubscribed(\"applyRemoteEvent()\"),this.localStore.applyRemoteEvent(e).then(function(n){return I(e.targetChanges,function(e,n){var r=t.limboResolutionsByTarget[e];r&&(p(n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size<=1,\"Limbo resolution for single document contains multiple changes.\"),n.addedDocuments.size>0?r.receivedDocument=!0:n.modifiedDocuments.size>0?p(r.receivedDocument,\"Received change for limbo target document without add.\"):n.removedDocuments.size>0&&(p(r.receivedDocument,\"Received remove for limbo target document without add.\"),r.receivedDocument=!1))}),t.emitNewSnapsAndNotifyLocalStore(n,e)}).catch(function(e){return t.ignoreIfPrimaryLeaseLoss(e)})},e.prototype.applyOnlineStateChange=function(e,t){if(this.isPrimary&&t===Ui.RemoteStore||!this.isPrimary&&t===Ui.SharedClientState){var n=[];this.queryViewsByQuery.forEach(function(t,r){var i=r.view.applyOnlineStateChange(e);p(0===i.limboChanges.length,\"OnlineState should not affect limbo documents.\"),i.snapshot&&n.push(i.snapshot)}),this.syncEngineListener.onOnlineStateChange(e),this.syncEngineListener.onWatchChange(n),this.onlineState=e,this.isPrimary&&this.sharedClientState.setOnlineState(e)}},e.prototype.rejectListen=function(e,t){return i.__awaiter(this,void 0,void 0,function(){var n,r,o,a,s,u,c=this;return i.__generator(this,function(i){switch(i.label){case 0:return this.assertSubscribed(\"rejectListens()\"),this.sharedClientState.updateQueryState(e,\"rejected\",t),n=this.limboResolutionsByTarget[e],(r=n&&n.key)?(this.limboTargetsByKey=this.limboTargetsByKey.remove(r),delete this.limboResolutionsByTarget[e],o=(o=new be(me.comparator)).insert(r,new ve(r,ot.forDeletedDoc())),a=xt().add(r),s=new zt(ot.MIN,{},new Nt(Y),o,a),[2,this.applyRemoteEvent(s)]):[3,1];case 1:return p(!!(u=this.queryViewsByTarget[e]),\"Unknown targetId: \"+e),[4,this.localStore.releaseQuery(u.query,!1).then(function(){return c.removeAndCleanupQuery(u)}).catch(function(e){return c.ignoreIfPrimaryLeaseLoss(e)})];case 2:i.sent(),this.syncEngineListener.onWatchError(u.query,t),i.label=3;case 3:return[2]}})})},e.prototype.applyBatchState=function(e,t,n){return i.__awaiter(this,void 0,void 0,function(){var r;return i.__generator(this,function(i){switch(i.label){case 0:return this.assertSubscribed(\"applyBatchState()\"),[4,this.localStore.lookupMutationDocuments(e)];case 1:return null===(r=i.sent())?(h(fo,\"Cannot apply mutation batch with id: \"+e),[2]):\"pending\"!==t?[3,3]:[4,this.remoteStore.fillWritePipeline()];case 2:return i.sent(),[3,4];case 3:\"acknowledged\"===t||\"rejected\"===t?(this.processUserCallback(e,n||null),this.localStore.removeCachedMutationBatchMetadata(e)):d(\"Unknown batchState: \"+t),i.label=4;case 4:return[4,this.emitNewSnapsAndNotifyLocalStore(r)];case 5:return i.sent(),[2]}})})},e.prototype.applySuccessfulWrite=function(e){var t=this;this.assertSubscribed(\"applySuccessfulWrite()\");var n=e.batch.batchId;return this.processUserCallback(n,null),this.localStore.acknowledgeBatch(e).then(function(e){return t.sharedClientState.updateMutationState(n,\"acknowledged\"),t.emitNewSnapsAndNotifyLocalStore(e)}).catch(function(e){return t.ignoreIfPrimaryLeaseLoss(e)})},e.prototype.rejectFailedWrite=function(e,t){var n=this;return this.assertSubscribed(\"rejectFailedWrite()\"),this.processUserCallback(e,t),this.localStore.rejectBatch(e).then(function(r){return n.sharedClientState.updateMutationState(e,\"rejected\",t),n.emitNewSnapsAndNotifyLocalStore(r)}).catch(function(e){return n.ignoreIfPrimaryLeaseLoss(e)})},e.prototype.addMutationCallback=function(e,t){var n=this.mutationUserCallbacks[this.currentUser.toKey()];n||(n=new be(Y)),n=n.insert(e,t),this.mutationUserCallbacks[this.currentUser.toKey()]=n},e.prototype.processUserCallback=function(e,t){var n=this.mutationUserCallbacks[this.currentUser.toKey()];if(n){var r=n.get(e);r&&(p(e===n.minKey(),\"Mutation callbacks processed out-of-order?\"),t?r.reject(t):r.resolve(),n=n.remove(e)),this.mutationUserCallbacks[this.currentUser.toKey()]=n}},e.prototype.removeAndCleanupQuery=function(e){var t=this;if(this.sharedClientState.removeLocalQueryTarget(e.targetId),this.queryViewsByQuery.delete(e.query),delete this.queryViewsByTarget[e.targetId],this.isPrimary){var n=this.limboDocumentRefs.referencesForId(e.targetId);this.limboDocumentRefs.removeReferencesForId(e.targetId),n.forEach(function(e){t.limboDocumentRefs.containsKey(e)||t.removeLimboTarget(e)})}},e.prototype.removeLimboTarget=function(e){var t=this.limboTargetsByKey.get(e);null!==t&&(this.remoteStore.unlisten(t),this.limboTargetsByKey=this.limboTargetsByKey.remove(e),delete this.limboResolutionsByTarget[t])},e.prototype.updateTrackedLimbos=function(e,t){for(var n=0,r=t;n<r.length;n++){var i=r[n];if(i instanceof uo)this.limboDocumentRefs.addReference(i.key,e),this.trackLimboChange(i);else if(i instanceof co){h(fo,\"Document no longer in limbo: \"+i.key),this.limboDocumentRefs.removeReference(i.key,e),this.limboDocumentRefs.containsKey(i.key)||this.removeLimboTarget(i.key)}else d(\"Unknown limbo change: \"+JSON.stringify(i))}},e.prototype.trackLimboChange=function(e){var t=e.key;if(!this.limboTargetsByKey.get(t)){h(fo,\"New document in limbo: \"+t);var n=this.limboTargetIdGenerator.next(),r=He.atPath(t.path);this.limboResolutionsByTarget[n]=new mo(t),this.remoteStore.listen(new st(r,n,Ge.LimboResolution,Dn.INVALID)),this.limboTargetsByKey=this.limboTargetsByKey.insert(t,n)}},e.prototype.currentLimboDocs=function(){return this.limboTargetsByKey},e.prototype.emitNewSnapsAndNotifyLocalStore=function(e,t){return i.__awaiter(this,void 0,void 0,function(){var n,r,o,a=this;return i.__generator(this,function(i){switch(i.label){case 0:return n=[],r=[],o=[],this.queryViewsByQuery.forEach(function(i,s){o.push(Promise.resolve().then(function(){var t=s.view.computeDocChanges(e);return t.needsRefill?a.localStore.executeQuery(s.query).then(function(e){return s.view.computeDocChanges(e,t)}):t}).then(function(e){var i=t&&t.targetChanges[s.targetId],o=s.view.applyChanges(e,!0===a.isPrimary,i);if(a.updateTrackedLimbos(s.targetId,o.limboChanges),o.snapshot){a.isPrimary&&a.sharedClientState.updateQueryState(s.targetId,o.snapshot.fromCache?\"not-current\":\"current\"),n.push(o.snapshot);var u=so.fromSnapshot(s.targetId,o.snapshot);r.push(u)}}))}),[4,Promise.all(o)];case 1:return i.sent(),this.syncEngineListener.onWatchChange(n),[4,this.localStore.notifyLocalViewChanges(r)];case 2:return i.sent(),[2]}})})},e.prototype.ignoreIfPrimaryLeaseLoss=function(e){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(t){if(!pi(e))throw e;return h(fo,\"Unexpectedly lost primary lease\"),[2]})})},e.prototype.assertSubscribed=function(e){p(null!==this.syncEngineListener,\"Trying to call \"+e+\" before calling subscribe().\")},e.prototype.handleCredentialChange=function(e){return i.__awaiter(this,void 0,void 0,function(){var t,n;return i.__generator(this,function(r){switch(r.label){case 0:return t=!this.currentUser.isEqual(e),this.currentUser=e,t?[4,this.localStore.handleUserChange(e)]:[3,3];case 1:return n=r.sent(),this.sharedClientState.handleUserChange(e,n.removedBatchIds,n.addedBatchIds),[4,this.emitNewSnapsAndNotifyLocalStore(n.affectedDocuments)];case 2:r.sent(),r.label=3;case 3:return[4,this.remoteStore.handleCredentialChange()];case 4:return r.sent(),[2]}})})},e.prototype.applyPrimaryState=function(e){return i.__awaiter(this,void 0,void 0,function(){var t,n,r,o,a,s,u,c=this;return i.__generator(this,function(i){switch(i.label){case 0:return!0!==e||!0===this.isPrimary?[3,3]:(this.isPrimary=!0,[4,this.remoteStore.applyPrimaryState(!0)]);case 1:return i.sent(),t=this.sharedClientState.getAllActiveQueryTargets(),[4,this.synchronizeQueryViewsAndRaiseSnapshots(t.toArray())];case 2:for(n=i.sent(),r=0,o=n;r<o.length;r++)a=o[r],this.remoteStore.listen(a);return[3,7];case 3:return!1!==e||!1===this.isPrimary?[3,7]:(this.isPrimary=!1,s=[],u=Promise.resolve(),T(this.queryViewsByTarget,function(e,t){c.sharedClientState.isLocalQueryTarget(e)?s.push(e):u=u.then(function(){return c.unlisten(t.query)}),c.remoteStore.unlisten(t.targetId)}),[4,u]);case 4:return i.sent(),[4,this.synchronizeQueryViewsAndRaiseSnapshots(s)];case 5:return i.sent(),this.resetLimboDocuments(),[4,this.remoteStore.applyPrimaryState(!1)];case 6:i.sent(),i.label=7;case 7:return[2]}})})},e.prototype.resetLimboDocuments=function(){var e=this;T(this.limboResolutionsByTarget,function(t){e.remoteStore.unlisten(t)}),this.limboDocumentRefs.removeAllReferences(),this.limboResolutionsByTarget=[],this.limboTargetsByKey=new be(me.comparator)},e.prototype.synchronizeQueryViewsAndRaiseSnapshots=function(e){for(var t=this,n=Promise.resolve(),r=[],o=[],a=function(e){n=n.then(function(){return i.__awaiter(t,void 0,void 0,function(){var t,n,a,s;return i.__generator(this,function(i){switch(i.label){case 0:return(n=this.queryViewsByTarget[e])?[4,this.localStore.releaseQuery(n.query,!0)]:[3,4];case 1:return i.sent(),[4,this.localStore.allocateQuery(n.query)];case 2:return t=i.sent(),[4,this.synchronizeViewAndComputeSnapshot(n)];case 3:return(a=i.sent()).snapshot&&o.push(a.snapshot),[3,8];case 4:return p(!0===this.isPrimary,\"A secondary tab should never have an active query without an active view.\"),[4,this.localStore.getQueryForTarget(e)];case 5:return p(!!(s=i.sent()),\"Query data for target \"+e+\" not found\"),[4,this.localStore.allocateQuery(s)];case 6:return t=i.sent(),[4,this.initializeViewAndComputeSnapshot(t,!1)];case 7:i.sent(),i.label=8;case 8:return r.push(t),[2]}})})})},s=0,u=e;s<u.length;s++){a(u[s])}return n.then(function(){return t.syncEngineListener.onWatchChange(o),r})},e.prototype.getActiveClients=function(){return this.localStore.getActiveClients()},e.prototype.applyTargetState=function(e,t,n){return i.__awaiter(this,void 0,void 0,function(){var r,o=this;return i.__generator(this,function(a){switch(a.label){case 0:if(this.isPrimary)return h(fo,\"Ignoring unexpected query state notification.\"),[2];if(!this.queryViewsByTarget[e])return[3,5];switch(t){case\"current\":case\"not-current\":return[3,1];case\"rejected\":return[3,2]}return[3,4];case 1:return[2,this.localStore.getNewDocumentChanges().then(function(n){return i.__awaiter(o,void 0,void 0,function(){var r;return i.__generator(this,function(i){switch(i.label){case 0:return r=zt.createSynthesizedRemoteEventForCurrentChange(e,\"current\"===t),[4,this.emitNewSnapsAndNotifyLocalStore(n,r)];case 1:return i.sent(),[2]}})})},function(e){return i.__awaiter(o,void 0,void 0,function(){var t;return i.__generator(this,function(n){switch(n.label){case 0:return $n(e)?(t=[],T(this.queryViewsByTarget,function(e){return t.push(e)}),[4,this.synchronizeQueryViewsAndRaiseSnapshots(t)]):[3,2];case 1:return n.sent(),[3,3];case 2:throw e;case 3:return[2]}})})})];case 2:return r=this.queryViewsByTarget[e],this.removeAndCleanupQuery(r),[4,this.localStore.releaseQuery(r.query,!0)];case 3:return a.sent(),this.syncEngineListener.onWatchError(r.query,n),[3,5];case 4:d(\"Unexpected target state: \"+t),a.label=5;case 5:return[2]}})})},e.prototype.applyActiveTargetsChange=function(e,t){return i.__awaiter(this,void 0,void 0,function(){var n,r,o,a,s,u,c,h,l,f=this;return i.__generator(this,function(d){switch(d.label){case 0:if(!this.isPrimary)return[2];n=0,r=e,d.label=1;case 1:return n<r.length?(l=r[n],p(!this.queryViewsByTarget[l],\"Trying to add an already active target\"),[4,this.localStore.getQueryForTarget(l)]):[3,6];case 2:return p(!!(o=d.sent()),\"Query data for active target \"+l+\" not found\"),[4,this.localStore.allocateQuery(o)];case 3:return a=d.sent(),[4,this.initializeViewAndComputeSnapshot(a,!1)];case 4:d.sent(),this.remoteStore.listen(a),d.label=5;case 5:return n++,[3,1];case 6:s=function(e){var t;return i.__generator(this,function(n){switch(n.label){case 0:return(t=u.queryViewsByTarget[e])?[4,u.localStore.releaseQuery(t.query,!1).then(function(){f.remoteStore.unlisten(e),f.removeAndCleanupQuery(t)}).catch(function(e){return f.ignoreIfPrimaryLeaseLoss(e)})]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})},u=this,c=0,h=t,d.label=7;case 7:return c<h.length?(l=h[c],[5,s(l)]):[3,10];case 8:d.sent(),d.label=9;case 9:return c++,[3,7];case 10:return[2]}})})},e.prototype.enableNetwork=function(){return this.localStore.setNetworkEnabled(!0),this.remoteStore.enableNetwork()},e.prototype.disableNetwork=function(){return this.localStore.setNetworkEnabled(!1),this.remoteStore.disableNetwork()},e.prototype.getRemoteKeysForTarget=function(e){var t=this.limboResolutionsByTarget[e];return t&&t.receivedDocument?xt().add(t.key):this.queryViewsByTarget[e]?this.queryViewsByTarget[e].view.syncedDocuments:xt()},e}(),go=function(){function e(e){this.uid=e}return e.prototype.isAuthenticated=function(){return null!=this.uid},e.prototype.toKey=function(){return this.isAuthenticated()?\"uid:\"+this.uid:\"anonymous-user\"},e.prototype.isEqual=function(e){return e.uid===this.uid},e.UNAUTHENTICATED=new e(null),e.GOOGLE_CREDENTIALS=new e(\"google-credentials-uid\"),e.FIRST_PARTY=new e(\"first-party-uid\"),e}(),vo=\"SharedClientState\",wo=\"firestore_clients\",bo=\"firestore_mutations\",So=\"firestore_targets\",To=\"firestore_online_state\",Eo=\"firestore_sequence_number\",Io=function(){function e(e,t,n,r){this.user=e,this.batchId=t,this.state=n,this.error=r,p(void 0!==r==(\"rejected\"===n),\"MutationMetadata must contain an error iff state is 'rejected'\")}return e.fromWebStorageEntry=function(t,n,r){var i=JSON.parse(r),o=\"object\"==typeof i&&-1!==[\"pending\",\"acknowledged\",\"rejected\"].indexOf(i.state)&&(void 0===i.error||\"object\"==typeof i.error),a=void 0;return o&&i.error&&(o=\"string\"==typeof i.error.message&&\"string\"==typeof i.error.code)&&(a=new v(i.error.code,i.error.message)),o?new e(t,n,i.state,a):(l(vo,\"Failed to parse mutation state for ID '\"+n+\"': \"+r),null)},e.prototype.toWebStorageJSON=function(){var e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)},e}(),Do=function(){function e(e,t,n){this.targetId=e,this.state=t,this.error=n,p(void 0!==n==(\"rejected\"===t),\"QueryTargetMetadata must contain an error iff state is 'rejected'\")}return e.fromWebStorageEntry=function(t,n){var r=JSON.parse(n),i=\"object\"==typeof r&&-1!==[\"not-current\",\"current\",\"rejected\"].indexOf(r.state)&&(void 0===r.error||\"object\"==typeof r.error),o=void 0;return i&&r.error&&(i=\"string\"==typeof r.error.message&&\"string\"==typeof r.error.code)&&(o=new v(r.error.code,r.error.message)),i?new e(t,r.state,o):(l(vo,\"Failed to parse target state for ID '\"+t+\"': \"+n),null)},e.prototype.toWebStorageJSON=function(){var e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)},e}(),Co=function(){function e(e,t){this.clientId=e,this.activeTargetIds=t}return e.fromWebStorageEntry=function(t,n){for(var r=JSON.parse(n),i=\"object\"==typeof r&&r.activeTargetIds instanceof Array,o=Ft(),a=0;i&&a<r.activeTargetIds.length;++a)i=je(r.activeTargetIds[a]),o=o.add(r.activeTargetIds[a]);return i?new e(t,o):(l(vo,\"Failed to parse client data for instance '\"+t+\"': \"+n),null)},e}(),_o=function(){function e(e,t){this.clientId=e,this.onlineState=t}return e.fromWebStorageEntry=function(t){var n=JSON.parse(t);return\"object\"==typeof n&&void 0!==Bi[n.onlineState]&&\"string\"==typeof n.clientId?new e(n.clientId,Bi[n.onlineState]):(l(vo,\"Failed to parse online state: \"+t),null)},e}(),No=function(){function e(){this.activeTargetIds=Ft()}return e.prototype.addQueryTarget=function(e){p(!this.activeTargetIds.has(e),\"Target with ID '\"+e+\"' already active.\"),this.activeTargetIds=this.activeTargetIds.add(e)},e.prototype.removeQueryTarget=function(e){this.activeTargetIds=this.activeTargetIds.delete(e)},e.prototype.toWebStorageJSON=function(){var e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)},e}(),Ao=function(){function e(t,n,r,i,o){if(this.queue=t,this.platform=n,this.persistenceKey=r,this.localClientId=i,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.activeClients={},this.storageListener=this.handleWebStorageEvent.bind(this),this.started=!1,this.earlyEvents=[],!e.isAvailable(this.platform))throw new v(g.UNIMPLEMENTED,\"LocalStorage is not available on this platform.\");var a=r.replace(\/[.*+?^${}()|[\\]\\\\]\/g,\"\\\\$&\");this.storage=this.platform.window.localStorage,this.currentUser=o,this.localClientStorageKey=this.toWebStorageClientStateKey(this.localClientId),this.sequenceNumberKey=Eo+\"_\"+r,this.activeClients[this.localClientId]=new No,this.clientStateKeyRe=new RegExp(\"^\"+wo+\"_\"+a+\"_([^_]*)$\"),this.mutationBatchKeyRe=new RegExp(\"^\"+bo+\"_\"+a+\"_(\\\\d+)(?:_(.*))?$\"),this.queryTargetKeyRe=new RegExp(\"^\"+So+\"_\"+a+\"_(\\\\d+)$\"),this.onlineStateKey=To+\"_\"+r,this.platform.window.addEventListener(\"storage\",this.storageListener)}return e.isAvailable=function(e){return!(!e.window||null==e.window.localStorage)},e.prototype.start=function(){return i.__awaiter(this,void 0,void 0,function(){var e,t,n,r,o,a,s,u,c,h,l,f=this;return i.__generator(this,function(i){switch(i.label){case 0:return p(!this.started,\"WebStorageSharedClientState already started\"),p(null!==this.syncEngine,\"syncEngine property must be set before calling start()\"),p(null!==this.onlineStateHandler,\"onlineStateHandler property must be set before calling start()\"),[4,this.syncEngine.getActiveClients()];case 1:for(e=i.sent(),t=0,n=e;t<n.length;t++)(r=n[t])!==this.localClientId&&(o=this.getItem(this.toWebStorageClientStateKey(r)))&&(a=Co.fromWebStorageEntry(r,o))&&(this.activeClients[a.clientId]=a);for(this.persistClientState(),(s=this.storage.getItem(this.onlineStateKey))&&(u=this.fromWebStorageOnlineState(s))&&this.handleOnlineStateEvent(u),c=0,h=this.earlyEvents;c<h.length;c++)l=h[c],this.handleWebStorageEvent(l);return this.earlyEvents=[],this.platform.window.addEventListener(\"unload\",function(){return f.shutdown()}),this.started=!0,[2]}})})},e.prototype.writeSequenceNumber=function(e){this.setItem(this.sequenceNumberKey,JSON.stringify(e))},e.prototype.getAllActiveQueryTargets=function(){var e=Ft();return I(this.activeClients,function(t,n){e=e.unionWith(n.activeTargetIds)}),e},e.prototype.isActiveQueryTarget=function(e){for(var t in this.activeClients)if(this.activeClients.hasOwnProperty(t)&&this.activeClients[t].activeTargetIds.has(e))return!0;return!1},e.prototype.addPendingMutation=function(e){this.persistMutationState(e,\"pending\")},e.prototype.updateMutationState=function(e,t,n){this.persistMutationState(e,t,n),this.removeMutationState(e)},e.prototype.addLocalQueryTarget=function(e){var t=\"not-current\";if(this.isActiveQueryTarget(e)){var n=this.storage.getItem(this.toWebStorageQueryTargetMetadataKey(e));if(n){var r=Do.fromWebStorageEntry(e,n);r&&(t=r.state)}}return this.localClientState.addQueryTarget(e),this.persistClientState(),t},e.prototype.removeLocalQueryTarget=function(e){this.localClientState.removeQueryTarget(e),this.persistClientState()},e.prototype.isLocalQueryTarget=function(e){return this.localClientState.activeTargetIds.has(e)},e.prototype.clearQueryState=function(e){this.removeItem(this.toWebStorageQueryTargetMetadataKey(e))},e.prototype.updateQueryState=function(e,t,n){this.persistQueryTargetState(e,t,n)},e.prototype.handleUserChange=function(e,t,n){var r=this;t.forEach(function(e){r.removeMutationState(e)}),this.currentUser=e,n.forEach(function(e){r.addPendingMutation(e)})},e.prototype.setOnlineState=function(e){this.persistOnlineState(e)},e.prototype.shutdown=function(){this.started&&(this.platform.window.removeEventListener(\"storage\",this.storageListener),this.removeItem(this.localClientStorageKey),this.started=!1)},e.prototype.getItem=function(e){var t=this.storage.getItem(e);return h(vo,\"READ\",e,t),t},e.prototype.setItem=function(e,t){h(vo,\"SET\",e,t),this.storage.setItem(e,t)},e.prototype.removeItem=function(e){h(vo,\"REMOVE\",e),this.storage.removeItem(e)},e.prototype.handleWebStorageEvent=function(e){var t=this;if(e.storageArea===this.storage){if(h(vo,\"EVENT\",e.key,e.newValue),e.key===this.localClientStorageKey)return void l(\"Received WebStorage notification for local change. Another client might have garbage-collected our state\");this.queue.enqueueAndForget(function(){return i.__awaiter(t,void 0,void 0,function(){var t,n,r,o,a,s;return i.__generator(this,function(i){if(!this.started)return this.earlyEvents.push(e),[2];if(null===e.key)return[2];if(this.clientStateKeyRe.test(e.key)){if(null==e.newValue)return n=this.fromWebStorageClientStateKey(e.key),[2,this.handleClientStateEvent(n,null)];if(t=this.fromWebStorageClientState(e.key,e.newValue))return[2,this.handleClientStateEvent(t.clientId,t)]}else if(this.mutationBatchKeyRe.test(e.key)){if(null!==e.newValue&&(r=this.fromWebStorageMutationMetadata(e.key,e.newValue)))return[2,this.handleMutationBatchEvent(r)]}else if(this.queryTargetKeyRe.test(e.key)){if(null!==e.newValue&&(o=this.fromWebStorageQueryTargetMetadata(e.key,e.newValue)))return[2,this.handleQueryTargetEvent(o)]}else if(e.key===this.onlineStateKey){if(null!==e.newValue&&(a=this.fromWebStorageOnlineState(e.newValue)))return[2,this.handleOnlineStateEvent(a)]}else e.key===this.sequenceNumberKey&&(p(!!this.sequenceNumberHandler,\"Missing sequenceNumberHandler\"),(s=ko(e.newValue))!==Dn.INVALID&&this.sequenceNumberHandler(s));return[2]})})})}},Object.defineProperty(e.prototype,\"localClientState\",{get:function(){return this.activeClients[this.localClientId]},enumerable:!0,configurable:!0}),e.prototype.persistClientState=function(){this.setItem(this.localClientStorageKey,this.localClientState.toWebStorageJSON())},e.prototype.persistMutationState=function(e,t,n){var r=new Io(this.currentUser,e,t,n),i=this.toWebStorageMutationBatchKey(e);this.setItem(i,r.toWebStorageJSON())},e.prototype.removeMutationState=function(e){var t=this.toWebStorageMutationBatchKey(e);this.removeItem(t)},e.prototype.persistOnlineState=function(e){var t={clientId:this.localClientId,onlineState:Bi[e]};this.storage.setItem(this.onlineStateKey,JSON.stringify(t))},e.prototype.persistQueryTargetState=function(e,t,n){var r=this.toWebStorageQueryTargetMetadataKey(e),i=new Do(e,t,n);this.setItem(r,i.toWebStorageJSON())},e.prototype.toWebStorageClientStateKey=function(e){return p(-1===e.indexOf(\"_\"),\"Client key cannot contain '_', but was '\"+e+\"'\"),wo+\"_\"+this.persistenceKey+\"_\"+e},e.prototype.toWebStorageQueryTargetMetadataKey=function(e){return So+\"_\"+this.persistenceKey+\"_\"+e},e.prototype.toWebStorageMutationBatchKey=function(e){var t=bo+\"_\"+this.persistenceKey+\"_\"+e;return this.currentUser.isAuthenticated()&&(t+=\"_\"+this.currentUser.uid),t},e.prototype.fromWebStorageClientStateKey=function(e){var t=this.clientStateKeyRe.exec(e);return t?t[1]:null},e.prototype.fromWebStorageClientState=function(e,t){var n=this.fromWebStorageClientStateKey(e);return p(null!==n,\"Cannot parse client state key '\"+e+\"'\"),Co.fromWebStorageEntry(n,t)},e.prototype.fromWebStorageMutationMetadata=function(e,t){var n=this.mutationBatchKeyRe.exec(e);p(null!==n,\"Cannot parse mutation batch key '\"+e+\"'\");var r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return Io.fromWebStorageEntry(new go(i),r,t)},e.prototype.fromWebStorageQueryTargetMetadata=function(e,t){var n=this.queryTargetKeyRe.exec(e);p(null!==n,\"Cannot parse query target key '\"+e+\"'\");var r=Number(n[1]);return Do.fromWebStorageEntry(r,t)},e.prototype.fromWebStorageOnlineState=function(e){return _o.fromWebStorageEntry(e)},e.prototype.handleMutationBatchEvent=function(e){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(t){return e.user.uid!==this.currentUser.uid?(h(vo,\"Ignoring mutation for non-active user \"+e.user.uid),[2]):[2,this.syncEngine.applyBatchState(e.batchId,e.state,e.error)]})})},e.prototype.handleQueryTargetEvent=function(e){return this.syncEngine.applyTargetState(e.targetId,e.state,e.error)},e.prototype.handleClientStateEvent=function(e,t){var n=this,r=this.getAllActiveQueryTargets();t?this.activeClients[e]=t:delete this.activeClients[e];var o=this.getAllActiveQueryTargets(),a=[],s=[];return o.forEach(function(e){return i.__awaiter(n,void 0,void 0,function(){return i.__generator(this,function(t){return r.has(e)||a.push(e),[2]})})}),r.forEach(function(e){return i.__awaiter(n,void 0,void 0,function(){return i.__generator(this,function(t){return o.has(e)||s.push(e),[2]})})}),this.syncEngine.applyActiveTargetsChange(a,s)},e.prototype.handleOnlineStateEvent=function(e){this.activeClients[e.clientId]&&this.onlineStateHandler(e.onlineState)},e}();function ko(e){var t=Dn.INVALID;if(null!=e)try{var n=JSON.parse(e);p(\"number\"==typeof n,\"Found non-numeric sequence number\"),t=n}catch(e){l(vo,\"Failed to read sequence number from WebStorage\",e)}return t}var Ro=function(){function e(){this.localState=new No,this.queryState={},this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null}return e.prototype.addPendingMutation=function(e){},e.prototype.updateMutationState=function(e,t,n){},e.prototype.addLocalQueryTarget=function(e){return this.localState.addQueryTarget(e),this.queryState[e]||\"not-current\"},e.prototype.updateQueryState=function(e,t,n){this.queryState[e]=t},e.prototype.removeLocalQueryTarget=function(e){this.localState.removeQueryTarget(e)},e.prototype.isLocalQueryTarget=function(e){return this.localState.activeTargetIds.has(e)},e.prototype.clearQueryState=function(e){delete this.queryState[e]},e.prototype.getAllActiveQueryTargets=function(){return this.localState.activeTargetIds},e.prototype.isActiveQueryTarget=function(e){return this.localState.activeTargetIds.has(e)},e.prototype.start=function(){return this.localState=new No,Promise.resolve()},e.prototype.handleUserChange=function(e,t,n){},e.prototype.setOnlineState=function(e){},e.prototype.shutdown=function(){},e.prototype.writeSequenceNumber=function(e){},e}(),Mo=\"FirestoreClient\",Oo=20,Po=22,Lo=function(){function e(e,t,n,r){this.platform=e,this.databaseInfo=t,this.credentials=n,this.asyncQueue=r,this.clientId=H.newId()}return e.prototype.start=function(e){var t=this,n=new Cn,r=new Cn,i=!1;return this.credentials.setChangeListener(function(o){i?t.asyncQueue.enqueueAndForget(function(){return t.handleCredentialChange(o)}):(i=!0,t.initializePersistence(e,r,o).then(function(){return t.initializeRest(o)}).then(n.resolve,n.reject))}),this.asyncQueue.enqueueAndForget(function(){return n.promise}),r.promise},e.prototype.enableNetwork=function(){var e=this;return this.asyncQueue.enqueue(function(){return e.syncEngine.enableNetwork()})},e.prototype.initializePersistence=function(e,t,n){var r=this;return e.enabled?this.startIndexedDbPersistence(n,e).then(t.resolve).catch(function(e){return t.reject(e),r.canFallback(e)?(console.warn(\"Error enabling offline storage. Falling back to storage disabled: \"+e),r.startMemoryPersistence()):Promise.reject(e)}):(t.resolve(),this.startMemoryPersistence())},e.prototype.canFallback=function(e){return e instanceof v?e.code===g.FAILED_PRECONDITION||e.code===g.UNIMPLEMENTED:!(\"undefined\"!=typeof DOMException&&e instanceof DOMException)||(e.code===Po||e.code===Oo)},e.prototype.startIndexedDbPersistence=function(e,t){var n=this;p(t.enabled,\"Should only start IndexedDb persitence with offline persistence enabled.\");var r=di.buildStoragePrefix(this.databaseInfo),o=new an(this.databaseInfo.databaseId,{useProto3Json:!0});return Promise.resolve().then(function(){return i.__awaiter(n,void 0,void 0,function(){var n,a;return i.__generator(this,function(i){switch(i.label){case 0:if(t.experimentalTabSynchronization&&!Ao.isAvailable(this.platform))throw new v(g.UNIMPLEMENTED,\"IndexedDB persistence is only available on platforms that support LocalStorage.\");return t.experimentalTabSynchronization?(this.sharedClientState=new Ao(this.asyncQueue,this.platform,r,this.clientId,e),n=this,[4,di.createMultiClientIndexedDbPersistence(r,this.clientId,this.platform,this.asyncQueue,o,{sequenceNumberSyncer:this.sharedClientState})]):[3,2];case 1:return n.persistence=i.sent(),[3,4];case 2:return this.sharedClientState=new Ro,a=this,[4,di.createIndexedDbPersistence(r,this.clientId,this.platform,this.asyncQueue,o)];case 3:a.persistence=i.sent(),i.label=4;case 4:return[2]}})})})},e.prototype.startMemoryPersistence=function(){var e=new an(this.databaseInfo.databaseId,{useProto3Json:!0});return this.persistence=Oi.createEagerPersistence(this.clientId,e),this.sharedClientState=new Ro,Promise.resolve()},e.prototype.initializeRest=function(e){var t=this;return h(Mo,\"Initializing. user=\",e.uid),this.platform.loadConnection(this.databaseInfo).then(function(n){return i.__awaiter(t,void 0,void 0,function(){var t,r,o,a,s=this;return i.__generator(this,function(i){switch(i.label){case 0:return this.localStore=new Di(this.persistence,e),t=this.platform.newSerializer(this.databaseInfo.databaseId),r=new Yi(this.asyncQueue,n,this.credentials,t),o=function(e){return s.syncEngine.applyOnlineStateChange(e,Ui.RemoteStore)},a=function(e){return s.syncEngine.applyOnlineStateChange(e,Ui.SharedClientState)},this.remoteStore=new ro(this.localStore,r,this.asyncQueue,o),this.syncEngine=new yo(this.localStore,this.remoteStore,this.sharedClientState,e),this.sharedClientState.onlineStateHandler=a,this.remoteStore.syncEngine=this.syncEngine,this.sharedClientState.syncEngine=this.syncEngine,this.eventMgr=new oo(this.syncEngine),[4,this.sharedClientState.start()];case 1:return i.sent(),[4,this.remoteStore.start()];case 2:return i.sent(),[4,this.persistence.setPrimaryStateListener(function(e){return s.syncEngine.applyPrimaryState(e)})];case 3:return i.sent(),[2]}})})})},e.prototype.handleCredentialChange=function(e){return this.asyncQueue.verifyOperationInProgress(),h(Mo,\"Credential Changed. Current user: \"+e.uid),this.syncEngine.handleCredentialChange(e)},e.prototype.disableNetwork=function(){var e=this;return this.asyncQueue.enqueue(function(){return e.syncEngine.disableNetwork()})},e.prototype.shutdown=function(e){var t=this;return this.asyncQueue.enqueue(function(){return i.__awaiter(t,void 0,void 0,function(){return i.__generator(this,function(t){switch(t.label){case 0:return[4,this.remoteStore.shutdown()];case 1:return t.sent(),[4,this.sharedClientState.shutdown()];case 2:return t.sent(),[4,this.persistence.shutdown(e&&e.purgePersistenceWithDataLoss)];case 3:return t.sent(),this.credentials.removeChangeListener(),[2]}})})})},e.prototype.listen=function(e,t,n){var r=this,i=new ao(e,t,n);return this.asyncQueue.enqueueAndForget(function(){return r.eventMgr.listen(i)}),i},e.prototype.unlisten=function(e){var t=this;this.asyncQueue.enqueueAndForget(function(){return t.eventMgr.unlisten(e)})},e.prototype.getDocumentFromLocalCache=function(e){var t=this;return this.asyncQueue.enqueue(function(){return t.localStore.readDocument(e)}).then(function(e){if(e instanceof ge)return e;if(e instanceof ve)return null;throw new v(g.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.)\")})},e.prototype.getDocumentsFromLocalCache=function(e){var t=this;return this.asyncQueue.enqueue(function(){return t.localStore.executeQuery(e)}).then(function(t){var n=xt(),r=new ho(e,n),i=r.computeDocChanges(t);return r.applyChanges(i,!1).snapshot})},e.prototype.write=function(e){var t=this,n=new Cn;return this.asyncQueue.enqueueAndForget(function(){return t.syncEngine.write(e,n)}),n.promise},e.prototype.databaseId=function(){return this.databaseInfo.databaseId},e.prototype.transaction=function(e){var t=this;return this.asyncQueue.enqueue(function(){return i.__awaiter(t,void 0,void 0,function(){return i.__generator(this,function(e){return[2]})})}).then(function(){return t.syncEngine.runTransaction(e)})},e}(),xo=function(){function e(e){this.observer=e,this.muted=!1}return e.prototype.next=function(e){this.scheduleEvent(this.observer.next,e)},e.prototype.error=function(e){this.scheduleEvent(this.observer.error,e)},e.prototype.mute=function(){this.muted=!0},e.prototype.scheduleEvent=function(e,t){var n=this;this.muted||setTimeout(function(){n.muted||e(t)},0)},e}(),qo=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];k(\"FieldPath\",e,\"fieldNames\",1);for(var n=0;n<e.length;++n)if(R(\"FieldPath\",\"string\",n,e[n]),0===e[n].length)throw new v(g.INVALID_ARGUMENT,\"Invalid field name at argument $(i + 1). Field names must not be empty.\");this._internalPath=new pe(e)}return e.documentId=function(){return e._DOCUMENT_ID},e.prototype.isEqual=function(t){if(!(t instanceof e))throw z(\"isEqual\",\"FieldPath\",1,t);return this._internalPath.isEqual(t._internalPath)},e._DOCUMENT_ID=new e(pe.keyField().canonicalString()),e}(),Fo=new RegExp(\"[~\\\\*\/\\\\[\\\\]]\");function Vo(e){if(e.search(Fo)>=0)throw new v(g.INVALID_ARGUMENT,\"Invalid field path (\"+e+\"). Paths must not contain '~', '*', '\/', '[', or ']'\");try{return new(qo.bind.apply(qo,[void 0].concat(e.split(\".\"))))}catch(t){throw new v(g.INVALID_ARGUMENT,\"Invalid field path (\"+e+\"). Paths must not be empty, begin with '.', end with '.', or contain '..'\")}}var Bo=function(){return function(e,t){this.user=t,this.type=\"OAuth\",this.authHeaders={Authorization:\"Bearer \"+e}}}(),Uo=function(){function e(){this.changeListener=null}return e.prototype.getToken=function(){return Promise.resolve(null)},e.prototype.invalidateToken=function(){},e.prototype.setChangeListener=function(e){p(!this.changeListener,\"Can only call setChangeListener() once.\"),this.changeListener=e,e(go.UNAUTHENTICATED)},e.prototype.removeChangeListener=function(){p(null!==this.changeListener,\"removeChangeListener() when no listener registered\"),this.changeListener=null},e}(),Qo=function(){function e(e){var t=this;this.app=e,this.tokenListener=null,this.tokenCounter=0,this.changeListener=null,this.forceRefresh=!1,this.tokenListener=function(){t.tokenCounter++,t.currentUser=t.getUser(),t.changeListener&&t.changeListener(t.currentUser)},this.tokenCounter=0,this.app.INTERNAL.addAuthTokenListener(this.tokenListener)}return e.prototype.getToken=function(){var e=this;p(null!=this.tokenListener,\"getToken cannot be called after listener removed.\");var t=this.tokenCounter,n=this.forceRefresh;return this.forceRefresh=!1,this.app.INTERNAL.getToken(n).then(function(n){if(e.tokenCounter!==t)throw new v(g.ABORTED,\"getToken aborted due to token change.\");return n?(p(\"string\"==typeof n.accessToken,\"Invalid tokenData returned from getToken():\"+n),new Bo(n.accessToken,e.currentUser)):null})},e.prototype.invalidateToken=function(){this.forceRefresh=!0},e.prototype.setChangeListener=function(e){p(!this.changeListener,\"Can only call setChangeListener() once.\"),this.changeListener=e,this.currentUser&&e(this.currentUser)},e.prototype.removeChangeListener=function(){p(null!=this.tokenListener,\"removeChangeListener() called twice\"),p(null!==this.changeListener,\"removeChangeListener() called when no listener registered\"),this.app.INTERNAL.removeAuthTokenListener(this.tokenListener),this.tokenListener=null,this.changeListener=null},e.prototype.getUser=function(){var e=this.app.INTERNAL.getUid();return p(null===e||\"string\"==typeof e,\"Received invalid UID: \"+e),new go(e)},e}(),Ko=function(){function e(e,t){this.gapi=e,this.sessionIndex=t,this.type=\"FirstParty\",this.user=go.FIRST_PARTY,p(this.gapi&&this.gapi.auth&&this.gapi.auth.getAuthHeaderValueForFirstParty,\"unexpected gapi interface\")}return Object.defineProperty(e.prototype,\"authHeaders\",{get:function(){return{Authorization:this.gapi.auth.getAuthHeaderValueForFirstParty([]),\"X-Goog-AuthUser\":this.sessionIndex}},enumerable:!0,configurable:!0}),e}(),Wo=function(){function e(e,t){this.gapi=e,this.sessionIndex=t,p(this.gapi&&this.gapi.auth&&this.gapi.auth.getAuthHeaderValueForFirstParty,\"unexpected gapi interface\")}return e.prototype.getToken=function(){return Promise.resolve(new Ko(this.gapi,this.sessionIndex))},e.prototype.setChangeListener=function(e){e(go.FIRST_PARTY)},e.prototype.removeChangeListener=function(){},e.prototype.invalidateToken=function(){},e}();function zo(e){if(!e)return new Uo;switch(e.type){case\"gapi\":return new Wo(e.client,e.sessionIndex||\"0\");case\"provider\":return e.client;default:throw new v(g.INVALID_ARGUMENT,\"makeCredentialsProvider failed due to invalid credential type\")}}function jo(e){return Go(e,[\"next\",\"error\",\"complete\"])}function Go(e,t){if(\"object\"!=typeof e||null===e)return!1;for(var n=e,r=0,i=t;r<i.length;r++){var o=i[r];if(o in n&&\"function\"==typeof n[o])return!0}return!1}var Ho,Yo=function(){function e(e){this._methodName=e}return e.delete=function(){return Jo.instance},e.serverTimestamp=function(){return Xo.instance},e.arrayUnion=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return N(\"FieldValue.arrayUnion\",arguments,1),new Zo(e)},e.arrayRemove=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return N(\"FieldValue.arrayRemove\",arguments,1),new $o(e)},e.prototype.isEqual=function(e){return this===e},e}(),Jo=function(e){function t(){return e.call(this,\"FieldValue.delete\")||this}return i.__extends(t,e),t.instance=new t,t}(Yo),Xo=function(e){function t(){return e.call(this,\"FieldValue.serverTimestamp\")||this}return i.__extends(t,e),t.instance=new t,t}(Yo),Zo=function(e){function t(t){var n=e.call(this,\"FieldValue.arrayUnion\")||this;return n._elements=t,n}return i.__extends(t,e),t}(Yo),$o=function(e){function t(t){var n=e.call(this,\"FieldValue.arrayRemove\")||this;return n._elements=t,n}return i.__extends(t,e),t}(Yo),ea=w(Yo,\"Use FieldValue.<field>() instead.\"),ta=\/^__.*__$\/,na=function(){function e(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}return e.prototype.toMutations=function(e,t){var n=[];return null!==this.fieldMask?n.push(new pt(e,this.data,this.fieldMask,t)):n.push(new dt(e,this.data,t)),this.fieldTransforms.length>0&&n.push(new mt(e,this.fieldTransforms)),n},e}(),ra=function(){function e(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}return e.prototype.toMutations=function(e,t){var n=[new pt(e,this.data,this.fieldMask,t)];return this.fieldTransforms.length>0&&n.push(new mt(e,this.fieldTransforms)),n},e}();function ia(e){switch(e){case Ho.Set:case Ho.MergeSet:case Ho.Update:return!0;case Ho.Argument:return!1;default:throw d(\"Unexpected case for UserDataSource: \"+e)}}!function(e){e[e.Set=0]=\"Set\",e[e.Update=1]=\"Update\",e[e.MergeSet=2]=\"MergeSet\",e[e.Argument=3]=\"Argument\"}(Ho||(Ho={}));var oa=function(){function e(e,t,n,r,i,o){this.dataSource=e,this.methodName=t,this.path=n,this.arrayElement=r,void 0===i&&this.validatePath(),this.arrayElement=void 0!==r&&r,this.fieldTransforms=i||[],this.fieldMask=o||[]}return e.prototype.childContextForField=function(t){var n=null==this.path?null:this.path.child(t),r=new e(this.dataSource,this.methodName,n,!1,this.fieldTransforms,this.fieldMask);return r.validatePathSegment(t),r},e.prototype.childContextForFieldPath=function(t){var n=null==this.path?null:this.path.child(t),r=new e(this.dataSource,this.methodName,n,!1,this.fieldTransforms,this.fieldMask);return r.validatePath(),r},e.prototype.childContextForArray=function(t){return new e(this.dataSource,this.methodName,null,!0,this.fieldTransforms,this.fieldMask)},e.prototype.createError=function(e){var t=null===this.path||this.path.isEmpty()?\"\":\" (found in field \"+this.path.toString()+\")\";return new v(g.INVALID_ARGUMENT,\"Function \"+this.methodName+\"() called with invalid data. \"+e+t)},e.prototype.contains=function(e){return void 0!==this.fieldMask.find(function(t){return e.isPrefixOf(t)})||void 0!==this.fieldTransforms.find(function(t){return e.isPrefixOf(t.field)})},e.prototype.validatePath=function(){if(null!==this.path)for(var e=0;e<this.path.length;e++)this.validatePathSegment(this.path.get(e))},e.prototype.validatePathSegment=function(e){if(ia(this.dataSource)&&ta.test(e))throw this.createError(\"Document fields cannot begin and end with __\")},e}(),aa=function(){return function(e,t){this.databaseId=e,this.key=t}}(),sa=function(){function e(e){this.preConverter=e}return e.prototype.parseSetData=function(e,t){var n=new oa(Ho.Set,e,pe.EMPTY_PATH);ca(\"Data must be an object, but it was:\",n,t);var r=this.parseData(t,n);return new na(r,null,n.fieldTransforms)},e.prototype.parseMergeData=function(e,t,n){var r=new oa(Ho.MergeSet,e,pe.EMPTY_PATH);ca(\"Data must be an object, but it was:\",r,t);var i,o,a=this.parseData(t,r);if(n){for(var s=[],u=0,c=n;u<c.length;u++){var h=c[u],l=void 0;if(h instanceof qo)l=h._internalPath;else{if(\"string\"!=typeof h)throw d(\"Expected stringOrFieldPath to be a string or a FieldPath\");l=la(e,h)}if(!r.contains(l))throw new v(g.INVALID_ARGUMENT,\"Field '\"+l+\"' is specified in your field mask but missing from your input data.\");s.push(l)}i=new ut(s),o=r.fieldTransforms.filter(function(e){return i.covers(e.field)})}else i=new ut(r.fieldMask),o=r.fieldTransforms;return new na(a,i,o)},e.prototype.parseUpdateData=function(e,t){var n=this,r=new oa(Ho.Update,e,pe.EMPTY_PATH);ca(\"Data must be an object, but it was:\",r,t);var i=[],o=Ve.EMPTY;I(t,function(t,a){var s=la(e,t),u=r.childContextForFieldPath(s);if((a=n.runPreConverter(a,u))instanceof Jo)i.push(s);else{var c=n.parseData(a,u);null!=c&&(i.push(s),o=o.set(s,c))}});var a=new ut(i);return new ra(o,a,r.fieldTransforms)},e.prototype.parseUpdateVarargs=function(e,t,n,r){var i=new oa(Ho.Update,e,pe.EMPTY_PATH),o=[ha(e,t)],a=[n];if(r.length%2!=0)throw new v(g.INVALID_ARGUMENT,\"Function \"+e+\"() needs to be called with an even number of arguments that alternate between field names and values.\");for(var s=0;s<r.length;s+=2)o.push(ha(e,r[s])),a.push(r[s+1]);var u=[],c=Ve.EMPTY;for(s=0;s<o.length;++s){var h=o[s],l=i.childContextForFieldPath(h),f=this.runPreConverter(a[s],l);if(f instanceof Jo)u.push(h);else{var d=this.parseData(f,l);null!=d&&(u.push(h),c=c.set(h,d))}}var p=new ut(u);return new ra(c,p,i.fieldTransforms)},e.prototype.parseQueryValue=function(e,t){var n=new oa(Ho.Argument,e,pe.EMPTY_PATH),r=this.parseData(t,n);return p(null!=r,\"Parsed data should not be null.\"),p(0===n.fieldTransforms.length,\"Field transforms should have been disallowed.\"),r},e.prototype.runPreConverter=function(e,t){try{return this.preConverter(e)}catch(e){var n=fa(e);throw t.createError(n)}},e.prototype.parseData=function(e,t){if(ua(e=this.runPreConverter(e,t)))return ca(\"Unsupported field value:\",t,e),this.parseObject(e,t);if(e instanceof Yo)return this.parseSentinelFieldValue(e,t),null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.arrayElement)throw t.createError(\"Nested arrays are not supported\");return this.parseArray(e,t)}return this.parseScalarValue(e,t)},e.prototype.parseObject=function(e,t){var n=this,r=new be(Y);return D(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):I(e,function(e,i){var o=n.parseData(i,t.childContextForField(e));null!=o&&(r=r.insert(e,o))}),new Ve(r)},e.prototype.parseArray=function(e,t){for(var n=[],r=0,i=0,o=e;i<o.length;i++){var a=o[i],s=this.parseData(a,t.childContextForArray(r));null==s&&(s=Ce.INSTANCE),n.push(s),r++}return new Be(n)},e.prototype.parseSentinelFieldValue=function(e,t){if(!ia(t.dataSource))throw t.createError(e._methodName+\"() can only be used with update() and set()\");if(null===t.path)throw t.createError(e._methodName+\"() is not currently supported inside arrays\");if(e instanceof Jo){if(t.dataSource!==Ho.MergeSet)throw t.dataSource===Ho.Update?(p(t.path.length>0,\"FieldValue.delete() at the top level should have already been handled.\"),t.createError(\"FieldValue.delete() can only appear at the top level of your update data\")):t.createError(\"FieldValue.delete() cannot be used with set() unless you pass {merge:true}\");t.fieldMask.push(t.path)}else if(e instanceof Xo)t.fieldTransforms.push(new ct(t.path,gt.instance));else if(e instanceof Zo){var n=this.parseArrayTransformElements(e._methodName,e._elements),r=new vt(n);t.fieldTransforms.push(new ct(t.path,r))}else if(e instanceof $o){n=this.parseArrayTransformElements(e._methodName,e._elements);var i=new wt(n);t.fieldTransforms.push(new ct(t.path,i))}else d(\"Unknown FieldValue type: \"+e)},e.prototype.parseScalarValue=function(e,t){if(null===e)return Ce.INSTANCE;if(\"number\"==typeof e)return je(e)?new Re(e):new Me(e);if(\"boolean\"==typeof e)return _e.of(e);if(\"string\"==typeof e)return new Oe(e);if(e instanceof Date)return new Pe(ae.fromDate(e));if(e instanceof ae)return new Pe(new ae(e.seconds,1e3*Math.floor(e.nanoseconds\/1e3)));if(e instanceof oe)return new Fe(e);if(e instanceof re)return new xe(e);if(e instanceof aa)return new qe(e.databaseId,e.key);throw t.createError(\"Unsupported field value: \"+U(e))},e.prototype.parseArrayTransformElements=function(e,t){var n=this;return t.map(function(t,r){var i=new oa(Ho.Argument,e,pe.EMPTY_PATH);return n.parseData(t,i.childContextForArray(r))})},e}();function ua(e){return!(\"object\"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof ae||e instanceof oe||e instanceof re||e instanceof aa||e instanceof Yo)}function ca(e,t,n){if(!ua(n)||!B(n)){var r=U(n);throw\"an object\"===r?t.createError(e+\" a custom object\"):t.createError(e+\" \"+r)}}function ha(e,t){if(t instanceof qo)return t._internalPath;if(\"string\"==typeof t)return la(e,t);throw new v(g.INVALID_ARGUMENT,\"Function \"+e+\"() called with invalid data. Field path arguments must be of type string or FieldPath.\")}function la(e,t){try{return Vo(t)._internalPath}catch(t){var n=fa(t);throw new v(g.INVALID_ARGUMENT,\"Function \"+e+\"() called with invalid data. \"+n)}}function fa(e){return e instanceof Error?e.message:e.toString()}var da=\"firestore.googleapis.com\",pa=!0,ma=!1,ya=!1,ga=function(){function e(e){if(void 0===e.host){if(void 0!==e.ssl)throw new v(g.INVALID_ARGUMENT,\"Can't provide ssl option if host option is not set\");this.host=da,this.ssl=pa}else O(\"settings\",\"non-empty string\",\"host\",e.host),this.host=e.host,P(\"settings\",\"boolean\",\"ssl\",e.ssl),this.ssl=S(e.ssl,pa);W(\"settings\",e,[\"host\",\"ssl\",\"credentials\",\"timestampsInSnapshots\"]),P(\"settings\",\"object\",\"credentials\",e.credentials),this.credentials=e.credentials,P(\"settings\",\"boolean\",\"timestampsInSnapshots\",e.timestampsInSnapshots),this.timestampsInSnapshots=S(e.timestampsInSnapshots,ma)}return e.prototype.isEqual=function(e){return this.host===e.host&&this.ssl===e.ssl&&this.timestampsInSnapshots===e.timestampsInSnapshots&&this.credentials===e.credentials},e}(),va=function(){return function(){}}(),wa=function(){function e(e,t){this.enabled=e,p(e||!t,\"Can only provide PersistenceSettings with persistence enabled\"),t=t||{},this.experimentalTabSynchronization=S(t.experimentalTabSynchronization,ya)}return e.prototype.isEqual=function(e){return this.enabled===e.enabled&&this.experimentalTabSynchronization===e.experimentalTabSynchronization},e}(),ba=function(){function e(t){var n=this;this._queue=new Nn,this.INTERNAL={delete:function(e){return i.__awaiter(n,void 0,void 0,function(){return i.__generator(this,function(t){return this._firestoreClient?[2,this._firestoreClient.shutdown(e)]:[2]})})}};var r=new va;if(\"object\"==typeof t.options){var o=t;r.firebaseApp=o,r.databaseId=e.databaseIdFromApp(o),r.persistenceKey=r.firebaseApp.name,r.credentials=new Qo(o)}else{var a=t;if(!a.projectId)throw new v(g.INVALID_ARGUMENT,\"Must provide projectId\");r.databaseId=new ce(a.projectId,a.database),r.persistenceKey=\"[DEFAULT]\",r.credentials=new Uo}r.settings=new ga({}),this._config=r,this._databaseId=r.databaseId}return e.prototype.settings=function(e){if(_(\"Firestore.settings\",arguments,1),R(\"Firestore.settings\",\"object\",1,e),b(e,\"persistence\"))throw new v(g.INVALID_ARGUMENT,'\"persistence\" is now specified with a separate call to firestore.enablePersistence().');var t=new ga(e);if(this._firestoreClient&&!this._config.settings.isEqual(t))throw new v(g.FAILED_PRECONDITION,\"Firestore has already been started and its settings can no longer be changed. You can only call settings() before calling any other methods on a Firestore object.\");this._config.settings=t,void 0!==t.credentials&&(this._config.credentials=zo(t.credentials))},e.prototype.enableNetwork=function(){return this.ensureClientConfigured(),this._firestoreClient.enableNetwork()},e.prototype.disableNetwork=function(){return this.ensureClientConfigured(),this._firestoreClient.disableNetwork()},e.prototype.enablePersistence=function(e){if(this._firestoreClient)throw new v(g.FAILED_PRECONDITION,\"Firestore has already been started and persistence can no longer be enabled. You can only call enablePersistence() before calling any other methods on a Firestore object.\");return this.configureClient(new wa(!0,e))},e.prototype.ensureClientConfigured=function(){return this._firestoreClient||this.configureClient(new wa(!1)),this._firestoreClient},e.prototype.configureClient=function(e){var t=this;p(!!this._config.settings.host,\"FirestoreSettings.host cannot be falsey\"),this._config.settings.timestampsInSnapshots||l(\"\\nThe behavior for Date objects stored in Firestore is going to change\\nAND YOUR APP MAY BREAK.\\nTo hide this warning and ensure your app does not break, you need to add the\\nfollowing code to your app before calling any other Cloud Firestore methods:\\n\\n  const firestore = firebase.firestore();\\n  const settings = {\/* your settings... *\/ timestampsInSnapshots: true};\\n  firestore.settings(settings);\\n\\nWith this change, timestamps stored in Cloud Firestore will be read back as\\nFirebase Timestamp objects instead of as system Date objects. So you will also\\nneed to update code expecting a Date to instead expect a Timestamp. For example:\\n\\n  \/\/ Old:\\n  const date = snapshot.get('created_at');\\n  \/\/ New:\\n  const timestamp = snapshot.get('created_at');\\n  const date = timestamp.toDate();\\n\\nPlease audit all existing usages of Date when you enable the new behavior. In a\\nfuture release, the behavior will change to the new behavior, so if you do not\\nfollow these steps, YOUR APP MAY BREAK.\"),p(!this._firestoreClient,\"configureClient() called multiple times\");var n=new se(this._config.databaseId,this._config.persistenceKey,this._config.settings.host,this._config.settings.ssl);return this._dataConverter=new sa(function(e){if(e instanceof Ea){var n=t._config.databaseId,r=e.firestore._config.databaseId;if(!r.isEqual(n))throw new v(g.INVALID_ARGUMENT,\"Document reference is for database \"+r.projectId+\"\/\"+r.database+\" but should be for database \"+n.projectId+\"\/\"+n.database);return new aa(t._config.databaseId,e._key)}return e}),this._firestoreClient=new Lo(m.getPlatform(),n,this._config.credentials,this._queue),this._firestoreClient.start(e)},e.databaseIdFromApp=function(e){var t=e.options;if(!b(t,\"projectId\"))throw new v(g.INVALID_ARGUMENT,'\"projectId\" not provided in firebase.initializeApp.');var n=t.projectId;if(!n||\"string\"!=typeof n)throw new v(g.INVALID_ARGUMENT,\"projectId must be a string in FirebaseApp.options\");return new ce(n)},Object.defineProperty(e.prototype,\"app\",{get:function(){if(!this._config.firebaseApp)throw new v(g.FAILED_PRECONDITION,\"Firestore was not initialized using the Firebase SDK. 'app' is not available\");return this._config.firebaseApp},enumerable:!0,configurable:!0}),e.prototype.collection=function(e){if(_(\"Firestore.collection\",arguments,1),R(\"Firestore.collection\",\"non-empty string\",1,e),!e)throw new v(g.INVALID_ARGUMENT,\"Must provide a non-empty collection path to collection()\");return this.ensureClientConfigured(),new Ra(fe.fromString(e),this)},e.prototype.doc=function(e){if(_(\"Firestore.doc\",arguments,1),R(\"Firestore.doc\",\"non-empty string\",1,e),!e)throw new v(g.INVALID_ARGUMENT,\"Must provide a non-empty document path to doc()\");return this.ensureClientConfigured(),Ea.forPath(fe.fromString(e),this)},e.prototype.runTransaction=function(e){var t=this;return _(\"Firestore.runTransaction\",arguments,1),R(\"Firestore.runTransaction\",\"function\",1,e),this.ensureClientConfigured().transaction(function(n){return e(new Sa(t,n))})},e.prototype.batch=function(){return this.ensureClientConfigured(),new Ta(this)},Object.defineProperty(e,\"logLevel\",{get:function(){switch(u()){case t.DEBUG:return\"debug\";case t.ERROR:return\"error\";case t.SILENT:return\"silent\";default:return d(\"Unknown log level: \"+u())}},enumerable:!0,configurable:!0}),e.setLogLevel=function(e){switch(_(\"Firestore.setLogLevel\",arguments,1),R(\"Firestore.setLogLevel\",\"non-empty string\",1,e),e){case\"debug\":c(t.DEBUG);break;case\"error\":c(t.ERROR);break;case\"silent\":c(t.SILENT);break;default:throw new v(g.INVALID_ARGUMENT,\"Invalid log level: \"+e)}},e.prototype._areTimestampsInSnapshotsEnabled=function(){return this._config.settings.timestampsInSnapshots},e}(),Sa=function(){function e(e,t){this._firestore=e,this._transaction=t}return e.prototype.get=function(e){var t=this;_(\"Transaction.get\",arguments,1);var n=La(\"Transaction.get\",e,this._firestore);return this._transaction.lookup([n._key]).then(function(e){if(!e||1!==e.length)return d(\"Mismatch in docs returned from document lookup.\");var r=e[0];if(r instanceof ve)return new Da(t._firestore,n._key,null,!1,!1);if(r instanceof ge)return new Da(t._firestore,n._key,r,!1,!1);throw d(\"BatchGetDocumentsRequest returned unexpected document type: \"+r.constructor.name)})},e.prototype.set=function(e,t,n){A(\"Transaction.set\",arguments,2,3);var r=La(\"Transaction.set\",e,this._firestore),i=(n=Ma(\"Transaction.set\",n)).merge||n.mergeFields?this._firestore._dataConverter.parseMergeData(\"Transaction.set\",t,n.mergeFields):this._firestore._dataConverter.parseSetData(\"Transaction.set\",t);return this._transaction.set(r._key,i),this},e.prototype.update=function(e,t,n){for(var r,i,o=[],a=3;a<arguments.length;a++)o[a-3]=arguments[a];return\"string\"==typeof t||t instanceof qo?(N(\"Transaction.update\",arguments,3),r=La(\"Transaction.update\",e,this._firestore),i=this._firestore._dataConverter.parseUpdateVarargs(\"Transaction.update\",t,n,o)):(_(\"Transaction.update\",arguments,2),r=La(\"Transaction.update\",e,this._firestore),i=this._firestore._dataConverter.parseUpdateData(\"Transaction.update\",t)),this._transaction.update(r._key,i),this},e.prototype.delete=function(e){_(\"Transaction.delete\",arguments,1);var t=La(\"Transaction.delete\",e,this._firestore);return this._transaction.delete(t._key),this},e}(),Ta=function(){function e(e){this._firestore=e,this._mutations=[],this._committed=!1}return e.prototype.set=function(e,t,n){A(\"WriteBatch.set\",arguments,2,3),this.verifyNotCommitted();var r=La(\"WriteBatch.set\",e,this._firestore),i=(n=Ma(\"WriteBatch.set\",n)).merge||n.mergeFields?this._firestore._dataConverter.parseMergeData(\"WriteBatch.set\",t,n.mergeFields):this._firestore._dataConverter.parseSetData(\"WriteBatch.set\",t);return this._mutations=this._mutations.concat(i.toMutations(r._key,lt.NONE)),this},e.prototype.update=function(e,t,n){for(var r,i,o=[],a=3;a<arguments.length;a++)o[a-3]=arguments[a];return this.verifyNotCommitted(),\"string\"==typeof t||t instanceof qo?(N(\"WriteBatch.update\",arguments,3),r=La(\"WriteBatch.update\",e,this._firestore),i=this._firestore._dataConverter.parseUpdateVarargs(\"WriteBatch.update\",t,n,o)):(_(\"WriteBatch.update\",arguments,2),r=La(\"WriteBatch.update\",e,this._firestore),i=this._firestore._dataConverter.parseUpdateData(\"WriteBatch.update\",t)),this._mutations=this._mutations.concat(i.toMutations(r._key,lt.exists(!0))),this},e.prototype.delete=function(e){_(\"WriteBatch.delete\",arguments,1),this.verifyNotCommitted();var t=La(\"WriteBatch.delete\",e,this._firestore);return this._mutations=this._mutations.concat(new yt(t._key,lt.NONE)),this},e.prototype.commit=function(){return i.__awaiter(this,void 0,void 0,function(){return i.__generator(this,function(e){return this.verifyNotCommitted(),this._committed=!0,this._mutations.length>0?[2,this._firestore.ensureClientConfigured().write(this._mutations)]:[2]})})},e.prototype.verifyNotCommitted=function(){if(this._committed)throw new v(g.FAILED_PRECONDITION,\"A write batch can no longer be used after commit() has been called.\")},e}(),Ea=function(){function e(e,t){this._key=e,this.firestore=t,this._firestoreClient=this.firestore.ensureClientConfigured()}return e.forPath=function(t,n){if(t.length%2!=0)throw new v(g.INVALID_ARGUMENT,\"Invalid document reference. Document references must have an even number of segments, but \"+t.canonicalString()+\" has \"+t.length);return new e(new me(t),n)},Object.defineProperty(e.prototype,\"id\",{get:function(){return this._key.path.lastSegment()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,\"parent\",{get:function(){return new Ra(this._key.path.popLast(),this.firestore)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,\"path\",{get:function(){return this._key.path.canonicalString()},enumerable:!0,configurable:!0}),e.prototype.collection=function(e){if(_(\"DocumentReference.collection\",arguments,1),R(\"DocumentReference.collection\",\"non-empty string\",1,e),!e)throw new v(g.INVALID_ARGUMENT,\"Must provide a non-empty collection name to collection()\");var t=fe.fromString(e);return new Ra(this._key.path.child(t),this.firestore)},e.prototype.isEqual=function(t){if(!(t instanceof e))throw z(\"isEqual\",\"DocumentReference\",1,t);return this.firestore===t.firestore&&this._key.isEqual(t._key)},e.prototype.set=function(e,t){A(\"DocumentReference.set\",arguments,1,2);var n=(t=Ma(\"DocumentReference.set\",t)).merge||t.mergeFields?this.firestore._dataConverter.parseMergeData(\"DocumentReference.set\",e,t.mergeFields):this.firestore._dataConverter.parseSetData(\"DocumentReference.set\",e);return this._firestoreClient.write(n.toMutations(this._key,lt.NONE))},e.prototype.update=function(e,t){for(var n,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];return\"string\"==typeof e||e instanceof qo?(N(\"DocumentReference.update\",arguments,2),n=this.firestore._dataConverter.parseUpdateVarargs(\"DocumentReference.update\",e,t,r)):(_(\"DocumentReference.update\",arguments,1),n=this.firestore._dataConverter.parseUpdateData(\"DocumentReference.update\",e)),this._firestoreClient.write(n.toMutations(this._key,lt.exists(!0)))},e.prototype.delete=function(){return _(\"DocumentReference.delete\",arguments,0),this._firestoreClient.write([new yt(this._key,lt.NONE)])},e.prototype.onSnapshot=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];A(\"DocumentReference.onSnapshot\",arguments,1,4);var n,r={includeMetadataChanges:!1},i=0;\"object\"!=typeof e[i]||jo(e[i])||(W(\"DocumentReference.onSnapshot\",r=e[i],[\"includeMetadataChanges\"]),P(\"DocumentReference.onSnapshot\",\"boolean\",\"includeMetadataChanges\",r.includeMetadataChanges),i++);var o={includeMetadataChanges:r.includeMetadataChanges};return jo(e[i])?n=e[i]:(R(\"DocumentReference.onSnapshot\",\"function\",i,e[i]),M(\"DocumentReference.onSnapshot\",\"function\",i+1,e[i+1]),M(\"DocumentReference.onSnapshot\",\"function\",i+2,e[i+2]),n={next:e[i],error:e[i+1],complete:e[i+2]}),this.onSnapshotInternal(o,n)},e.prototype.onSnapshotInternal=function(e,t){var n=this,r=function(e){console.error(\"Uncaught Error in onSnapshot:\",e)};t.error&&(r=t.error.bind(t));var i=new xo({next:function(e){if(t.next){p(e.docs.size<=1,\"Too many documents returned on a document query\");var r=e.docs.get(n._key);t.next(new Da(n.firestore,n._key,r,e.fromCache,e.hasPendingWrites))}},error:r}),o=this._firestoreClient.listen(He.atPath(this._key.path),i,e);return function(){i.mute(),n._firestoreClient.unlisten(o)}},e.prototype.get=function(e){var t=this;return A(\"DocumentReference.get\",arguments,0,1),Pa(\"DocumentReference.get\",e),new Promise(function(n,r){e&&\"cache\"===e.source?t.firestore.ensureClientConfigured().getDocumentFromLocalCache(t._key).then(function(e){n(new Da(t.firestore,t._key,e,!0,e instanceof ge&&e.hasLocalMutations))},r):t.getViaSnapshotListener(n,r,e)})},e.prototype.getViaSnapshotListener=function(e,t,n){var r=this.onSnapshotInternal({includeMetadataChanges:!0,waitForSyncWhenOnline:!0},{next:function(i){r(),!i.exists&&i.metadata.fromCache?t(new v(g.UNAVAILABLE,\"Failed to get document because the client is offline.\")):i.exists&&i.metadata.fromCache&&n&&\"server\"===n.source?t(new v(g.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.)')):e(i)},error:t})},e}(),Ia=function(){function e(e,t){this.hasPendingWrites=e,this.fromCache=t}return e.prototype.isEqual=function(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache},e}(),Da=function(){function e(e,t,n,r,i){this._firestore=e,this._key=t,this._document=n,this._fromCache=r,this._hasPendingWrites=i}return e.prototype.data=function(e){return A(\"DocumentSnapshot.data\",arguments,0,1),e=Oa(\"DocumentSnapshot.data\",e),this._document?this.convertObject(this._document.data,Ie.fromSnapshotOptions(e,this._firestore._areTimestampsInSnapshotsEnabled())):void 0},e.prototype.get=function(e,t){if(A(\"DocumentSnapshot.get\",arguments,1,2),t=Oa(\"DocumentSnapshot.get\",t),this._document){var n=this._document.data.field(ha(\"DocumentSnapshot.get\",e));if(void 0!==n)return this.convertValue(n,Ie.fromSnapshotOptions(t,this._firestore._areTimestampsInSnapshotsEnabled()))}},Object.defineProperty(e.prototype,\"id\",{get:function(){return this._key.path.lastSegment()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,\"ref\",{get:function(){return new Ea(this._key,this._firestore)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,\"exists\",{get:function(){return null!==this._document},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,\"metadata\",{get:function(){return new Ia(this._hasPendingWrites,this._fromCache)},enumerable:!0,configurable:!0}),e.prototype.isEqual=function(t){if(!(t instanceof e))throw z(\"isEqual\",\"DocumentSnapshot\",1,t);return this._firestore===t._firestore&&this._fromCache===t._fromCache&&this._key.isEqual(t._key)&&(null===this._document?null===t._document:this._document.isEqual(t._document))},e.prototype.convertObject=function(e,t){var n=this,r={};return e.forEach(function(e,i){r[e]=n.convertValue(i,t)}),r},e.prototype.convertValue=function(e,t){if(e instanceof Ve)return this.convertObject(e,t);if(e instanceof Be)return this.convertArray(e,t);if(e instanceof qe){var n=e.value(t),r=this._firestore.ensureClientConfigured().databaseId();return e.databaseId.isEqual(r)||l(\"Document \"+this._key.path+\" contains a document reference within a different database (\"+e.databaseId.projectId+\"\/\"+e.databaseId.database+\") which is not supported. It will be treated as a reference in the current database (\"+r.projectId+\"\/\"+r.database+\") instead.\"),new Ea(n,this._firestore)}return e.value(t)},e.prototype.convertArray=function(e,t){var n=this;return e.internalValue.map(function(e){return n.convertValue(e,t)})},e}(),Ca=function(e){function t(t,n,r,i,o){return e.call(this,t,n,r,i,o)||this}return i.__extends(t,e),t.prototype.data=function(t){var n=e.prototype.data.call(this,t);return p(\"object\"==typeof n,\"Document in a QueryDocumentSnapshot should exist\"),n},t}(Da),_a=function(){function e(e,t){this._query=e,this.firestore=t}return e.prototype.where=function(t,n,r){var i;_(\"Query.where\",arguments,3),R(\"Query.where\",\"non-empty string\",2,n),K(\"Query.where\",3,r);var o=ha(\"Query.where\",t),a=Je.fromString(n);if(o.isKeyField()){if(a===Je.ARRAY_CONTAINS)throw new v(g.INVALID_ARGUMENT,\"Invalid Query. You can't perform array-contains queries on FieldPath.documentId() since document IDs are not arrays.\");if(\"string\"==typeof r){if(-1!==r.indexOf(\"\/\"))throw new v(g.INVALID_ARGUMENT,\"Function Query.where() requires its third parameter to be a valid document ID if the first parameter is FieldPath.documentId(), but it contains a slash.\");if(\"\"===r)throw new v(g.INVALID_ARGUMENT,\"Function Query.where() requires its third parameter to be a valid document ID if the first parameter is FieldPath.documentId(), but it was an empty string.\");var s=this._query.path.child(new fe([r]));p(s.length%2==0,\"Path should be a document key\"),i=new qe(this.firestore._databaseId,new me(s))}else{if(!(r instanceof Ea))throw new v(g.INVALID_ARGUMENT,\"Function Query.where() requires its third parameter to be a string or a DocumentReference if the first parameter is FieldPath.documentId(), but it was: \"+U(r)+\".\");var u=r;i=new qe(this.firestore._databaseId,u._key)}}else i=this.firestore._dataConverter.parseQueryValue(\"Query.where\",r);var c=Ye.create(o,a,i);return this.validateNewFilter(c),new e(this._query.addFilter(c),this.firestore)},e.prototype.orderBy=function(t,n){var r;if(A(\"Query.orderBy\",arguments,1,2),M(\"Query.orderBy\",\"non-empty string\",2,n),void 0===n||\"asc\"===n)r=et.ASCENDING;else{if(\"desc\"!==n)throw new v(g.INVALID_ARGUMENT,\"Function Query.orderBy() has unknown direction '\"+n+\"', expected 'asc' or 'desc'.\");r=et.DESCENDING}if(null!==this._query.startAt)throw new v(g.INVALID_ARGUMENT,\"Invalid query. You must not call Query.startAt() or Query.startAfter() before calling Query.orderBy().\");if(null!==this._query.endAt)throw new v(g.INVALID_ARGUMENT,\"Invalid query. You must not call Query.endAt() or Query.endBefore() before calling Query.orderBy().\");var i=ha(\"Query.orderBy\",t),o=new nt(i,r);return this.validateNewOrderBy(o),new e(this._query.addOrderBy(o),this.firestore)},e.prototype.limit=function(t){if(_(\"Query.limit\",arguments,1),R(\"Query.limit\",\"number\",1,t),t<=0)throw new v(g.INVALID_ARGUMENT,\"Invalid Query. Query limit (\"+t+\") is invalid. Limit must be positive.\");return new e(this._query.withLimit(t),this.firestore)},e.prototype.startAt=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];N(\"Query.startAt\",arguments,1);var i=this.boundFromDocOrFields(\"Query.startAt\",t,n,!0);return new e(this._query.withStartAt(i),this.firestore)},e.prototype.startAfter=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];N(\"Query.startAfter\",arguments,1);var i=this.boundFromDocOrFields(\"Query.startAfter\",t,n,!1);return new e(this._query.withStartAt(i),this.firestore)},e.prototype.endBefore=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];N(\"Query.endBefore\",arguments,1);var i=this.boundFromDocOrFields(\"Query.endBefore\",t,n,!0);return new e(this._query.withEndAt(i),this.firestore)},e.prototype.endAt=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];N(\"Query.endAt\",arguments,1);var i=this.boundFromDocOrFields(\"Query.endAt\",t,n,!1);return new e(this._query.withEndAt(i),this.firestore)},e.prototype.isEqual=function(t){if(!(t instanceof e))throw z(\"isEqual\",\"Query\",1,t);return this.firestore===t.firestore&&this._query.isEqual(t._query)},e.prototype.boundFromDocOrFields=function(e,t,n,r){if(K(e,1,t),t instanceof Da){if(n.length>0)throw new v(g.INVALID_ARGUMENT,\"Too many arguments provided to \"+e+\"().\");var i=t;if(!i.exists)throw new v(g.NOT_FOUND,\"Can't use a DocumentSnapshot that doesn't exist for \"+e+\"().\");return this.boundFromDocument(e,i._document,r)}var o=[t].concat(n);return this.boundFromFields(e,o,r)},e.prototype.boundFromDocument=function(e,t,n){for(var r=[],i=0,o=this._query.orderBy;i<o.length;i++){var a=o[i];if(a.field.isKeyField())r.push(new qe(this.firestore._databaseId,t.key));else{var s=t.field(a.field);if(void 0===s){var u=a.field.canonicalString();throw new v(g.INVALID_ARGUMENT,\"Invalid query. You are trying to start or end a query using a document for which the field '\"+u+\"' (used as the orderBy) does not exist.\")}r.push(s)}}return new tt(r,n)},e.prototype.boundFromFields=function(e,t,n){var r=this._query.explicitOrderBy;if(t.length>r.length)throw new v(g.INVALID_ARGUMENT,\"Too many arguments provided to \"+e+\"(). The number of arguments must be less than or equal to the number of Query.orderBy() clauses\");for(var i=[],o=0;o<t.length;o++){var a=t[o];if(r[o].field.isKeyField()){if(\"string\"!=typeof a)throw new v(g.INVALID_ARGUMENT,\"Invalid query. Expected a string for document ID in \"+e+\"(), but got a \"+typeof a);if(-1!==a.indexOf(\"\/\"))throw new v(g.INVALID_ARGUMENT,\"Invalid query. Document ID '\"+a+\"' contains a slash in \"+e+\"()\");var s=new me(this._query.path.child(a));i.push(new qe(this.firestore._databaseId,s))}else{var u=this.firestore._dataConverter.parseQueryValue(e,a);i.push(u)}}return new tt(i,n)},e.prototype.onSnapshot=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];A(\"Query.onSnapshot\",arguments,1,4);var n,r={},i=0;return\"object\"!=typeof e[i]||jo(e[i])||(W(\"Query.onSnapshot\",r=e[i],[\"includeMetadataChanges\"]),P(\"Query.onSnapshot\",\"boolean\",\"includeMetadataChanges\",r.includeMetadataChanges),i++),jo(e[i])?n=e[i]:(R(\"Query.onSnapshot\",\"function\",i,e[i]),M(\"Query.onSnapshot\",\"function\",i+1,e[i+1]),M(\"Query.onSnapshot\",\"function\",i+2,e[i+2]),n={next:e[i],error:e[i+1],complete:e[i+2]}),this.onSnapshotInternal(r,n)},e.prototype.onSnapshotInternal=function(e,t){var n=this,r=function(e){console.error(\"Uncaught Error in onSnapshot:\",e)};t.error&&(r=t.error.bind(t));var i=new xo({next:function(e){t.next&&t.next(new Na(n.firestore,n._query,e))},error:r}),o=this.firestore.ensureClientConfigured(),a=o.listen(this._query,i,e);return function(){i.mute(),o.unlisten(a)}},e.prototype.get=function(e){var t=this;return A(\"Query.get\",arguments,0,1),Pa(\"Query.get\",e),new Promise(function(n,r){e&&\"cache\"===e.source?t.firestore.ensureClientConfigured().getDocumentsFromLocalCache(t._query).then(function(e){n(new Na(t.firestore,t._query,e))},r):t.getViaSnapshotListener(n,r,e)})},e.prototype.getViaSnapshotListener=function(e,t,n){var r=this.onSnapshotInternal({includeMetadataChanges:!0,waitForSyncWhenOnline:!0},{next:function(i){r(),i.metadata.fromCache&&n&&\"server\"===n.source?t(new v(g.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.)')):e(i)},error:t})},e.prototype.validateNewFilter=function(e){if(e instanceof Xe)if(e.isInequality()){var t=this._query.getInequalityFilterField();if(null!==t&&!t.isEqual(e.field))throw new v(g.INVALID_ARGUMENT,\"Invalid query. All where filters with an inequality (<, <=, >, or >=) must be on the same field. But you have inequality filters on '\"+t.toString()+\"' and '\"+e.field.toString()+\"'\");var n=this._query.getFirstOrderByField();null!==n&&this.validateOrderByAndInequalityMatch(e.field,n)}else if(e.op===Je.ARRAY_CONTAINS&&this._query.hasArrayContainsFilter())throw new v(g.INVALID_ARGUMENT,\"Invalid query. Queries only support a single array-contains filter.\")},e.prototype.validateNewOrderBy=function(e){if(null===this._query.getFirstOrderByField()){var t=this._query.getInequalityFilterField();null!==t&&this.validateOrderByAndInequalityMatch(t,e.field)}},e.prototype.validateOrderByAndInequalityMatch=function(e,t){if(!t.isEqual(e))throw new v(g.INVALID_ARGUMENT,\"Invalid query. You have a where filter with an inequality (<, <=, >, or >=) on field '\"+e.toString()+\"' and so you must also use '\"+e.toString()+\"' as your first Query.orderBy(), but your first Query.orderBy() is on field '\"+t.toString()+\"' instead.\")},e}(),Na=function(){function e(e,t,n){this._firestore=e,this._originalQuery=t,this._snapshot=n,this._cachedChanges=null,this._cachedChangesIncludeMetadataChanges=null,this.metadata=new Ia(n.hasPendingWrites,n.fromCache)}return Object.defineProperty(e.prototype,\"docs\",{get:function(){var e=[];return this.forEach(function(t){return e.push(t)}),e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,\"empty\",{get:function(){return this._snapshot.docs.isEmpty()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,\"size\",{get:function(){return this._snapshot.docs.size},enumerable:!0,configurable:!0}),e.prototype.forEach=function(e,t){var n=this;A(\"QuerySnapshot.forEach\",arguments,1,2),R(\"QuerySnapshot.forEach\",\"function\",1,e),this._snapshot.docs.forEach(function(r){e.call(t,n.convertToDocumentImpl(r))})},Object.defineProperty(e.prototype,\"query\",{get:function(){return new _a(this._originalQuery,this._firestore)},enumerable:!0,configurable:!0}),e.prototype.docChanges=function(e){e&&(W(\"QuerySnapshot.docChanges\",e,[\"includeMetadataChanges\"]),P(\"QuerySnapshot.docChanges\",\"boolean\",\"includeMetadataChanges\",e.includeMetadataChanges));var t=!(!e||!e.includeMetadataChanges);if(t&&this._snapshot.excludesMetadataChanges)throw new v(g.INVALID_ARGUMENT,\"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().\");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=xa(this._firestore,t,this._snapshot),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges},e.prototype.isEqual=function(t){if(!(t instanceof e))throw z(\"isEqual\",\"QuerySnapshot\",1,t);return this._firestore===t._firestore&&this._originalQuery.isEqual(t._originalQuery)&&this._snapshot.isEqual(t._snapshot)},e.prototype.convertToDocumentImpl=function(e){return new Ca(this._firestore,e.key,e,this.metadata.fromCache,this._snapshot.mutatedKeys.has(e.key))},e}();function Aa(){throw new v(g.INVALID_ARGUMENT,'QuerySnapshot.docChanges has been changed from a property into a method, so usages like \"querySnapshot.docChanges\" should become \"querySnapshot.docChanges()\"')}var ka=[\"length\",\"forEach\",\"map\"].concat(\"undefined\"!=typeof Symbol?[Symbol.iterator]:[]);ka.forEach(function(e){try{Object.defineProperty(Na.prototype.docChanges,e,{get:function(){return Aa()}})}catch(e){}});var Ra=function(e){function t(t,n){var r=e.call(this,He.atPath(t),n)||this;if(t.length%2!=1)throw new v(g.INVALID_ARGUMENT,\"Invalid collection reference. Collection references must have an odd number of segments, but \"+t.canonicalString()+\" has \"+t.length);return r}return i.__extends(t,e),Object.defineProperty(t.prototype,\"id\",{get:function(){return this._query.path.lastSegment()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,\"parent\",{get:function(){var e=this._query.path.popLast();return e.isEmpty()?null:new Ea(new me(e),this.firestore)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,\"path\",{get:function(){return this._query.path.canonicalString()},enumerable:!0,configurable:!0}),t.prototype.doc=function(e){if(A(\"CollectionReference.doc\",arguments,0,1),0===arguments.length&&(e=H.newId()),R(\"CollectionReference.doc\",\"non-empty string\",1,e),\"\"===e)throw new v(g.INVALID_ARGUMENT,\"Document path must be a non-empty string\");var t=fe.fromString(e);return Ea.forPath(this._query.path.child(t),this.firestore)},t.prototype.add=function(e){_(\"CollectionReference.add\",arguments,1),R(\"CollectionReference.add\",\"object\",1,e);var t=this.doc();return t.set(e).then(function(){return t})},t}(_a);function Ma(e,t){if(void 0===t)return{merge:!1};if(W(e,t,[\"merge\",\"mergeFields\"]),P(e,\"boolean\",\"merge\",t.merge),x(e,\"mergeFields\",\"a string or a FieldPath\",t.mergeFields,function(e){return\"string\"==typeof e||e instanceof qo}),void 0!==t.mergeFields&&void 0!==t.merge)throw new v(g.INVALID_ARGUMENT,\"Invalid options passed to function \"+e+'(): You cannot specify both \"merge\" and \"mergeFields\".');return t}function Oa(e,t){return void 0===t?{}:(W(e,t,[\"serverTimestamps\"]),F(e,\"options\",\"serverTimestamps\",t.serverTimestamps,[\"estimate\",\"previous\",\"none\"]),t)}function Pa(e,t){M(e,\"object\",1,t),t&&(W(e,t,[\"source\"]),F(e,\"options\",\"source\",t.source,[\"default\",\"server\",\"cache\"]))}function La(e,t,n){if(t instanceof Ea){if(t.firestore!==n)throw new v(g.INVALID_ARGUMENT,\"Provided document reference is from a different Firestore instance.\");return t}throw z(e,\"DocumentReference\",1,t)}function xa(e,t,n){if(n.oldDocs.isEmpty()){var r,i=0;return n.docChanges.map(function(t){var o=new Ca(e,t.doc.key,t.doc,n.fromCache,n.mutatedKeys.has(t.doc.key));return p(t.type===Vt.Added,\"Invalid event type for first snapshot\"),p(!r||n.query.docComparator(r,t.doc)<0,\"Got added events in wrong order\"),r=t.doc,{type:\"added\",doc:o,oldIndex:-1,newIndex:i++}})}var o=n.oldDocs;return n.docChanges.filter(function(e){return t||e.type!==Vt.Metadata}).map(function(t){var r=new Ca(e,t.doc.key,t.doc,n.fromCache,n.mutatedKeys.has(t.doc.key)),i=-1,a=-1;return t.type!==Vt.Added&&(p((i=o.indexOf(t.doc.key))>=0,\"Index for document not found\"),o=o.delete(t.doc.key)),t.type!==Vt.Removed&&(a=(o=o.add(t.doc)).indexOf(t.doc.key)),{type:qa(t.type),doc:r,oldIndex:i,newIndex:a}})}function qa(e){switch(e){case Vt.Added:return\"added\";case Vt.Modified:case Vt.Metadata:return\"modified\";case Vt.Removed:return\"removed\";default:return d(\"Unknown change type: \"+e)}}var Fa=w(ba,\"Use firebase.firestore() instead.\"),Va=w(Sa,\"Use firebase.firestore().runTransaction() instead.\"),Ba=w(Ta,\"Use firebase.firestore().batch() instead.\"),Ua=w(Ea,\"Use firebase.firestore().doc() instead.\"),Qa=w(Da),Ka=w(Ca),Wa=w(_a),za=w(Na),ja=w(Ra,\"Use firebase.firestore().collection() instead.\"),Ga={Firestore:Fa,GeoPoint:oe,Timestamp:ae,Blob:ie,Transaction:Va,WriteBatch:Ba,DocumentReference:Ua,DocumentSnapshot:Qa,Query:Wa,QueryDocumentSnapshot:Ka,QuerySnapshot:za,CollectionReference:ja,FieldPath:qo,FieldValue:ea,setLogLevel:ba.setLogLevel};function Ha(e){e.INTERNAL.registerService(\"firestore\",function(e){return new ba(e)},C(Ga))}function Ya(e){Ha(e)}Ya(n),exports.registerFirestore=Ya;\r\n},{\"@firebase\/app\":19,\"@firebase\/logger\":23,\"tslib\":22,\"@firebase\/webchannel-wrapper\":21}],15:[function(require,module,exports) {\r\n\"use strict\";require(\"@firebase\/firestore\");\r\n},{\"@firebase\/firestore\":17}],12:[function(require,module,exports) {\r\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0});var e=require(\"firebase\/app\"),a=i(e);function i(e){return e&&e.__esModule?e:{default:e}}require(\"firebase\/firestore\");var r={apiKey:\"AIzaSyCXOjI_ZDyXcKUUfmLIQxktkZsiE5w7Iug\",authDomain:\"be-livestream-admin.firebaseapp.com\",databaseURL:\"https:\/\/be-livestream-admin.firebaseio.com\",projectId:\"be-livestream-admin\",storageBucket:\"be-livestream-admin.appspot.com\",messagingSenderId:\"1060715660133\"};exports.default=a.default.initializeApp(r);\r\n},{\"firebase\/app\":16,\"firebase\/firestore\":15}],9:[function(require,module,exports) {\r\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0});var e=require(\".\/StreamEvent\"),t=a(e),s=require(\"..\/firebase\"),r=a(s);function a(e){return e&&e.__esModule?e:{default:e}}const i=r.default.firestore();i.settings({timestampsInSnapshots:!0});const n=\"7ddb8793-e408-4da4-a3d0-09ce59b61d2d\";class d{constructor(e){this.targetNode=e,this.languageCode=\"fi\",this.leagues=[],this.streamEvents=[],this.maxStreamEvents=10,this.render()}sortStreamEvents(){this.streamEvents.sort((e,t)=>this.leagueOrder.indexOf(e.sci)-this.leagueOrder.indexOf(t.sci))}getStreamEvents(){const e=this.leagues.map(e=>e.scid).join(\",\"),t=`https:\/\/bts-api-a.bpsgameserver.com\/isa\/v2\/901\/${this.languageCode}\/event`;return fetch(`${t}?ocb=${n}&subCategoryIds=${e}&EventMarketCount=1&streamTypeIds=1`)}getLeagueOrder(){this.leagueOrder=this.leagues.slice().sort((e,t)=>e.priority-t.priority).map(e=>e.scid)}renderStreamEvents(){for(let e=0;e<this.streamEvents.length;e++){if(e>=this.maxStreamEvents)return;this.targetNode.appendChild(this.streamEvents[e].node)}}render(){i.collection(\"leagues\").where(\"market\",\"==\",this.languageCode).get().then(e=>{e.forEach(e=>{const t=e.data();this.leagues.push(t)}),this.getLeagueOrder(),this.getStreamEvents().then(e=>e.json()).then(e=>{this.streamEvents=e.el.map(e=>new t.default(e)).sort((e,t)=>this.leagueOrder.indexOf(e.data.sci)-this.leagueOrder.indexOf(t.data.sci))}).then(()=>{this.renderStreamEvents()})}).catch(e=>{console.error(\"Error getting documents: \",e)})}}exports.default=d;\r\n},{\".\/StreamEvent\":11,\"..\/firebase\":12}],6:[function(require,module,exports) {\r\n\"use strict\";var e=require(\".\/src\/App\"),r=t(e);function t(e){return e&&e.__esModule?e:{default:e}}const u=new r.default(document.querySelector(\"#ls-container\"));\r\n},{\".\/src\/App\":9}]},{},[6])"},{"meta_key":"reflector","meta_value":"on"}],[{"meta_key":"_wp_page_template","meta_value":"campaign_settings.php"},{"meta_key":"pagetitle","meta_value":"Sports Live Streams for Free at Betsson"},{"meta_key":"termsandconditions","meta_value":"<h3>General Terms & Conditions<\/h3>\r\n<ul class=\"fa fa-ul\">\r\n<li><i class=\"fa-li fa fa-check-circle-o\"><\/i>Your first term and condition here.<\/li>\r\n<li><i class=\"fa-li fa fa-check-circle-o\"><\/i>Your second term and condition here.<\/li>\r\n<li><i class=\"fa-li fa fa-check-circle-o\"><\/i>Your third term and condition here.<\/li>\r\n<\/ul>"},{"meta_key":"headerbuttons","meta_value":"a:1:{i:0;a:4:{s:11:\"buttonlabel\";s:1:\" \";s:10:\"buttonlink\";s:1:\" \";s:10:\"buttonsize\";s:3:\"sml\";s:11:\"buttonstyle\";s:3:\"std\";}}"},{"meta_key":"items","meta_value":"a:2:{i:0;a:5:{s:5:\"label\";s:1:\" \";s:4:\"link\";s:1:\" \";s:11:\"innerscroll\";b:0;s:9:\"newwindow\";b:0;s:5:\"popup\";b:0;}i:1;a:2:{s:5:\"label\";s:1:\" \";s:4:\"link\";s:1:\" \";}}"},{"meta_key":"_edit_lock","meta_value":"1564580362:154"},{"meta_key":"_edit_last","meta_value":"154"},{"meta_key":"h_lang_switcher_style","meta_value":"horizontal"},{"meta_key":"sidebuttons_right","meta_value":"a:1:{i:0;a:3:{s:10:\"buttonlink\";s:1:\" \";s:10:\"buttonsize\";s:3:\"sml\";s:11:\"buttonstyle\";s:3:\"std\";}}"},{"meta_key":"pagemetarobots","meta_value":"nofollow"},{"meta_key":"campaign_css","meta_value":"*::-moz-selection {\r\nbackground-color: rgba(255,255,255,0.29);\r\n}\r\n\r\n*::selection {\r\nbackground-color: rgba(255,255,255,0.29);\r\n}\r\n\r\n\/* DESKTOP background*\/\r\n\r\n.echo_wrapper {\r\nbackground: url('https:\/\/in.betsson.com\/wp-content\/uploads\/content\/betsson\/sites\/3\/2018\/03\/Test-BG.jpg');\r\nbackground-size: cover;\r\nbackground-attachment: fixed;\r\nbackground-repeat: no-repeat;\r\nbackground-position: center;\r\n}\r\n\r\n\/* MOBILE background*\/ \r\n\r\n@media (max-width: 480px) {\r\n.echo_wrapper {\r\nbackground: url('https:\/\/in.nordicbet.com\/wp-content\/uploads\/content\/nordicbet\/sites\/4\/2017\/10\/480x1200_THIS.jpg');\r\nbackground-size: cover;\r\nbackground-attachment: fixed;\r\nbackground-repeat: no-repeat;\r\nbackground-position: center top;\r\n}\r\n}\r\n\r\n\/* TABLET background & adjustments *\/\r\n\r\n@media (min-width: 480px) and (max-width: 992px) {\r\n.echo_wrapper {\r\nbackground: url('https:\/\/in.nordicbet.com\/wp-content\/uploads\/content\/nordicbet\/sites\/4\/2017\/10\/992x1200_THIS.jpg');\r\nbackground-size: cover;\r\nbackground-attachment: fixed;\r\nbackground-repeat: no-repeat;\r\nbackground-position: center top;\r\n}\r\n\r\nh4 {\r\ntext-align: center;\r\nfont-size: 1.65em;\r\n}\r\n\r\n.echo .match-time, .echo .match-teams {\r\nfont-size: 1em;\r\n}\r\n\r\n.echo section .echo-image-text.echo-ambassador h3 {\r\nmargin: 20px 0 14px 100px!important;\r\nfont-size: 1.2em;\r\n}\r\n#echo-stream .echo-btn {\r\ndisplay: block;\r\nwidth: 45%;\r\nmargin: 0 auto;\r\nmargin-top: 25px;\r\n}\r\n}\r\n\r\n\/* general *\/\r\n\r\n.echo section {\r\nbackground: transparent;\r\n}\r\n\r\n.echo .echo-header {\r\ndisplay: none;\r\n}\r\n\r\n#echo-top img {\r\nmax-width: 190px;\r\n}\r\n\r\n\/* columns background *\/\r\n\r\n.echo #echo-stream .echo-col-lg-6:nth-of-type(1) {\r\nbackground-color: rgba(0,0,0, 0.3);\r\npadding-top: 25px;\r\npadding-bottom: 25px;\r\n}\r\n\r\n.echo .echo-col-lg-6 {\r\npadding-right: 35px;\r\npadding-left: 35px;\r\n}\r\n\r\n\/* fonts *\/\r\n\r\n.echo section p, .echo section h1, .echo section h2, .echo section h3, .echo section .echo-image-text h3 {\r\ncolor: #fff;\r\n}\r\n\r\n.echo section h1 {\r\nfont-size: 2.8em;\r\nfont-weight: 800;\r\nline-height: 1.1em;\r\ntext-transform: uppercase;\r\n}\r\n\r\n.echo p .engagement {\r\ndisplay: block;\r\nfont-size: 1.5em;\r\nline-height: 1.4em;\r\nmargin-bottom: 32px;\r\n}\r\n\r\n\r\n.echo section .echo-image-text.echo-ambassador:hover h3 {\r\ncolor: #fff;\r\n}\r\n\r\n.echo section h4 {\r\ncolor: #f60;\r\nfont-size: 1.8em;\r\nfont-weight: 600;\r\n}\r\n\r\n\/* steps appearance *\/\r\n\r\n.echo section .echo-image-text {\r\nmargin: 0 0 15px;\r\n}\r\n\r\n.echo section .echo-image-text.echo-ambassador {\r\nmin-height: 0px;\r\n}\r\n\r\n.echo section .echo-image-text.echo-ambassador img {\r\nwidth: 8%;\r\n}\r\n\r\n.echo section .echo-image-text.echo-ambassador h3 {\r\nmargin: 8px 0 16px 80px;\r\ntext-transform: none;\r\nfont-size: 1.4em;\r\nfont-weight: 400;\r\n}\r\n\r\n\/* Live Stream Part *\/\r\n\r\n\r\n.echo .echo-btn {\r\nfont-family: 'Roboto', sans-serif!important;\r\ntext-transform: none;\r\n}\r\n\r\n.echo .echo-btn span {\r\nfont-weight: 400!important;\r\n}\r\n\r\n#echo-stream .echo-btn, #echo-top .echo-btn {\r\nmin-width: 230px;\r\npadding: 6px;\r\ntext-align: center;\r\nborder-radius: 7px;\r\n}\r\n\r\n@media (max-width: 480px) {\r\n\r\n#echo-top .echo-image {\r\nmargin-bottom: 7px;\r\n}\r\n\r\n#echo-top h1 {\r\ntext-align: center;\r\nfont-size: 1.61em;\r\nmargin-bottom: 1.5em;\r\n}\r\n\r\n#echo-stream .echo-col-lg-6:nth-of-type(2) {\r\nmargin-top: 35px;\r\n}\r\n\r\n#echo-stream .echo-btn, #echo-top .echo-btn {\r\ndisplay: block;\r\nmin-width: 68%;\r\nmargin: 0 auto;\r\n}\r\n\r\n#echo-stream .echo-btn:hover, #echo-top .echo-btn:hover {\r\nbackground: #f60;\r\n}\r\n\r\n.echo section .echo-image-text.echo-ambassador h3 {\r\nmargin: 0 0 22px 80px;\r\nfont-family: 'Roboto', Helvetica, arial, sans-serif;\r\ntext-transform: none;\r\nfont-size: 1.1em;\r\n}\r\n}\r\n\r\nfooter {\r\ndisplay: none !important;\r\n}\r\n\r\n.echo_wrapper {\r\nmin-height: 100vh;\r\n}\r\n\r\n\r\n\r\n#echo-matches-container {\r\ndisplay: grid;\r\ngrid-template-columns: 1fr 1fr;\r\ngrid-gap: 8px 12px;\r\nline-height: 1.2em;\r\n}\r\n@media screen and (max-width: 520px) {\r\n#echo-matches-container {\r\ngrid-template-columns: 1fr;\r\n}\r\n}\r\n\r\n.match-container {\r\ndisplay: grid;\r\n-ms-grid-template-columns: 25px 1fr;\r\ngrid-template-columns: 25px 1fr;\r\n}\r\n\r\n#echo-matches-container .match-icon-container {\r\n-ms-grid-row: span 2;\r\ngrid-row: span 2;\r\npadding-top: 8px;\r\n}\r\n\r\n#echo-matches-container .match-icon-container > img {\r\nwidth: 70%;\r\n}\r\n\r\n#echo-matches-container .match-dates-container {\r\npadding: 6px 0;\r\n}\r\n\r\n#echo-matches-container .match-date {\r\ncolor: #fff;\r\nfont-size: 18px;\r\nfont-weight: 600;\r\n}\r\n\r\n#echo-matches-container .match-time {\r\ncolor: #f60;\r\nfont-size: 18px;\r\nfont-weight: 600;\r\n}\r\n\r\n#echo-matches-container .match-lineup {\r\ncolor: #fff;\r\nfont-size: 18px;\r\nfont-weight: 300;\r\n}\r\n\r\n"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"termsandconditions_hide","meta_value":"on"},{"meta_key":"reflector","meta_value":"on"},{"meta_key":"campaign_js","meta_value":"require=function(r,e,n){function t(n,o){function i(r){return t(i.resolve(r))}function f(e){return r[n][1][e]||e}if(!e[n]){if(!r[n]){var c=\"function\"==typeof require&&require;if(!o&&c)return c(n,!0);if(u)return u(n,!0);var l=new Error(\"Cannot find module '\"+n+\"'\");throw l.code=\"MODULE_NOT_FOUND\",l}i.resolve=f;var a=e[n]=new t.Module;r[n][0].call(a.exports,i,a,a.exports)}return e[n].exports}function o(){this.bundle=t,this.exports={}}var u=\"function\"==typeof require&&require;t.Module=o,t.modules=r,t.cache=e,t.parent=u;for(var i=0;i<n.length;i++)t(n[i]);return t}({3:[function(require,module,exports) {\r\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0});class t{constructor(t){this.ocb=t.ocb,this.language=t.language,this.sports=t.sports,this.sportPriority=t.sportPriority,this.maxFeaturedMatches=t.maxFeaturedMatches,this.scids=(t=>{let s=[];for(let e in t)s=s.concat(t[e].scids);return s})(this.sports),this.featuredMatches=[]}async getData(){const t=\"&subCategoryIds=\"+this.scids.join(\",\"),s=`${`https:\/\/bts-api-a.bpsgameserver.com\/isa\/v2\/901\/${this.language}\/event`}?ocb=${this.ocb}&${t}&EventMarketCount=1&streamTypeIds=1`;return await fetch(s)}calculateFeaturedMatches(t){for(let s=0;s<this.sportPriority.length;s++){if(this.featuredMatches.length===this.maxFeaturedMatches)return;const e=this.sportPriority[s];let a=0;t.forEach(t=>{t.cri===e&&this.featuredMatches.length<this.maxFeaturedMatches&&a<this.maxFeaturedMatches\/2&&(this.featuredMatches.push(t),a++)})}}createMatch$(t){const s=t.sd.match(\/-\\d\\d\/)[0].replace(\/\\D\/,\"\").replace(\/^0\/,\"\"),e=t.sd.match(\/\\d\\d[A-Z]\/)[0].replace(\/\\D\/,\"\").replace(\/^0\/,\"\"),a=t.sd.match(\/\\d\\d:\\d\\d\/)[0];return $(`\\n      <div class=\"match-container\">\\n        <div class=\"match-icon-container\">\\n          <img src=\"${this.sports[t.cri].logo}\" alt=\"${t.cri}\" \/>\\n        <\/div>\\n        <div class=\"match-info-container\">\\n          <div class=\"match-dates-container\">\\n          <span class=\"match-date\">${e}\/${s} \u2014 <\/span><span class=\"match-time\">${a}<\/span>\\n          <\/div>\\n          <div class=\"match-lineup-container\">\\n          <span class=\"match-lineup\">${t.en}<\/span>\\n          <\/div>\\n        <\/div>\\n      <\/div>\\n    `)}renderMatches(){$(\"<div>\");this.featuredMatches.forEach(t=>{const s=this.createMatch$(t);$(\"#echo-matches-container\").append(s)})}}exports.default=t;\r\n},{}],2:[function(require,module,exports) {\r\n\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.default={ocb:\"7ddb8793-e408-4da4-a3d0-09ce59b61d2d\",language:\"en\",sports:{\"ice-hockey\":{scids:[2,2079],logo:\"https:\/\/in.betsson.com\/wp-content\/uploads\/content\/betsson\/sites\/3\/2018\/03\/hockey.png\",matches:[]},football:{scids:[12,15,4,19],logo:\"https:\/\/bpsh2.hs.llnwd.net\/e1\/echo-cdn-origin\/content\/nordicbet\/sites\/3\/2017\/10\/football.png\",matches:[]},basketball:{scids:[87],logo:\"https:\/\/bpsh2.hs.llnwd.net\/e1\/echo-cdn-origin\/content\/nordicbet\/sites\/3\/2017\/10\/basketball.png\",matches:[]},baseball:{scids:[388],logo:\"https:\/\/bpsh2.hs.llnwd.net\/e1\/echo-cdn-origin\/content\/nordicbet\/sites\/3\/2017\/10\/baseball.png\",matches:[]}},sportPriority:[\"ice-hockey\",\"football\",\"basketball\",\"baseball\"],maxFeaturedMatches:8};\r\n},{}],1:[function(require,module,exports) {\r\n\"use strict\";var e=require(\".\/classes\/app\"),t=n(e),a=require(\".\/appconfig.js\"),s=n(a);function n(e){return e&&e.__esModule?e:{default:e}}(()=>{const e=new t.default(s.default);e.getData().then(e=>e.json()).then(({el:t})=>{console.log(e),e.calculateFeaturedMatches(t),e.renderMatches()})})();\r\n},{\".\/classes\/app\":3,\".\/appconfig.js\":2}]},{},[1])"}]],"campaign_ui_elements_meta":[[{"meta_key":"img","meta_value":"https:\/\/in.betsson.com\/wp-content\/uploads\/content\/betsson\/sites\/3\/2018\/02\/BE-logo-transparent-no-tagline.png"},{"meta_key":"img_link","meta_value":"#"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"_edit_lock","meta_value":"1562154123:194"},{"meta_key":"_edit_last","meta_value":"154"}],[{"meta_key":"space","meta_value":"1px"},{"meta_key":"_reflector_data","meta_value":""}],[{"meta_key":"heading","meta_value":"WATCH LIVE<br>STREAMED SPORTS for FREE AT NORDICBET!"},{"meta_key":"headingtag","meta_value":"h1"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"device_visibility","meta_value":"a:2:{i:0;s:9:\"hidden-lg\";i:1;s:9:\"hidden-md\";}"}],[{"meta_key":"buttontext","meta_value":"Open Account"},{"meta_key":"buttonlink","meta_value":"#"},{"meta_key":"buttonsize","meta_value":"mdm"},{"meta_key":"buttonstyle","meta_value":"std"},{"meta_key":"buttonicon","meta_value":""},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"device_visibility","meta_value":"a:2:{i:0;s:9:\"hidden-lg\";i:1;s:9:\"hidden-md\";}"}],[{"meta_key":"heading","meta_value":"Upcoming Matches"},{"meta_key":"headingtag","meta_value":"h4"},{"meta_key":"_reflector_data","meta_value":""}],[{"meta_key":"rawhtml","meta_value":"<div id=\"ls-container\">\r\n\r\n<\/div>"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"_edit_lock","meta_value":"1541170014:154"},{"meta_key":"_edit_last","meta_value":"154"}],[{"meta_key":"heading","meta_value":"Watch live<br>streamed sports free at Betsson!"},{"meta_key":"headingtag","meta_value":"h1"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"device_visibility","meta_value":"a:2:{i:0;s:9:\"hidden-sm\";i:1;s:9:\"hidden-xs\";}"}],[{"meta_key":"text","meta_value":"<span class=\"engagement\">Watch 2017\/2018 season matches live and free of charge.<\/span>"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"device_visibility","meta_value":"a:2:{i:0;s:9:\"hidden-sm\";i:1;s:9:\"hidden-xs\";}"}],[{"meta_key":"image","meta_value":"https:\/\/in.betsson.com\/wp-content\/uploads\/content\/betsson\/sites\/3\/2018\/02\/11.png"},{"meta_key":"heading","meta_value":"Open an account"},{"meta_key":"imageposition","meta_value":"side"},{"meta_key":"buttonsize","meta_value":"sml"},{"meta_key":"buttonstyle","meta_value":"std"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"_edit_lock","meta_value":"1519138827:154"},{"meta_key":"_edit_last","meta_value":"154"},{"meta_key":"image_id","meta_value":"16376"}],[{"meta_key":"image","meta_value":"https:\/\/in.betsson.com\/wp-content\/uploads\/content\/betsson\/sites\/3\/2018\/02\/21.png"},{"meta_key":"heading","meta_value":"Make a deposit"},{"meta_key":"cta_link","meta_value":"#"},{"meta_key":"imageposition","meta_value":"side"},{"meta_key":"buttonsize","meta_value":"sml"},{"meta_key":"buttonstyle","meta_value":"std"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"_edit_lock","meta_value":"1519138880:154"},{"meta_key":"_edit_last","meta_value":"154"},{"meta_key":"image_id","meta_value":"16377"}],[{"meta_key":"image","meta_value":"https:\/\/in.betsson.com\/wp-content\/uploads\/content\/betsson\/sites\/3\/2018\/02\/3.png"},{"meta_key":"heading","meta_value":"Watch all the sports you want for this season"},{"meta_key":"cta_link","meta_value":"#"},{"meta_key":"imageposition","meta_value":"side"},{"meta_key":"buttonsize","meta_value":"sml"},{"meta_key":"buttonstyle","meta_value":"std"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"_edit_lock","meta_value":"1519143799:154"},{"meta_key":"_edit_last","meta_value":"154"},{"meta_key":"image_id","meta_value":"16378"}],[{"meta_key":"buttontext","meta_value":"Open Account"},{"meta_key":"buttonlink","meta_value":"#"},{"meta_key":"buttonsize","meta_value":"lrg"},{"meta_key":"buttonstyle","meta_value":"std"},{"meta_key":"buttonicon","meta_value":""},{"meta_key":"_reflector_data","meta_value":""}],[{"meta_key":"rawhtml","meta_value":""}],[{"meta_key":"heading","meta_value":"This is a Heading"},{"meta_key":"headingtag","meta_value":"h1"},{"meta_key":"headingalignment","meta_value":"echo-text-left"}],[{"meta_key":"img","meta_value":"https:\/\/in.betsson.com\/wp-content\/uploads\/content\/betsson\/sites\/3\/2018\/02\/BE-logo-transparent-no-tagline.png"},{"meta_key":"img_link","meta_value":"#"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"_edit_lock","meta_value":"1519135838:154"},{"meta_key":"_edit_last","meta_value":"154"}],[{"meta_key":"space","meta_value":"1px"},{"meta_key":"_reflector_data","meta_value":""}],[{"meta_key":"heading","meta_value":"WATCH LIVE<br>STREAMED SPORTS for FREE AT Betsson!"},{"meta_key":"headingtag","meta_value":"h1"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"device_visibility","meta_value":"a:2:{i:0;s:9:\"hidden-lg\";i:1;s:9:\"hidden-md\";}"}],[{"meta_key":"buttontext","meta_value":"Open Account"},{"meta_key":"buttonlink","meta_value":"#"},{"meta_key":"buttonsize","meta_value":"mdm"},{"meta_key":"buttonstyle","meta_value":"std"},{"meta_key":"buttonicon","meta_value":""},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"device_visibility","meta_value":"a:2:{i:0;s:9:\"hidden-lg\";i:1;s:9:\"hidden-md\";}"}],[{"meta_key":"heading","meta_value":"Upcoming Matches"},{"meta_key":"headingtag","meta_value":"h4"},{"meta_key":"_reflector_data","meta_value":""}],[{"meta_key":"rawhtml","meta_value":"<div id=\"echo-matches-container\">\r\n\t<\/div>\r\n<\/div>"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"_edit_lock","meta_value":"1520106421:154"},{"meta_key":"_edit_last","meta_value":"154"}],[{"meta_key":"heading","meta_value":"Watch live<br>streamed sports free at Betsson!"},{"meta_key":"headingtag","meta_value":"h1"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"device_visibility","meta_value":"a:2:{i:0;s:9:\"hidden-sm\";i:1;s:9:\"hidden-xs\";}"}],[{"meta_key":"text","meta_value":"<span class=\"engagement\">Watch 2017\/2018 season matches live and free of charge.<\/span>"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"device_visibility","meta_value":"a:2:{i:0;s:9:\"hidden-sm\";i:1;s:9:\"hidden-xs\";}"}],[{"meta_key":"image","meta_value":"https:\/\/in.betsson.com\/wp-content\/uploads\/content\/betsson\/sites\/3\/2018\/02\/11.png"},{"meta_key":"heading","meta_value":"Open an account"},{"meta_key":"cta_link","meta_value":"#"},{"meta_key":"imageposition","meta_value":"side"},{"meta_key":"buttonsize","meta_value":"sml"},{"meta_key":"buttonstyle","meta_value":"std"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"_edit_lock","meta_value":"1520108191:154"},{"meta_key":"_edit_last","meta_value":"154"},{"meta_key":"image_id","meta_value":"16376"}],[{"meta_key":"image","meta_value":"https:\/\/in.betsson.com\/wp-content\/uploads\/content\/betsson\/sites\/3\/2018\/02\/21.png"},{"meta_key":"heading","meta_value":"Make a deposit"},{"meta_key":"cta_link","meta_value":"#"},{"meta_key":"imageposition","meta_value":"side"},{"meta_key":"buttonsize","meta_value":"sml"},{"meta_key":"buttonstyle","meta_value":"std"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"_edit_lock","meta_value":"1520108192:154"},{"meta_key":"_edit_last","meta_value":"154"},{"meta_key":"image_id","meta_value":"16377"}],[{"meta_key":"image","meta_value":"https:\/\/in.betsson.com\/wp-content\/uploads\/content\/betsson\/sites\/3\/2018\/02\/3.png"},{"meta_key":"heading","meta_value":"Watch all the sports you want for this season"},{"meta_key":"cta_link","meta_value":"#"},{"meta_key":"imageposition","meta_value":"side"},{"meta_key":"buttonsize","meta_value":"sml"},{"meta_key":"buttonstyle","meta_value":"std"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"_edit_lock","meta_value":"1520108191:154"},{"meta_key":"_edit_last","meta_value":"154"},{"meta_key":"image_id","meta_value":"16378"}],[{"meta_key":"buttontext","meta_value":"Open Account"},{"meta_key":"buttonlink","meta_value":"https:\/\/in.betsson.com\/livestream-prebuild\/mx\/test\/"},{"meta_key":"buttonsize","meta_value":"lrg"},{"meta_key":"buttonstyle","meta_value":"std"},{"meta_key":"_reflector_data","meta_value":""},{"meta_key":"_edit_lock","meta_value":"1564580577:154"},{"meta_key":"_edit_last","meta_value":"154"},{"meta_key":"openpopup","meta_value":"on"}],[{"meta_key":"rawhtml","meta_value":"<div class=\"echo-uiwrapper\" ng-repeat=\"ui_element in ::column.elements track by $index\" render-sub-directive=\"<span echo-render-button config=&quot;ui_element&quot;><\/span>\" data-row-id=\"1\" data-column-id=\"5\" data-element-id=\"16597\" ng-class=\"::ui_element.visibility.device_css\" ng-if=\"(((campaign_globals.isMobileApp &amp;&amp; !ui_element.visibility.hide_in_native) || (!campaign_globals.isMobileApp) ) &amp;&amp; (ui_element.visibility.enabled === false || (ui_element.visibility.from <= campaign.request_timestamp &amp;&amp; ui_element.visibility.to >= campaign.request_timestamp))) &amp;&amp; !(ui_element.visibility.hidden)\"><span echo-render-button=\"\" config=\"ui_element\"><a link-control-directive=\"\" config=\"::linkControl\" ng-attr-id=\"{{::elementData.settings.button_id}}\" ng-style=\"::elementData.settings.colour !=='' ? {'background' : elementData.settings.colour}: ''\" ng-show=\"::elementData.settings.hyperlink_text | stripTags | trim\" ng-class=\"::elementData.classes\" class=\"echo-btn  echo-lrg echo-std\" id=\"\" target=\"popup\" href=\"https:\/\/in.betsson.com\/livestream-prebuild\/mx\/test\/\"><span ng-html-compile=\"::elementData.settings.hyperlink_text\">Open Account<\/span> <!-- ngIf: ::elementData.settings.button_icon --><\/a><\/span><a ng-show=\"campaign.logged_in &amp;&amp; is_translating\" target=\"_blank\" class=\"echo-translateLink ng-hide\" href=\"https:\/\/in.betsson.com\/wp-admin\/post.php?post=16597&amp;action=edit&amp;campaign=16311\"><i class=\"fa fa-share-square\"><\/i> Translate buttons<\/a><\/div>"},{"meta_key":"_edit_lock","meta_value":"1564580650:154"},{"meta_key":"_edit_last","meta_value":"154"},{"meta_key":"_reflector_data","meta_value":""}],[{"meta_key":"heading","meta_value":"This is a Heading"},{"meta_key":"headingtag","meta_value":"h1"},{"meta_key":"headingalignment","meta_value":"echo-text-left"}]],"campaign_translations":[],"campaign_rh_elements_meta":[]}