@mideind/netskrafl-react 3.2.5 → 3.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/css/netskrafl.css +10202 -0
- package/dist/esm/index.js +3028 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/types.d.ts +52 -0
- package/package.json +1 -1
|
@@ -0,0 +1,3028 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import t,{useEffect as n}from"react";const i={projectId:"netskrafl",firebaseApiKey:"",databaseUrl:"",firebaseSenderId:"",firebaseAppId:"",measurementId:"",account:"",userEmail:"",netskraflUserId:"",userNick:"",userFullname:"",locale:"is_IS",isExplo:!1,serverUrl:"",movesUrl:"",movesAccessKey:"",token:"",netskraflToken:"",loginMethod:"",subscriptionUrl:"",newUser:!1,beginner:!0,fairPlay:!1,plan:"",hasPaid:!1,audio:!1,fanfare:!1,ready:!0,readyTimed:!0,uiFullscreen:!0,uiLandscape:!1,runningLocal:!1},r="netskrafl_auth_settings",s=(e,t)=>{const n=e=>(e.length>0&&"/"===e[e.length-1]&&(e=e.slice(0,-1)),e);return{serverUrl:n(e),movesUrl:n(t)}},a=e=>{const t={...i,...e},n={...t,...s(t.serverUrl,t.movesUrl)};return c(n)},o=e=>{if(e)try{const t={userEmail:e.userEmail};void 0!==e.account&&(t.account=e.account),void 0!==e.netskraflUserId&&(t.netskraflUserId=e.netskraflUserId),void 0!==e.userNick&&(t.userNick=e.userNick),void 0!==e.firebaseApiKey&&(t.firebaseApiKey=e.firebaseApiKey),void 0!==e.netskraflToken&&(t.netskraflToken=e.netskraflToken),void 0!==e.beginner&&(t.beginner=e.beginner),void 0!==e.fairPlay&&(t.fairPlay=e.fairPlay),void 0!==e.ready&&(t.ready=e.ready),void 0!==e.readyTimed&&(t.readyTimed=e.readyTimed),void 0!==e.audio&&(t.audio=e.audio),void 0!==e.fanfare&&(t.fanfare=e.fanfare),Object.keys(t).length>1?sessionStorage.setItem(r,JSON.stringify(t)):l()}catch(e){console.warn("Could not save auth settings to sessionStorage:",e)}else l()},l=()=>{try{sessionStorage.removeItem(r)}catch(e){console.warn("Could not clear auth settings from sessionStorage:",e)}},c=e=>{const t=(()=>{try{const e=sessionStorage.getItem(r);if(e)return JSON.parse(e)}catch(e){console.warn("Could not load auth settings from sessionStorage:",e)}return null})();return t?t.userEmail!==e.userEmail?(l(),e):{...e,account:t.account||e.account||e.netskraflUserId,netskraflUserId:t.netskraflUserId||e.netskraflUserId,userNick:t.userNick||e.userNick,firebaseApiKey:e.firebaseApiKey||t.firebaseApiKey||e.firebaseApiKey,netskraflToken:t.netskraflToken||e.netskraflToken,beginner:t.beginner??e.beginner,fairPlay:t.fairPlay??e.fairPlay,ready:t.ready??e.ready,readyTimed:t.readyTimed??e.readyTimed,audio:t.audio??e.audio,fanfare:t.fanfare??e.fanfare}:e},u="${JSCORE_VERSION}",h=function(e,t){if(!e)throw d(t)},d=function(e){return new Error("Firebase Database ("+u+") INTERNAL ASSERT FAILED: "+e)},p=function(e){const t=[];let n=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);r<128?t[n++]=r:r<2048?(t[n++]=r>>6|192,t[n++]=63&r|128):55296==(64512&r)&&i+1<e.length&&56320==(64512&e.charCodeAt(i+1))?(r=65536+((1023&r)<<10)+(1023&e.charCodeAt(++i)),t[n++]=r>>18|240,t[n++]=r>>12&63|128,t[n++]=r>>6&63|128,t[n++]=63&r|128):(t[n++]=r>>12|224,t[n++]=r>>6&63|128,t[n++]=63&r|128)}return t},g={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(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,i=[];for(let t=0;t<e.length;t+=3){const r=e[t],s=t+1<e.length,a=s?e[t+1]:0,o=t+2<e.length,l=o?e[t+2]:0,c=r>>2,u=(3&r)<<4|a>>4;let h=(15&a)<<2|l>>6,d=63&l;o||(d=64,s||(h=64)),i.push(n[c],n[u],n[h],n[d])}return i.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(p(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let n=0,i=0;for(;n<e.length;){const r=e[n++];if(r<128)t[i++]=String.fromCharCode(r);else if(r>191&&r<224){const s=e[n++];t[i++]=String.fromCharCode((31&r)<<6|63&s)}else if(r>239&&r<365){const s=((7&r)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536;t[i++]=String.fromCharCode(55296+(s>>10)),t[i++]=String.fromCharCode(56320+(1023&s))}else{const s=e[n++],a=e[n++];t[i++]=String.fromCharCode((15&r)<<12|(63&s)<<6|63&a)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const n=t?this.charToByteMapWebSafe_:this.charToByteMap_,i=[];for(let t=0;t<e.length;){const r=n[e.charAt(t++)],s=t<e.length?n[e.charAt(t)]:0;++t;const a=t<e.length?n[e.charAt(t)]:64;++t;const o=t<e.length?n[e.charAt(t)]:64;if(++t,null==r||null==s||null==a||null==o)throw new f;const l=r<<2|s>>4;if(i.push(l),64!==a){const e=s<<4&240|a>>2;if(i.push(e),64!==o){const e=a<<6&192|o;i.push(e)}}}return i},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class f extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const m=function(e){const t=p(e);return g.encodeByteArray(t,!0)},v=function(e){return m(e).replace(/\./g,"")},y=function(e){try{return g.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2017 Google LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
function w(e){return b(void 0,e)}function b(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(const n in t)t.hasOwnProperty(n)&&_(n)&&(e[n]=b(e[n],t[n]));return e}function _(e){return"__proto__"!==e}
|
|
19
|
+
/**
|
|
20
|
+
* @license
|
|
21
|
+
* Copyright 2022 Google LLC
|
|
22
|
+
*
|
|
23
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
24
|
+
* you may not use this file except in compliance with the License.
|
|
25
|
+
* You may obtain a copy of the License at
|
|
26
|
+
*
|
|
27
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
+
* See the License for the specific language governing permissions and
|
|
33
|
+
* limitations under the License.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* @license
|
|
37
|
+
* Copyright 2022 Google LLC
|
|
38
|
+
*
|
|
39
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
40
|
+
* you may not use this file except in compliance with the License.
|
|
41
|
+
* You may obtain a copy of the License at
|
|
42
|
+
*
|
|
43
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
44
|
+
*
|
|
45
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
46
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
47
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
48
|
+
* See the License for the specific language governing permissions and
|
|
49
|
+
* limitations under the License.
|
|
50
|
+
*/
|
|
51
|
+
const k=()=>function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("Unable to locate global object.")}().__FIREBASE_DEFAULTS__,C=()=>{try{return k()||(()=>{if("undefined"==typeof process||void 0===process.env)return;const e=process.env.__FIREBASE_DEFAULTS__;return e?JSON.parse(e):void 0})()||(()=>{if("undefined"==typeof document)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}const t=e&&y(e[1]);return t&&JSON.parse(t)})()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}},S=e=>C()?.emulatorHosts?.[e],T=()=>C()?.config,I=e=>C()?.[`_${e}`];
|
|
52
|
+
/**
|
|
53
|
+
* @license
|
|
54
|
+
* Copyright 2017 Google LLC
|
|
55
|
+
*
|
|
56
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
57
|
+
* you may not use this file except in compliance with the License.
|
|
58
|
+
* You may obtain a copy of the License at
|
|
59
|
+
*
|
|
60
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
61
|
+
*
|
|
62
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
63
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
64
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
65
|
+
* See the License for the specific language governing permissions and
|
|
66
|
+
* limitations under the License.
|
|
67
|
+
*/
|
|
68
|
+
class E{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,n)=>{t?this.reject(t):this.resolve(n),"function"==typeof e&&(this.promise.catch(()=>{}),1===e.length?e(t):e(t,n))}}}
|
|
69
|
+
/**
|
|
70
|
+
* @license
|
|
71
|
+
* Copyright 2025 Google LLC
|
|
72
|
+
*
|
|
73
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
74
|
+
* you may not use this file except in compliance with the License.
|
|
75
|
+
* You may obtain a copy of the License at
|
|
76
|
+
*
|
|
77
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
78
|
+
*
|
|
79
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
80
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
81
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
82
|
+
* See the License for the specific language governing permissions and
|
|
83
|
+
* limitations under the License.
|
|
84
|
+
*/function P(e){try{return(e.startsWith("http://")||e.startsWith("https://")?new URL(e).hostname:e).endsWith(".cloudworkstations.dev")}catch{return!1}}async function x(e){return(await fetch(e,{credentials:"include"})).ok}
|
|
85
|
+
/**
|
|
86
|
+
* @license
|
|
87
|
+
* Copyright 2021 Google LLC
|
|
88
|
+
*
|
|
89
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
90
|
+
* you may not use this file except in compliance with the License.
|
|
91
|
+
* You may obtain a copy of the License at
|
|
92
|
+
*
|
|
93
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
94
|
+
*
|
|
95
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
96
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
97
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
98
|
+
* See the License for the specific language governing permissions and
|
|
99
|
+
* limitations under the License.
|
|
100
|
+
*/const R={};let L=!1;function N(e,t){if("undefined"==typeof window||"undefined"==typeof document||!P(window.location.host)||R[e]===t||R[e]||L)return;function n(e){return`__firebase__banner__${e}`}R[e]=t;const i="__firebase__banner",r=function(){const e={prod:[],emulator:[]};for(const t of Object.keys(R))R[t]?e.emulator.push(t):e.prod.push(t);return e}().prod.length>0;function s(){const e=document.createElement("span");return e.style.cursor="pointer",e.style.marginLeft="16px",e.style.fontSize="24px",e.innerHTML=" ×",e.onclick=()=>{L=!0,function(){const e=document.getElementById(i);e&&e.remove()}()},e}function a(){const e=function(e){let t=document.getElementById(e),n=!1;return t||(t=document.createElement("div"),t.setAttribute("id",e),n=!0),{created:n,element:t}}(i),t=n("text"),a=document.getElementById(t)||document.createElement("span"),o=n("learnmore"),l=document.getElementById(o)||document.createElement("a"),c=n("preprendIcon"),u=document.getElementById(c)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(e.created){const t=e.element;!function(e){e.style.display="flex",e.style.background="#7faaf0",e.style.position="fixed",e.style.bottom="5px",e.style.left="5px",e.style.padding=".5em",e.style.borderRadius="5px",e.style.alignItems="center"}(t),function(e,t){e.setAttribute("id",t),e.innerText="Learn more",e.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",e.setAttribute("target","__blank"),e.style.paddingLeft="5px",e.style.textDecoration="underline"}(l,o);const n=s();!function(e,t){e.setAttribute("width","24"),e.setAttribute("id",t),e.setAttribute("height","24"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.style.marginLeft="-6px"}(u,c),t.append(u,a,l,n),document.body.appendChild(t)}r?(a.innerText="Preview backend disconnected.",u.innerHTML='<g clip-path="url(#clip0_6013_33858)">\n<path d="M4.8 17.6L12 5.6L19.2 17.6H4.8ZM6.91667 16.4H17.0833L12 7.93333L6.91667 16.4ZM12 15.6C12.1667 15.6 12.3056 15.5444 12.4167 15.4333C12.5389 15.3111 12.6 15.1667 12.6 15C12.6 14.8333 12.5389 14.6944 12.4167 14.5833C12.3056 14.4611 12.1667 14.4 12 14.4C11.8333 14.4 11.6889 14.4611 11.5667 14.5833C11.4556 14.6944 11.4 14.8333 11.4 15C11.4 15.1667 11.4556 15.3111 11.5667 15.4333C11.6889 15.5444 11.8333 15.6 12 15.6ZM11.4 13.6H12.6V10.4H11.4V13.6Z" fill="#212121"/>\n</g>\n<defs>\n<clipPath id="clip0_6013_33858">\n<rect width="24" height="24" fill="white"/>\n</clipPath>\n</defs>'):(u.innerHTML='<g clip-path="url(#clip0_6083_34804)">\n<path d="M11.4 15.2H12.6V11.2H11.4V15.2ZM12 10C12.1667 10 12.3056 9.94444 12.4167 9.83333C12.5389 9.71111 12.6 9.56667 12.6 9.4C12.6 9.23333 12.5389 9.09444 12.4167 8.98333C12.3056 8.86111 12.1667 8.8 12 8.8C11.8333 8.8 11.6889 8.86111 11.5667 8.98333C11.4556 9.09444 11.4 9.23333 11.4 9.4C11.4 9.56667 11.4556 9.71111 11.5667 9.83333C11.6889 9.94444 11.8333 10 12 10ZM12 18.4C11.1222 18.4 10.2944 18.2333 9.51667 17.9C8.73889 17.5667 8.05556 17.1111 7.46667 16.5333C6.88889 15.9444 6.43333 15.2611 6.1 14.4833C5.76667 13.7056 5.6 12.8778 5.6 12C5.6 11.1111 5.76667 10.2833 6.1 9.51667C6.43333 8.73889 6.88889 8.06111 7.46667 7.48333C8.05556 6.89444 8.73889 6.43333 9.51667 6.1C10.2944 5.76667 11.1222 5.6 12 5.6C12.8889 5.6 13.7167 5.76667 14.4833 6.1C15.2611 6.43333 15.9389 6.89444 16.5167 7.48333C17.1056 8.06111 17.5667 8.73889 17.9 9.51667C18.2333 10.2833 18.4 11.1111 18.4 12C18.4 12.8778 18.2333 13.7056 17.9 14.4833C17.5667 15.2611 17.1056 15.9444 16.5167 16.5333C15.9389 17.1111 15.2611 17.5667 14.4833 17.9C13.7167 18.2333 12.8889 18.4 12 18.4ZM12 17.2C13.4444 17.2 14.6722 16.6944 15.6833 15.6833C16.6944 14.6722 17.2 13.4444 17.2 12C17.2 10.5556 16.6944 9.32778 15.6833 8.31667C14.6722 7.30555 13.4444 6.8 12 6.8C10.5556 6.8 9.32778 7.30555 8.31667 8.31667C7.30556 9.32778 6.8 10.5556 6.8 12C6.8 13.4444 7.30556 14.6722 8.31667 15.6833C9.32778 16.6944 10.5556 17.2 12 17.2Z" fill="#212121"/>\n</g>\n<defs>\n<clipPath id="clip0_6083_34804">\n<rect width="24" height="24" fill="white"/>\n</clipPath>\n</defs>',a.innerText="Preview backend running in this workspace."),a.setAttribute("id",t)}"loading"===document.readyState?window.addEventListener("DOMContentLoaded",a):a()}
|
|
101
|
+
/**
|
|
102
|
+
* @license
|
|
103
|
+
* Copyright 2017 Google LLC
|
|
104
|
+
*
|
|
105
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
106
|
+
* you may not use this file except in compliance with the License.
|
|
107
|
+
* You may obtain a copy of the License at
|
|
108
|
+
*
|
|
109
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
110
|
+
*
|
|
111
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
112
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
113
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
114
|
+
* See the License for the specific language governing permissions and
|
|
115
|
+
* limitations under the License.
|
|
116
|
+
*/function D(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function A(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(D())}function M(){const e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof e&&void 0!==e.id}function O(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function j(){try{return"object"==typeof indexedDB}catch(e){return!1}}function F(){return new Promise((e,t)=>{try{let n=!0;const i="validate-browser-context-for-indexeddb-analytics-module",r=self.indexedDB.open(i);r.onsuccess=()=>{r.result.close(),n||self.indexedDB.deleteDatabase(i),e(!0)},r.onupgradeneeded=()=>{n=!1},r.onerror=()=>{t(r.error?.message||"")}}catch(e){t(e)}})}class z extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,z.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,U.prototype.create)}}class U{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){const n=t[0]||{},i=`${this.service}/${e}`,r=this.errors[e],s=r?function(e,t){return e.replace($,(e,n)=>{const i=t[n];return null!=i?String(i):`<${n}?>`})}(r,n):"Error",a=`${this.serviceName}: ${s} (${i}).`;return new z(i,a,n)}}const $=/\{\$([^}]+)}/g;
|
|
117
|
+
/**
|
|
118
|
+
* @license
|
|
119
|
+
* Copyright 2017 Google LLC
|
|
120
|
+
*
|
|
121
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
122
|
+
* you may not use this file except in compliance with the License.
|
|
123
|
+
* You may obtain a copy of the License at
|
|
124
|
+
*
|
|
125
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
126
|
+
*
|
|
127
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
128
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
129
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
130
|
+
* See the License for the specific language governing permissions and
|
|
131
|
+
* limitations under the License.
|
|
132
|
+
*/function q(e){return JSON.parse(e)}function B(e){return JSON.stringify(e)}
|
|
133
|
+
/**
|
|
134
|
+
* @license
|
|
135
|
+
* Copyright 2017 Google LLC
|
|
136
|
+
*
|
|
137
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
138
|
+
* you may not use this file except in compliance with the License.
|
|
139
|
+
* You may obtain a copy of the License at
|
|
140
|
+
*
|
|
141
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
142
|
+
*
|
|
143
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
144
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
145
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
146
|
+
* See the License for the specific language governing permissions and
|
|
147
|
+
* limitations under the License.
|
|
148
|
+
*/const V=function(e){let t={},n={},i={},r="";try{const s=e.split(".");t=q(y(s[0])||""),n=q(y(s[1])||""),r=s[2],i=n.d||{},delete n.d}catch(e){}return{header:t,claims:n,data:i,signature:r}};
|
|
149
|
+
/**
|
|
150
|
+
* @license
|
|
151
|
+
* Copyright 2017 Google LLC
|
|
152
|
+
*
|
|
153
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
154
|
+
* you may not use this file except in compliance with the License.
|
|
155
|
+
* You may obtain a copy of the License at
|
|
156
|
+
*
|
|
157
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
158
|
+
*
|
|
159
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
160
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
161
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
162
|
+
* See the License for the specific language governing permissions and
|
|
163
|
+
* limitations under the License.
|
|
164
|
+
*/
|
|
165
|
+
function H(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function W(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function G(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function K(e,t,n){const i={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=t.call(n,e[r],r,e));return i}function Y(e,t){if(e===t)return!0;const n=Object.keys(e),i=Object.keys(t);for(const r of n){if(!i.includes(r))return!1;const n=e[r],s=t[r];if(J(n)&&J(s)){if(!Y(n,s))return!1}else if(n!==s)return!1}for(const e of i)if(!n.includes(e))return!1;return!0}function J(e){return null!==e&&"object"==typeof e}
|
|
166
|
+
/**
|
|
167
|
+
* @license
|
|
168
|
+
* Copyright 2017 Google LLC
|
|
169
|
+
*
|
|
170
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
171
|
+
* you may not use this file except in compliance with the License.
|
|
172
|
+
* You may obtain a copy of the License at
|
|
173
|
+
*
|
|
174
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
175
|
+
*
|
|
176
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
177
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
178
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
179
|
+
* See the License for the specific language governing permissions and
|
|
180
|
+
* limitations under the License.
|
|
181
|
+
*/function Z(e){const t=[];for(const[n,i]of Object.entries(e))Array.isArray(i)?i.forEach(e=>{t.push(encodeURIComponent(n)+"="+encodeURIComponent(e))}):t.push(encodeURIComponent(n)+"="+encodeURIComponent(i));return t.length?"&"+t.join("&"):""}
|
|
182
|
+
/**
|
|
183
|
+
* @license
|
|
184
|
+
* Copyright 2017 Google LLC
|
|
185
|
+
*
|
|
186
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
187
|
+
* you may not use this file except in compliance with the License.
|
|
188
|
+
* You may obtain a copy of the License at
|
|
189
|
+
*
|
|
190
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
191
|
+
*
|
|
192
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
193
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
194
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
195
|
+
* See the License for the specific language governing permissions and
|
|
196
|
+
* limitations under the License.
|
|
197
|
+
*/class X{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(let e=1;e<this.blockSize;++e)this.pad_[e]=0;this.reset()}reset(){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}compress_(e,t){t||(t=0);const n=this.W_;if("string"==typeof e)for(let i=0;i<16;i++)n[i]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(let i=0;i<16;i++)n[i]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],t+=4;for(let e=16;e<80;e++){const t=n[e-3]^n[e-8]^n[e-14]^n[e-16];n[e]=4294967295&(t<<1|t>>>31)}let i,r,s=this.chain_[0],a=this.chain_[1],o=this.chain_[2],l=this.chain_[3],c=this.chain_[4];for(let e=0;e<80;e++){e<40?e<20?(i=l^a&(o^l),r=1518500249):(i=a^o^l,r=1859775393):e<60?(i=a&o|l&(a|o),r=2400959708):(i=a^o^l,r=3395469782);const t=(s<<5|s>>>27)+i+c+r+n[e]&4294967295;c=l,l=o,o=4294967295&(a<<30|a>>>2),a=s,s=t}this.chain_[0]=this.chain_[0]+s&4294967295,this.chain_[1]=this.chain_[1]+a&4294967295,this.chain_[2]=this.chain_[2]+o&4294967295,this.chain_[3]=this.chain_[3]+l&4294967295,this.chain_[4]=this.chain_[4]+c&4294967295}update(e,t){if(null==e)return;void 0===t&&(t=e.length);const n=t-this.blockSize;let i=0;const r=this.buf_;let s=this.inbuf_;for(;i<t;){if(0===s)for(;i<=n;)this.compress_(e,i),i+=this.blockSize;if("string"==typeof e){for(;i<t;)if(r[s]=e.charCodeAt(i),++s,++i,s===this.blockSize){this.compress_(r),s=0;break}}else for(;i<t;)if(r[s]=e[i],++s,++i,s===this.blockSize){this.compress_(r),s=0;break}}this.inbuf_=s,this.total_+=t}digest(){const e=[];let t=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let e=this.blockSize-1;e>=56;e--)this.buf_[e]=255&t,t/=256;this.compress_(this.buf_);let n=0;for(let t=0;t<5;t++)for(let i=24;i>=0;i-=8)e[n]=this.chain_[t]>>i&255,++n;return e}}class Q{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(e=>{this.error(e)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,n){let i;if(void 0===e&&void 0===t&&void 0===n)throw new Error("Missing Observer.");i=function(e,t){if("object"!=typeof e||null===e)return!1;for(const n of t)if(n in e&&"function"==typeof e[n])return!0;return!1}(e,["next","error","complete"])?e:{next:e,error:t,complete:n},void 0===i.next&&(i.next=ee),void 0===i.error&&(i.error=ee),void 0===i.complete&&(i.complete=ee);const r=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?i.error(this.finalError):i.complete()}catch(e){}}),this.observers.push(i),r}unsubscribeOne(e){void 0!==this.observers&&void 0!==this.observers[e]&&(delete this.observers[e],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(void 0!==this.observers&&void 0!==this.observers[e])try{t(this.observers[e])}catch(e){"undefined"!=typeof console&&console.error&&console.error(e)}})}close(e){this.finalized||(this.finalized=!0,void 0!==e&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function ee(){}function te(e,t){return`${e} failed: ${t} argument `}
|
|
198
|
+
/**
|
|
199
|
+
* @license
|
|
200
|
+
* Copyright 2017 Google LLC
|
|
201
|
+
*
|
|
202
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
203
|
+
* you may not use this file except in compliance with the License.
|
|
204
|
+
* You may obtain a copy of the License at
|
|
205
|
+
*
|
|
206
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
207
|
+
*
|
|
208
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
209
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
210
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
211
|
+
* See the License for the specific language governing permissions and
|
|
212
|
+
* limitations under the License.
|
|
213
|
+
*/const ne=function(e){let t=0;for(let n=0;n<e.length;n++){const i=e.charCodeAt(n);i<128?t++:i<2048?t+=2:i>=55296&&i<=56319?(t+=4,n++):t+=3}return t};function ie(e,t=1e3,n=2){const i=t*Math.pow(n,e),r=Math.round(.5*i*(Math.random()-.5)*2);return Math.min(144e5,i+r)}
|
|
214
|
+
/**
|
|
215
|
+
* @license
|
|
216
|
+
* Copyright 2021 Google LLC
|
|
217
|
+
*
|
|
218
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
219
|
+
* you may not use this file except in compliance with the License.
|
|
220
|
+
* You may obtain a copy of the License at
|
|
221
|
+
*
|
|
222
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
223
|
+
*
|
|
224
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
225
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
226
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
227
|
+
* See the License for the specific language governing permissions and
|
|
228
|
+
* limitations under the License.
|
|
229
|
+
*/function re(e){return e&&e._delegate?e._delegate:e}class se{constructor(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}
|
|
230
|
+
/**
|
|
231
|
+
* @license
|
|
232
|
+
* Copyright 2019 Google LLC
|
|
233
|
+
*
|
|
234
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
235
|
+
* you may not use this file except in compliance with the License.
|
|
236
|
+
* You may obtain a copy of the License at
|
|
237
|
+
*
|
|
238
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
239
|
+
*
|
|
240
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
241
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
242
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
243
|
+
* See the License for the specific language governing permissions and
|
|
244
|
+
* limitations under the License.
|
|
245
|
+
*/const ae="[DEFAULT]";
|
|
246
|
+
/**
|
|
247
|
+
* @license
|
|
248
|
+
* Copyright 2019 Google LLC
|
|
249
|
+
*
|
|
250
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
251
|
+
* you may not use this file except in compliance with the License.
|
|
252
|
+
* You may obtain a copy of the License at
|
|
253
|
+
*
|
|
254
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
255
|
+
*
|
|
256
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
257
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
258
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
259
|
+
* See the License for the specific language governing permissions and
|
|
260
|
+
* limitations under the License.
|
|
261
|
+
*/class oe{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const e=new E;if(this.instancesDeferred.set(t,e),this.isInitialized(t)||this.shouldAutoInitialize())try{const n=this.getOrInitializeService({instanceIdentifier:t});n&&e.resolve(n)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){const t=this.normalizeInstanceIdentifier(e?.identifier),n=e?.optional??!1;if(!this.isInitialized(t)&&!this.shouldAutoInitialize()){if(n)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:t})}catch(e){if(n)return null;throw e}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,this.shouldAutoInitialize()){if(function(e){return"EAGER"===e.instantiationMode}
|
|
262
|
+
/**
|
|
263
|
+
* @license
|
|
264
|
+
* Copyright 2019 Google LLC
|
|
265
|
+
*
|
|
266
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
267
|
+
* you may not use this file except in compliance with the License.
|
|
268
|
+
* You may obtain a copy of the License at
|
|
269
|
+
*
|
|
270
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
271
|
+
*
|
|
272
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
273
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
274
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
275
|
+
* See the License for the specific language governing permissions and
|
|
276
|
+
* limitations under the License.
|
|
277
|
+
*/(e))try{this.getOrInitializeService({instanceIdentifier:ae})}catch(e){}for(const[e,t]of this.instancesDeferred.entries()){const n=this.normalizeInstanceIdentifier(e);try{const e=this.getOrInitializeService({instanceIdentifier:n});t.resolve(e)}catch(e){}}}}clearInstance(e=ae){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...e.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return null!=this.component}isInitialized(e=ae){return this.instances.has(e)}getOptions(e=ae){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,n=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const i=this.getOrInitializeService({instanceIdentifier:n,options:t});for(const[e,t]of this.instancesDeferred.entries()){n===this.normalizeInstanceIdentifier(e)&&t.resolve(i)}return i}onInit(e,t){const n=this.normalizeInstanceIdentifier(t),i=this.onInitCallbacks.get(n)??new Set;i.add(e),this.onInitCallbacks.set(n,i);const r=this.instances.get(n);return r&&e(r,n),()=>{i.delete(e)}}invokeOnInitCallbacks(e,t){const n=this.onInitCallbacks.get(t);if(n)for(const i of n)try{i(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let n=this.instances.get(e);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:(i=e,i===ae?void 0:i),options:t}),this.instances.set(e,n),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(n,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,n)}catch{}var i;return n||null}normalizeInstanceIdentifier(e=ae){return this.component?this.component.multipleInstances?e:ae:e}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class le{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new oe(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}
|
|
278
|
+
/**
|
|
279
|
+
* @license
|
|
280
|
+
* Copyright 2017 Google LLC
|
|
281
|
+
*
|
|
282
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
283
|
+
* you may not use this file except in compliance with the License.
|
|
284
|
+
* You may obtain a copy of the License at
|
|
285
|
+
*
|
|
286
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
287
|
+
*
|
|
288
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
289
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
290
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
291
|
+
* See the License for the specific language governing permissions and
|
|
292
|
+
* limitations under the License.
|
|
293
|
+
*/var ce;!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"}(ce||(ce={}));const ue={debug:ce.DEBUG,verbose:ce.VERBOSE,info:ce.INFO,warn:ce.WARN,error:ce.ERROR,silent:ce.SILENT},he=ce.INFO,de={[ce.DEBUG]:"log",[ce.VERBOSE]:"log",[ce.INFO]:"info",[ce.WARN]:"warn",[ce.ERROR]:"error"},pe=(e,t,...n)=>{if(t<e.logLevel)return;const i=(new Date).toISOString(),r=de[t];if(!r)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[r](`[${i}] ${e.name}:`,...n)};class ge{constructor(e){this.name=e,this._logLevel=he,this._logHandler=pe,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in ce))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?ue[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,ce.DEBUG,...e),this._logHandler(this,ce.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,ce.VERBOSE,...e),this._logHandler(this,ce.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,ce.INFO,...e),this._logHandler(this,ce.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,ce.WARN,...e),this._logHandler(this,ce.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,ce.ERROR,...e),this._logHandler(this,ce.ERROR,...e)}}let fe,me;const ve=new WeakMap,ye=new WeakMap,we=new WeakMap,be=new WeakMap,_e=new WeakMap;let ke={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return ye.get(e);if("objectStoreNames"===t)return e.objectStoreNames||we.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Te(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function Ce(e){return e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(me||(me=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(Ie(this),t),Te(ve.get(this))}:function(...t){return Te(e.apply(Ie(this),t))}:function(t,...n){const i=e.call(Ie(this),t,...n);return we.set(i,t.sort?t.sort():[t]),Te(i)}}function Se(e){return"function"==typeof e?Ce(e):(e instanceof IDBTransaction&&function(e){if(ye.has(e))return;const t=new Promise((t,n)=>{const i=()=>{e.removeEventListener("complete",r),e.removeEventListener("error",s),e.removeEventListener("abort",s)},r=()=>{t(),i()},s=()=>{n(e.error||new DOMException("AbortError","AbortError")),i()};e.addEventListener("complete",r),e.addEventListener("error",s),e.addEventListener("abort",s)});ye.set(e,t)}(e),t=e,(fe||(fe=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some(e=>t instanceof e)?new Proxy(e,ke):e);var t}function Te(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,n)=>{const i=()=>{e.removeEventListener("success",r),e.removeEventListener("error",s)},r=()=>{t(Te(e.result)),i()},s=()=>{n(e.error),i()};e.addEventListener("success",r),e.addEventListener("error",s)});return t.then(t=>{t instanceof IDBCursor&&ve.set(t,e)}).catch(()=>{}),_e.set(t,e),t}(e);if(be.has(e))return be.get(e);const t=Se(e);return t!==e&&(be.set(e,t),_e.set(t,e)),t}const Ie=e=>_e.get(e);function Ee(e,t,{blocked:n,upgrade:i,blocking:r,terminated:s}={}){const a=indexedDB.open(e,t),o=Te(a);return i&&a.addEventListener("upgradeneeded",e=>{i(Te(a.result),e.oldVersion,e.newVersion,Te(a.transaction),e)}),n&&a.addEventListener("blocked",e=>n(e.oldVersion,e.newVersion,e)),o.then(e=>{s&&e.addEventListener("close",()=>s()),r&&e.addEventListener("versionchange",e=>r(e.oldVersion,e.newVersion,e))}).catch(()=>{}),o}const Pe=["get","getKey","getAll","getAllKeys","count"],xe=["put","add","delete","clear"],Re=new Map;function Le(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(Re.get(t))return Re.get(t);const n=t.replace(/FromIndex$/,""),i=t!==n,r=xe.includes(n);if(!(n in(i?IDBIndex:IDBObjectStore).prototype)||!r&&!Pe.includes(n))return;const s=async function(e,...t){const s=this.transaction(e,r?"readwrite":"readonly");let a=s.store;return i&&(a=a.index(t.shift())),(await Promise.all([a[n](...t),r&&s.done]))[0]};return Re.set(t,s),s}ke=(e=>({...e,get:(t,n,i)=>Le(t,n)||e.get(t,n,i),has:(t,n)=>!!Le(t,n)||e.has(t,n)}))(ke);
|
|
294
|
+
/**
|
|
295
|
+
* @license
|
|
296
|
+
* Copyright 2019 Google LLC
|
|
297
|
+
*
|
|
298
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
299
|
+
* you may not use this file except in compliance with the License.
|
|
300
|
+
* You may obtain a copy of the License at
|
|
301
|
+
*
|
|
302
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
303
|
+
*
|
|
304
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
305
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
306
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
307
|
+
* See the License for the specific language governing permissions and
|
|
308
|
+
* limitations under the License.
|
|
309
|
+
*/
|
|
310
|
+
class Ne{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(function(e){const t=e.getComponent();return"VERSION"===t?.type}(e)){const t=e.getImmediate();return`${t.library}/${t.version}`}return null}).filter(e=>e).join(" ")}}const De="@firebase/app",Ae="0.14.8",Me=new ge("@firebase/app"),Oe="@firebase/app-compat",je="@firebase/analytics-compat",Fe="@firebase/analytics",ze="@firebase/app-check-compat",Ue="@firebase/app-check",$e="@firebase/auth",qe="@firebase/auth-compat",Be="@firebase/database",Ve="@firebase/data-connect",He="@firebase/database-compat",We="@firebase/functions",Ge="@firebase/functions-compat",Ke="@firebase/installations",Ye="@firebase/installations-compat",Je="@firebase/messaging",Ze="@firebase/messaging-compat",Xe="@firebase/performance",Qe="@firebase/performance-compat",et="@firebase/remote-config",tt="@firebase/remote-config-compat",nt="@firebase/storage",it="@firebase/storage-compat",rt="@firebase/firestore",st="@firebase/ai",at="@firebase/firestore-compat",ot="firebase",lt="[DEFAULT]",ct={[De]:"fire-core",[Oe]:"fire-core-compat",[Fe]:"fire-analytics",[je]:"fire-analytics-compat",[Ue]:"fire-app-check",[ze]:"fire-app-check-compat",[$e]:"fire-auth",[qe]:"fire-auth-compat",[Be]:"fire-rtdb",[Ve]:"fire-data-connect",[He]:"fire-rtdb-compat",[We]:"fire-fn",[Ge]:"fire-fn-compat",[Ke]:"fire-iid",[Ye]:"fire-iid-compat",[Je]:"fire-fcm",[Ze]:"fire-fcm-compat",[Xe]:"fire-perf",[Qe]:"fire-perf-compat",[et]:"fire-rc",[tt]:"fire-rc-compat",[nt]:"fire-gcs",[it]:"fire-gcs-compat",[rt]:"fire-fst",[at]:"fire-fst-compat",[st]:"fire-vertex","fire-js":"fire-js",[ot]:"fire-js-all"},ut=new Map,ht=new Map,dt=new Map;function pt(e,t){try{e.container.addComponent(t)}catch(n){Me.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function gt(e){const t=e.name;if(dt.has(t))return Me.debug(`There were multiple attempts to register component ${t}.`),!1;dt.set(t,e);for(const t of ut.values())pt(t,e);for(const t of ht.values())pt(t,e);return!0}function ft(e,t){const n=e.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function mt(e){return null!=e&&void 0!==e.settings}
|
|
311
|
+
/**
|
|
312
|
+
* @license
|
|
313
|
+
* Copyright 2019 Google LLC
|
|
314
|
+
*
|
|
315
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
316
|
+
* you may not use this file except in compliance with the License.
|
|
317
|
+
* You may obtain a copy of the License at
|
|
318
|
+
*
|
|
319
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
320
|
+
*
|
|
321
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
322
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
323
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
324
|
+
* See the License for the specific language governing permissions and
|
|
325
|
+
* limitations under the License.
|
|
326
|
+
*/const vt=new U("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."});
|
|
327
|
+
/**
|
|
328
|
+
* @license
|
|
329
|
+
* Copyright 2019 Google LLC
|
|
330
|
+
*
|
|
331
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
332
|
+
* you may not use this file except in compliance with the License.
|
|
333
|
+
* You may obtain a copy of the License at
|
|
334
|
+
*
|
|
335
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
336
|
+
*
|
|
337
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
338
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
339
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
340
|
+
* See the License for the specific language governing permissions and
|
|
341
|
+
* limitations under the License.
|
|
342
|
+
*/
|
|
343
|
+
class yt{constructor(e,t,n){this._isDeleted=!1,this._options={...e},this._config={...t},this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new se("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw vt.create("app-deleted",{appName:this._name})}}
|
|
344
|
+
/**
|
|
345
|
+
* @license
|
|
346
|
+
* Copyright 2019 Google LLC
|
|
347
|
+
*
|
|
348
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
349
|
+
* you may not use this file except in compliance with the License.
|
|
350
|
+
* You may obtain a copy of the License at
|
|
351
|
+
*
|
|
352
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
353
|
+
*
|
|
354
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
355
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
356
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
357
|
+
* See the License for the specific language governing permissions and
|
|
358
|
+
* limitations under the License.
|
|
359
|
+
*/const wt="12.9.0";function bt(e,t={}){let n=e;if("object"!=typeof t){t={name:t}}const i={name:lt,automaticDataCollectionEnabled:!0,...t},r=i.name;if("string"!=typeof r||!r)throw vt.create("bad-app-name",{appName:String(r)});if(n||(n=T()),!n)throw vt.create("no-options");const s=ut.get(r);if(s){if(Y(n,s.options)&&Y(i,s.config))return s;throw vt.create("duplicate-app",{appName:r})}const a=new le(r);for(const e of dt.values())a.addComponent(e);const o=new yt(n,i,a);return ut.set(r,o),o}function _t(e=lt){const t=ut.get(e);if(!t&&e===lt&&T())return bt();if(!t)throw vt.create("no-app",{appName:e});return t}function kt(e,t,n){let i=ct[e]??e;n&&(i+=`-${n}`);const r=i.match(/\s|\//),s=t.match(/\s|\//);if(r||s){const e=[`Unable to register library "${i}" with version "${t}":`];return r&&e.push(`library name "${i}" contains illegal characters (whitespace or "/")`),r&&s&&e.push("and"),s&&e.push(`version name "${t}" contains illegal characters (whitespace or "/")`),void Me.warn(e.join(" "))}gt(new se(`${i}-version`,()=>({library:i,version:t}),"VERSION"))}
|
|
360
|
+
/**
|
|
361
|
+
* @license
|
|
362
|
+
* Copyright 2021 Google LLC
|
|
363
|
+
*
|
|
364
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
365
|
+
* you may not use this file except in compliance with the License.
|
|
366
|
+
* You may obtain a copy of the License at
|
|
367
|
+
*
|
|
368
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
369
|
+
*
|
|
370
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
371
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
372
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
373
|
+
* See the License for the specific language governing permissions and
|
|
374
|
+
* limitations under the License.
|
|
375
|
+
*/const Ct="firebase-heartbeat-store";let St=null;function Tt(){return St||(St=Ee("firebase-heartbeat-database",1,{upgrade:(e,t)=>{if(0===t)try{e.createObjectStore(Ct)}catch(e){console.warn(e)}}}).catch(e=>{throw vt.create("idb-open",{originalErrorMessage:e.message})})),St}async function It(e,t){try{const n=(await Tt()).transaction(Ct,"readwrite"),i=n.objectStore(Ct);await i.put(t,Et(e)),await n.done}catch(e){if(e instanceof z)Me.warn(e.message);else{const t=vt.create("idb-set",{originalErrorMessage:e?.message});Me.warn(t.message)}}}function Et(e){return`${e.name}!${e.options.appId}`}
|
|
376
|
+
/**
|
|
377
|
+
* @license
|
|
378
|
+
* Copyright 2021 Google LLC
|
|
379
|
+
*
|
|
380
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
381
|
+
* you may not use this file except in compliance with the License.
|
|
382
|
+
* You may obtain a copy of the License at
|
|
383
|
+
*
|
|
384
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
385
|
+
*
|
|
386
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
387
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
388
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
389
|
+
* See the License for the specific language governing permissions and
|
|
390
|
+
* limitations under the License.
|
|
391
|
+
*/class Pt{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new Rt(t),this._heartbeatsCachePromise=this._storage.read().then(e=>(this._heartbeatsCache=e,e))}async triggerHeartbeat(){try{const e=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),t=xt();if(null==this._heartbeatsCache?.heartbeats&&(this._heartbeatsCache=await this._heartbeatsCachePromise,null==this._heartbeatsCache?.heartbeats))return;if(this._heartbeatsCache.lastSentHeartbeatDate===t||this._heartbeatsCache.heartbeats.some(e=>e.date===t))return;if(this._heartbeatsCache.heartbeats.push({date:t,agent:e}),this._heartbeatsCache.heartbeats.length>30){const e=function(e){if(0===e.length)return-1;let t=0,n=e[0].date;for(let i=1;i<e.length;i++)e[i].date<n&&(n=e[i].date,t=i);return t}
|
|
392
|
+
/**
|
|
393
|
+
* @license
|
|
394
|
+
* Copyright 2019 Google LLC
|
|
395
|
+
*
|
|
396
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
397
|
+
* you may not use this file except in compliance with the License.
|
|
398
|
+
* You may obtain a copy of the License at
|
|
399
|
+
*
|
|
400
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
401
|
+
*
|
|
402
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
403
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
404
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
405
|
+
* See the License for the specific language governing permissions and
|
|
406
|
+
* limitations under the License.
|
|
407
|
+
*/(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(e,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){Me.warn(e)}}async getHeartbeatsHeader(){try{if(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,null==this._heartbeatsCache?.heartbeats||0===this._heartbeatsCache.heartbeats.length)return"";const e=xt(),{heartbeatsToSend:t,unsentEntries:n}=function(e,t=1024){const n=[];let i=e.slice();for(const r of e){const e=n.find(e=>e.agent===r.agent);if(e){if(e.dates.push(r.date),Lt(n)>t){e.dates.pop();break}}else if(n.push({agent:r.agent,dates:[r.date]}),Lt(n)>t){n.pop();break}i=i.slice(1)}return{heartbeatsToSend:n,unsentEntries:i}}(this._heartbeatsCache.heartbeats),i=v(JSON.stringify({version:2,heartbeats:t}));return this._heartbeatsCache.lastSentHeartbeatDate=e,n.length>0?(this._heartbeatsCache.heartbeats=n,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(e){return Me.warn(e),""}}}function xt(){return(new Date).toISOString().substring(0,10)}class Rt{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!j()&&F().then(()=>!0).catch(()=>!1)}async read(){if(await this._canUseIndexedDBPromise){const e=await async function(e){try{const t=(await Tt()).transaction(Ct),n=await t.objectStore(Ct).get(Et(e));return await t.done,n}catch(e){if(e instanceof z)Me.warn(e.message);else{const t=vt.create("idb-get",{originalErrorMessage:e?.message});Me.warn(t.message)}}}(this.app);return e?.heartbeats?e:{heartbeats:[]}}return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const t=await this.read();return It(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??t.lastSentHeartbeatDate,heartbeats:e.heartbeats})}}async add(e){if(await this._canUseIndexedDBPromise){const t=await this.read();return It(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??t.lastSentHeartbeatDate,heartbeats:[...t.heartbeats,...e.heartbeats]})}}}function Lt(e){return v(JSON.stringify({version:2,heartbeats:e})).length}var Nt;Nt="",gt(new se("platform-logger",e=>new Ne(e),"PRIVATE")),gt(new se("heartbeat",e=>new Pt(e),"PRIVATE")),kt(De,Ae,Nt),kt(De,Ae,"esm2020"),kt("fire-js","");const Dt="@firebase/installations",At="0.6.19",Mt=1e4,Ot=`w:${At}`,jt="FIS_v2",Ft=36e5,zt=new U("installations","Installations",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."});function Ut(e){return e instanceof z&&e.code.includes("request-failed")}
|
|
408
|
+
/**
|
|
409
|
+
* @license
|
|
410
|
+
* Copyright 2019 Google LLC
|
|
411
|
+
*
|
|
412
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
413
|
+
* you may not use this file except in compliance with the License.
|
|
414
|
+
* You may obtain a copy of the License at
|
|
415
|
+
*
|
|
416
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
417
|
+
*
|
|
418
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
419
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
420
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
421
|
+
* See the License for the specific language governing permissions and
|
|
422
|
+
* limitations under the License.
|
|
423
|
+
*/function $t({projectId:e}){return`https://firebaseinstallations.googleapis.com/v1/projects/${e}/installations`}function qt(e){return{token:e.token,requestStatus:2,expiresIn:(t=e.expiresIn,Number(t.replace("s","000"))),creationTime:Date.now()};var t}async function Bt(e,t){const n=(await t.json()).error;return zt.create("request-failed",{requestName:e,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})}function Vt({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function Ht(e,{refreshToken:t}){const n=Vt(e);return n.append("Authorization",function(e){return`${jt} ${e}`}
|
|
424
|
+
/**
|
|
425
|
+
* @license
|
|
426
|
+
* Copyright 2019 Google LLC
|
|
427
|
+
*
|
|
428
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
429
|
+
* you may not use this file except in compliance with the License.
|
|
430
|
+
* You may obtain a copy of the License at
|
|
431
|
+
*
|
|
432
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
433
|
+
*
|
|
434
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
435
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
436
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
437
|
+
* See the License for the specific language governing permissions and
|
|
438
|
+
* limitations under the License.
|
|
439
|
+
*/(t)),n}async function Wt(e){const t=await e();return t.status>=500&&t.status<600?e():t}
|
|
440
|
+
/**
|
|
441
|
+
* @license
|
|
442
|
+
* Copyright 2019 Google LLC
|
|
443
|
+
*
|
|
444
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
445
|
+
* you may not use this file except in compliance with the License.
|
|
446
|
+
* You may obtain a copy of the License at
|
|
447
|
+
*
|
|
448
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
449
|
+
*
|
|
450
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
451
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
452
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
453
|
+
* See the License for the specific language governing permissions and
|
|
454
|
+
* limitations under the License.
|
|
455
|
+
*/
|
|
456
|
+
function Gt(e){return new Promise(t=>{setTimeout(t,e)})}
|
|
457
|
+
/**
|
|
458
|
+
* @license
|
|
459
|
+
* Copyright 2019 Google LLC
|
|
460
|
+
*
|
|
461
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
462
|
+
* you may not use this file except in compliance with the License.
|
|
463
|
+
* You may obtain a copy of the License at
|
|
464
|
+
*
|
|
465
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
466
|
+
*
|
|
467
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
468
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
469
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
470
|
+
* See the License for the specific language governing permissions and
|
|
471
|
+
* limitations under the License.
|
|
472
|
+
*/
|
|
473
|
+
/**
|
|
474
|
+
* @license
|
|
475
|
+
* Copyright 2019 Google LLC
|
|
476
|
+
*
|
|
477
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
478
|
+
* you may not use this file except in compliance with the License.
|
|
479
|
+
* You may obtain a copy of the License at
|
|
480
|
+
*
|
|
481
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
482
|
+
*
|
|
483
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
484
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
485
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
486
|
+
* See the License for the specific language governing permissions and
|
|
487
|
+
* limitations under the License.
|
|
488
|
+
*/
|
|
489
|
+
const Kt=/^[cdef][\w-]{21}$/;function Yt(){try{const e=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(e),e[0]=112+e[0]%16;const t=function(e){const t=(n=e,btoa(String.fromCharCode(...n)).replace(/\+/g,"-").replace(/\//g,"_"));var n;return t.substr(0,22)}
|
|
490
|
+
/**
|
|
491
|
+
* @license
|
|
492
|
+
* Copyright 2019 Google LLC
|
|
493
|
+
*
|
|
494
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
495
|
+
* you may not use this file except in compliance with the License.
|
|
496
|
+
* You may obtain a copy of the License at
|
|
497
|
+
*
|
|
498
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
499
|
+
*
|
|
500
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
501
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
502
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
503
|
+
* See the License for the specific language governing permissions and
|
|
504
|
+
* limitations under the License.
|
|
505
|
+
*/(e);return Kt.test(t)?t:""}catch{return""}}function Jt(e){return`${e.appName}!${e.appId}`}
|
|
506
|
+
/**
|
|
507
|
+
* @license
|
|
508
|
+
* Copyright 2019 Google LLC
|
|
509
|
+
*
|
|
510
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
511
|
+
* you may not use this file except in compliance with the License.
|
|
512
|
+
* You may obtain a copy of the License at
|
|
513
|
+
*
|
|
514
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
515
|
+
*
|
|
516
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
517
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
518
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
519
|
+
* See the License for the specific language governing permissions and
|
|
520
|
+
* limitations under the License.
|
|
521
|
+
*/const Zt=new Map;function Xt(e,t){const n=Jt(e);Qt(n,t),function(e,t){const n=function(){!en&&"BroadcastChannel"in self&&(en=new BroadcastChannel("[Firebase] FID Change"),en.onmessage=e=>{Qt(e.data.key,e.data.fid)});return en}();n&&n.postMessage({key:e,fid:t});0===Zt.size&&en&&(en.close(),en=null)}(n,t)}function Qt(e,t){const n=Zt.get(e);if(n)for(const e of n)e(t)}let en=null;
|
|
522
|
+
/**
|
|
523
|
+
* @license
|
|
524
|
+
* Copyright 2019 Google LLC
|
|
525
|
+
*
|
|
526
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
527
|
+
* you may not use this file except in compliance with the License.
|
|
528
|
+
* You may obtain a copy of the License at
|
|
529
|
+
*
|
|
530
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
531
|
+
*
|
|
532
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
533
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
534
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
535
|
+
* See the License for the specific language governing permissions and
|
|
536
|
+
* limitations under the License.
|
|
537
|
+
*/
|
|
538
|
+
const tn="firebase-installations-store";let nn=null;function rn(){return nn||(nn=Ee("firebase-installations-database",1,{upgrade:(e,t)=>{if(0===t)e.createObjectStore(tn)}})),nn}async function sn(e,t){const n=Jt(e),i=(await rn()).transaction(tn,"readwrite"),r=i.objectStore(tn),s=await r.get(n);return await r.put(t,n),await i.done,s&&s.fid===t.fid||Xt(e,t.fid),t}async function an(e){const t=Jt(e),n=(await rn()).transaction(tn,"readwrite");await n.objectStore(tn).delete(t),await n.done}async function on(e,t){const n=Jt(e),i=(await rn()).transaction(tn,"readwrite"),r=i.objectStore(tn),s=await r.get(n),a=t(s);return void 0===a?await r.delete(n):await r.put(a,n),await i.done,!a||s&&s.fid===a.fid||Xt(e,a.fid),a}
|
|
539
|
+
/**
|
|
540
|
+
* @license
|
|
541
|
+
* Copyright 2019 Google LLC
|
|
542
|
+
*
|
|
543
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
544
|
+
* you may not use this file except in compliance with the License.
|
|
545
|
+
* You may obtain a copy of the License at
|
|
546
|
+
*
|
|
547
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
548
|
+
*
|
|
549
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
550
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
551
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
552
|
+
* See the License for the specific language governing permissions and
|
|
553
|
+
* limitations under the License.
|
|
554
|
+
*/async function ln(e){let t;const n=await on(e.appConfig,n=>{const i=function(e){const t=e||{fid:Yt(),registrationStatus:0};return hn(t)}(n),r=function(e,t){if(0===t.registrationStatus){if(!navigator.onLine){return{installationEntry:t,registrationPromise:Promise.reject(zt.create("app-offline"))}}const n={fid:t.fid,registrationStatus:1,registrationTime:Date.now()},i=async function(e,t){try{const n=await async function({appConfig:e,heartbeatServiceProvider:t},{fid:n}){const i=$t(e),r=Vt(e),s=t.getImmediate({optional:!0});if(s){const e=await s.getHeartbeatsHeader();e&&r.append("x-firebase-client",e)}const a={fid:n,authVersion:jt,appId:e.appId,sdkVersion:Ot},o={method:"POST",headers:r,body:JSON.stringify(a)},l=await Wt(()=>fetch(i,o));if(l.ok){const e=await l.json();return{fid:e.fid||n,registrationStatus:2,refreshToken:e.refreshToken,authToken:qt(e.authToken)}}throw await Bt("Create Installation",l)}(e,t);return sn(e.appConfig,n)}catch(n){throw Ut(n)&&409===n.customData.serverCode?await an(e.appConfig):await sn(e.appConfig,{fid:t.fid,registrationStatus:0}),n}}(e,n);return{installationEntry:n,registrationPromise:i}}return 1===t.registrationStatus?{installationEntry:t,registrationPromise:cn(e)}:{installationEntry:t}}(e,i);return t=r.registrationPromise,r.installationEntry});return""===n.fid?{installationEntry:await t}:{installationEntry:n,registrationPromise:t}}async function cn(e){let t=await un(e.appConfig);for(;1===t.registrationStatus;)await Gt(100),t=await un(e.appConfig);if(0===t.registrationStatus){const{installationEntry:t,registrationPromise:n}=await ln(e);return n||t}return t}function un(e){return on(e,e=>{if(!e)throw zt.create("installation-not-found");return hn(e)})}function hn(e){return 1===(t=e).registrationStatus&&t.registrationTime+Mt<Date.now()?{fid:e.fid,registrationStatus:0}:e;var t;
|
|
555
|
+
/**
|
|
556
|
+
* @license
|
|
557
|
+
* Copyright 2019 Google LLC
|
|
558
|
+
*
|
|
559
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
560
|
+
* you may not use this file except in compliance with the License.
|
|
561
|
+
* You may obtain a copy of the License at
|
|
562
|
+
*
|
|
563
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
564
|
+
*
|
|
565
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
566
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
567
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
568
|
+
* See the License for the specific language governing permissions and
|
|
569
|
+
* limitations under the License.
|
|
570
|
+
*/}async function dn({appConfig:e,heartbeatServiceProvider:t},n){const i=function(e,{fid:t}){return`${$t(e)}/${t}/authTokens:generate`}
|
|
571
|
+
/**
|
|
572
|
+
* @license
|
|
573
|
+
* Copyright 2019 Google LLC
|
|
574
|
+
*
|
|
575
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
576
|
+
* you may not use this file except in compliance with the License.
|
|
577
|
+
* You may obtain a copy of the License at
|
|
578
|
+
*
|
|
579
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
580
|
+
*
|
|
581
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
582
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
583
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
584
|
+
* See the License for the specific language governing permissions and
|
|
585
|
+
* limitations under the License.
|
|
586
|
+
*/(e,n),r=Ht(e,n),s=t.getImmediate({optional:!0});if(s){const e=await s.getHeartbeatsHeader();e&&r.append("x-firebase-client",e)}const a={installation:{sdkVersion:Ot,appId:e.appId}},o={method:"POST",headers:r,body:JSON.stringify(a)},l=await Wt(()=>fetch(i,o));if(l.ok){return qt(await l.json())}throw await Bt("Generate Auth Token",l)}async function pn(e,t=!1){let n;const i=await on(e.appConfig,i=>{if(!fn(i))throw zt.create("not-registered");const r=i.authToken;if(!t&&function(e){return 2===e.requestStatus&&!function(e){const t=Date.now();return t<e.creationTime||e.creationTime+e.expiresIn<t+Ft}(e)}(r))return i;if(1===r.requestStatus)return n=async function(e,t){let n=await gn(e.appConfig);for(;1===n.authToken.requestStatus;)await Gt(100),n=await gn(e.appConfig);const i=n.authToken;return 0===i.requestStatus?pn(e,t):i}(e,t),i;{if(!navigator.onLine)throw zt.create("app-offline");const t=function(e){const t={requestStatus:1,requestTime:Date.now()};return{...e,authToken:t}}(i);return n=async function(e,t){try{const n=await dn(e,t),i={...t,authToken:n};return await sn(e.appConfig,i),n}catch(n){if(!Ut(n)||401!==n.customData.serverCode&&404!==n.customData.serverCode){const n={...t,authToken:{requestStatus:0}};await sn(e.appConfig,n)}else await an(e.appConfig);throw n}}(e,t),t}});return n?await n:i.authToken}function gn(e){return on(e,e=>{if(!fn(e))throw zt.create("not-registered");const t=e.authToken;return 1===(n=t).requestStatus&&n.requestTime+Mt<Date.now()?{...e,authToken:{requestStatus:0}}:e;var n;
|
|
587
|
+
/**
|
|
588
|
+
* @license
|
|
589
|
+
* Copyright 2019 Google LLC
|
|
590
|
+
*
|
|
591
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
592
|
+
* you may not use this file except in compliance with the License.
|
|
593
|
+
* You may obtain a copy of the License at
|
|
594
|
+
*
|
|
595
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
596
|
+
*
|
|
597
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
598
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
599
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
600
|
+
* See the License for the specific language governing permissions and
|
|
601
|
+
* limitations under the License.
|
|
602
|
+
*/})}function fn(e){return void 0!==e&&2===e.registrationStatus}
|
|
603
|
+
/**
|
|
604
|
+
* @license
|
|
605
|
+
* Copyright 2019 Google LLC
|
|
606
|
+
*
|
|
607
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
608
|
+
* you may not use this file except in compliance with the License.
|
|
609
|
+
* You may obtain a copy of the License at
|
|
610
|
+
*
|
|
611
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
612
|
+
*
|
|
613
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
614
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
615
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
616
|
+
* See the License for the specific language governing permissions and
|
|
617
|
+
* limitations under the License.
|
|
618
|
+
*/
|
|
619
|
+
async function mn(e,t=!1){const n=e;await async function(e){const{registrationPromise:t}=await ln(e);t&&await t}
|
|
620
|
+
/**
|
|
621
|
+
* @license
|
|
622
|
+
* Copyright 2019 Google LLC
|
|
623
|
+
*
|
|
624
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
625
|
+
* you may not use this file except in compliance with the License.
|
|
626
|
+
* You may obtain a copy of the License at
|
|
627
|
+
*
|
|
628
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
629
|
+
*
|
|
630
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
631
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
632
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
633
|
+
* See the License for the specific language governing permissions and
|
|
634
|
+
* limitations under the License.
|
|
635
|
+
*/(n);return(await pn(n,t)).token}function vn(e){return zt.create("missing-app-config-values",{valueName:e})}
|
|
636
|
+
/**
|
|
637
|
+
* @license
|
|
638
|
+
* Copyright 2020 Google LLC
|
|
639
|
+
*
|
|
640
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
641
|
+
* you may not use this file except in compliance with the License.
|
|
642
|
+
* You may obtain a copy of the License at
|
|
643
|
+
*
|
|
644
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
645
|
+
*
|
|
646
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
647
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
648
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
649
|
+
* See the License for the specific language governing permissions and
|
|
650
|
+
* limitations under the License.
|
|
651
|
+
*/const yn="installations",wn=e=>{const t=e.getProvider("app").getImmediate(),n=function(e){if(!e||!e.options)throw vn("App Configuration");if(!e.name)throw vn("App Name");const t=["projectId","apiKey","appId"];for(const n of t)if(!e.options[n])throw vn(n);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t);return{app:t,appConfig:n,heartbeatServiceProvider:ft(t,"heartbeat"),_delete:()=>Promise.resolve()}},bn=e=>{const t=ft(e.getProvider("app").getImmediate(),yn).getImmediate();return{getId:()=>async function(e){const t=e,{installationEntry:n,registrationPromise:i}=await ln(t);return i?i.catch(console.error):pn(t).catch(console.error),n.fid}(t),getToken:e=>mn(t,e)}};gt(new se(yn,wn,"PUBLIC")),gt(new se("installations-internal",bn,"PRIVATE")),kt(Dt,At),kt(Dt,At,"esm2020");
|
|
652
|
+
/**
|
|
653
|
+
* @license
|
|
654
|
+
* Copyright 2019 Google LLC
|
|
655
|
+
*
|
|
656
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
657
|
+
* you may not use this file except in compliance with the License.
|
|
658
|
+
* You may obtain a copy of the License at
|
|
659
|
+
*
|
|
660
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
661
|
+
*
|
|
662
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
663
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
664
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
665
|
+
* See the License for the specific language governing permissions and
|
|
666
|
+
* limitations under the License.
|
|
667
|
+
*/
|
|
668
|
+
const _n="analytics",kn="https://www.googletagmanager.com/gtag/js",Cn=new ge("@firebase/analytics"),Sn=new U("analytics","Analytics",{"already-exists":"A Firebase Analytics instance with the appId {$id} already exists. Only one Firebase Analytics instance can be created for each appId.","already-initialized":"initializeAnalytics() cannot be called again with different options than those it was initially called with. It can be called again with the same options to return the existing instance, or getAnalytics() can be used to get a reference to the already-initialized instance.","already-initialized-settings":"Firebase Analytics has already been initialized.settings() must be called before initializing any Analytics instanceor it will have no effect.","interop-component-reg-failed":"Firebase Analytics Interop Component failed to instantiate: {$reason}","invalid-analytics-context":"Firebase Analytics is not supported in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","indexeddb-unavailable":"IndexedDB unavailable or restricted in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","fetch-throttle":"The config fetch request timed out while in an exponential backoff state. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.","config-fetch-failed":"Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}","no-api-key":'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid API key.',"no-app-id":'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid app ID.',"no-client-id":'The "client_id" field is empty.',"invalid-gtag-resource":"Trusted Types detected an invalid gtag resource: {$gtagURL}."});
|
|
669
|
+
/**
|
|
670
|
+
* @license
|
|
671
|
+
* Copyright 2019 Google LLC
|
|
672
|
+
*
|
|
673
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
674
|
+
* you may not use this file except in compliance with the License.
|
|
675
|
+
* You may obtain a copy of the License at
|
|
676
|
+
*
|
|
677
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
678
|
+
*
|
|
679
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
680
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
681
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
682
|
+
* See the License for the specific language governing permissions and
|
|
683
|
+
* limitations under the License.
|
|
684
|
+
*/
|
|
685
|
+
function Tn(e){if(!e.startsWith(kn)){const t=Sn.create("invalid-gtag-resource",{gtagURL:e});return Cn.warn(t.message),""}return e}function In(e){return Promise.all(e.map(e=>e.catch(e=>e)))}function En(e,t){const n=function(e,t){let n;return window.trustedTypes&&(n=window.trustedTypes.createPolicy(e,t)),n}("firebase-js-sdk-policy",{createScriptURL:Tn}),i=document.createElement("script"),r=`${kn}?l=${e}&id=${t}`;i.src=n?n?.createScriptURL(r):r,i.async=!0,document.head.appendChild(i)}function Pn(e,t,n,i){return async function(r,...s){try{if("event"===r){const[i,r]=s;await async function(e,t,n,i,r){try{let s=[];if(r&&r.send_to){let e=r.send_to;Array.isArray(e)||(e=[e]);const i=await In(n);for(const n of e){const e=i.find(e=>e.measurementId===n),r=e&&t[e.appId];if(!r){s=[];break}s.push(r)}}0===s.length&&(s=Object.values(t)),await Promise.all(s),e("event",i,r||{})}catch(e){Cn.error(e)}}(e,t,n,i,r)}else if("config"===r){const[r,a]=s;await async function(e,t,n,i,r,s){const a=i[r];try{if(a)await t[a];else{const e=(await In(n)).find(e=>e.measurementId===r);e&&await t[e.appId]}}catch(e){Cn.error(e)}e("config",r,s)}(e,t,n,i,r,a)}else if("consent"===r){const[t,n]=s;e("consent",t,n)}else if("get"===r){const[t,n,i]=s;e("get",t,n,i)}else if("set"===r){const[t]=s;e("set",t)}else e(r,...s)}catch(e){Cn.error(e)}}}const xn=new class{constructor(e={},t=1e3){this.throttleMetadata=e,this.intervalMillis=t}getThrottleMetadata(e){return this.throttleMetadata[e]}setThrottleMetadata(e,t){this.throttleMetadata[e]=t}deleteThrottleMetadata(e){delete this.throttleMetadata[e]}};function Rn(e){return new Headers({Accept:"application/json","x-goog-api-key":e})}async function Ln(e,t=xn,n){const{appId:i,apiKey:r,measurementId:s}=e.options;if(!i)throw Sn.create("no-app-id");if(!r){if(s)return{measurementId:s,appId:i};throw Sn.create("no-api-key")}const a=t.getThrottleMetadata(i)||{backoffCount:0,throttleEndTimeMillis:Date.now()},o=new Dn;return setTimeout(async()=>{o.abort()},6e4),Nn({appId:i,apiKey:r,measurementId:s},a,o,t)}async function Nn(e,{throttleEndTimeMillis:t,backoffCount:n},i,r=xn){const{appId:s,measurementId:a}=e;try{await function(e,t){return new Promise((n,i)=>{const r=Math.max(t-Date.now(),0),s=setTimeout(n,r);e.addEventListener(()=>{clearTimeout(s),i(Sn.create("fetch-throttle",{throttleEndTimeMillis:t}))})})}(i,t)}catch(e){if(a)return Cn.warn(`Timed out fetching this Firebase app's measurement ID from the server. Falling back to the measurement ID ${a} provided in the "measurementId" field in the local Firebase config. [${e?.message}]`),{appId:s,measurementId:a};throw e}try{const t=await async function(e){const{appId:t,apiKey:n}=e,i={method:"GET",headers:Rn(n)},r="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig".replace("{app-id}",t),s=await fetch(r,i);if(200!==s.status&&304!==s.status){let e="";try{const t=await s.json();t.error?.message&&(e=t.error.message)}catch(e){}throw Sn.create("config-fetch-failed",{httpStatus:s.status,responseMessage:e})}return s.json()}(e);return r.deleteThrottleMetadata(s),t}catch(t){const o=t;if(!function(e){if(!(e instanceof z&&e.customData))return!1;const t=Number(e.customData.httpStatus);return 429===t||500===t||503===t||504===t}(o)){if(r.deleteThrottleMetadata(s),a)return Cn.warn(`Failed to fetch this Firebase app's measurement ID from the server. Falling back to the measurement ID ${a} provided in the "measurementId" field in the local Firebase config. [${o?.message}]`),{appId:s,measurementId:a};throw t}const l=503===Number(o?.customData?.httpStatus)?ie(n,r.intervalMillis,30):ie(n,r.intervalMillis),c={throttleEndTimeMillis:Date.now()+l,backoffCount:n+1};return r.setThrottleMetadata(s,c),Cn.debug(`Calling attemptFetch again in ${l} millis`),Nn(e,c,i,r)}}class Dn{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}async function An(e,t,n,i,r,s,a){const o=Ln(e);o.then(t=>{n[t.measurementId]=t.appId,e.options.measurementId&&t.measurementId!==e.options.measurementId&&Cn.warn(`The measurement ID in the local Firebase config (${e.options.measurementId}) does not match the measurement ID fetched from the server (${t.measurementId}). To ensure analytics events are always sent to the correct Analytics property, update the measurement ID field in the local config or remove it from the local config.`)}).catch(e=>Cn.error(e)),t.push(o);const l=
|
|
686
|
+
/**
|
|
687
|
+
* @license
|
|
688
|
+
* Copyright 2020 Google LLC
|
|
689
|
+
*
|
|
690
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
691
|
+
* you may not use this file except in compliance with the License.
|
|
692
|
+
* You may obtain a copy of the License at
|
|
693
|
+
*
|
|
694
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
695
|
+
*
|
|
696
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
697
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
698
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
699
|
+
* See the License for the specific language governing permissions and
|
|
700
|
+
* limitations under the License.
|
|
701
|
+
*/
|
|
702
|
+
async function(){if(!j())return Cn.warn(Sn.create("indexeddb-unavailable",{errorInfo:"IndexedDB is not available in this environment."}).message),!1;try{await F()}catch(e){return Cn.warn(Sn.create("indexeddb-unavailable",{errorInfo:e?.toString()}).message),!1}return!0}().then(e=>e?i.getId():void 0),[c,u]=await Promise.all([o,l]);(function(e){const t=window.document.getElementsByTagName("script");for(const n of Object.values(t))if(n.src&&n.src.includes(kn)&&n.src.includes(e))return n;return null}
|
|
703
|
+
/**
|
|
704
|
+
* @license
|
|
705
|
+
* Copyright 2020 Google LLC
|
|
706
|
+
*
|
|
707
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
708
|
+
* you may not use this file except in compliance with the License.
|
|
709
|
+
* You may obtain a copy of the License at
|
|
710
|
+
*
|
|
711
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
712
|
+
*
|
|
713
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
714
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
715
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
716
|
+
* See the License for the specific language governing permissions and
|
|
717
|
+
* limitations under the License.
|
|
718
|
+
*/)(s)||En(s,c.measurementId),r("js",new Date);const h=a?.config??{};return h.origin="firebase",h.update=!0,null!=u&&(h.firebase_id=u),r("config",c.measurementId,h),c.measurementId}
|
|
719
|
+
/**
|
|
720
|
+
* @license
|
|
721
|
+
* Copyright 2019 Google LLC
|
|
722
|
+
*
|
|
723
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
724
|
+
* you may not use this file except in compliance with the License.
|
|
725
|
+
* You may obtain a copy of the License at
|
|
726
|
+
*
|
|
727
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
728
|
+
*
|
|
729
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
730
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
731
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
732
|
+
* See the License for the specific language governing permissions and
|
|
733
|
+
* limitations under the License.
|
|
734
|
+
*/class Mn{constructor(e){this.app=e}_delete(){return delete On[this.app.options.appId],Promise.resolve()}}let On={},jn=[];const Fn={};let zn,Un,$n="dataLayer",qn=!1;function Bn(){const e=[];if(M()&&e.push("This is a browser extension environment."),"undefined"!=typeof navigator&&navigator.cookieEnabled||e.push("Cookies are not available."),e.length>0){const t=e.map((e,t)=>`(${t+1}) ${e}`).join(" "),n=Sn.create("invalid-analytics-context",{errorInfo:t});Cn.warn(n.message)}}function Vn(e,t,n){Bn();const i=e.options.appId;if(!i)throw Sn.create("no-app-id");if(!e.options.apiKey){if(!e.options.measurementId)throw Sn.create("no-api-key");Cn.warn(`The "apiKey" field is empty in the local Firebase config. This is needed to fetch the latest measurement ID for this Firebase app. Falling back to the measurement ID ${e.options.measurementId} provided in the "measurementId" field in the local Firebase config.`)}if(null!=On[i])throw Sn.create("already-exists",{id:i});if(!qn){!function(e){let t=[];Array.isArray(window[e])?t=window[e]:window[e]=t}($n);const{wrappedGtag:e,gtagCore:t}=function(e,t,n,i,r){let s=function(...e){window[i].push(arguments)};return window[r]&&"function"==typeof window[r]&&(s=window[r]),window[r]=Pn(s,e,t,n),{gtagCore:s,wrappedGtag:window[r]}}(On,jn,Fn,$n,"gtag");Un=e,zn=t,qn=!0}On[i]=An(e,jn,Fn,t,zn,$n,n);return new Mn(e)}function Hn(e=_t()){const t=ft(e=re(e),_n);return t.isInitialized()?t.getImmediate():function(e,t={}){const n=ft(e,_n);if(n.isInitialized()){const e=n.getImmediate();if(Y(t,n.getOptions()))return e;throw Sn.create("already-initialized")}const i=n.initialize({options:t});return i}(e)}function Wn(e,t,n){e=re(e),async function(e,t,n,i){if(i&&i.global){const t={};for(const e of Object.keys(n))t[`user_properties.${e}`]=n[e];return e("set",t),Promise.resolve()}e("config",await t,{update:!0,user_properties:n})}(Un,On[e.app.options.appId],t,n).catch(e=>Cn.error(e))}function Gn(e,t,n,i){e=re(e),async function(e,t,n,i,r){if(r&&r.global)e("event",n,i);else{const r=await t;e("event",n,{...i,send_to:r})}}(Un,On[e.app.options.appId],t,n,i).catch(e=>Cn.error(e))}const Kn="@firebase/analytics",Yn="0.10.19";gt(new se(_n,(e,{options:t})=>Vn(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),t),"PUBLIC")),gt(new se("analytics-internal",function(e){try{const t=e.getProvider(_n).getImmediate();return{logEvent:(e,n,i)=>Gn(t,e,n,i),setUserProperties:(e,n)=>Wn(t,e,n)}}catch(e){throw Sn.create("interop-component-reg-failed",{reason:e})}},"PRIVATE")),kt(Kn,Yn),kt(Kn,Yn,"esm2020");function Jn(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}
|
|
735
|
+
/**
|
|
736
|
+
* @license
|
|
737
|
+
* Copyright 2020 Google LLC
|
|
738
|
+
*
|
|
739
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
740
|
+
* you may not use this file except in compliance with the License.
|
|
741
|
+
* You may obtain a copy of the License at
|
|
742
|
+
*
|
|
743
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
744
|
+
*
|
|
745
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
746
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
747
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
748
|
+
* See the License for the specific language governing permissions and
|
|
749
|
+
* limitations under the License.
|
|
750
|
+
*/
|
|
751
|
+
kt("firebase","12.9.0","app");const Zn=Jn,Xn=new U("auth","Firebase",{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}),Qn=new ge("@firebase/auth");function ei(e,...t){Qn.logLevel<=ce.ERROR&&Qn.error(`Auth (${wt}): ${e}`,...t)}
|
|
752
|
+
/**
|
|
753
|
+
* @license
|
|
754
|
+
* Copyright 2020 Google LLC
|
|
755
|
+
*
|
|
756
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
757
|
+
* you may not use this file except in compliance with the License.
|
|
758
|
+
* You may obtain a copy of the License at
|
|
759
|
+
*
|
|
760
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
761
|
+
*
|
|
762
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
763
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
764
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
765
|
+
* See the License for the specific language governing permissions and
|
|
766
|
+
* limitations under the License.
|
|
767
|
+
*/function ti(e,...t){throw si(e,...t)}function ni(e,...t){return si(e,...t)}function ii(e,t,n){const i={...Zn(),[t]:n};return new U("auth","Firebase",i).create(t,{appName:e.name})}function ri(e){return ii(e,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function si(e,...t){if("string"!=typeof e){const n=t[0],i=[...t.slice(1)];return i[0]&&(i[0].appName=e.name),e._errorFactory.create(n,...i)}return Xn.create(e,...t)}function ai(e,t,...n){if(!e)throw si(t,...n)}function oi(e){const t="INTERNAL ASSERTION FAILED: "+e;throw ei(t),new Error(t)}function li(e,t){e||oi(t)}
|
|
768
|
+
/**
|
|
769
|
+
* @license
|
|
770
|
+
* Copyright 2020 Google LLC
|
|
771
|
+
*
|
|
772
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
773
|
+
* you may not use this file except in compliance with the License.
|
|
774
|
+
* You may obtain a copy of the License at
|
|
775
|
+
*
|
|
776
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
777
|
+
*
|
|
778
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
779
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
780
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
781
|
+
* See the License for the specific language governing permissions and
|
|
782
|
+
* limitations under the License.
|
|
783
|
+
*/function ci(){return"undefined"!=typeof self&&self.location?.href||""}function ui(){return"undefined"!=typeof self&&self.location?.protocol||null}
|
|
784
|
+
/**
|
|
785
|
+
* @license
|
|
786
|
+
* Copyright 2020 Google LLC
|
|
787
|
+
*
|
|
788
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
789
|
+
* you may not use this file except in compliance with the License.
|
|
790
|
+
* You may obtain a copy of the License at
|
|
791
|
+
*
|
|
792
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
793
|
+
*
|
|
794
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
795
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
796
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
797
|
+
* See the License for the specific language governing permissions and
|
|
798
|
+
* limitations under the License.
|
|
799
|
+
*/function hi(){return"undefined"==typeof navigator||!navigator||!("onLine"in navigator)||"boolean"!=typeof navigator.onLine||"http:"!==ui()&&"https:"!==ui()&&!M()&&!("connection"in navigator)||navigator.onLine}
|
|
800
|
+
/**
|
|
801
|
+
* @license
|
|
802
|
+
* Copyright 2020 Google LLC
|
|
803
|
+
*
|
|
804
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
805
|
+
* you may not use this file except in compliance with the License.
|
|
806
|
+
* You may obtain a copy of the License at
|
|
807
|
+
*
|
|
808
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
809
|
+
*
|
|
810
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
811
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
812
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
813
|
+
* See the License for the specific language governing permissions and
|
|
814
|
+
* limitations under the License.
|
|
815
|
+
*/
|
|
816
|
+
class di{constructor(e,t){this.shortDelay=e,this.longDelay=t,li(t>e,"Short delay should be less than long delay!"),this.isMobile=A()||O()}get(){return hi()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}
|
|
817
|
+
/**
|
|
818
|
+
* @license
|
|
819
|
+
* Copyright 2020 Google LLC
|
|
820
|
+
*
|
|
821
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
822
|
+
* you may not use this file except in compliance with the License.
|
|
823
|
+
* You may obtain a copy of the License at
|
|
824
|
+
*
|
|
825
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
826
|
+
*
|
|
827
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
828
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
829
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
830
|
+
* See the License for the specific language governing permissions and
|
|
831
|
+
* limitations under the License.
|
|
832
|
+
*/function pi(e,t){li(e.emulator,"Emulator should always be set here");const{url:n}=e.emulator;return t?`${n}${t.startsWith("/")?t.slice(1):t}`:n}
|
|
833
|
+
/**
|
|
834
|
+
* @license
|
|
835
|
+
* Copyright 2020 Google LLC
|
|
836
|
+
*
|
|
837
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
838
|
+
* you may not use this file except in compliance with the License.
|
|
839
|
+
* You may obtain a copy of the License at
|
|
840
|
+
*
|
|
841
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
842
|
+
*
|
|
843
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
844
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
845
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
846
|
+
* See the License for the specific language governing permissions and
|
|
847
|
+
* limitations under the License.
|
|
848
|
+
*/class gi{static initialize(e,t,n){this.fetchImpl=e,t&&(this.headersImpl=t),n&&(this.responseImpl=n)}static fetch(){return this.fetchImpl?this.fetchImpl:"undefined"!=typeof self&&"fetch"in self?self.fetch:"undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch:"undefined"!=typeof fetch?fetch:void oi("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){return this.headersImpl?this.headersImpl:"undefined"!=typeof self&&"Headers"in self?self.Headers:"undefined"!=typeof globalThis&&globalThis.Headers?globalThis.Headers:"undefined"!=typeof Headers?Headers:void oi("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){return this.responseImpl?this.responseImpl:"undefined"!=typeof self&&"Response"in self?self.Response:"undefined"!=typeof globalThis&&globalThis.Response?globalThis.Response:"undefined"!=typeof Response?Response:void oi("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}
|
|
849
|
+
/**
|
|
850
|
+
* @license
|
|
851
|
+
* Copyright 2020 Google LLC
|
|
852
|
+
*
|
|
853
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
854
|
+
* you may not use this file except in compliance with the License.
|
|
855
|
+
* You may obtain a copy of the License at
|
|
856
|
+
*
|
|
857
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
858
|
+
*
|
|
859
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
860
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
861
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
862
|
+
* See the License for the specific language governing permissions and
|
|
863
|
+
* limitations under the License.
|
|
864
|
+
*/const fi={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"},mi=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],vi=new di(3e4,6e4);
|
|
865
|
+
/**
|
|
866
|
+
* @license
|
|
867
|
+
* Copyright 2020 Google LLC
|
|
868
|
+
*
|
|
869
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
870
|
+
* you may not use this file except in compliance with the License.
|
|
871
|
+
* You may obtain a copy of the License at
|
|
872
|
+
*
|
|
873
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
874
|
+
*
|
|
875
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
876
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
877
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
878
|
+
* See the License for the specific language governing permissions and
|
|
879
|
+
* limitations under the License.
|
|
880
|
+
*/function yi(e,t){return e.tenantId&&!t.tenantId?{...t,tenantId:e.tenantId}:t}async function wi(e,t,n,i,r={}){return bi(e,r,async()=>{let r={},s={};i&&("GET"===t?s=i:r={body:JSON.stringify(i)});const a=Z({key:e.config.apiKey,...s}).slice(1),o=await e._getAdditionalHeaders();o["Content-Type"]="application/json",e.languageCode&&(o["X-Firebase-Locale"]=e.languageCode);const l={method:t,headers:o,...r};return"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||(l.referrerPolicy="no-referrer"),e.emulatorConfig&&P(e.emulatorConfig.host)&&(l.credentials="include"),gi.fetch()(await ki(e,e.config.apiHost,n,a),l)})}async function bi(e,t,n){e._canInitEmulator=!1;const i={...fi,...t};try{const t=new Ci(e),r=await Promise.race([n(),t.promise]);t.clearNetworkTimeout();const s=await r.json();if("needConfirmation"in s)throw Si(e,"account-exists-with-different-credential",s);if(r.ok&&!("errorMessage"in s))return s;{const t=r.ok?s.errorMessage:s.error.message,[n,a]=t.split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===n)throw Si(e,"credential-already-in-use",s);if("EMAIL_EXISTS"===n)throw Si(e,"email-already-in-use",s);if("USER_DISABLED"===n)throw Si(e,"user-disabled",s);const o=i[n]||n.toLowerCase().replace(/[_\s]+/g,"-");if(a)throw ii(e,o,a);ti(e,o)}}catch(t){if(t instanceof z)throw t;ti(e,"network-request-failed",{message:String(t)})}}async function _i(e,t,n,i,r={}){const s=await wi(e,t,n,i,r);return"mfaPendingCredential"in s&&ti(e,"multi-factor-auth-required",{_serverResponse:s}),s}async function ki(e,t,n,i){const r=`${t}${n}?${i}`,s=e,a=s.config.emulator?pi(e.config,r):`${e.config.apiScheme}://${r}`;if(mi.includes(n)&&(await s._persistenceManagerAvailable,"COOKIE"===s._getPersistenceType())){return s._getPersistence()._getFinalTarget(a).toString()}return a}class Ci{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>{this.timer=setTimeout(()=>t(ni(this.auth,"network-request-failed")),vi.get())})}}function Si(e,t,n){const i={appName:e.name};n.email&&(i.email=n.email),n.phoneNumber&&(i.phoneNumber=n.phoneNumber);const r=ni(e,t,i);return r.customData._tokenResponse=n,r}
|
|
881
|
+
/**
|
|
882
|
+
* @license
|
|
883
|
+
* Copyright 2020 Google LLC
|
|
884
|
+
*
|
|
885
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
886
|
+
* you may not use this file except in compliance with the License.
|
|
887
|
+
* You may obtain a copy of the License at
|
|
888
|
+
*
|
|
889
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
890
|
+
*
|
|
891
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
892
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
893
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
894
|
+
* See the License for the specific language governing permissions and
|
|
895
|
+
* limitations under the License.
|
|
896
|
+
*/async function Ti(e,t){return wi(e,"POST","/v1/accounts:lookup",t)}
|
|
897
|
+
/**
|
|
898
|
+
* @license
|
|
899
|
+
* Copyright 2020 Google LLC
|
|
900
|
+
*
|
|
901
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
902
|
+
* you may not use this file except in compliance with the License.
|
|
903
|
+
* You may obtain a copy of the License at
|
|
904
|
+
*
|
|
905
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
906
|
+
*
|
|
907
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
908
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
909
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
910
|
+
* See the License for the specific language governing permissions and
|
|
911
|
+
* limitations under the License.
|
|
912
|
+
*/function Ii(e){if(e)try{const t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch(e){}}function Ei(e){return 1e3*Number(e)}function Pi(e){const[t,n,i]=e.split(".");if(void 0===t||void 0===n||void 0===i)return ei("JWT malformed, contained fewer than 3 sections"),null;try{const e=y(n);return e?JSON.parse(e):(ei("Failed to decode base64 JWT payload"),null)}catch(e){return ei("Caught error parsing JWT payload as JSON",e?.toString()),null}}function xi(e){const t=Pi(e);return ai(t,"internal-error"),ai(void 0!==t.exp,"internal-error"),ai(void 0!==t.iat,"internal-error"),Number(t.exp)-Number(t.iat)}
|
|
913
|
+
/**
|
|
914
|
+
* @license
|
|
915
|
+
* Copyright 2020 Google LLC
|
|
916
|
+
*
|
|
917
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
918
|
+
* you may not use this file except in compliance with the License.
|
|
919
|
+
* You may obtain a copy of the License at
|
|
920
|
+
*
|
|
921
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
922
|
+
*
|
|
923
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
924
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
925
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
926
|
+
* See the License for the specific language governing permissions and
|
|
927
|
+
* limitations under the License.
|
|
928
|
+
*/async function Ri(e,t,n=!1){if(n)return t;try{return await t}catch(t){throw t instanceof z&&function({code:e}){return"auth/user-disabled"===e||"auth/user-token-expired"===e}
|
|
929
|
+
/**
|
|
930
|
+
* @license
|
|
931
|
+
* Copyright 2020 Google LLC
|
|
932
|
+
*
|
|
933
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
934
|
+
* you may not use this file except in compliance with the License.
|
|
935
|
+
* You may obtain a copy of the License at
|
|
936
|
+
*
|
|
937
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
938
|
+
*
|
|
939
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
940
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
941
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
942
|
+
* See the License for the specific language governing permissions and
|
|
943
|
+
* limitations under the License.
|
|
944
|
+
*/(t)&&e.auth.currentUser===e&&await e.auth.signOut(),t}}class Li{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,null!==this.timerId&&clearTimeout(this.timerId))}getInterval(e){if(e){const e=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),e}{this.errorBackoff=3e4;const e=(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5;return Math.max(0,e)}}schedule(e=!1){if(!this.isRunning)return;const t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){return void("auth/network-request-failed"===e?.code&&this.schedule(!0))}this.schedule()}}
|
|
945
|
+
/**
|
|
946
|
+
* @license
|
|
947
|
+
* Copyright 2020 Google LLC
|
|
948
|
+
*
|
|
949
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
950
|
+
* you may not use this file except in compliance with the License.
|
|
951
|
+
* You may obtain a copy of the License at
|
|
952
|
+
*
|
|
953
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
954
|
+
*
|
|
955
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
956
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
957
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
958
|
+
* See the License for the specific language governing permissions and
|
|
959
|
+
* limitations under the License.
|
|
960
|
+
*/class Ni{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=Ii(this.lastLoginAt),this.creationTime=Ii(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}
|
|
961
|
+
/**
|
|
962
|
+
* @license
|
|
963
|
+
* Copyright 2019 Google LLC
|
|
964
|
+
*
|
|
965
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
966
|
+
* you may not use this file except in compliance with the License.
|
|
967
|
+
* You may obtain a copy of the License at
|
|
968
|
+
*
|
|
969
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
970
|
+
*
|
|
971
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
972
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
973
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
974
|
+
* See the License for the specific language governing permissions and
|
|
975
|
+
* limitations under the License.
|
|
976
|
+
*/async function Di(e){const t=e.auth,n=await e.getIdToken(),i=await Ri(e,Ti(t,{idToken:n}));ai(i?.users.length,t,"internal-error");const r=i.users[0];e._notifyReloadListener(r);const s=r.providerUserInfo?.length?Ai(r.providerUserInfo):[],a=(o=e.providerData,l=s,[...o.filter(e=>!l.some(t=>t.providerId===e.providerId)),...l]);var o,l;const c=e.isAnonymous,u=!(e.email&&r.passwordHash||a?.length),h=!!c&&u,d={uid:r.localId,displayName:r.displayName||null,photoURL:r.photoUrl||null,email:r.email||null,emailVerified:r.emailVerified||!1,phoneNumber:r.phoneNumber||null,tenantId:r.tenantId||null,providerData:a,metadata:new Ni(r.createdAt,r.lastLoginAt),isAnonymous:h};Object.assign(e,d)}function Ai(e){return e.map(({providerId:e,...t})=>({providerId:e,uid:t.rawId||"",displayName:t.displayName||null,email:t.email||null,phoneNumber:t.phoneNumber||null,photoURL:t.photoUrl||null}))}
|
|
977
|
+
/**
|
|
978
|
+
* @license
|
|
979
|
+
* Copyright 2020 Google LLC
|
|
980
|
+
*
|
|
981
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
982
|
+
* you may not use this file except in compliance with the License.
|
|
983
|
+
* You may obtain a copy of the License at
|
|
984
|
+
*
|
|
985
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
986
|
+
*
|
|
987
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
988
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
989
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
990
|
+
* See the License for the specific language governing permissions and
|
|
991
|
+
* limitations under the License.
|
|
992
|
+
*/
|
|
993
|
+
/**
|
|
994
|
+
* @license
|
|
995
|
+
* Copyright 2020 Google LLC
|
|
996
|
+
*
|
|
997
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
998
|
+
* you may not use this file except in compliance with the License.
|
|
999
|
+
* You may obtain a copy of the License at
|
|
1000
|
+
*
|
|
1001
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1002
|
+
*
|
|
1003
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1004
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1005
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1006
|
+
* See the License for the specific language governing permissions and
|
|
1007
|
+
* limitations under the License.
|
|
1008
|
+
*/
|
|
1009
|
+
class Mi{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){ai(e.idToken,"internal-error"),ai(void 0!==e.idToken,"internal-error"),ai(void 0!==e.refreshToken,"internal-error");const t="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):xi(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){ai(0!==e.length,"internal-error");const t=xi(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return t||!this.accessToken||this.isExpired?(ai(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null):this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:n,refreshToken:i,expiresIn:r}=await async function(e,t){const n=await bi(e,{},async()=>{const n=Z({grant_type:"refresh_token",refresh_token:t}).slice(1),{tokenApiHost:i,apiKey:r}=e.config,s=await ki(e,i,"/v1/token",`key=${r}`),a=await e._getAdditionalHeaders();a["Content-Type"]="application/x-www-form-urlencoded";const o={method:"POST",headers:a,body:n};return e.emulatorConfig&&P(e.emulatorConfig.host)&&(o.credentials="include"),gi.fetch()(s,o)});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}(e,t);this.updateTokensAndExpiration(n,i,Number(r))}updateTokensAndExpiration(e,t,n){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+1e3*n}static fromJSON(e,t){const{refreshToken:n,accessToken:i,expirationTime:r}=t,s=new Mi;return n&&(ai("string"==typeof n,"internal-error",{appName:e}),s.refreshToken=n),i&&(ai("string"==typeof i,"internal-error",{appName:e}),s.accessToken=i),r&&(ai("number"==typeof r,"internal-error",{appName:e}),s.expirationTime=r),s}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new Mi,this.toJSON())}_performRefresh(){return oi("not implemented")}}
|
|
1010
|
+
/**
|
|
1011
|
+
* @license
|
|
1012
|
+
* Copyright 2020 Google LLC
|
|
1013
|
+
*
|
|
1014
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1015
|
+
* you may not use this file except in compliance with the License.
|
|
1016
|
+
* You may obtain a copy of the License at
|
|
1017
|
+
*
|
|
1018
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1019
|
+
*
|
|
1020
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1021
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1022
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1023
|
+
* See the License for the specific language governing permissions and
|
|
1024
|
+
* limitations under the License.
|
|
1025
|
+
*/function Oi(e,t){ai("string"==typeof e||void 0===e,"internal-error",{appName:t})}class ji{constructor({uid:e,auth:t,stsTokenManager:n,...i}){this.providerId="firebase",this.proactiveRefresh=new Li(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=t,this.stsTokenManager=n,this.accessToken=n.accessToken,this.displayName=i.displayName||null,this.email=i.email||null,this.emailVerified=i.emailVerified||!1,this.phoneNumber=i.phoneNumber||null,this.photoURL=i.photoURL||null,this.isAnonymous=i.isAnonymous||!1,this.tenantId=i.tenantId||null,this.providerData=i.providerData?[...i.providerData]:[],this.metadata=new Ni(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(e){const t=await Ri(this,this.stsTokenManager.getToken(this.auth,e));return ai(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return async function(e,t=!1){const n=re(e),i=await n.getIdToken(t),r=Pi(i);ai(r&&r.exp&&r.auth_time&&r.iat,n.auth,"internal-error");const s="object"==typeof r.firebase?r.firebase:void 0,a=s?.sign_in_provider;return{claims:r,token:i,authTime:Ii(Ei(r.auth_time)),issuedAtTime:Ii(Ei(r.iat)),expirationTime:Ii(Ei(r.exp)),signInProvider:a||null,signInSecondFactor:s?.sign_in_second_factor||null}}(this,e)}reload(){return async function(e){const t=re(e);await Di(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}(this)}_assign(e){this!==e&&(ai(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(e=>({...e})),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new ji({...this,auth:e,stsTokenManager:this.stsTokenManager._clone()});return t.metadata._copy(this.metadata),t}_onReload(e){ai(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let n=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),n=!0),t&&await Di(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(mt(this.auth.app))return Promise.reject(ri(this.auth));const e=await this.getIdToken();return await Ri(this,async function(e,t){return wi(e,"POST","/v1/accounts:delete",t)}(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return{uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>({...e})),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId,...this.metadata.toJSON(),apiKey:this.auth.config.apiKey,appName:this.auth.name}}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){const n=t.displayName??void 0,i=t.email??void 0,r=t.phoneNumber??void 0,s=t.photoURL??void 0,a=t.tenantId??void 0,o=t._redirectEventId??void 0,l=t.createdAt??void 0,c=t.lastLoginAt??void 0,{uid:u,emailVerified:h,isAnonymous:d,providerData:p,stsTokenManager:g}=t;ai(u&&g,e,"internal-error");const f=Mi.fromJSON(this.name,g);ai("string"==typeof u,e,"internal-error"),Oi(n,e.name),Oi(i,e.name),ai("boolean"==typeof h,e,"internal-error"),ai("boolean"==typeof d,e,"internal-error"),Oi(r,e.name),Oi(s,e.name),Oi(a,e.name),Oi(o,e.name),Oi(l,e.name),Oi(c,e.name);const m=new ji({uid:u,auth:e,email:i,emailVerified:h,displayName:n,isAnonymous:d,photoURL:s,phoneNumber:r,tenantId:a,stsTokenManager:f,createdAt:l,lastLoginAt:c});return p&&Array.isArray(p)&&(m.providerData=p.map(e=>({...e}))),o&&(m._redirectEventId=o),m}static async _fromIdTokenResponse(e,t,n=!1){const i=new Mi;i.updateFromServerResponse(t);const r=new ji({uid:t.localId,auth:e,stsTokenManager:i,isAnonymous:n});return await Di(r),r}static async _fromGetAccountInfoResponse(e,t,n){const i=t.users[0];ai(void 0!==i.localId,"internal-error");const r=void 0!==i.providerUserInfo?Ai(i.providerUserInfo):[],s=!(i.email&&i.passwordHash||r?.length),a=new Mi;a.updateFromIdToken(n);const o=new ji({uid:i.localId,auth:e,stsTokenManager:a,isAnonymous:s}),l={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:r,metadata:new Ni(i.createdAt,i.lastLoginAt),isAnonymous:!(i.email&&i.passwordHash||r?.length)};return Object.assign(o,l),o}}
|
|
1026
|
+
/**
|
|
1027
|
+
* @license
|
|
1028
|
+
* Copyright 2020 Google LLC
|
|
1029
|
+
*
|
|
1030
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1031
|
+
* you may not use this file except in compliance with the License.
|
|
1032
|
+
* You may obtain a copy of the License at
|
|
1033
|
+
*
|
|
1034
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1035
|
+
*
|
|
1036
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1037
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1038
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1039
|
+
* See the License for the specific language governing permissions and
|
|
1040
|
+
* limitations under the License.
|
|
1041
|
+
*/const Fi=new Map;function zi(e){li(e instanceof Function,"Expected a class definition");let t=Fi.get(e);return t?(li(t instanceof e,"Instance stored in cache mismatched with class"),t):(t=new e,Fi.set(e,t),t)}
|
|
1042
|
+
/**
|
|
1043
|
+
* @license
|
|
1044
|
+
* Copyright 2019 Google LLC
|
|
1045
|
+
*
|
|
1046
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1047
|
+
* you may not use this file except in compliance with the License.
|
|
1048
|
+
* You may obtain a copy of the License at
|
|
1049
|
+
*
|
|
1050
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1051
|
+
*
|
|
1052
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1053
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1054
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1055
|
+
* See the License for the specific language governing permissions and
|
|
1056
|
+
* limitations under the License.
|
|
1057
|
+
*/class Ui{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){const t=this.storage[e];return void 0===t?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}Ui.type="NONE";const $i=Ui;
|
|
1058
|
+
/**
|
|
1059
|
+
* @license
|
|
1060
|
+
* Copyright 2019 Google LLC
|
|
1061
|
+
*
|
|
1062
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1063
|
+
* you may not use this file except in compliance with the License.
|
|
1064
|
+
* You may obtain a copy of the License at
|
|
1065
|
+
*
|
|
1066
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1067
|
+
*
|
|
1068
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1069
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1070
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1071
|
+
* See the License for the specific language governing permissions and
|
|
1072
|
+
* limitations under the License.
|
|
1073
|
+
*/function qi(e,t,n){return`firebase:${e}:${t}:${n}`}class Bi{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;const{config:i,name:r}=this.auth;this.fullUserKey=qi(this.userKey,i.apiKey,r),this.fullPersistenceKey=qi("persistence",i.apiKey,r),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);if(!e)return null;if("string"==typeof e){const t=await Ti(this.auth,{idToken:e}).catch(()=>{});return t?ji._fromGetAccountInfoResponse(this.auth,t,e):null}return ji._fromJSON(this.auth,e)}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const t=await this.getCurrentUser();return await this.removeCurrentUser(),this.persistence=e,t?this.setCurrentUser(t):void 0}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,n="authUser"){if(!t.length)return new Bi(zi($i),e,n);const i=(await Promise.all(t.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e);let r=i[0]||zi($i);const s=qi(n,e.config.apiKey,e.name);let a=null;for(const n of t)try{const t=await n._get(s);if(t){let i;if("string"==typeof t){const n=await Ti(e,{idToken:t}).catch(()=>{});if(!n)break;i=await ji._fromGetAccountInfoResponse(e,n,t)}else i=ji._fromJSON(e,t);n!==r&&(a=i),r=n;break}}catch{}const o=i.filter(e=>e._shouldAllowMigration);return r._shouldAllowMigration&&o.length?(r=o[0],a&&await r._set(s,a.toJSON()),await Promise.all(t.map(async e=>{if(e!==r)try{await e._remove(s)}catch{}})),new Bi(r,e,n)):new Bi(r,e,n)}}
|
|
1074
|
+
/**
|
|
1075
|
+
* @license
|
|
1076
|
+
* Copyright 2020 Google LLC
|
|
1077
|
+
*
|
|
1078
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1079
|
+
* you may not use this file except in compliance with the License.
|
|
1080
|
+
* You may obtain a copy of the License at
|
|
1081
|
+
*
|
|
1082
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1083
|
+
*
|
|
1084
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1085
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1086
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1087
|
+
* See the License for the specific language governing permissions and
|
|
1088
|
+
* limitations under the License.
|
|
1089
|
+
*/function Vi(e){const t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";if(Ki(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(Hi(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(Ji(t))return"Blackberry";if(Zi(t))return"Webos";if(Wi(t))return"Safari";if((t.includes("chrome/")||Gi(t))&&!t.includes("edge/"))return"Chrome";if(Yi(t))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,n=e.match(t);if(2===n?.length)return n[1]}return"Other"}function Hi(e=D()){return/firefox\//i.test(e)}function Wi(e=D()){const t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function Gi(e=D()){return/crios\//i.test(e)}function Ki(e=D()){return/iemobile/i.test(e)}function Yi(e=D()){return/android/i.test(e)}function Ji(e=D()){return/blackberry/i.test(e)}function Zi(e=D()){return/webos/i.test(e)}function Xi(e=D()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function Qi(){return function(){const e=D();return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0}()&&10===document.documentMode}function er(e=D()){return Xi(e)||Yi(e)||Zi(e)||Ji(e)||/windows phone/i.test(e)||Ki(e)}
|
|
1090
|
+
/**
|
|
1091
|
+
* @license
|
|
1092
|
+
* Copyright 2020 Google LLC
|
|
1093
|
+
*
|
|
1094
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1095
|
+
* you may not use this file except in compliance with the License.
|
|
1096
|
+
* You may obtain a copy of the License at
|
|
1097
|
+
*
|
|
1098
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1099
|
+
*
|
|
1100
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1101
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1102
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1103
|
+
* See the License for the specific language governing permissions and
|
|
1104
|
+
* limitations under the License.
|
|
1105
|
+
*/function tr(e,t=[]){let n;switch(e){case"Browser":n=Vi(D());break;case"Worker":n=`${Vi(D())}-${e}`;break;default:n=e}const i=t.length?t.join(","):"FirebaseCore-web";return`${n}/JsCore/${wt}/${i}`}
|
|
1106
|
+
/**
|
|
1107
|
+
* @license
|
|
1108
|
+
* Copyright 2022 Google LLC
|
|
1109
|
+
*
|
|
1110
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1111
|
+
* you may not use this file except in compliance with the License.
|
|
1112
|
+
* You may obtain a copy of the License at
|
|
1113
|
+
*
|
|
1114
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1115
|
+
*
|
|
1116
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1117
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1118
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1119
|
+
* See the License for the specific language governing permissions and
|
|
1120
|
+
* limitations under the License.
|
|
1121
|
+
*/class nr{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const n=t=>new Promise((n,i)=>{try{n(e(t))}catch(e){i(e)}});n.onAbort=t,this.queue.push(n);const i=this.queue.length-1;return()=>{this.queue[i]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const n of this.queue)await n(e),n.onAbort&&t.push(n.onAbort)}catch(e){t.reverse();for(const e of t)try{e()}catch(e){}throw this.auth._errorFactory.create("login-blocked",{originalMessage:e?.message})}}}
|
|
1122
|
+
/**
|
|
1123
|
+
* @license
|
|
1124
|
+
* Copyright 2023 Google LLC
|
|
1125
|
+
*
|
|
1126
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1127
|
+
* you may not use this file except in compliance with the License.
|
|
1128
|
+
* You may obtain a copy of the License at
|
|
1129
|
+
*
|
|
1130
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1131
|
+
*
|
|
1132
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1133
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1134
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1135
|
+
* See the License for the specific language governing permissions and
|
|
1136
|
+
* limitations under the License.
|
|
1137
|
+
*/class ir{constructor(e){const t=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=t.minPasswordLength??6,t.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=t.maxPasswordLength),void 0!==t.containsLowercaseCharacter&&(this.customStrengthOptions.containsLowercaseLetter=t.containsLowercaseCharacter),void 0!==t.containsUppercaseCharacter&&(this.customStrengthOptions.containsUppercaseLetter=t.containsUppercaseCharacter),void 0!==t.containsNumericCharacter&&(this.customStrengthOptions.containsNumericCharacter=t.containsNumericCharacter),void 0!==t.containsNonAlphanumericCharacter&&(this.customStrengthOptions.containsNonAlphanumericCharacter=t.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,"ENFORCEMENT_STATE_UNSPECIFIED"===this.enforcementState&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=e.allowedNonAlphanumericCharacters?.join("")??"",this.forceUpgradeOnSignin=e.forceUpgradeOnSignin??!1,this.schemaVersion=e.schemaVersion}validatePassword(e){const t={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,t),this.validatePasswordCharacterOptions(e,t),t.isValid&&(t.isValid=t.meetsMinPasswordLength??!0),t.isValid&&(t.isValid=t.meetsMaxPasswordLength??!0),t.isValid&&(t.isValid=t.containsLowercaseLetter??!0),t.isValid&&(t.isValid=t.containsUppercaseLetter??!0),t.isValid&&(t.isValid=t.containsNumericCharacter??!0),t.isValid&&(t.isValid=t.containsNonAlphanumericCharacter??!0),t}validatePasswordLengthOptions(e,t){const n=this.customStrengthOptions.minPasswordLength,i=this.customStrengthOptions.maxPasswordLength;n&&(t.meetsMinPasswordLength=e.length>=n),i&&(t.meetsMaxPasswordLength=e.length<=i)}validatePasswordCharacterOptions(e,t){let n;this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);for(let i=0;i<e.length;i++)n=e.charAt(i),this.updatePasswordCharacterOptionsStatuses(t,n>="a"&&n<="z",n>="A"&&n<="Z",n>="0"&&n<="9",this.allowedNonAlphanumericCharacters.includes(n))}updatePasswordCharacterOptionsStatuses(e,t,n,i,r){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=n)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=i)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=r))}}
|
|
1138
|
+
/**
|
|
1139
|
+
* @license
|
|
1140
|
+
* Copyright 2020 Google LLC
|
|
1141
|
+
*
|
|
1142
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1143
|
+
* you may not use this file except in compliance with the License.
|
|
1144
|
+
* You may obtain a copy of the License at
|
|
1145
|
+
*
|
|
1146
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1147
|
+
*
|
|
1148
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1149
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1150
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1151
|
+
* See the License for the specific language governing permissions and
|
|
1152
|
+
* limitations under the License.
|
|
1153
|
+
*/class rr{constructor(e,t,n,i){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=n,this.config=i,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new ar(this),this.idTokenSubscription=new ar(this),this.beforeStateQueue=new nr(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=Xn,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=i.sdkClientVersion,this._persistenceManagerAvailable=new Promise(e=>this._resolvePersistenceManagerAvailable=e)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=zi(t)),this._initializationPromise=this.queue(async()=>{if(!this._deleted&&(this.persistenceManager=await Bi.create(this,e),this._resolvePersistenceManagerAvailable?.(),!this._deleted)){if(this._popupRedirectResolver?._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(e){}await this.initializeCurrentUser(t),this.lastNotifiedUid=this.currentUser?.uid||null,this._deleted||(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();return this.currentUser||e?this.currentUser&&e&&this.currentUser.uid===e.uid?(this._currentUser._assign(e),void await this.currentUser.getIdToken()):void await this._updateCurrentUser(e,!0):void 0}async initializeCurrentUserFromIdToken(e){try{const t=await Ti(this,{idToken:e}),n=await ji._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(n)}catch(e){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",e),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){if(mt(this.app)){const e=this.app.settings.authIdToken;return e?new Promise(t=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(e).then(t,t))}):this.directlySetCurrentUser(null)}const t=await this.assertedPersistence.getCurrentUser();let n=t,i=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const t=this.redirectUser?._redirectEventId,r=n?._redirectEventId,s=await this.tryRedirectSignIn(e);t&&t!==r||!s?.user||(n=s.user,i=!0)}if(!n)return this.directlySetCurrentUser(null);if(!n._redirectEventId){if(i)try{await this.beforeStateQueue.runMiddleware(n)}catch(e){n=t,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(e))}return n?this.reloadAndSetCurrentUserOrClear(n):this.directlySetCurrentUser(null)}return ai(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===n._redirectEventId?this.directlySetCurrentUser(n):this.reloadAndSetCurrentUserOrClear(n)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch(e){await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await Di(e)}catch(e){if("auth/network-request-failed"!==e?.code)return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=function(){if("undefined"==typeof navigator)return null;const e=navigator;return e.languages&&e.languages[0]||e.language||null}()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(mt(this.app))return Promise.reject(ri(this));const t=e?re(e):null;return t&&ai(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&ai(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return mt(this.app)?Promise.reject(ri(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return mt(this.app)?Promise.reject(ri(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(zi(e))})}_getRecaptchaConfig(){return null==this.tenantId?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return null===this.tenantId?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await async function(e,t={}){return wi(e,"GET","/v2/passwordPolicy",yi(e,t))}
|
|
1154
|
+
/**
|
|
1155
|
+
* @license
|
|
1156
|
+
* Copyright 2023 Google LLC
|
|
1157
|
+
*
|
|
1158
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1159
|
+
* you may not use this file except in compliance with the License.
|
|
1160
|
+
* You may obtain a copy of the License at
|
|
1161
|
+
*
|
|
1162
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1163
|
+
*
|
|
1164
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1165
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1166
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1167
|
+
* See the License for the specific language governing permissions and
|
|
1168
|
+
* limitations under the License.
|
|
1169
|
+
*/(this),t=new ir(e);null===this.tenantId?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new U("auth","Firebase",e())}onAuthStateChanged(e,t,n){return this.registerStateListener(this.authStateSubscription,e,t,n)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,n){return this.registerStateListener(this.idTokenSubscription,e,t,n)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{const n=this.onAuthStateChanged(()=>{n(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:await this.currentUser.getIdToken()};null!=this.tenantId&&(t.tenantId=this.tenantId),await async function(e,t){return wi(e,"POST","/v2/accounts:revokeToken",yi(e,t))}(this,t)}}toJSON(){return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:this._currentUser?.toJSON()}}async _setRedirectUser(e,t){const n=await this.getOrInitRedirectPersistenceManager(t);return null===e?n.removeCurrentUser():n.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&zi(e)||this._popupRedirectResolver;ai(t,this,"argument-error"),this.redirectPersistenceManager=await Bi.create(this,[zi(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){return this._isInitialized&&await this.queue(async()=>{}),this._currentUser?._redirectEventId===e?this._currentUser:this.redirectUser?._redirectEventId===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const e=this.currentUser?.uid??null;this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,n,i){if(this._deleted)return()=>{};const r="function"==typeof t?t:t.next.bind(t);let s=!1;const a=this._isInitialized?Promise.resolve():this._initializationPromise;if(ai(a,this,"internal-error"),a.then(()=>{s||r(this.currentUser)}),"function"==typeof t){const r=e.addObserver(t,n,i);return()=>{s=!0,r()}}{const n=e.addObserver(t);return()=>{s=!0,n()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return ai(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){e&&!this.frameworks.includes(e)&&(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=tr(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){const e={"X-Client-Version":this.clientVersion};this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId);const t=await(this.heartbeatServiceProvider.getImmediate({optional:!0})?.getHeartbeatsHeader());t&&(e["X-Firebase-Client"]=t);const n=await this._getAppCheckToken();return n&&(e["X-Firebase-AppCheck"]=n),e}async _getAppCheckToken(){if(mt(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=await(this.appCheckServiceProvider.getImmediate({optional:!0})?.getToken());return e?.error&&function(e,...t){Qn.logLevel<=ce.WARN&&Qn.warn(`Auth (${wt}): ${e}`,...t)}(`Error while retrieving App Check token: ${e.error}`),e?.token}}function sr(e){return re(e)}class ar{constructor(e){this.auth=e,this.observer=null,this.addObserver=function(e,t){const n=new Q(e,t);return n.subscribe.bind(n)}(e=>this.observer=e)}get next(){return ai(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}
|
|
1170
|
+
/**
|
|
1171
|
+
* @license
|
|
1172
|
+
* Copyright 2020 Google LLC
|
|
1173
|
+
*
|
|
1174
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1175
|
+
* you may not use this file except in compliance with the License.
|
|
1176
|
+
* You may obtain a copy of the License at
|
|
1177
|
+
*
|
|
1178
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1179
|
+
*
|
|
1180
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1181
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1182
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1183
|
+
* See the License for the specific language governing permissions and
|
|
1184
|
+
* limitations under the License.
|
|
1185
|
+
*/let or={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function lr(e,t,n){const i=sr(e);ai(/^https?:\/\//.test(t),i,"invalid-emulator-scheme");const r=cr(t),{host:s,port:a}=function(e){const t=cr(e),n=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length));if(!n)return{host:"",port:null};const i=n[2].split("@").pop()||"",r=/^(\[[^\]]+\])(:|$)/.exec(i);if(r){const e=r[1];return{host:e,port:ur(i.substr(e.length+1))}}{const[e,t]=i.split(":");return{host:e,port:ur(t)}}}(t),o=null===a?"":`:${a}`,l={url:`${r}//${s}${o}/`},c=Object.freeze({host:s,port:a,protocol:r.replace(":",""),options:Object.freeze({disableWarnings:!1})});if(!i._canInitEmulator)return ai(i.config.emulator&&i.emulatorConfig,i,"emulator-config-failed"),void ai(Y(l,i.config.emulator)&&Y(c,i.emulatorConfig),i,"emulator-config-failed");i.config.emulator=l,i.emulatorConfig=c,i.settings.appVerificationDisabledForTesting=!0,P(s)?(x(`${r}//${s}${o}`),N("Auth",!0)):function(){function e(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}"undefined"!=typeof console&&"function"==typeof console.info&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials.");"undefined"!=typeof window&&"undefined"!=typeof document&&("loading"===document.readyState?window.addEventListener("DOMContentLoaded",e):e())}
|
|
1186
|
+
/**
|
|
1187
|
+
* @license
|
|
1188
|
+
* Copyright 2020 Google LLC
|
|
1189
|
+
*
|
|
1190
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1191
|
+
* you may not use this file except in compliance with the License.
|
|
1192
|
+
* You may obtain a copy of the License at
|
|
1193
|
+
*
|
|
1194
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1195
|
+
*
|
|
1196
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1197
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1198
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1199
|
+
* See the License for the specific language governing permissions and
|
|
1200
|
+
* limitations under the License.
|
|
1201
|
+
*/()}function cr(e){const t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function ur(e){if(!e)return null;const t=Number(e);return isNaN(t)?null:t}class hr{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return oi("not implemented")}_getIdTokenResponse(e){return oi("not implemented")}_linkToIdToken(e,t){return oi("not implemented")}_getReauthenticationResolver(e){return oi("not implemented")}}
|
|
1202
|
+
/**
|
|
1203
|
+
* @license
|
|
1204
|
+
* Copyright 2020 Google LLC
|
|
1205
|
+
*
|
|
1206
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1207
|
+
* you may not use this file except in compliance with the License.
|
|
1208
|
+
* You may obtain a copy of the License at
|
|
1209
|
+
*
|
|
1210
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1211
|
+
*
|
|
1212
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1213
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1214
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1215
|
+
* See the License for the specific language governing permissions and
|
|
1216
|
+
* limitations under the License.
|
|
1217
|
+
*/async function dr(e,t){return _i(e,"POST","/v1/accounts:signInWithIdp",yi(e,t))}
|
|
1218
|
+
/**
|
|
1219
|
+
* @license
|
|
1220
|
+
* Copyright 2020 Google LLC
|
|
1221
|
+
*
|
|
1222
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1223
|
+
* you may not use this file except in compliance with the License.
|
|
1224
|
+
* You may obtain a copy of the License at
|
|
1225
|
+
*
|
|
1226
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1227
|
+
*
|
|
1228
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1229
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1230
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1231
|
+
* See the License for the specific language governing permissions and
|
|
1232
|
+
* limitations under the License.
|
|
1233
|
+
*/class pr extends hr{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new pr(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):ti("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const t="string"==typeof e?JSON.parse(e):e,{providerId:n,signInMethod:i,...r}=t;if(!n||!i)return null;const s=new pr(n,i);return s.idToken=r.idToken||void 0,s.accessToken=r.accessToken||void 0,s.secret=r.secret,s.nonce=r.nonce,s.pendingToken=r.pendingToken||null,s}_getIdTokenResponse(e){return dr(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,dr(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,dr(e,t)}buildRequest(){const e={requestUri:"http://localhost",returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=Z(t)}return e}}
|
|
1234
|
+
/**
|
|
1235
|
+
* @license
|
|
1236
|
+
* Copyright 2020 Google LLC
|
|
1237
|
+
*
|
|
1238
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1239
|
+
* you may not use this file except in compliance with the License.
|
|
1240
|
+
* You may obtain a copy of the License at
|
|
1241
|
+
*
|
|
1242
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1243
|
+
*
|
|
1244
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1245
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1246
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1247
|
+
* See the License for the specific language governing permissions and
|
|
1248
|
+
* limitations under the License.
|
|
1249
|
+
*/class gr{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}
|
|
1250
|
+
/**
|
|
1251
|
+
* @license
|
|
1252
|
+
* Copyright 2019 Google LLC
|
|
1253
|
+
*
|
|
1254
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1255
|
+
* you may not use this file except in compliance with the License.
|
|
1256
|
+
* You may obtain a copy of the License at
|
|
1257
|
+
*
|
|
1258
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1259
|
+
*
|
|
1260
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1261
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1262
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1263
|
+
* See the License for the specific language governing permissions and
|
|
1264
|
+
* limitations under the License.
|
|
1265
|
+
*/class fr extends gr{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}
|
|
1266
|
+
/**
|
|
1267
|
+
* @license
|
|
1268
|
+
* Copyright 2020 Google LLC
|
|
1269
|
+
*
|
|
1270
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1271
|
+
* you may not use this file except in compliance with the License.
|
|
1272
|
+
* You may obtain a copy of the License at
|
|
1273
|
+
*
|
|
1274
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1275
|
+
*
|
|
1276
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1277
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1278
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1279
|
+
* See the License for the specific language governing permissions and
|
|
1280
|
+
* limitations under the License.
|
|
1281
|
+
*/class mr extends fr{constructor(){super("facebook.com")}static credential(e){return pr._fromParams({providerId:mr.PROVIDER_ID,signInMethod:mr.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return mr.credentialFromTaggedObject(e)}static credentialFromError(e){return mr.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return mr.credential(e.oauthAccessToken)}catch{return null}}}mr.FACEBOOK_SIGN_IN_METHOD="facebook.com",mr.PROVIDER_ID="facebook.com";
|
|
1282
|
+
/**
|
|
1283
|
+
* @license
|
|
1284
|
+
* Copyright 2020 Google LLC
|
|
1285
|
+
*
|
|
1286
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1287
|
+
* you may not use this file except in compliance with the License.
|
|
1288
|
+
* You may obtain a copy of the License at
|
|
1289
|
+
*
|
|
1290
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1291
|
+
*
|
|
1292
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1293
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1294
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1295
|
+
* See the License for the specific language governing permissions and
|
|
1296
|
+
* limitations under the License.
|
|
1297
|
+
*/
|
|
1298
|
+
class vr extends fr{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return pr._fromParams({providerId:vr.PROVIDER_ID,signInMethod:vr.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return vr.credentialFromTaggedObject(e)}static credentialFromError(e){return vr.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:n}=e;if(!t&&!n)return null;try{return vr.credential(t,n)}catch{return null}}}vr.GOOGLE_SIGN_IN_METHOD="google.com",vr.PROVIDER_ID="google.com";
|
|
1299
|
+
/**
|
|
1300
|
+
* @license
|
|
1301
|
+
* Copyright 2020 Google LLC
|
|
1302
|
+
*
|
|
1303
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1304
|
+
* you may not use this file except in compliance with the License.
|
|
1305
|
+
* You may obtain a copy of the License at
|
|
1306
|
+
*
|
|
1307
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1308
|
+
*
|
|
1309
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1310
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1311
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1312
|
+
* See the License for the specific language governing permissions and
|
|
1313
|
+
* limitations under the License.
|
|
1314
|
+
*/
|
|
1315
|
+
class yr extends fr{constructor(){super("github.com")}static credential(e){return pr._fromParams({providerId:yr.PROVIDER_ID,signInMethod:yr.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return yr.credentialFromTaggedObject(e)}static credentialFromError(e){return yr.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return yr.credential(e.oauthAccessToken)}catch{return null}}}yr.GITHUB_SIGN_IN_METHOD="github.com",yr.PROVIDER_ID="github.com";
|
|
1316
|
+
/**
|
|
1317
|
+
* @license
|
|
1318
|
+
* Copyright 2020 Google LLC
|
|
1319
|
+
*
|
|
1320
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1321
|
+
* you may not use this file except in compliance with the License.
|
|
1322
|
+
* You may obtain a copy of the License at
|
|
1323
|
+
*
|
|
1324
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1325
|
+
*
|
|
1326
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1327
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1328
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1329
|
+
* See the License for the specific language governing permissions and
|
|
1330
|
+
* limitations under the License.
|
|
1331
|
+
*/
|
|
1332
|
+
class wr extends fr{constructor(){super("twitter.com")}static credential(e,t){return pr._fromParams({providerId:wr.PROVIDER_ID,signInMethod:wr.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return wr.credentialFromTaggedObject(e)}static credentialFromError(e){return wr.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:n}=e;if(!t||!n)return null;try{return wr.credential(t,n)}catch{return null}}}wr.TWITTER_SIGN_IN_METHOD="twitter.com",wr.PROVIDER_ID="twitter.com";
|
|
1333
|
+
/**
|
|
1334
|
+
* @license
|
|
1335
|
+
* Copyright 2020 Google LLC
|
|
1336
|
+
*
|
|
1337
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1338
|
+
* you may not use this file except in compliance with the License.
|
|
1339
|
+
* You may obtain a copy of the License at
|
|
1340
|
+
*
|
|
1341
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1342
|
+
*
|
|
1343
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1344
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1345
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1346
|
+
* See the License for the specific language governing permissions and
|
|
1347
|
+
* limitations under the License.
|
|
1348
|
+
*/
|
|
1349
|
+
class br{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,n,i=!1){const r=await ji._fromIdTokenResponse(e,n,i),s=_r(n);return new br({user:r,providerId:s,_tokenResponse:n,operationType:t})}static async _forOperation(e,t,n){await e._updateTokensIfNecessary(n,!0);const i=_r(n);return new br({user:e,providerId:i,_tokenResponse:n,operationType:t})}}function _r(e){return e.providerId?e.providerId:"phoneNumber"in e?"phone":null}
|
|
1350
|
+
/**
|
|
1351
|
+
* @license
|
|
1352
|
+
* Copyright 2020 Google LLC
|
|
1353
|
+
*
|
|
1354
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1355
|
+
* you may not use this file except in compliance with the License.
|
|
1356
|
+
* You may obtain a copy of the License at
|
|
1357
|
+
*
|
|
1358
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1359
|
+
*
|
|
1360
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1361
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1362
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1363
|
+
* See the License for the specific language governing permissions and
|
|
1364
|
+
* limitations under the License.
|
|
1365
|
+
*/class kr extends z{constructor(e,t,n,i){super(t.code,t.message),this.operationType=n,this.user=i,Object.setPrototypeOf(this,kr.prototype),this.customData={appName:e.name,tenantId:e.tenantId??void 0,_serverResponse:t.customData._serverResponse,operationType:n}}static _fromErrorAndOperation(e,t,n,i){return new kr(e,t,n,i)}}function Cr(e,t,n,i){return("reauthenticate"===t?n._getReauthenticationResolver(e):n._getIdTokenResponse(e)).catch(n=>{if("auth/multi-factor-auth-required"===n.code)throw kr._fromErrorAndOperation(e,n,t,i);throw n})}
|
|
1366
|
+
/**
|
|
1367
|
+
* @license
|
|
1368
|
+
* Copyright 2020 Google LLC
|
|
1369
|
+
*
|
|
1370
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1371
|
+
* you may not use this file except in compliance with the License.
|
|
1372
|
+
* You may obtain a copy of the License at
|
|
1373
|
+
*
|
|
1374
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1375
|
+
*
|
|
1376
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1377
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1378
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1379
|
+
* See the License for the specific language governing permissions and
|
|
1380
|
+
* limitations under the License.
|
|
1381
|
+
*/
|
|
1382
|
+
async function Sr(e,t){if(mt(e.app))return Promise.reject(ri(e));const n=sr(e),i=
|
|
1383
|
+
/**
|
|
1384
|
+
* @license
|
|
1385
|
+
* Copyright 2020 Google LLC
|
|
1386
|
+
*
|
|
1387
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1388
|
+
* you may not use this file except in compliance with the License.
|
|
1389
|
+
* You may obtain a copy of the License at
|
|
1390
|
+
*
|
|
1391
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1392
|
+
*
|
|
1393
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1394
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1395
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1396
|
+
* See the License for the specific language governing permissions and
|
|
1397
|
+
* limitations under the License.
|
|
1398
|
+
*/await async function(e,t){return _i(e,"POST","/v1/accounts:signInWithCustomToken",yi(e,t))}(n,{token:t,returnSecureToken:!0}),r=await br._fromIdTokenResponse(n,"signIn",i);return await n._updateCurrentUser(r.user),r}const Tr="__sak";
|
|
1399
|
+
/**
|
|
1400
|
+
* @license
|
|
1401
|
+
* Copyright 2019 Google LLC
|
|
1402
|
+
*
|
|
1403
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1404
|
+
* you may not use this file except in compliance with the License.
|
|
1405
|
+
* You may obtain a copy of the License at
|
|
1406
|
+
*
|
|
1407
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1408
|
+
*
|
|
1409
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1410
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1411
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1412
|
+
* See the License for the specific language governing permissions and
|
|
1413
|
+
* limitations under the License.
|
|
1414
|
+
*/class Ir{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Tr,"1"),this.storage.removeItem(Tr),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){const t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}
|
|
1415
|
+
/**
|
|
1416
|
+
* @license
|
|
1417
|
+
* Copyright 2020 Google LLC
|
|
1418
|
+
*
|
|
1419
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1420
|
+
* you may not use this file except in compliance with the License.
|
|
1421
|
+
* You may obtain a copy of the License at
|
|
1422
|
+
*
|
|
1423
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1424
|
+
*
|
|
1425
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1426
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1427
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1428
|
+
* See the License for the specific language governing permissions and
|
|
1429
|
+
* limitations under the License.
|
|
1430
|
+
*/class Er extends Ir{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=er(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const n=this.storage.getItem(t),i=this.localCache[t];n!==i&&e(t,i,n)}}onStorageEvent(e,t=!1){if(!e.key)return void this.forAllChangedKeys((e,t,n)=>{this.notifyListeners(e,n)});const n=e.key;t?this.detachListener():this.stopPolling();const i=()=>{const e=this.storage.getItem(n);(t||this.localCache[n]!==e)&&this.notifyListeners(n,e)},r=this.storage.getItem(n);Qi()&&r!==e.newValue&&e.newValue!==e.oldValue?setTimeout(i,10):i()}notifyListeners(e,t){this.localCache[e]=t;const n=this.listeners[e];if(n)for(const e of Array.from(n))e(t?JSON.parse(t):t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,n)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:n}),!0)})},1e3)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){0===Object.keys(this.listeners).length&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){const t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}Er.type="LOCAL";const Pr=Er;
|
|
1431
|
+
/**
|
|
1432
|
+
* @license
|
|
1433
|
+
* Copyright 2020 Google LLC
|
|
1434
|
+
*
|
|
1435
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1436
|
+
* you may not use this file except in compliance with the License.
|
|
1437
|
+
* You may obtain a copy of the License at
|
|
1438
|
+
*
|
|
1439
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1440
|
+
*
|
|
1441
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1442
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1443
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1444
|
+
* See the License for the specific language governing permissions and
|
|
1445
|
+
* limitations under the License.
|
|
1446
|
+
*/class xr extends Ir{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}xr.type="SESSION";const Rr=xr;
|
|
1447
|
+
/**
|
|
1448
|
+
* @license
|
|
1449
|
+
* Copyright 2019 Google LLC
|
|
1450
|
+
*
|
|
1451
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1452
|
+
* you may not use this file except in compliance with the License.
|
|
1453
|
+
* You may obtain a copy of the License at
|
|
1454
|
+
*
|
|
1455
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1456
|
+
*
|
|
1457
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1458
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1459
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1460
|
+
* See the License for the specific language governing permissions and
|
|
1461
|
+
* limitations under the License.
|
|
1462
|
+
*/
|
|
1463
|
+
/**
|
|
1464
|
+
* @license
|
|
1465
|
+
* Copyright 2019 Google LLC
|
|
1466
|
+
*
|
|
1467
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1468
|
+
* you may not use this file except in compliance with the License.
|
|
1469
|
+
* You may obtain a copy of the License at
|
|
1470
|
+
*
|
|
1471
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1472
|
+
*
|
|
1473
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1474
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1475
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1476
|
+
* See the License for the specific language governing permissions and
|
|
1477
|
+
* limitations under the License.
|
|
1478
|
+
*/
|
|
1479
|
+
class Lr{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find(t=>t.isListeningto(e));if(t)return t;const n=new Lr(e);return this.receivers.push(n),n}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:n,eventType:i,data:r}=t.data,s=this.handlersMap[i];if(!s?.size)return;t.ports[0].postMessage({status:"ack",eventId:n,eventType:i});const a=Array.from(s).map(async e=>e(t.origin,r)),o=await function(e){return Promise.all(e.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(e){return{fulfilled:!1,reason:e}}}))}(a);t.ports[0].postMessage({status:"done",eventId:n,eventType:i,response:o})}_subscribe(e,t){0===Object.keys(this.handlersMap).length&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),t&&0!==this.handlersMap[e].size||delete this.handlersMap[e],0===Object.keys(this.handlersMap).length&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}
|
|
1480
|
+
/**
|
|
1481
|
+
* @license
|
|
1482
|
+
* Copyright 2020 Google LLC
|
|
1483
|
+
*
|
|
1484
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1485
|
+
* you may not use this file except in compliance with the License.
|
|
1486
|
+
* You may obtain a copy of the License at
|
|
1487
|
+
*
|
|
1488
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1489
|
+
*
|
|
1490
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1491
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1492
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1493
|
+
* See the License for the specific language governing permissions and
|
|
1494
|
+
* limitations under the License.
|
|
1495
|
+
*/
|
|
1496
|
+
function Nr(e="",t=10){let n="";for(let e=0;e<t;e++)n+=Math.floor(10*Math.random());return e+n}
|
|
1497
|
+
/**
|
|
1498
|
+
* @license
|
|
1499
|
+
* Copyright 2019 Google LLC
|
|
1500
|
+
*
|
|
1501
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1502
|
+
* you may not use this file except in compliance with the License.
|
|
1503
|
+
* You may obtain a copy of the License at
|
|
1504
|
+
*
|
|
1505
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1506
|
+
*
|
|
1507
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1508
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1509
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1510
|
+
* See the License for the specific language governing permissions and
|
|
1511
|
+
* limitations under the License.
|
|
1512
|
+
*/Lr.receivers=[];class Dr{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,n=50){const i="undefined"!=typeof MessageChannel?new MessageChannel:null;if(!i)throw new Error("connection_unavailable");let r,s;return new Promise((a,o)=>{const l=Nr("",20);i.port1.start();const c=setTimeout(()=>{o(new Error("unsupported_event"))},n);s={messageChannel:i,onMessage(e){const t=e;if(t.data.eventId===l)switch(t.data.status){case"ack":clearTimeout(c),r=setTimeout(()=>{o(new Error("timeout"))},3e3);break;case"done":clearTimeout(r),a(t.data.response);break;default:clearTimeout(c),clearTimeout(r),o(new Error("invalid_response"))}}},this.handlers.add(s),i.port1.addEventListener("message",s.onMessage),this.target.postMessage({eventType:e,eventId:l,data:t},[i.port2])}).finally(()=>{s&&this.removeMessageHandler(s)})}}
|
|
1513
|
+
/**
|
|
1514
|
+
* @license
|
|
1515
|
+
* Copyright 2020 Google LLC
|
|
1516
|
+
*
|
|
1517
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1518
|
+
* you may not use this file except in compliance with the License.
|
|
1519
|
+
* You may obtain a copy of the License at
|
|
1520
|
+
*
|
|
1521
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1522
|
+
*
|
|
1523
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1524
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1525
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1526
|
+
* See the License for the specific language governing permissions and
|
|
1527
|
+
* limitations under the License.
|
|
1528
|
+
*/function Ar(){return window}
|
|
1529
|
+
/**
|
|
1530
|
+
* @license
|
|
1531
|
+
* Copyright 2020 Google LLC.
|
|
1532
|
+
*
|
|
1533
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1534
|
+
* you may not use this file except in compliance with the License.
|
|
1535
|
+
* You may obtain a copy of the License at
|
|
1536
|
+
*
|
|
1537
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1538
|
+
*
|
|
1539
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1540
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1541
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1542
|
+
* See the License for the specific language governing permissions and
|
|
1543
|
+
* limitations under the License.
|
|
1544
|
+
*/
|
|
1545
|
+
function Mr(){return void 0!==Ar().WorkerGlobalScope&&"function"==typeof Ar().importScripts}
|
|
1546
|
+
/**
|
|
1547
|
+
* @license
|
|
1548
|
+
* Copyright 2019 Google LLC
|
|
1549
|
+
*
|
|
1550
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1551
|
+
* you may not use this file except in compliance with the License.
|
|
1552
|
+
* You may obtain a copy of the License at
|
|
1553
|
+
*
|
|
1554
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1555
|
+
*
|
|
1556
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1557
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1558
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1559
|
+
* See the License for the specific language governing permissions and
|
|
1560
|
+
* limitations under the License.
|
|
1561
|
+
*/
|
|
1562
|
+
const Or="firebaseLocalStorageDb",jr="firebaseLocalStorage",Fr="fbase_key";class zr{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{t(this.request.error)})})}}function Ur(e,t){return e.transaction([jr],t?"readwrite":"readonly").objectStore(jr)}function $r(){const e=indexedDB.open(Or,1);return new Promise((t,n)=>{e.addEventListener("error",()=>{n(e.error)}),e.addEventListener("upgradeneeded",()=>{const t=e.result;try{t.createObjectStore(jr,{keyPath:Fr})}catch(e){n(e)}}),e.addEventListener("success",async()=>{const n=e.result;n.objectStoreNames.contains(jr)?t(n):(n.close(),await function(){const e=indexedDB.deleteDatabase(Or);return new zr(e).toPromise()}(),t(await $r()))})})}async function qr(e,t,n){const i=Ur(e,!0).put({[Fr]:t,value:n});return new zr(i).toPromise()}function Br(e,t){const n=Ur(e,!0).delete(t);return new zr(n).toPromise()}class Vr{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db||(this.db=await $r()),this.db}async _withRetries(e){let t=0;for(;;)try{const t=await this._openDb();return await e(t)}catch(e){if(t++>3)throw e;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Mr()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Lr._getInstance(Mr()?self:null),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){if(this.activeServiceWorker=await async function(){if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}(),!this.activeServiceWorker)return;this.sender=new Dr(this.activeServiceWorker);const e=await this.sender._send("ping",{},800);e&&e[0]?.fulfilled&&e[0]?.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(this.sender&&this.activeServiceWorker&&(navigator?.serviceWorker?.controller||null)===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await $r();return await qr(e,Tr,"1"),await Br(e,Tr),!0}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(n=>qr(n,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(t=>async function(e,t){const n=Ur(e,!1).get(t),i=await new zr(n).toPromise();return void 0===i?null:i.value}(t,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>Br(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(e=>{const t=Ur(e,!1).getAll();return new zr(t).toPromise()});if(!e)return[];if(0!==this.pendingWrites)return[];const t=[],n=new Set;if(0!==e.length)for(const{fbase_key:i,value:r}of e)n.add(i),JSON.stringify(this.localCache[i])!==JSON.stringify(r)&&(this.notifyListeners(i,r),t.push(i));for(const e of Object.keys(this.localCache))this.localCache[e]&&!n.has(e)&&(this.notifyListeners(e,null),t.push(e));return t}notifyListeners(e,t){this.localCache[e]=t;const n=this.listeners[e];if(n)for(const e of Array.from(n))e(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),800)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){0===Object.keys(this.listeners).length&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&this.stopPolling()}}Vr.type="LOCAL";const Hr=Vr;new di(3e4,6e4);
|
|
1563
|
+
/**
|
|
1564
|
+
* @license
|
|
1565
|
+
* Copyright 2019 Google LLC
|
|
1566
|
+
*
|
|
1567
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1568
|
+
* you may not use this file except in compliance with the License.
|
|
1569
|
+
* You may obtain a copy of the License at
|
|
1570
|
+
*
|
|
1571
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1572
|
+
*
|
|
1573
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1574
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1575
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1576
|
+
* See the License for the specific language governing permissions and
|
|
1577
|
+
* limitations under the License.
|
|
1578
|
+
*/
|
|
1579
|
+
class Wr extends hr{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return dr(e,this._buildIdpRequest())}_linkToIdToken(e,t){return dr(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return dr(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function Gr(e){
|
|
1580
|
+
/**
|
|
1581
|
+
* @license
|
|
1582
|
+
* Copyright 2020 Google LLC
|
|
1583
|
+
*
|
|
1584
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1585
|
+
* you may not use this file except in compliance with the License.
|
|
1586
|
+
* You may obtain a copy of the License at
|
|
1587
|
+
*
|
|
1588
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1589
|
+
*
|
|
1590
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1591
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1592
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1593
|
+
* See the License for the specific language governing permissions and
|
|
1594
|
+
* limitations under the License.
|
|
1595
|
+
*/
|
|
1596
|
+
return async function(e,t,n=!1){if(mt(e.app))return Promise.reject(ri(e));const i="signIn",r=await Cr(e,i,t),s=await br._fromIdTokenResponse(e,i,r);return n||await e._updateCurrentUser(s.user),s}(e.auth,new Wr(e),e.bypassAuthState)}function Kr(e){const{auth:t,user:n}=e;return ai(n,t,"internal-error"),
|
|
1597
|
+
/**
|
|
1598
|
+
* @license
|
|
1599
|
+
* Copyright 2019 Google LLC
|
|
1600
|
+
*
|
|
1601
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1602
|
+
* you may not use this file except in compliance with the License.
|
|
1603
|
+
* You may obtain a copy of the License at
|
|
1604
|
+
*
|
|
1605
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1606
|
+
*
|
|
1607
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1608
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1609
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1610
|
+
* See the License for the specific language governing permissions and
|
|
1611
|
+
* limitations under the License.
|
|
1612
|
+
*/
|
|
1613
|
+
async function(e,t,n=!1){const{auth:i}=e;if(mt(i.app))return Promise.reject(ri(i));const r="reauthenticate";try{const s=await Ri(e,Cr(i,r,t,e),n);ai(s.idToken,i,"internal-error");const a=Pi(s.idToken);ai(a,i,"internal-error");const{sub:o}=a;return ai(e.uid===o,i,"user-mismatch"),br._forOperation(e,r,s)}catch(e){throw"auth/user-not-found"===e?.code&&ti(i,"user-mismatch"),e}}(n,new Wr(e),e.bypassAuthState)}async function Yr(e){const{auth:t,user:n}=e;return ai(n,t,"internal-error"),async function(e,t,n=!1){const i=await Ri(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return br._forOperation(e,"link",i)}(n,new Wr(e),e.bypassAuthState)}
|
|
1614
|
+
/**
|
|
1615
|
+
* @license
|
|
1616
|
+
* Copyright 2020 Google LLC
|
|
1617
|
+
*
|
|
1618
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1619
|
+
* you may not use this file except in compliance with the License.
|
|
1620
|
+
* You may obtain a copy of the License at
|
|
1621
|
+
*
|
|
1622
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1623
|
+
*
|
|
1624
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1625
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1626
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1627
|
+
* See the License for the specific language governing permissions and
|
|
1628
|
+
* limitations under the License.
|
|
1629
|
+
*/class Jr{constructor(e,t,n,i,r=!1){this.auth=e,this.resolver=n,this.user=i,this.bypassAuthState=r,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(e){this.reject(e)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:n,postBody:i,tenantId:r,error:s,type:a}=e;if(s)return void this.reject(s);const o={auth:this.auth,requestUri:t,sessionId:n,tenantId:r||void 0,postBody:i||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(a)(o))}catch(e){this.reject(e)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return Gr;case"linkViaPopup":case"linkViaRedirect":return Yr;case"reauthViaPopup":case"reauthViaRedirect":return Kr;default:ti(this.auth,"internal-error")}}resolve(e){li(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){li(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}
|
|
1630
|
+
/**
|
|
1631
|
+
* @license
|
|
1632
|
+
* Copyright 2020 Google LLC
|
|
1633
|
+
*
|
|
1634
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1635
|
+
* you may not use this file except in compliance with the License.
|
|
1636
|
+
* You may obtain a copy of the License at
|
|
1637
|
+
*
|
|
1638
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1639
|
+
*
|
|
1640
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1641
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1642
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1643
|
+
* See the License for the specific language governing permissions and
|
|
1644
|
+
* limitations under the License.
|
|
1645
|
+
*/const Zr=new di(2e3,1e4);class Xr extends Jr{constructor(e,t,n,i,r){super(e,t,i,r),this.provider=n,this.authWindow=null,this.pollId=null,Xr.currentPopupAction&&Xr.currentPopupAction.cancel(),Xr.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return ai(e,this.auth,"internal-error"),e}async onExecution(){li(1===this.filter.length,"Popup operations only handle one event");const e=Nr();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(e=>{this.reject(e)}),this.resolver._isIframeWebStorageSupported(this.auth,e=>{e||this.reject(ni(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(ni(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Xr.currentPopupAction=null}pollUserCancellation(){const e=()=>{this.authWindow?.window?.closed?this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(ni(this.auth,"popup-closed-by-user"))},8e3):this.pollId=window.setTimeout(e,Zr.get())};e()}}Xr.currentPopupAction=null;
|
|
1646
|
+
/**
|
|
1647
|
+
* @license
|
|
1648
|
+
* Copyright 2020 Google LLC
|
|
1649
|
+
*
|
|
1650
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1651
|
+
* you may not use this file except in compliance with the License.
|
|
1652
|
+
* You may obtain a copy of the License at
|
|
1653
|
+
*
|
|
1654
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1655
|
+
*
|
|
1656
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1657
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1658
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1659
|
+
* See the License for the specific language governing permissions and
|
|
1660
|
+
* limitations under the License.
|
|
1661
|
+
*/
|
|
1662
|
+
const Qr="pendingRedirect",es=new Map;class ts extends Jr{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let e=es.get(this.auth._key());if(!e){try{const t=await async function(e,t){const n=function(e){return qi(Qr,e.config.apiKey,e.name)}(t),i=function(e){return zi(e._redirectPersistence)}(e);if(!await i._isAvailable())return!1;const r="true"===await i._get(n);return await i._remove(n),r}(this.resolver,this.auth),n=t?await super.execute():null;e=()=>Promise.resolve(n)}catch(t){e=()=>Promise.reject(t)}es.set(this.auth._key(),e)}return this.bypassAuthState||es.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if("signInViaRedirect"===e.type)return super.onAuthEvent(e);if("unknown"!==e.type){if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}else this.resolve(null)}async onExecution(){}cleanUp(){}}function ns(e,t){es.set(e._key(),t)}async function is(e,t,n=!1){if(mt(e.app))return Promise.reject(ri(e));const i=sr(e),r=
|
|
1663
|
+
/**
|
|
1664
|
+
* @license
|
|
1665
|
+
* Copyright 2021 Google LLC
|
|
1666
|
+
*
|
|
1667
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1668
|
+
* you may not use this file except in compliance with the License.
|
|
1669
|
+
* You may obtain a copy of the License at
|
|
1670
|
+
*
|
|
1671
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1672
|
+
*
|
|
1673
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1674
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1675
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1676
|
+
* See the License for the specific language governing permissions and
|
|
1677
|
+
* limitations under the License.
|
|
1678
|
+
*/
|
|
1679
|
+
function(e,t){return t?zi(t):(ai(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}(i,t),s=new ts(i,r,n),a=await s.execute();return a&&!n&&(delete a.user._redirectEventId,await i._persistUserIfCurrent(a.user),await i._setRedirectUser(null,t)),a}
|
|
1680
|
+
/**
|
|
1681
|
+
* @license
|
|
1682
|
+
* Copyright 2020 Google LLC
|
|
1683
|
+
*
|
|
1684
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1685
|
+
* you may not use this file except in compliance with the License.
|
|
1686
|
+
* You may obtain a copy of the License at
|
|
1687
|
+
*
|
|
1688
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1689
|
+
*
|
|
1690
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1691
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1692
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1693
|
+
* See the License for the specific language governing permissions and
|
|
1694
|
+
* limitations under the License.
|
|
1695
|
+
*/class rs{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(n=>{this.isEventForConsumer(e,n)&&(t=!0,this.sendToConsumer(e,n),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!function(e){switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return as(e);default:return!1}}
|
|
1696
|
+
/**
|
|
1697
|
+
* @license
|
|
1698
|
+
* Copyright 2020 Google LLC
|
|
1699
|
+
*
|
|
1700
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1701
|
+
* you may not use this file except in compliance with the License.
|
|
1702
|
+
* You may obtain a copy of the License at
|
|
1703
|
+
*
|
|
1704
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1705
|
+
*
|
|
1706
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1707
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1708
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1709
|
+
* See the License for the specific language governing permissions and
|
|
1710
|
+
* limitations under the License.
|
|
1711
|
+
*/(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){if(e.error&&!as(e)){const n=e.error.code?.split("auth/")[1]||"internal-error";t.onError(ni(this.auth,n))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const n=null===t.eventId||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&n}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=6e5&&this.cachedEventUids.clear(),this.cachedEventUids.has(ss(e))}saveEventToCache(e){this.cachedEventUids.add(ss(e)),this.lastProcessedEventTime=Date.now()}}function ss(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join("-")}function as({type:e,error:t}){return"unknown"===e&&"auth/no-auth-event"===t?.code}
|
|
1712
|
+
/**
|
|
1713
|
+
* @license
|
|
1714
|
+
* Copyright 2020 Google LLC
|
|
1715
|
+
*
|
|
1716
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1717
|
+
* you may not use this file except in compliance with the License.
|
|
1718
|
+
* You may obtain a copy of the License at
|
|
1719
|
+
*
|
|
1720
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1721
|
+
*
|
|
1722
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1723
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1724
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1725
|
+
* See the License for the specific language governing permissions and
|
|
1726
|
+
* limitations under the License.
|
|
1727
|
+
*/
|
|
1728
|
+
const os=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,ls=/^https?/;async function cs(e){if(e.config.emulator)return;const{authorizedDomains:t}=await async function(e,t={}){return wi(e,"GET","/v1/projects",t)}(e);for(const e of t)try{if(us(e))return}catch{}ti(e,"unauthorized-domain")}function us(e){const t=ci(),{protocol:n,hostname:i}=new URL(t);if(e.startsWith("chrome-extension://")){const r=new URL(e);return""===r.hostname&&""===i?"chrome-extension:"===n&&e.replace("chrome-extension://","")===t.replace("chrome-extension://",""):"chrome-extension:"===n&&r.hostname===i}if(!ls.test(n))return!1;if(os.test(e))return i===e;const r=e.replace(/\./g,"\\.");return new RegExp("^(.+\\."+r+"|"+r+")$","i").test(i)}
|
|
1729
|
+
/**
|
|
1730
|
+
* @license
|
|
1731
|
+
* Copyright 2020 Google LLC.
|
|
1732
|
+
*
|
|
1733
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1734
|
+
* you may not use this file except in compliance with the License.
|
|
1735
|
+
* You may obtain a copy of the License at
|
|
1736
|
+
*
|
|
1737
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1738
|
+
*
|
|
1739
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1740
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1741
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1742
|
+
* See the License for the specific language governing permissions and
|
|
1743
|
+
* limitations under the License.
|
|
1744
|
+
*/const hs=new di(3e4,6e4);function ds(){const e=Ar().___jsl;if(e?.H)for(const t of Object.keys(e.H))if(e.H[t].r=e.H[t].r||[],e.H[t].L=e.H[t].L||[],e.H[t].r=[...e.H[t].L],e.CP)for(let t=0;t<e.CP.length;t++)e.CP[t]=null}function ps(e){return new Promise((t,n)=>{function i(){ds(),gapi.load("gapi.iframes",{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{ds(),n(ni(e,"network-request-failed"))},timeout:hs.get()})}if(Ar().gapi?.iframes?.Iframe)t(gapi.iframes.getContext());else{if(!Ar().gapi?.load){const t=`__${"iframefcb"}${Math.floor(1e6*Math.random())}`;return Ar()[t]=()=>{gapi.load?i():n(ni(e,"network-request-failed"))},(r=`${or.gapiScript}?onload=${t}`,or.loadJS(r)).catch(e=>n(e))}i()}var r}).catch(e=>{throw gs=null,e})}let gs=null;
|
|
1745
|
+
/**
|
|
1746
|
+
* @license
|
|
1747
|
+
* Copyright 2020 Google LLC.
|
|
1748
|
+
*
|
|
1749
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1750
|
+
* you may not use this file except in compliance with the License.
|
|
1751
|
+
* You may obtain a copy of the License at
|
|
1752
|
+
*
|
|
1753
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1754
|
+
*
|
|
1755
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1756
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1757
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1758
|
+
* See the License for the specific language governing permissions and
|
|
1759
|
+
* limitations under the License.
|
|
1760
|
+
*/
|
|
1761
|
+
const fs=new di(5e3,15e3),ms={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},vs=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function ys(e){const t=e.config;ai(t.authDomain,e,"auth-domain-config-required");const n=t.emulator?pi(t,"emulator/auth/iframe"):`https://${e.config.authDomain}/__/auth/iframe`,i={apiKey:t.apiKey,appName:e.name,v:wt},r=vs.get(e.config.apiHost);r&&(i.eid=r);const s=e._getFrameworks();return s.length&&(i.fw=s.join(",")),`${n}?${Z(i).slice(1)}`}async function ws(e){const t=await function(e){return gs=gs||ps(e),gs}(e),n=Ar().gapi;return ai(n,e,"internal-error"),t.open({where:document.body,url:ys(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:ms,dontclear:!0},t=>new Promise(async(n,i)=>{await t.restyle({setHideOnLeave:!1});const r=ni(e,"network-request-failed"),s=Ar().setTimeout(()=>{i(r)},fs.get());function a(){Ar().clearTimeout(s),n(t)}t.ping(a).then(a,()=>{i(r)})}))}
|
|
1762
|
+
/**
|
|
1763
|
+
* @license
|
|
1764
|
+
* Copyright 2020 Google LLC.
|
|
1765
|
+
*
|
|
1766
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1767
|
+
* you may not use this file except in compliance with the License.
|
|
1768
|
+
* You may obtain a copy of the License at
|
|
1769
|
+
*
|
|
1770
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1771
|
+
*
|
|
1772
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1773
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1774
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1775
|
+
* See the License for the specific language governing permissions and
|
|
1776
|
+
* limitations under the License.
|
|
1777
|
+
*/const bs={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class _s{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}function ks(e,t,n,i=500,r=600){const s=Math.max((window.screen.availHeight-r)/2,0).toString(),a=Math.max((window.screen.availWidth-i)/2,0).toString();let o="";const l={...bs,width:i.toString(),height:r.toString(),top:s,left:a},c=D().toLowerCase();n&&(o=Gi(c)?"_blank":n),Hi(c)&&(t=t||"http://localhost",l.scrollbars="yes");const u=Object.entries(l).reduce((e,[t,n])=>`${e}${t}=${n},`,"");if(function(e=D()){return Xi(e)&&!!window.navigator?.standalone}(c)&&"_self"!==o)return function(e,t){const n=document.createElement("a");n.href=e,n.target=t;const i=document.createEvent("MouseEvent");i.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(i)}
|
|
1778
|
+
/**
|
|
1779
|
+
* @license
|
|
1780
|
+
* Copyright 2021 Google LLC
|
|
1781
|
+
*
|
|
1782
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1783
|
+
* you may not use this file except in compliance with the License.
|
|
1784
|
+
* You may obtain a copy of the License at
|
|
1785
|
+
*
|
|
1786
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1787
|
+
*
|
|
1788
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1789
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1790
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1791
|
+
* See the License for the specific language governing permissions and
|
|
1792
|
+
* limitations under the License.
|
|
1793
|
+
*/(t||"",o),new _s(null);const h=window.open(t||"",o,u);ai(h,e,"popup-blocked");try{h.focus()}catch(e){}return new _s(h)}const Cs="__/auth/handler",Ss="emulator/auth/handler",Ts=encodeURIComponent("fac");async function Is(e,t,n,i,r,s){ai(e.config.authDomain,e,"auth-domain-config-required"),ai(e.config.apiKey,e,"invalid-api-key");const a={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:i,v:wt,eventId:r};if(t instanceof gr){t.setDefaultLanguage(e.languageCode),a.providerId=t.providerId||"",G(t.getCustomParameters())||(a.customParameters=JSON.stringify(t.getCustomParameters()));for(const[e,t]of Object.entries({}))a[e]=t}if(t instanceof fr){const e=t.getScopes().filter(e=>""!==e);e.length>0&&(a.scopes=e.join(","))}e.tenantId&&(a.tid=e.tenantId);const o=a;for(const e of Object.keys(o))void 0===o[e]&&delete o[e];const l=await e._getAppCheckToken(),c=l?`#${Ts}=${encodeURIComponent(l)}`:"";return`${function({config:e}){if(!e.emulator)return`https://${e.authDomain}/${Cs}`;return pi(e,Ss)}
|
|
1794
|
+
/**
|
|
1795
|
+
* @license
|
|
1796
|
+
* Copyright 2020 Google LLC
|
|
1797
|
+
*
|
|
1798
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1799
|
+
* you may not use this file except in compliance with the License.
|
|
1800
|
+
* You may obtain a copy of the License at
|
|
1801
|
+
*
|
|
1802
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1803
|
+
*
|
|
1804
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1805
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1806
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1807
|
+
* See the License for the specific language governing permissions and
|
|
1808
|
+
* limitations under the License.
|
|
1809
|
+
*/(e)}?${Z(o).slice(1)}${c}`}const Es="webStorageSupport";const Ps=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Rr,this._completeRedirectFn=is,this._overrideRedirectResult=ns}async _openPopup(e,t,n,i){li(this.eventManagers[e._key()]?.manager,"_initialize() not called before _openPopup()");return ks(e,await Is(e,t,n,ci(),i),Nr())}async _openRedirect(e,t,n,i){await this._originValidation(e);return function(e){Ar().location.href=e}(await Is(e,t,n,ci(),i)),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:e,promise:n}=this.eventManagers[t];return e?Promise.resolve(e):(li(n,"If manager is not set, promise should be"),n)}const n=this.initAndGetManager(e);return this.eventManagers[t]={promise:n},n.catch(()=>{delete this.eventManagers[t]}),n}async initAndGetManager(e){const t=await ws(e),n=new rs(e);return t.register("authEvent",t=>{ai(t?.authEvent,e,"invalid-auth-event");return{status:n.onEvent(t.authEvent)?"ACK":"ERROR"}},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:n},this.iframes[e._key()]=t,n}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(Es,{type:Es},n=>{const i=n?.[0]?.[Es];void 0!==i&&t(!!i),ti(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=cs(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return er()||Wi()||Xi()}};var xs="@firebase/auth",Rs="1.12.0";
|
|
1810
|
+
/**
|
|
1811
|
+
* @license
|
|
1812
|
+
* Copyright 2020 Google LLC
|
|
1813
|
+
*
|
|
1814
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1815
|
+
* you may not use this file except in compliance with the License.
|
|
1816
|
+
* You may obtain a copy of the License at
|
|
1817
|
+
*
|
|
1818
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1819
|
+
*
|
|
1820
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1821
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1822
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1823
|
+
* See the License for the specific language governing permissions and
|
|
1824
|
+
* limitations under the License.
|
|
1825
|
+
*/
|
|
1826
|
+
class Ls{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){return this.assertAuthConfigured(),this.auth.currentUser?.uid||null}async getToken(e){if(this.assertAuthConfigured(),await this.auth._initializationPromise,!this.auth.currentUser)return null;return{accessToken:await this.auth.currentUser.getIdToken(e)}}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(t=>{e(t?.stsTokenManager.accessToken||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){ai(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}
|
|
1827
|
+
/**
|
|
1828
|
+
* @license
|
|
1829
|
+
* Copyright 2020 Google LLC
|
|
1830
|
+
*
|
|
1831
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1832
|
+
* you may not use this file except in compliance with the License.
|
|
1833
|
+
* You may obtain a copy of the License at
|
|
1834
|
+
*
|
|
1835
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1836
|
+
*
|
|
1837
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1838
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1839
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1840
|
+
* See the License for the specific language governing permissions and
|
|
1841
|
+
* limitations under the License.
|
|
1842
|
+
*/
|
|
1843
|
+
/**
|
|
1844
|
+
* @license
|
|
1845
|
+
* Copyright 2021 Google LLC
|
|
1846
|
+
*
|
|
1847
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1848
|
+
* you may not use this file except in compliance with the License.
|
|
1849
|
+
* You may obtain a copy of the License at
|
|
1850
|
+
*
|
|
1851
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1852
|
+
*
|
|
1853
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1854
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1855
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1856
|
+
* See the License for the specific language governing permissions and
|
|
1857
|
+
* limitations under the License.
|
|
1858
|
+
*/
|
|
1859
|
+
const Ns=I("authIdTokenMaxAge")||300;let Ds=null;function As(e=_t()){const t=ft(e,"auth");if(t.isInitialized())return t.getImmediate();const n=
|
|
1860
|
+
/**
|
|
1861
|
+
* @license
|
|
1862
|
+
* Copyright 2020 Google LLC
|
|
1863
|
+
*
|
|
1864
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1865
|
+
* you may not use this file except in compliance with the License.
|
|
1866
|
+
* You may obtain a copy of the License at
|
|
1867
|
+
*
|
|
1868
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1869
|
+
*
|
|
1870
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1871
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1872
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1873
|
+
* See the License for the specific language governing permissions and
|
|
1874
|
+
* limitations under the License.
|
|
1875
|
+
*/
|
|
1876
|
+
function(e,t){const n=ft(e,"auth");if(n.isInitialized()){const e=n.getImmediate();if(Y(n.getOptions(),t??{}))return e;ti(e,"already-initialized")}return n.initialize({options:t})}(e,{popupRedirectResolver:Ps,persistence:[Hr,Pr,Rr]}),i=I("authTokenSyncURL");if(i&&"boolean"==typeof isSecureContext&&isSecureContext){const e=new URL(i,location.origin);if(location.origin===e.origin){const t=(r=e.toString(),async e=>{const t=e&&await e.getIdTokenResult(),n=t&&((new Date).getTime()-Date.parse(t.issuedAtTime))/1e3;if(n&&n>Ns)return;const i=t?.token;Ds!==i&&(Ds=i,await fetch(r,{method:i?"POST":"DELETE",headers:i?{Authorization:`Bearer ${i}`}:{}}))});!function(e,t,n){re(e).beforeAuthStateChanged(t,n)}(n,t,()=>t(n.currentUser)),function(e,t,n,i){re(e).onIdTokenChanged(t,n,i)}(n,e=>t(e))}}var r;const s=S("auth");return s&&lr(n,`http://${s}`),n}var Ms,Os;Ms={loadJS:e=>new Promise((t,n)=>{const i=document.createElement("script");i.setAttribute("src",e),i.onload=t,i.onerror=e=>{const t=ni("internal-error");t.customData=e,n(t)},i.type="text/javascript",i.charset="UTF-8",(document.getElementsByTagName("head")?.[0]??document).appendChild(i)}),gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="},or=Ms,Os="Browser",gt(new se("auth",(e,{options:t})=>{const n=e.getProvider("app").getImmediate(),i=e.getProvider("heartbeat"),r=e.getProvider("app-check-internal"),{apiKey:s,authDomain:a}=n.options;ai(s&&!s.includes(":"),"invalid-api-key",{appName:n.name});const o={apiKey:s,authDomain:a,clientPlatform:Os,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:tr(Os)},l=new rr(n,i,r,o);return function(e,t){const n=t?.persistence||[],i=(Array.isArray(n)?n:[n]).map(zi);t?.errorMap&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(i,t?.popupRedirectResolver)}(l,t),l},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,n)=>{e.getProvider("auth-internal").initialize()})),gt(new se("auth-internal",e=>(e=>new Ls(e))(sr(e.getProvider("auth").getImmediate())),"PRIVATE").setInstantiationMode("EXPLICIT")),kt(xs,Rs,function(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}(Os)),kt(xs,Rs,"esm2020");const js="@firebase/database",Fs="1.1.0";
|
|
1877
|
+
/**
|
|
1878
|
+
* @license
|
|
1879
|
+
* Copyright 2019 Google LLC
|
|
1880
|
+
*
|
|
1881
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1882
|
+
* you may not use this file except in compliance with the License.
|
|
1883
|
+
* You may obtain a copy of the License at
|
|
1884
|
+
*
|
|
1885
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1886
|
+
*
|
|
1887
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1888
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1889
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1890
|
+
* See the License for the specific language governing permissions and
|
|
1891
|
+
* limitations under the License.
|
|
1892
|
+
*/
|
|
1893
|
+
let zs="";
|
|
1894
|
+
/**
|
|
1895
|
+
* @license
|
|
1896
|
+
* Copyright 2017 Google LLC
|
|
1897
|
+
*
|
|
1898
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1899
|
+
* you may not use this file except in compliance with the License.
|
|
1900
|
+
* You may obtain a copy of the License at
|
|
1901
|
+
*
|
|
1902
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1903
|
+
*
|
|
1904
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1905
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1906
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1907
|
+
* See the License for the specific language governing permissions and
|
|
1908
|
+
* limitations under the License.
|
|
1909
|
+
*/
|
|
1910
|
+
class Us{constructor(e){this.domStorage_=e,this.prefix_="firebase:"}set(e,t){null==t?this.domStorage_.removeItem(this.prefixedName_(e)):this.domStorage_.setItem(this.prefixedName_(e),B(t))}get(e){const t=this.domStorage_.getItem(this.prefixedName_(e));return null==t?null:q(t)}remove(e){this.domStorage_.removeItem(this.prefixedName_(e))}prefixedName_(e){return this.prefix_+e}toString(){return this.domStorage_.toString()}}
|
|
1911
|
+
/**
|
|
1912
|
+
* @license
|
|
1913
|
+
* Copyright 2017 Google LLC
|
|
1914
|
+
*
|
|
1915
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1916
|
+
* you may not use this file except in compliance with the License.
|
|
1917
|
+
* You may obtain a copy of the License at
|
|
1918
|
+
*
|
|
1919
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1920
|
+
*
|
|
1921
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1922
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1923
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1924
|
+
* See the License for the specific language governing permissions and
|
|
1925
|
+
* limitations under the License.
|
|
1926
|
+
*/class $s{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(e,t){null==t?delete this.cache_[e]:this.cache_[e]=t}get(e){return H(this.cache_,e)?this.cache_[e]:null}remove(e){delete this.cache_[e]}}
|
|
1927
|
+
/**
|
|
1928
|
+
* @license
|
|
1929
|
+
* Copyright 2017 Google LLC
|
|
1930
|
+
*
|
|
1931
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1932
|
+
* you may not use this file except in compliance with the License.
|
|
1933
|
+
* You may obtain a copy of the License at
|
|
1934
|
+
*
|
|
1935
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1936
|
+
*
|
|
1937
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1938
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1939
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1940
|
+
* See the License for the specific language governing permissions and
|
|
1941
|
+
* limitations under the License.
|
|
1942
|
+
*/const qs=function(e){try{if("undefined"!=typeof window&&void 0!==window[e]){const t=window[e];return t.setItem("firebase:sentinel","cache"),t.removeItem("firebase:sentinel"),new Us(t)}}catch(e){}return new $s},Bs=qs("localStorage"),Vs=qs("sessionStorage"),Hs=new ge("@firebase/database"),Ws=function(){let e=1;return function(){return e++}}(),Gs=function(e){const t=function(e){const t=[];let n=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);if(r>=55296&&r<=56319){const t=r-55296;i++,h(i<e.length,"Surrogate pair missing trail surrogate."),r=65536+(t<<10)+(e.charCodeAt(i)-56320)}r<128?t[n++]=r:r<2048?(t[n++]=r>>6|192,t[n++]=63&r|128):r<65536?(t[n++]=r>>12|224,t[n++]=r>>6&63|128,t[n++]=63&r|128):(t[n++]=r>>18|240,t[n++]=r>>12&63|128,t[n++]=r>>6&63|128,t[n++]=63&r|128)}return t}(e),n=new X;n.update(t);const i=n.digest();return g.encodeByteArray(i)},Ks=function(...e){let t="";for(let n=0;n<e.length;n++){const i=e[n];Array.isArray(i)||i&&"object"==typeof i&&"number"==typeof i.length?t+=Ks.apply(null,i):t+="object"==typeof i?B(i):i,t+=" "}return t};let Ys=null,Js=!0;const Zs=function(...e){if(!0===Js&&(Js=!1,null===Ys&&!0===Vs.get("logging_enabled")&&(h(!0,"Can't turn on custom loggers persistently."),Hs.logLevel=ce.VERBOSE,Ys=Hs.log.bind(Hs))),Ys){const t=Ks.apply(null,e);Ys(t)}},Xs=function(e){return function(...t){Zs(e,...t)}},Qs=function(...e){const t="FIREBASE INTERNAL ERROR: "+Ks(...e);Hs.error(t)},ea=function(...e){const t=`FIREBASE FATAL ERROR: ${Ks(...e)}`;throw Hs.error(t),new Error(t)},ta=function(...e){const t="FIREBASE WARNING: "+Ks(...e);Hs.warn(t)},na=function(e){return"number"==typeof e&&(e!=e||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY)},ia="[MIN_NAME]",ra="[MAX_NAME]",sa=function(e,t){if(e===t)return 0;if(e===ia||t===ra)return-1;if(t===ia||e===ra)return 1;{const n=pa(e),i=pa(t);return null!==n?null!==i?n-i===0?e.length-t.length:n-i:-1:null!==i?1:e<t?-1:1}},aa=function(e,t){return e===t?0:e<t?-1:1},oa=function(e,t){if(t&&e in t)return t[e];throw new Error("Missing required key ("+e+") in object: "+B(t))},la=function(e){if("object"!=typeof e||null===e)return B(e);const t=[];for(const n in e)t.push(n);t.sort();let n="{";for(let i=0;i<t.length;i++)0!==i&&(n+=","),n+=B(t[i]),n+=":",n+=la(e[t[i]]);return n+="}",n},ca=function(e,t){const n=e.length;if(n<=t)return[e];const i=[];for(let r=0;r<n;r+=t)r+t>n?i.push(e.substring(r,n)):i.push(e.substring(r,r+t));return i};function ua(e,t){for(const n in e)e.hasOwnProperty(n)&&t(n,e[n])}const ha=function(e){h(!na(e),"Invalid JSON number");const t=1023;let n,i,r,s,a;0===e?(i=0,r=0,n=1/e==-1/0?1:0):(n=e<0,(e=Math.abs(e))>=Math.pow(2,-1022)?(s=Math.min(Math.floor(Math.log(e)/Math.LN2),t),i=s+t,r=Math.round(e*Math.pow(2,52-s)-Math.pow(2,52))):(i=0,r=Math.round(e/Math.pow(2,-1074))));const o=[];for(a=52;a;a-=1)o.push(r%2?1:0),r=Math.floor(r/2);for(a=11;a;a-=1)o.push(i%2?1:0),i=Math.floor(i/2);o.push(n?1:0),o.reverse();const l=o.join("");let c="";for(a=0;a<64;a+=8){let e=parseInt(l.substr(a,8),2).toString(16);1===e.length&&(e="0"+e),c+=e}return c.toLowerCase()};const da=new RegExp("^-?(0*)\\d{1,10}$"),pa=function(e){if(da.test(e)){const t=Number(e);if(t>=-2147483648&&t<=2147483647)return t}return null},ga=function(e){try{e()}catch(e){setTimeout(()=>{const t=e.stack||"";throw ta("Exception was thrown by user callback.",t),e},Math.floor(0))}},fa=function(e,t){const n=setTimeout(e,t);return"number"==typeof n&&"undefined"!=typeof Deno&&Deno.unrefTimer?Deno.unrefTimer(n):"object"==typeof n&&n.unref&&n.unref(),n};
|
|
1943
|
+
/**
|
|
1944
|
+
* @license
|
|
1945
|
+
* Copyright 2021 Google LLC
|
|
1946
|
+
*
|
|
1947
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1948
|
+
* you may not use this file except in compliance with the License.
|
|
1949
|
+
* You may obtain a copy of the License at
|
|
1950
|
+
*
|
|
1951
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1952
|
+
*
|
|
1953
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1954
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1955
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1956
|
+
* See the License for the specific language governing permissions and
|
|
1957
|
+
* limitations under the License.
|
|
1958
|
+
*/
|
|
1959
|
+
class ma{constructor(e,t){this.appCheckProvider=t,this.appName=e.name,mt(e)&&e.settings.appCheckToken&&(this.serverAppAppCheckToken=e.settings.appCheckToken),this.appCheck=t?.getImmediate({optional:!0}),this.appCheck||t?.get().then(e=>this.appCheck=e)}getToken(e){if(this.serverAppAppCheckToken){if(e)throw new Error("Attempted reuse of `FirebaseServerApp.appCheckToken` after previous usage failed.");return Promise.resolve({token:this.serverAppAppCheckToken})}return this.appCheck?this.appCheck.getToken(e):new Promise((t,n)=>{setTimeout(()=>{this.appCheck?this.getToken(e).then(t,n):t(null)},0)})}addTokenChangeListener(e){this.appCheckProvider?.get().then(t=>t.addTokenListener(e))}notifyForInvalidToken(){ta(`Provided AppCheck credentials for the app named "${this.appName}" are invalid. This usually indicates your app was not initialized correctly.`)}}
|
|
1960
|
+
/**
|
|
1961
|
+
* @license
|
|
1962
|
+
* Copyright 2017 Google LLC
|
|
1963
|
+
*
|
|
1964
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1965
|
+
* you may not use this file except in compliance with the License.
|
|
1966
|
+
* You may obtain a copy of the License at
|
|
1967
|
+
*
|
|
1968
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1969
|
+
*
|
|
1970
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1971
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1972
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1973
|
+
* See the License for the specific language governing permissions and
|
|
1974
|
+
* limitations under the License.
|
|
1975
|
+
*/class va{constructor(e,t,n){this.appName_=e,this.firebaseOptions_=t,this.authProvider_=n,this.auth_=null,this.auth_=n.getImmediate({optional:!0}),this.auth_||n.onInit(e=>this.auth_=e)}getToken(e){return this.auth_?this.auth_.getToken(e).catch(e=>e&&"auth/token-not-initialized"===e.code?(Zs("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(e)):new Promise((t,n)=>{setTimeout(()=>{this.auth_?this.getToken(e).then(t,n):t(null)},0)})}addTokenChangeListener(e){this.auth_?this.auth_.addAuthTokenListener(e):this.authProvider_.get().then(t=>t.addAuthTokenListener(e))}removeTokenChangeListener(e){this.authProvider_.get().then(t=>t.removeAuthTokenListener(e))}notifyForInvalidToken(){let e='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?e+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?e+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':e+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',ta(e)}}class ya{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}ya.OWNER="owner";
|
|
1976
|
+
/**
|
|
1977
|
+
* @license
|
|
1978
|
+
* Copyright 2017 Google LLC
|
|
1979
|
+
*
|
|
1980
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1981
|
+
* you may not use this file except in compliance with the License.
|
|
1982
|
+
* You may obtain a copy of the License at
|
|
1983
|
+
*
|
|
1984
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1985
|
+
*
|
|
1986
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1987
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1988
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1989
|
+
* See the License for the specific language governing permissions and
|
|
1990
|
+
* limitations under the License.
|
|
1991
|
+
*/
|
|
1992
|
+
const wa=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,ba="ac",_a="websocket",ka="long_polling";
|
|
1993
|
+
/**
|
|
1994
|
+
* @license
|
|
1995
|
+
* Copyright 2017 Google LLC
|
|
1996
|
+
*
|
|
1997
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1998
|
+
* you may not use this file except in compliance with the License.
|
|
1999
|
+
* You may obtain a copy of the License at
|
|
2000
|
+
*
|
|
2001
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2002
|
+
*
|
|
2003
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2004
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2005
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2006
|
+
* See the License for the specific language governing permissions and
|
|
2007
|
+
* limitations under the License.
|
|
2008
|
+
*/
|
|
2009
|
+
class Ca{constructor(e,t,n,i,r=!1,s="",a=!1,o=!1,l=null){this.secure=t,this.namespace=n,this.webSocketOnly=i,this.nodeAdmin=r,this.persistenceKey=s,this.includeNamespaceInQueryParams=a,this.isUsingEmulator=o,this.emulatorOptions=l,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=Bs.get("host:"+e)||this._host}isCacheableHost(){return"s-"===this.internalHost.substr(0,2)}isCustomHost(){return"firebaseio.com"!==this._domain&&"firebaseio-demo.com"!==this._domain}get host(){return this._host}set host(e){e!==this.internalHost&&(this.internalHost=e,this.isCacheableHost()&&Bs.set("host:"+this._host,this.internalHost))}toString(){let e=this.toURLString();return this.persistenceKey&&(e+="<"+this.persistenceKey+">"),e}toURLString(){const e=this.secure?"https://":"http://",t=this.includeNamespaceInQueryParams?`?ns=${this.namespace}`:"";return`${e}${this.host}/${t}`}}function Sa(e,t,n){let i;if(h("string"==typeof t,"typeof type must == string"),h("object"==typeof n,"typeof params must == object"),t===_a)i=(e.secure?"wss://":"ws://")+e.internalHost+"/.ws?";else{if(t!==ka)throw new Error("Unknown connection type: "+t);i=(e.secure?"https://":"http://")+e.internalHost+"/.lp?"}(function(e){return e.host!==e.internalHost||e.isCustomHost()||e.includeNamespaceInQueryParams})(e)&&(n.ns=e.namespace);const r=[];return ua(n,(e,t)=>{r.push(e+"="+t)}),i+r.join("&")}
|
|
2010
|
+
/**
|
|
2011
|
+
* @license
|
|
2012
|
+
* Copyright 2017 Google LLC
|
|
2013
|
+
*
|
|
2014
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2015
|
+
* you may not use this file except in compliance with the License.
|
|
2016
|
+
* You may obtain a copy of the License at
|
|
2017
|
+
*
|
|
2018
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2019
|
+
*
|
|
2020
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2021
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2022
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2023
|
+
* See the License for the specific language governing permissions and
|
|
2024
|
+
* limitations under the License.
|
|
2025
|
+
*/class Ta{constructor(){this.counters_={}}incrementCounter(e,t=1){H(this.counters_,e)||(this.counters_[e]=0),this.counters_[e]+=t}get(){return w(this.counters_)}}
|
|
2026
|
+
/**
|
|
2027
|
+
* @license
|
|
2028
|
+
* Copyright 2017 Google LLC
|
|
2029
|
+
*
|
|
2030
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2031
|
+
* you may not use this file except in compliance with the License.
|
|
2032
|
+
* You may obtain a copy of the License at
|
|
2033
|
+
*
|
|
2034
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2035
|
+
*
|
|
2036
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2037
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2038
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2039
|
+
* See the License for the specific language governing permissions and
|
|
2040
|
+
* limitations under the License.
|
|
2041
|
+
*/const Ia={},Ea={};function Pa(e){const t=e.toString();return Ia[t]||(Ia[t]=new Ta),Ia[t]}
|
|
2042
|
+
/**
|
|
2043
|
+
* @license
|
|
2044
|
+
* Copyright 2017 Google LLC
|
|
2045
|
+
*
|
|
2046
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2047
|
+
* you may not use this file except in compliance with the License.
|
|
2048
|
+
* You may obtain a copy of the License at
|
|
2049
|
+
*
|
|
2050
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2051
|
+
*
|
|
2052
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2053
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2054
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2055
|
+
* See the License for the specific language governing permissions and
|
|
2056
|
+
* limitations under the License.
|
|
2057
|
+
*/
|
|
2058
|
+
class xa{constructor(e){this.onMessage_=e,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(e,t){this.closeAfterResponse=e,this.onClose=t,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)}handleResponse(e,t){for(this.pendingResponses[e]=t;this.pendingResponses[this.currentResponseNum];){const e=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let t=0;t<e.length;++t)e[t]&&ga(()=>{this.onMessage_(e[t])});if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}
|
|
2059
|
+
/**
|
|
2060
|
+
* @license
|
|
2061
|
+
* Copyright 2017 Google LLC
|
|
2062
|
+
*
|
|
2063
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2064
|
+
* you may not use this file except in compliance with the License.
|
|
2065
|
+
* You may obtain a copy of the License at
|
|
2066
|
+
*
|
|
2067
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2068
|
+
*
|
|
2069
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2070
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2071
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2072
|
+
* See the License for the specific language governing permissions and
|
|
2073
|
+
* limitations under the License.
|
|
2074
|
+
*/const Ra="start";class La{constructor(e,t,n,i,r,s,a){this.connId=e,this.repoInfo=t,this.applicationId=n,this.appCheckToken=i,this.authToken=r,this.transportSessionId=s,this.lastSessionId=a,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=Xs(e),this.stats_=Pa(t),this.urlFn=e=>(this.appCheckToken&&(e[ba]=this.appCheckToken),Sa(t,ka,e))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new xa(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null},Math.floor(3e4)),function(e){if("complete"===document.readyState)e();else{let t=!1;const n=function(){document.body?t||(t=!0,e()):setTimeout(n,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",n,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",()=>{"complete"===document.readyState&&n()}),window.attachEvent("onload",n))}}(()=>{if(this.isClosed_)return;this.scriptTagHolder=new Na((...e)=>{const[t,n,i,r,s]=e;if(this.incrementIncomingBytes_(e),this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,t===Ra)this.id=n,this.password=i;else{if("close"!==t)throw new Error("Unrecognized command received: "+t);n?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(n,()=>{this.onClosed_()})):this.onClosed_()}},(...e)=>{const[t,n]=e;this.incrementIncomingBytes_(e),this.myPacketOrderer.handleResponse(t,n)},()=>{this.onClosed_()},this.urlFn);const e={};e[Ra]="t",e.ser=Math.floor(1e8*Math.random()),this.scriptTagHolder.uniqueCallbackIdentifier&&(e.cb=this.scriptTagHolder.uniqueCallbackIdentifier),e.v="5",this.transportSessionId&&(e.s=this.transportSessionId),this.lastSessionId&&(e.ls=this.lastSessionId),this.applicationId&&(e.p=this.applicationId),this.appCheckToken&&(e[ba]=this.appCheckToken),"undefined"!=typeof location&&location.hostname&&wa.test(location.hostname)&&(e.r="f");const t=this.urlFn(e);this.log_("Connecting via long-poll to "+t),this.scriptTagHolder.addTag(t,()=>{})})}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){La.forceAllow_=!0}static forceDisallow(){La.forceDisallow_=!0}static isAvailable(){return!!La.forceAllow_||!(La.forceDisallow_||"undefined"==typeof document||null==document.createElement||"object"==typeof window&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href)||"object"==typeof Windows&&"object"==typeof Windows.UI)}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(e){const t=B(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const n=m(t),i=ca(n,1840);for(let e=0;e<i.length;e++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,i.length,i[e]),this.curSegmentNum++}addDisconnectPingFrame(e,t){this.myDisconnFrame=document.createElement("iframe");const n={dframe:"t"};n.id=e,n.pw=t,this.myDisconnFrame.src=this.urlFn(n),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(e){const t=B(e).length;this.bytesReceived+=t,this.stats_.incrementCounter("bytes_received",t)}}class Na{constructor(e,t,n,i){this.onDisconnect=n,this.urlFn=i,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(1e8*Math.random()),this.sendNewPolls=!0;{this.uniqueCallbackIdentifier=Ws(),window["pLPCommand"+this.uniqueCallbackIdentifier]=e,window["pRTLPCB"+this.uniqueCallbackIdentifier]=t,this.myIFrame=Na.createIFrame_();let n="";if(this.myIFrame.src&&"javascript:"===this.myIFrame.src.substr(0,11)){n='<script>document.domain="'+document.domain+'";<\/script>'}const i="<html><body>"+n+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(i),this.myIFrame.doc.close()}catch(e){Zs("frame writing exception"),e.stack&&Zs(e.stack),Zs(e)}}}static createIFrame_(){const e=document.createElement("iframe");if(e.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(e);try{e.contentWindow.document||Zs("No IE domain setting required")}catch(t){const n=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+n+"';document.close();})())"}return e.contentDocument?e.doc=e.contentDocument:e.contentWindow?e.doc=e.contentWindow.document:e.document&&(e.doc=e.document),e}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.textContent="",setTimeout(()=>{null!==this.myIFrame&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)},Math.floor(0)));const e=this.onDisconnect;e&&(this.onDisconnect=null,e())}startLongPoll(e,t){for(this.myID=e,this.myPW=t,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;const e={};e.id=this.myID,e.pw=this.myPW,e.ser=this.currentSerial;let t=this.urlFn(e),n="",i=0;for(;this.pendingSegs.length>0;){if(!(this.pendingSegs[0].d.length+30+n.length<=1870))break;{const e=this.pendingSegs.shift();n=n+"&seg"+i+"="+e.seg+"&ts"+i+"="+e.ts+"&d"+i+"="+e.d,i++}}return t+=n,this.addLongPollTag_(t,this.currentSerial),!0}return!1}enqueueSegment(e,t,n){this.pendingSegs.push({seg:e,ts:t,d:n}),this.alive&&this.newRequest_()}addLongPollTag_(e,t){this.outstandingRequests.add(t);const n=()=>{this.outstandingRequests.delete(t),this.newRequest_()},i=setTimeout(n,Math.floor(25e3));this.addTag(e,()=>{clearTimeout(i),n()})}addTag(e,t){setTimeout(()=>{try{if(!this.sendNewPolls)return;const n=this.myIFrame.doc.createElement("script");n.type="text/javascript",n.async=!0,n.src=e,n.onload=n.onreadystatechange=function(){const e=n.readyState;e&&"loaded"!==e&&"complete"!==e||(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),t())},n.onerror=()=>{Zs("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(n)}catch(e){}},Math.floor(1))}}
|
|
2075
|
+
/**
|
|
2076
|
+
* @license
|
|
2077
|
+
* Copyright 2017 Google LLC
|
|
2078
|
+
*
|
|
2079
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2080
|
+
* you may not use this file except in compliance with the License.
|
|
2081
|
+
* You may obtain a copy of the License at
|
|
2082
|
+
*
|
|
2083
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2084
|
+
*
|
|
2085
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2086
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2087
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2088
|
+
* See the License for the specific language governing permissions and
|
|
2089
|
+
* limitations under the License.
|
|
2090
|
+
*/let Da=null;"undefined"!=typeof MozWebSocket?Da=MozWebSocket:"undefined"!=typeof WebSocket&&(Da=WebSocket);class Aa{constructor(e,t,n,i,r,s,a){this.connId=e,this.applicationId=n,this.appCheckToken=i,this.authToken=r,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=Xs(this.connId),this.stats_=Pa(t),this.connURL=Aa.connectionURL_(t,s,a,i,n),this.nodeAdmin=t.nodeAdmin}static connectionURL_(e,t,n,i,r){const s={v:"5"};return"undefined"!=typeof location&&location.hostname&&wa.test(location.hostname)&&(s.r="f"),t&&(s.s=t),n&&(s.ls=n),i&&(s[ba]=i),r&&(s.p=r),Sa(e,_a,s)}open(e,t){this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,Bs.set("previous_websocket_failure",!0);try{let e;this.mySock=new Da(this.connURL,[],e)}catch(e){this.log_("Error instantiating WebSocket.");const t=e.message||e.data;return t&&this.log_(t),void this.onClosed_()}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=e=>{this.handleIncomingFrame(e)},this.mySock.onerror=e=>{this.log_("WebSocket error. Closing connection.");const t=e.message||e.data;t&&this.log_(t),this.onClosed_()}}start(){}static forceDisallow(){Aa.forceDisallow_=!0}static isAvailable(){let e=!1;if("undefined"!=typeof navigator&&navigator.userAgent){const t=/Android ([0-9]{0,}\.[0-9]{0,})/,n=navigator.userAgent.match(t);n&&n.length>1&&parseFloat(n[1])<4.4&&(e=!0)}return!e&&null!==Da&&!Aa.forceDisallow_}static previouslyFailed(){return Bs.isInMemoryStorage||!0===Bs.get("previous_websocket_failure")}markConnectionHealthy(){Bs.remove("previous_websocket_failure")}appendFrame_(e){if(this.frames.push(e),this.frames.length===this.totalFrames){const e=this.frames.join("");this.frames=null;const t=q(e);this.onMessage(t)}}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if(h(null===this.frames,"We already have a frame buffer"),e.length<=6){const t=Number(e);if(!isNaN(t))return this.handleNewFrameCount_(t),null}return this.handleNewFrameCount_(1),e}handleIncomingFrame(e){if(null===this.mySock)return;const t=e.data;if(this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),null!==this.frames)this.appendFrame_(t);else{const e=this.extractFrameCount_(t);null!==e&&this.appendFrame_(e)}}send(e){this.resetKeepAlive();const t=B(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const n=ca(t,16384);n.length>1&&this.sendString_(String(n.length));for(let e=0;e<n.length;e++)this.sendString_(n[e])}shutdown_(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)}onClosed_(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))}close(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())}resetKeepAlive(){clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(()=>{this.mySock&&this.sendString_("0"),this.resetKeepAlive()},Math.floor(45e3))}sendString_(e){try{this.mySock.send(e)}catch(e){this.log_("Exception thrown from WebSocket.send():",e.message||e.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}Aa.responsesRequiredToBeHealthy=2,Aa.healthyTimeout=3e4;
|
|
2091
|
+
/**
|
|
2092
|
+
* @license
|
|
2093
|
+
* Copyright 2017 Google LLC
|
|
2094
|
+
*
|
|
2095
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2096
|
+
* you may not use this file except in compliance with the License.
|
|
2097
|
+
* You may obtain a copy of the License at
|
|
2098
|
+
*
|
|
2099
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2100
|
+
*
|
|
2101
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2102
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2103
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2104
|
+
* See the License for the specific language governing permissions and
|
|
2105
|
+
* limitations under the License.
|
|
2106
|
+
*/
|
|
2107
|
+
class Ma{static get ALL_TRANSPORTS(){return[La,Aa]}static get IS_TRANSPORT_INITIALIZED(){return this.globalTransportInitialized_}constructor(e){this.initTransports_(e)}initTransports_(e){const t=Aa&&Aa.isAvailable();let n=t&&!Aa.previouslyFailed();if(e.webSocketOnly&&(t||ta("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),n=!0),n)this.transports_=[Aa];else{const e=this.transports_=[];for(const t of Ma.ALL_TRANSPORTS)t&&t.isAvailable()&&e.push(t);Ma.globalTransportInitialized_=!0}}initialTransport(){if(this.transports_.length>0)return this.transports_[0];throw new Error("No transports available")}upgradeTransport(){return this.transports_.length>1?this.transports_[1]:null}}Ma.globalTransportInitialized_=!1;class Oa{constructor(e,t,n,i,r,s,a,o,l,c){this.id=e,this.repoInfo_=t,this.applicationId_=n,this.appCheckToken_=i,this.authToken_=r,this.onMessage_=s,this.onReady_=a,this.onDisconnect_=o,this.onKill_=l,this.lastSessionId=c,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=Xs("c:"+this.id+":"),this.transportManager_=new Ma(t),this.log_("Connection created"),this.start_()}start_(){const e=this.transportManager_.initialTransport();this.conn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.conn_),n=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(()=>{this.conn_&&this.conn_.open(t,n)},Math.floor(0));const i=e.healthyTimeout||0;i>0&&(this.healthyTimeout_=fa(()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&this.conn_.bytesReceived>102400?(this.log_("Connection exceeded healthy timeout but has received "+this.conn_.bytesReceived+" bytes. Marking connection healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()):this.conn_&&this.conn_.bytesSent>10240?this.log_("Connection exceeded healthy timeout but has sent "+this.conn_.bytesSent+" bytes. Leaving connection alive."):(this.log_("Closing unhealthy connection after timeout."),this.close()))},Math.floor(i)))}nextTransportId_(){return"c:"+this.id+":"+this.connectionCount++}disconnReceiver_(e){return t=>{e===this.conn_?this.onConnectionLost_(t):e===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(e){return t=>{2!==this.state_&&(e===this.rx_?this.onPrimaryMessageReceived_(t):e===this.secondaryConn_?this.onSecondaryMessageReceived_(t):this.log_("message on old connection"))}}sendRequest(e){const t={t:"d",d:e};this.sendData_(t)}tryCleanupConnection(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)}onSecondaryControl_(e){if("t"in e){const t=e.t;"a"===t?this.upgradeIfSecondaryHealthy_():"r"===t?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&&this.rx_!==this.secondaryConn_||this.close()):"o"===t&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}}onSecondaryMessageReceived_(e){const t=oa("t",e),n=oa("d",e);if("c"===t)this.onSecondaryControl_(n);else{if("d"!==t)throw new Error("Unknown protocol layer: "+t);this.pendingDataMessages.push(n)}}upgradeIfSecondaryHealthy_(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:"p",d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:"a",d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:"n",d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(e){const t=oa("t",e),n=oa("d",e);"c"===t?this.onControl_(n):"d"===t&&this.onDataMessage_(n)}onDataMessage_(e){this.onPrimaryResponse_(),this.onMessage_(e)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(e){const t=oa("t",e);if("d"in e){const n=e.d;if("h"===t){const e={...n};this.repoInfo_.isUsingEmulator&&(e.h=this.repoInfo_.host),this.onHandshake_(e)}else if("n"===t){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let e=0;e<this.pendingDataMessages.length;++e)this.onDataMessage_(this.pendingDataMessages[e]);this.pendingDataMessages=[],this.tryCleanupConnection()}else"s"===t?this.onConnectionShutdown_(n):"r"===t?this.onReset_(n):"e"===t?Qs("Server Error: "+n):"o"===t?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):Qs("Unknown control packet command: "+t)}}onHandshake_(e){const t=e.ts,n=e.v,i=e.h;this.sessionId=e.s,this.repoInfo_.host=i,0===this.state_&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,t),"5"!==n&&ta("Protocol version mismatch detected"),this.tryStartUpgrade_())}tryStartUpgrade_(){const e=this.transportManager_.upgradeTransport();e&&this.startUpgrade_(e)}startUpgrade_(e){this.secondaryConn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,this.sessionId),this.secondaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.secondaryConn_),n=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(t,n),fa(()=>{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())},Math.floor(6e4))}onReset_(e){this.log_("Reset packet received. New host: "+e),this.repoInfo_.host=e,1===this.state_?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(e,t){this.log_("Realtime connection established."),this.conn_=e,this.state_=1,this.onReady_&&(this.onReady_(t,this.sessionId),this.onReady_=null),0===this.primaryResponsesRequired_?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):fa(()=>{this.sendPingOnPrimaryIfNecessary_()},Math.floor(5e3))}sendPingOnPrimaryIfNecessary_(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:"p",d:{}}}))}onSecondaryConnectionLost_(){const e=this.secondaryConn_;this.secondaryConn_=null,this.tx_!==e&&this.rx_!==e||this.close()}onConnectionLost_(e){this.conn_=null,e||0!==this.state_?1===this.state_&&this.log_("Realtime connection lost."):(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(Bs.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)),this.close()}onConnectionShutdown_(e){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(e),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(e){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(e)}close(){2!==this.state_&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}}
|
|
2108
|
+
/**
|
|
2109
|
+
* @license
|
|
2110
|
+
* Copyright 2017 Google LLC
|
|
2111
|
+
*
|
|
2112
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2113
|
+
* you may not use this file except in compliance with the License.
|
|
2114
|
+
* You may obtain a copy of the License at
|
|
2115
|
+
*
|
|
2116
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2117
|
+
*
|
|
2118
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2119
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2120
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2121
|
+
* See the License for the specific language governing permissions and
|
|
2122
|
+
* limitations under the License.
|
|
2123
|
+
*/class ja{put(e,t,n,i){}merge(e,t,n,i){}refreshAuthToken(e){}refreshAppCheckToken(e){}onDisconnectPut(e,t,n){}onDisconnectMerge(e,t,n){}onDisconnectCancel(e,t){}reportStats(e){}}
|
|
2124
|
+
/**
|
|
2125
|
+
* @license
|
|
2126
|
+
* Copyright 2017 Google LLC
|
|
2127
|
+
*
|
|
2128
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2129
|
+
* you may not use this file except in compliance with the License.
|
|
2130
|
+
* You may obtain a copy of the License at
|
|
2131
|
+
*
|
|
2132
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2133
|
+
*
|
|
2134
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2135
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2136
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2137
|
+
* See the License for the specific language governing permissions and
|
|
2138
|
+
* limitations under the License.
|
|
2139
|
+
*/class Fa{constructor(e){this.allowedEvents_=e,this.listeners_={},h(Array.isArray(e)&&e.length>0,"Requires a non-empty array")}trigger(e,...t){if(Array.isArray(this.listeners_[e])){const n=[...this.listeners_[e]];for(let e=0;e<n.length;e++)n[e].callback.apply(n[e].context,t)}}on(e,t,n){this.validateEventType_(e),this.listeners_[e]=this.listeners_[e]||[],this.listeners_[e].push({callback:t,context:n});const i=this.getInitialEvent(e);i&&t.apply(n,i)}off(e,t,n){this.validateEventType_(e);const i=this.listeners_[e]||[];for(let e=0;e<i.length;e++)if(i[e].callback===t&&(!n||n===i[e].context))return void i.splice(e,1)}validateEventType_(e){h(this.allowedEvents_.find(t=>t===e),"Unknown event: "+e)}}
|
|
2140
|
+
/**
|
|
2141
|
+
* @license
|
|
2142
|
+
* Copyright 2017 Google LLC
|
|
2143
|
+
*
|
|
2144
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2145
|
+
* you may not use this file except in compliance with the License.
|
|
2146
|
+
* You may obtain a copy of the License at
|
|
2147
|
+
*
|
|
2148
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2149
|
+
*
|
|
2150
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2151
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2152
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2153
|
+
* See the License for the specific language governing permissions and
|
|
2154
|
+
* limitations under the License.
|
|
2155
|
+
*/class za extends Fa{static getInstance(){return new za}constructor(){super(["online"]),this.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||A()||(window.addEventListener("online",()=>{this.online_||(this.online_=!0,this.trigger("online",!0))},!1),window.addEventListener("offline",()=>{this.online_&&(this.online_=!1,this.trigger("online",!1))},!1))}getInitialEvent(e){return h("online"===e,"Unknown event type: "+e),[this.online_]}currentlyOnline(){return this.online_}}
|
|
2156
|
+
/**
|
|
2157
|
+
* @license
|
|
2158
|
+
* Copyright 2017 Google LLC
|
|
2159
|
+
*
|
|
2160
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2161
|
+
* you may not use this file except in compliance with the License.
|
|
2162
|
+
* You may obtain a copy of the License at
|
|
2163
|
+
*
|
|
2164
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2165
|
+
*
|
|
2166
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2167
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2168
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2169
|
+
* See the License for the specific language governing permissions and
|
|
2170
|
+
* limitations under the License.
|
|
2171
|
+
*/class Ua{constructor(e,t){if(void 0===t){this.pieces_=e.split("/");let t=0;for(let e=0;e<this.pieces_.length;e++)this.pieces_[e].length>0&&(this.pieces_[t]=this.pieces_[e],t++);this.pieces_.length=t,this.pieceNum_=0}else this.pieces_=e,this.pieceNum_=t}toString(){let e="";for(let t=this.pieceNum_;t<this.pieces_.length;t++)""!==this.pieces_[t]&&(e+="/"+this.pieces_[t]);return e||"/"}}function $a(){return new Ua("")}function qa(e){return e.pieceNum_>=e.pieces_.length?null:e.pieces_[e.pieceNum_]}function Ba(e){return e.pieces_.length-e.pieceNum_}function Va(e){let t=e.pieceNum_;return t<e.pieces_.length&&t++,new Ua(e.pieces_,t)}function Ha(e){return e.pieceNum_<e.pieces_.length?e.pieces_[e.pieces_.length-1]:null}function Wa(e,t=0){return e.pieces_.slice(e.pieceNum_+t)}function Ga(e){if(e.pieceNum_>=e.pieces_.length)return null;const t=[];for(let n=e.pieceNum_;n<e.pieces_.length-1;n++)t.push(e.pieces_[n]);return new Ua(t,0)}function Ka(e,t){const n=[];for(let t=e.pieceNum_;t<e.pieces_.length;t++)n.push(e.pieces_[t]);if(t instanceof Ua)for(let e=t.pieceNum_;e<t.pieces_.length;e++)n.push(t.pieces_[e]);else{const e=t.split("/");for(let t=0;t<e.length;t++)e[t].length>0&&n.push(e[t])}return new Ua(n,0)}function Ya(e){return e.pieceNum_>=e.pieces_.length}function Ja(e,t){const n=qa(e),i=qa(t);if(null===n)return t;if(n===i)return Ja(Va(e),Va(t));throw new Error("INTERNAL ERROR: innerPath ("+t+") is not within outerPath ("+e+")")}function Za(e,t){const n=Wa(e,0),i=Wa(t,0);for(let e=0;e<n.length&&e<i.length;e++){const t=sa(n[e],i[e]);if(0!==t)return t}return n.length===i.length?0:n.length<i.length?-1:1}function Xa(e,t){if(Ba(e)!==Ba(t))return!1;for(let n=e.pieceNum_,i=t.pieceNum_;n<=e.pieces_.length;n++,i++)if(e.pieces_[n]!==t.pieces_[i])return!1;return!0}function Qa(e,t){let n=e.pieceNum_,i=t.pieceNum_;if(Ba(e)>Ba(t))return!1;for(;n<e.pieces_.length;){if(e.pieces_[n]!==t.pieces_[i])return!1;++n,++i}return!0}class eo{constructor(e,t){this.errorPrefix_=t,this.parts_=Wa(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let e=0;e<this.parts_.length;e++)this.byteLength_+=ne(this.parts_[e]);to(this)}}function to(e){if(e.byteLength_>768)throw new Error(e.errorPrefix_+"has a key path longer than 768 bytes ("+e.byteLength_+").");if(e.parts_.length>32)throw new Error(e.errorPrefix_+"path specified exceeds the maximum depth that can be written (32) or object contains a cycle "+no(e))}function no(e){return 0===e.parts_.length?"":"in property '"+e.parts_.join(".")+"'"}
|
|
2172
|
+
/**
|
|
2173
|
+
* @license
|
|
2174
|
+
* Copyright 2017 Google LLC
|
|
2175
|
+
*
|
|
2176
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2177
|
+
* you may not use this file except in compliance with the License.
|
|
2178
|
+
* You may obtain a copy of the License at
|
|
2179
|
+
*
|
|
2180
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2181
|
+
*
|
|
2182
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2183
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2184
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2185
|
+
* See the License for the specific language governing permissions and
|
|
2186
|
+
* limitations under the License.
|
|
2187
|
+
*/class io extends Fa{static getInstance(){return new io}constructor(){let e,t;super(["visible"]),"undefined"!=typeof document&&void 0!==document.addEventListener&&(void 0!==document.hidden?(t="visibilitychange",e="hidden"):void 0!==document.mozHidden?(t="mozvisibilitychange",e="mozHidden"):void 0!==document.msHidden?(t="msvisibilitychange",e="msHidden"):void 0!==document.webkitHidden&&(t="webkitvisibilitychange",e="webkitHidden")),this.visible_=!0,t&&document.addEventListener(t,()=>{const t=!document[e];t!==this.visible_&&(this.visible_=t,this.trigger("visible",t))},!1)}getInitialEvent(e){return h("visible"===e,"Unknown event type: "+e),[this.visible_]}}
|
|
2188
|
+
/**
|
|
2189
|
+
* @license
|
|
2190
|
+
* Copyright 2017 Google LLC
|
|
2191
|
+
*
|
|
2192
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2193
|
+
* you may not use this file except in compliance with the License.
|
|
2194
|
+
* You may obtain a copy of the License at
|
|
2195
|
+
*
|
|
2196
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2197
|
+
*
|
|
2198
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2199
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2200
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2201
|
+
* See the License for the specific language governing permissions and
|
|
2202
|
+
* limitations under the License.
|
|
2203
|
+
*/const ro=1e3;class so extends ja{constructor(e,t,n,i,r,s,a,o){if(super(),this.repoInfo_=e,this.applicationId_=t,this.onDataUpdate_=n,this.onConnectStatus_=i,this.onServerInfoUpdate_=r,this.authTokenProvider_=s,this.appCheckTokenProvider_=a,this.authOverride_=o,this.id=so.nextPersistentConnectionId_++,this.log_=Xs("p:"+this.id+":"),this.interruptReasons_={},this.listens=new Map,this.outstandingPuts_=[],this.outstandingGets_=[],this.outstandingPutCount_=0,this.outstandingGetCount_=0,this.onDisconnectRequestQueue_=[],this.connected_=!1,this.reconnectDelay_=ro,this.maxReconnectDelay_=3e5,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,o)throw new Error("Auth override specified in options, but not supported on non Node.js platforms");io.getInstance().on("visible",this.onVisible_,this),-1===e.host.indexOf("fblocal")&&za.getInstance().on("online",this.onOnline_,this)}sendRequest(e,t,n){const i=++this.requestNumber_,r={r:i,a:e,b:t};this.log_(B(r)),h(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(r),n&&(this.requestCBHash_[i]=n)}get(e){this.initConnection_();const t=new E,n={action:"g",request:{p:e._path.toString(),q:e._queryObject},onComplete:e=>{const n=e.d;"ok"===e.s?t.resolve(n):t.reject(n)}};this.outstandingGets_.push(n),this.outstandingGetCount_++;const i=this.outstandingGets_.length-1;return this.connected_&&this.sendGet_(i),t.promise}listen(e,t,n,i){this.initConnection_();const r=e._queryIdentifier,s=e._path.toString();this.log_("Listen called for "+s+" "+r),this.listens.has(s)||this.listens.set(s,new Map),h(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),h(!this.listens.get(s).has(r),"listen() called twice for same path/queryId.");const a={onComplete:i,hashFn:t,query:e,tag:n};this.listens.get(s).set(r,a),this.connected_&&this.sendListen_(a)}sendGet_(e){const t=this.outstandingGets_[e];this.sendRequest("g",t.request,n=>{delete this.outstandingGets_[e],this.outstandingGetCount_--,0===this.outstandingGetCount_&&(this.outstandingGets_=[]),t.onComplete&&t.onComplete(n)})}sendListen_(e){const t=e.query,n=t._path.toString(),i=t._queryIdentifier;this.log_("Listen on "+n+" for "+i);const r={p:n};e.tag&&(r.q=t._queryObject,r.t=e.tag),r.h=e.hashFn(),this.sendRequest("q",r,r=>{const s=r.d,a=r.s;so.warnOnListenWarnings_(s,t);(this.listens.get(n)&&this.listens.get(n).get(i))===e&&(this.log_("listen response",r),"ok"!==a&&this.removeListen_(n,i),e.onComplete&&e.onComplete(a,s))})}static warnOnListenWarnings_(e,t){if(e&&"object"==typeof e&&H(e,"w")){const n=W(e,"w");if(Array.isArray(n)&&~n.indexOf("no_index")){const e='".indexOn": "'+t._queryParams.getIndex().toString()+'"',n=t._path.toString();ta(`Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ${e} at ${n} to your security rules for better performance.`)}}}refreshAuthToken(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},()=>{}),this.reduceReconnectDelayIfAdminCredential_(e)}reduceReconnectDelayIfAdminCredential_(e){(e&&40===e.length||function(e){const t=V(e).claims;return"object"==typeof t&&!0===t.admin}(e))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=3e4)}refreshAppCheckToken(e){this.appCheckToken_=e,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},()=>{})}tryAuth(){if(this.connected_&&this.authToken_){const e=this.authToken_,t=function(e){const t=V(e).claims;return!!t&&"object"==typeof t&&t.hasOwnProperty("iat")}(e)?"auth":"gauth",n={cred:e};null===this.authOverride_?n.noauth=!0:"object"==typeof this.authOverride_&&(n.authvar=this.authOverride_),this.sendRequest(t,n,t=>{const n=t.s,i=t.d||"error";this.authToken_===e&&("ok"===n?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(n,i))})}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},e=>{const t=e.s,n=e.d||"error";"ok"===t?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(t,n)})}unlisten(e,t){const n=e._path.toString(),i=e._queryIdentifier;this.log_("Unlisten called for "+n+" "+i),h(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query");this.removeListen_(n,i)&&this.connected_&&this.sendUnlisten_(n,i,e._queryObject,t)}sendUnlisten_(e,t,n,i){this.log_("Unlisten on "+e+" for "+t);const r={p:e};i&&(r.q=n,r.t=i),this.sendRequest("n",r)}onDisconnectPut(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:t,onComplete:n})}onDisconnectMerge(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:t,onComplete:n})}onDisconnectCancel(e,t){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,t):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:t})}sendOnDisconnect_(e,t,n,i){const r={p:t,d:n};this.log_("onDisconnect "+e,r),this.sendRequest(e,r,e=>{i&&setTimeout(()=>{i(e.s,e.d)},Math.floor(0))})}put(e,t,n,i){this.putInternal("p",e,t,n,i)}merge(e,t,n,i){this.putInternal("m",e,t,n,i)}putInternal(e,t,n,i,r){this.initConnection_();const s={p:t,d:n};void 0!==r&&(s.h=r),this.outstandingPuts_.push({action:e,request:s,onComplete:i}),this.outstandingPutCount_++;const a=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(a):this.log_("Buffering put: "+t)}sendPut_(e){const t=this.outstandingPuts_[e].action,n=this.outstandingPuts_[e].request,i=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(t,n,n=>{this.log_(t+" response",n),delete this.outstandingPuts_[e],this.outstandingPutCount_--,0===this.outstandingPutCount_&&(this.outstandingPuts_=[]),i&&i(n.s,n.d)})}reportStats(e){if(this.connected_){const t={c:e};this.log_("reportStats",t),this.sendRequest("s",t,e=>{if("ok"!==e.s){const t=e.d;this.log_("reportStats","Error sending stats: "+t)}})}}onDataMessage_(e){if("r"in e){this.log_("from server: "+B(e));const t=e.r,n=this.requestCBHash_[t];n&&(delete this.requestCBHash_[t],n(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&&this.onDataPush_(e.a,e.b)}}onDataPush_(e,t){this.log_("handleServerMessage",e,t),"d"===e?this.onDataUpdate_(t.p,t.d,!1,t.t):"m"===e?this.onDataUpdate_(t.p,t.d,!0,t.t):"c"===e?this.onListenRevoked_(t.p,t.q):"ac"===e?this.onAuthRevoked_(t.s,t.d):"apc"===e?this.onAppCheckRevoked_(t.s,t.d):"sd"===e?this.onSecurityDebugPacket_(t):Qs("Unrecognized action received from server: "+B(e)+"\nAre you using the latest client?")}onReady_(e,t){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=(new Date).getTime(),this.handleTimestamp_(e),this.lastSessionId=t,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(e){h(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(()=>{this.establishConnectionTimer_=null,this.establishConnection_()},Math.floor(e))}initConnection_(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)}onVisible_(e){e&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible. Reducing delay."),this.reconnectDelay_=ro,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=ro,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline. Killing connection."),this.realtime_&&this.realtime_.close())}onRealtimeDisconnect_(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){if(this.visible_){if(this.lastConnectionEstablishedTime_){(new Date).getTime()-this.lastConnectionEstablishedTime_>3e4&&(this.reconnectDelay_=ro),this.lastConnectionEstablishedTime_=null}}else this.log_("Window isn't visible. Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime();const e=Math.max(0,(new Date).getTime()-this.lastConnectionAttemptTime_);let t=Math.max(0,this.reconnectDelay_-e);t=Math.random()*t,this.log_("Trying to reconnect in "+t+"ms"),this.scheduleConnect_(t),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,1.3*this.reconnectDelay_)}this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=(new Date).getTime(),this.lastConnectionEstablishedTime_=null;const e=this.onDataMessage_.bind(this),t=this.onReady_.bind(this),n=this.onRealtimeDisconnect_.bind(this),i=this.id+":"+so.nextConnectionId_++,r=this.lastSessionId;let s=!1,a=null;const o=function(){a?a.close():(s=!0,n())},l=function(e){h(a,"sendRequest call when we're not connected not allowed."),a.sendRequest(e)};this.realtime_={close:o,sendRequest:l};const c=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[o,l]=await Promise.all([this.authTokenProvider_.getToken(c),this.appCheckTokenProvider_.getToken(c)]);s?Zs("getToken() completed but was canceled"):(Zs("getToken() completed. Creating connection."),this.authToken_=o&&o.accessToken,this.appCheckToken_=l&&l.token,a=new Oa(i,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,t,n,e=>{ta(e+" ("+this.repoInfo_.toString()+")"),this.interrupt("server_kill")},r))}catch(e){this.log_("Failed to get token: "+e),s||(this.repoInfo_.nodeAdmin&&ta(e),o())}}}interrupt(e){Zs("Interrupting connection for reason: "+e),this.interruptReasons_[e]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())}resume(e){Zs("Resuming connection for reason: "+e),delete this.interruptReasons_[e],G(this.interruptReasons_)&&(this.reconnectDelay_=ro,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(e){const t=e-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:t})}cancelSentTransactions_(){for(let e=0;e<this.outstandingPuts_.length;e++){const t=this.outstandingPuts_[e];t&&"h"in t.request&&t.queued&&(t.onComplete&&t.onComplete("disconnect"),delete this.outstandingPuts_[e],this.outstandingPutCount_--)}0===this.outstandingPutCount_&&(this.outstandingPuts_=[])}onListenRevoked_(e,t){let n;n=t?t.map(e=>la(e)).join("$"):"default";const i=this.removeListen_(e,n);i&&i.onComplete&&i.onComplete("permission_denied")}removeListen_(e,t){const n=new Ua(e).toString();let i;if(this.listens.has(n)){const e=this.listens.get(n);i=e.get(t),e.delete(t),0===e.size&&this.listens.delete(n)}else i=void 0;return i}onAuthRevoked_(e,t){Zs("Auth token revoked: "+e+"/"+t),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),"invalid_token"!==e&&"permission_denied"!==e||(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=3&&(this.reconnectDelay_=3e4,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,t){Zs("App check token revoked: "+e+"/"+t),this.appCheckToken_=null,this.forceTokenRefresh_=!0,"invalid_token"!==e&&"permission_denied"!==e||(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=3&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&&console.log("FIREBASE: "+e.msg.replace("\n","\nFIREBASE: "))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of this.listens.values())for(const t of e.values())this.sendListen_(t);for(let e=0;e<this.outstandingPuts_.length;e++)this.outstandingPuts_[e]&&this.sendPut_(e);for(;this.onDisconnectRequestQueue_.length;){const e=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(e.action,e.pathString,e.data,e.onComplete)}for(let e=0;e<this.outstandingGets_.length;e++)this.outstandingGets_[e]&&this.sendGet_(e)}sendConnectStats_(){const e={};e["sdk.js."+zs.replace(/\./g,"-")]=1,A()?e["framework.cordova"]=1:O()&&(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){const e=za.getInstance().currentlyOnline();return G(this.interruptReasons_)&&e}}so.nextPersistentConnectionId_=0,so.nextConnectionId_=0;
|
|
2204
|
+
/**
|
|
2205
|
+
* @license
|
|
2206
|
+
* Copyright 2017 Google LLC
|
|
2207
|
+
*
|
|
2208
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2209
|
+
* you may not use this file except in compliance with the License.
|
|
2210
|
+
* You may obtain a copy of the License at
|
|
2211
|
+
*
|
|
2212
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2213
|
+
*
|
|
2214
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2215
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2216
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2217
|
+
* See the License for the specific language governing permissions and
|
|
2218
|
+
* limitations under the License.
|
|
2219
|
+
*/
|
|
2220
|
+
class ao{constructor(e,t){this.name=e,this.node=t}static Wrap(e,t){return new ao(e,t)}}
|
|
2221
|
+
/**
|
|
2222
|
+
* @license
|
|
2223
|
+
* Copyright 2017 Google LLC
|
|
2224
|
+
*
|
|
2225
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2226
|
+
* you may not use this file except in compliance with the License.
|
|
2227
|
+
* You may obtain a copy of the License at
|
|
2228
|
+
*
|
|
2229
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2230
|
+
*
|
|
2231
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2232
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2233
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2234
|
+
* See the License for the specific language governing permissions and
|
|
2235
|
+
* limitations under the License.
|
|
2236
|
+
*/class oo{getCompare(){return this.compare.bind(this)}indexedValueChanged(e,t){const n=new ao(ia,e),i=new ao(ia,t);return 0!==this.compare(n,i)}minPost(){return ao.MIN}}
|
|
2237
|
+
/**
|
|
2238
|
+
* @license
|
|
2239
|
+
* Copyright 2017 Google LLC
|
|
2240
|
+
*
|
|
2241
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2242
|
+
* you may not use this file except in compliance with the License.
|
|
2243
|
+
* You may obtain a copy of the License at
|
|
2244
|
+
*
|
|
2245
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2246
|
+
*
|
|
2247
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2248
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2249
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2250
|
+
* See the License for the specific language governing permissions and
|
|
2251
|
+
* limitations under the License.
|
|
2252
|
+
*/let lo;class co extends oo{static get __EMPTY_NODE(){return lo}static set __EMPTY_NODE(e){lo=e}compare(e,t){return sa(e.name,t.name)}isDefinedOn(e){throw d("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(e,t){return!1}minPost(){return ao.MIN}maxPost(){return new ao(ra,lo)}makePost(e,t){return h("string"==typeof e,"KeyIndex indexValue must always be a string."),new ao(e,lo)}toString(){return".key"}}const uo=new co;
|
|
2253
|
+
/**
|
|
2254
|
+
* @license
|
|
2255
|
+
* Copyright 2017 Google LLC
|
|
2256
|
+
*
|
|
2257
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2258
|
+
* you may not use this file except in compliance with the License.
|
|
2259
|
+
* You may obtain a copy of the License at
|
|
2260
|
+
*
|
|
2261
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2262
|
+
*
|
|
2263
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2264
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2265
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2266
|
+
* See the License for the specific language governing permissions and
|
|
2267
|
+
* limitations under the License.
|
|
2268
|
+
*/class ho{constructor(e,t,n,i,r=null){this.isReverse_=i,this.resultGenerator_=r,this.nodeStack_=[];let s=1;for(;!e.isEmpty();)if(s=t?n(e.key,t):1,i&&(s*=-1),s<0)e=this.isReverse_?e.left:e.right;else{if(0===s){this.nodeStack_.push(e);break}this.nodeStack_.push(e),e=this.isReverse_?e.right:e.left}}getNext(){if(0===this.nodeStack_.length)return null;let e,t=this.nodeStack_.pop();if(e=this.resultGenerator_?this.resultGenerator_(t.key,t.value):{key:t.key,value:t.value},this.isReverse_)for(t=t.left;!t.isEmpty();)this.nodeStack_.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack_.push(t),t=t.left;return e}hasNext(){return this.nodeStack_.length>0}peek(){if(0===this.nodeStack_.length)return null;const e=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value}}}class po{constructor(e,t,n,i,r){this.key=e,this.value=t,this.color=null!=n?n:po.RED,this.left=null!=i?i:go.EMPTY_NODE,this.right=null!=r?r:go.EMPTY_NODE}copy(e,t,n,i,r){return new po(null!=e?e:this.key,null!=t?t:this.value,null!=n?n:this.color,null!=i?i:this.left,null!=r?r:this.right)}count(){return this.left.count()+1+this.right.count()}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||!!e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min_(){return this.left.isEmpty()?this:this.left.min_()}minKey(){return this.min_().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,n){let i=this;const r=n(e,i.key);return i=r<0?i.copy(null,null,null,i.left.insert(e,t,n),null):0===r?i.copy(null,t,null,null,null):i.copy(null,null,null,null,i.right.insert(e,t,n)),i.fixUp_()}removeMin_(){if(this.left.isEmpty())return go.EMPTY_NODE;let e=this;return e.left.isRed_()||e.left.left.isRed_()||(e=e.moveRedLeft_()),e=e.copy(null,null,null,e.left.removeMin_(),null),e.fixUp_()}remove(e,t){let n,i;if(n=this,t(e,n.key)<0)n.left.isEmpty()||n.left.isRed_()||n.left.left.isRed_()||(n=n.moveRedLeft_()),n=n.copy(null,null,null,n.left.remove(e,t),null);else{if(n.left.isRed_()&&(n=n.rotateRight_()),n.right.isEmpty()||n.right.isRed_()||n.right.left.isRed_()||(n=n.moveRedRight_()),0===t(e,n.key)){if(n.right.isEmpty())return go.EMPTY_NODE;i=n.right.min_(),n=n.copy(i.key,i.value,null,null,n.right.removeMin_())}n=n.copy(null,null,null,null,n.right.remove(e,t))}return n.fixUp_()}isRed_(){return this.color}fixUp_(){let 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}moveRedLeft_(){let e=this.colorFlip_();return e.right.left.isRed_()&&(e=e.copy(null,null,null,null,e.right.rotateRight_()),e=e.rotateLeft_(),e=e.colorFlip_()),e}moveRedRight_(){let e=this.colorFlip_();return e.left.left.isRed_()&&(e=e.rotateRight_(),e=e.colorFlip_()),e}rotateLeft_(){const e=this.copy(null,null,po.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){const e=this.copy(null,null,po.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip_(){const 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)}checkMaxDepth_(){const e=this.check_();return Math.pow(2,e)<=this.count()+1}check_(){if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");const e=this.left.check_();if(e!==this.right.check_())throw new Error("Black depths differ");return e+(this.isRed_()?0:1)}}po.RED=!0,po.BLACK=!1;class go{constructor(e,t=go.EMPTY_NODE){this.comparator_=e,this.root_=t}insert(e,t){return new go(this.comparator_,this.root_.insert(e,t,this.comparator_).copy(null,null,po.BLACK,null,null))}remove(e){return new go(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,po.BLACK,null,null))}get(e){let t,n=this.root_;for(;!n.isEmpty();){if(t=this.comparator_(e,n.key),0===t)return n.value;t<0?n=n.left:t>0&&(n=n.right)}return null}getPredecessorKey(e){let t,n=this.root_,i=null;for(;!n.isEmpty();){if(t=this.comparator_(e,n.key),0===t){if(n.left.isEmpty())return i?i.key:null;for(n=n.left;!n.right.isEmpty();)n=n.right;return n.key}t<0?n=n.left:t>0&&(i=n,n=n.right)}throw new Error("Attempted to find predecessor key for a nonexistent key. What gives?")}isEmpty(){return this.root_.isEmpty()}count(){return this.root_.count()}minKey(){return this.root_.minKey()}maxKey(){return this.root_.maxKey()}inorderTraversal(e){return this.root_.inorderTraversal(e)}reverseTraversal(e){return this.root_.reverseTraversal(e)}getIterator(e){return new ho(this.root_,null,this.comparator_,!1,e)}getIteratorFrom(e,t){return new ho(this.root_,e,this.comparator_,!1,t)}getReverseIteratorFrom(e,t){return new ho(this.root_,e,this.comparator_,!0,t)}getReverseIterator(e){return new ho(this.root_,null,this.comparator_,!0,e)}}
|
|
2269
|
+
/**
|
|
2270
|
+
* @license
|
|
2271
|
+
* Copyright 2017 Google LLC
|
|
2272
|
+
*
|
|
2273
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2274
|
+
* you may not use this file except in compliance with the License.
|
|
2275
|
+
* You may obtain a copy of the License at
|
|
2276
|
+
*
|
|
2277
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2278
|
+
*
|
|
2279
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2280
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2281
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2282
|
+
* See the License for the specific language governing permissions and
|
|
2283
|
+
* limitations under the License.
|
|
2284
|
+
*/
|
|
2285
|
+
function fo(e,t){return sa(e.name,t.name)}function mo(e,t){return sa(e,t)}
|
|
2286
|
+
/**
|
|
2287
|
+
* @license
|
|
2288
|
+
* Copyright 2017 Google LLC
|
|
2289
|
+
*
|
|
2290
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2291
|
+
* you may not use this file except in compliance with the License.
|
|
2292
|
+
* You may obtain a copy of the License at
|
|
2293
|
+
*
|
|
2294
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2295
|
+
*
|
|
2296
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2297
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2298
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2299
|
+
* See the License for the specific language governing permissions and
|
|
2300
|
+
* limitations under the License.
|
|
2301
|
+
*/let vo;go.EMPTY_NODE=new class{copy(e,t,n,i,r){return this}insert(e,t,n){return new po(e,t,null)}remove(e,t){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}};const yo=function(e){return"number"==typeof e?"number:"+ha(e):"string:"+e},wo=function(e){if(e.isLeafNode()){const t=e.val();h("string"==typeof t||"number"==typeof t||"object"==typeof t&&H(t,".sv"),"Priority must be a string or number.")}else h(e===vo||e.isEmpty(),"priority of unexpected type.");h(e===vo||e.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")};
|
|
2302
|
+
/**
|
|
2303
|
+
* @license
|
|
2304
|
+
* Copyright 2017 Google LLC
|
|
2305
|
+
*
|
|
2306
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2307
|
+
* you may not use this file except in compliance with the License.
|
|
2308
|
+
* You may obtain a copy of the License at
|
|
2309
|
+
*
|
|
2310
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2311
|
+
*
|
|
2312
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2313
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2314
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2315
|
+
* See the License for the specific language governing permissions and
|
|
2316
|
+
* limitations under the License.
|
|
2317
|
+
*/
|
|
2318
|
+
let bo,_o,ko;class Co{static set __childrenNodeConstructor(e){bo=e}static get __childrenNodeConstructor(){return bo}constructor(e,t=Co.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=t,this.lazyHash_=null,h(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),wo(this.priorityNode_)}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new Co(this.value_,e)}getImmediateChild(e){return".priority"===e?this.priorityNode_:Co.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return Ya(e)?this:".priority"===qa(e)?this.priorityNode_:Co.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,t){return null}updateImmediateChild(e,t){return".priority"===e?this.updatePriority(t):t.isEmpty()&&".priority"!==e?this:Co.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){const n=qa(e);return null===n?t:t.isEmpty()&&".priority"!==n?this:(h(".priority"!==n||1===Ba(e),".priority must be the last token in a path"),this.updateImmediateChild(n,Co.__childrenNodeConstructor.EMPTY_NODE.updateChild(Va(e),t)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,t){return!1}val(e){return e&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(null===this.lazyHash_){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+yo(this.priorityNode_.val())+":");const t=typeof this.value_;e+=t+":",e+="number"===t?ha(this.value_):this.value_,this.lazyHash_=Gs(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===Co.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof Co.__childrenNodeConstructor?-1:(h(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){const t=typeof e.value_,n=typeof this.value_,i=Co.VALUE_TYPE_ORDER.indexOf(t),r=Co.VALUE_TYPE_ORDER.indexOf(n);return h(i>=0,"Unknown leaf type: "+t),h(r>=0,"Unknown leaf type: "+n),i===r?"object"===n?0:this.value_<e.value_?-1:this.value_===e.value_?0:1:r-i}withIndex(){return this}isIndexed(){return!0}equals(e){if(e===this)return!0;if(e.isLeafNode()){const t=e;return this.value_===t.value_&&this.priorityNode_.equals(t.priorityNode_)}return!1}}Co.VALUE_TYPE_ORDER=["object","boolean","number","string"];const So=new class extends oo{compare(e,t){const n=e.node.getPriority(),i=t.node.getPriority(),r=n.compareTo(i);return 0===r?sa(e.name,t.name):r}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return ao.MIN}maxPost(){return new ao(ra,new Co("[PRIORITY-POST]",ko))}makePost(e,t){const n=_o(e);return new ao(t,new Co("[PRIORITY-POST]",n))}toString(){return".priority"}},To=Math.log(2);
|
|
2319
|
+
/**
|
|
2320
|
+
* @license
|
|
2321
|
+
* Copyright 2017 Google LLC
|
|
2322
|
+
*
|
|
2323
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2324
|
+
* you may not use this file except in compliance with the License.
|
|
2325
|
+
* You may obtain a copy of the License at
|
|
2326
|
+
*
|
|
2327
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2328
|
+
*
|
|
2329
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2330
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2331
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2332
|
+
* See the License for the specific language governing permissions and
|
|
2333
|
+
* limitations under the License.
|
|
2334
|
+
*/class Io{constructor(e){var t;this.count=(t=e+1,parseInt(Math.log(t)/To,10)),this.current_=this.count-1;const n=(i=this.count,parseInt(Array(i+1).join("1"),2));var i;this.bits_=e+1&n}nextBitIsOne(){const e=!(this.bits_&1<<this.current_);return this.current_--,e}}const Eo=function(e,t,n,i){e.sort(t);const r=function(t,i){const s=i-t;let a,o;if(0===s)return null;if(1===s)return a=e[t],o=n?n(a):a,new po(o,a.node,po.BLACK,null,null);{const l=parseInt(s/2,10)+t,c=r(t,l),u=r(l+1,i);return a=e[l],o=n?n(a):a,new po(o,a.node,po.BLACK,c,u)}},s=function(t){let i=null,s=null,a=e.length;const o=function(t,i){const s=a-t,o=a;a-=t;const c=r(s+1,o),u=e[s],h=n?n(u):u;l(new po(h,u.node,i,null,c))},l=function(e){i?(i.left=e,i=e):(s=e,i=e)};for(let e=0;e<t.count;++e){const n=t.nextBitIsOne(),i=Math.pow(2,t.count-(e+1));n?o(i,po.BLACK):(o(i,po.BLACK),o(i,po.RED))}return s}(new Io(e.length));return new go(i||t,s)};
|
|
2335
|
+
/**
|
|
2336
|
+
* @license
|
|
2337
|
+
* Copyright 2017 Google LLC
|
|
2338
|
+
*
|
|
2339
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2340
|
+
* you may not use this file except in compliance with the License.
|
|
2341
|
+
* You may obtain a copy of the License at
|
|
2342
|
+
*
|
|
2343
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2344
|
+
*
|
|
2345
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2346
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2347
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2348
|
+
* See the License for the specific language governing permissions and
|
|
2349
|
+
* limitations under the License.
|
|
2350
|
+
*/let Po;const xo={};class Ro{static get Default(){return h(xo&&So,"ChildrenNode.ts has not been loaded"),Po=Po||new Ro({".priority":xo},{".priority":So}),Po}constructor(e,t){this.indexes_=e,this.indexSet_=t}get(e){const t=W(this.indexes_,e);if(!t)throw new Error("No index defined for "+e);return t instanceof go?t:null}hasIndex(e){return H(this.indexSet_,e.toString())}addIndex(e,t){h(e!==uo,"KeyIndex always exists and isn't meant to be added to the IndexMap.");const n=[];let i=!1;const r=t.getIterator(ao.Wrap);let s,a=r.getNext();for(;a;)i=i||e.isDefinedOn(a.node),n.push(a),a=r.getNext();s=i?Eo(n,e.getCompare()):xo;const o=e.toString(),l={...this.indexSet_};l[o]=e;const c={...this.indexes_};return c[o]=s,new Ro(c,l)}addToIndexes(e,t){const n=K(this.indexes_,(n,i)=>{const r=W(this.indexSet_,i);if(h(r,"Missing index implementation for "+i),n===xo){if(r.isDefinedOn(e.node)){const n=[],i=t.getIterator(ao.Wrap);let s=i.getNext();for(;s;)s.name!==e.name&&n.push(s),s=i.getNext();return n.push(e),Eo(n,r.getCompare())}return xo}{const i=t.get(e.name);let r=n;return i&&(r=r.remove(new ao(e.name,i))),r.insert(e,e.node)}});return new Ro(n,this.indexSet_)}removeFromIndexes(e,t){const n=K(this.indexes_,n=>{if(n===xo)return n;{const i=t.get(e.name);return i?n.remove(new ao(e.name,i)):n}});return new Ro(n,this.indexSet_)}}
|
|
2351
|
+
/**
|
|
2352
|
+
* @license
|
|
2353
|
+
* Copyright 2017 Google LLC
|
|
2354
|
+
*
|
|
2355
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2356
|
+
* you may not use this file except in compliance with the License.
|
|
2357
|
+
* You may obtain a copy of the License at
|
|
2358
|
+
*
|
|
2359
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2360
|
+
*
|
|
2361
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2362
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2363
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2364
|
+
* See the License for the specific language governing permissions and
|
|
2365
|
+
* limitations under the License.
|
|
2366
|
+
*/let Lo;class No{static get EMPTY_NODE(){return Lo||(Lo=new No(new go(mo),null,Ro.Default))}constructor(e,t,n){this.children_=e,this.priorityNode_=t,this.indexMap_=n,this.lazyHash_=null,this.priorityNode_&&wo(this.priorityNode_),this.children_.isEmpty()&&h(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}isLeafNode(){return!1}getPriority(){return this.priorityNode_||Lo}updatePriority(e){return this.children_.isEmpty()?this:new No(this.children_,e,this.indexMap_)}getImmediateChild(e){if(".priority"===e)return this.getPriority();{const t=this.children_.get(e);return null===t?Lo:t}}getChild(e){const t=qa(e);return null===t?this:this.getImmediateChild(t).getChild(Va(e))}hasChild(e){return null!==this.children_.get(e)}updateImmediateChild(e,t){if(h(t,"We should always be passing snapshot nodes"),".priority"===e)return this.updatePriority(t);{const n=new ao(e,t);let i,r;t.isEmpty()?(i=this.children_.remove(e),r=this.indexMap_.removeFromIndexes(n,this.children_)):(i=this.children_.insert(e,t),r=this.indexMap_.addToIndexes(n,this.children_));const s=i.isEmpty()?Lo:this.priorityNode_;return new No(i,s,r)}}updateChild(e,t){const n=qa(e);if(null===n)return t;{h(".priority"!==qa(e)||1===Ba(e),".priority must be the last token in a path");const i=this.getImmediateChild(n).updateChild(Va(e),t);return this.updateImmediateChild(n,i)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(e){if(this.isEmpty())return null;const t={};let n=0,i=0,r=!0;if(this.forEachChild(So,(s,a)=>{t[s]=a.val(e),n++,r&&No.INTEGER_REGEXP_.test(s)?i=Math.max(i,Number(s)):r=!1}),!e&&r&&i<2*n){const e=[];for(const n in t)e[n]=t[n];return e}return e&&!this.getPriority().isEmpty()&&(t[".priority"]=this.getPriority().val()),t}hash(){if(null===this.lazyHash_){let e="";this.getPriority().isEmpty()||(e+="priority:"+yo(this.getPriority().val())+":"),this.forEachChild(So,(t,n)=>{const i=n.hash();""!==i&&(e+=":"+t+":"+i)}),this.lazyHash_=""===e?"":Gs(e)}return this.lazyHash_}getPredecessorChildName(e,t,n){const i=this.resolveIndex_(n);if(i){const n=i.getPredecessorKey(new ao(e,t));return n?n.name:null}return this.children_.getPredecessorKey(e)}getFirstChildName(e){const t=this.resolveIndex_(e);if(t){const e=t.minKey();return e&&e.name}return this.children_.minKey()}getFirstChild(e){const t=this.getFirstChildName(e);return t?new ao(t,this.children_.get(t)):null}getLastChildName(e){const t=this.resolveIndex_(e);if(t){const e=t.maxKey();return e&&e.name}return this.children_.maxKey()}getLastChild(e){const t=this.getLastChildName(e);return t?new ao(t,this.children_.get(t)):null}forEachChild(e,t){const n=this.resolveIndex_(e);return n?n.inorderTraversal(e=>t(e.name,e.node)):this.children_.inorderTraversal(t)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(e,t){const n=this.resolveIndex_(t);if(n)return n.getIteratorFrom(e,e=>e);{const n=this.children_.getIteratorFrom(e.name,ao.Wrap);let i=n.peek();for(;null!=i&&t.compare(i,e)<0;)n.getNext(),i=n.peek();return n}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(e,t){const n=this.resolveIndex_(t);if(n)return n.getReverseIteratorFrom(e,e=>e);{const n=this.children_.getReverseIteratorFrom(e.name,ao.Wrap);let i=n.peek();for(;null!=i&&t.compare(i,e)>0;)n.getNext(),i=n.peek();return n}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===Do?-1:0}withIndex(e){if(e===uo||this.indexMap_.hasIndex(e))return this;{const t=this.indexMap_.addIndex(e,this.children_);return new No(this.children_,this.priorityNode_,t)}}isIndexed(e){return e===uo||this.indexMap_.hasIndex(e)}equals(e){if(e===this)return!0;if(e.isLeafNode())return!1;{const t=e;if(this.getPriority().equals(t.getPriority())){if(this.children_.count()===t.children_.count()){const e=this.getIterator(So),n=t.getIterator(So);let i=e.getNext(),r=n.getNext();for(;i&&r;){if(i.name!==r.name||!i.node.equals(r.node))return!1;i=e.getNext(),r=n.getNext()}return null===i&&null===r}return!1}return!1}}resolveIndex_(e){return e===uo?null:this.indexMap_.get(e.toString())}}No.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;const Do=new class extends No{constructor(){super(new go(mo),No.EMPTY_NODE,Ro.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return No.EMPTY_NODE}isEmpty(){return!1}};Object.defineProperties(ao,{MIN:{value:new ao(ia,No.EMPTY_NODE)},MAX:{value:new ao(ra,Do)}}),co.__EMPTY_NODE=No.EMPTY_NODE,Co.__childrenNodeConstructor=No,vo=Do,function(e){ko=e}(Do);function Ao(e,t=null){if(null===e)return No.EMPTY_NODE;if("object"==typeof e&&".priority"in e&&(t=e[".priority"]),h(null===t||"string"==typeof t||"number"==typeof t||"object"==typeof t&&".sv"in t,"Invalid priority type found: "+typeof t),"object"==typeof e&&".value"in e&&null!==e[".value"]&&(e=e[".value"]),"object"!=typeof e||".sv"in e){return new Co(e,Ao(t))}if(e instanceof Array){let n=No.EMPTY_NODE;return ua(e,(t,i)=>{if(H(e,t)&&"."!==t.substring(0,1)){const e=Ao(i);!e.isLeafNode()&&e.isEmpty()||(n=n.updateImmediateChild(t,e))}}),n.updatePriority(Ao(t))}{const n=[];let i=!1;if(ua(e,(e,t)=>{if("."!==e.substring(0,1)){const r=Ao(t);r.isEmpty()||(i=i||!r.getPriority().isEmpty(),n.push(new ao(e,r)))}}),0===n.length)return No.EMPTY_NODE;const r=Eo(n,fo,e=>e.name,mo);if(i){const e=Eo(n,So.getCompare());return new No(r,Ao(t),new Ro({".priority":e},{".priority":So}))}return new No(r,Ao(t),Ro.Default)}}!function(e){_o=e}(Ao);
|
|
2367
|
+
/**
|
|
2368
|
+
* @license
|
|
2369
|
+
* Copyright 2017 Google LLC
|
|
2370
|
+
*
|
|
2371
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2372
|
+
* you may not use this file except in compliance with the License.
|
|
2373
|
+
* You may obtain a copy of the License at
|
|
2374
|
+
*
|
|
2375
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2376
|
+
*
|
|
2377
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2378
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2379
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2380
|
+
* See the License for the specific language governing permissions and
|
|
2381
|
+
* limitations under the License.
|
|
2382
|
+
*/
|
|
2383
|
+
class Mo extends oo{constructor(e){super(),this.indexPath_=e,h(!Ya(e)&&".priority"!==qa(e),"Can't create PathIndex with empty path or .priority key")}extractChild(e){return e.getChild(this.indexPath_)}isDefinedOn(e){return!e.getChild(this.indexPath_).isEmpty()}compare(e,t){const n=this.extractChild(e.node),i=this.extractChild(t.node),r=n.compareTo(i);return 0===r?sa(e.name,t.name):r}makePost(e,t){const n=Ao(e),i=No.EMPTY_NODE.updateChild(this.indexPath_,n);return new ao(t,i)}maxPost(){const e=No.EMPTY_NODE.updateChild(this.indexPath_,Do);return new ao(ra,e)}toString(){return Wa(this.indexPath_,0).join("/")}}
|
|
2384
|
+
/**
|
|
2385
|
+
* @license
|
|
2386
|
+
* Copyright 2017 Google LLC
|
|
2387
|
+
*
|
|
2388
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2389
|
+
* you may not use this file except in compliance with the License.
|
|
2390
|
+
* You may obtain a copy of the License at
|
|
2391
|
+
*
|
|
2392
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2393
|
+
*
|
|
2394
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2395
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2396
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2397
|
+
* See the License for the specific language governing permissions and
|
|
2398
|
+
* limitations under the License.
|
|
2399
|
+
*/const Oo=new class extends oo{compare(e,t){const n=e.node.compareTo(t.node);return 0===n?sa(e.name,t.name):n}isDefinedOn(e){return!0}indexedValueChanged(e,t){return!e.equals(t)}minPost(){return ao.MIN}maxPost(){return ao.MAX}makePost(e,t){const n=Ao(e);return new ao(t,n)}toString(){return".value"}};
|
|
2400
|
+
/**
|
|
2401
|
+
* @license
|
|
2402
|
+
* Copyright 2017 Google LLC
|
|
2403
|
+
*
|
|
2404
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2405
|
+
* you may not use this file except in compliance with the License.
|
|
2406
|
+
* You may obtain a copy of the License at
|
|
2407
|
+
*
|
|
2408
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2409
|
+
*
|
|
2410
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2411
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2412
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2413
|
+
* See the License for the specific language governing permissions and
|
|
2414
|
+
* limitations under the License.
|
|
2415
|
+
*/function jo(e){return{type:"value",snapshotNode:e}}function Fo(e,t){return{type:"child_added",snapshotNode:t,childName:e}}function zo(e,t){return{type:"child_removed",snapshotNode:t,childName:e}}function Uo(e,t,n){return{type:"child_changed",snapshotNode:t,childName:e,oldSnap:n}}
|
|
2416
|
+
/**
|
|
2417
|
+
* @license
|
|
2418
|
+
* Copyright 2017 Google LLC
|
|
2419
|
+
*
|
|
2420
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2421
|
+
* you may not use this file except in compliance with the License.
|
|
2422
|
+
* You may obtain a copy of the License at
|
|
2423
|
+
*
|
|
2424
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2425
|
+
*
|
|
2426
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2427
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2428
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2429
|
+
* See the License for the specific language governing permissions and
|
|
2430
|
+
* limitations under the License.
|
|
2431
|
+
*/
|
|
2432
|
+
class $o{constructor(e){this.index_=e}updateChild(e,t,n,i,r,s){h(e.isIndexed(this.index_),"A node must be indexed if only a child is updated");const a=e.getImmediateChild(t);return a.getChild(i).equals(n.getChild(i))&&a.isEmpty()===n.isEmpty()?e:(null!=s&&(n.isEmpty()?e.hasChild(t)?s.trackChildChange(zo(t,a)):h(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?s.trackChildChange(Fo(t,n)):s.trackChildChange(Uo(t,n,a))),e.isLeafNode()&&n.isEmpty()?e:e.updateImmediateChild(t,n).withIndex(this.index_))}updateFullNode(e,t,n){return null!=n&&(e.isLeafNode()||e.forEachChild(So,(e,i)=>{t.hasChild(e)||n.trackChildChange(zo(e,i))}),t.isLeafNode()||t.forEachChild(So,(t,i)=>{if(e.hasChild(t)){const r=e.getImmediateChild(t);r.equals(i)||n.trackChildChange(Uo(t,i,r))}else n.trackChildChange(Fo(t,i))})),t.withIndex(this.index_)}updatePriority(e,t){return e.isEmpty()?No.EMPTY_NODE:e.updatePriority(t)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}
|
|
2433
|
+
/**
|
|
2434
|
+
* @license
|
|
2435
|
+
* Copyright 2017 Google LLC
|
|
2436
|
+
*
|
|
2437
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2438
|
+
* you may not use this file except in compliance with the License.
|
|
2439
|
+
* You may obtain a copy of the License at
|
|
2440
|
+
*
|
|
2441
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2442
|
+
*
|
|
2443
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2444
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2445
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2446
|
+
* See the License for the specific language governing permissions and
|
|
2447
|
+
* limitations under the License.
|
|
2448
|
+
*/class qo{constructor(e){this.indexedFilter_=new $o(e.getIndex()),this.index_=e.getIndex(),this.startPost_=qo.getStartPost_(e),this.endPost_=qo.getEndPost_(e),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}getStartPost(){return this.startPost_}getEndPost(){return this.endPost_}matches(e){const t=this.startIsInclusive_?this.index_.compare(this.getStartPost(),e)<=0:this.index_.compare(this.getStartPost(),e)<0,n=this.endIsInclusive_?this.index_.compare(e,this.getEndPost())<=0:this.index_.compare(e,this.getEndPost())<0;return t&&n}updateChild(e,t,n,i,r,s){return this.matches(new ao(t,n))||(n=No.EMPTY_NODE),this.indexedFilter_.updateChild(e,t,n,i,r,s)}updateFullNode(e,t,n){t.isLeafNode()&&(t=No.EMPTY_NODE);let i=t.withIndex(this.index_);i=i.updatePriority(No.EMPTY_NODE);const r=this;return t.forEachChild(So,(e,t)=>{r.matches(new ao(e,t))||(i=i.updateImmediateChild(e,No.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(e,i,n)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.indexedFilter_}getIndex(){return this.index_}static getStartPost_(e){if(e.hasStart()){const t=e.getIndexStartName();return e.getIndex().makePost(e.getIndexStartValue(),t)}return e.getIndex().minPost()}static getEndPost_(e){if(e.hasEnd()){const t=e.getIndexEndName();return e.getIndex().makePost(e.getIndexEndValue(),t)}return e.getIndex().maxPost()}}
|
|
2449
|
+
/**
|
|
2450
|
+
* @license
|
|
2451
|
+
* Copyright 2017 Google LLC
|
|
2452
|
+
*
|
|
2453
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2454
|
+
* you may not use this file except in compliance with the License.
|
|
2455
|
+
* You may obtain a copy of the License at
|
|
2456
|
+
*
|
|
2457
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2458
|
+
*
|
|
2459
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2460
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2461
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2462
|
+
* See the License for the specific language governing permissions and
|
|
2463
|
+
* limitations under the License.
|
|
2464
|
+
*/class Bo{constructor(e){this.withinDirectionalStart=e=>this.reverse_?this.withinEndPost(e):this.withinStartPost(e),this.withinDirectionalEnd=e=>this.reverse_?this.withinStartPost(e):this.withinEndPost(e),this.withinStartPost=e=>{const t=this.index_.compare(this.rangedFilter_.getStartPost(),e);return this.startIsInclusive_?t<=0:t<0},this.withinEndPost=e=>{const t=this.index_.compare(e,this.rangedFilter_.getEndPost());return this.endIsInclusive_?t<=0:t<0},this.rangedFilter_=new qo(e),this.index_=e.getIndex(),this.limit_=e.getLimit(),this.reverse_=!e.isViewFromLeft(),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}updateChild(e,t,n,i,r,s){return this.rangedFilter_.matches(new ao(t,n))||(n=No.EMPTY_NODE),e.getImmediateChild(t).equals(n)?e:e.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(e,t,n,i,r,s):this.fullLimitUpdateChild_(e,t,n,r,s)}updateFullNode(e,t,n){let i;if(t.isLeafNode()||t.isEmpty())i=No.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_<t.numChildren()&&t.isIndexed(this.index_)){let e;i=No.EMPTY_NODE.withIndex(this.index_),e=this.reverse_?t.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):t.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);let n=0;for(;e.hasNext()&&n<this.limit_;){const t=e.getNext();if(this.withinDirectionalStart(t)){if(!this.withinDirectionalEnd(t))break;i=i.updateImmediateChild(t.name,t.node),n++}}}else{let e;i=t.withIndex(this.index_),i=i.updatePriority(No.EMPTY_NODE),e=this.reverse_?i.getReverseIterator(this.index_):i.getIterator(this.index_);let n=0;for(;e.hasNext();){const t=e.getNext();n<this.limit_&&this.withinDirectionalStart(t)&&this.withinDirectionalEnd(t)?n++:i=i.updateImmediateChild(t.name,No.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(e,i,n)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.rangedFilter_.getIndexedFilter()}getIndex(){return this.index_}fullLimitUpdateChild_(e,t,n,i,r){let s;if(this.reverse_){const e=this.index_.getCompare();s=(t,n)=>e(n,t)}else s=this.index_.getCompare();const a=e;h(a.numChildren()===this.limit_,"");const o=new ao(t,n),l=this.reverse_?a.getFirstChild(this.index_):a.getLastChild(this.index_),c=this.rangedFilter_.matches(o);if(a.hasChild(t)){const e=a.getImmediateChild(t);let u=i.getChildAfterChild(this.index_,l,this.reverse_);for(;null!=u&&(u.name===t||a.hasChild(u.name));)u=i.getChildAfterChild(this.index_,u,this.reverse_);const h=null==u?1:s(u,o);if(c&&!n.isEmpty()&&h>=0)return null!=r&&r.trackChildChange(Uo(t,n,e)),a.updateImmediateChild(t,n);{null!=r&&r.trackChildChange(zo(t,e));const n=a.updateImmediateChild(t,No.EMPTY_NODE);return null!=u&&this.rangedFilter_.matches(u)?(null!=r&&r.trackChildChange(Fo(u.name,u.node)),n.updateImmediateChild(u.name,u.node)):n}}return n.isEmpty()?e:c&&s(l,o)>=0?(null!=r&&(r.trackChildChange(zo(l.name,l.node)),r.trackChildChange(Fo(t,n))),a.updateImmediateChild(t,n).updateImmediateChild(l.name,No.EMPTY_NODE)):e}}
|
|
2465
|
+
/**
|
|
2466
|
+
* @license
|
|
2467
|
+
* Copyright 2017 Google LLC
|
|
2468
|
+
*
|
|
2469
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2470
|
+
* you may not use this file except in compliance with the License.
|
|
2471
|
+
* You may obtain a copy of the License at
|
|
2472
|
+
*
|
|
2473
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2474
|
+
*
|
|
2475
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2476
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2477
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2478
|
+
* See the License for the specific language governing permissions and
|
|
2479
|
+
* limitations under the License.
|
|
2480
|
+
*/class Vo{constructor(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=So}hasStart(){return this.startSet_}isViewFromLeft(){return""===this.viewFrom_?this.startSet_:"l"===this.viewFrom_}getIndexStartValue(){return h(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return h(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:ia}hasEnd(){return this.endSet_}getIndexEndValue(){return h(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return h(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:ra}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&""!==this.viewFrom_}getLimit(){return h(this.limitSet_,"Only valid if limit has been set"),this.limit_}getIndex(){return this.index_}loadsAllData(){return!(this.startSet_||this.endSet_||this.limitSet_)}isDefault(){return this.loadsAllData()&&this.index_===So}copy(){const e=new Vo;return e.limitSet_=this.limitSet_,e.limit_=this.limit_,e.startSet_=this.startSet_,e.startAfterSet_=this.startAfterSet_,e.indexStartValue_=this.indexStartValue_,e.startNameSet_=this.startNameSet_,e.indexStartName_=this.indexStartName_,e.endSet_=this.endSet_,e.endBeforeSet_=this.endBeforeSet_,e.indexEndValue_=this.indexEndValue_,e.endNameSet_=this.endNameSet_,e.indexEndName_=this.indexEndName_,e.index_=this.index_,e.viewFrom_=this.viewFrom_,e}}function Ho(e){const t={};if(e.isDefault())return t;let n;if(e.index_===So?n="$priority":e.index_===Oo?n="$value":e.index_===uo?n="$key":(h(e.index_ instanceof Mo,"Unrecognized index type!"),n=e.index_.toString()),t.orderBy=B(n),e.startSet_){const n=e.startAfterSet_?"startAfter":"startAt";t[n]=B(e.indexStartValue_),e.startNameSet_&&(t[n]+=","+B(e.indexStartName_))}if(e.endSet_){const n=e.endBeforeSet_?"endBefore":"endAt";t[n]=B(e.indexEndValue_),e.endNameSet_&&(t[n]+=","+B(e.indexEndName_))}return e.limitSet_&&(e.isViewFromLeft()?t.limitToFirst=e.limit_:t.limitToLast=e.limit_),t}function Wo(e){const t={};if(e.startSet_&&(t.sp=e.indexStartValue_,e.startNameSet_&&(t.sn=e.indexStartName_),t.sin=!e.startAfterSet_),e.endSet_&&(t.ep=e.indexEndValue_,e.endNameSet_&&(t.en=e.indexEndName_),t.ein=!e.endBeforeSet_),e.limitSet_){t.l=e.limit_;let n=e.viewFrom_;""===n&&(n=e.isViewFromLeft()?"l":"r"),t.vf=n}return e.index_!==So&&(t.i=e.index_.toString()),t}
|
|
2481
|
+
/**
|
|
2482
|
+
* @license
|
|
2483
|
+
* Copyright 2017 Google LLC
|
|
2484
|
+
*
|
|
2485
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2486
|
+
* you may not use this file except in compliance with the License.
|
|
2487
|
+
* You may obtain a copy of the License at
|
|
2488
|
+
*
|
|
2489
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2490
|
+
*
|
|
2491
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2492
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2493
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2494
|
+
* See the License for the specific language governing permissions and
|
|
2495
|
+
* limitations under the License.
|
|
2496
|
+
*/class Go extends ja{reportStats(e){throw new Error("Method not implemented.")}static getListenId_(e,t){return void 0!==t?"tag$"+t:(h(e._queryParams.isDefault(),"should have a tag if it's not a default query."),e._path.toString())}constructor(e,t,n,i){super(),this.repoInfo_=e,this.onDataUpdate_=t,this.authTokenProvider_=n,this.appCheckTokenProvider_=i,this.log_=Xs("p:rest:"),this.listens_={}}listen(e,t,n,i){const r=e._path.toString();this.log_("Listen called for "+r+" "+e._queryIdentifier);const s=Go.getListenId_(e,n),a={};this.listens_[s]=a;const o=Ho(e._queryParams);this.restRequest_(r+".json",o,(e,t)=>{let o=t;if(404===e&&(o=null,e=null),null===e&&this.onDataUpdate_(r,o,!1,n),W(this.listens_,s)===a){let t;t=e?401===e?"permission_denied":"rest_error:"+e:"ok",i(t,null)}})}unlisten(e,t){const n=Go.getListenId_(e,t);delete this.listens_[n]}get(e){const t=Ho(e._queryParams),n=e._path.toString(),i=new E;return this.restRequest_(n+".json",t,(e,t)=>{let r=t;404===e&&(r=null,e=null),null===e?(this.onDataUpdate_(n,r,!1,null),i.resolve(r)):i.reject(new Error(r))}),i.promise}refreshAuthToken(e){}restRequest_(e,t={},n){return t.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then(([i,r])=>{i&&i.accessToken&&(t.auth=i.accessToken),r&&r.token&&(t.ac=r.token);const s=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+e+"?ns="+this.repoInfo_.namespace+Z(t);this.log_("Sending REST request for "+s);const a=new XMLHttpRequest;a.onreadystatechange=()=>{if(n&&4===a.readyState){this.log_("REST Response for "+s+" received. status:",a.status,"response:",a.responseText);let e=null;if(a.status>=200&&a.status<300){try{e=q(a.responseText)}catch(e){ta("Failed to parse JSON response for "+s+": "+a.responseText)}n(null,e)}else 401!==a.status&&404!==a.status&&ta("Got unsuccessful REST response for "+s+" Status: "+a.status),n(a.status);n=null}},a.open("GET",s,!0),a.send()})}}
|
|
2497
|
+
/**
|
|
2498
|
+
* @license
|
|
2499
|
+
* Copyright 2017 Google LLC
|
|
2500
|
+
*
|
|
2501
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2502
|
+
* you may not use this file except in compliance with the License.
|
|
2503
|
+
* You may obtain a copy of the License at
|
|
2504
|
+
*
|
|
2505
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2506
|
+
*
|
|
2507
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2508
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2509
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2510
|
+
* See the License for the specific language governing permissions and
|
|
2511
|
+
* limitations under the License.
|
|
2512
|
+
*/class Ko{constructor(){this.rootNode_=No.EMPTY_NODE}getNode(e){return this.rootNode_.getChild(e)}updateSnapshot(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)}}
|
|
2513
|
+
/**
|
|
2514
|
+
* @license
|
|
2515
|
+
* Copyright 2017 Google LLC
|
|
2516
|
+
*
|
|
2517
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2518
|
+
* you may not use this file except in compliance with the License.
|
|
2519
|
+
* You may obtain a copy of the License at
|
|
2520
|
+
*
|
|
2521
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2522
|
+
*
|
|
2523
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2524
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2525
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2526
|
+
* See the License for the specific language governing permissions and
|
|
2527
|
+
* limitations under the License.
|
|
2528
|
+
*/function Yo(){return{value:null,children:new Map}}function Jo(e,t,n){if(Ya(t))e.value=n,e.children.clear();else if(null!==e.value)e.value=e.value.updateChild(t,n);else{const i=qa(t);e.children.has(i)||e.children.set(i,Yo());Jo(e.children.get(i),t=Va(t),n)}}function Zo(e,t){if(Ya(t))return e.value=null,e.children.clear(),!0;if(null!==e.value){if(e.value.isLeafNode())return!1;{const n=e.value;return e.value=null,n.forEachChild(So,(t,n)=>{Jo(e,new Ua(t),n)}),Zo(e,t)}}if(e.children.size>0){const n=qa(t);if(t=Va(t),e.children.has(n)){Zo(e.children.get(n),t)&&e.children.delete(n)}return 0===e.children.size}return!0}function Xo(e,t,n){null!==e.value?n(t,e.value):function(e,t){e.children.forEach((e,n)=>{t(n,e)})}
|
|
2529
|
+
/**
|
|
2530
|
+
* @license
|
|
2531
|
+
* Copyright 2017 Google LLC
|
|
2532
|
+
*
|
|
2533
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2534
|
+
* you may not use this file except in compliance with the License.
|
|
2535
|
+
* You may obtain a copy of the License at
|
|
2536
|
+
*
|
|
2537
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2538
|
+
*
|
|
2539
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2540
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2541
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2542
|
+
* See the License for the specific language governing permissions and
|
|
2543
|
+
* limitations under the License.
|
|
2544
|
+
*/(e,(e,i)=>{Xo(i,new Ua(t.toString()+"/"+e),n)})}class Qo{constructor(e){this.collection_=e,this.last_=null}get(){const e=this.collection_.get(),t={...e};return this.last_&&ua(this.last_,(e,n)=>{t[e]=t[e]-n}),this.last_=e,t}}
|
|
2545
|
+
/**
|
|
2546
|
+
* @license
|
|
2547
|
+
* Copyright 2017 Google LLC
|
|
2548
|
+
*
|
|
2549
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2550
|
+
* you may not use this file except in compliance with the License.
|
|
2551
|
+
* You may obtain a copy of the License at
|
|
2552
|
+
*
|
|
2553
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2554
|
+
*
|
|
2555
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2556
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2557
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2558
|
+
* See the License for the specific language governing permissions and
|
|
2559
|
+
* limitations under the License.
|
|
2560
|
+
*/class el{constructor(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new Qo(e);const n=1e4+2e4*Math.random();fa(this.reportStats_.bind(this),Math.floor(n))}reportStats_(){const e=this.statsListener_.get(),t={};let n=!1;ua(e,(e,i)=>{i>0&&H(this.statsToReport_,e)&&(t[e]=i,n=!0)}),n&&this.server_.reportStats(t),fa(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))}}
|
|
2561
|
+
/**
|
|
2562
|
+
* @license
|
|
2563
|
+
* Copyright 2017 Google LLC
|
|
2564
|
+
*
|
|
2565
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2566
|
+
* you may not use this file except in compliance with the License.
|
|
2567
|
+
* You may obtain a copy of the License at
|
|
2568
|
+
*
|
|
2569
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2570
|
+
*
|
|
2571
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2572
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2573
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2574
|
+
* See the License for the specific language governing permissions and
|
|
2575
|
+
* limitations under the License.
|
|
2576
|
+
*/var tl;function nl(e){return{fromUser:!1,fromServer:!0,queryId:e,tagged:!0}}
|
|
2577
|
+
/**
|
|
2578
|
+
* @license
|
|
2579
|
+
* Copyright 2017 Google LLC
|
|
2580
|
+
*
|
|
2581
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2582
|
+
* you may not use this file except in compliance with the License.
|
|
2583
|
+
* You may obtain a copy of the License at
|
|
2584
|
+
*
|
|
2585
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2586
|
+
*
|
|
2587
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2588
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2589
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2590
|
+
* See the License for the specific language governing permissions and
|
|
2591
|
+
* limitations under the License.
|
|
2592
|
+
*/!function(e){e[e.OVERWRITE=0]="OVERWRITE",e[e.MERGE=1]="MERGE",e[e.ACK_USER_WRITE=2]="ACK_USER_WRITE",e[e.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"}(tl||(tl={}));class il{constructor(e,t,n){this.path=e,this.affectedTree=t,this.revert=n,this.type=tl.ACK_USER_WRITE,this.source={fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}operationForChild(e){if(Ya(this.path)){if(null!=this.affectedTree.value)return h(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const t=this.affectedTree.subtree(new Ua(e));return new il($a(),t,this.revert)}}return h(qa(this.path)===e,"operationForChild called for unrelated child."),new il(Va(this.path),this.affectedTree,this.revert)}}
|
|
2593
|
+
/**
|
|
2594
|
+
* @license
|
|
2595
|
+
* Copyright 2017 Google LLC
|
|
2596
|
+
*
|
|
2597
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2598
|
+
* you may not use this file except in compliance with the License.
|
|
2599
|
+
* You may obtain a copy of the License at
|
|
2600
|
+
*
|
|
2601
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2602
|
+
*
|
|
2603
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2604
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2605
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2606
|
+
* See the License for the specific language governing permissions and
|
|
2607
|
+
* limitations under the License.
|
|
2608
|
+
*/class rl{constructor(e,t){this.source=e,this.path=t,this.type=tl.LISTEN_COMPLETE}operationForChild(e){return Ya(this.path)?new rl(this.source,$a()):new rl(this.source,Va(this.path))}}
|
|
2609
|
+
/**
|
|
2610
|
+
* @license
|
|
2611
|
+
* Copyright 2017 Google LLC
|
|
2612
|
+
*
|
|
2613
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2614
|
+
* you may not use this file except in compliance with the License.
|
|
2615
|
+
* You may obtain a copy of the License at
|
|
2616
|
+
*
|
|
2617
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2618
|
+
*
|
|
2619
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2620
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2621
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2622
|
+
* See the License for the specific language governing permissions and
|
|
2623
|
+
* limitations under the License.
|
|
2624
|
+
*/class sl{constructor(e,t,n){this.source=e,this.path=t,this.snap=n,this.type=tl.OVERWRITE}operationForChild(e){return Ya(this.path)?new sl(this.source,$a(),this.snap.getImmediateChild(e)):new sl(this.source,Va(this.path),this.snap)}}
|
|
2625
|
+
/**
|
|
2626
|
+
* @license
|
|
2627
|
+
* Copyright 2017 Google LLC
|
|
2628
|
+
*
|
|
2629
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2630
|
+
* you may not use this file except in compliance with the License.
|
|
2631
|
+
* You may obtain a copy of the License at
|
|
2632
|
+
*
|
|
2633
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2634
|
+
*
|
|
2635
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2636
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2637
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2638
|
+
* See the License for the specific language governing permissions and
|
|
2639
|
+
* limitations under the License.
|
|
2640
|
+
*/class al{constructor(e,t,n){this.source=e,this.path=t,this.children=n,this.type=tl.MERGE}operationForChild(e){if(Ya(this.path)){const t=this.children.subtree(new Ua(e));return t.isEmpty()?null:t.value?new sl(this.source,$a(),t.value):new al(this.source,$a(),t)}return h(qa(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new al(this.source,Va(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}
|
|
2641
|
+
/**
|
|
2642
|
+
* @license
|
|
2643
|
+
* Copyright 2017 Google LLC
|
|
2644
|
+
*
|
|
2645
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2646
|
+
* you may not use this file except in compliance with the License.
|
|
2647
|
+
* You may obtain a copy of the License at
|
|
2648
|
+
*
|
|
2649
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2650
|
+
*
|
|
2651
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2652
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2653
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2654
|
+
* See the License for the specific language governing permissions and
|
|
2655
|
+
* limitations under the License.
|
|
2656
|
+
*/class ol{constructor(e,t,n){this.node_=e,this.fullyInitialized_=t,this.filtered_=n}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(Ya(e))return this.isFullyInitialized()&&!this.filtered_;const t=qa(e);return this.isCompleteForChild(t)}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}
|
|
2657
|
+
/**
|
|
2658
|
+
* @license
|
|
2659
|
+
* Copyright 2017 Google LLC
|
|
2660
|
+
*
|
|
2661
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2662
|
+
* you may not use this file except in compliance with the License.
|
|
2663
|
+
* You may obtain a copy of the License at
|
|
2664
|
+
*
|
|
2665
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2666
|
+
*
|
|
2667
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2668
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2669
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2670
|
+
* See the License for the specific language governing permissions and
|
|
2671
|
+
* limitations under the License.
|
|
2672
|
+
*/class ll{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function cl(e,t,n,i,r,s){const a=i.filter(e=>e.type===n);a.sort((t,n)=>function(e,t,n){if(null==t.childName||null==n.childName)throw d("Should only compare child_ events.");const i=new ao(t.childName,t.snapshotNode),r=new ao(n.childName,n.snapshotNode);return e.index_.compare(i,r)}
|
|
2673
|
+
/**
|
|
2674
|
+
* @license
|
|
2675
|
+
* Copyright 2017 Google LLC
|
|
2676
|
+
*
|
|
2677
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2678
|
+
* you may not use this file except in compliance with the License.
|
|
2679
|
+
* You may obtain a copy of the License at
|
|
2680
|
+
*
|
|
2681
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2682
|
+
*
|
|
2683
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2684
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2685
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2686
|
+
* See the License for the specific language governing permissions and
|
|
2687
|
+
* limitations under the License.
|
|
2688
|
+
*/(e,t,n)),a.forEach(n=>{const i=function(e,t,n){return"value"===t.type||"child_removed"===t.type||(t.prevName=n.getPredecessorChildName(t.childName,t.snapshotNode,e.index_)),t}(e,n,s);r.forEach(r=>{r.respondsTo(n.type)&&t.push(r.createEvent(i,e.query_))})})}function ul(e,t){return{eventCache:e,serverCache:t}}function hl(e,t,n,i){return ul(new ol(t,n,i),e.serverCache)}function dl(e,t,n,i){return ul(e.eventCache,new ol(t,n,i))}function pl(e){return e.eventCache.isFullyInitialized()?e.eventCache.getNode():null}function gl(e){return e.serverCache.isFullyInitialized()?e.serverCache.getNode():null}
|
|
2689
|
+
/**
|
|
2690
|
+
* @license
|
|
2691
|
+
* Copyright 2017 Google LLC
|
|
2692
|
+
*
|
|
2693
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2694
|
+
* you may not use this file except in compliance with the License.
|
|
2695
|
+
* You may obtain a copy of the License at
|
|
2696
|
+
*
|
|
2697
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2698
|
+
*
|
|
2699
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2700
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2701
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2702
|
+
* See the License for the specific language governing permissions and
|
|
2703
|
+
* limitations under the License.
|
|
2704
|
+
*/let fl;class ml{static fromObject(e){let t=new ml(null);return ua(e,(e,n)=>{t=t.set(new Ua(e),n)}),t}constructor(e,t=(()=>(fl||(fl=new go(aa)),fl))()){this.value=e,this.children=t}isEmpty(){return null===this.value&&this.children.isEmpty()}findRootMostMatchingPathAndValue(e,t){if(null!=this.value&&t(this.value))return{path:$a(),value:this.value};if(Ya(e))return null;{const n=qa(e),i=this.children.get(n);if(null!==i){const r=i.findRootMostMatchingPathAndValue(Va(e),t);if(null!=r){return{path:Ka(new Ua(n),r.path),value:r.value}}return null}return null}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,()=>!0)}subtree(e){if(Ya(e))return this;{const t=qa(e),n=this.children.get(t);return null!==n?n.subtree(Va(e)):new ml(null)}}set(e,t){if(Ya(e))return new ml(t,this.children);{const n=qa(e),i=(this.children.get(n)||new ml(null)).set(Va(e),t),r=this.children.insert(n,i);return new ml(this.value,r)}}remove(e){if(Ya(e))return this.children.isEmpty()?new ml(null):new ml(null,this.children);{const t=qa(e),n=this.children.get(t);if(n){const i=n.remove(Va(e));let r;return r=i.isEmpty()?this.children.remove(t):this.children.insert(t,i),null===this.value&&r.isEmpty()?new ml(null):new ml(this.value,r)}return this}}get(e){if(Ya(e))return this.value;{const t=qa(e),n=this.children.get(t);return n?n.get(Va(e)):null}}setTree(e,t){if(Ya(e))return t;{const n=qa(e),i=(this.children.get(n)||new ml(null)).setTree(Va(e),t);let r;return r=i.isEmpty()?this.children.remove(n):this.children.insert(n,i),new ml(this.value,r)}}fold(e){return this.fold_($a(),e)}fold_(e,t){const n={};return this.children.inorderTraversal((i,r)=>{n[i]=r.fold_(Ka(e,i),t)}),t(e,this.value,n)}findOnPath(e,t){return this.findOnPath_(e,$a(),t)}findOnPath_(e,t,n){const i=!!this.value&&n(t,this.value);if(i)return i;if(Ya(e))return null;{const i=qa(e),r=this.children.get(i);return r?r.findOnPath_(Va(e),Ka(t,i),n):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,$a(),t)}foreachOnPath_(e,t,n){if(Ya(e))return this;{this.value&&n(t,this.value);const i=qa(e),r=this.children.get(i);return r?r.foreachOnPath_(Va(e),Ka(t,i),n):new ml(null)}}foreach(e){this.foreach_($a(),e)}foreach_(e,t){this.children.inorderTraversal((n,i)=>{i.foreach_(Ka(e,n),t)}),this.value&&t(e,this.value)}foreachChild(e){this.children.inorderTraversal((t,n)=>{n.value&&e(t,n.value)})}}
|
|
2705
|
+
/**
|
|
2706
|
+
* @license
|
|
2707
|
+
* Copyright 2017 Google LLC
|
|
2708
|
+
*
|
|
2709
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2710
|
+
* you may not use this file except in compliance with the License.
|
|
2711
|
+
* You may obtain a copy of the License at
|
|
2712
|
+
*
|
|
2713
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2714
|
+
*
|
|
2715
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2716
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2717
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2718
|
+
* See the License for the specific language governing permissions and
|
|
2719
|
+
* limitations under the License.
|
|
2720
|
+
*/class vl{constructor(e){this.writeTree_=e}static empty(){return new vl(new ml(null))}}function yl(e,t,n){if(Ya(t))return new vl(new ml(n));{const i=e.writeTree_.findRootMostValueAndPath(t);if(null!=i){const r=i.path;let s=i.value;const a=Ja(r,t);return s=s.updateChild(a,n),new vl(e.writeTree_.set(r,s))}{const i=new ml(n),r=e.writeTree_.setTree(t,i);return new vl(r)}}}function wl(e,t,n){let i=e;return ua(n,(e,n)=>{i=yl(i,Ka(t,e),n)}),i}function bl(e,t){if(Ya(t))return vl.empty();{const n=e.writeTree_.setTree(t,new ml(null));return new vl(n)}}function _l(e,t){return null!=kl(e,t)}function kl(e,t){const n=e.writeTree_.findRootMostValueAndPath(t);return null!=n?e.writeTree_.get(n.path).getChild(Ja(n.path,t)):null}function Cl(e){const t=[],n=e.writeTree_.value;return null!=n?n.isLeafNode()||n.forEachChild(So,(e,n)=>{t.push(new ao(e,n))}):e.writeTree_.children.inorderTraversal((e,n)=>{null!=n.value&&t.push(new ao(e,n.value))}),t}function Sl(e,t){if(Ya(t))return e;{const n=kl(e,t);return new vl(null!=n?new ml(n):e.writeTree_.subtree(t))}}function Tl(e){return e.writeTree_.isEmpty()}function Il(e,t){return El($a(),e.writeTree_,t)}function El(e,t,n){if(null!=t.value)return n.updateChild(e,t.value);{let i=null;return t.children.inorderTraversal((t,r)=>{".priority"===t?(h(null!==r.value,"Priority writes must always be leaf nodes"),i=r.value):n=El(Ka(e,t),r,n)}),n.getChild(e).isEmpty()||null===i||(n=n.updateChild(Ka(e,".priority"),i)),n}}
|
|
2721
|
+
/**
|
|
2722
|
+
* @license
|
|
2723
|
+
* Copyright 2017 Google LLC
|
|
2724
|
+
*
|
|
2725
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2726
|
+
* you may not use this file except in compliance with the License.
|
|
2727
|
+
* You may obtain a copy of the License at
|
|
2728
|
+
*
|
|
2729
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2730
|
+
*
|
|
2731
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2732
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2733
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2734
|
+
* See the License for the specific language governing permissions and
|
|
2735
|
+
* limitations under the License.
|
|
2736
|
+
*/function Pl(e,t){return $l(t,e)}function xl(e,t){const n=e.allWrites.findIndex(e=>e.writeId===t);h(n>=0,"removeWrite called with nonexistent writeId.");const i=e.allWrites[n];e.allWrites.splice(n,1);let r=i.visible,s=!1,a=e.allWrites.length-1;for(;r&&a>=0;){const t=e.allWrites[a];t.visible&&(a>=n&&Rl(t,i.path)?r=!1:Qa(i.path,t.path)&&(s=!0)),a--}if(r){if(s)return function(e){e.visibleWrites=Nl(e.allWrites,Ll,$a()),e.allWrites.length>0?e.lastWriteId=e.allWrites[e.allWrites.length-1].writeId:e.lastWriteId=-1}(e),!0;if(i.snap)e.visibleWrites=bl(e.visibleWrites,i.path);else{ua(i.children,t=>{e.visibleWrites=bl(e.visibleWrites,Ka(i.path,t))})}return!0}return!1}function Rl(e,t){if(e.snap)return Qa(e.path,t);for(const n in e.children)if(e.children.hasOwnProperty(n)&&Qa(Ka(e.path,n),t))return!0;return!1}function Ll(e){return e.visible}function Nl(e,t,n){let i=vl.empty();for(let r=0;r<e.length;++r){const s=e[r];if(t(s)){const e=s.path;let t;if(s.snap)Qa(n,e)?(t=Ja(n,e),i=yl(i,t,s.snap)):Qa(e,n)&&(t=Ja(e,n),i=yl(i,$a(),s.snap.getChild(t)));else{if(!s.children)throw d("WriteRecord should have .snap or .children");if(Qa(n,e))t=Ja(n,e),i=wl(i,t,s.children);else if(Qa(e,n))if(t=Ja(e,n),Ya(t))i=wl(i,$a(),s.children);else{const e=W(s.children,qa(t));if(e){const n=e.getChild(Va(t));i=yl(i,$a(),n)}}}}}return i}function Dl(e,t,n,i,r){if(i||r){const s=Sl(e.visibleWrites,t);if(!r&&Tl(s))return n;if(r||null!=n||_l(s,$a())){const s=function(e){return(e.visible||r)&&(!i||!~i.indexOf(e.writeId))&&(Qa(e.path,t)||Qa(t,e.path))};return Il(Nl(e.allWrites,s,t),n||No.EMPTY_NODE)}return null}{const i=kl(e.visibleWrites,t);if(null!=i)return i;{const i=Sl(e.visibleWrites,t);if(Tl(i))return n;if(null!=n||_l(i,$a())){return Il(i,n||No.EMPTY_NODE)}return null}}}function Al(e,t,n,i){return Dl(e.writeTree,e.treePath,t,n,i)}function Ml(e,t){return function(e,t,n){let i=No.EMPTY_NODE;const r=kl(e.visibleWrites,t);if(r)return r.isLeafNode()||r.forEachChild(So,(e,t)=>{i=i.updateImmediateChild(e,t)}),i;if(n){const r=Sl(e.visibleWrites,t);return n.forEachChild(So,(e,t)=>{const n=Il(Sl(r,new Ua(e)),t);i=i.updateImmediateChild(e,n)}),Cl(r).forEach(e=>{i=i.updateImmediateChild(e.name,e.node)}),i}return Cl(Sl(e.visibleWrites,t)).forEach(e=>{i=i.updateImmediateChild(e.name,e.node)}),i}(e.writeTree,e.treePath,t)}function Ol(e,t,n,i){return function(e,t,n,i,r){h(i||r,"Either existingEventSnap or existingServerSnap must exist");const s=Ka(t,n);if(_l(e.visibleWrites,s))return null;{const t=Sl(e.visibleWrites,s);return Tl(t)?r.getChild(n):Il(t,r.getChild(n))}}(e.writeTree,e.treePath,t,n,i)}function jl(e,t){return function(e,t){return kl(e.visibleWrites,t)}(e.writeTree,Ka(e.treePath,t))}function Fl(e,t,n,i,r,s){return function(e,t,n,i,r,s,a){let o;const l=Sl(e.visibleWrites,t),c=kl(l,$a());if(null!=c)o=c;else{if(null==n)return[];o=Il(l,n)}if(o=o.withIndex(a),o.isEmpty()||o.isLeafNode())return[];{const e=[],t=a.getCompare(),n=s?o.getReverseIteratorFrom(i,a):o.getIteratorFrom(i,a);let l=n.getNext();for(;l&&e.length<r;)0!==t(l,i)&&e.push(l),l=n.getNext();return e}}(e.writeTree,e.treePath,t,n,i,r,s)}function zl(e,t,n){return function(e,t,n,i){const r=Ka(t,n),s=kl(e.visibleWrites,r);if(null!=s)return s;if(i.isCompleteForChild(n))return Il(Sl(e.visibleWrites,r),i.getNode().getImmediateChild(n));return null}(e.writeTree,e.treePath,t,n)}function Ul(e,t){return $l(Ka(e.treePath,t),e.writeTree)}function $l(e,t){return{treePath:e,writeTree:t}}
|
|
2737
|
+
/**
|
|
2738
|
+
* @license
|
|
2739
|
+
* Copyright 2017 Google LLC
|
|
2740
|
+
*
|
|
2741
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2742
|
+
* you may not use this file except in compliance with the License.
|
|
2743
|
+
* You may obtain a copy of the License at
|
|
2744
|
+
*
|
|
2745
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2746
|
+
*
|
|
2747
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2748
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2749
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2750
|
+
* See the License for the specific language governing permissions and
|
|
2751
|
+
* limitations under the License.
|
|
2752
|
+
*/class ql{constructor(){this.changeMap=new Map}trackChildChange(e){const t=e.type,n=e.childName;h("child_added"===t||"child_changed"===t||"child_removed"===t,"Only child changes supported for tracking"),h(".priority"!==n,"Only non-priority child changes can be tracked.");const i=this.changeMap.get(n);if(i){const r=i.type;if("child_added"===t&&"child_removed"===r)this.changeMap.set(n,Uo(n,e.snapshotNode,i.snapshotNode));else if("child_removed"===t&&"child_added"===r)this.changeMap.delete(n);else if("child_removed"===t&&"child_changed"===r)this.changeMap.set(n,zo(n,i.oldSnap));else if("child_changed"===t&&"child_added"===r)this.changeMap.set(n,Fo(n,e.snapshotNode));else{if("child_changed"!==t||"child_changed"!==r)throw d("Illegal combination of changes: "+e+" occurred after "+i);this.changeMap.set(n,Uo(n,e.snapshotNode,i.oldSnap))}}else this.changeMap.set(n,e)}getChanges(){return Array.from(this.changeMap.values())}}
|
|
2753
|
+
/**
|
|
2754
|
+
* @license
|
|
2755
|
+
* Copyright 2017 Google LLC
|
|
2756
|
+
*
|
|
2757
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2758
|
+
* you may not use this file except in compliance with the License.
|
|
2759
|
+
* You may obtain a copy of the License at
|
|
2760
|
+
*
|
|
2761
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2762
|
+
*
|
|
2763
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2764
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2765
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2766
|
+
* See the License for the specific language governing permissions and
|
|
2767
|
+
* limitations under the License.
|
|
2768
|
+
*/const Bl=new class{getCompleteChild(e){return null}getChildAfterChild(e,t,n){return null}};class Vl{constructor(e,t,n=null){this.writes_=e,this.viewCache_=t,this.optCompleteServerCache_=n}getCompleteChild(e){const t=this.viewCache_.eventCache;if(t.isCompleteForChild(e))return t.getNode().getImmediateChild(e);{const t=null!=this.optCompleteServerCache_?new ol(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return zl(this.writes_,e,t)}}getChildAfterChild(e,t,n){const i=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:gl(this.viewCache_),r=Fl(this.writes_,i,t,1,n,e);return 0===r.length?null:r[0]}}
|
|
2769
|
+
/**
|
|
2770
|
+
* @license
|
|
2771
|
+
* Copyright 2017 Google LLC
|
|
2772
|
+
*
|
|
2773
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2774
|
+
* you may not use this file except in compliance with the License.
|
|
2775
|
+
* You may obtain a copy of the License at
|
|
2776
|
+
*
|
|
2777
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2778
|
+
*
|
|
2779
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2780
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2781
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2782
|
+
* See the License for the specific language governing permissions and
|
|
2783
|
+
* limitations under the License.
|
|
2784
|
+
*/function Hl(e,t,n,i,r){const s=new ql;let a,o;if(n.type===tl.OVERWRITE){const l=n;l.source.fromUser?a=Kl(e,t,l.path,l.snap,i,r,s):(h(l.source.fromServer,"Unknown source."),o=l.source.tagged||t.serverCache.isFiltered()&&!Ya(l.path),a=Gl(e,t,l.path,l.snap,i,r,o,s))}else if(n.type===tl.MERGE){const l=n;l.source.fromUser?a=function(e,t,n,i,r,s,a){let o=t;return i.foreach((i,l)=>{const c=Ka(n,i);Yl(t,qa(c))&&(o=Kl(e,o,c,l,r,s,a))}),i.foreach((i,l)=>{const c=Ka(n,i);Yl(t,qa(c))||(o=Kl(e,o,c,l,r,s,a))}),o}(e,t,l.path,l.children,i,r,s):(h(l.source.fromServer,"Unknown source."),o=l.source.tagged||t.serverCache.isFiltered(),a=Zl(e,t,l.path,l.children,i,r,o,s))}else if(n.type===tl.ACK_USER_WRITE){const o=n;a=o.revert?function(e,t,n,i,r,s){let a;if(null!=jl(i,n))return t;{const o=new Vl(i,t,r),l=t.eventCache.getNode();let c;if(Ya(n)||".priority"===qa(n)){let n;if(t.serverCache.isFullyInitialized())n=Al(i,gl(t));else{const e=t.serverCache.getNode();h(e instanceof No,"serverChildren would be complete if leaf node"),n=Ml(i,e)}c=e.filter.updateFullNode(l,n,s)}else{const r=qa(n);let u=zl(i,r,t.serverCache);null==u&&t.serverCache.isCompleteForChild(r)&&(u=l.getImmediateChild(r)),c=null!=u?e.filter.updateChild(l,r,u,Va(n),o,s):t.eventCache.getNode().hasChild(r)?e.filter.updateChild(l,r,No.EMPTY_NODE,Va(n),o,s):l,c.isEmpty()&&t.serverCache.isFullyInitialized()&&(a=Al(i,gl(t)),a.isLeafNode()&&(c=e.filter.updateFullNode(c,a,s)))}return a=t.serverCache.isFullyInitialized()||null!=jl(i,$a()),hl(t,c,a,e.filter.filtersNodes())}}
|
|
2785
|
+
/**
|
|
2786
|
+
* @license
|
|
2787
|
+
* Copyright 2017 Google LLC
|
|
2788
|
+
*
|
|
2789
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2790
|
+
* you may not use this file except in compliance with the License.
|
|
2791
|
+
* You may obtain a copy of the License at
|
|
2792
|
+
*
|
|
2793
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2794
|
+
*
|
|
2795
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2796
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2797
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2798
|
+
* See the License for the specific language governing permissions and
|
|
2799
|
+
* limitations under the License.
|
|
2800
|
+
*/(e,t,o.path,i,r,s):function(e,t,n,i,r,s,a){if(null!=jl(r,n))return t;const o=t.serverCache.isFiltered(),l=t.serverCache;if(null!=i.value){if(Ya(n)&&l.isFullyInitialized()||l.isCompleteForPath(n))return Gl(e,t,n,l.getNode().getChild(n),r,s,o,a);if(Ya(n)){let i=new ml(null);return l.getNode().forEachChild(uo,(e,t)=>{i=i.set(new Ua(e),t)}),Zl(e,t,n,i,r,s,o,a)}return t}{let c=new ml(null);return i.foreach((e,t)=>{const i=Ka(n,e);l.isCompleteForPath(i)&&(c=c.set(e,l.getNode().getChild(i)))}),Zl(e,t,n,c,r,s,o,a)}}(e,t,o.path,o.affectedTree,i,r,s)}else{if(n.type!==tl.LISTEN_COMPLETE)throw d("Unknown operation type: "+n.type);a=function(e,t,n,i,r){const s=t.serverCache,a=dl(t,s.getNode(),s.isFullyInitialized()||Ya(n),s.isFiltered());return Wl(e,a,n,i,Bl,r)}(e,t,n.path,i,s)}const l=s.getChanges();return function(e,t,n){const i=t.eventCache;if(i.isFullyInitialized()){const r=i.getNode().isLeafNode()||i.getNode().isEmpty(),s=pl(e);(n.length>0||!e.eventCache.isFullyInitialized()||r&&!i.getNode().equals(s)||!i.getNode().getPriority().equals(s.getPriority()))&&n.push(jo(pl(t)))}}(t,a,l),{viewCache:a,changes:l}}function Wl(e,t,n,i,r,s){const a=t.eventCache;if(null!=jl(i,n))return t;{let o,l;if(Ya(n))if(h(t.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),t.serverCache.isFiltered()){const n=gl(t),r=Ml(i,n instanceof No?n:No.EMPTY_NODE);o=e.filter.updateFullNode(t.eventCache.getNode(),r,s)}else{const n=Al(i,gl(t));o=e.filter.updateFullNode(t.eventCache.getNode(),n,s)}else{const c=qa(n);if(".priority"===c){h(1===Ba(n),"Can't have a priority with additional path components");const r=a.getNode();l=t.serverCache.getNode();const s=Ol(i,n,r,l);o=null!=s?e.filter.updatePriority(r,s):a.getNode()}else{const u=Va(n);let h;if(a.isCompleteForChild(c)){l=t.serverCache.getNode();const e=Ol(i,n,a.getNode(),l);h=null!=e?a.getNode().getImmediateChild(c).updateChild(u,e):a.getNode().getImmediateChild(c)}else h=zl(i,c,t.serverCache);o=null!=h?e.filter.updateChild(a.getNode(),c,h,u,r,s):a.getNode()}}return hl(t,o,a.isFullyInitialized()||Ya(n),e.filter.filtersNodes())}}function Gl(e,t,n,i,r,s,a,o){const l=t.serverCache;let c;const u=a?e.filter:e.filter.getIndexedFilter();if(Ya(n))c=u.updateFullNode(l.getNode(),i,null);else if(u.filtersNodes()&&!l.isFiltered()){const e=l.getNode().updateChild(n,i);c=u.updateFullNode(l.getNode(),e,null)}else{const e=qa(n);if(!l.isCompleteForPath(n)&&Ba(n)>1)return t;const r=Va(n),s=l.getNode().getImmediateChild(e).updateChild(r,i);c=".priority"===e?u.updatePriority(l.getNode(),s):u.updateChild(l.getNode(),e,s,r,Bl,null)}const h=dl(t,c,l.isFullyInitialized()||Ya(n),u.filtersNodes());return Wl(e,h,n,r,new Vl(r,h,s),o)}function Kl(e,t,n,i,r,s,a){const o=t.eventCache;let l,c;const u=new Vl(r,t,s);if(Ya(n))c=e.filter.updateFullNode(t.eventCache.getNode(),i,a),l=hl(t,c,!0,e.filter.filtersNodes());else{const r=qa(n);if(".priority"===r)c=e.filter.updatePriority(t.eventCache.getNode(),i),l=hl(t,c,o.isFullyInitialized(),o.isFiltered());else{const s=Va(n),c=o.getNode().getImmediateChild(r);let h;if(Ya(s))h=i;else{const e=u.getCompleteChild(r);h=null!=e?".priority"===Ha(s)&&e.getChild(Ga(s)).isEmpty()?e:e.updateChild(s,i):No.EMPTY_NODE}if(c.equals(h))l=t;else{l=hl(t,e.filter.updateChild(o.getNode(),r,h,s,u,a),o.isFullyInitialized(),e.filter.filtersNodes())}}}return l}function Yl(e,t){return e.eventCache.isCompleteForChild(t)}function Jl(e,t,n){return n.foreach((e,n)=>{t=t.updateChild(e,n)}),t}function Zl(e,t,n,i,r,s,a,o){if(t.serverCache.getNode().isEmpty()&&!t.serverCache.isFullyInitialized())return t;let l,c=t;l=Ya(n)?i:new ml(null).setTree(n,i);const u=t.serverCache.getNode();return l.children.inorderTraversal((n,i)=>{if(u.hasChild(n)){const l=Jl(0,t.serverCache.getNode().getImmediateChild(n),i);c=Gl(e,c,new Ua(n),l,r,s,a,o)}}),l.children.inorderTraversal((n,i)=>{const l=!t.serverCache.isCompleteForChild(n)&&null===i.value;if(!u.hasChild(n)&&!l){const l=Jl(0,t.serverCache.getNode().getImmediateChild(n),i);c=Gl(e,c,new Ua(n),l,r,s,a,o)}}),c}let Xl,Ql,ec=class{constructor(e,t){this.query_=e,this.eventRegistrations_=[];const n=this.query_._queryParams,i=new $o(n.getIndex()),r=(s=n).loadsAllData()?new $o(s.getIndex()):s.hasLimit()?new Bo(s):new qo(s);var s;this.processor_=function(e){return{filter:e}}(r);const a=t.serverCache,o=t.eventCache,l=i.updateFullNode(No.EMPTY_NODE,a.getNode(),null),c=r.updateFullNode(No.EMPTY_NODE,o.getNode(),null),u=new ol(l,a.isFullyInitialized(),i.filtersNodes()),h=new ol(c,o.isFullyInitialized(),r.filtersNodes());this.viewCache_=ul(h,u),this.eventGenerator_=new ll(this.query_)}get query(){return this.query_}};function tc(e,t){const n=gl(e.viewCache_);return n&&(e.query._queryParams.loadsAllData()||!Ya(t)&&!n.getImmediateChild(qa(t)).isEmpty())?n.getChild(t):null}function nc(e){return 0===e.eventRegistrations_.length}function ic(e,t,n){const i=[];if(n){h(null==t,"A cancel should cancel all event registrations.");const r=e.query._path;e.eventRegistrations_.forEach(e=>{const t=e.createCancelEvent(n,r);t&&i.push(t)})}if(t){let n=[];for(let i=0;i<e.eventRegistrations_.length;++i){const r=e.eventRegistrations_[i];if(r.matches(t)){if(t.hasAnyCallback()){n=n.concat(e.eventRegistrations_.slice(i+1));break}}else n.push(r)}e.eventRegistrations_=n}else e.eventRegistrations_=[];return i}function rc(e,t,n,i){t.type===tl.MERGE&&null!==t.source.queryId&&(h(gl(e.viewCache_),"We should always have a full cache before handling merges"),h(pl(e.viewCache_),"Missing event cache, even though we have a server cache"));const r=e.viewCache_,s=Hl(e.processor_,r,t,n,i);var a,o;return a=e.processor_,o=s.viewCache,h(o.eventCache.getNode().isIndexed(a.filter.getIndex()),"Event snap not indexed"),h(o.serverCache.getNode().isIndexed(a.filter.getIndex()),"Server snap not indexed"),h(s.viewCache.serverCache.isFullyInitialized()||!r.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),e.viewCache_=s.viewCache,sc(e,s.changes,s.viewCache.eventCache.getNode(),null)}function sc(e,t,n,i){const r=i?[i]:e.eventRegistrations_;return function(e,t,n,i){const r=[],s=[];return t.forEach(t=>{var n;"child_changed"===t.type&&e.index_.indexedValueChanged(t.oldSnap,t.snapshotNode)&&s.push((n=t.childName,{type:"child_moved",snapshotNode:t.snapshotNode,childName:n}))}),cl(e,r,"child_removed",t,i,n),cl(e,r,"child_added",t,i,n),cl(e,r,"child_moved",s,i,n),cl(e,r,"child_changed",t,i,n),cl(e,r,"value",t,i,n),r}(e.eventGenerator_,t,n,r)}
|
|
2801
|
+
/**
|
|
2802
|
+
* @license
|
|
2803
|
+
* Copyright 2017 Google LLC
|
|
2804
|
+
*
|
|
2805
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2806
|
+
* you may not use this file except in compliance with the License.
|
|
2807
|
+
* You may obtain a copy of the License at
|
|
2808
|
+
*
|
|
2809
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2810
|
+
*
|
|
2811
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2812
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2813
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2814
|
+
* See the License for the specific language governing permissions and
|
|
2815
|
+
* limitations under the License.
|
|
2816
|
+
*/class ac{constructor(){this.views=new Map}}function oc(e,t,n,i){const r=t.source.queryId;if(null!==r){const s=e.views.get(r);return h(null!=s,"SyncTree gave us an op for an invalid query."),rc(s,t,n,i)}{let r=[];for(const s of e.views.values())r=r.concat(rc(s,t,n,i));return r}}function lc(e,t,n,i,r,s){const a=function(e,t,n,i,r){const s=t._queryIdentifier,a=e.views.get(s);if(!a){let e=Al(n,r?i:null),s=!1;e?s=!0:i instanceof No?(e=Ml(n,i),s=!1):(e=No.EMPTY_NODE,s=!1);const a=ul(new ol(e,s,!1),new ol(i,r,!1));return new ec(t,a)}return a}(e,t,i,r,s);return e.views.has(t._queryIdentifier)||e.views.set(t._queryIdentifier,a),function(e,t){e.eventRegistrations_.push(t)}(a,n),function(e,t){const n=e.viewCache_.eventCache,i=[];n.getNode().isLeafNode()||n.getNode().forEachChild(So,(e,t)=>{i.push(Fo(e,t))});return n.isFullyInitialized()&&i.push(jo(n.getNode())),sc(e,i,n.getNode(),t)}(a,n)}function cc(e,t,n,i){const r=t._queryIdentifier,s=[];let a=[];const o=gc(e);if("default"===r)for(const[t,r]of e.views.entries())a=a.concat(ic(r,n,i)),nc(r)&&(e.views.delete(t),r.query._queryParams.loadsAllData()||s.push(r.query));else{const t=e.views.get(r);t&&(a=a.concat(ic(t,n,i)),nc(t)&&(e.views.delete(r),t.query._queryParams.loadsAllData()||s.push(t.query)))}return o&&!gc(e)&&s.push(new(h(Xl,"Reference.ts has not been loaded"),Xl)(t._repo,t._path)),{removed:s,events:a}}function uc(e){const t=[];for(const n of e.views.values())n.query._queryParams.loadsAllData()||t.push(n);return t}function hc(e,t){let n=null;for(const i of e.views.values())n=n||tc(i,t);return n}function dc(e,t){if(t._queryParams.loadsAllData())return fc(e);{const n=t._queryIdentifier;return e.views.get(n)}}function pc(e,t){return null!=dc(e,t)}function gc(e){return null!=fc(e)}function fc(e){for(const t of e.views.values())if(t.query._queryParams.loadsAllData())return t;return null}
|
|
2817
|
+
/**
|
|
2818
|
+
* @license
|
|
2819
|
+
* Copyright 2017 Google LLC
|
|
2820
|
+
*
|
|
2821
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2822
|
+
* you may not use this file except in compliance with the License.
|
|
2823
|
+
* You may obtain a copy of the License at
|
|
2824
|
+
*
|
|
2825
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2826
|
+
*
|
|
2827
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2828
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2829
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2830
|
+
* See the License for the specific language governing permissions and
|
|
2831
|
+
* limitations under the License.
|
|
2832
|
+
*/let mc=1;class vc{constructor(e){this.listenProvider_=e,this.syncPointTree_=new ml(null),this.pendingWriteTree_={visibleWrites:vl.empty(),allWrites:[],lastWriteId:-1},this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function yc(e,t,n,i,r){return function(e,t,n,i,r){h(i>e.lastWriteId,"Stacking an older write on top of newer ones"),void 0===r&&(r=!0),e.allWrites.push({path:t,snap:n,writeId:i,visible:r}),r&&(e.visibleWrites=yl(e.visibleWrites,t,n)),e.lastWriteId=i}(e.pendingWriteTree_,t,n,i,r),r?Sc(e,new sl({fromUser:!0,fromServer:!1,queryId:null,tagged:!1},t,n)):[]}function wc(e,t,n=!1){const i=function(e,t){for(let n=0;n<e.allWrites.length;n++){const i=e.allWrites[n];if(i.writeId===t)return i}return null}(e.pendingWriteTree_,t);if(xl(e.pendingWriteTree_,t)){let t=new ml(null);return null!=i.snap?t=t.set($a(),!0):ua(i.children,e=>{t=t.set(new Ua(e),!0)}),Sc(e,new il(i.path,t,n))}return[]}function bc(e,t,n){return Sc(e,new sl({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},t,n))}function _c(e,t,n,i,r=!1){const s=t._path,a=e.syncPointTree_.get(s);let o=[];if(a&&("default"===t._queryIdentifier||pc(a,t))){const l=cc(a,t,n,i);0===a.views.size&&(e.syncPointTree_=e.syncPointTree_.remove(s));const c=l.removed;if(o=l.events,!r){const n=-1!==c.findIndex(e=>e._queryParams.loadsAllData()),r=e.syncPointTree_.findOnPath(s,(e,t)=>gc(t));if(n&&!r){const t=e.syncPointTree_.subtree(s);if(!t.isEmpty()){const n=function(e){return e.fold((e,t,n)=>{if(t&&gc(t)){return[fc(t)]}{let e=[];return t&&(e=uc(t)),ua(n,(t,n)=>{e=e.concat(n)}),e}})}(t);for(let t=0;t<n.length;++t){const i=n[t],r=i.query,s=Ec(e,i);e.listenProvider_.startListening(Dc(r),Pc(e,r),s.hashFn,s.onComplete)}}}if(!r&&c.length>0&&!i)if(n){const n=null;e.listenProvider_.stopListening(Dc(t),n)}else c.forEach(t=>{const n=e.queryToTagMap.get(xc(t));e.listenProvider_.stopListening(Dc(t),n)})}!function(e,t){for(let n=0;n<t.length;++n){const i=t[n];if(!i._queryParams.loadsAllData()){const t=xc(i),n=e.queryToTagMap.get(t);e.queryToTagMap.delete(t),e.tagToQueryMap.delete(n)}}}(e,c)}return o}function kc(e,t,n,i=!1){const r=t._path;let s=null,a=!1;e.syncPointTree_.foreachOnPath(r,(e,t)=>{const n=Ja(e,r);s=s||hc(t,n),a=a||gc(t)});let o,l=e.syncPointTree_.get(r);if(l?(a=a||gc(l),s=s||hc(l,$a())):(l=new ac,e.syncPointTree_=e.syncPointTree_.set(r,l)),null!=s)o=!0;else{o=!1,s=No.EMPTY_NODE;e.syncPointTree_.subtree(r).foreachChild((e,t)=>{const n=hc(t,$a());n&&(s=s.updateImmediateChild(e,n))})}const c=pc(l,t);if(!c&&!t._queryParams.loadsAllData()){const n=xc(t);h(!e.queryToTagMap.has(n),"View does not exist, but we have a tag");const i=mc++;e.queryToTagMap.set(n,i),e.tagToQueryMap.set(i,n)}let u=lc(l,t,n,Pl(e.pendingWriteTree_,r),s,o);if(!c&&!a&&!i){const n=dc(l,t);u=u.concat(function(e,t,n){const i=t._path,r=Pc(e,t),s=Ec(e,n),a=e.listenProvider_.startListening(Dc(t),r,s.hashFn,s.onComplete),o=e.syncPointTree_.subtree(i);if(r)h(!gc(o.value),"If we're adding a query, it shouldn't be shadowed");else{const t=o.fold((e,t,n)=>{if(!Ya(e)&&t&&gc(t))return[fc(t).query];{let e=[];return t&&(e=e.concat(uc(t).map(e=>e.query))),ua(n,(t,n)=>{e=e.concat(n)}),e}});for(let n=0;n<t.length;++n){const i=t[n];e.listenProvider_.stopListening(Dc(i),Pc(e,i))}}return a}
|
|
2833
|
+
/**
|
|
2834
|
+
* @license
|
|
2835
|
+
* Copyright 2017 Google LLC
|
|
2836
|
+
*
|
|
2837
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2838
|
+
* you may not use this file except in compliance with the License.
|
|
2839
|
+
* You may obtain a copy of the License at
|
|
2840
|
+
*
|
|
2841
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2842
|
+
*
|
|
2843
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2844
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2845
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2846
|
+
* See the License for the specific language governing permissions and
|
|
2847
|
+
* limitations under the License.
|
|
2848
|
+
*/(e,t,n))}return u}function Cc(e,t,n){const i=e.pendingWriteTree_,r=e.syncPointTree_.findOnPath(t,(e,n)=>{const i=hc(n,Ja(e,t));if(i)return i});return Dl(i,t,r,n,!0)}function Sc(e,t){return Tc(t,e.syncPointTree_,null,Pl(e.pendingWriteTree_,$a()))}function Tc(e,t,n,i){if(Ya(e.path))return Ic(e,t,n,i);{const r=t.get($a());null==n&&null!=r&&(n=hc(r,$a()));let s=[];const a=qa(e.path),o=e.operationForChild(a),l=t.children.get(a);if(l&&o){const e=n?n.getImmediateChild(a):null,t=Ul(i,a);s=s.concat(Tc(o,l,e,t))}return r&&(s=s.concat(oc(r,e,i,n))),s}}function Ic(e,t,n,i){const r=t.get($a());null==n&&null!=r&&(n=hc(r,$a()));let s=[];return t.children.inorderTraversal((t,r)=>{const a=n?n.getImmediateChild(t):null,o=Ul(i,t),l=e.operationForChild(t);l&&(s=s.concat(Ic(l,r,a,o)))}),r&&(s=s.concat(oc(r,e,i,n))),s}function Ec(e,t){const n=t.query,i=Pc(e,n);return{hashFn:()=>{const e=function(e){return e.viewCache_.serverCache.getNode()}(t)||No.EMPTY_NODE;return e.hash()},onComplete:t=>{if("ok"===t)return i?function(e,t,n){const i=Rc(e,n);if(i){const n=Lc(i),r=n.path,s=n.queryId,a=Ja(r,t);return Nc(e,r,new rl(nl(s),a))}return[]}(e,n._path,i):function(e,t){return Sc(e,new rl({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},t))}(e,n._path);{const i=function(e,t){let n="Unknown Error";"too_big"===e?n="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"===e?n="Client doesn't have permission to access the desired data.":"unavailable"===e&&(n="The service is unavailable");const i=new Error(e+" at "+t._path.toString()+": "+n);return i.code=e.toUpperCase(),i}(t,n);return _c(e,n,null,i)}}}}function Pc(e,t){const n=xc(t);return e.queryToTagMap.get(n)}function xc(e){return e._path.toString()+"$"+e._queryIdentifier}function Rc(e,t){return e.tagToQueryMap.get(t)}function Lc(e){const t=e.indexOf("$");return h(-1!==t&&t<e.length-1,"Bad queryKey."),{queryId:e.substr(t+1),path:new Ua(e.substr(0,t))}}function Nc(e,t,n){const i=e.syncPointTree_.get(t);h(i,"Missing sync point for query tag that we're tracking");return oc(i,n,Pl(e.pendingWriteTree_,t),null)}function Dc(e){return e._queryParams.loadsAllData()&&!e._queryParams.isDefault()?new(h(Ql,"Reference.ts has not been loaded"),Ql)(e._repo,e._path):e}class Ac{constructor(e){this.node_=e}getImmediateChild(e){const t=this.node_.getImmediateChild(e);return new Ac(t)}node(){return this.node_}}class Mc{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){const t=Ka(this.path_,e);return new Mc(this.syncTree_,t)}node(){return Cc(this.syncTree_,this.path_)}}const Oc=function(e,t,n){return e&&"object"==typeof e?(h(".sv"in e,"Unexpected leaf node or priority contents"),"string"==typeof e[".sv"]?jc(e[".sv"],t,n):"object"==typeof e[".sv"]?Fc(e[".sv"],t):void h(!1,"Unexpected server value: "+JSON.stringify(e,null,2))):e},jc=function(e,t,n){if("timestamp"===e)return n.timestamp;h(!1,"Unexpected server value: "+e)},Fc=function(e,t,n){e.hasOwnProperty("increment")||h(!1,"Unexpected server value: "+JSON.stringify(e,null,2));const i=e.increment;"number"!=typeof i&&h(!1,"Unexpected increment value: "+i);const r=t.node();if(h(null!=r,"Expected ChildrenNode.EMPTY_NODE for nulls"),!r.isLeafNode())return i;const s=r.getValue();return"number"!=typeof s?i:s+i},zc=function(e,t,n){return Uc(e,new Ac(t),n)};function Uc(e,t,n){const i=e.getPriority().val(),r=Oc(i,t.getImmediateChild(".priority"),n);let s;if(e.isLeafNode()){const i=e,s=Oc(i.getValue(),t,n);return s!==i.getValue()||r!==i.getPriority().val()?new Co(s,Ao(r)):e}{const i=e;return s=i,r!==i.getPriority().val()&&(s=s.updatePriority(new Co(r))),i.forEachChild(So,(e,i)=>{const r=Uc(i,t.getImmediateChild(e),n);r!==i&&(s=s.updateImmediateChild(e,r))}),s}}
|
|
2849
|
+
/**
|
|
2850
|
+
* @license
|
|
2851
|
+
* Copyright 2017 Google LLC
|
|
2852
|
+
*
|
|
2853
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2854
|
+
* you may not use this file except in compliance with the License.
|
|
2855
|
+
* You may obtain a copy of the License at
|
|
2856
|
+
*
|
|
2857
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2858
|
+
*
|
|
2859
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2860
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2861
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2862
|
+
* See the License for the specific language governing permissions and
|
|
2863
|
+
* limitations under the License.
|
|
2864
|
+
*/class $c{constructor(e="",t=null,n={children:{},childCount:0}){this.name=e,this.parent=t,this.node=n}}function qc(e,t){let n=t instanceof Ua?t:new Ua(t),i=e,r=qa(n);for(;null!==r;){const e=W(i.node.children,r)||{children:{},childCount:0};i=new $c(r,i,e),n=Va(n),r=qa(n)}return i}function Bc(e){return e.node.value}function Vc(e,t){e.node.value=t,Yc(e)}function Hc(e){return e.node.childCount>0}function Wc(e,t){ua(e.node.children,(n,i)=>{t(new $c(n,e,i))})}function Gc(e,t,n,i){n&&t(e),Wc(e,e=>{Gc(e,t,!0)})}function Kc(e){return new Ua(null===e.parent?e.name:Kc(e.parent)+"/"+e.name)}function Yc(e){null!==e.parent&&function(e,t,n){const i=function(e){return void 0===Bc(e)&&!Hc(e)}(n),r=H(e.node.children,t);i&&r?(delete e.node.children[t],e.node.childCount--,Yc(e)):i||r||(e.node.children[t]=n.node,e.node.childCount++,Yc(e))}
|
|
2865
|
+
/**
|
|
2866
|
+
* @license
|
|
2867
|
+
* Copyright 2017 Google LLC
|
|
2868
|
+
*
|
|
2869
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2870
|
+
* you may not use this file except in compliance with the License.
|
|
2871
|
+
* You may obtain a copy of the License at
|
|
2872
|
+
*
|
|
2873
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2874
|
+
*
|
|
2875
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2876
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2877
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2878
|
+
* See the License for the specific language governing permissions and
|
|
2879
|
+
* limitations under the License.
|
|
2880
|
+
*/(e.parent,e.name,e)}const Jc=/[\[\].#$\/\u0000-\u001F\u007F]/,Zc=/[\[\].#$\u0000-\u001F\u007F]/,Xc=10485760,Qc=function(e){return"string"==typeof e&&0!==e.length&&!Jc.test(e)},eu=function(e){return"string"==typeof e&&0!==e.length&&!Zc.test(e)},tu=function(e){return null===e||"string"==typeof e||"number"==typeof e&&!na(e)||e&&"object"==typeof e&&H(e,".sv")},nu=function(e,t,n,i){i&&void 0===t||iu(te(e,"value"),t,n)},iu=function(e,t,n){const i=n instanceof Ua?new eo(n,e):n;if(void 0===t)throw new Error(e+"contains undefined "+no(i));if("function"==typeof t)throw new Error(e+"contains a function "+no(i)+" with contents = "+t.toString());if(na(t))throw new Error(e+"contains "+t.toString()+" "+no(i));if("string"==typeof t&&t.length>Xc/3&&ne(t)>Xc)throw new Error(e+"contains a string greater than "+Xc+" utf8 bytes "+no(i)+" ('"+t.substring(0,50)+"...')");if(t&&"object"==typeof t){let n=!1,r=!1;if(ua(t,(t,s)=>{if(".value"===t)n=!0;else if(".priority"!==t&&".sv"!==t&&(r=!0,!Qc(t)))throw new Error(e+" contains an invalid key ("+t+") "+no(i)+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');!function(e,t){e.parts_.length>0&&(e.byteLength_+=1),e.parts_.push(t),e.byteLength_+=ne(t),to(e)}(i,t),iu(e,s,i),function(e){const t=e.parts_.pop();e.byteLength_-=ne(t),e.parts_.length>0&&(e.byteLength_-=1)}(i)}),n&&r)throw new Error(e+' contains ".value" child '+no(i)+" in addition to actual children.")}},ru=function(e,t,n,i){const r=te(e,"values");if(!t||"object"!=typeof t||Array.isArray(t))throw new Error(r+" must be an object containing the children to replace.");const s=[];ua(t,(e,t)=>{const i=new Ua(e);if(iu(r,t,Ka(n,i)),".priority"===Ha(i)&&!tu(t))throw new Error(r+"contains an invalid value for '"+i.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");s.push(i)}),function(e,t){let n,i;for(n=0;n<t.length;n++){i=t[n];const r=Wa(i);for(let t=0;t<r.length;t++)if(".priority"===r[t]&&t===r.length-1);else if(!Qc(r[t]))throw new Error(e+"contains an invalid key ("+r[t]+") in path "+i.toString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"')}t.sort(Za);let r=null;for(n=0;n<t.length;n++){if(i=t[n],null!==r&&Qa(r,i))throw new Error(e+"contains a path "+r.toString()+" that is ancestor of another path "+i.toString());r=i}}(r,s)},su=function(e,t,n,i){if(!eu(n))throw new Error(te(e,t)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')},au=function(e,t){if(".info"===qa(t))throw new Error(e+" failed = Can't modify data under /.info/")},ou=function(e,t){const n=t.path.toString();if("string"!=typeof t.repoInfo.host||0===t.repoInfo.host.length||!Qc(t.repoInfo.namespace)&&"localhost"!==t.repoInfo.host.split(":")[0]||0!==n.length&&!function(e){return e&&(e=e.replace(/^\/*\.info(\/|$)/,"/")),eu(e)}(n))throw new Error(te(e,"url")+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')};
|
|
2881
|
+
/**
|
|
2882
|
+
* @license
|
|
2883
|
+
* Copyright 2017 Google LLC
|
|
2884
|
+
*
|
|
2885
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2886
|
+
* you may not use this file except in compliance with the License.
|
|
2887
|
+
* You may obtain a copy of the License at
|
|
2888
|
+
*
|
|
2889
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2890
|
+
*
|
|
2891
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2892
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2893
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2894
|
+
* See the License for the specific language governing permissions and
|
|
2895
|
+
* limitations under the License.
|
|
2896
|
+
*/
|
|
2897
|
+
class lu{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function cu(e,t){let n=null;for(let i=0;i<t.length;i++){const r=t[i],s=r.getPath();null===n||Xa(s,n.path)||(e.eventLists_.push(n),n=null),null===n&&(n={events:[],path:s}),n.events.push(r)}n&&e.eventLists_.push(n)}function uu(e,t,n){cu(e,n),du(e,e=>Xa(e,t))}function hu(e,t,n){cu(e,n),du(e,e=>Qa(e,t)||Qa(t,e))}function du(e,t){e.recursionDepth_++;let n=!0;for(let i=0;i<e.eventLists_.length;i++){const r=e.eventLists_[i];if(r){t(r.path)?(pu(e.eventLists_[i]),e.eventLists_[i]=null):n=!1}}n&&(e.eventLists_=[]),e.recursionDepth_--}function pu(e){for(let t=0;t<e.events.length;t++){const n=e.events[t];if(null!==n){e.events[t]=null;const i=n.getEventRunner();Ys&&Zs("event: "+n.toString()),ga(i)}}}
|
|
2898
|
+
/**
|
|
2899
|
+
* @license
|
|
2900
|
+
* Copyright 2017 Google LLC
|
|
2901
|
+
*
|
|
2902
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2903
|
+
* you may not use this file except in compliance with the License.
|
|
2904
|
+
* You may obtain a copy of the License at
|
|
2905
|
+
*
|
|
2906
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2907
|
+
*
|
|
2908
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2909
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2910
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2911
|
+
* See the License for the specific language governing permissions and
|
|
2912
|
+
* limitations under the License.
|
|
2913
|
+
*/class gu{constructor(e,t,n,i){this.repoInfo_=e,this.forceRestClient_=t,this.authTokenProvider_=n,this.appCheckProvider_=i,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new lu,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=Yo(),this.transactionQueueTree_=new $c,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function fu(e,t,n){if(e.stats_=Pa(e.repoInfo_),e.forceRestClient_||("object"==typeof window&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)>=0)e.server_=new Go(e.repoInfo_,(t,n,i,r)=>{yu(e,t,n,i,r)},e.authTokenProvider_,e.appCheckProvider_),setTimeout(()=>wu(e,!0),0);else{if(null!=n){if("object"!=typeof n)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{B(n)}catch(e){throw new Error("Invalid authOverride provided: "+e)}}e.persistentConnection_=new so(e.repoInfo_,t,(t,n,i,r)=>{yu(e,t,n,i,r)},t=>{wu(e,t)},t=>{!function(e,t){ua(t,(t,n)=>{bu(e,t,n)})}(e,t)},e.authTokenProvider_,e.appCheckProvider_,n),e.server_=e.persistentConnection_}e.authTokenProvider_.addTokenChangeListener(t=>{e.server_.refreshAuthToken(t)}),e.appCheckProvider_.addTokenChangeListener(t=>{e.server_.refreshAppCheckToken(t.token)}),e.statsReporter_=function(e,t){const n=e.toString();return Ea[n]||(Ea[n]=t()),Ea[n]}(e.repoInfo_,()=>new el(e.stats_,e.server_)),e.infoData_=new Ko,e.infoSyncTree_=new vc({startListening:(t,n,i,r)=>{let s=[];const a=e.infoData_.getNode(t._path);return a.isEmpty()||(s=bc(e.infoSyncTree_,t._path,a),setTimeout(()=>{r("ok")},0)),s},stopListening:()=>{}}),bu(e,"connected",!1),e.serverSyncTree_=new vc({startListening:(t,n,i,r)=>(e.server_.listen(t,i,n,(n,i)=>{const s=r(n,i);hu(e.eventQueue_,t._path,s)}),[]),stopListening:(t,n)=>{e.server_.unlisten(t,n)}})}function mu(e){const t=e.infoData_.getNode(new Ua(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+t}function vu(e){return(t=(t={timestamp:mu(e)})||{}).timestamp=t.timestamp||(new Date).getTime(),t;var t}function yu(e,t,n,i,r){e.dataUpdateCount++;const s=new Ua(t);n=e.interceptServerDataCallback_?e.interceptServerDataCallback_(t,n):n;let a=[];if(r)if(i){const t=K(n,e=>Ao(e));a=function(e,t,n,i){const r=Rc(e,i);if(r){const i=Lc(r),s=i.path,a=i.queryId,o=Ja(s,t),l=ml.fromObject(n);return Nc(e,s,new al(nl(a),o,l))}return[]}(e.serverSyncTree_,s,t,r)}else{const t=Ao(n);a=function(e,t,n,i){const r=Rc(e,i);if(null!=r){const i=Lc(r),s=i.path,a=i.queryId,o=Ja(s,t);return Nc(e,s,new sl(nl(a),o,n))}return[]}(e.serverSyncTree_,s,t,r)}else if(i){const t=K(n,e=>Ao(e));a=function(e,t,n){const i=ml.fromObject(n);return Sc(e,new al({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},t,i))}(e.serverSyncTree_,s,t)}else{const t=Ao(n);a=bc(e.serverSyncTree_,s,t)}let o=s;a.length>0&&(o=xu(e,s)),hu(e.eventQueue_,o,a)}function wu(e,t){bu(e,"connected",t),!1===t&&function(e){Tu(e,"onDisconnectEvents");const t=vu(e),n=Yo();Xo(e.onDisconnect_,$a(),(i,r)=>{const s=function(e,t,n,i){return Uc(t,new Mc(n,e),i)}(i,r,e.serverSyncTree_,t);Jo(n,i,s)});let i=[];Xo(n,$a(),(t,n)=>{i=i.concat(bc(e.serverSyncTree_,t,n));const r=Au(e,t);xu(e,r)}),e.onDisconnect_=Yo(),hu(e.eventQueue_,$a(),i)}(e)}function bu(e,t,n){const i=new Ua("/.info/"+t),r=Ao(n);e.infoData_.updateSnapshot(i,r);const s=bc(e.infoSyncTree_,i,r);hu(e.eventQueue_,i,s)}function _u(e){return e.nextWriteId_++}function ku(e,t,n){e.server_.onDisconnectCancel(t.toString(),(i,r)=>{"ok"===i&&Zo(e.onDisconnect_,t),Iu(e,n,i,r)})}function Cu(e,t,n,i){const r=Ao(n);e.server_.onDisconnectPut(t.toString(),r.val(!0),(n,s)=>{"ok"===n&&Jo(e.onDisconnect_,t,r),Iu(e,i,n,s)})}function Su(e,t,n){let i;i=".info"===qa(t._path)?_c(e.infoSyncTree_,t,n):_c(e.serverSyncTree_,t,n),uu(e.eventQueue_,t._path,i)}function Tu(e,...t){let n="";e.persistentConnection_&&(n=e.persistentConnection_.id+":"),Zs(n,...t)}function Iu(e,t,n,i){t&&ga(()=>{if("ok"===n)t(null);else{const e=(n||"error").toUpperCase();let r=e;i&&(r+=": "+i);const s=new Error(r);s.code=e,t(s)}})}function Eu(e,t,n){return Cc(e.serverSyncTree_,t,n)||No.EMPTY_NODE}function Pu(e,t=e.transactionQueueTree_){if(t||Du(e,t),Bc(t)){const n=Lu(e,t);h(n.length>0,"Sending zero length transaction queue");n.every(e=>0===e.status)&&function(e,t,n){const i=n.map(e=>e.currentWriteId),r=Eu(e,t,i);let s=r;const a=r.hash();for(let e=0;e<n.length;e++){const i=n[e];h(0===i.status,"tryToSendTransactionQueue_: items in queue should all be run."),i.status=1,i.retryCount++;const r=Ja(t,i.path);s=s.updateChild(r,i.currentOutputSnapshotRaw)}const o=s.val(!0),l=t;e.server_.put(l.toString(),o,i=>{Tu(e,"transaction put response",{path:l.toString(),status:i});let r=[];if("ok"===i){const i=[];for(let t=0;t<n.length;t++)n[t].status=2,r=r.concat(wc(e.serverSyncTree_,n[t].currentWriteId)),n[t].onComplete&&i.push(()=>n[t].onComplete(null,!0,n[t].currentOutputSnapshotResolved)),n[t].unwatcher();Du(e,qc(e.transactionQueueTree_,t)),Pu(e,e.transactionQueueTree_),hu(e.eventQueue_,t,r);for(let e=0;e<i.length;e++)ga(i[e])}else{if("datastale"===i)for(let e=0;e<n.length;e++)3===n[e].status?n[e].status=4:n[e].status=0;else{ta("transaction at "+l.toString()+" failed: "+i);for(let e=0;e<n.length;e++)n[e].status=4,n[e].abortReason=i}xu(e,t)}},a)}(e,Kc(t),n)}else Hc(t)&&Wc(t,t=>{Pu(e,t)})}function xu(e,t){const n=Ru(e,t),i=Kc(n);return function(e,t,n){if(0===t.length)return;const i=[];let r=[];const s=t.filter(e=>0===e.status),a=s.map(e=>e.currentWriteId);for(let s=0;s<t.length;s++){const o=t[s],l=Ja(n,o.path);let c,u=!1;if(h(null!==l,"rerunTransactionsUnderNode_: relativePath should not be null."),4===o.status)u=!0,c=o.abortReason,r=r.concat(wc(e.serverSyncTree_,o.currentWriteId,!0));else if(0===o.status)if(o.retryCount>=25)u=!0,c="maxretry",r=r.concat(wc(e.serverSyncTree_,o.currentWriteId,!0));else{const n=Eu(e,o.path,a);o.currentInputSnapshot=n;const i=t[s].update(n.val());if(void 0!==i){iu("transaction failed: Data returned ",i,o.path);let t=Ao(i);"object"==typeof i&&null!=i&&H(i,".priority")||(t=t.updatePriority(n.getPriority()));const s=o.currentWriteId,l=vu(e),c=zc(t,n,l);o.currentOutputSnapshotRaw=t,o.currentOutputSnapshotResolved=c,o.currentWriteId=_u(e),a.splice(a.indexOf(s),1),r=r.concat(yc(e.serverSyncTree_,o.path,c,o.currentWriteId,o.applyLocally)),r=r.concat(wc(e.serverSyncTree_,s,!0))}else u=!0,c="nodata",r=r.concat(wc(e.serverSyncTree_,o.currentWriteId,!0))}hu(e.eventQueue_,n,r),r=[],u&&(t[s].status=2,function(e){setTimeout(e,Math.floor(0))}(t[s].unwatcher),t[s].onComplete&&("nodata"===c?i.push(()=>t[s].onComplete(null,!1,t[s].currentInputSnapshot)):i.push(()=>t[s].onComplete(new Error(c),!1,null))))}Du(e,e.transactionQueueTree_);for(let e=0;e<i.length;e++)ga(i[e]);Pu(e,e.transactionQueueTree_)}(e,Lu(e,n),i),i}function Ru(e,t){let n,i=e.transactionQueueTree_;for(n=qa(t);null!==n&&void 0===Bc(i);)i=qc(i,n),n=qa(t=Va(t));return i}function Lu(e,t){const n=[];return Nu(e,t,n),n.sort((e,t)=>e.order-t.order),n}function Nu(e,t,n){const i=Bc(t);if(i)for(let e=0;e<i.length;e++)n.push(i[e]);Wc(t,t=>{Nu(e,t,n)})}function Du(e,t){const n=Bc(t);if(n){let e=0;for(let t=0;t<n.length;t++)2!==n[t].status&&(n[e]=n[t],e++);n.length=e,Vc(t,n.length>0?n:void 0)}Wc(t,t=>{Du(e,t)})}function Au(e,t){const n=Kc(Ru(e,t)),i=qc(e.transactionQueueTree_,t);return function(e,t){let n=e.parent;for(;null!==n;){if(t(n))return!0;n=n.parent}}(i,t=>{Mu(e,t)}),Mu(e,i),Gc(i,t=>{Mu(e,t)}),n}function Mu(e,t){const n=Bc(t);if(n){const i=[];let r=[],s=-1;for(let t=0;t<n.length;t++)3===n[t].status||(1===n[t].status?(h(s===t-1,"All SENT items should be at beginning of queue."),s=t,n[t].status=3,n[t].abortReason="set"):(h(0===n[t].status,"Unexpected transaction status in abort"),n[t].unwatcher(),r=r.concat(wc(e.serverSyncTree_,n[t].currentWriteId,!0)),n[t].onComplete&&i.push(n[t].onComplete.bind(null,new Error("set"),!1,null))));-1===s?Vc(t,void 0):n.length=s+1,hu(e.eventQueue_,Kc(t),r);for(let e=0;e<i.length;e++)ga(i[e])}}
|
|
2914
|
+
/**
|
|
2915
|
+
* @license
|
|
2916
|
+
* Copyright 2017 Google LLC
|
|
2917
|
+
*
|
|
2918
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2919
|
+
* you may not use this file except in compliance with the License.
|
|
2920
|
+
* You may obtain a copy of the License at
|
|
2921
|
+
*
|
|
2922
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2923
|
+
*
|
|
2924
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2925
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2926
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2927
|
+
* See the License for the specific language governing permissions and
|
|
2928
|
+
* limitations under the License.
|
|
2929
|
+
*/const Ou=function(e,t){const n=ju(e),i=n.namespace;"firebase.com"===n.domain&&ea(n.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),i&&"undefined"!==i||"localhost"===n.domain||ea("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),n.secure||"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&ta("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().");const r="ws"===n.scheme||"wss"===n.scheme;return{repoInfo:new Ca(n.host,n.secure,i,r,t,"",i!==n.subdomain),path:new Ua(n.pathString)}},ju=function(e){let t="",n="",i="",r="",s="",a=!0,o="https",l=443;if("string"==typeof e){let c=e.indexOf("//");c>=0&&(o=e.substring(0,c-1),e=e.substring(c+2));let u=e.indexOf("/");-1===u&&(u=e.length);let h=e.indexOf("?");-1===h&&(h=e.length),t=e.substring(0,Math.min(u,h)),u<h&&(r=function(e){let t="";const n=e.split("/");for(let e=0;e<n.length;e++)if(n[e].length>0){let i=n[e];try{i=decodeURIComponent(i.replace(/\+/g," "))}catch(e){}t+="/"+i}return t}(e.substring(u,h)));const d=function(e){const t={};"?"===e.charAt(0)&&(e=e.substring(1));for(const n of e.split("&")){if(0===n.length)continue;const i=n.split("=");2===i.length?t[decodeURIComponent(i[0])]=decodeURIComponent(i[1]):ta(`Invalid query segment '${n}' in query '${e}'`)}return t}(e.substring(Math.min(e.length,h)));c=t.indexOf(":"),c>=0?(a="https"===o||"wss"===o,l=parseInt(t.substring(c+1),10)):c=t.length;const p=t.slice(0,c);if("localhost"===p.toLowerCase())n="localhost";else if(p.split(".").length<=2)n=p;else{const e=t.indexOf(".");i=t.substring(0,e).toLowerCase(),n=t.substring(e+1),s=i}"ns"in d&&(s=d.ns)}return{host:t,port:l,domain:n,subdomain:i,secure:a,scheme:o,pathString:r,namespace:s}},Fu="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",zu=function(){let e=0;const t=[];return function(n){const i=n===e;let r;e=n;const s=new Array(8);for(r=7;r>=0;r--)s[r]=Fu.charAt(n%64),n=Math.floor(n/64);h(0===n,"Cannot push at time == 0");let a=s.join("");if(i){for(r=11;r>=0&&63===t[r];r--)t[r]=0;t[r]++}else for(r=0;r<12;r++)t[r]=Math.floor(64*Math.random());for(r=0;r<12;r++)a+=Fu.charAt(t[r]);return h(20===a.length,"nextPushId: Length should be 20."),a}}();
|
|
2930
|
+
/**
|
|
2931
|
+
* @license
|
|
2932
|
+
* Copyright 2017 Google LLC
|
|
2933
|
+
*
|
|
2934
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2935
|
+
* you may not use this file except in compliance with the License.
|
|
2936
|
+
* You may obtain a copy of the License at
|
|
2937
|
+
*
|
|
2938
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2939
|
+
*
|
|
2940
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2941
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2942
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2943
|
+
* See the License for the specific language governing permissions and
|
|
2944
|
+
* limitations under the License.
|
|
2945
|
+
*/
|
|
2946
|
+
class Uu{constructor(e,t,n,i){this.eventType=e,this.eventRegistration=t,this.snapshot=n,this.prevName=i}getPath(){const e=this.snapshot.ref;return"value"===this.eventType?e._path:e.parent._path}getEventType(){return this.eventType}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.getPath().toString()+":"+this.eventType+":"+B(this.snapshot.exportVal())}}class $u{constructor(e,t,n){this.eventRegistration=e,this.error=t,this.path=n}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}}
|
|
2947
|
+
/**
|
|
2948
|
+
* @license
|
|
2949
|
+
* Copyright 2017 Google LLC
|
|
2950
|
+
*
|
|
2951
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2952
|
+
* you may not use this file except in compliance with the License.
|
|
2953
|
+
* You may obtain a copy of the License at
|
|
2954
|
+
*
|
|
2955
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2956
|
+
*
|
|
2957
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2958
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2959
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2960
|
+
* See the License for the specific language governing permissions and
|
|
2961
|
+
* limitations under the License.
|
|
2962
|
+
*/class qu{constructor(e,t){this.snapshotCallback=e,this.cancelCallback=t}onValue(e,t){this.snapshotCallback.call(null,e,t)}onCancel(e){return h(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,e)}get hasCancelCallback(){return!!this.cancelCallback}matches(e){return this.snapshotCallback===e.snapshotCallback||void 0!==this.snapshotCallback.userCallback&&this.snapshotCallback.userCallback===e.snapshotCallback.userCallback&&this.snapshotCallback.context===e.snapshotCallback.context}}
|
|
2963
|
+
/**
|
|
2964
|
+
* @license
|
|
2965
|
+
* Copyright 2021 Google LLC
|
|
2966
|
+
*
|
|
2967
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2968
|
+
* you may not use this file except in compliance with the License.
|
|
2969
|
+
* You may obtain a copy of the License at
|
|
2970
|
+
*
|
|
2971
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2972
|
+
*
|
|
2973
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2974
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2975
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2976
|
+
* See the License for the specific language governing permissions and
|
|
2977
|
+
* limitations under the License.
|
|
2978
|
+
*/class Bu{constructor(e,t){this._repo=e,this._path=t}cancel(){const e=new E;return ku(this._repo,this._path,e.wrapCallback(()=>{})),e.promise}remove(){au("OnDisconnect.remove",this._path);const e=new E;return Cu(this._repo,this._path,null,e.wrapCallback(()=>{})),e.promise}set(e){au("OnDisconnect.set",this._path),nu("OnDisconnect.set",e,this._path,!1);const t=new E;return Cu(this._repo,this._path,e,t.wrapCallback(()=>{})),t.promise}setWithPriority(e,t){au("OnDisconnect.setWithPriority",this._path),nu("OnDisconnect.setWithPriority",e,this._path,!1),function(e,t){if(na(t))throw new Error(te(e,"priority")+"is "+t.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!tu(t))throw new Error(te(e,"priority")+"must be a valid Firebase priority (a string, finite number, server value, or null).")}("OnDisconnect.setWithPriority",t);const n=new E;return function(e,t,n,i,r){const s=Ao(n,i);e.server_.onDisconnectPut(t.toString(),s.val(!0),(n,i)=>{"ok"===n&&Jo(e.onDisconnect_,t,s),Iu(0,r,n,i)})}(this._repo,this._path,e,t,n.wrapCallback(()=>{})),n.promise}update(e){au("OnDisconnect.update",this._path),ru("OnDisconnect.update",e,this._path);const t=new E;return function(e,t,n,i){if(G(n))return Zs("onDisconnect().update() called with empty data. Don't do anything."),void Iu(0,i,"ok",void 0);e.server_.onDisconnectMerge(t.toString(),n,(r,s)=>{"ok"===r&&ua(n,(n,i)=>{const r=Ao(i);Jo(e.onDisconnect_,Ka(t,n),r)}),Iu(0,i,r,s)})}(this._repo,this._path,e,t.wrapCallback(()=>{})),t.promise}}
|
|
2979
|
+
/**
|
|
2980
|
+
* @license
|
|
2981
|
+
* Copyright 2020 Google LLC
|
|
2982
|
+
*
|
|
2983
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2984
|
+
* you may not use this file except in compliance with the License.
|
|
2985
|
+
* You may obtain a copy of the License at
|
|
2986
|
+
*
|
|
2987
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2988
|
+
*
|
|
2989
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2990
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2991
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2992
|
+
* See the License for the specific language governing permissions and
|
|
2993
|
+
* limitations under the License.
|
|
2994
|
+
*/class Vu{constructor(e,t,n,i){this._repo=e,this._path=t,this._queryParams=n,this._orderByCalled=i}get key(){return Ya(this._path)?null:Ha(this._path)}get ref(){return new Hu(this._repo,this._path)}get _queryIdentifier(){const e=Wo(this._queryParams),t=la(e);return"{}"===t?"default":t}get _queryObject(){return Wo(this._queryParams)}isEqual(e){if(!((e=re(e))instanceof Vu))return!1;const t=this._repo===e._repo,n=Xa(this._path,e._path),i=this._queryIdentifier===e._queryIdentifier;return t&&n&&i}toJSON(){return this.toString()}toString(){return this._repo.toString()+function(e){let t="";for(let n=e.pieceNum_;n<e.pieces_.length;n++)""!==e.pieces_[n]&&(t+="/"+encodeURIComponent(String(e.pieces_[n])));return t||"/"}(this._path)}}class Hu extends Vu{constructor(e,t){super(e,t,new Vo,!1)}get parent(){const e=Ga(this._path);return null===e?null:new Hu(this._repo,e)}get root(){let e=this;for(;null!==e.parent;)e=e.parent;return e}}class Wu{constructor(e,t,n){this._node=e,this.ref=t,this._index=n}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(e){const t=new Ua(e),n=Ku(this.ref,e);return new Wu(this._node.getChild(t),n,So)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(e){if(this._node.isLeafNode())return!1;return!!this._node.forEachChild(this._index,(t,n)=>e(new Wu(n,Ku(this.ref,t),So)))}hasChild(e){const t=new Ua(e);return!this._node.getChild(t).isEmpty()}hasChildren(){return!this._node.isLeafNode()&&!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}}function Gu(e,t){return(e=re(e))._checkNotDeleted("ref"),void 0!==t?Ku(e._root,t):e._root}function Ku(e,t){var n,i,r;return null===qa((e=re(e))._path)?(n="child",i="path",(r=t)&&(r=r.replace(/^\/*\.info(\/|$)/,"/")),su(n,i,r)):su("child","path",t),new Hu(e._repo,Ka(e._path,t))}function Yu(e,t){e=re(e),au("set",e._path),nu("set",t,e._path,!1);const n=new E;return function(e,t,n,i,r){Tu(e,"set",{path:t.toString(),value:n,priority:i});const s=vu(e),a=Ao(n,i),o=Cc(e.serverSyncTree_,t),l=zc(a,o,s),c=_u(e),u=yc(e.serverSyncTree_,t,l,c,!0);cu(e.eventQueue_,u),e.server_.put(t.toString(),a.val(!0),(n,i)=>{const s="ok"===n;s||ta("set at "+t+" failed: "+n);const a=wc(e.serverSyncTree_,c,!s);hu(e.eventQueue_,t,a),Iu(0,r,n,i)});const h=Au(e,t);xu(e,h),hu(e.eventQueue_,h,[])}(e._repo,e._path,t,null,n.wrapCallback(()=>{})),n.promise}class Ju{constructor(e){this.callbackContext=e}respondsTo(e){return"value"===e}createEvent(e,t){const n=t._queryParams.getIndex();return new Uu("value",this,new Wu(e.snapshotNode,new Hu(t._repo,t._path),n))}getEventRunner(e){return"cancel"===e.getEventType()?()=>this.callbackContext.onCancel(e.error):()=>this.callbackContext.onValue(e.snapshot,null)}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new $u(this,e,t):null}matches(e){return e instanceof Ju&&(!e.callbackContext||!this.callbackContext||e.callbackContext.matches(this.callbackContext))}hasAnyCallback(){return null!==this.callbackContext}}function Zu(e,t,n,i,r){const s=new qu(n,void 0),a=new Ju(s);return function(e,t,n){let i;i=".info"===qa(t._path)?kc(e.infoSyncTree_,t,n):kc(e.serverSyncTree_,t,n),uu(e.eventQueue_,t._path,i)}(e._repo,e,a),()=>Su(e._repo,e,a)}function Xu(e,t,n,i){return Zu(e,0,t)}!function(e){h(!Xl,"__referenceConstructor has already been defined"),Xl=e}(Hu),function(e){h(!Ql,"__referenceConstructor has already been defined"),Ql=e}(Hu);
|
|
2995
|
+
/**
|
|
2996
|
+
* @license
|
|
2997
|
+
* Copyright 2020 Google LLC
|
|
2998
|
+
*
|
|
2999
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3000
|
+
* you may not use this file except in compliance with the License.
|
|
3001
|
+
* You may obtain a copy of the License at
|
|
3002
|
+
*
|
|
3003
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3004
|
+
*
|
|
3005
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3006
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3007
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3008
|
+
* See the License for the specific language governing permissions and
|
|
3009
|
+
* limitations under the License.
|
|
3010
|
+
*/
|
|
3011
|
+
const Qu={};let eh,th,nh,ih,rh=!1;function sh(e,t,n,i,r){let s=i||e.options.databaseURL;void 0===s&&(e.options.projectId||ea("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),Zs("Using default host for project ",e.options.projectId),s=`${e.options.projectId}-default-rtdb.firebaseio.com`);let a,o=Ou(s,r),l=o.repoInfo;"undefined"!=typeof process&&process.env&&(a=process.env.FIREBASE_DATABASE_EMULATOR_HOST),a?(s=`http://${a}?ns=${l.namespace}`,o=Ou(s,r),l=o.repoInfo):o.repoInfo.secure;const c=new va(e.name,e.options,t);ou("Invalid Firebase Database URL",o),Ya(o.path)||ea("Database URL must point to the root of a Firebase Database (not including a child path).");const u=function(e,t,n,i){let r=Qu[t.name];r||(r={},Qu[t.name]=r);let s=r[e.toURLString()];s&&ea("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call.");return s=new gu(e,rh,n,i),r[e.toURLString()]=s,s}(l,e,c,new ma(e,n));return new ah(u,e)}class ah{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(fu(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new Hu(this._repo,$a())),this._rootInternal}_delete(){return null!==this._rootInternal&&(!function(e,t){const n=Qu[t];n&&n[e.key]===e||ea(`Database ${t}(${e.repoInfo_}) has already been deleted.`),function(e){e.persistentConnection_&&e.persistentConnection_.interrupt("repo_interrupt")}(e),delete n[e.key]}(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){null===this._rootInternal&&ea("Cannot call "+e+" on a deleted database.")}}function oh(e=_t(),t){const n=ft(e,"database").getImmediate({identifier:t});if(!n._instanceStarted){const e=(e=>{const t=S(e);if(!t)return;const n=t.lastIndexOf(":");if(n<=0||n+1===t.length)throw new Error(`Invalid host ${t} with no separate hostname and port!`);const i=parseInt(t.substring(n+1),10);return"["===t[0]?[t.substring(1,n-1),i]:[t.substring(0,n),i]})("database");e&&function(e,t,n,i={}){e=re(e),e._checkNotDeleted("useEmulator");const r=`${t}:${n}`,s=e._repoInternal;if(e._instanceStarted){if(r===e._repoInternal.repoInfo_.host&&Y(i,s.repoInfo_.emulatorOptions))return;ea("connectDatabaseEmulator() cannot initialize or alter the emulator configuration after the database instance has started.")}let a;if(s.repoInfo_.nodeAdmin)i.mockUserToken&&ea('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),a=new ya(ya.OWNER);else if(i.mockUserToken){const t="string"==typeof i.mockUserToken?i.mockUserToken:function(e,t){if(e.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const n=t||"demo-project",i=e.iat||0,r=e.sub||e.user_id;if(!r)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const s={iss:`https://securetoken.google.com/${n}`,aud:n,iat:i,exp:i+3600,auth_time:i,sub:r,user_id:r,firebase:{sign_in_provider:"custom",identities:{}},...e};return[v(JSON.stringify({alg:"none",type:"JWT"})),v(JSON.stringify(s)),""].join(".")}(i.mockUserToken,e.app.options.projectId);a=new ya(t)}P(t)&&(x(t),N("Database",!0));!function(e,t,n,i){const r=t.lastIndexOf(":"),s=P(t.substring(0,r));e.repoInfo_=new Ca(t,s,e.repoInfo_.namespace,e.repoInfo_.webSocketOnly,e.repoInfo_.nodeAdmin,e.repoInfo_.persistenceKey,e.repoInfo_.includeNamespaceInQueryParams,!0,n),i&&(e.authTokenProvider_=i)}(s,r,i,a)}
|
|
3012
|
+
/**
|
|
3013
|
+
* @license
|
|
3014
|
+
* Copyright 2021 Google LLC
|
|
3015
|
+
*
|
|
3016
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3017
|
+
* you may not use this file except in compliance with the License.
|
|
3018
|
+
* You may obtain a copy of the License at
|
|
3019
|
+
*
|
|
3020
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3021
|
+
*
|
|
3022
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3023
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3024
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3025
|
+
* See the License for the specific language governing permissions and
|
|
3026
|
+
* limitations under the License.
|
|
3027
|
+
*/(n,...e)}return n}so.prototype.simpleListen=function(e,t){this.sendRequest("q",{p:e},t)},so.prototype.echo=function(e,t){this.sendRequest("echo",{d:e},t)},function(e){!function(e){zs=e}(wt),gt(new se("database",(e,{instanceIdentifier:t})=>sh(e.getProvider("app").getImmediate(),e.getProvider("auth-internal"),e.getProvider("app-check-internal"),t),"PUBLIC").setMultipleInstances(!0)),kt(js,Fs,e),kt(js,Fs,"esm2020")}();let lh=[];function ch(e){const t=[...lh];lh=[],t.forEach(e=>{e()}),e.onFirebaseReady?.()}function uh(e){try{const{projectId:t,firebaseApiKey:n,databaseUrl:i,firebaseSenderId:r,firebaseAppId:s,measurementId:a}=e;if(eh=bt({projectId:t,apiKey:n,authDomain:`${t}.firebaseapp.com`,databaseURL:i,storageBucket:`${t}.firebasestorage.app`,messagingSenderId:r,appId:s,measurementId:a},t),!eh)return console.error("Failed to initialize Firebase"),!1}catch(e){return console.error("Failed to initialize Firebase",e),!1}return!0}async function hh(e,t,n){if(!eh&&!uh(e))return;const{netskraflUserId:i,locale:r,projectId:s,loginMethod:a}=e;th=As(eh),th?function(e,t,n,i){re(e).onAuthStateChanged(t,n,i)}(th,t=>{null!==t&&(e.newUser&&gh("sign_up",{locale:r,method:a,userid:i}),gh("login",{locale:r,method:a,userid:i}))}):console.error("Failed to initialize Firebase Auth"),await Sr(th,t),nh=oh(eh),nh?ch(e):console.error("Failed to initialize Firebase Database"),ih=Hn(eh),ih||console.error("Failed to initialize Firebase Analytics"),function(e,t,n){if(!nh)return;const i=Gu(nh,".info/connected"),r="netskrafl"===e?`connection/${t}`:`connection/${n}/${t}`,s=function(e,t){e=re(e),au("push",e._path),nu("push",t,e._path,!0);const n=mu(e._repo),i=zu(n),r=Ku(e,i),s=Ku(e,i);let a;return a=Promise.resolve(s),r.then=a.then.bind(a),r.catch=a.then.bind(a,void 0),r}(Gu(nh,r));Xu(i,e=>{e.val()?(function(e){return e=re(e),new Bu(e._repo,e._path)}(s).remove(),Yu(s,!0)):function(e){au("remove",e._path),Yu(e,null)}(s)})}(s,i,r)}function dh(e,t){if(!nh)return void lh.push(()=>dh(e,t));let n=0;Xu(Gu(nh,e),e=>{n++;const i=e.val();i&&t(i,1===n)})}function ph(e){if(!nh)return;const t=Gu(nh,e);var n;Su((n=t)._repo,n,null)}function gh(e,t){ih&&Gn(ih,e,t)}function fh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var mh,vh,yh,wh,bh,_h,kh,Ch,Sh,Th,Ih,Eh,Ph,xh,Rh,Lh,Nh,Dh,Ah,Mh,Oh,jh,Fh,zh,Uh,$h,qh,Bh,Vh,Hh,Wh,Gh,Kh,Yh,Jh,Zh,Xh,Qh,ed,td,nd,id,rd,sd,ad,od,ld,cd,ud,hd,dd,pd,gd,fd;function md(){if(vh)return mh;function e(e,t,n,i,r,s){return{tag:e,key:t,attrs:n,children:i,text:r,dom:s,is:void 0,domSize:void 0,state:void 0,events:void 0,instance:void 0}}return vh=1,e.normalize=function(t){return Array.isArray(t)?e("[",void 0,void 0,e.normalizeChildren(t),void 0,void 0):null==t||"boolean"==typeof t?null:"object"==typeof t?t:e("#",void 0,void 0,String(t),void 0,void 0)},e.normalizeChildren=function(t){for(var n=new Array(t.length),i=0,r=0;r<t.length;r++)n[r]=e.normalize(t[r]),null!==n[r]&&null!=n[r].key&&i++;if(0!==i&&i!==t.length)throw new TypeError(n.includes(null)?"In fragments, vnodes must either all have keys or none have keys. You may wish to consider using an explicit keyed empty fragment, m.fragment({key: ...}), instead of a hole.":"In fragments, vnodes must either all have keys or none have keys.");return n},mh=e}function vd(){if(wh)return yh;wh=1;var e=md();return yh=function(t,n){return null==t||"object"==typeof t&&null==t.tag&&!Array.isArray(t)?1===n.length&&Array.isArray(n[0])&&(n=n[0]):(n=0===n.length&&Array.isArray(t)?t:[t,...n],t=void 0),e("",t&&t.key,t,n)}}function yd(){return _h?bh:(_h=1,bh={}.hasOwnProperty)}function wd(){return Ch?kh:(Ch=1,kh={})}function bd(){if(Th)return Sh;Th=1;var e=wd();return Sh=new Map([[e,!0]])}function _d(){if(Eh)return Ih;Eh=1;var e=md(),t=vd(),n=yd(),i=wd(),r=bd(),s=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,a=Object.create(null);function o(e){return"value"===e||"checked"===e||"selectedIndex"===e||"selected"===e}function l(e){for(var t,l="div",c=[],u={},h=!0;t=s.exec(e);){var d=t[1],p=t[2];if(""===d&&""!==p)l=p;else if("#"===d)u.id=p;else if("."===d)c.push(p);else if("["===t[3][0]){var g=t[6];g&&(g=g.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),"class"===t[4]?c.push(g):(u[t[4]]=""===g?g:g||!0,o(t[4])&&(h=!1))}}return c.length>0&&(u.className=c.join(" ")),!function(e){for(var t in e)if(n.call(e,t))return!1;return!0}(u)?r.set(u,h):u=i,a[e]={tag:l,attrs:u,is:u.is}}return Ih=function(r,s,...o){if(null==r||"string"!=typeof r&&"function"!=typeof r&&"function"!=typeof r.view)throw Error("The selector must be either a string or a component.");var c=t(s,o);return"string"==typeof r&&(c.children=e.normalizeChildren(c.children),"["!==r)?function(e,t){t.tag=e.tag;var r=t.attrs;if(null==r)return t.attrs=e.attrs,t.is=e.is,t;if(n.call(r,"class")&&(null!=r.class&&(r.className=r.class),r.class=null),e.attrs!==i){var s=r.className;r=Object.assign({},e.attrs,r),null!=e.attrs.className&&(r.className=null!=s?String(e.attrs.className)+" "+String(s):e.attrs.className)}return"input"===e.tag&&n.call(r,"type")&&(r=Object.assign({type:r.type},r)),t.is=r.is,t.attrs=r,t}(a[r]||l(r),c):(null==c.attrs&&(c.attrs={}),c.tag=r,c)},Ih}function kd(){if(Dh)return Nh;Dh=1;var e=_d();return e.trust=function(){if(xh)return Ph;xh=1;var e=md();return Ph=function(t){return null==t&&(t=""),e("<",void 0,void 0,t,void 0,void 0)}}(),e.fragment=function(){if(Lh)return Rh;Lh=1;var e=md(),t=vd();return Rh=function(n,...i){var r=t(n,i);return null==r.attrs&&(r.attrs={}),r.tag="[",r.children=e.normalizeChildren(r.children),r},Rh}(),Nh=e}function Cd(){return Mh?Ah:(Mh=1,Ah=new WeakMap)}function Sd(){if(jh)return Oh;jh=1;var e=Cd();return Oh=function*(t){var n=t.dom,i=t.domSize,r=e.get(n);if(null!=n)do{var s=n.nextSibling;e.get(n)===r&&(yield n,i--),n=s}while(i)},Oh}function Td(){if(zh)return Fh;zh=1;var e=md(),t=Cd(),n=Sd(),i=bd();return Fh=function(){var r,s,a={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"};function o(e){return e.ownerDocument}function l(e){return e.attrs&&e.attrs.xmlns||a[e.tag]}function c(e,t){if(e.state!==t)throw new Error("'vnode.state' must not be modified.")}function u(e){var t=e.state;try{return this.apply(t,arguments)}finally{c(e,t)}}function h(e){try{return o(e).activeElement}catch(e){return null}}function d(e,t,n,i,r,s,a){for(var o=n;o<i;o++){var l=t[o];null!=l&&p(e,l,r,a,s)}}function p(t,n,i,r,s){var a=n.tag;if("string"==typeof a)switch(n.state={},null!=n.attrs&&F(n.attrs,n,i),a){case"#":!function(e,t,n){t.dom=o(e).createTextNode(t.children),C(e,t.dom,n)}(t,n,s);break;case"<":f(t,n,r,s);break;case"[":!function(e,t,n,i,r){var s=o(e).createDocumentFragment();if(null!=t.children){var a=t.children;d(s,a,0,a.length,n,null,i)}t.dom=s.firstChild,t.domSize=s.childNodes.length,C(e,s,r)}(t,n,i,r,s);break;default:!function(e,t,n,i,r){var s=t.tag,a=t.attrs,c=t.is;i=l(t)||i;var u=i?c?o(e).createElementNS(i,s,{is:c}):o(e).createElementNS(i,s):c?o(e).createElement(s,{is:c}):o(e).createElement(s);t.dom=u,null!=a&&function(e,t,n){for(var i in t)L(e,i,null,t[i],n)}(t,a,i);if(C(e,u,r),!S(t)&&null!=t.children){var h=t.children;d(u,h,0,h.length,n,null,i),"select"===t.tag&&null!=a&&function(e,t){if("value"in t)if(null===t.value)-1!==e.dom.selectedIndex&&(e.dom.value=null);else{var n=""+t.value;e.dom.value===n&&-1!==e.dom.selectedIndex||(e.dom.value=n)}"selectedIndex"in t&&L(e,"selectedIndex",null,t.selectedIndex,void 0)}(t,a)}}(t,n,i,r,s)}else!function(t,n,i,r,s){(function(t,n){var i;if("function"==typeof t.tag.view){if(t.state=Object.create(t.tag),null!=(i=t.state.view).$$reentrantLock$$)return;i.$$reentrantLock$$=!0}else{if(t.state=void 0,null!=(i=t.tag).$$reentrantLock$$)return;i.$$reentrantLock$$=!0,t.state=null!=t.tag.prototype&&"function"==typeof t.tag.prototype.view?new t.tag(t):t.tag(t)}F(t.state,t,n),null!=t.attrs&&F(t.attrs,t,n);if(t.instance=e.normalize(u.call(t.state.view,t)),t.instance===t)throw Error("A view cannot return the vnode it received as argument");i.$$reentrantLock$$=null})(n,i),null!=n.instance?(p(t,n.instance,i,r,s),n.dom=n.instance.dom,n.domSize=n.instance.domSize):n.domSize=0}(t,n,i,r,s)}var g={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"};function f(e,t,n,i){var r=t.children.match(/^\s*?<(\w+)/im)||[],s=o(e).createElement(g[r[1]]||"div");"http://www.w3.org/2000/svg"===n?(s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+t.children+"</svg>",s=s.firstChild):s.innerHTML=t.children,t.dom=s.firstChild,t.domSize=s.childNodes.length;for(var a,l=o(e).createDocumentFragment();a=s.firstChild;)l.appendChild(a);C(e,l,i)}function m(e,t,n,i,r,s){if(t!==n&&(null!=t||null!=n))if(null==t||0===t.length)d(e,n,0,n.length,i,r,s);else if(null==n||0===n.length)T(e,t,0,t.length);else{var a=null!=t[0]&&null!=t[0].key,o=null!=n[0]&&null!=n[0].key,l=0,c=0;if(!a)for(;c<t.length&&null==t[c];)c++;if(!o)for(;l<n.length&&null==n[l];)l++;if(a!==o)T(e,t,c,t.length),d(e,n,l,n.length,i,r,s);else if(o){for(var u,h,g,f,m,w=t.length-1,C=n.length-1;w>=c&&C>=l&&(g=t[w],f=n[C],g.key===f.key);)g!==f&&v(e,g,f,i,r,s),null!=f.dom&&(r=f.dom),w--,C--;for(;w>=c&&C>=l&&(u=t[c],h=n[l],u.key===h.key);)c++,l++,u!==h&&v(e,u,h,i,_(t,c,r),s);for(;w>=c&&C>=l&&l!==C&&u.key===f.key&&g.key===h.key;)k(e,g,m=_(t,c,r)),g!==h&&v(e,g,h,i,m,s),++l<=--C&&k(e,u,r),u!==f&&v(e,u,f,i,r,s),null!=f.dom&&(r=f.dom),c++,g=t[--w],f=n[C],u=t[c],h=n[l];for(;w>=c&&C>=l&&g.key===f.key;)g!==f&&v(e,g,f,i,r,s),null!=f.dom&&(r=f.dom),C--,g=t[--w],f=n[C];if(l>C)T(e,t,c,w+1);else if(c>w)d(e,n,l,C+1,i,r,s);else{var S,I,E=r,x=C-l+1,R=new Array(x),L=0,N=0,D=2147483647,A=0;for(N=0;N<x;N++)R[N]=-1;for(N=C;N>=l;N--){null==S&&(S=y(t,c,w+1));var M=S[(f=n[N]).key];null!=M&&(D=M<D?M:-1,R[N-l]=M,g=t[M],t[M]=null,g!==f&&v(e,g,f,i,r,s),null!=f.dom&&(r=f.dom),A++)}if(r=E,A!==w-c+1&&T(e,t,c,w+1),0===A)d(e,n,l,C+1,i,r,s);else if(-1===D)for(I=function(e){var t=[0],n=0,i=0,r=0,s=b.length=e.length;for(r=0;r<s;r++)b[r]=e[r];for(r=0;r<s;++r)if(-1!==e[r]){var a=t[t.length-1];if(e[a]<e[r])b[r]=a,t.push(r);else{for(n=0,i=t.length-1;n<i;){var o=(n>>>1)+(i>>>1)+(n&i&1);e[t[o]]<e[r]?n=o+1:i=o}e[r]<e[t[n]]&&(n>0&&(b[r]=t[n-1]),t[n]=r)}}n=t.length,i=t[n-1];for(;n-- >0;)t[n]=i,i=b[i];return b.length=0,t}(R),L=I.length-1,N=C;N>=l;N--)h=n[N],-1===R[N-l]?p(e,h,i,s,r):I[L]===N-l?L--:k(e,h,r),null!=h.dom&&(r=n[N].dom);else for(N=C;N>=l;N--)h=n[N],-1===R[N-l]&&p(e,h,i,s,r),null!=h.dom&&(r=n[N].dom)}}else{var O=t.length<n.length?t.length:n.length;for(l=l<c?l:c;l<O;l++)(u=t[l])===(h=n[l])||null==u&&null==h||(null==u?p(e,h,i,s,_(t,l+1,r)):null==h?P(e,u):v(e,u,h,i,_(t,l+1,r),s));t.length>O&&T(e,t,l,t.length),n.length>O&&d(e,n,l,n.length,i,r,s)}}}function v(t,n,r,s,a,o){var c=n.tag;if(c===r.tag&&n.is===r.is){if(r.state=n.state,r.events=n.events,function(e,t){do{var n;if(null!=e.attrs&&"function"==typeof e.attrs.onbeforeupdate)if(void 0!==(n=u.call(e.attrs.onbeforeupdate,e,t))&&!n)break;if("string"!=typeof e.tag&&"function"==typeof e.state.onbeforeupdate)if(void 0!==(n=u.call(e.state.onbeforeupdate,e,t))&&!n)break;return!1}while(0);return e.dom=t.dom,e.domSize=t.domSize,e.instance=t.instance,e.attrs=t.attrs,e.children=t.children,e.text=t.text,!0}(r,n))return;if("string"==typeof c)switch(null!=r.attrs&&z(r.attrs,r,s),c){case"#":!function(e,t){e.children.toString()!==t.children.toString()&&(e.dom.nodeValue=t.children);t.dom=e.dom}(n,r);break;case"<":!function(e,t,n,i,r){t.children!==n.children?(x(e,t),f(e,n,i,r)):(n.dom=t.dom,n.domSize=t.domSize)}(t,n,r,o,a);break;case"[":!function(e,t,n,i,r,s){m(e,t.children,n.children,i,r,s);var a=0,o=n.children;if(n.dom=null,null!=o)for(var l=0;l<o.length;l++){var c=o[l];null!=c&&null!=c.dom&&(null==n.dom&&(n.dom=c.dom),a+=c.domSize||1)}n.domSize=a}(t,n,r,s,a,o);break;default:!function(e,t,n,r){var s=t.dom=e.dom;r=l(t)||r,(e.attrs!=t.attrs||null!=t.attrs&&!i.get(t.attrs))&&function(e,t,n,r){var s;if(null!=t)for(var a in t!==n||i.has(n)||console.warn("Don't reuse attrs object, use new object for every redraw, this will throw in next major"),t)null==(s=t[a])||null!=n&&null!=n[a]||N(e,a,s,r);if(null!=n)for(var a in n)L(e,a,t&&t[a],n[a],r)}(t,e.attrs,t.attrs,r);S(t)||m(s,e.children,t.children,n,null,r)}(n,r,s,o)}else!function(t,n,i,r,s,a){if(i.instance=e.normalize(u.call(i.state.view,i)),i.instance===i)throw Error("A view cannot return the vnode it received as argument");z(i.state,i,r),null!=i.attrs&&z(i.attrs,i,r);null!=i.instance?(null==n.instance?p(t,i.instance,r,a,s):v(t,n.instance,i.instance,r,s,a),i.dom=i.instance.dom,i.domSize=i.instance.domSize):(null!=n.instance&&P(t,n.instance),i.domSize=0)}(t,n,r,s,a,o)}else P(t,n),p(t,r,s,o,a)}function y(e,t,n){for(var i=Object.create(null);t<n;t++){var r=e[t];if(null!=r){var s=r.key;null!=s&&(i[s]=t)}}return i}var w,b=[];function _(e,t,n){for(;t<e.length;t++)if(null!=e[t]&&null!=e[t].dom)return e[t].dom;return n}function k(e,t,i){if(null!=t.dom){var r;if(null==t.domSize||1===t.domSize)r=t.dom;else for(var s of(r=o(e).createDocumentFragment(),n(t)))r.appendChild(s);C(e,r,i)}}function C(e,t,n){null!=n?e.insertBefore(t,n):e.appendChild(t)}function S(e){if(null==e.attrs||null==e.attrs.contenteditable&&null==e.attrs.contentEditable)return!1;var t=e.children;if(null!=t&&1===t.length&&"<"===t[0].tag){var n=t[0].children;e.dom.innerHTML!==n&&(e.dom.innerHTML=n)}else if(null!=t&&0!==t.length)throw new Error("Child node of a contenteditable must be trusted.");return!0}function T(e,t,n,i){for(var r=n;r<i;r++){var s=t[r];null!=s&&P(e,s)}}function I(e,i,r,a){var o=i.state,l=u.call(r.onbeforeremove,i);if(null!=l){var h=s;for(var d of n(i))t.set(d,h);a.v++,Promise.resolve(l).finally(function(){c(i,o),E(e,i,a)})}}function E(e,t,n){0===--n.v&&(R(t),x(e,t))}function P(e,t){var n={v:1};"string"!=typeof t.tag&&"function"==typeof t.state.onbeforeremove&&I(e,t,t.state,n),t.attrs&&"function"==typeof t.attrs.onbeforeremove&&I(e,t,t.attrs,n),E(e,t,n)}function x(e,t){if(null!=t.dom)if(null==t.domSize||1===t.domSize)e.removeChild(t.dom);else for(var i of n(t))e.removeChild(i)}function R(e){if("string"!=typeof e.tag&&"function"==typeof e.state.onremove&&u.call(e.state.onremove,e),e.attrs&&"function"==typeof e.attrs.onremove&&u.call(e.attrs.onremove,e),"string"!=typeof e.tag)null!=e.instance&&R(e.instance);else{null!=e.events&&(e.events._=null);var t=e.children;if(Array.isArray(t))for(var n=0;n<t.length;n++){var i=t[n];null!=i&&R(i)}}}function L(e,t,n,i,r){if("key"!==t&&null!=i&&!D(t)&&(n!==i||function(e,t){return"value"===t||"checked"===t||"selectedIndex"===t||"selected"===t&&(e.dom===h(e.dom)||"option"===e.tag&&e.dom.parentNode===h(e.dom))}(e,t)||"object"==typeof i)){if("o"===t[0]&&"n"===t[1])return j(e,t,i);if("xlink:"===t.slice(0,6))e.dom.setAttributeNS("http://www.w3.org/1999/xlink",t.slice(6),i);else if("style"===t)M(e.dom,n,i);else if(A(e,t,r)){if("value"===t){if(("input"===e.tag||"textarea"===e.tag)&&e.dom.value===""+i)return;if("select"===e.tag&&null!==n&&e.dom.value===""+i)return;if("option"===e.tag&&null!==n&&e.dom.value===""+i)return;if("input"===e.tag&&"file"===e.attrs.type&&""+i!="")return void console.error("`value` is read-only on file inputs!")}"input"===e.tag&&"type"===t?e.dom.setAttribute(t,i):e.dom[t]=i}else"boolean"==typeof i?i?e.dom.setAttribute(t,""):e.dom.removeAttribute(t):e.dom.setAttribute("className"===t?"class":t,i)}}function N(e,t,n,i){if("key"!==t&&null!=n&&!D(t))if("o"===t[0]&&"n"===t[1])j(e,t,void 0);else if("style"===t)M(e.dom,n,null);else if(!A(e,t,i)||"className"===t||"title"===t||"value"===t&&("option"===e.tag||"select"===e.tag&&-1===e.dom.selectedIndex&&e.dom===h(e.dom))||"input"===e.tag&&"type"===t){var r=t.indexOf(":");-1!==r&&(t=t.slice(r+1)),!1!==n&&e.dom.removeAttribute("className"===t?"class":t)}else e.dom[t]=null}function D(e){return"oninit"===e||"oncreate"===e||"onupdate"===e||"onremove"===e||"onbeforeremove"===e||"onbeforeupdate"===e}function A(e,t,n){return void 0===n&&(e.tag.indexOf("-")>-1||e.is||"href"!==t&&"list"!==t&&"form"!==t&&"width"!==t&&"height"!==t)&&t in e.dom}function M(e,t,n){if(t===n);else if(null==n)e.style="";else if("object"!=typeof n)e.style=n;else if(null==t||"object"!=typeof t)for(var i in e.style="",n){null!=(r=n[i])&&(i.includes("-")?e.style.setProperty(i,String(r)):e.style[i]=String(r))}else{for(var i in t)null!=t[i]&&null==n[i]&&(i.includes("-")?e.style.removeProperty(i):e.style[i]="");for(var i in n){var r;null!=(r=n[i])&&(r=String(r))!==String(t[i])&&(i.includes("-")?e.style.setProperty(i,r):e.style[i]=r)}}}function O(){this._=r}function j(e,t,n){if(null!=e.events){if(e.events._=r,e.events[t]===n)return;null==n||"function"!=typeof n&&"object"!=typeof n?(null!=e.events[t]&&e.dom.removeEventListener(t.slice(2),e.events,!1),e.events[t]=void 0):(null==e.events[t]&&e.dom.addEventListener(t.slice(2),e.events,!1),e.events[t]=n)}else null==n||"function"!=typeof n&&"object"!=typeof n||(e.events=new O,e.dom.addEventListener(t.slice(2),e.events,!1),e.events[t]=n)}function F(e,t,n){"function"==typeof e.oninit&&u.call(e.oninit,t),"function"==typeof e.oncreate&&n.push(u.bind(e.oncreate,t))}function z(e,t,n){"function"==typeof e.onupdate&&n.push(u.bind(e.onupdate,t))}return O.prototype=Object.create(null),O.prototype.handleEvent=function(e){var t,n=this["on"+e.type];"function"==typeof n?t=n.call(e.currentTarget,e):"function"==typeof n.handleEvent&&n.handleEvent(e);var i=this;null!=i._&&(!1!==e.redraw&&(0,i._)(),null!=t&&"function"==typeof t.then&&Promise.resolve(t).then(function(){null!=i._&&!1!==e.redraw&&(0,i._)()})),!1===t&&(e.preventDefault(),e.stopPropagation())},function(t,n,i){if(!t)throw new TypeError("DOM element being rendered to does not exist.");if(null!=w&&t.contains(w))throw new TypeError("Node is currently being rendered to and thus is locked.");var a=r,o=w,l=[],c=h(t),u=t.namespaceURI;w=t,r="function"==typeof i?i:void 0,s={};try{null==t.vnodes&&(t.textContent=""),n=e.normalizeChildren(Array.isArray(n)?n:[n]),m(t,t.vnodes,n,l,null,"http://www.w3.org/1999/xhtml"===u?void 0:u),t.vnodes=n,null!=c&&h(t)!==c&&"function"==typeof c.focus&&c.focus();for(var d=0;d<l.length;d++)l[d]()}finally{r=a,w=o}}},Fh}function Id(){return $h?Uh:($h=1,Uh=Td()())}function Ed(){if(Hh)return Vh;Hh=1;var e=Id();return Vh=function(){if(Bh)return qh;Bh=1;var e=md();return qh=function(t,n,i){var r=[],s=!1,a=-1;function o(){for(a=0;a<r.length;a+=2)try{t(r[a],e(r[a+1]),l)}catch(e){i.error(e)}a=-1}function l(){s||(s=!0,n(function(){s=!1,o()}))}return l.sync=o,{mount:function(n,i){if(null!=i&&null==i.view&&"function"!=typeof i)throw new TypeError("m.mount expects a component, not a vnode.");var s=r.indexOf(n);s>=0&&(r.splice(s,2),s<=a&&(a-=2),t(n,[])),null!=i&&(r.push(n,i),t(n,e(i),l))},redraw:l}},qh}()(e,"undefined"!=typeof requestAnimationFrame?requestAnimationFrame:null,"undefined"!=typeof console?console:null),Vh}function Pd(){return Gh?Wh:(Gh=1,Wh=function(e){if("[object Object]"!==Object.prototype.toString.call(e))return"";var t=[];for(var n in e)i(n,e[n]);return t.join("&");function i(e,n){if(Array.isArray(n))for(var r=0;r<n.length;r++)i(e+"["+r+"]",n[r]);else if("[object Object]"===Object.prototype.toString.call(n))for(var r in n)i(e+"["+r+"]",n[r]);else t.push(encodeURIComponent(e)+(null!=n&&""!==n?"="+encodeURIComponent(n):""))}})}function xd(){if(Yh)return Kh;Yh=1;var e=Pd();return Kh=function(t,n){if(/:([^\/\.-]+)(\.{3})?:/.test(t))throw new SyntaxError("Template parameter names must be separated by either a '/', '-', or '.'.");if(null==n)return t;var i=t.indexOf("?"),r=t.indexOf("#"),s=r<0?t.length:r,a=i<0?s:i,o=t.slice(0,a),l={};Object.assign(l,n);var c=o.replace(/:([^\/\.-]+)(\.{3})?/g,function(e,t,i){return delete l[t],null==n[t]?e:i?n[t]:encodeURIComponent(String(n[t]))}),u=c.indexOf("?"),h=c.indexOf("#"),d=h<0?c.length:h,p=u<0?d:u,g=c.slice(0,p);i>=0&&(g+=t.slice(i,s)),u>=0&&(g+=(i<0?"?":"&")+c.slice(u,d));var f=e(l);return f&&(g+=(i<0&&u<0?"?":"&")+f),r>=0&&(g+=t.slice(r)),h>=0&&(g+=(r<0?"":"&")+c.slice(h)),g},Kh}function Rd(){if(Zh)return Jh;Zh=1;var e=xd(),t=yd();return Jh=function(n,i){function r(e){return new Promise(e)}function s(e,n){for(var i in e.headers)if(t.call(e.headers,i)&&i.toLowerCase()===n)return!0;return!1}return r.prototype=Promise.prototype,r.__proto__=Promise,{request:function(a,o){"string"!=typeof a?(o=a,a=a.url):null==o&&(o={});var l=function(i,r){return new Promise(function(a,o){i=e(i,r.params);var l,c=null!=r.method?r.method.toUpperCase():"GET",u=r.body,h=(null==r.serialize||r.serialize===JSON.serialize)&&!(u instanceof n.FormData||u instanceof n.URLSearchParams),d=r.responseType||("function"==typeof r.extract?"":"json"),p=new n.XMLHttpRequest,g=!1,f=!1,m=p,v=p.abort;for(var y in p.abort=function(){g=!0,v.call(this)},p.open(c,i,!1!==r.async,"string"==typeof r.user?r.user:void 0,"string"==typeof r.password?r.password:void 0),h&&null!=u&&!s(r,"content-type")&&p.setRequestHeader("Content-Type","application/json; charset=utf-8"),"function"==typeof r.deserialize||s(r,"accept")||p.setRequestHeader("Accept","application/json, text/*"),r.withCredentials&&(p.withCredentials=r.withCredentials),r.timeout&&(p.timeout=r.timeout),p.responseType=d,r.headers)t.call(r.headers,y)&&p.setRequestHeader(y,r.headers[y]);p.onreadystatechange=function(e){if(!g&&4===e.target.readyState)try{var t,n=e.target.status>=200&&e.target.status<300||304===e.target.status||/^file:\/\//i.test(i),s=e.target.response;if("json"===d){if(!e.target.responseType&&"function"!=typeof r.extract)try{s=JSON.parse(e.target.responseText)}catch(e){s=null}}else d&&"text"!==d||null==s&&(s=e.target.responseText);if("function"==typeof r.extract?(s=r.extract(e.target,r),n=!0):"function"==typeof r.deserialize&&(s=r.deserialize(s)),n){if("function"==typeof r.type)if(Array.isArray(s))for(var l=0;l<s.length;l++)s[l]=new r.type(s[l]);else s=new r.type(s);a(s)}else{var c=function(){try{t=e.target.responseText}catch(e){t=s}var n=new Error(t);n.code=e.target.status,n.response=s,o(n)};0===p.status?setTimeout(function(){f||c()}):c()}}catch(e){o(e)}},p.ontimeout=function(e){f=!0;var t=new Error("Request timed out");t.code=e.target.status,o(t)},"function"==typeof r.config&&(p=r.config(p,r,i)||p)!==m&&(l=p.abort,p.abort=function(){g=!0,l.call(this)}),null==u?p.send():"function"==typeof r.serialize?p.send(r.serialize(u)):u instanceof n.FormData||u instanceof n.URLSearchParams?p.send(u):p.send(JSON.stringify(u))})}(a,o);if(!0===o.background)return l;var c=0;function u(){0===--c&&"function"==typeof i&&i()}return function e(t){var n=t.then;return t.constructor=r,t.then=function(){c++;var i=n.apply(t,arguments);return i.then(u,function(e){if(u(),0===c)throw e}),e(i)},t}(l)}}},Jh}function Ld(){if(td)return ed;td=1;var e=/%(?:[0-7]|(?!c[01]|e0%[89]|ed%[ab]|f0%8|f4%[9ab])(?:c|d|(?:e|f[0-4]%[89ab])[\da-f]%[89ab])[\da-f]%[89ab])[\da-f]/gi;return ed=function(t){return String(t).replace(e,decodeURIComponent)}}function Nd(){if(id)return nd;id=1;var e=Ld();return nd=function(t){if(""===t||null==t)return{};"?"===t.charAt(0)&&(t=t.slice(1));for(var n=t.split("&"),i={},r={},s=0;s<n.length;s++){var a=n[s].split("="),o=e(a[0]),l=2===a.length?e(a[1]):"";"true"===l?l=!0:"false"===l&&(l=!1);var c=o.split(/\]\[?|\[/),u=r;o.indexOf("[")>-1&&c.pop();for(var h=0;h<c.length;h++){var d=c[h],p=c[h+1],g=""==p||!isNaN(parseInt(p,10));if(""===d)null==i[o=c.slice(0,h).join()]&&(i[o]=Array.isArray(u)?u.length:0),d=i[o]++;else if("__proto__"===d)break;if(h===c.length-1)u[d]=l;else{var f=Object.getOwnPropertyDescriptor(u,d);null!=f&&(f=f.value),null==f&&(u[d]=f=g?[]:{}),u=f}}}return r}}function Dd(){if(sd)return rd;sd=1;var e=Nd();return rd=function(t){var n=t.indexOf("?"),i=t.indexOf("#"),r=i<0?t.length:i,s=n<0?r:n,a=t.slice(0,s).replace(/\/{2,}/g,"/");return a?"/"!==a[0]&&(a="/"+a):a="/",{path:a,params:n<0?{}:e(t.slice(n+1,r))}}}function Ad(){if(od)return ad;od=1;var e=Dd();return ad=function(t){var n=e(t),i=Object.keys(n.params),r=[],s=new RegExp("^"+n.path.replace(/:([^\/.-]+)(\.{3}|\.(?!\.)|-)?|[\\^$*+.()|\[\]{}]/g,function(e,t,n){return null==t?"\\"+e:(r.push({k:t,r:"..."===n}),"..."===n?"(.*)":"."===n?"([^/]+)\\.":"([^/]+)"+(n||""))})+"\\/?$");return function(e){for(var t=0;t<i.length;t++)if(n.params[i[t]]!==e.params[i[t]])return!1;if(!r.length)return s.test(e.path);var a=s.exec(e.path);if(null==a)return!1;for(t=0;t<r.length;t++)e.params[r[t].k]=r[t].r?a[t+1]:decodeURIComponent(a[t+1]);return!0}},ad}function Md(){if(cd)return ld;cd=1;var e=yd(),t=/^(?:key|oninit|oncreate|onbeforeupdate|onupdate|onbeforeremove|onremove)$/;return ld=function(n,i){var r={};if(null!=i)for(var s in n)e.call(n,s)&&!t.test(s)&&i.indexOf(s)<0&&(r[s]=n[s]);else for(var s in n)e.call(n,s)&&!t.test(s)&&(r[s]=n[s]);return r}}function Od(){if(pd)return dd;pd=1;var e=Ed();return dd=function(){if(hd)return ud;hd=1;var e=md(),t=_d(),n=Ld(),i=xd(),r=Dd(),s=Ad(),a=Md();return ud=function(o,l){var c,u,h,d,p,g,f,m,v=Promise.resolve(),y=!1,w=!1,b=!1,_={onremove:function(){w=b=!1,o.removeEventListener("popstate",S,!1)},view:function(){var t=e(p,g.key,g);return d?d.render(t):[t]}},k=T.SKIP={};function C(){y=!1;var e=o.location.hash;"#"!==T.prefix[0]&&(e=o.location.search+e,"?"!==T.prefix[0]&&"/"!==(e=o.location.pathname+e)[0]&&(e="/"+e));var t=n(e).slice(T.prefix.length),i=r(t);function s(e){console.error(e),T.set(h,null,{replace:!0})}Object.assign(i.params,o.history.state),function e(n){for(;n<u.length;n++)if(u[n].check(i)){var r=u[n].component,a=u[n].route,o=r,y=m=function(s){if(y===m){if(s===k)return e(n+1);p=null==s||"function"!=typeof s.view&&"function"!=typeof s?"div":s,g=i.params,f=t,m=null,d=r.render?r:null,b?l.redraw():(b=!0,l.mount(c,_))}};return void(r.view||"function"==typeof r?(r={},y(o)):r.onmatch?v.then(function(){return r.onmatch(i.params,t,a)}).then(y,t===h?null:s):y())}if(t===h)throw new Error("Could not resolve default route "+h+".");T.set(h,null,{replace:!0})}(0)}function S(){y||(y=!0,setTimeout(C))}function T(e,t,n){if(!e)throw new TypeError("DOM element being rendered to does not exist.");if(u=Object.keys(n).map(function(e){if("/"!==e[0])throw new SyntaxError("Routes must start with a '/'.");if(/:([^\/\.-]+)(\.{3})?:/.test(e))throw new SyntaxError("Route parameter names must be separated with either '/', '.', or '-'.");return{route:e,component:n[e],check:s(e)}}),h=t,null!=t){var i=r(t);if(!u.some(function(e){return e.check(i)}))throw new ReferenceError("Default route doesn't match any known routes.")}c=e,o.addEventListener("popstate",S,!1),w=!0,C()}return T.set=function(e,t,n){if(null!=m&&((n=n||{}).replace=!0),m=null,e=i(e,t),w){S();var r=n?n.state:null,s=n?n.title:null;n&&n.replace?o.history.replaceState(r,s,T.prefix+e):o.history.pushState(r,s,T.prefix+e)}else o.location.href=T.prefix+e},T.get=function(){return f},T.prefix="#!",T.Link={view:function(e){var n,r,s,o=t(e.attrs.selector||"a",a(e.attrs,["options","params","selector","onclick"]),e.children);return(o.attrs.disabled=Boolean(o.attrs.disabled))?(o.attrs.href=null,o.attrs["aria-disabled"]="true"):(n=e.attrs.options,r=e.attrs.onclick,s=i(o.attrs.href,e.attrs.params),o.attrs.href=T.prefix+s,o.attrs.onclick=function(e){var t;"function"==typeof r?t=r.call(e.currentTarget,e):null==r||"object"!=typeof r||"function"==typeof r.handleEvent&&r.handleEvent(e),!1===t||e.defaultPrevented||0!==e.button&&0!==e.which&&1!==e.which||e.currentTarget.target&&"_self"!==e.currentTarget.target||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||(e.preventDefault(),e.redraw=!1,T.set(s,null,n))}),o}},T.param=function(e){return g&&null!=e?g[e]:g},T},ud}()("undefined"!=typeof window?window:null,e),dd}var jd=function(){if(fd)return gd;fd=1;var e=kd(),t=Ed(),n=function(){if(Qh)return Xh;Qh=1;var e=Ed();return Xh=Rd()("undefined"!=typeof window?window:null,e.redraw)}(),i=Od(),r=function(){return e.apply(this,arguments)};return r.m=e,r.trust=e.trust,r.fragment=e.fragment,r.Fragment="[",r.mount=t.mount,r.route=i,r.render=Id(),r.redraw=t.redraw,r.request=n.request,r.parseQueryString=Nd(),r.buildQueryString=Pd(),r.parsePathname=Dd(),r.buildPathname=xd(),r.vnode=md(),r.censor=Md(),r.domFor=Sd(),gd=r}(),Fd=fh(jd);const zd=(e,t)=>`${e.serverUrl}${t}`,Ud=async e=>{const{userEmail:t,userNick:n,userFullname:i,token:r}=e;return((e,t)=>Fd.request({withCredentials:!1,...t,url:zd(e,t.url)}))(e,{method:"POST",url:"/login_malstadur",body:{email:t,nickname:n,fullname:i,token:r,bearer_auth:!0}})},$d=12e4;let qd=null,Bd=null,Vd=0,Hd=0,Wd=!1,Gd=0;class Kd extends Error{constructor(){super("Authentication required"),this.name="AuthenticationError"}}class Yd extends Error{constructor(e){super(e),this.name="LoginThrottledError"}}const Jd=e=>new Promise(t=>setTimeout(t,e)),Zd=e=>{const t=500*2**(e-1);return Math.min(t,5e3)},Xd=()=>{Vd=0,Wd=!1,Gd=0},Qd=()=>{Wd=!0,Gd=Date.now()+$d,Vd=0,console.error(`Circuit breaker opened. Login attempts blocked until ${new Date(Gd).toLocaleTimeString()}`)},ep=e=>qd||(qd=tp(e).finally(()=>{qd=null}),qd),tp=async e=>{if(Wd&&Date.now()>=Gd&&Xd(),Wd){const e=Math.ceil((Gd-Date.now())/6e4);throw new Yd(`Too many failed login attempts. Please wait ${e} minute(s) before trying again.`)}if(Date.now()-Hd<500&&Vd>0)throw new Yd("Please wait a moment before trying again.");let t=!0;for(;t&&Vd<3;){if(t=!1,Vd++,Hd=Date.now(),Vd>=2){const e=Zd(Vd-1);await Jd(e)}try{const n=await Ud(e);if("expired"===n.status){if(e.tokenExpired)try{const n=await e.tokenExpired();"string"==typeof n&&n&&(e.token=n),Vd=0,t=!0;continue}catch(e){throw Vd=0,l(),new Error(`Failed to refresh authentication token: ${e instanceof Error?e.message:String(e)}`)}throw Vd=0,l(),new Error("Authentication token has expired. Please log in again.")}if("success"!==n.status)throw l(),new Error(`Authentication failed: ${n.message||n.status}`);e.netskraflUserId=n.user_id||e.netskraflUserId,e.account=n.account||e.netskraflUserId,e.userNick=n.nickname||e.userNick,e.firebaseApiKey=n.firebase_api_key||e.firebaseApiKey,e.beginner=n.prefs?.beginner??!0,e.fairPlay=n.prefs?.fairplay??!1,e.ready=n.prefs?.ready??!0,e.readyTimed=n.prefs?.ready_timed??!0,e.audio=n.prefs?.audio??!1,e.fanfare=n.prefs?.fanfare??!1,e.hasPaid=n.prefs?.haspaid??!1;const i=n.token||"";return e.netskraflToken=i,Bd={token:i,userEmail:e.userEmail},o({userEmail:e.userEmail,netskraflUserId:e.netskraflUserId,userNick:e.userNick,firebaseApiKey:e.firebaseApiKey,netskraflToken:e.netskraflToken,beginner:e.beginner,fairPlay:e.fairPlay,ready:e.ready,readyTimed:e.readyTimed,audio:e.audio,fanfare:e.fanfare}),Fd.redraw(),await hh(e,n.firebase_token),void Xd()}catch(e){if(Vd>=3)throw Qd(),new Error(`Login failed after 3 attempts. Please wait ${Math.ceil(2)} minutes before trying again.`);if(!t)throw e}}if(Vd>=3)throw Qd(),new Error("Maximum login attempts exceeded. Please try again later.")},np=async(e,t,n=0)=>{if(qd)try{await qd}catch(e){}Bd&&Bd.userEmail===e.userEmail&&e.netskraflToken!==Bd.token?e.netskraflToken=Bd.token:!e.netskraflToken||Bd&&Bd.userEmail===e.userEmail||(Bd={token:e.netskraflToken,userEmail:e.userEmail}),n||function(e){if(th||(eh||uh(e),eh&&(th=As(eh))),!th||null===th.currentUser)return!1;if(!nh&&eh){if(nh=oh(eh),!nh)return console.error("Failed to initialize Firebase Database"),!1;ch(e),ih||(ih=Hn(eh),ih||console.error("Failed to initialize Firebase Analytics"))}return!0}(e)&&e.netskraflToken||await ep(e);try{let n=!0,{headers:i}=t;const r=e.netskraflToken;return r&&"*"!==r&&(i={...i,Authorization:`Bearer ${r}`},n=!1),await Fd.request({withCredentials:n,...t,url:zd(e,t.url),headers:i,extract:e=>{if(401===e.status)throw new Kd;if(!e.responseText)return null;try{return JSON.parse(e.responseText)}catch(t){return e.responseText}}})}catch(i){if(i instanceof Kd&&!n)return await ep(e),np(e,t,n+1);throw i}},ip=(e,t)=>np(e,t),rp=(e,t)=>{const n=`${e.movesUrl}${t.url}`,i={"Content-Type":"application/json; charset=UTF-8",Authorization:`Bearer ${e.movesAccessKey}`,...t?.headers};return Fd.request({withCredentials:!1,method:"POST",...t,url:n,headers:i})},sp="ABCDEFGHIJKLMNO",ap=15,op=1.5,lp="2025-11-01",cp={1:"Enginn stafur lagður niður",2:"Fyrsta orð verður að liggja um byrjunarreitinn",3:"Orð verður að vera samfellt á borðinu",4:"Orð verður að tengjast orði sem fyrir er",5:"Reitur þegar upptekinn",6:"Ekki má vera eyða í orði",7:"word_not_found",8:"word_not_found",9:"Of margir stafir lagðir niður",10:"Stafur er ekki í rekkanum",11:"Of fáir stafir eftir, skipting ekki leyfð",12:"Of mörgum stöfum skipt",13:"Leik vantar á borðið - notið F5/Refresh",14:"Notandi ekki innskráður - notið F5/Refresh",15:"Rangur eða óþekktur notandi",16:"Viðureign finnst ekki",17:"Viðureign er ekki utan tímamarka",18:"Netþjónn gat ekki tekið við leiknum - reyndu aftur",19:"Véfenging er ekki möguleg í þessari viðureign",20:"Síðasti leikur er ekki véfengjanlegur",21:"Aðeins véfenging eða pass leyfileg",server:"Netþjónn gat ekki tekið við leiknum - reyndu aftur"};class up{constructor(e,t){this.sounds=new Map,this.initialized=!1;const n=zd(e,"/static"),i={"your-turn":`${n}/your-turn.mp3`,"you-win":`${n}/you-win.mp3`,"new-msg":`${n}/new-msg.mp3`};this.soundUrls={...i,...t||{}}}initialize(){this.initialized||(Object.entries(this.soundUrls).forEach(([e,t])=>{const n=new Audio(t);n.preload="auto",n.addEventListener("error",()=>{console.warn(`Failed to load audio: ${e} from ${t}`)}),this.sounds.set(e,n)}),this.initialized=!0)}play(e){this.initialized||this.initialize();const t=this.sounds.get(e);t?(t.currentTime=0,t.play().catch(t=>{"NotAllowedError"!==t.name&&console.warn(`Failed to play audio ${e}:`,t)})):console.warn(`Audio not found: ${e}`)}updateSoundUrl(e,t){if(this.soundUrls[e]=t,this.initialized){const n=new Audio(t);n.preload="auto",n.addEventListener("error",()=>{console.warn(`Failed to load audio: ${e} from ${t}`)}),this.sounds.set(e,n)}}dispose(){this.sounds.forEach(e=>{e.pause(),e.src=""}),this.sounds.clear(),this.initialized=!1}}let hp=null;function dp(e,t){return hp||(hp=new up(e,t)),hp}var pp={Leikir:{en:"Moves",nb:"Trekk",nn:"Trekk",pl:"Ruchy",ga:"Bogann"},submit_move:{is:"Leika",en:"Move",nb:"Trekk",nn:"Trekk",pl:"Wykonaj ruch",ga:"Bog"},"Viðureignir":{en:"Games",nb:"Spill",nn:"Spel",pl:"Gry",ga:"Cluichí"},"Borðið":{en:"Board",nb:"Brett",nn:"Brett",pl:"Plansza",ga:"Bord"},"Tveggja stafa orð":{en:"Two letter words",nb:"Tobokstavsord",nn:"Tobokstavsord",pl:"Dwuliterowe słowa",ga:"Focail dhá litir"},Spjall:{en:"Chat",nb:"Chat",nn:"Chat",pl:"Czat",ga:"Comhrá"},"Þessi vefslóð er ekki rétt":{en:"Unknown URL",nb:"Ukjent URL",nn:"Ukjend URL",pl:"Nieznany URL",ga:"URL Anaithnid"},player_info:{is:"Upplýsingar um leikmann",en:"Player information",nb:"Spillerinformasjon",nn:"Spelarinformasjon",pl:"Informacje o graczu",ga:"Eolas Imreoir"},"Einkenni:":{en:"Nickname:",nb:"Kallenavn:",nn:"Kallenamn:",pl:"Pseudonim:",ga:"Leasainm:"},"Verður að vera útfyllt":{en:"Required field",nb:"Obligatorisk felt",nn:"Obligatorisk felt",pl:"Pole wymagane",ga:"Réimse Riachtanach"},"Fullt nafn:":{en:"Full name:",nb:"Fullt navn:",nn:"Fullt namn:",pl:"Pełne imię i nazwisko:",ga:"Ainm Iomlán:"},"Valfrjálst - sýnt í notendalistum Netskrafls":{en:"Optional - shown in user lists",nb:"Valgfritt - vist i brukerlister",nn:"Valfritt - vist i brukarlister",pl:"Opcjonalne - pokazane na listach użytkowników",ga:"Roghnach - le feiceáil i liostaí úsáideoirí"},"Tölvupóstfang:":{en:"E-mail:",nb:"E-post:",nn:"E-post:",pl:"E-mail:",ga:"Ríomhphost:"},explain_email:{is:"Ef póstfang er gefið upp mun Netskrafl geta sent tölvupóst þegar þú átt leik",en:"If given, Explo can send e-mail to the address when it's your turn in a game",nb:"Hvis oppgitt, kan Explo sende e-post til adressen når det er din tur i et spill",nn:"Viss oppgjeve, kan Explo sende e-post til adressa når det er din tur i eit spel",pl:"Jeśli podano, Explo może wysłać e-mail na ten adres, gdy nadejdzie Twoja kolej w grze",ga:"Más tugadh é, is féidir le Explo ríomhphost a sheoladh chuig an seoladh nuair atá sé do sheal sa chluiche"},"Hljóðmerki:":{en:"Sounds:",nb:"Lyder:",nn:"Lydar:",pl:"Dźwięki:",ga:"Fuaimeanna:"},"Hljóð á/af":{en:"Sound on/off",nb:"Lyd på/av",nn:"Lyd på/av",pl:"Dźwięki włącz/wyłącz",ga:"Fuaimeanna ar/amuigh"},"Lúðraþytur eftir sigur:":{en:"Fanfare after a win:",nb:"Trompeter etter seier:",nn:"Trompeter etter siger:",pl:"Trąbki po zwycięstwie:",ga:"Trumpaí tar éis bua:"},"Lúðraþytur á/af":{en:"Fanfare on/off",nb:"Trompeter på/av",nn:"Trompeter på/av",pl:"Trąbki włącz/wyłącz",ga:"Trumpaí ar/amuigh"},explain_sound:{is:"Stillir hvort hljóðmerki heyrast t.d. þegar andstæðingur leikur og þegar sigur vinnst",en:"Controls whether sounds are played, e.g. when an opponent makes a move or when you win",nb:"Kontrollerer om lyder spilles, f.eks. når en motstander gjør et trekk eller når du vinner",nn:"Kontrollerer om lydar blir spelte, t.d. når ein motstandar gjer eit trekk eller når du vinn",pl:"Kontroluje, czy dźwięki są odtwarzane, np. gdy przeciwnik wykonuje ruch lub gdy wygrywasz",ga:"Rialaíonn sé an seinntear fuaimeanna, m.sh. nuair a bhogann freasúra nó nuair a bhuaigh tú"},"Sýna reitagildi:":{en:"Show multipliers:",nb:"Vis multiplikatorer:",nn:"Vis multiplikatorar:",pl:"Pokaż mnożniki:",ga:"Taispeáin iolraitheoirí:"},"Nýi skraflpokinn:":{en:"Use the new bag:",nb:"Bruk den nye posen:",nn:"Bruk den nye posen:",pl:"Użyj nowego worka:",ga:"Bain úsáid as an mála nua:"},"Án hjálpartækja:":{en:"Without helpers:",nb:"Uten hjelpemidler:",nn:"Utan hjelpemiddel:",pl:"Bez pomocy:",ga:"Gan chúntóirí:"},Vista:{en:"Save",nb:"Lagre",nn:"Lagre",pl:"Zapisz",ga:"Sábháil"},"Hætta við":{en:"Cancel",nb:"Avbryt",nn:"Bryt av",pl:"Anuluj",ga:"Cealaigh"},"Skrá mig út":{en:"Log out",nb:"Logg ut",nn:"Logg ut",pl:"Wyloguj się",ga:"Logáil Amach"},"Þú ert áskrifandi!":{en:"You're a subscriber!",nb:"Du er en abonnent!",nn:"Du er ein abonnent!",pl:"Jesteś subskrybentem!",ga:"Is síntiúsóir tú!"},"Gerast áskrifandi":{en:"Subscribe",nb:"Abonner",nn:"Abonner",pl:"Subskrybuj",ga:"Liostáil"},"Tek við áskorunum!":{en:"Accepting challenges!",nb:"Aksepterer utfordringer!",nn:"Tek imot utfordringar!",pl:"Akceptuje wyzwania!",ga:"Ag glacadh le dúshláin!"},"Til í viðureign með klukku!":{en:"Ready for timed games!",nb:"Klar for tidsbegrensede spill!",nn:"Klar for tidsavgrensa spel!",pl:"Gotowy na gry z czasem!",ga:"Réidh do chluichí ama!"},"Stillir hvort ":{en:"Controls whether ",nb:"Kontrollerer om ",nn:"Styrer om ",pl:"Kontroluje czy ",ga:"Rialaíonn sé an "},"minnismiði":{en:"a memo sticker",nb:"en huskelapp",nn:"ein hugselapp",pl:"naklejka memo",ga:"nóta meabhrúcháin"}," um margföldunargildi reita er sýndur við borðið":{en:" with square multipliers is shown beside the board",nb:" med rute-multiplikatorer vises ved siden av brettet",nn:" med rute-multiplikatorar blir vist ved sida av brettet",pl:" z mnożnikami kwadratów jest pokazany obok planszy",ga:" le hiolraitheoirí cearnóg le feiceáil in aice leis an mbord"},"Gefur til kynna hvort þú sért reiðubúin(n) að\nskrafla með ":{en:"Indicates whether you are ready to play with\n",nb:"Indikerer om du er klar til å spille med\n",nn:"Indikerer om du er klar til å spele med\n",pl:"Wskazuje czy jesteś gotowy do gry z\n",ga:"Léiríonn sé an bhfuil tú ullamh chun imeartha le\n"},"nýja íslenska skraflpokanum":{en:"the new tile bag",nb:"den nye brikkeposen",nn:"den nye brikkeposen",pl:"nowym workiem z kafelkami",ga:"an mála tíleanna nua"},no_helpers:{is:"Með því að velja þessa merkingu lýsir þú því yfir að þú\nskraflir við aðra leikmenn ",en:"By selecting this option, you declare that you play\nagainst other humans ",nb:"Ved å velge dette alternativet, erklærer du at du spiller\nmot andre mennesker ",nn:"Ved å velje dette, stadfester du at du spelar\nmot andre menneske ",pl:"Wybierając tę opcję, deklarujesz, że grasz\nprzeciwko innym ludziom ",ga:"Trí an rogha seo a roghnú, dearbhaíonn tú go n-imríonn tú\ni gcoinne daoine eile "},"án stafrænna hjálpartækja":{en:"without helpers or tools",nb:"uten hjelpemidler eller verktøy",nn:"utan hjelpemiddel eller verktøy",pl:"bez pomocy lub narzędzi",ga:"gan chúntóirí ná uirlisí"}," af nokkru tagi":{en:" of any kind",nb:" av noe slag",nn:" av noko slag",pl:" jakiegokolwiek rodzaju",ga:" de chineál ar bith"},"Áskoranir":{en:"Challenges",nb:"Utfordringer",nn:"Utfordringar",pl:"Wyzwania",ga:"Dúshláin"},"Andstæðingar":{en:"Opponents",nb:"Motstandere",nn:"Motstandarar",pl:"Przeciwnicy",ga:"Freasúra"},Ferill:{en:"History",nb:"Historikk",nn:"Historikk",pl:"Historia",ga:"Stair"},"Þú átt leik":{en:"Your turn",nb:"Din tur",nn:"Din tur",pl:"Twoja kolej",ga:"Do sheal"},"Viðureign lokið":{en:"Game over",nb:"Spillet er over",nn:"Spelet er over",pl:"Koniec gry",ga:"Cluiche thart"},opp_move:{is:"{opponent} á leik",en:"{opponent}'s turn",nb:"{opponent}s tur",nn:"{opponent} sin tur",pl:"Tura {opponent}",ga:"Seal {opponent}"},"Átt þú leik?":{en:"Your turn?",nb:"Din tur?",nn:"Din tur?",pl:"Twoja kolej?",ga:"Do sheal?"},"Langt frá síðasta leik?":{en:"Long time elapsed since last move?",nb:"Lang tid siden siste trekk?",nn:"Lang tid sidan siste trekk?",pl:"Dużo czasu minęło od ostatniego ruchu?",ga:"An bhfuil am fada caite ón mbogadh deireanach?"},"Síðasti leikur":{en:"Last move",nb:"Siste trekk",nn:"Siste trekk",pl:"Ostatni ruch",ga:"Bogadh deireanach"},"Andstæðingur":{en:"Opponent",nb:"Motstander",nn:"Motstandar",pl:"Przeciwnik",ga:"Iomaitheoir"},"Staða":{en:"Score",nb:"Poeng",nn:"Poeng",pl:"Wynik",ga:"Scór"},Framvinda:{en:"Progress",nb:"Fremgang",nn:"Framgang",pl:"Postęp",ga:"Dul chun cinn"},Keppnishamur:{en:"Pro mode",nb:"Pro-modus",nn:"Pro-modus",pl:"Tryb Pro",ga:"Modh Pro"},"Venjuleg ótímabundin viðureign":{en:"Standard Mode without time limit",nb:"Standardmodus uten tidsbegrensning",nn:"Standardmodus utan tidsbegrensing",pl:"Tryb standardowy bez limitu czasu",ga:"Gnáthchluiche gan teorainn ama"},with_clock:{is:"Með klukku, 2 x {duration} mínútur",en:"With clock, 2 x {duration} minutes",nb:"Med klokke, 2 x {duration} minutter",nn:"Med klokke, 2 x {duration} minutt",pl:"Z zegarem, 2 x {duration} minut",ga:"Le clog, 2 x {duration} nóiméad"},Hafna:{en:"Decline",nb:"Avslå",nn:"Avslå",pl:"Odrzuć",ga:"Diúltaigh"},Afturkalla:{en:"Retract",nb:"Trekk tilbake",nn:"Trekk tilbake",pl:"Wycofaj",ga:"Tarraing siar"},"Án hjálpartækja":{en:"Without helpers",nb:"Uten hjelpemidler",nn:"Utan hjelpemiddel",pl:"Bez pomocy",ga:"Gan chúntóirí"},"Skoða feril":{en:"View history",nb:"Vis historikk",nn:"Vis historikk",pl:"Zobacz historię",ga:"Féach ar stair"},"Gamli pokinn":{en:"Old tile bag",nb:"Gammel brikkepose",nn:"Gammal brikkepose",pl:"Stary worek z kafelkami",ga:"Mála tíleanna sean"},"Hvenær":{en:"When",nb:"Når",nn:"Når",pl:"Kiedy",ga:"Cathain"},"Áskorandi":{en:"Challenger",nb:"Utfordrer",nn:"Utfordrar",pl:"Wyzwający",ga:"Dúshlánóir"},Hvernig:{en:"How",nb:"Hvordan",nn:"Korleis",pl:"Jak",ga:"Conas"},Sigur:{en:"Win",nb:"Seier",nn:"Siger",pl:"Zwycięstwo",ga:"Bua"},Jafntefli:{en:"Draw",nb:"Uavgjort",nn:"Uavgjort",pl:"Remis",ga:"Tarraingt"},Tap:{en:"Loss",nb:"Tap",nn:"Tap",pl:"Porażka",ga:"Caill"},"Úrslit":{en:"Result",nb:"Resultat",nn:"Resultat",pl:"Wynik",ga:"Toradh"},"Viðureign lauk":{en:"Game finished",nb:"Spill avsluttet",nn:"Spel avslutta",pl:"Gra zakończona",ga:"Cluiche críochnaithe"},"Mennskir andstæðingar":{en:"Human opponents",nb:"Menneskelige motstandere",nn:"Menneskelege motstandarar",pl:"Ludzcy przeciwnicy",ga:"Freasúra daonna"},"Allir andstæðingar":{en:"All opponents",nb:"Alle motstandere",nn:"Alle motstandarar",pl:"Wszyscy przeciwnicy",ga:"Gach freasúra"},Elo:{is:"Elo",en:"Elo",nb:"Elo",nn:"Elo",pl:"Elo",ga:"Elo"},Lengd:{en:"Duration",nb:"Varighet",nn:"Varigheit",pl:"Czas trwania",ga:"Fad"},"Uppáhald":{en_US:"Favorite",en:"Favourite",nb:"Favoritt",nn:"Favoritt",pl:"Ulubione",ga:"Is fearr leat"},"Uppáhalds":{en_US:"Favorites",en:"Favourites",nb:"Favoritter",nn:"Favorittar",pl:"Ulubione",ga:"Roghanna"},"Skora á":{en:"Challenge",nb:"Utfordre",nn:"Utfordre",pl:"Wyzwanie",ga:"Dúshlán"},Einkenni:{en:"Nickname",nb:"Kallenavn",nn:"Kallenamn",pl:"Pseudonim",ga:"Leasainm"},"Nafn og merki":{en:"Full name and badges",nb:"Fullt navn og merker",nn:"Fullt namn og merke",pl:"Pełna nazwa i odznaki",ga:"Ainm iomlán agus suaitheantais"}," finnst ekki":{en:" not found",nb:" ikke funnet",nn:" ikkje funne",pl:" nie znaleziono",ga:" gan aimsiú"},"Þjarkar":{en:"Robots",nb:"Roboter",nn:"Robotar",pl:"Roboty",ga:"Róbónna"},"Álínis":{en:"Online",nb:"Pålogget",nn:"Pålogga",pl:"Online",ga:"Ar líne"},"Svipaðir":{en:"Similar",nb:"Lignende",nn:"Liknande",pl:"Podobne",ga:"Cosúil"},"Topp 100":{en:"Top 100",nb:"Topp 100",nn:"Topp 100",pl:"Top 100",ga:"Barr 100"},"orð":{en:"word",nb:"ord",nn:"ord",pl:"słowo",ga:"focal"},stafur:{en:"letter",nb:"bokstav",nn:"bokstav",pl:"litera",ga:"litir"},Senda:{en:"Send",nb:"Send",nn:"Send",pl:"Wyślij",ga:"Seol"},Pass:{en:"Pass",nb:"Pass",nn:"Pass",pl:"Pas",ga:"Pas"},letter:{is:"staf",en:"letter",nb:"bokstav",nn:"bokstav",pl:"litera",ga:"litir"},letters:{is:"stafi",en:"letters",nb:"bokstaver",nn:"bokstavar",pl:"litery",ga:"litreacha"},exchanged:{is:"Skipti um {numtiles} {letters}",en:"Exchanged {numtiles} {letters}",nb:"Byttet ut {numtiles} {letters}",nn:"Bytte ut {numtiles} {letters}",pl:"Wymieniono {numtiles} {letters}",ga:"Mhalartaithe {numtiles} {letters}"},"Gaf viðureign":{en:"Resigned",nb:"Ga opp",nn:"Gav opp",pl:"Zrezygnował",ga:"D'éirigh as"},"Véfengdi lögn":{en:"Challenged move",nb:"Utfordret trekk",nn:"Utfordra trekk",pl:"Ruch zakwestionowany",ga:"Bogadh dúshlánach"},"Óleyfileg lögn":{en:"Invalid move",nb:"Ugyldig trekk",nn:"Ugyldig trekk",pl:"Nieprawidłowy ruch",ga:"Bogadh neamhbhailí"},"Röng véfenging":{en:"Unsuccessful challenge",nb:"Mislykket utfordring",nn:"Mislukka utfordring",pl:"Nieudane wyzwanie",ga:"Dúshlán gan rath"},"Umframtími":{en:"Extra time",nb:"Ekstra tid",nn:"Ekstra tid",pl:"Dodatkowy czas",ga:"Am breise"},"Stafaleif: engin":{en:"Rack leave: none",nb:"Rack forlater: ingen",nn:"Stativ forlèt: ingen",pl:"Pozostawienie na stojaku: brak",ga:"Fágáil raca: dada"},"Stafaleif: ":{en:"Rack leave: ",nb:"Rack forlater: ",nn:"Stativ forlèt: ",pl:"Pozostawienie na stojaku: ",ga:"Fágáil raca: "},"Ný áskorun":{en:"New challenge",nb:"Ny utfordring",nn:"Ny utfordring",pl:"Nowe wyzwanie",ga:"Dúshlán nua"},"Viðureign án klukku":{en:"Game with no time limit",nb:"Spill uten tidsbegrensning",nn:"Spel utan tidsbegrensing",pl:"Gra bez limitu czasu",ga:"Cluiche gan teorainn ama"},"Nota ":{en:"Enable ",nb:"Aktiver ",nn:"Aktiver ",pl:"Włącz ",ga:"Cumasaigh "},"handvirka véfengingu":{en:"manual challenges",nb:"manuelle utfordringer",nn:"manuelle utfordringar",pl:"ręczne wyzwania",ga:"dúshláin láimhe"},'("keppnishamur")':{en:'("Pro mode")',nb:'("Pro-modus")',nn:'("Pro-modus")',pl:'("Tryb Pro")',ga:'("Modh Pro")'},"Viðureignir sem standa yfir":{en:"Games in progress",nb:"Pågående spill",nn:"Pågåande spel",pl:"Trwające gry",ga:"Cluichí ar siúl"},click_on_game:{is:" - smelltu á viðureign til að skoða stöðuna og leika ef ",en:" - click on a game to view it and make a move if ",nb:" - klikk på et spill for å åpne det og gjøre et trekk hvis ",nn:" - klikk på eit spel for å opne det og gjere eit trekk viss ",pl:" - kliknij na grę, aby ją zobaczyć i wykonać ruch, jeśli ",ga:" - cliceáil ar chluiche chun é a fheiceáil agus bogadh má "}," þú átt leik":{en:" it's your turn",nb:" det er din tur",nn:" det er din tur",pl:" to twoja kolej",ga:" tá sé do sheal"},"Skorað á þig":{en:"Other players have challenged you",nb:"Andre spillere har utfordret deg",nn:"Andre spelarar har utfordra deg",pl:"Inni gracze wyzwali cię",ga:"Tá dúshláin curtha ort ag imreoirí eile"},click_on_challenge:{is:" - smelltu á áskorun til að taka henni og hefja viðureign, eða á ",en:" - click on a challenge to accept it and start a game, or on ",nb:" - klikk på en utfordring for å akseptere den og starte et spill, eller på ",nn:" - klikk på ei utfordring for å akseptere ho og starte eit spel, eller på ",pl:" - kliknij na wyzwanie, aby je zaakceptować i rozpocząć grę, lub na ",ga:" - cliceáil ar dhúshlán chun glacadh leis agus cluiche a thosú, nó ar "}," til að hafna henni":{en:" to decline it",nb:" for å avslå det",nn:" for å avslå det",pl:" aby je odrzucić",ga:" chun é a dhiúltú"},"Þú skorar á aðra":{en:"You challenge other players",nb:"Du utfordrer andre spillere",nn:"Du utfordrar andre spelarar",pl:"Wyzwasz innych graczy",ga:"Dúshlánaíonn tú imreoirí eile"}," - smelltu á ":{en:" - click on ",nb:" - klikk på ",nn:" - klikk på ",pl:" - kliknij na ",ga:" - cliceáil ar "}," til að afturkalla áskorun":{en:" to retract an issued challenge",nb:" for å trekke tilbake en utfordring",nn:" for å trekkje tilbake ei utfordring",pl:" aby wycofać wydane wyzwanie",ga:" chun dúshlán eisithe a tharraingt siar"},"Nýlegar viðureignir þínar":{en:"Your recent games",nb:"Dine nylige spill",nn:"Dine nylege spel",pl:"Twoje ostatnie gry",ga:"Do chluichí le déanaí"},click_to_review:{is:" - smelltu á viðureign til að skoða hana og rifja upp",en:" - click on a game to review it",nb:" - klikk på et spill for å åpne det og gå gjennom det",nn:" - klikk på eit spel for å opne det og gå gjennom det",pl:" - kliknij na grę, aby ją przejrzeć",ga:" - cliceáil ar chluiche chun athbhreithniú a dhéanamh air"},"Einkenni eða nafn":{en:"Nickname or name",nb:"Kallenavn eller navn",nn:"Kallenamn eller namn",pl:"Pseudonim lub nazwa",ga:"Leasainm nó ainm"},"Upplýsingar og hjálp":{en:"Information and help",nb:"Informasjon og hjelp",nn:"Informasjon og hjelp",pl:"Informacje i pomoc",ga:"Eolas agus cabhair"},"1 dagur":{en:"1 day",nb:"1 dag",nn:"1 dag",pl:"1 dzień",ga:"1 lá"}," dagar":{en:" days",nb:" dager",nn:" dagar",pl:" dni",ga:" laethanta"}," og ":{en:" and ",nb:" og ",nn:" og ",pl:" i ",ga:" agus "},"1 klst":{en:"1 hour",nb:"1 time",nn:"1 time",pl:"1 godzina",ga:"1 uair"}," klst":{en:" hours",nb:" timer",nn:" timar",pl:" godzin",ga:" uair an chloig"},"1 mínúta":{en:"1 minute",nb:"1 minutt",nn:"1 minutt",pl:"1 minuta",ga:"1 nóiméad"}," mínútur":{en:" minutes",nb:" minutter",nn:" minutt",pl:" minuty",ga:" nóiméad"},"Viðureign með klukku":{en:"Timed game",nb:"Tidsbegrenset spill",nn:"Tidsbegrensa spel",pl:"Gra zegarowa",ga:"Cluiche ama"},"Áskrifandi":{en:"Subscriber",nb:"Abonnent",nn:"Abonnent",pl:"Subskrybent",ga:"Síntiúsóir"},"Nýjustu viðureignir":{en:"Recent games",nb:"Nylige spill",nn:"Nylege spel",pl:"Najnowsze gry",ga:"Cluichí is déanaí"},Loka:{en:"Close",nb:"Lukk",nn:"Lukk",pl:"Zamknij",ga:"Dún"},"Besta orð ":{en:"Best word ",nb:"Beste ord ",nn:"Beste ord ",pl:"Najlepsze słowo ",ga:"An focal is fearr "},"Hæsta skor ":{en:"Highest score ",nb:"Høyeste poengsum ",nn:"Høgaste poengsum ",pl:"Najwyższy wynik ",ga:"An scór is airde "}," stig":{en:" points",nb:" poeng",nn:" poeng",pl:" punkty",ga:" pointí"},"Til hamingju með sigurinn!":{en:"You won - congratulations!",nb:"Du vant - gratulerer!",nn:"Du vann - gratulerer!",pl:"Wygrałeś - gratulacje!",ga:"Bhuaigh tú - comhghairdeas!"},"Viðureigninni er lokið":{en:"Game over",nb:"Spillet er over",nn:"Spelet er over",pl:"Gra zakończona",ga:"Cluiche thart"},opponent_emptied_rack:{is:"Andstæðingur tæmdi rekkann - þú getur véfengt eða sagt pass",en:"Your opponent emptied the rack - you can challenge or pass",nb:"Motstanderen tømte stativet - du kan utfordre eller passere",nn:"Motstandaren tømde stativet - du kan utfordre eller passere",pl:"Twój przeciwnik opróżnił stojak - możesz rzucić wyzwanie lub spasować",ga:"D'fholmhaigh do chéile comhraic an raca - is féidir leat dúshlán a thabhairt nó pas a fháil"},"Viltu gefa leikinn?":{en:"Do you want to resign the game?",nb:"Ønsker du å gi opp spillet?",nn:"Ønskjer du å gje opp spelet?",pl:"Czy chcesz zrezygnować z gry?",ga:"Ar mhaith leat éirí as an gcluiche?"}," Já":{en:" Yes",nb:" Ja",nn:" Ja",pl:" Tak",ga:" Tá"}," Nei":{en:" No",nb:" Nei",nn:" Nei",pl:" Nie",ga:" Níl"},"Segja pass?":{en:"Pass the turn?",nb:"Passere turen?",nn:"Passere turen?",pl:"Spasować kolej?",ga:"Pas an tsealaíocht?"},"2x3 pöss í röð ljúka viðureign":{en:"2x3 passes in a row end the game",nb:"2x3 pasninger på rad avslutter spillet",nn:"2x3 pasningar på rad avsluttar spelet",pl:"2x3 pasy z rzędu kończą grę",ga:"Críochnaíonn 2x3 pasanna as a chéile an cluiche"},"Viðureign lýkur þar með":{en:"This finishes the game",nb:"Dette avslutter spillet",nn:"Dette avsluttar spelet",pl:"To kończy grę",ga:"Críochnaíonn sé seo an cluiche"},Skipta:{en:"Exchange",nb:"Bytte",nn:"Byte",pl:"Wymiana",ga:"Malartú"},"Smelltu á flísarnar sem þú vilt skipta":{en:"Click on the tiles that you wish to exchange",nb:"Klikk på brikkene du ønsker å bytte",nn:"Klikk på brikkene du ønskjer å byte",pl:"Kliknij na kafelki, które chcesz wymienić",ga:"Cliceáil ar na tíleanna ar mhaith leat a mhalartú"},"Véfengja lögn?":{en:"Challenge move?",nb:"Utfordre trekk?",nn:"Utfordre trekk?",pl:"Wyzwanie ruchu?",ga:"Dúshlán bogadh?"},"Röng véfenging kostar 10 stig":{en:"Wrong challenge costs 10 points",nb:"Feil utfordring koster 10 poeng",nn:"Feil utfordring kostar 10 poeng",pl:"Błędne wyzwanie kosztuje 10 punktów",ga:"Cosnaíonn dúshlán mícheart 10 bpointe"},"Er álínis":{en:"Is online",nb:"Er pålogget",nn:"Er pålogga",pl:"Jest online",ga:"Ar líne"},"Álínis?":{en:"Online?",nb:"Pålogget?",nn:"Pålogga?",pl:"Online?",ga:"Ar líne?"},"Röð":{en:"Rank",nb:"Rang",nn:"Rang",pl:"Ranking",ga:"Áit"},"Röð í gær":{en:"Rank yesterday",nb:"Rang i går",nn:"Rang i går",pl:"Ranking wczoraj",ga:"Áit inné"},"Röð fyrir viku":{en:"Rank a week ago",nb:"Rang for en uke siden",nn:"Rang for ei veke sidan",pl:"Ranking tydzień temu",ga:"Áit seachtain ó shin"},"1d":{en:"1d",nb:"1d",nn:"1d",pl:"1d",ga:"1l"},"7d":{en:"7d",nb:"7d",nn:"7d",pl:"7d",ga:"7l"},"30d":{en:"30d",nb:"30d",nn:"30d",pl:"30d",ga:"30l"},"Elo-stig":{en:"Elo points",nb:"Elo-poeng",nn:"Elo-poeng",pl:"Punkty Elo",ga:"Pointí Elo"},"Elo-stig í gær":{en:"Elo points yesterday",nb:"Elo-poeng i går",nn:"Elo-poeng i går",pl:"Punkty Elo wczoraj",ga:"Pointí Elo inné"},"Elo-stig fyrir viku":{en:"Elo points a week ago",nb:"Elo-poeng for en uke siden",nn:"Elo-poeng for ei veke sidan",pl:"Punkty Elo tydzień temu",ga:"Pointí Elo seachtain ó shin"},"Elo-stig fyrir mánuði":{en:"Elo points a month ago",nb:"Elo-poeng for en måned siden",nn:"Elo-poeng for ein månad sidan",pl:"Punkty Elo miesiąc temu",ga:"Pointí Elo mí ó shin"},elo_list_choice:{is:"Fólk | Allar | Keppnishamur",en:"Humans | All | Pro mode",nb:"Mennesker | Alle | Pro modus",nn:"Menneske | Alle | Pro-modus",pl:"Ludzie | Wszyscy | Tryb Pro",ga:"Daoine | Gach | Modh Pro"},stats_choice:{is:"Með þjörkum eða án",en:"With or without robot games",nb:"Med eller uten robotspill",nn:"Med eller utan robotspel",pl:"Z grami robotów lub bez",ga:"Le cluichí róbón nó gan iad"},"Fjöldi viðureigna":{en:"Number of games",nb:"Antall spill",nn:"Tal på spel",pl:"Liczba gier",ga:"Líon cluichí"},"Leikmenn sem hafa leyst gátuna":{en:"Players who solved the riddle",nb:"Spillere som har løst gåten",nn:"Spelarar som har løyst gåta",pl:"Gracze, którzy rozwiązali zagadkę",ga:"Imreoirí a réitigh an tomhas"},Vinningshlutfall:{en:"Winning ratio",nb:"Vinningsforhold",nn:"Vinningsforhold",pl:"Stosunek wygranych",ga:"Cóimheas bua"},"Meðalstigafjöldi":{en:"Average score",nb:"Gjennomsnittlig poengsum",nn:"Gjennomsnittleg poengsum",pl:"Średni wynik",ga:"Scór meánach"}," gegn öllum ":{en:" against all ",nb:" mot alle ",nn:" mot alle ",pl:" przeciwko wszystkim ",ga:" in aghaidh gach "}," gegn þér ":{en:" against you ",nb:" mot deg ",nn:" mot deg ",pl:" przeciwko tobie ",ga:" in aghaidh tú "}," - veldu lengd viðureignar:":{en:" - choose game duration:",nb:" - velg spillvarighet:",nn:" - vel spelvarigheit:",pl:" - wybierz czas trwania gry:",ga:" - roghnaigh fad an chluiche:"},"2 x 10 mínútur":{en:"2 x 10 minutes",nb:"2 x 10 minutter",nn:"2 x 10 minutt",pl:"2 x 10 minut",ga:"2 x 10 nóiméad"},"2 x 15 mínútur":{en:"2 x 15 minutes",nb:"2 x 15 minutter",nn:"2 x 15 minutt",pl:"2 x 15 minut",ga:"2 x 15 nóiméad"},"2 x 20 mínútur":{en:"2 x 20 minutes",nb:"2 x 20 minutter",nn:"2 x 20 minutt",pl:"2 x 20 minut",ga:"2 x 20 nóiméad"},"2 x 25 mínútur":{en:"2 x 25 minutes",nb:"2 x 25 minutter",nn:"2 x 25 minutt",pl:"2 x 25 minut",ga:"2 x 25 nóiméad"},"2 x 30 mínútur":{en:"2 x 30 minutes",nb:"2 x 30 minutter",nn:"2 x 30 minutt",pl:"2 x 30 minut",ga:"2 x 30 nóiméad"},"Báðir leikmenn lýsa því yfir að þeir skrafla ":{en:"Both players declare that they play ",nb:"Begge spillere erklærer at de spiller ",nn:"Begge spelarar erklærer at dei spelar ",pl:"Obaj gracze deklarują, że grają ",ga:"Dearbhaíonn an bheirt imreoirí go n-imríonn siad "},"Flísar sem eftir eru":{en:"Tiles remaining",nb:"Fliser igjen",nn:"Fliser igjen",pl:"Pozostałe kafelki",ga:"Tíleanna fágtha"},"Hvaða staf táknar auða flísin?":{en:"Which letter does the blank tile represent?",nb:"Hvilken bokstav representerer den blanke flisen?",nn:"Kva bokstav representerer den blanke flisa?",pl:"Jaką literę reprezentuje pusty kafelek?",ga:"Cén litir a léiríonn an tíl bán?"},"Þvinga til uppgjafar":{en:"Force to resign",nb:"Tving til å gi opp",nn:"Tving til å gje opp",pl:"Zmusić do rezygnacji",ga:"Éignigh le héirí as"},"14 dagar liðnir án leiks":{en:"14 days elapsed without a move",nb:"14 dager gått uten trekk",nn:"14 dagar gått utan trekk",pl:"Upłynęło 14 dni bez ruchu",ga:"14 lá caite gan bogadh"},"Gefa viðureign":{en:"Resign from game",nb:"Gi opp spillet",nn:"Gje opp spelet",pl:"Zrezygnować z gry",ga:"Éirigh as an gcluiche"},"Skipta stöfum":{en:"Exchange tiles",nb:"Bytt fliser",nn:"Byt fliser",pl:"Wymień kafelki",ga:"Malartú tíleanna"},word_not_found:{en:"'{word}' is not in the dictionary",is:"'{word}' finnst ekki í orðasafni",nb:"'{word}' finnes ikke i ordboken",nn:"'{word}' finst ikkje i ordboka",pl:"'{word}' nie znajduje się w słowniku",ga:"Níl '{word}' sa fhoclóir"},"Smelltu til að fletta upp":{en:"Click to look up",nb:"Klikk for å slå opp",nn:"Klikk for å slå opp",pl:"Kliknij, aby wyszukać",ga:"Cliceáil chun cuardach"},"Skoða yfirlit":{en:"Review game",nb:"Gjennomgå spill",nn:"Gjennomgå spel",pl:"Przejrzyj grę",ga:"Athbhreithniú cluiche"},"Skraflað án hjálpartækja":{en:"Game without helpers or tools",nb:"Spill uten hjelpemidler eller verktøy",nn:"Spel utan hjelpemiddel eller verktøy",pl:"Gra bez pomocy lub narzędzi",ga:"Cluiche gan chúntóirí nó uirlisí"},"Skraflar án hjálpartækja":{en:"Plays without helpers or tools",nb:"Spiller uten hjelpemidler eller verktøy",nn:"Spelar utan hjelpemiddel eller verktøy",pl:"Gra bez pomocy lub narzędzi",ga:"Imríonn gan chúntóirí nó uirlisí"},"Til í viðureign með klukku":{en:"Willing to play timed games",nb:"Villig til å spille tidsbegrensede spill",nn:"Villig til å spele tidsbegrensa spel",pl:"Chętny do gry w gry zegarowe",ga:"Toilteanach cluichí ama a imirt"},"Álínis og tekur við áskorunum":{en:"Online and accepting challenges",nb:"Pålogget og aksepterer utfordringer",nn:"Pålogga og aksepterer utfordringar",pl:"Online i akceptuje wyzwania",ga:"Ar líne agus ag glacadh le dúshláin"},"Enginn stafur lagður niður":{en:"No tile played",nb:"Ingen flis spilt",nn:"Inga flis spelt",pl:"Żaden kafelek nie został położony",ga:"Níor imríodh aon tíl"},"Fyrsta orð verður að liggja um byrjunarreitinn":{en:"First word must cover the start square",nb:"Første ord må dekke startfeltet",nn:"Første ord må dekkje startfeltet",pl:"Pierwsze słowo musi pokryć pole startowe",ga:"Caithfidh an chéad fhocal an cearnóg tosaigh a chlúdach"},"Orð verður að vera samfellt á borðinu":{en:"Word must be placed consecutively on the board",nb:"Ord må plasseres etter hverandre på brettet",nn:"Ord må plasserast etter kvarandre på brettet",pl:"Słowo musi być umieszczone kolejno na planszy",ga:"Caithfear an focal a chur go leanúnach ar an mbord"},"Orð verður að tengjast orði sem fyrir er":{en:"Word must be connected to another word on the board",nb:"Ord må være koblet til et annet ord på brettet",nn:"Ord må vere kopla til eit anna ord på brettet",pl:"Słowo musi być połączone z innym słowem na planszy",ga:"Caithfidh an focal a bheith ceangailte le focal eile ar an mbord"},"Reitur þegar upptekinn":{en:"Square is already occupied",nb:"Feltet er allerede opptatt",nn:"Feltet er allereie oppteke",pl:"Pole jest już zajęte",ga:"Tá an cearnóg áitithe cheana"},"Ekki má vera eyða í orði":{en:"Word cannot contain a space",nb:"Ord kan ikke inneholde et mellomrom",nn:"Ord kan ikkje innehalde eit mellomrom",pl:"Słowo nie może zawierać spacji",ga:"Ní féidir spás a bheith i bhfocal"},"Of margir stafir lagðir niður":{en:"Too many tiles laid down",nb:"For mange fliser lagt ned",nn:"For mange fliser lagde ned",pl:"Położono zbyt wiele kafelków",ga:"Leagadh síos an iomarca tíleanna"},"Stafur er ekki í rekkanum":{en:"Tile is not present in the player's rack",nb:"Flisen er ikke til stede i spillerens stativ",nn:"Flisa er ikkje til stades i spelaren sitt stativ",pl:"Kafelek nie znajduje się na stojaku gracza",ga:"Níl an tíl i raca an imreora"},"Of fáir stafir eftir, skipting ekki leyfð":{en:"Too few tiles left in bag; exchange not permitted",nb:"For få fliser igjen i posen; bytte ikke tillatt",nn:"For få fliser igjen i posen; byte ikkje tillate",pl:"Zbyt mało kafelków w worku; wymiana niedozwolona",ga:"Ró-bheag tíleanna fágtha sa mhála; malartú toirmiscthe"},"Of mörgum stöfum skipt":{en:"Too many tiles exchanged",nb:"For mange fliser byttet",nn:"For mange fliser bytte",pl:"Wymieniono zbyt wiele kafelków",ga:"Malartaíodh an iomarca tíleanna"},"Leik vantar á borðið - endurglæðið vefráparann":{en:"Move missing from board - refresh browser",nb:"Trekk mangler på brettet - oppdater nettleseren",nn:"Trekk manglar på brettet - oppdater nettlesaren",pl:"Ruch nieobecny na planszy - odśwież przeglądarkę",ga:"Bogadh in easnamh ón mbord - athnuaigh an brabhsálaí"},"Notandi ekki innskráður - endurglæðið vefráparann":{en:"User not logged in - refresh browser",nb:"Bruker ikke logget inn - oppdater nettleseren",nn:"Brukar ikkje logga inn - oppdater nettlesaren",pl:"Użytkownik nie jest zalogowany - odśwież przeglądarkę",ga:"Úsáideoir gan logáil isteach - athnuaigh an brabhsálaí"},"Rangur eða óþekktur notandi":{en:"Wrong or unknown user",nb:"Feil eller ukjent bruker",nn:"Feil eller ukjend brukar",pl:"Błędny lub nieznany użytkownik",ga:"Úsáideoir mícheart nó anaithnid"},"Viðureign finnst ekki":{en:"Game not found",nb:"Spill ikke funnet",nn:"Spel ikkje funne",pl:"Gra nie znaleziona",ga:"Cluiche gan aimsiú"},"Viðureign er ekki utan tímamarka":{en:"Game has not exceeded time limit",nb:"Spillet har ikke overskredet tidsbegrensningen",nn:"Spelet har ikkje overskride tidsbegrensinga",pl:"Gra nie przekroczyła limitu czasu",ga:"Níor sháraigh an cluiche an teorainn ama"},"Netþjónn gat ekki tekið við leiknum - reyndu aftur":{en:"Server is unable to process move - try again",nb:"Serveren kan ikke behandle trekket - prøv igjen",nn:"Tenaren kan ikkje behandle trekket - prøv igjen",pl:"Serwer nie może przetworzyć ruchu - spróbuj ponownie",ga:"Ní féidir leis an bhfreastalaí an gluaiseacht a phróiseáil - bain triail eile as"},"Véfenging er ekki möguleg í þessari viðureign":{en:"A challenge is not possible in this game",nb:"En utfordring er ikke mulig i dette spillet",nn:"Ei utfordring er ikkje mogleg i dette spelet",pl:"Wyzwanie nie jest możliwe w tej grze",ga:"Ní féidir dúshlán a thabhairt sa chluiche seo"},"Síðasti leikur er ekki véfengjanlegur":{en:"The last move cannot be challenged",nb:"Siste trekk kan ikke utfordres",nn:"Siste trekk kan ikkje utfordrast",pl:"Ostatniego ruchu nie można zakwestionować",ga:"Ní féidir an gluaiseacht deireanach a dhúshlánú"},"Aðeins véfenging eða pass leyfileg":{en:"Only a challenge or a pass are possible",nb:"Bare en utfordring eller pass er mulig",nn:"Berre ei utfordring eller pass er mogleg",pl:"Możliwe jest tylko wyzwanie lub pas",ga:"Níl ach dúshlán nó pas indéanta"},welcome_2:{is:["Til auðkenningar tengir Netskrafl tölvupóstfang og nafn við hvern notanda. ","Að öðru leyti eru ekki geymdar aðrar upplýsingar um notendur ","en þær sem þeir skrá sjálfir. Annáll er haldinn um umferð um vefinn og um ","aðgerðir notenda, í því skyni að endurbæta Netskrafl."],en:["For identification, Explo associates an e-mail address and a name with each user. ","Apart from this, Explo only stores information which is voluntarily ","entered by users themselves. A log is kept of web traffic and events within Explo, ","for the purpose of improving the service."],nb:["For identifikasjon knytter Explo en e-postadresse og et navn til hver bruker. ","Utover dette lagrer Explo kun informasjon som frivillig ","legges inn av brukerne selv. En logg føres over webtrafikk og hendelser innen Explo, ","i hensikt å forbedre tjenesten."],nn:["For identifikasjon knyter Explo ei e-postadresse og eit namn til kvar brukar. ","Utover dette lagrar Explo berre informasjon som frivillig ","blir lagt inn av brukarane sjølve. Ein logg blir ført over webtrafikk og hendingar innan Explo, ","i føremål å forbetre tenesta."],pl:["W celu identyfikacji Explo przypisuje każdemu użytkownikowi adres e-mail i nazwę. ","Poza tym Explo przechowuje tylko te informacje, które dobrowolnie wprowadzają sami ","użytkownicy. Prowadzony jest rejestr ruchu internetowego i zdarzeń w Explo w celu ","ulepszenia usługi."],ga:["Chun aitheantais, ceanglaíonn Explo seoladh ríomhphoist agus ainm le gach úsáideoir. ","Seachas sin, ní stóráiltear ag Explo ach an fhaisnéis a chuirtear isteach go deonach ","ag na húsáideoirí iad féin. Coinnítear logáil ar thrácht gréasáin agus imeachtaí laistigh de Explo, ","leis an gcuspóir an tseirbhís a fheabhsú."]},welcome_1:{is:["Netskrafl notar Google Accounts innskráningu, þá sömu og er notuð m.a. í Gmail. ","Til að auðkenna þig sem notanda og halda innskráningunni virkri ","er óhjákvæmilegt að geyma þar til gerða smáköku (<i>cookie</i>) ","í vafranum þínum."],en:["Explo uses Google Accounts for user authentication, similarly to e.g. Gmail. ","To remember your login and maintain your session, it is necessary to store a ","cookie within your browser."],nb:["Explo bruker Google-kontoer for brukerautentisering, likt som f.eks. Gmail. ","For å huske din innlogging og opprettholde din økt, er det nødvendig å lagre en ","informasjonskapsel i nettleseren din."],nn:["Explo brukar Google-kontoar for brukarautentisering, likt som t.d. Gmail. ","For å hugse innlogginga di og halde ved like økta di, er det naudsynt å lagre ein ","informasjonskapsel i nettlesaren din."],pl:["Explo używa kont Google do uwierzytelniania użytkownika, podobnie jak np. Gmail. ","Aby zapamiętać twoje logowanie i utrzymać sesję, konieczne jest przechowanie ","ciasteczka w twojej przeglądarce."],ga:["Úsáideann Explo Cuntais Google le haghaidh fíordheimhniú úsáideora, cosúil le Gmail, mar shampla. ","Chun do logáil isteach a mheabhrú agus do sheisiún a chothabháil, tá sé riachtanach fianán a stóráil ","i do bhrabhsálaí."]},welcome_0:{is:["Netskrafl er vettvangur ","<b>yfir 40.000 íslenskra skraflara</b>"," á netinu."],en:["Explo is a venue for ","<b>tens of thousands of crossword game enthusiasts</b> ","on the Internet."],nb:["Explo er et møtested for ","<b>tusenvis av kryssordspillentusiaster</b>"," på internett."],nn:["Explo er ein møtestad for ","<b>tusenvis av kryssordspelentusiastar</b>"," på internett."],pl:["Explo to miejsce dla ","<b>dziesiątek tysięcy entuzjastów gier krzyżówkowych</b>"," w Internecie."],ga:["Is ionad é Explo do ","<b>na deich mílte díograiseoirí cluiche crosfhocal</b>"," ar an Idirlíon."]},"Skrái þig inn...":{en:"Logging you in...",nb:"Logger deg inn...",nn:"Loggar deg inn...",pl:"Logowanie...",ga:"Ag logáil isteach tú..."},"Innskrá":{en:"Log in",nb:"Logg inn",nn:"Logg inn",pl:"Zaloguj się",ga:"Logáil isteach"},"Smelltu til að raða eftir seinni staf":{en:"Click to sort by last letter",nb:"Klikk for å sortere etter siste bokstav",nn:"Klikk for å sortere etter siste bokstav",pl:"Kliknij, aby posortować według ostatniej litery",ga:"Cliceáil chun sórtáil de réir an litir deireanaigh"},"Smelltu til að raða eftir fyrri staf":{en:"Click to sort by first letter",nb:"Klikk for å sortere etter første bokstav",nn:"Klikk for å sortere etter første bokstav",pl:"Kliknij, aby posortować według pierwszej litery",ga:"Cliceáil chun sórtáil de réir an chéad litir"},"Hvernig reitirnir margfalda stigin":{en:"How squares multiply points",nb:"Hvordan ruter multipliserer poeng",nn:"Korleis ruter multipliserer poeng",pl:"Jak kwadraty mnożą punkty",ga:"Conas a iolraíonn cearnóga pointí"},"Loka þessari hjálp":{en:"Close this help",nb:"Lukk denne hjelpen",nn:"Lukk denne hjelpa",pl:"Zamknij tę pomoc",ga:"Dún an chabhair seo"},"Stokka upp rekka":{en:"Shuffle rack",nb:"Stokk stativet",nn:"Stokk stativet",pl:"Przetasuj stojak",ga:"Measc raca"},"Færa stafi aftur í rekka":{en:"Recall tiles into rack",nb:"Hent fliser tilbake til stativet",nn:"Hent fliser tilbake til stativet",pl:"Przywróć kafelki do stojaka",ga:"Cuimhnigh tíleanna isteach sa raca"},"Besta mögulega lögn":{en:"Best possible move",nb:"Beste mulige trekk",nn:"Beste mogelege trekk",pl:"Najlepszy możliwy ruch",ga:"An bogadh is fearr is féidir"},"Nei, takk":{en:"No, thanks",nb:"Nei, takk",nn:"Nei, takk",pl:"Nie, dziękuję",ga:"Ní hea"},"Fyrri dagur":{en:"Previous day",nb:"Forrige dag",nn:"Førre dag",pl:"Poprzedni dzień",ga:"An lá roimhe"},"Næsti dagur":{en:"Next day",nb:"Neste dag",nn:"Neste dag",pl:"Następny dzień",ga:"An lá dar gcionn"},"Frammistaða":{en:"Performance",nb:"Ytelse",nn:"Yting",pl:"Wyniki",ga:"Feidhmíocht"},"Tölfræði":{en:"Statistics",nb:"Statistikk",nn:"Statistikk",pl:"Statystyki",ga:"Staitisticí"},Stigatafla:{en:"Leaderboard",nb:"Toppliste",nn:"Toppliste",pl:"Tabela wyników",ga:"Clár ceannairí"},"Tölfræði og stigatafla":{en:"Stats and leaderboard",nb:"Statistikk og toppliste",nn:"Statistikk og toppliste",pl:"Statystyki i tabela",ga:"Staitisticí agus clár"},"Þín besta":{en:"Your best",nb:"Din beste",nn:"Di beste",pl:"Twój najlepszy",ga:"Do cheann is fearr"},"Þú leiðir!":{en:"You lead!",nb:"Du leder!",nn:"Du leier!",pl:"Prowadzisz!",ga:"Tá tú chun tosaigh!"},"Best til þessa":{en:"Best so far",nb:"Beste hittil",nn:"Beste hittil",pl:"Najlepszy dotąd",ga:"Is fearr go dtí seo"},"Sýna besta leik":{en:"Show best move",nb:"Vis beste trekk",nn:"Vis beste trekk",pl:"Pokaż najlepszy ruch",ga:"Taispeáin an bogadh is fearr"},"Sýna leik":{en:"Show move",nb:"Vis trekk",nn:"Vis trekk",pl:"Pokaż ruch",ga:"Taispeáin bogadh"},"Smelltu til að sjá lausn":{en:"Click to see solution",nb:"Klikk for å se løsning",nn:"Klikk for å sjå løysing",pl:"Kliknij, aby zobaczyć rozwiązanie",ga:"Cliceáil chun an réiteach a fheiceáil"},"Þú":{en:"You",nb:"Du",nn:"Du",pl:"Ty",ga:"Tú"},"Sæki tölfræði...":{en:"Loading stats...",nb:"Laster statistikk...",nn:"Lastar statistikk...",pl:"Ładowanie statystyk...",ga:"Ag lódáil staitisticí..."},"Engin tölfræði til að sýna":{en:"No statistics to show",nb:"Ingen statistikk å vise",nn:"Ingen statistikk å vise",pl:"Brak statystyk do wyświetlenia",ga:"Níl aon staitisticí le taispeáint"},"Núverandi striklota":{en:"Current streak",nb:"Nåværende rekke",nn:"Noverande rekkje",pl:"Bieżąca seria",ga:"Sraith reatha"},"Lengsta striklota":{en:"Longest streak",nb:"Lengste rekke",nn:"Lengste rekkje",pl:"Najdłuższa seria",ga:"An tsraith is faide"},"Hæsta skori náð":{en:"Best score achieved",nb:"Beste oppnådde poengsum",nn:"Beste oppnådde poengsum",pl:"Najwyższy wynik",ga:"An scór is fearr"},"Striklota hæsta skors":{en:"Best score streak",nb:"Rekke med beste poengsum",nn:"Rekkje med beste poengsum",pl:"Seria najwyższych wyników",ga:"Sraith scór is fearr"},"Heildarfjöldi daga":{en:"Total days played",nb:"Totalt antall dager",nn:"Totalt tal på dagar",pl:"Łączna liczba dni",ga:"Iomlán laethanta"},"Hleð stigatöflu...":{en:"Loading leaderboard...",nb:"Laster toppliste...",nn:"Lastar toppliste...",pl:"Ładowanie tabeli...",ga:"Ag lódáil an chláir..."},"Engin stig skráð enn":{en:"No scores yet",nb:"Ingen poeng ennå",nn:"Ingen poeng enno",pl:"Brak wyników",ga:"Gan scóir fós"},"Reyna síðar":{en:"Try later",nb:"Prøv senere",nn:"Prøv seinare",pl:"Spróbuj później",ga:"Bain triail níos déanaí"}," mínútur.":{en:" minutes.",nb:" minutter.",nn:" minutt.",pl:" minut.",ga:" nóiméad."},date_format:{is:"{day}. {month}",en:"{month} {day}",nb:"{day}. {month}",nn:"{day}. {month}",pl:"{day} {month}",ga:"{day} {month}"},january:{is:"janúar",en:"January",nb:"januar",nn:"januar",pl:"styczeń",ga:"Eanáir"},february:{is:"febrúar",en:"February",nb:"februar",nn:"februar",pl:"luty",ga:"Feabhra"},march:{is:"mars",en:"March",nb:"mars",nn:"mars",pl:"marzec",ga:"Márta"},april:{is:"apríl",en:"April",nb:"april",nn:"april",pl:"kwiecień",ga:"Aibreán"},may:{is:"maí",en:"May",nb:"mai",nn:"mai",pl:"maj",ga:"Bealtaine"},june:{is:"júní",en:"June",nb:"juni",nn:"juni",pl:"czerwiec",ga:"Meitheamh"},july:{is:"júlí",en:"July",nb:"juli",nn:"juli",pl:"lipiec",ga:"Iúil"},august:{is:"ágúst",en:"August",nb:"august",nn:"august",pl:"sierpień",ga:"Lúnasa"},september:{is:"september",en:"September",nb:"september",nn:"september",pl:"wrzesień",ga:"Meán Fómhair"},october:{is:"október",en:"October",nb:"oktober",nn:"oktober",pl:"październik",ga:"Deireadh Fómhair"},november:{is:"nóvember",en:"November",nb:"november",nn:"november",pl:"listopad",ga:"Samhain"},december:{is:"desember",en:"December",nb:"desember",nn:"desember",pl:"grudzień",ga:"Nollaig"},share_popup_title:{is:"Til hamingju!",en:"Congratulations!",nb:"Gratulerer!",nn:"Gratulerer!",pl:"Gratulacje!",ga:"Comhghairdeas!"},share_popup_subtitle:{is:"Þú náðir besta mögulega skori!",en:"You achieved the best possible score!",nb:"Du oppnådde best mulig poengsum!",nn:"Du oppnådde best mogeleg poengsum!",pl:"Osiągnąłeś najlepszy możliwy wynik!",ga:"Bhain tú an scór is fearr is féidir amach!"},share_button_copy:{is:"Afrita texta",en:"Copy to clipboard",nb:"Kopier til utklippstavle",nn:"Kopier til utklippstavle",pl:"Skopiuj do schowka",ga:"Cóipeáil chuig gearrthaisce"},share_button_share:{is:"Deila",en:"Share",nb:"Del",nn:"Del",pl:"Udostępnij",ga:"Roinn"},share_copied_confirmation:{is:"Afritað!",en:"Copied!",nb:"Kopiert!",nn:"Kopiert!",pl:"Skopiowano!",ga:"Cóipeáilte!"},share_text_template:{is:"🎯 Ég leysti Gátu dagsins (#{position} í dag!) 🏆 https://gatadagsins.is",en:"🎯 I solved Gáta dagsins (#{position} today!) 🏆 https://gatadagsins.is",nb:"🎯 Jeg løste dagens gåte (#{position} i dag!) 🏆 https://gatadagsins.is",nn:"🎯 Eg løyste dagens gåte (#{position} i dag!) 🏆 https://gatadagsins.is",pl:"🎯 Rozwiązałem zagadkę dnia (#{position} dzisiaj!) 🏆 https://gatadagsins.is",ga:"🎯 Réitigh mé tomhas an lae (#{position} inniu!) 🏆 https://gatadagsins.is"},Stillingar:{en:"Settings",nb:"Innstillinger",nn:"Innstillingar",pl:"Ustawienia",ga:"Socruithe"},"Tækisstillingar":{en:"Device settings",nb:"Enhetsinnstillinger",nn:"Einingsinnstillingar",pl:"Ustawienia urządzenia",ga:"Socruithe gléis"},"Þysja sjálfkrafa":{en:"Auto-zoom",nb:"Automatisk zoom",nn:"Automatisk zoom",pl:"Automatyczne powiększenie",ga:"Uathzúmáil"},autozoom_explain:{is:"Þysja sjálfkrafa inn þegar fyrsta flís er lögð á borðið",en:"Zoom in when first tile is placed on the board",nb:"Zoom inn når første brikke legges på brettet",nn:"Zoom inn når første brikke vert lagt på brettet",pl:"Powiększ, gdy pierwsza płytka zostanie położona na planszy",ga:"Zúmáil isteach nuair a leagtar an chéad tíl ar an gclár"},"á":{en:"on",nb:"på",nn:"på",pl:"wł.",ga:"air"},af:{en:"off",nb:"av",nn:"av",pl:"wył.",ga:"as"},"Eldri litasamsetning:":{en:"Legacy colors:",nb:"Eldre farger:",nn:"Eldre fargar:",pl:"Starsze kolory:",ga:"Dathanna oidhreachta:"},"Eldri litasamsetning":{en:"Legacy colors",nb:"Eldre farger",nn:"Eldre fargar",pl:"Starsze kolory",ga:"Dathanna oidhreachta"},legacy_colors_explain:{is:"Nota upprunalegu litina frá eldri útgáfu Netskrafls",en:"Use the original colors from the classic version of Netskrafl",nb:"Bruk de originale fargene fra den klassiske versjonen av Netskrafl",nn:"Bruk dei originale fargane frå den klassiske versjonen av Netskrafl",pl:"Użyj oryginalnych kolorów z klasycznej wersji Netskrafl",ga:"Úsáid na dathanna bunaidh ón leagan clasaiceach de Netskrafl"},use_original:{is:"Nota ",en:"Use ",nb:"Bruke ",nn:"Bruka ",pl:"Używa ",ga:"Úsáideann "},upprunalegu:{en:"the original",nb:"de originale",nn:"dei originale",pl:"oryginalne",ga:"na bunaidh"}," litina frá eldri útgáfu Netskrafls":{en:" colors from the classic version of Netskrafl",nb:" fargene fra den klassiske versjonen av Netskrafl",nn:" fargane frå den klassiske versjonen av Netskrafl",pl:" kolory z klasycznej wersji Netskrafl",ga:" dathanna ón leagan clasaiceach de Netskrafl"},"Hámarki viðureigna náð":{en:"Game limit reached",nb:"Spillgrensen er nådd",nn:"Spelgrensa er nådd",pl:"Osiągnięto limit gier",ga:"Teorainn cluichí bainte amach"},game_limit_message_1:{is:"Þú getur ekki haft fleiri en",en:"You have reached the maximum of",nb:"Du kan ikke ha mer enn",nn:"Du kan ikkje ha meir enn",pl:"Osiągnięto maksymalną liczbę",ga:"Ní féidir leat níos mó ná"},game_limit_message_2:{is:"viðureignir í gangi samtímis.",en:"concurrent games.",nb:"spill gående samtidig.",nn:"spel gåande samtidig.",pl:"jednoczesnych gier.",ga:"cluiche a bheith ar siúl ag an am céanna."},game_limit_message_3:{is:"Þú þarft að ljúka viðureignum sem eru í gangi áður en þú getur byrjað nýjar.",en:"You need to complete games in progress before starting new ones.",nb:"Du må fullføre pågående spill før du kan starte nye.",nn:"Du må fullføre pågåande spel før du kan starte nye.",pl:"Musisz zakończyć trwające gry, zanim rozpoczniesz nowe.",ga:"Ní mór duit cluichí atá ar siúl a chríochnú sula dtosaíonn tú cinn nua."},"Ég skil":{en:"I understand",nb:"Jeg forstår",nn:"Eg forstår",pl:"Rozumiem",ga:"Tuigim"},"[sentinel]":{}};let gp="is_IS",fp="is";const mp=/{\s*(\w+)\s*}/g;let vp={},yp=!1;function wp(e,t){for(const n in e)if(void 0!==e[n][t])return!0;return!1}function bp(e){!function(e,t){gp=e,fp=e.split("_")[0],wp(t,gp)||wp(t,fp)||(gp="en_US",fp="en"),vp={};for(const e in t)for(const n in t[e]){let i=t[e][n];if(Array.isArray(i)&&(i=i.join("")),void 0===vp[e]&&(vp[e]={}),i.match(/<[a-z]+>/)){const e=[];let t=0,n=null;for(;t<i.length&&(n=i.slice(t).match(/<[a-z]+>/))&&void 0!==n.index;){const r=n[0],s=t+n.index+r.length,a=i.indexOf(`</${r.slice(1)}`,s);a<0?t=s:(n.index>0&&e.push(i.slice(t,t+n.index)),e.push(Fd(r.slice(1,-1),i.slice(s,a))),t=a+r.length+1)}t<i.length&&e.push(i.slice(t)),i=e}vp[e][n]=i}yp=!0}(function(){const e=new URLSearchParams(window.location.search).get("lang");return e?e.replace("-","_"):null}()||e,pp)}function _p(e,t={}){const n=vp[e];if(void 0===n)return yp?e:"";const i=n[gp]||n[fp]||e;return Object.keys(t).length?Sp(i,t):i}function kp(e,t={}){const n=vp[e];if(void 0===n)return yp?e:"";const i=n[gp]||n[fp]||e;return"string"!=typeof i?"":Object.keys(t).length?function(e,t){return e.replace(mp,(e,n)=>t[n]||e)}(i,t):i}function Cp(e,t){return"string"==typeof t?Fd(e,_p(t)):Array.isArray(t)?Fd(e,t.map(e=>"string"==typeof e?_p(e):e)):Fd(e,t)}function Sp(e,t){return"string"==typeof e?e.replace(mp,(e,n)=>t[n]||e):Array.isArray(e)?e.map(e=>Sp(e,t)):e}const Tp=new WeakMap;const Ip="/board?game=",Ep=["january","february","march","april","may","june","july","august","september","october","november","december"];function Pp(e){const t=e.currentTarget.classList;void 0===t||t.contains("disabled")||t.add("over"),e.redraw=!1}function xp(e){const t=e.currentTarget.classList;void 0!==t&&t.remove("over"),e.redraw=!1}function Rp(e,t,n){return Fd(`span.glyphicon.glyphicon-${e}${n?".grayed":""}`,t??{})}function Lp(e,t){return Fd(`span.glyphicon.glyphicon-${e}.grayed`,t??{})}function Np(e){return Fd.trust(" ")}function Dp(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(e).replace(/[&<>"'/]/g,e=>t[e]??"")}function Ap(e){return document.getElementById(e).value}function Mp(e,t){dp(e).play(t)}function Op(e){e.slice(0,12)===Ip&&(e=e.slice(12));const t=e.slice(0,36);let n=e.slice(36);return n.length>0&&"&"===n.charAt(0)&&(n=`?${n.slice(1)}`),`/game/${t}${n}`}function jp(){const e=document.querySelectorAll("div.movelist .move");if(!e||!e.length)return;const t=e[e.length-1],n=t.parentNode,i=n.getAttribute("data-len"),r=i?parseInt(i,10):0;e.length>r&&(n.scrollTop=t.offsetTop),n.setAttribute("data-len",e.length.toString())}function Fp(e,t,n=!1){return e<0||e>=ap||t<0||t>=ap?null:n?`${t+1}${sp[e]}`:`${sp[e]}${t+1}`}function zp(e){var t=0,n=0,i=0,r=sp.indexOf(e[0]);return r>=0?(i=parseInt(e.slice(1),10)-1,t=1):(r=sp.indexOf(e.slice(-1)),i=parseInt(e,10)-1,n=1),{col:i,row:r,dx:t,dy:n}}function Up(e){const t=new Date(`${e}T00:00:00Z`),n=t.getUTCDate().toString(),i=kp(Ep[t.getUTCMonth()]);return kp("date_format",{day:n,month:i})}function $p(e=0){const t=()=>{const e=document.querySelector(".netskrafl-container");e?.focus()};e>0?setTimeout(t,e):setTimeout(t)}function qp(e,t,n=100){setTimeout(()=>{const n=document.querySelector(".netskrafl-container");n&&(n.tabIndex=0,n.addEventListener("keydown",e),n.addEventListener("compositionend",t),n.focus())},n)}function Bp(e){const t=document.querySelector(".netskrafl-container");t&&t.classList.toggle("legacy-colors",e)}class Vp{constructor(e){this.riddleLoading=!1,this.midnightTimer=null,this.visibilityHandler=null,this.model=e}cleanup(){this.clearMidnightTimer(),this.clearVisibilityHandler()}isViewingToday(){return!new URLSearchParams(window.location.search).has("date")}msUntilMidnightUTC(){const e=new Date;return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+1,0,0,0,0)).getTime()-e.getTime()}clearMidnightTimer(){null!==this.midnightTimer&&(clearTimeout(this.midnightTimer),this.midnightTimer=null)}setupMidnightTimer(){this.clearMidnightTimer();const e=this.msUntilMidnightUTC();this.midnightTimer=setTimeout(()=>{if(this.midnightTimer=null,!this.isViewingToday())return;const e=this.model.state?.locale||"is_IS",t=(new Date).toISOString().split("T")[0];this.loadRiddle(t,e)},e+5e3)}clearVisibilityHandler(){null!==this.visibilityHandler&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null)}setupVisibilityHandler(){this.clearVisibilityHandler(),this.visibilityHandler=()=>{if("visible"!==document.visibilityState)return;if(!this.isViewingToday())return;const e=this.model.riddle;if(!e)return;const t=(new Date).toISOString().split("T")[0];if(e.date<t){const e=this.model.state?.locale||"is_IS";this.loadRiddle(t,e)}},document.addEventListener("visibilitychange",this.visibilityHandler)}get isRiddleLoading(){return this.riddleLoading}onNavigateTo(e,t,n){const i=this.model;i.routeName=e,i.params=t;const r=t.uuid??"";if("game"===e){null!==i.game&&this.detachListenerFromGame(i.game.uuid);const e="1"===t.zombie;i.loadGame(r,()=>{this.attachListenerToGame(r,n),setTimeout(jp),n.isMobile()&&n.setSelectedTab("board"),$p(100)},e),null!==i.game&&void 0!==i.game&&gh("game_open",{locale:i.game.locale,uuid:t.uuid})}else if("review"===e){null!==i.game&&this.detachListenerFromGame(i.game.uuid);const e=t.move||"0";let s=parseInt(e,10);(Number.isNaN(s)||!s||s<0)&&(s=0),i.loadGame(r,()=>{i.loadBestMoves(s),setTimeout(jp),n.isMobile()&&n.setSelectedTab("board")})}else{null!==i.game&&(this.detachListenerFromGame(i.game.uuid),i.game.cleanup(),i.game=null);const t=i.state?.locale||"is_IS";"help"===e?(i.loadHelp(),gh("help",{locale:t})):"main"===e&&(n.actions.withSpinner(()=>i.loadAllLists()),i.userListCriteria=null,i.userList=null)}}onMoveMessage(e,t){this.model.handleMoveMessage(e,t)}onUserChallengeMessage(e,t){this.model.handleUserChallengeMessage(e,t)}onUserMoveMessage(e,t){this.model.handleUserMoveMessage(e,t)}onChatMessage(e,t,n){if(t);else if(this.model.addChatMessage(e.game,e.from_userid,e.msg,e.ts)){n.notifyChatMessage();const{state:t}=this.model,i=t.netskraflUserId??"";t.audio&&e.from_userid!==i&&Mp(t,"new-msg")}}onFullScreen(e){const t=this.model.state;t&&!t.uiFullscreen&&(t.uiFullscreen=!0,e&&(e.resetScale(),e.notifyMediaChange()),Fd.redraw())}onMobileScreen(e){const t=this.model.state;t&&!1!==t.uiFullscreen&&(t.uiFullscreen=!1,e&&e.notifyMediaChange(),Fd.redraw())}onLandscapeScreen(e){const t=this.model.state;t&&!t.uiLandscape&&(t.uiLandscape=!0,e&&e.notifyMediaChange(),Fd.redraw())}onPortraitScreen(e){const t=this.model.state;t&&!1!==t.uiLandscape&&(t.uiLandscape=!1,e&&e.notifyMediaChange(),Fd.redraw())}mediaMinWidth667(e,t){e.matches?this.onLandscapeScreen(t):this.onPortraitScreen(t)}mediaMinWidth1024(e,t){e.matches?this.onFullScreen(t):this.onMobileScreen(t)}initMediaListener(e){function t(e,t){try{e.addEventListener("change",t,{passive:!0})}catch(n){try{e.addListener(t)}catch(e){console.error(e)}}}let n=window.matchMedia("(min-width: 667px) and (max-width: 1023px) and (orientation: landscape)");n&&(this.mediaMinWidth667(n,e),t(n,()=>this.mediaMinWidth667(n,e))),n=window.matchMedia("(min-width: 1024px)"),n&&(this.mediaMinWidth1024(n,e),t(n,()=>this.mediaMinWidth1024(n,e)))}attachListenerToUser(){const e=this.model.state;e&&e.netskraflUserId&&(dh(`user/${e.netskraflUserId}/challenge`,(e,t)=>this.onUserChallengeMessage(e,t)),dh(`user/${e.netskraflUserId}/move`,(e,t)=>this.onUserMoveMessage(e,t)))}detachListenerFromUser(){const e=this.model.state;e?.netskraflUserId&&ph(`user/${e.netskraflUserId}`)}attachListenerToGame(e,t){const n=this.model.state;if(!e||!n)return;const i=`game/${e}/${n.netskraflUserId}/`;dh(`${i}move`,(e,t)=>this.onMoveMessage(e,t)),dh(`${i}chat`,(e,n)=>this.onChatMessage(e,n,t))}detachListenerFromGame(e){const t=this.model.state;if(!e||!t)return;const n=`game/${e}/${t.netskraflUserId}/`;ph(`${n}move`),ph(`${n}chat`)}async markFavorite(e,t){if(this.model.state)try{await ip(this.model.state,{method:"POST",url:"/favorite",body:{destuser:e,action:t?"add":"delete"}})}catch(e){}}async toggleFavorite(e,t){await this.markFavorite(e,!t)}async handleChallenge(e){if(this.model.state)try{const t=await ip(this.model.state,{method:"POST",url:"/challenge",body:e});if(0===t?.result){const t={locale:this.model.state?.locale||"is_IS"};void 0!==e.duration&&(t.duration=e.duration),void 0!==e.fairplay&&(t.fairplay=e.fairplay),void 0!==e.manual&&(t.manual=e.manual),gh(`challenge_${e.action}`,t),this.model.loadChallengeList(),this.model.userListCriteria&&this.model.loadUserList(this.model.userListCriteria)}}catch(e){}}async acceptChallenge(e,t){await this.handleChallenge({action:"accept",destuser:e,key:t})}async declineChallenge(e,t){await this.handleChallenge({action:"decline",destuser:e,key:t})}async retractChallenge(e,t){await this.handleChallenge({action:"retract",destuser:e,key:t})}async startNewGame(e,t=!1){if(this.model.state)try{const n={opp:e,rev:t};this.model.isExplo&&(n.board_type="explo");const i={method:"POST",url:"/initgame",body:n},r=await ip(this.model.state,i);if(r?.ok){const e=this.model.state?.locale||"is_IS";gh("new_game",{uuid:r.uuid,timed:t,locale:e}),Fd.route.set(`/game/${r.uuid}`)}}catch(e){}}async startRobotGame(e){await this.startNewGame(e,!1)}async loadUsers(e,t=!0){t?await this.withSpinner(()=>this.model.loadUserList(e)):await this.model.loadUserList(e)}async searchUsers(e,t=!0){await this.loadUsers({query:"search",spec:e},t)}async loadUsersByType(e,t=!0){await this.loadUsers({query:e,spec:""},t)}showSpinner(){this.model.spinners++,Fd.redraw()}hideSpinner(){this.model.spinners>0&&(this.model.spinners--,Fd.redraw())}async withSpinner(e){this.showSpinner();try{return await e()}finally{this.hideSpinner()}}async setUserPref(e){if(this.model.state)try{await ip(this.model.state,{method:"POST",url:"/setuserpref",body:e}),o(this.model.state)}catch(e){}}async cancelFriendship(){const e=this.model.user,t=this.model.state;if(!e||!t)return!1;try{const n=await ip(t,{method:"POST",url:"/cancelplan",body:{}});if(n?.ok)return e.friend=!1,t.hasPaid=!1,t.plan="",gh("cancel_plan",{userid:t.netskraflUserId,locale:t.locale,plan:"friend"}),!0}catch(e){}return!1}attachListenerToRiddle(e,t){const{state:n}=this.model,i=`gatadagsins/${e}/${t}/`;dh(`${i}count`,(e,t)=>this.onSolverCountUpdate(e,t)),dh(`${i}best`,(e,t)=>this.onRiddleGlobalScoreUpdate(e,t)),n?.userGroupId&&dh(`${i}group/${n.userGroupId}/best`,(e,t)=>this.onRiddleGroupScoreUpdate(e,t)),dh(`${i}leaders`,(e,t)=>this.onLeaderboardUpdate(e,t)),n?.netskraflUserId&&(dh(`gatadagsins/users/${t}/${n.netskraflUserId}/stats`,(e,t)=>this.onUserStatsUpdate(e,t)),dh(`${i}achievements/${n.netskraflUserId}`,(e,t)=>this.onPersonalBestScoreUpdate(e,t)))}detachListenerFromRiddle(e,t){const{state:n}=this.model,i=`gatadagsins/${e}/${t}/`;ph(`${i}count`),ph(`${i}best`),n?.userGroupId&&ph(`${i}group/${n.userGroupId}/best`),ph(`${i}leaders`),n?.netskraflUserId&&(ph(`gatadagsins/users/${t}/${n.netskraflUserId}/stats`),ph(`${i}achievements/${n.netskraflUserId}`))}onSolverCountUpdate(e,t){this.model.solverCount=e??0,Fd.redraw()}onRiddleGlobalScoreUpdate(e,t){const{riddle:n}=this.model,{score:i}=e;!n||!i||i<=0||(n.updateGlobalBestScore(e),Fd.redraw())}onRiddleGroupScoreUpdate(e,t){const{riddle:n}=this.model,{score:i}=e;!n||!i||i<=0||(n.updateGroupBestScore(e),Fd.redraw())}onLeaderboardUpdate(e,t){if(e&&"object"==typeof e){const{riddle:t}=this.model,n=t?.bestPossibleScore??Number.POSITIVE_INFINITY,i=Object.keys(e).map(t=>({userId:e[t].userId||t,displayName:e[t].displayName||"",score:e[t].score||0,timestamp:e[t].timestamp||""})).filter(e=>e.score<=n);i.sort((e,t)=>t.score!==e.score?t.score-e.score:e.timestamp.localeCompare(t.timestamp)),this.model.leaderboard=i}else this.model.leaderboard=[];Fd.redraw()}onUserStatsUpdate(e,t){this.model.userStats=e||null,Fd.redraw()}onPersonalBestScoreUpdate(e,t){const{riddle:n}=this.model;if(!n||!e||"object"!=typeof e)return;const i=e.score||0,r=e.word||"",s=e.coord||"",a=e.timestamp||(new Date).toISOString();if(i<=n.personalBestScore||!r||!s)return;n.personalBestScore=i;const o=n.playerMoves.some(e=>e.word===r&&e.coord===s&&e.score===i);o||n.playerMoves.push({word:r,score:i,coord:s,timestamp:a}),Fd.redraw()}async fetchRiddle(e,t){if(!this.model)throw new Error("Model is not initialized");await this.model.initRiddle(e,t),this.attachListenerToRiddle(e,t)}async loadRiddle(e,t){if(!this.riddleLoading){this.riddleLoading=!0,this.clearMidnightTimer();try{const n=this.model.riddle,i=(new Date).toISOString().split("T")[0];let r=e;(r<lp||r>i)&&(r=i);const s=new URL(window.location.href);r===i?s.searchParams.delete("date"):s.searchParams.set("date",r),window.history.pushState({},"",s.toString()),n&&this.detachListenerFromRiddle(n.date,n.locale),this.model.solverCount=0,await this.fetchRiddle(r,t),r===i?(this.setupMidnightTimer(),this.setupVisibilityHandler()):this.clearVisibilityHandler(),Fd.redraw()}finally{this.riddleLoading=!1}}}}const Hp=e=>{const{view:t,showClose:n}=e.attrs,{model:i,actions:r}=t,s=i.state;return{view:()=>Fd(".board-help",{title:kp("Hvernig reitirnir margfalda stigin")},[n?Fd(".board-help-close",{title:kp("Loka þessari hjálp"),onclick:e=>{s&&(s.beginner=!1,r.setUserPref({beginner:!1})),e.preventDefault()}},Rp("remove")):null,Fd(".board-colors",[Fd(".board-color[id='triple-word']",["3 x",Fd("br"),_p("orð")]),Fd(".board-color[id='double-word']",["2 x",Fd("br"),_p("orð")]),Fd(".board-color[id='triple-letter']",["3 x",Fd("br"),_p("stafur")]),Fd(".board-color[id='double-letter']",["2 x",Fd("br"),_p("stafur")]),Fd(".board-color[id='single-letter']",["1 x",Fd("br"),_p("stafur")])])])}},Wp=182,Gp=210,Kp=['<path d="M50.0335 81.1768V58.6393C50.0335 56.9025 48.7821 54.7618 47.2876 53.8732L27.7859 42.6044C26.2932 41.7158 23.7887 41.7158 22.296 42.6044L2.75319 53.8732C1.2587 54.7618 0.00732422 56.9025 0.00732422 58.6393V81.1768C0.00732422 82.9136 1.2587 85.0543 2.75319 85.9428L16.3591 93.7785C18.6617 95.0306 20.2366 97.4944 20.2366 100.322V115.145C20.2366 117.972 18.6617 120.436 16.3591 121.688L7.35643 126.898L2.79251 129.524C1.29981 130.412 0.0484453 132.553 0.0484453 134.29V156.827C0.0484453 158.564 1.29981 160.705 2.79251 161.593L22.296 172.862C23.7887 173.751 26.2932 173.751 27.7859 172.862L47.2876 161.593C48.7821 160.705 50.0335 158.564 50.0335 156.827V134.29C50.0335 132.553 48.7821 130.412 47.2876 129.524L33.6817 121.688C31.3791 120.436 29.806 117.972 29.806 115.145V100.322C29.806 97.4944 31.3791 95.0306 33.6817 93.7785L47.2876 85.9428C48.8232 85.0543 50.0335 82.9136 50.0335 81.1768Z" fill="#F17736"/>','<path d="M25.0401 73.1002C25.0401 71.3633 23.7887 69.2227 22.296 68.3341L2.75319 57.0653C1.2587 56.1767 0.00732422 56.9037 0.00732422 58.6404V81.1782C0.00732422 82.9149 1.2587 85.0556 2.75319 85.9441L22.2549 97.2129C23.7494 98.1015 25.0007 97.3745 25.0007 95.6377L25.0401 73.1002Z" fill="#FFAA88"/>','<path d="M73.9793 88.4472L68.2856 91.7188C66.9126 92.5267 65.7417 94.3846 65.5397 96.0405V96.0809V96.2021V96.4848V103.028C65.4986 100.524 64.1668 98.0601 61.7838 96.6868L48.9859 89.2954C46.5225 87.8818 43.6157 88.003 41.3543 89.3762L27.7466 97.2118C26.2539 98.0601 25.0007 97.3734 25.0007 95.6367V73.0989C25.0007 71.3622 26.2539 69.2217 27.7466 68.333L47.2483 57.0642C47.6934 56.8219 48.0974 56.7007 48.4603 56.7007C49.3488 56.7007 49.9941 57.4277 49.9941 58.6393V74.351C49.9137 76.9764 51.2866 79.6018 53.7089 81.0155L66.5086 88.4068C68.972 89.7801 71.7572 89.6993 73.9793 88.4472Z" fill="#C94314"/>','<path d="M25.0401 148.791C25.0401 147.054 23.7887 144.913 22.296 144.024L2.75319 132.756C1.2587 131.867 0.00732422 132.594 0.00732422 134.331V156.869C0.00732422 158.605 1.2587 160.746 2.75319 161.634L22.2549 172.903C23.7494 173.792 25.0007 173.065 25.0007 171.328L25.0401 148.791Z" fill="#FFAA88"/>','<path d="M50.035 156.869C50.035 158.605 48.7837 160.746 47.2892 161.634L27.7875 172.903C26.293 173.792 25.0416 173.065 25.0416 171.328V148.791C25.0416 147.054 26.293 144.913 27.7875 144.024L47.2892 132.756C48.7837 131.867 50.035 132.594 50.035 134.331V156.869Z" fill="#C94314"/>','<path d="M115.566 96.4844V119.022C115.566 120.759 114.313 122.899 112.821 123.788L93.3189 135.057C91.9853 135.824 89.9258 135.905 88.392 135.34C88.3116 135.299 88.2311 135.299 88.1507 135.259C88.1096 135.218 88.0685 135.218 87.988 135.178C87.9487 135.138 87.8665 135.138 87.8271 135.097L68.3254 123.828C68.1234 123.707 67.9608 123.586 67.7587 123.424C67.5979 123.263 67.3959 123.101 67.235 122.94C66.266 121.89 65.5385 120.355 65.5385 119.062V103.351C65.5385 103.229 65.5385 103.149 65.5385 103.028V96.4844C65.5385 96.4036 65.5385 96.3228 65.5385 96.2018C65.5385 96.1614 65.5385 96.121 65.5385 96.0806V96.0402C65.7011 94.3843 66.872 92.5261 68.2843 91.7185L73.9781 88.4468L87.786 80.4497C89.3198 79.561 91.7832 79.561 93.2777 80.4497L112.779 91.7185C114.354 92.6069 115.566 94.7477 115.566 96.4844Z" fill="#F17736"/>','<path d="M90.573 133.482C90.573 135.097 89.5218 135.824 88.1489 135.259C88.1096 135.219 88.0684 135.219 87.988 135.178C87.9487 135.138 87.8664 135.138 87.8271 135.097L68.3254 123.829C68.1234 123.707 67.9608 123.586 67.7587 123.425C67.5979 123.263 67.3958 123.102 67.235 122.94C66.266 121.89 65.5385 120.355 65.5385 119.063V103.351C65.5385 103.23 65.5385 103.149 65.5385 103.028V96.4847C65.5385 96.4039 65.5385 96.3231 65.5385 96.2019C65.5385 96.1615 65.5385 96.1211 65.5385 96.0807V96.0403C65.7405 94.6268 66.872 94.1016 68.2843 94.9094L76.6828 99.7561L87.8271 106.178C89.3609 107.067 90.573 109.207 90.573 110.944V133.482Z" fill="#FFAA88"/>','<path d="M115.566 16.7012V39.2388C115.566 40.9757 114.313 43.1162 112.821 44.0049L93.3189 55.2737C91.9853 56.0411 89.9258 56.1219 88.392 55.5563C88.3116 55.5159 88.2311 55.5159 88.1507 55.4757C88.1096 55.4353 88.0685 55.4353 87.988 55.3949C87.9487 55.3545 87.8665 55.3545 87.8271 55.3141L68.3254 44.0453C68.1234 43.9241 67.9608 43.8029 67.7587 43.6413C67.5979 43.4798 67.3959 43.3182 67.235 43.1566C66.266 42.1066 65.5385 40.5717 65.5385 39.2792V23.5675C65.5385 23.4463 65.5385 23.3657 65.5385 23.2444V16.7012C65.5385 16.6204 65.5385 16.5396 65.5385 16.4186C65.5385 16.3782 65.5385 16.3378 65.5385 16.2974V16.257C65.7011 14.601 66.872 12.7429 68.2843 11.9353L73.9781 8.66365L87.786 0.666489C89.3198 -0.222163 91.7832 -0.222163 93.2777 0.666489L112.779 11.9353C114.354 12.8237 115.566 14.9645 115.566 16.7012Z" fill="#F17736"/>','<path d="M89.6624 31.5736C89.6624 29.9159 88.4316 27.8729 86.9616 27.0247L67.7803 16.2696C66.3104 15.4216 65.0796 16.1154 65.0796 17.773V39.2833C65.0796 40.9409 66.3104 42.9841 67.7803 43.832L86.9616 54.5871C88.4316 55.4353 89.6624 54.7414 89.6624 53.0838V31.5736Z" fill="#FFAA88"/>','<path d="M115.691 38.9886C115.691 40.7689 114.388 42.9634 112.831 43.8742L92.5219 55.426C90.9673 56.3369 89.6622 55.5916 89.6622 53.8113V30.7077C89.6622 28.9272 90.9673 26.7329 92.5219 25.8219L112.831 14.2702C114.388 13.3593 115.691 14.1045 115.691 15.8848V38.9886Z" fill="#C94314"/>','<path d="M115.566 169.984V192.521C115.566 194.258 114.313 196.399 112.821 197.288L93.3189 208.556C91.9853 209.324 89.9258 209.405 88.392 208.839C88.3116 208.799 88.2311 208.799 88.1507 208.758C88.1096 208.718 88.0685 208.718 87.988 208.678C87.9487 208.637 87.8665 208.637 87.8271 208.597L68.3254 197.328C68.1234 197.207 67.9608 197.086 67.7587 196.924C67.5979 196.763 67.3959 196.601 67.235 196.439C66.266 195.389 65.5385 193.854 65.5385 192.562V176.85C65.5385 176.729 65.5385 176.648 65.5385 176.527V169.984C65.5385 169.903 65.5385 169.822 65.5385 169.701C65.5385 169.661 65.5385 169.62 65.5385 169.58V169.54C65.7011 167.884 66.872 166.026 68.2843 165.218L73.9781 161.946L87.786 153.949C89.3198 153.061 91.7832 153.061 93.2777 153.949L112.779 165.218C114.354 166.106 115.566 168.247 115.566 169.984Z" fill="#F17736"/>','<path d="M90.573 206.981C90.573 208.596 89.5218 209.323 88.1489 208.758C88.1096 208.718 88.0684 208.718 87.988 208.677C87.9487 208.637 87.8664 208.637 87.8271 208.596L68.3254 197.328C68.1234 197.206 67.9608 197.085 67.7587 196.924C67.5979 196.762 67.3958 196.601 67.235 196.439C66.266 195.389 65.5385 193.854 65.5385 192.562V176.85C65.5385 176.729 65.5385 176.648 65.5385 176.527V169.984C65.5385 169.903 65.5385 169.822 65.5385 169.701C65.5385 169.661 65.5385 169.62 65.5385 169.58V169.539C65.7405 168.126 66.872 167.601 68.2843 168.408L76.6828 173.255L87.8271 179.677C89.3609 180.566 90.573 182.706 90.573 184.443V206.981Z" fill="#FFAA88"/>','<path d="M116.102 192.239C116.102 193.975 114.851 196.116 113.356 197.005L93.8544 208.273C92.3617 209.162 91.1085 208.435 91.1085 206.698V184.161C91.1085 182.424 92.3617 180.283 93.8544 179.395L113.356 168.126C114.851 167.237 116.102 167.964 116.102 169.701V192.239Z" fill="#C94314"/>','<path d="M139.467 126.291L138.418 126.896L133.855 129.522C132.482 130.33 131.312 132.188 131.11 133.844V134.005V134.248V140.791C131.068 138.286 129.737 135.823 127.354 134.449L114.554 127.058C112.092 125.644 109.184 125.766 106.924 127.139L93.3164 134.974C91.7826 135.823 90.5706 135.136 90.5706 133.359V110.821C90.5706 109.084 91.8219 106.944 93.3164 106.055L112.818 94.7864C114.313 93.898 115.564 94.6248 115.564 96.3617V112.073C115.484 114.699 116.856 117.324 119.279 118.738L132.078 126.129C134.46 127.583 137.247 127.543 139.467 126.291Z" fill="#C94314"/>','<path d="M160.869 100.362V115.145C160.869 117.972 162.444 120.436 164.745 121.688L178.353 129.524C179.845 130.412 181.099 132.553 181.099 134.29V156.827C181.099 158.564 179.845 160.705 178.353 161.593L158.851 172.862C157.478 173.629 155.338 173.71 153.844 173.104C153.763 173.064 153.722 173.064 153.642 173.024C153.561 172.983 153.44 172.943 153.359 172.862L133.858 161.593C133.493 161.391 133.13 161.068 132.808 160.745C131.837 159.695 131.112 158.16 131.112 156.827V141.156C131.112 141.035 131.112 140.954 131.112 140.833V134.29C131.112 134.209 131.112 134.128 131.112 134.047C131.112 134.007 131.112 133.926 131.112 133.886C131.273 132.23 132.444 130.331 133.858 129.564L138.42 126.939L139.469 126.333L140.803 125.565L147.424 121.728C147.585 121.647 147.707 121.567 147.868 121.486C149.927 120.153 151.3 117.851 151.3 115.185V100.402C151.3 97.5752 149.725 95.1114 147.424 93.8593L133.858 86.0236C132.363 85.135 131.112 82.9944 131.112 81.2577V58.6393C131.112 56.9025 132.363 54.7618 133.858 53.8732L153.359 42.6044C154.893 41.7158 157.356 41.7158 158.851 42.6044L178.353 53.8732C179.886 54.7618 181.099 56.9025 181.099 58.6393V81.1769C181.099 82.0653 180.775 83.0348 180.291 83.8829C179.806 84.7311 179.12 85.4986 178.353 85.9428L164.745 93.7785C162.444 95.071 160.869 97.5348 160.869 100.362Z" fill="#F17736"/>','<path d="M156.105 73.1002C156.105 71.3633 154.854 69.2227 153.359 68.3341L133.858 57.0653C132.363 56.1767 131.112 56.9037 131.112 58.6404V81.1782C131.112 82.9149 132.363 85.0556 133.858 85.9441L153.359 97.2129C154.854 98.1015 156.105 97.3745 156.105 95.6377V73.1002Z" fill="#FFAA88"/>','<path d="M181.096 81.1782C181.096 82.9149 179.845 85.0556 178.35 85.9441L158.849 97.2129C157.356 98.1015 156.103 97.3745 156.103 95.6377V73.1002C156.103 71.3633 157.356 69.2227 158.849 68.3341L178.35 57.0653C179.845 56.1767 181.096 56.9037 181.096 58.6404V81.1782Z" fill="#C94314"/>','<path d="M156.105 171.328C156.105 172.903 155.136 173.63 153.844 173.145C153.763 173.105 153.722 173.105 153.642 173.064C153.561 173.024 153.44 172.984 153.359 172.903L133.857 161.634C133.493 161.432 133.13 161.109 132.808 160.786C131.837 159.736 131.112 158.201 131.112 156.868V141.197C131.112 141.076 131.112 140.995 131.112 140.874V134.331C131.112 134.25 131.112 134.169 131.112 134.088C131.112 134.048 131.112 133.967 131.112 133.927C131.314 132.513 132.443 131.988 133.857 132.796L142.215 137.642L153.359 144.064C154.893 144.953 156.105 147.094 156.105 148.83V171.328Z" fill="#FFAA88"/>','<path d="M181.096 156.869C181.096 158.605 179.845 160.746 178.35 161.634L158.849 172.903C157.356 173.792 156.103 173.065 156.103 171.328V148.791C156.103 147.054 157.356 144.913 158.849 144.024L178.35 132.756C179.845 131.867 181.096 132.594 181.096 134.331V156.869Z" fill="#C94314"/>'],Yp=`\n<svg preserveAspectRatio="xMidYMid meet" width="100%" height="100%" viewBox="0 0 182 210" fill="none" xmlns="http://www.w3.org/2000/svg">\n${Kp.join("\n")}\n</svg>`,Jp=Fd.trust(Yp),Zp=Math.max(Wp,Gp)+40,Xp=`\n<svg preserveAspectRatio="xMidYMid meet" width="100%" height="100%" viewBox="0 0 ${Zp} ${Zp}" fill="none" xmlns="http://www.w3.org/2000/svg">\n ${`<circle cx="${Zp/2}" cy="${Zp/2}" r="${Zp/2-5}" fill="#ffffff"/>`}\n <svg x="${(Zp-Wp)/2}" y="${(Zp-Gp)/2}" width="182" height="210" viewBox="0 0 182 210">\n ${Kp.join("\n")}\n </svg>\n</svg>`,Qp=Fd.trust(Xp),eg=e=>{const{attrs:t}=e,{width:n,withCircle:i}=t;return{view:()=>{const e={};return void 0!==n&&(e.width=`${n}px`),Fd(".animated-netskrafl-logo",{style:e},i?Qp:Jp)}}},tg="netskrafl_settings",ng={autoZoom:!0,legacyColors:!1};let ig=null;function rg(){if(ig)return ig;try{const e=localStorage.getItem(tg);if(e){const t={...ng,...JSON.parse(e)};return ig=t,t}}catch(e){console.error("Failed to load settings:",e)}const e={...ng};return ig=e,e}function sg(e){try{localStorage.setItem(tg,JSON.stringify(e)),ig=e}catch(e){console.error("Failed to save settings:",e)}}function ag(){return rg().autoZoom}function og(e){const t=rg();t.autoZoom=e,sg(t)}function lg(){return rg().legacyColors}function cg(e){const t=rg();t.legacyColors=e,sg(t),Bp(e)}const ug={oninit:e=>{e.state.show=!1,e.state.ival=setTimeout(()=>{e.state.show=!0,e.state.ival=0,Fd.redraw()},800)},onremove:e=>{e.state.ival&&clearTimeout(e.state.ival),e.state.ival=0},view:e=>{if(e.state.show)return Fd(".modal-dialog",{id:"spinner-dialog",style:{visibility:"visible"}},Fd(".animated-spinner",Fd(eg,{withCircle:!0})))}},hg=()=>{let e="",t="";return{oninit:n=>{e=`${n.attrs.initialValue}`,t=n.attrs.class,t=t?`.${t.split(" ").join(".")}`:""},view:n=>{const{id:i,maxlength:r,tabindex:s,autocomplete:a}=n.attrs;return Fd(`input.text${t}`,{id:i,name:i,maxlength:r,tabindex:s,autocomplete:a,value:e,oninput:t=>{e=`${t.target.value}`}})}}},dg={view:e=>{const t={onmouseout:xp,onmouseover:Pp};return Object.assign(t,e.attrs),Fd(".modal-close",t,e.children)}},pg={view:e=>{const t=e.attrs.item,n=e.attrs.view,i=n.actions,r=0===t.userid.indexOf("robot-");function s(){if(t.chall)t.chall=!1,i.retractChallenge(t.userid,"");else if(r){if(!function(){const e=n.model.moreGamesAllowed();if("allowed"===e)return!0;const t=n.model.state;return"limit_reached"===e?(t&&gh("hit_absolute_game_limit",{userid:t.netskraflUserId,locale:t.locale}),n.showGameLimitReached()):(t&&gh("hit_game_limit",{userid:t.netskraflUserId,locale:t.locale,limit:n.model.maxFreeGames}),n.showFriendPromo()),!1}())return;i.startRobotGame(t.userid)}else n.pushDialog("challenge",t)}return Fd("span.list-ch",{title:kp("Skora á"),onclick:e=>{s(),e.preventDefault()}},Rp("hand-right",void 0,!t.chall))}},gg={view:e=>{const t=e.attrs.item,n=e.attrs.view,i=!t.userid||0===t.userid.indexOf("robot-");return Fd("span.list-info",{title:kp("Skoða feril"),onclick:e=>{i||n.showUserInfo(t.userid,t.nick,t.fullname),e.preventDefault()}},i?"":Fd("span.usr-info"))}},fg={oninit:e=>{const{state:t}=e;t.online=!1},oncreate:e=>{const{attrs:t,state:n}=e;if(n.online=!!t.online,void 0===t.online){(async()=>{try{const e=await ip(t.state,{method:"POST",url:"/onlinecheck",body:{user:t.userId}});n.online=e?.online}catch(e){n.online=!1}})()}},view:e=>{const{attrs:t,state:n}=e,i=n.online||!!t.online;return Fd("span",{id:t.id,title:kp(i?"Er álínis":"Álínis?"),class:i?"online":""})}},mg={view:e=>{const t=e.attrs.view,n=t.model;return n.state?.netskraflUserId?Fd(".userid",{title:kp("player_info"),onclick:e=>{t.pushDialog("userprefs",{}),e.preventDefault()}},[Rp("address-book"),Np(),n.state.userNick]):""}},vg={view:e=>{const{manual:t,header:n}=e.attrs,i=kp("Keppnishamur"),r=!0===t&&!n;return Fd("span.list-manual",r||n?{title:i}:{},Rp("lightbulb",void 0,!r))}},yg=e=>{let t=e.attrs.initialSelection??0;const n=e.attrs.defaultClass??"",i=e.attrs.selectedClass||"selected";return{view:e=>{const r=e.children;if(Array.isArray(r))return Fd("div",{onclick:e=>{const n=r.map(e=>e.dom);for(let i=0;i<n.length;i++)n[i].contains(e.target)&&(t=i);e.stopPropagation()}},r.map((e,r)=>{const s=e;return s.attrs.className=r===t?`${n} ${i}`:n,e}))}}},wg={view:()=>Fd(".info",{title:kp("Upplýsingar og hjálp")},Fd(Fd.route.Link,{href:"/help",class:"iconlink"},Rp("info-sign")))},bg={view:e=>Fd(".logo"+(e.attrs.hidden?".hidden":""),Fd(Fd.route.Link,{href:"/main",class:"nodecorate"},Rp("home")))},_g={view:e=>Fd(".header-logo"+(e.attrs.hidden?".hidden":""),Fd(Fd.route.Link,{href:"/main",class:"backlink"},Rp("home")))},kg=()=>{function e(e,t){const n=document.querySelector(`#${e} #opt1`)?.classList,i=document.querySelector(`#${e} #opt2`)?.classList;n?.toggle("selected"),i?.toggle("selected"),void 0!==t&&i&&t(i.contains("selected"))}return{view:({attrs:{id:t,small:n,funcToggle:i,state:r,tabindex:s,title:a,opt1:o,opt2:l}})=>{const c=`${t}-toggler`,u=".option"+(n?".small":"");return Fd.fragment({},[Fd(`input.checkbox.${t}`,{type:"checkbox",id:t,name:t,checked:r,value:"True"}),Fd(".toggler",{id:c,tabindex:s,title:a,onclick:t=>{e(c,i),t.preventDefault()},onkeypress:t=>{" "===t.key&&(e(c,i),t.preventDefault())}},[Fd(u+(r?"":".selected"),{id:"opt1"},o),Fd(u+(r?".selected":""),{id:"opt2"},l)])])}}},Cg=e=>{const t=e.attrs.view,n=t.model;function i(e){n.state&&(n.state.ready=e,t.actions.setUserPref({ready:e}))}return{view:()=>Fd(kg,{id:"ready",state:n.state?.ready??!1,tabindex:2,opt1:Np(),opt2:Rp("thumbs-up"),funcToggle:i,small:!0,title:kp("Tek við áskorunum!")})}},Sg=e=>{const t=e.attrs.view,n=t.model;function i(e){n.state&&(n.state.readyTimed=e,t.actions.setUserPref({ready_timed:e}))}return{view:()=>Fd(kg,{id:"timed",state:n.state?.readyTimed??!1,tabindex:3,opt1:Np(),opt2:Rp("time"),funcToggle:i,small:!0,title:kp("Til í viðureign með klukku!")})}},Tg=e=>{const{model:t}=e.attrs.view;function n(e){e&&null!==t.state&&Mp(t.state,"your-turn")}return{view:({attrs:{state:e,tabindex:t}})=>Fd(kg,{id:"audio",state:e,tabindex:t,opt1:Rp("volume-off"),opt2:Rp("volume-up"),funcToggle:n,small:!0,title:kp("Hljóð á/af")})}},Ig=e=>{const{model:t}=e.attrs.view;function n(e){e&&null!==t.state&&Mp(t.state,"you-win")}return{view:({attrs:{state:e,tabindex:t}})=>Fd(kg,{id:"fanfare",state:e,tabindex:t,opt1:Rp("volume-off"),opt2:Rp("volume-up"),funcToggle:n,small:!0,title:kp("Lúðraþytur á/af")})}},Eg=()=>({view:({attrs:{state:e,tabindex:t}})=>Fd(kg,{id:"beginner",state:e,tabindex:t,opt1:Np(),opt2:Rp("ok"),small:!0})}),Pg=()=>({view:({attrs:{state:e,tabindex:t}})=>Fd(kg,{id:"fairplay",state:e,tabindex:t,opt1:Np(),opt2:Rp("edit"),small:!0})}),xg=()=>{let e=lg();function t(t){e=t,cg(t)}return{view:({attrs:{tabindex:n}})=>Fd(kg,{id:"legacy-colors",state:e,tabindex:n,opt1:Np(),opt2:Rp("brush"),funcToggle:t,small:!0})}},Rg=()=>{function e(e){e.cancelBlankDialog(),$p()}function t(e,t){e.placeBlank(t),$p()}function n(e){const n=e.alphabet;let i=n.length,r=0;const s=[];for(;i>0;){const a=[];for(let s=0;s<6&&i>0;s++){const s=n[r++];a.push(Fd("td",{onclick:n=>{n.preventDefault(),t(e,s)},onmouseover:Pp,onmouseout:xp},Fd(".blank-choice.netskrafl-tile.netskrafl-racktile",s))),i--}s.push(Fd("tr",a))}return s}return{view:i=>{const{game:r}=i.attrs;if(r)return Fd(".modal-dialog",{id:"blank-dialog",style:{visibility:"visible"},tabindex:-1,onkeydown:n=>function(n,i){const{key:r}=i;if("Escape"===r)return i.preventDefault(),i.stopPropagation(),void e(n);if(i.isComposing)return;const s=r.normalize("NFC");if(1===s.length){const e=s.toLowerCase();n.alphabet.includes(e)&&(i.preventDefault(),i.stopPropagation(),t(n,e))}}(r,n),oncompositionend:e=>function(e,n){const{data:i}=n,r=i?.normalize("NFC");if(r&&1===r.length){const i=r.toLowerCase();e.alphabet.includes(i)&&(n.preventDefault(),n.stopPropagation(),t(e,i))}}(r,e),oncreate:e=>e.dom.focus()},Fd(".ui-widget.ui-widget-content.ui-corner-all",{id:"blank-form"},[Cp("p","Hvaða staf táknar auða flísin?"),Fd(".rack.blank-rack",Fd("table.board",{id:"blank-meaning"},n(r))),Fd(dg,{id:"blank-close",title:kp("Hætta við"),onclick:t=>{t.preventDefault(),e(r)}},Rp("remove"))]))}}};function Lg(e,t,n,i,r,s,a){const o={onmouseout:xp,onmouseover:Pp,style:{visibility:!1===s?"hidden":"visible"}};return i&&(o.title=i),a&&(o.id=a),o.onclick=t?e=>e.preventDefault():e=>{n?.(),e.preventDefault()},Fd(`.${e}${t?".disabled":""}`,o,r)}const Ng={view:e=>{const{game:t}=e.attrs,n=[".score"];t.manual?n.push("manual"):t.wordGood&&(n.push("word-good"),void 0!==t.currentScore&&t.currentScore>=50&&n.push("word-great"));const i=void 0===t.currentScore?"?":t.currentScore.toString();return Fd(n.join("."),{title:i},i)}},Dg={view:e=>{const{view:t,game:n,disabled:i,visible:r=!0}=e.attrs;if(n)return Lg("recallbtn",!!i,()=>{n.resetRack(),t.updateScale()},kp("Færa stafi aftur í rekka"),Rp("down-arrow"),r)}},Ag={view:e=>{const{game:t,disabled:n,visible:i=!0}=e.attrs;if(t)return Lg("scramblebtn",!!n,()=>t.rescrambleRack(),kp("Stokka upp rekka"),Rp("random"),i)}},Mg={view:e=>{const{view:t,game:n}=e.attrs;if(!n)return;const i=n.buttonState();if(i.showRecall&&!i.showingDialog)return Fd(Dg,{view:t,game:n});const r=i.showScramble&&!i.tilesPlaced,s=i.showingDialog;return Fd(Ag,{view:t,game:n,visible:r,disabled:s})}},Og={view:e=>{const{view:t}=e.attrs,{game:n}=t.model,i=[];if(!n)return i;const r=n.buttonState();if(i.push(Fd(".word-check"+(r.wordGood?".word-good":"")+(r.wordBad?".word-bad":""))),r.showChallenge){const e=(r.tilesPlaced||r.showingDialog)&&!r.lastChallenge;i.push(Lg("challenge",e,()=>n.submitChallenge(),"Véfenging (röng kostar 10 stig)",Rp("ban-circle")))}if(r.showRecall&&i.push(Fd(Dg,{view:t,game:n,disabled:r.showingDialog})),r.showScramble&&i.push(Fd(Ag,{view:t,game:n,disabled:r.showingDialog})),r.showMove){const e=kp("submit_move"),s=!r.tilesPlaced||r.showingDialog;i.push(Lg("submitmove",s,()=>{n.submitMove(),t.updateScale()},e,[e,Rp("play")]))}if(r.showMoveMobile){const e=["submitmove"];let s=void 0!==n.currentScore;n.manual?e.push("manual"):r.wordGood?(e.push("word-good"),void 0!==n.currentScore&&n.currentScore>=50&&e.push("word-great")):r.wordBad&&(e.push("word-bad"),s=!1);const a=void 0===n.currentScore?"?":n.currentScore.toString(),o=[Fd("span.score-mobile",a)];let l;r.canPlay&&s?o.push(Rp("play")):o.push(Rp("remove")),l=r.canPlay?s?()=>{n.submitMove(),t.updateScale()}:()=>{}:()=>{const e=document.querySelector("div.opp-turn");e&&(e.classList.toggle("flashing",!0),setTimeout(()=>e.classList.toggle("flashing",!1),1200))},i.push(Lg(e.join("."),r.showingDialog,l,a,o,!0,"move-mobile"))}if(r.showForceResignMobile){const e=kp("Þvinga til uppgjafar");i.push(Lg("force-resign",r.showingDialog,()=>n.forceResign(),e,e))}if(r.showPass){const e=(r.tilesPlaced||r.showingDialog)&&!r.lastChallenge;i.push(Lg("submitpass",e,()=>n.submitPass(),kp("Pass"),Rp("forward")))}if(r.showExchange){const e=!r.exchangeAllowed||r.tilesPlaced||r.showingDialog;i.push(Lg("submitexchange",e,()=>n.submitExchange(),kp("Skipta stöfum"),Rp("refresh")))}if(r.showResign&&i.push(Lg("submitresign",r.showingDialog,()=>n.submitResign(),kp("Gefa viðureign"),Rp("fire"))),!r.gameOver&&!r.localTurn&&!n.moveInProgress&&null!==n.player){const e=n.nickname[1-n.player];i.push(Fd(".opp-turn",{style:{visibility:"visible"}},[Fd("span.move-indicator"),Np(),Fd("strong",kp("opp_move",{opponent:e})),Np(),r.tardyOpponent?Fd("span.yesnobutton",{id:"force-resign",onclick:e=>{e.preventDefault(),n.forceResign()},onmouseout:xp,onmouseover:Pp,title:kp("14 dagar liðnir án leiks")},kp("Þvinga til uppgjafar")):""]))}if(r.tilesPlaced){const e=Fd(Ng,{game:n});e&&i.push(e)}return n?.moveInProgress&&i.push(Fd(".waitmove",Fd(".animated-waitmove",Fd(eg,{withCircle:!1})))),Fd(".buttons",i)}};class jg{getEventCoordinates(e){if(e instanceof MouseEvent)return{x:e.clientX,y:e.clientY};if(e instanceof TouchEvent){const t=e.touches[0];return t?{x:t.clientX,y:t.clientY}:{x:this.lastX,y:this.lastY}}return{x:0,y:0}}static rectContains(e,t){return t.x>=e.left&&t.x<e.right&&t.y>=e.top&&t.y<e.bottom}constructor(e,t,n){this.parentElement=null,this.parentRect=null,this.offsetX=0,this.offsetY=0,this.centerX=0,this.centerY=0,this.startX=0,this.startY=0,this.lastX=0,this.lastY=0,this.currentDropTarget=null,this.dragStarted=!1;const i=e.currentTarget;i.addEventListener("click",e=>e.stopPropagation(),{once:!0});const r=this.getEventCoordinates(e);this.startX=r.x,this.startY=r.y,this.lastX=r.x,this.lastY=r.y,this.draggedElement=i,this.dropHandler=t,this.clickHandler=n,this.parentElement=i.parentElement,this.parentRect=this.parentElement?.getBoundingClientRect()??null,this.boundEventHandlers={drag:this.drag.bind(this),endDrag:this.endDrag.bind(this),cancelDrag:this.cancelDrag.bind(this)};const{drag:s,endDrag:a,cancelDrag:o}=this.boundEventHandlers;e instanceof MouseEvent?(document.addEventListener("mousemove",s),document.addEventListener("mouseup",a),document.addEventListener("mouseleave",o)):e instanceof TouchEvent&&(document.addEventListener("touchmove",s,{passive:!1}),document.addEventListener("touchend",a),document.addEventListener("touchcancel",a)),document.addEventListener("visibilitychange",o),window.addEventListener("blur",o)}initiateDrag(e){e.preventDefault(),this.dragStarted=!0;const t=this.draggedElement,n=t.getBoundingClientRect(),{offsetWidth:i,offsetHeight:r}=t,s=t.closest(".netskrafl-container"),a=s?.classList.contains("legacy-colors");t.classList.add("dragging"),a&&t.classList.add("legacy-colors"),document.body.appendChild(t);const{offsetWidth:o,offsetHeight:l}=t;this.offsetX=this.startX-n.left+(o-i)/2,this.offsetY=this.startY-n.top+(l-r)/2,this.centerX=o/2,this.centerY=l/2,this.updatePosition(this.lastX,this.lastY)}removeDragListeners(){const{drag:e,endDrag:t,cancelDrag:n}=this.boundEventHandlers;document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t),document.removeEventListener("mouseleave",n),document.removeEventListener("touchmove",e),document.removeEventListener("touchend",t),document.removeEventListener("touchcancel",t),document.removeEventListener("visibilitychange",n),window.removeEventListener("blur",n)}elementCenter(e,t){return{x:e-this.offsetX+this.centerX,y:t-this.offsetY+this.centerY}}findDropTargetAtPoint(e,t){const{x:n,y:i}=this.elementCenter(e,t);for(const e of document.elementsFromPoint(n,i)){if(e.classList.contains("drop-target"))return e;if(e.classList.contains("not-target"))return null}return null}updatePosition(e,t){this.lastX=e,this.lastY=t,this.draggedElement.style.left=e-this.offsetX+"px",this.draggedElement.style.top=t-this.offsetY+"px"}updateDropTarget(e,t){const n=this.findDropTargetAtPoint(e,t);n!==this.currentDropTarget&&(this.currentDropTarget&&this.currentDropTarget.classList.remove("over"),n&&n.classList.add("over"),this.currentDropTarget=n)}drag(e){e.stopPropagation();const t=this.getEventCoordinates(e);if(this.lastX=t.x,this.lastY=t.y,!this.dragStarted){return void(Math.sqrt((t.x-this.startX)**2+(t.y-this.startY)**2)>=10&&this.initiateDrag(e))}e.preventDefault(),this.updatePosition(t.x,t.y),this.updateDropTarget(t.x,t.y);const n=null!==this.currentDropTarget||this.parentRect&&jg.rectContains(this.parentRect,t);this.draggedElement.classList.toggle("no-drop",!n)}resetPosition(){this.draggedElement.style.left="",this.draggedElement.style.top="",this.draggedElement.classList.remove("dragging","no-drop","legacy-colors"),this.parentElement&&this.parentElement.appendChild(this.draggedElement)}cancelDrag(){this.removeDragListeners(),this.currentDropTarget&&this.currentDropTarget.classList.remove("over"),this.dragStarted&&this.resetPosition()}endDrag(e){if(e.stopPropagation(),this.removeDragListeners(),!this.dragStarted)return void(this.clickHandler&&this.clickHandler(this.draggedElement));e.preventDefault();const t=this.getEventCoordinates(e),n=this.findDropTargetAtPoint(t.x,t.y);this.currentDropTarget&&this.currentDropTarget.classList.remove("over"),this.draggedElement.style.visibility="hidden",this.resetPosition(),n&&this.dropHandler(this.draggedElement,n),setTimeout(()=>{this.draggedElement.style.visibility="visible"})}}const Fg=(e,t,n)=>i=>{var r,s,a;if(!("button"in i)||0===i.button)return s=(i,r)=>{if(!t)return;const s=r.id;if(!s)return;let a="";if("board-background"===s?a="R1":s.startsWith("sq_")&&(a=s.slice(3)),a)try{t.attemptMove(n,a),e.updateScale(),Fd.redraw()}catch(e){console.error(e)}},a=()=>{t&&(n===t.selectedSq?t.selectedSq=null:t.selectedSq=n,Fd.redraw())},(r=i).stopPropagation(),new jg(r,s,a),i.redraw=!1,!1},zg=()=>({view:e=>{const{view:t,game:n,coord:i,opponent:r}=e.attrs;if(!n)return;const s="R"===i[0],a=n.tiles[i],o=[".netskrafl-tile"],l={};if("?"===a.tile&&o.push("netskrafl-blanktile"),"q".includes(a.letter)?o.push("netskrafl-extra-wide"):"zxmæ".includes(a.letter)&&o.push("netskrafl-wide"),s||a.draggable?(o.push(r?"netskrafl-freshtile":"netskrafl-racktile"),s&&"exchange"===n.showingDialog&&(a.xchg&&o.push("netskrafl-xchgsel"),l.onclick=e=>{a.xchg=!a.xchg,e.preventDefault()})):a.freshtile&&o.push("netskrafl-freshtile"),a.index){const e=150,t=`${(a.index*e).toString()}ms`;l.style=`animation-delay: ${t}`}if(i===n.selectedSq&&o.push("sel"),void 0!==a.highlight&&o.push(`highlight${a.highlight}`),a.draggable&&n.allowDragDrop()){const e=Fg(t,n,i);l.onmousedown=e,l.ontouchstart=e}return Fd(o.join("."),l,[Fd(".tileletter"," "===a.letter?Np():a.letter),Fd(".letterscore",a.score)])}}),Ug={view:e=>{const{view:t,game:n,coord:i}=e.attrs;if(n)return Fd("td.not-target",{id:`sq_${i}`,class:n.squareClass(i)},Fd(zg,{view:t,game:n,coord:i,opponent:!1}))}},$g={view:e=>{const{game:t,coord:n}=e.attrs;if(!t)return;let i=t.squareClass(n)||"";return i&&(i=`.${i}`),i+=e.attrs.opponent?".opp":".local",Fd(`td${i}`,{id:`sq_${n}`},e.children)}},qg={view:e=>{const{view:t,game:n,coord:i,isKeyboardTarget:r,keyboardDirection:s}=e.attrs;if(!n)return;let a=n.squareClass(i)||"";return a&&(a=`.${a}`),null!==n.askingForBlank&&n.askingForBlank.to===i&&(a+=".blinking"),i===n.startSquare&&n.localturn&&(a+=".center"),r&&(a+=".keyboard-target","V"===s&&(a+=".vertical")),Fd(`td.drop-target${a}`,{id:`sq_${i}`,onclick:e=>{if(null!==n.selectedSq)return e.stopPropagation(),n.attemptMove(n.selectedSq,i),n.selectedSq=null,e.currentTarget.classList.remove("sel"),t.updateScale(),!1},onmouseover:e=>{null!==n.selectedSq&&e.currentTarget.classList.add("sel")},onmouseout:e=>{e.currentTarget.classList.remove("sel")}},e.children)}},Bg={view:e=>{const{view:t,game:n,review:i}=e.attrs;if(!n)return;const{model:r}=t,s=[],a=r.reviewMove??0,o=i&&0===a,l=i&&a>0&&a%2===n.player;for(let e=1;e<=7;e++){const r=`R${e}`;!o&&n&&r in n.tiles?i?s.push(Fd($g,{key:r,view:t,game:n,coord:r,opponent:l},Fd(zg,{view:t,game:n,coord:r,opponent:l}))):s.push(Fd(qg,{key:r,view:t,game:n,coord:r},Fd(zg,{view:t,game:n,coord:r,opponent:!1}))):i?s.push(Fd($g,{key:r,view:t,game:n,coord:r,opponent:!1})):s.push(Fd(qg,{key:r,view:t,game:n,coord:r}))}return Fd("table.board",Fd("tbody",Fd("tr",s)))}},Vg={view:e=>{const{view:t,game:n,review:i}=e.attrs;return Fd(".rack-row",[Fd(".rack-left",Fd(Mg,{view:t,game:n})),Fd(".rack",Fd(Bg,{view:t,game:n,review:i}))])}},Hg={view:e=>{const{game:t}=e.attrs;return t.congratulate?Fd("div",{id:"congrats"},[Rp("bookmark")," ",Cp("strong","Til hamingju með sigurinn!")]):t.over?Fd("div",{id:"gameover"},[Rp("info-sign")," ",Cp("strong","Viðureigninni er lokið")]):void 0}},Wg={view:e=>{const{game:t}=e.attrs,n=t.currentError||"";if(n&&n in cp){const e=t.currentMessage||"",i=kp(cp[n]),r=i.indexOf("{word}");let s;return s=r>=0?[i.slice(0,r),Fd("span.errword",e),i.slice(r+6)]:[i],Fd(".error",{style:{visibility:"visible"},onclick:e=>{t.resetError(),e.preventDefault()}},[Rp("exclamation-sign"),...s])}}},Gg={view:e=>{const{view:t,game:n}=e.attrs;let i=[];return n&&(i=[Fd(Kg,{view:t,game:n,review:!1}),Fd(Vg,{view:t,game:n,review:!1}),Fd(Og,{view:t}),Fd(Wg,{game:n}),Fd(Hg,{game:n})],i=i.concat(t.vwDialogs())),Fd(".board-area",i)}};const Kg={oninit:e=>{e.state.columnIdentifiers=function(){const e=[];e.push(Fd("td"));for(let t=1;t<=15;t++)e.push(Fd("td",t.toString()));return Fd("tr.colid",e)}()},view:e=>{const{view:t,game:n,review:i}=e.attrs,r=t.isMobile(),s=i||r?null:n.getNextKeyboardSquare();function a(e){const r=[];r.push(Fd("td.rowid",{key:`R${e}`},e));for(let a=1;a<=15;a++){const o=e+a.toString();n&&o in n.tiles?r.push(Fd(Ug,{view:t,game:n,key:o,coord:o,opponent:!1})):i?r.push(Fd($g,{view:t,game:n,key:o,coord:o,opponent:!1})):r.push(Fd(qg,{view:t,game:n,key:o,coord:o,isKeyboardTarget:o===s,keyboardDirection:n?.getEffectiveKeyboardDirection()}))}return Fd("tr",r)}const o=Fd("tbody",function(){const t=[];t.push(e.state.columnIdentifiers);for(const e of"ABCDEFGHIJKLMNO")t.push(a(e));return t}()),l=Fd("table.board",{},o);return Fd(".board",{id:"board-parent",onclick:e=>{r&&t.boardScale>1&&function(e){const t=e.currentTarget;if(!t)return!1;const n=Date.now(),i=Tp.get(t)||0;return Tp.set(t,n),n-i<300}(e)&&(e.stopPropagation(),t.zoomOut())}},l)}},Yg={view:e=>{const{riddle:t,mode:n="desktop"}=e.attrs;if(!t)return Fd("div");const i=t.currentScore,r=void 0!==i,s=["mobile"===n?".mobile-score":".gata-dagsins-score"];let a="0";t.tilesPlaced().length>0?r?t.wordGood?(a=i.toString(),i<t.warmBoundary?s.push(".cold"):i<t.hotBoundary?s.push(".warm"):s.push(".hot"),i>=t.bestPossibleScore&&s.push(".celebrate")):(s.push(".word-bad"),a=i.toString()):(s.push(".illegal"),a="?"):(s.push(".disabled"),a="0");const o="mobile"===n?".mobile-score-legend":".gata-dagsins-legend";return Fd(`div${s.join("")}`,Fd(`span${o}`,a))}},Jg={view:e=>{const{view:t}=e.attrs,{riddle:n}=t.model;if(!n)return Fd(".gatadagsins-board-rack-wrapper","");const i=n.wordGood&&(n.currentScore||0)>=n.bestPossibleScore;return Fd(".gatadagsins-board-rack-wrapper",[Fd(".gatadagsins-board-area"+(i?".celebrate":""),[n?Fd(Kg,{view:t,game:n,review:!1}):""]),Fd(".gatadagsins-rack-area",[Fd(".rack-left",Fd(Mg,{view:t,game:n})),Fd(".rack",Fd(Bg,{view:t,game:n,review:!1})),Fd(Yg,{riddle:n})])])}},Zg={view:e=>{const t=e.attrs.onClose;return[Fd(".modal-backdrop-netskrafl",{onclick:e=>{e.preventDefault()},onwheel:e=>{e.preventDefault(),e.stopPropagation()},ontouchmove:e=>{e.preventDefault(),e.stopPropagation()}}),Fd(".modal-dialog.gatadagsins-help",Fd(".modal-content",[Fd("button.close",{onclick:t,"aria-label":"Loka"},Rp("remove")),Fd(".modal-header",Fd("h2","Um Gátu dagsins")),Fd(".modal-body",[Fd("p","Gáta dagsins er dagleg krossgátuþraut, svipuð skrafli, þar sem þú reynir að finna stigahæsta orðið sem hægt er að mynda með gefnum stöfum."),Fd("h3","Hvernig á að spila"),Fd("ul",[Fd("li","Þú færð borð með allmörgum stöfum sem þegar hafa verið lagðir."),Fd("li","Neðst á skjánum eru stafaflísar sem þú getur notað til að mynda orð."),Fd("li","Dragðu flísar á borðið til að mynda orð, annaðhvort lárétt eða lóðrétt."),Fd("li","Orðin verða að tengjast við stafi sem fyrir eru á borðinu."),Fd("li","Þú sérð jafnóðum hvort lögnin á borðinu er gild og hversu mörg stig hún gefur."),Fd("li","Þú getur prófað eins mörg orð og þú vilt - besta skorið þitt er vistað.")]),Fd("h3","Stigagjöf"),Fd("p","Þú færð stig fyrir hvern staf í orðinu, auk bónusstiga fyrir lengri orð:"),Fd("ul",[Fd("li","Hver stafur gefur 1-10 stig eftir gildi hans"),Fd("li","Orð sem nota allar 7 stafaflísarnar gefa 50 stiga bónus"),Fd("li",["Sumir reitir á borðinu ",Fd("span.help-bonus-square.double-letter"),"tvöfalda eða ",Fd("span.help-bonus-square.triple-letter"),"þrefalda stafgildið"]),Fd("li",["Sumir reitir ",Fd("span.help-bonus-square.double-word"),"tvöfalda eða ",Fd("span.help-bonus-square.triple-word"),"þrefalda heildarorðgildið"])]),Fd("h3","Hitamælir"),Fd("p","Hitamælirinn hægra megin við borðið (sést ekki á farsímum) sýnir:"),Fd("ul",[Fd("li",Fd("strong","Besta mögulega lögn:")," Hæstu stig sem hægt er að ná á þessu borði."),Fd("li",Fd("strong","Besta skor dagsins:")," Hæstu stig sem einhver leikmaður hefur náð í dag."),Fd("li",Fd("strong","Þín bestu orð:")," Orðin sem þú hefur lagt og stigin fyrir þau."),Fd("li","Þú getur smellt á orð á hitamælinum til að fá þá lögn aftur á borðið.")]),Fd("h3","Ábendingar"),Fd("ul",[Fd("li","Reyndu að nota dýra stafi (eins og X, Ý, Þ) á tvöföldunar- eða þreföldunarreitum."),Fd("li","Lengri orð gefa mun fleiri stig vegna bónussins."),Fd("li","Þú getur dregið allar flísar til baka með bláa endurkalls-hnappnum."),Fd("li","Ný gáta birtist á hverjum nýjum degi - klukkan 00:00!")]),Fd("h3","Um leikinn"),Fd("p",["Gáta dagsins er systkini ",Fd("a",{href:"https://netskrafl.is",target:"_blank"},"Netskrafls"),", hins sívinsæla íslenska krossgátuleiks á netinu. ","Leikurinn er þróaður af Miðeind ehf."])]),Fd(".modal-footer",Fd("button.btn.btn-primary",{onclick:t},"Loka"))]))]}},Xg={view:e=>{const{view:t}=e.attrs,{model:n}=t.actions,{solverCount:i}=n;return i<=0?null:Fd(".solver-count-pill",{title:kp("Leikmenn sem hafa leyst gátuna")},i)}},Qg={view:e=>{const{view:t,date:n,locale:i}=e.attrs,{actions:r}=t,s=(e,t)=>{const n=new Date(`${e}T00:00:00Z`);return n.setUTCDate(n.getUTCDate()+t),n.toISOString().split("T")[0]},a=(new Date).toISOString().split("T")[0],o=s(n,-1),l=s(n,1),c=r.isRiddleLoading,u=!c&&o>=lp,h=!c&&l<=a,d=e=>{const n=new URL(window.location.href);e===a?n.searchParams.delete("date"):n.searchParams.set("date",e),window.history.pushState({},"",n.toString()),t.resetScale(),r.loadRiddle(e,i)},p=(e,t)=>{if(e)return e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),t())}},g=kp("Fyrri dagur"),f=kp("Næsti dagur"),m=n>="2025-12-05";return Fd(".date-navigator",[Fd(".nav-arrow.prev"+(u?"":".disabled"),{role:"button",tabindex:u?0:-1,"aria-disabled":!u,"aria-label":g,onclick:u?()=>d(o):void 0,onkeydown:p(u,()=>d(o)),title:u?g:""},Rp("chevron-left")),Fd(".nav-date",Up(n)),m?Fd(Xg,{view:t}):null,Fd(".nav-arrow.next"+(h?"":".disabled"),{role:"button",tabindex:h?0:-1,"aria-disabled":!h,"aria-label":f,onclick:h?()=>d(l):void 0,onkeydown:p(h,()=>d(l)),title:h?f:""},Rp("chevron-right"))])}},ef={view:e=>{const{animate:t=!1,size:n=80}=e.attrs,i=n/2,r=n/3;return Fd("div.sun-corona"+(t?".rotating":""),[Fd.trust(`\n <svg width="${n}" height="${n}" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">\n <g transform="translate(50,50)">\n \x3c!-- Ray at 0° (12 o'clock) --\x3e\n <polygon points="0,-${i} -3,-${r} 3,-${r}" fill="#f1c40f" opacity="0.8" transform="rotate(0)"/>\n \x3c!-- Ray at 30° --\x3e\n <polygon points="0,-${i} -3,-${r} 3,-${r}" fill="#f39c12" opacity="0.7" transform="rotate(30)"/>\n \x3c!-- Ray at 60° --\x3e\n <polygon points="0,-${i} -3,-${r} 3,-${r}" fill="#f1c40f" opacity="0.8" transform="rotate(60)"/>\n \x3c!-- Ray at 90° (3 o'clock) --\x3e\n <polygon points="0,-${i} -3,-${r} 3,-${r}" fill="#f39c12" opacity="0.7" transform="rotate(90)"/>\n \x3c!-- Ray at 120° --\x3e\n <polygon points="0,-${i} -3,-${r} 3,-${r}" fill="#f1c40f" opacity="0.8" transform="rotate(120)"/>\n \x3c!-- Ray at 150° --\x3e\n <polygon points="0,-${i} -3,-${r} 3,-${r}" fill="#f39c12" opacity="0.7" transform="rotate(150)"/>\n \x3c!-- Ray at 180° (6 o'clock) --\x3e\n <polygon points="0,-${i} -3,-${r} 3,-${r}" fill="#f1c40f" opacity="0.8" transform="rotate(180)"/>\n \x3c!-- Ray at 210° --\x3e\n <polygon points="0,-${i} -3,-${r} 3,-${r}" fill="#f39c12" opacity="0.7" transform="rotate(210)"/>\n \x3c!-- Ray at 240° --\x3e\n <polygon points="0,-${i} -3,-${r} 3,-${r}" fill="#f1c40f" opacity="0.8" transform="rotate(240)"/>\n \x3c!-- Ray at 270° (9 o'clock) --\x3e\n <polygon points="0,-${i} -3,-${r} 3,-${r}" fill="#f39c12" opacity="0.7" transform="rotate(270)"/>\n \x3c!-- Ray at 300° --\x3e\n <polygon points="0,-${i} -3,-${r} 3,-${r}" fill="#f1c40f" opacity="0.8" transform="rotate(300)"/>\n \x3c!-- Ray at 330° --\x3e\n <polygon points="0,-${i} -3,-${r} 3,-${r}" fill="#f39c12" opacity="0.7" transform="rotate(330)"/>\n </g>\n </svg>\n `)])}},tf=()=>{const e=e=>t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),e())};return{view:t=>{const{view:n,bestMove:i,onMoveClick:r,onStatsClick:s}=t.attrs,{riddle:a}=n.model;if(!a)return null;const{bestPossibleScore:o,globalBestScore:l,personalBestScore:c}=a,u=i&&""!==i.word,h=(new Date).toISOString().split("T")[0],d=a.date<h,p=d?a.solution||l:null;let g=0,f=!1;l&&l.score>0?(g=l.score,f=!d&&c>=l.score):(g=c,f=!d&&c>0);const m=!(!p&&!u),v=()=>{p?(n.zoomOut(),r(p.word,p.coord)):u&&r(i.word,i.coord)},y=kp("Tölfræði og stigatafla");return Fd(".mobile-status-container",[Fd(".mobile-status-item.left",Fd(Yg,{riddle:a,mode:"mobile"})),Fd(".mobile-status-card",{role:"button",tabindex:0,"aria-label":y,onclick:s,onkeydown:e(s),title:y},[Fd(".mobile-status-card-item.player-best",[Fd(".mobile-status-label",kp("Þín besta")),Fd(".mobile-status-score",c.toString())]),Fd(".mobile-status-card-item.leader"+(f?".is-player":""),[Fd(".mobile-status-label",kp(f?"Þú leiðir!":"Best til þessa")),Fd(".mobile-status-score",g.toString())]),Fd(".mobile-status-card-icon",Rp("chevron-down"))]),Fd(".mobile-status-item.right.best-possible"+(u?".celebrate":""),{role:m?"button":void 0,tabindex:m?0:void 0,"aria-label":m?kp("Sýna besta leik"):void 0,onclick:v,onkeydown:m?e(v):void 0},[Fd(".mobile-best-score-wrapper",[u?Fd(ef,{animate:!0,size:100}):null,Fd(".mobile-status-score",o.toString())])])])}}};const nf={view:e=>{const{leaderboard:t,currentUserId:n,loading:i=!1}=e.attrs;return i?Fd(".leaderboard-view.loading",Fd(".loading-message",kp("Hleð stigatöflu..."))):t&&0!==t.length?Fd(".leaderboard-view",[Fd(".leaderboard-list",{ontouchmove:e=>{e.stopPropagation()}},t.map((e,t)=>{const i=t+1,r=e.userId===n,s=function(e){switch(e){case 1:return"🥇";case 2:return"🥈";case 3:return"🥉";default:return null}}(i);return Fd(".leaderboard-entry"+(r?".current-user":""),{key:e.userId},[Fd(".entry-rank",[s?Fd("span.medal",s):Fd("span.rank-number",i.toString())]),Fd(".entry-name",r?[Fd("span.entry-star",Rp("star")),kp("Þú")]:e.displayName),Fd(".entry-score",e.score.toString())])}))]):Fd(".leaderboard-view.empty",Fd(".empty-message",kp("Engin stig skráð enn")))}},rf=()=>({view:({attrs:e})=>{const{state:t,onToggle:n,id:i,tabindex:r=0,title:s,disabled:a=!1,size:o="medium"}=e;return Fd(`.sliding-toggle${"medium"!==o?`.toggle-${o}`:""}${t?".on":""}${a?".disabled":""}`,{id:i,tabindex:a?-1:r,title:s,role:"switch","aria-checked":t?"true":"false","aria-disabled":a?"true":void 0,onclick:()=>{a||n(!t)},onkeydown:e=>{a||" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),n(!t))}},Fd(".sliding-toggle-thumb"))}}),sf=e=>{let t=ag(),n=lg();const{view:i}=e.attrs;function r(e){t=e,og(e),e||i.zoomOut()}function s(e){n=e,cg(e)}return{view:e=>{const{stats:i,loading:a=!1}=e.attrs;if(a)return Fd(".stats-view.loading",Fd(".loading-message",kp("Sæki tölfræði...")));if(!i)return Fd(".stats-view.empty",Fd(".empty-message",kp("Engin tölfræði til að sýna")));const o=[{iconGlyph:"fire",label:kp("Núverandi striklota"),value:i.currentStreak,highlight:i.currentStreak>0},{iconGlyph:"star",label:kp("Lengsta striklota"),value:i.longestStreak},{iconGlyph:"tower",label:kp("Hæsta skori náð"),value:i.totalTopScores},{iconGlyph:"certificate",label:kp("Striklota hæsta skors"),value:i.topScoreStreak,highlight:i.topScoreStreak>0},{iconGlyph:"calendar",label:kp("Heildarfjöldi daga"),value:i.totalDaysPlayed}];return Fd(".stats-view",[Fd(".stats-grid",o.map((e,t)=>Fd(".stat-item"+(e.highlight?".highlight":""),{key:t},[Fd(".stat-icon",Rp(e.iconGlyph)),Fd(".stat-info",[Fd(".stat-label",e.label),Fd(".stat-value",e.value.toString())])]))),Fd(".stats-settings",[Fd(".settings-row",[Fd("span.settings-label",kp("Þysja sjálfkrafa")),Fd(rf,{state:t,onToggle:r,id:"autozoom-gata",title:kp("Þysja sjálfkrafa"),size:"small"})]),Fd(".settings-explain",kp("autozoom_explain"))]),Fd(".stats-settings",[Fd(".settings-row",[Fd("span.settings-label",kp("Eldri litasamsetning")),Fd(rf,{state:n,onToggle:s,id:"legacycolors-gata",title:kp("Eldri litasamsetning"),size:"small"})]),Fd(".settings-explain",kp("legacy_colors_explain"))])])}}},af={view:e=>{const{tabs:t,activeTab:n,onTabChange:i}=e.attrs;return Fd(".tab-bar[role=tablist]",t.map(e=>{const t=n===e.id;return Fd(".tab-item"+(t?".active":""),{key:e.id,role:"tab",tabindex:t?0:-1,"aria-selected":t,"aria-label":e.label,onclick:()=>i(e.id),onkeydown:(r=e.id,e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),i(r))})},[Fd("span.tab-icon-wrapper",[e.iconGlyph?Fd("span.tab-icon",Rp(e.iconGlyph)):e.icon?Fd("span.tab-icon",e.icon):null,e.badgeGlyph?Fd("span.tab-badge",Rp(e.badgeGlyph)):null]),Fd("span.tab-label",e.label)]);var r}))}};function of(e){return e.replace(/\?/g,"")}const lf={view:e=>{const{score:t,bestMove:n,onMoveClick:i,solution:r}=e.attrs;let s;const a=n&&""!==n.word;s=a?of(n.word):kp("Besta mögulega lögn");const o=r&&!a?kp("Smelltu til að sjá lausn"):"",l=!(!r&&!a),c=()=>{r?i(r.word,r.coord):a&&i(n.word,n.coord)},u=l?e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),c())}:void 0;return Fd(".thermometer-best-score"+(a?".celebrate":""),Fd(".thermometer-best-score-container",{role:l?"button":void 0,tabindex:l?0:void 0,"aria-label":l?kp("Sýna besta leik"):void 0,onclick:c,onkeydown:u,title:o},[a?Fd(ef,{animate:!0}):null,Fd(".thermometer-best-circle",t.toString()),Fd(".thermometer-best-label",s)]))}},cf={view:e=>{const{score:t,thisPlayer:n}=e.attrs;return Fd(".thermometer-current-score"+(n?".this-player":""),[Fd(".thermometer-current-circle",t.toString())])}},uf={view:e=>{const{zoneHeights:t,zoneAllocation:n,onMoveClick:i}=e.attrs,r=t.cold,s=r+t.warm,a=[];function o(e,t,n,r){const s=e.length,o=r/(s+1);e.forEach((e,r)=>{const l=n+o*(s-r),c=!(!e.word||!e.coord),u=()=>{c&&i(e.word,e.coord)},h=c?e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),u())}:void 0;a.push(Fd(`.thermometer-move-overlay .${t}`,{key:`${t}-${r}`,style:`--move-position: ${l.toFixed(2)}%`,role:c?"button":void 0,tabindex:c?0:void 0,"aria-label":c?`${kp("Sýna leik")}: ${of(e.word)}`:void 0,onclick:u,onkeydown:h},function(e){return e.isGlobalBestScore?""===e.word?[Fd(cf,{thisPlayer:!1,score:e.score})]:[Fd(cf,{thisPlayer:!0,score:e.score}),Fd(".thermometer-move-word",of(e.word)),Fd(".thermometer-move-coord",`(${e.coord})`)]:[Fd(".thermometer-move-score",e.score.toString()),Fd(".thermometer-move-word",of(e.word)),Fd(".thermometer-move-coord",`(${e.coord})`)]}(e)))})}return o(n.cold,"cold",0,t.cold),o(n.warm,"warm",r,t.warm),o(n.hot,"hot",s,t.hot),Fd(".thermometer-moves-overlay-wrapper",a)}},hf={view:e=>{const{riddle:t,selectedMoves:n,bestMove:i,onMoveClick:r}=e.attrs,{warmBoundary:s,hotBoundary:a,bestPossibleScore:o,globalBestScore:l}=t,c=function(e,t,n){const i={hot:[],warm:[],cold:[]};return n.forEach(n=>{n.score>=t?i.hot.push(n):n.score>=e?i.warm.push(n):i.cold.push(n)}),i}(s,a,n),u=function(e){const t=e.hot.length,n=e.warm.length,i=e.cold.length,r=Math.max(15,8*t),s=Math.max(15,8*n),a=Math.max(15,8*i),o=r+s+a;if(o>100){const e=100/o;return{hot:r*e,warm:s*e,cold:a*e}}const l=100-o,c=t+n+i,u=c>0?l/c:0,h=0===c?l/3:0;return{hot:r+t*u+h,warm:s+n*u+h,cold:a+i*u+h}}(c),h=(new Date).toISOString().split("T")[0],d=t.date<h?t.solution||l:null;return Fd(".thermometer-container",[Fd(".thermometer-body",[Fd(".thermometer-zones",[Fd(".thermometer-zone.hot",{style:`--zone-size: ${u.hot+u.warm+u.cold}%`}),Fd(".thermometer-zone.warm",{style:`--zone-size: ${u.warm+u.cold}%`}),Fd(".thermometer-zone.cold",{style:`--zone-size: ${u.cold}%`})]),Fd(uf,{moves:n,maxScore:o,zoneHeights:u,zoneAllocation:c,onMoveClick:r})]),Fd(lf,{score:o,bestMove:i,onMoveClick:r,solution:d})])}},df=()=>{let e="performance";return{view:t=>{const{view:n,selectedMoves:i,bestMove:r,onMoveClick:s}=t.attrs,{riddle:a,state:o,leaderboard:l}=n.model;if(!a)return Fd(".gatadagsins-right-side-tabs","");const c=o?.netskraflUserId||"",u=l?.some(e=>e.userId===c),h=[{id:"performance",label:kp("Frammistaða"),iconGlyph:"dashboard"},{id:"stats",label:kp("Tölfræði"),iconGlyph:"stats"},{id:"leaderboard",label:kp("Stigatafla"),iconGlyph:"tower",badgeGlyph:u?"star":void 0}];return Fd(".gatadagsins-right-side-tabs",[Fd(af,{tabs:h,activeTab:e,onTabChange:t=>{e=t}}),Fd(".tab-content",["performance"===e?Fd(hf,{riddle:a,selectedMoves:i,bestMove:r,onMoveClick:s}):null,"stats"===e?Fd(sf,{view:n,stats:n.model.userStats||null,loading:!1}):null,"leaderboard"===e?Fd(nf,{leaderboard:n.model.leaderboard||[],currentUserId:o?.netskraflUserId||"",loading:!1}):null])])}}},pf={view:e=>{const{view:t,selectedMoves:n,bestMove:i,onStatsClick:r}=e.attrs,{riddle:s}=t.model,a=(e,t)=>{s&&e&&t&&s.recreateWordOnBoard(e,t)};return Fd(".gatadagsins-right-side-wrapper",s?[Fd(".gatadagsins-mobile-wrapper",[Fd(".mobile-date-nav-container",Fd(Qg,{view:t,date:s.date,locale:s.locale})),Fd(".gatadagsins-mobile-status",Fd(tf,{view:t,selectedMoves:n,bestMove:i,onMoveClick:a,onStatsClick:r}))]),Fd(".gatadagsins-thermometer-column",[Fd(".desktop-date-nav-container",Fd(Qg,{view:t,date:s.date,locale:s.locale})),Fd(df,{view:t,selectedMoves:n,bestMove:i,onMoveClick:a})])]:null)}};const gf=()=>{let e=!1,t=null;return{onremove:()=>{t&&(clearTimeout(t),t=null)},view:n=>{const{score:i,position:r,word:s,onClose:a}=n.attrs,o=s.replace(/\?/g,"").toUpperCase(),l=kp("share_text_template",{position:String(r)});return[Fd(".modal-backdrop-netskrafl",{onclick:e=>(e.preventDefault(),a(),!1),onwheel:e=>(e.preventDefault(),e.stopPropagation(),!1),ontouchmove:e=>(e.preventDefault(),e.stopPropagation(),!1)}),Fd(".modal-dialog.share-popup",{role:"dialog","aria-modal":"true","aria-labelledby":"share-popup-title",tabindex:0,oncreate:e=>{const t=e.dom.querySelector("button");t&&t.focus()},onkeydown:e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),a())},onwheel:e=>(e.stopPropagation(),!1),ontouchmove:e=>(e.stopPropagation(),!1)},[Fd(".modal-content",[Fd("button.close",{onclick:a,"aria-label":kp("Loka")},Rp("remove")),Fd(".share-popup-celebration",[Fd(ef,{animate:!0,size:84}),Fd(".share-popup-score-circle",[Fd(".share-popup-score",String(i))])]),Fd(".share-popup-title",{id:"share-popup-title"},kp("share_popup_title")),Fd(".share-popup-subtitle",kp("share_popup_subtitle")),Fd(".share-popup-word",o),Fd(".share-popup-text-preview",l),Fd(".share-popup-buttons",[Fd("button.share-popup-btn",{class:e?"success":"primary",onclick:async()=>{await async function(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0;const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.focus(),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch(e){return console.error("Failed to copy to clipboard:",e),!1}}(l)&&(e=!0,Fd.redraw(),t=setTimeout(()=>{e=!1,t=null,Fd.redraw()},2e3))}},[Rp(e?"ok":"copy")," ",kp(e?"share_copied_confirmation":"share_button_copy")]),"undefined"!=typeof navigator&&"function"==typeof navigator.share?Fd("button.share-popup-btn.secondary",{onclick:async()=>{await async function(e){try{return await navigator.share({text:e}),!0}catch(e){return e instanceof Error&&"AbortError"!==e.name&&console.error("Share failed:",e),!1}}(l)}},[Rp("share")," ",kp("share_button_share")]):null])])])]}}},ff=()=>{let e="stats";return{view:t=>{const{view:n,onClose:i}=t.attrs,{riddle:r,state:s,leaderboard:a}=n.model;if(!r)return null;const o=s?.netskraflUserId||"",l=a?.some(e=>e.userId===o),c=[{id:"stats",label:kp("Tölfræði"),iconGlyph:"stats"},{id:"leaderboard",label:kp("Stigatafla"),iconGlyph:"tower",badgeGlyph:l?"star":void 0}];return[Fd(".modal-backdrop-netskrafl",{onclick:e=>(e.preventDefault(),!1),onwheel:e=>(e.preventDefault(),e.stopPropagation(),!1),ontouchmove:e=>(e.preventDefault(),e.stopPropagation(),!1)}),Fd(".modal-dialog.stats-modal",{onwheel:e=>(e.stopPropagation(),!1),ontouchmove:e=>(e.stopPropagation(),!1)},[Fd(".modal-content",[Fd("button.close",{onclick:i,"aria-label":"Loka"},Rp("remove")),Fd(af,{tabs:c,activeTab:e,onTabChange:t=>{e=t}}),Fd(".modal-body",["stats"===e?Fd(sf,{view:n,stats:n.model.userStats||null,loading:!1}):null,"leaderboard"===e?Fd(nf,{leaderboard:n.model.leaderboard||[],currentUserId:s?.netskraflUserId||"",loading:!1}):null])])])]}}},mf={oninit:async e=>{const{attrs:t,state:n}=e;n.showHelp=!1,n.showStatsModal=!1;const{model:i,actions:r}=t.view,{riddle:s}=i;if(!s){const{date:e,locale:n}=t;await r.fetchRiddle(e,n)}},view:e=>{const{attrs:t,state:n}=e,{view:i}=t,{model:r}=i,{riddle:s}=r,{selectedMoves:a,bestMove:o}=s?vf(s):{selectedMoves:[],bestMove:void 0},l=()=>{n.showHelp=!n.showHelp,Fd.redraw()},c=()=>{n.showStatsModal=!n.showStatsModal,Fd.redraw()};return Fd("div.drop-target",{id:"gatadagsins-background"},[Fd(".gatadagsins-container",[s?Fd(".gatadagsins-main",[Fd(Jg,{view:i}),Fd(pf,{view:i,selectedMoves:a,bestMove:o,onStatsClick:c}),s.askingForBlank?Fd(Rg,{game:s}):""]):"",r.state?.beginner?Fd(Hp,{view:i,showClose:!1}):"",Fd(".info",{title:kp("Upplýsingar og hjálp")},Fd("a.iconlink",{href:"#",onclick:e=>{e.preventDefault(),l()}},Rp("info-sign"))),n.showHelp?Fd(Zg,{onClose:l}):""]),n.showStatsModal?Fd(ff,{view:i,onClose:c}):"",s?.justAchievedBestScore&&o?Fd(gf,{score:o.score,position:r.solverCount,word:o.word,onClose:()=>{s&&(s.justAchievedBestScore=!1),Fd.redraw()}}):""])}},vf=e=>{const t=e.model.state?.netskraflUserId||"",{bestPossibleScore:n,globalBestScore:i,playerMoves:r}=e;let s;const a=r.sort((e,t)=>t.score-e.score).slice(0,10).map(e=>({score:e.score,word:e.word,coord:e.coord}));if(i&&i.score>0){const{score:e,word:n,coord:r}=i;(a[0]?.score??0)>=e?a[0].isGlobalBestScore=!0:i.player===t?a.unshift({score:e,isGlobalBestScore:!0,word:n,coord:r}):a.unshift({score:e,isGlobalBestScore:!0,word:"",coord:""})}return a.length>0&&a[0].score===n&&(s=a.shift()),{selectedMoves:a,bestMove:s}};function yf(e,t,n){const i=n.target;return!("INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName&&"SELECT"!==i.tagName&&!i.isContentEditable)||(!!t.isMobile()||(!!e.showingDialog||null!==e.askingForBlank))}function wf(e,t,n){if(yf(e,t,n))return;const{key:i}=n;if("ArrowRight"===i)return n.preventDefault(),e.setKeyboardDirection("H"),void Fd.redraw();if("ArrowDown"===i)return n.preventDefault(),e.setKeyboardDirection("V"),void Fd.redraw();if("Backspace"===i)return n.preventDefault(),void(e.undoLastKeyboardTile()&&Fd.redraw());if("Escape"===i)return n.preventDefault(),e.resetRack(),void Fd.redraw();if(n.isComposing)return;const r=i.normalize("NFC");if(1===r.length){const t=r.toLowerCase();if(e.alphabet.includes(t))return n.preventDefault(),void(e.placeKeyboardTile(t)&&Fd.redraw())}}function bf(e,t,n){if(yf(e,t,n))return;const{data:i}=n,r=i?.normalize("NFC");if(r&&1===r.length){const t=r.toLowerCase();e.alphabet.includes(t)&&(n.preventDefault(),e.placeKeyboardTile(t)&&Fd.redraw())}}let _f=null;class kf{constructor(e){this._prefix=`game.${e}`}getLocalTile(e){return window.localStorage[`${this._prefix}.tile.${e}.t`]}getLocalTileSq(e){return window.localStorage[`${this._prefix}.tile.${e}.sq`]}setLocalTile(e,t){window.localStorage[`${this._prefix}.tile.${e}.t`]=t}setLocalTileSq(e,t){window.localStorage[`${this._prefix}.tile.${e}.sq`]=t}clearTiles(){try{const e=window.localStorage;for(let t=1;t<=7;t++)e.removeItem(`${this._prefix}.tile.${t}.sq`),e.removeItem(`${this._prefix}.tile.${t}.t`)}catch(e){}}saveTiles(e){let t;for(t=0;t<e.length;t++){const n=e[t].sq,i=e[t].tile;this.setLocalTileSq(t+1,n),this.setLocalTile(t+1,i)}for(;t<7;t++)this.setLocalTileSq(t+1,""),this.setLocalTile(t+1,"")}loadTiles(){let e,t;const n=[];for(let i=0;i<7;i++)e=this.getLocalTileSq(i+1),t=this.getLocalTile(i+1),e&&t&&n.push({sq:e,tile:t});return n}}class Cf{getLocalTile(e){return""}getLocalTileSq(e){return""}setLocalTile(e,t){}setLocalTileSq(e,t){}clearTiles(){}saveTiles(e){}loadTiles(){return[]}}const Sf=e=>function(){if(null===_f)try{_f="localStorage"in window&&null!==window.localStorage&&void 0!==window.localStorage}catch(e){_f=!1}return _f}()?new kf(e):new Cf;const Tf=new class{constructor(){this.wordCheckCache={}}ingestTwoLetterWords(e,t){let n=this.wordCheckCache[e];void 0===n&&(n=this.wordCheckCache[e]={});for(const[,e]of t)for(const t of e)n[t]=!0}async checkWords(e,t,n){let i=this.wordCheckCache[t];if(i){let e=!0;for(const t of n){if(void 0===i[t]){if(2===t.length)return!1;e=!1;break}if(!1===i[t])return!1}if(e)return!0}try{const r=await rp(e,{url:"/wordcheck",body:{locale:t,word:n[0],words:n}});if(r?.word===n[0]&&r?.valid){i||(i=this.wordCheckCache[t]={});for(const[e,t]of r.valid)i[e]=t}return!!r.ok}catch(e){}return!1}},If={standard:"H8",explo:"D4"},Ef={standard:[7,7],explo:[3,3]},Pf={standard:{WORDSCORE:["3 3 3"," 2 2 "," 2 2 "," 2 2 "," 2 2 "," "," ","3 2 3"," "," "," 2 2 "," 2 2 "," 2 2 "," 2 2 ","3 3 3"],LETTERSCORE:[" 2 2 "," 3 3 "," 2 2 ","2 2 2"," "," 3 3 3 3 "," 2 2 2 2 "," 2 2 "," 2 2 2 2 "," 3 3 3 3 "," ","2 2 2"," 2 2 "," 3 3 "," 2 2 "]},explo:{WORDSCORE:["3 3 3"," 2 "," 2 "," 2 "," 2 "," 2 2 "," 2 2 ","3 2 3"," 2 2 "," 2 2 "," 2 "," 2 "," 2 "," 2 ","3 3 3"],LETTERSCORE:[" 2 2 "," 3 2 3 "," 2 3 2 "," 2 3 2","2 3 "," 2 2 "," 3 2 "," 2 2 "," 2 3 "," 2 2 "," 3 2","2 3 2 "," 2 3 2 "," 3 2 3 "," 2 2 "]}};class xf{constructor(e,t,n="standard"){this.locale="is_IS",this.alphabet="",this.tile_scores={},this.board_type="standard",this.two_letter_words=[[],[]],this.startSquare="H8",this.startCoord=[7,7],this.manual=!1,this.tiles={},this.over=!1,this.currentScore=void 0,this.currentWord="",this.currentWordWithBlanks="",this.currentCoord="",this.wordGood=!1,this.wordBad=!1,this.currentError=null,this.currentMessage=null,this.localturn=!0,this.moveInProgress=!1,this.showingDialog=null,this.selectedSq=null,this.sel="movelist",this.askingForBlank=null,this.keyboardDirection="H",this.keyboardPlacedTiles=[],this.localStorage=null,this.uuid=e,this.localStorage=Sf(e),this.board_type=n,this.startSquare=If[n],this.startCoord=Ef[n],this.state=t}init(){}tilescore(e){return this.tile_scores[e]}twoLetterWords(){return this.two_letter_words}squareClass(e){if(!e||"R"===e[0])return;const{row:t,col:n}=zp(e);return this.squareType(t,n)||void 0}squareType(e,t){const n=this.wordScore(e,t);if(2===n)return"dw";if(3===n)return"tw";const i=this.letterScore(e,t);return 2===i?"dl":3===i?"tl":""}wordScore(e,t){const n=Pf[this.board_type].WORDSCORE;return parseInt(n[e].charAt(t),10)||1}letterScore(e,t){const n=Pf[this.board_type].LETTERSCORE;return parseInt(n[e].charAt(t),10)||1}attemptMove(e,t){if(t===e)return;if(t in this.tiles&&"R"!==t[0])throw`Square ${t} occupied`;if(!(e in this.tiles))throw`No tile at ${e}`;const n=this.tiles[e];"R"===t[0]||"?"!==n.tile||" "!==n.letter?this.moveTile(e,t):this.askingForBlank={from:e,to:t}}_moveTile(e,t){if(e===t)return;const n=this.tiles[e];if(void 0===n)throw"Moving from an empty square";if(delete this.tiles[e],t in this.tiles){if("R"!==t.charAt(0))throw"Dropping to an occupied square";const e=parseInt(t.slice(1),10);let n=e+1;for(;`R${n}`in this.tiles;)n++;if(n<=7)for(let t=n;t>e;t--)this.tiles[`R${t}`]=this.tiles["R"+(t-1)];else{for(n=e-1;`R${n}`in this.tiles;)n--;if(n<1)throw"No place in rack to drop tile";for(let t=n;t<e;t++)this.tiles[`R${t}`]=this.tiles[`R${t+1}`]}}"R"===t[0]&&"?"===n.tile&&(n.letter=" "),this.tiles[t]=n}moveTile(e,t){if(this._moveTile(e,t),this.currentError=this.currentMessage=null,"R"===e[0]&&"R"!==t[0]){1===this.tilesPlaced().length&&this.setDefaultDirection(t)}this.updateScore(),this.saveTiles()}cancelBlankDialog(){this.askingForBlank=null}placeBlank(e){if(null===this.askingForBlank)return;const{from:t,to:n}=this.askingForBlank;this.tiles[t].letter=e,this.moveTile(t,n),this.askingForBlank=null}draggableTiles(){return Object.keys(this.tiles).filter(e=>this.tiles[e].draggable)}tilesPlaced(){return this.draggableTiles().filter(e=>"R"!==e[0])}resetRack(){this.selectedSq=null,this._resetRack(),this.saveTiles()}_moveBoardTileToRack(e,t=1){if(!(e in this.tiles))return t;let n=t;for(;`R${n}`in this.tiles;)n++;const i=`R${n}`;return this.tiles[i]=this.tiles[e],delete this.tiles[e],"?"===this.tiles[i].tile&&(this.tiles[i].letter=" "),n+1}_resetRack(){const e=this.tilesPlaced();if(e.length>0){let t=1;for(const n of e)t=this._moveBoardTileToRack(n,t);this.updateScore()}this.currentError=null,this.resetKeyboardState()}rescrambleRack(){if(this.selectedSq=null,null!==this.showingDialog)return;this._resetRack();const e=[];for(let t=1;t<=7;t++){const n=`R${t}`;n in this.tiles?e.push(this.tiles[n]):e.push(null)}let t=e.length;for(;0!==t;){const n=Math.floor(Math.random()*t);t-=1;const i=e[t];e[t]=e[n],e[n]=i}let n=0;for(let t=1;t<=7;t++){const i=e[t-1];null!==i?this.tiles["R"+(t-n)]=i:(delete this.tiles["R"+(7-n)],n++)}this.saveTiles()}resetError(){this.currentError=this.currentMessage=null}placeTiles(e,t,n){this.tiles={}}populateRackTiles(){}async updateScore(){this.wordGood=!1,this.wordBad=!1;const e=this.calcScore();if(void 0!==e&&e.word){if(this.currentScore=e.score,this.currentWord=e.word,this.currentWordWithBlanks=e.wordWithBlanks,this.currentCoord=e.coord,!this.manual){const t=await Tf.checkWords(this.state,this.locale,e.words);this.currentWord===e.word&&(this.wordGood=t,this.wordBad=!t)}}else this.currentScore=void 0,this.currentWord="",this.currentWordWithBlanks="",this.currentCoord=""}calcScore(){let e=0,t=0,n=1,i=ap,r=ap,s=0,a=0,o=0,l=0,c="",u="";const h=[],d=Object.values(this.tiles).filter(e=>!e.draggable).length;if(this.tilesPlaced().forEach(t=>{const l=sp.indexOf(t.charAt(0)),c=parseInt(t.slice(1),10)-1,u=this.tiles[t];e+=u.score*this.letterScore(l,c),o++,n*=this.wordScore(l,c),l<i&&(i=l),c<r&&(r=c),l>s&&(s=l),c>a&&(a=c)}),!o)return;if(i!==s&&r!==a)return;let p=r,g=i,f=0,m=0;for(i!==s?m=1:r!==a||null===this.tileAt(i-1,r)&&null===this.tileAt(i+1,r)?f=1:m=1;null!==this.tileAt(g-m,p-f);)p-=f,g-=m;const v=Fp(g,p,1===m)||"";let y;for(;null!==(y=this.tileAt(g,p));){if(y.draggable){const e=this.calcCrossScore(g,p,1-m,1-f);e.score>=0&&(t+=e.score,l++,h.push(e.word))}else e+=y.score,l++;c+=y.letter,y.draggable&&"?"===y.tile?u+=`?${y.letter}`:u+=y.letter,p+=f,g+=m}if(0===d){const e=this.startCoord;if(null===this.tileAt(e[0],e[1]))return}else if(!l)return;return f&&p<=a||m&&g<=s?void 0:(h.push(c),{word:c,wordWithBlanks:u,words:h,score:e*n+t+(7===o?50:0),coord:v})}calcCrossScore(e,t,n,i){let r,s=0,a=!1,o=t,l=e,c="";for(;null!==this.tileAt(l-n,o-i);)o-=i,l-=n;for(;null!==(r=this.tileAt(l,o));){let u=r.score;o===t&&l===e?u*=this.letterScore(l,o):a=!0,c+=r.letter,s+=u,o+=i,l+=n}return a?{score:s*this.wordScore(e,t),word:c}:{score:-1,word:""}}tileAt(e,t){const n=Fp(e,t);return n&&this.tiles[n]||null}saveTiles(){const e=[],t=this.tilesPlaced();for(const n of t){const{tile:t,letter:i}=this.tiles[n];e.push({sq:n,tile:"?"===t?t+i:t})}for(let t=1;t<=7;t++){const n=`R${t}`;n in this.tiles&&e.push({sq:n,tile:this.tiles[n].tile})}this.localStorage?.saveTiles(e)}restoreTiles(e){if(!e.length)return;const t=[],n=[],i={};for(let n=0;n<e.length;n++)t.push(e[n].tile.charAt(0));for(let e=1;e<=7;e++)`R${e}`in this.tiles&&n.push(this.tiles[`R${e}`].tile.charAt(0));if(t.sort(),n.sort(),!function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(t,n))return;for(let e=1;e<=7;e++)`R${e}`in this.tiles&&(i[`R${e}`]=this.tiles[`R${e}`],delete this.tiles[`R${e}`]);for(let t=0;t<e.length;t++){const n=e[t].sq;if(!(n in this.tiles)){const r=e[t].tile;for(const e of Object.keys(i))if(i[e].tile===r.charAt(0)){"?"===r.charAt(0)&&("R"===n.charAt(0)?i[e].letter=" ":i[e].letter=r.charAt(1)),this.tiles[n]=i[e],delete i[e];break}}}let r=1;for(const e of Object.keys(i)){for(;`R${r}`in this.tiles;)r++;r<=7&&(this.tiles[`R${r}`]=i[e])}this.saveTiles(),this.updateScore()}cleanup(){}getLockedDirection(){const e=this.tilesPlaced();if(e.length<2)return null;const t=new Set,n=new Set;for(const i of e)t.add(i.charAt(0)),n.add(parseInt(i.slice(1),10));return 1===t.size&&n.size>1?"H":1===n.size&&t.size>1?"V":null}setKeyboardDirection(e){null===this.getLockedDirection()&&(this.keyboardDirection=e)}getEffectiveKeyboardDirection(){return this.getLockedDirection()??this.keyboardDirection}findNextEmptySquare(e,t,n){const i="H"===n?1:0,r="V"===n?1:0;let s=e,a=t;for(;s>=0&&s<ap&&a>=0&&a<ap;){const e=Fp(s,a);if(e&&!(e in this.tiles))return e;s+=r,a+=i}return null}canContinueInDirection(e,t){const n=zp(e),i="H"===t?1:0,r="V"===t?1:0;return null!==this.findNextEmptySquare(n.row+r,n.col+i,t)}setDefaultDirection(e){this.canContinueInDirection(e,"H")?this.keyboardDirection="H":this.keyboardDirection="V"}getNextKeyboardSquare(){const e=this.tilesPlaced();if(0===e.length)return null;let t=!0;for(let e=1;e<=7;e++)if(`R${e}`in this.tiles){t=!1;break}if(t)return null;const n=this.getLockedDirection()??this.keyboardDirection;let i=-1,r=-1;for(const t of e){const e=sp.indexOf(t.charAt(0)),s=parseInt(t.slice(1),10)-1;"H"===n?(s>r||s===r&&e>i)&&(r=s,i=e):(e>i||e===i&&s>r)&&(i=e,r=s)}const s="H"===n?1:0,a="V"===n?1:0;return this.findNextEmptySquare(i+a,r+s,n)}findRackTileForLetter(e){let t=null;for(let n=1;n<=7;n++){const i=`R${n}`;if(i in this.tiles){const n=this.tiles[i];if(n.tile===e)return i;"?"===n.tile&&null===t&&(t=i)}}return t}placeKeyboardTile(e){const t=this.getNextKeyboardSquare();if(!t)return!1;const n=this.findRackTileForLetter(e);if(!n)return!1;const i=this.tiles[n];return"?"===i.tile&&(i.letter=e),this.moveTile(n,t),this.keyboardPlacedTiles.push(t),!0}undoLastKeyboardTile(){if(0===this.keyboardPlacedTiles.length)return!1;const e=this.keyboardPlacedTiles.pop();if(!e||!(e in this.tiles))return!1;let t=null;for(let e=1;e<=7;e++){const n=`R${e}`;if(!(n in this.tiles)){t=n;break}}return!!t&&(this.moveTile(e,t),!0)}resetKeyboardState(){this.keyboardDirection="H",this.keyboardPlacedTiles=[]}}class Rf extends xf{constructor(e,t,n,i,r){if(super(e,i),this.userid=["",""],this.nickname=["",""],this.fullname=["",""],this.autoplayer=[!1,!1],this.maxOvertime=600,this.scores=[0,0],this.moves=[],this.newmoves=[],this.lastmove=void 0,this.rack=[],this.racks=[],this.num_moves=0,this.bag="",this.newbag=!0,this.localturn=!1,this.player=null,this.stats=null,this.manual=!1,this.fairplay=!1,this.zombie=!1,this.overdue=!1,this.messages=null,this.chatLoading=!1,this.chatSeen=!0,this.congratulate=!1,this.xchg=!1,this.chall=!1,this.last_chall=!1,this.succ_chall=!1,this.moveInProgress=!1,this.isFresh=!1,this.numTileMoves=0,this.interval=null,this.time_info=null,this.penalty0=0,this.penalty1=0,this.timeBase=null,this.runningOut0=!1,this.runningOut1=!1,this.blinking0=!1,this.blinking1=!1,this.clockText0="",this.clockText1="",this.moveListener=n,void 0!==r&&(this.maxOvertime=r),null===t)return void this.initMockupGame();const s=this.localStorage?.loadTiles()||[];this.init(t),this.restoreTiles(s),!this.over&&this.isTimed()&&this.startClock(),this.isRobotGame()||this.loadMessages()}applyServerState(e){return this.over=99===e.result,this.over||0===e.result?(this.currentError=this.currentMessage=null,Object.assign(this,e),e.newmoves&&(this.moves=this.moves.concat(e.newmoves)),this.newmoves=[],this.localturn=!this.over&&this.moves.length%2===this.player,this.isFresh=!0,this.startSquare=If[this.board_type],this.startCoord=Ef[this.board_type],this.congratulate=this.over&&null!==this.player&&this.scores[this.player]>this.scores[1-this.player],!0):(this.currentError=e.result||"server",this.currentMessage=e.msg||"",!1)}init(e){e?this.applyServerState(e)&&(this.placeTiles(),Tf.ingestTwoLetterWords(this.locale,this.two_letter_words[0])):super.init()}applyOpponentMove(e){const t=this.localturn,n=this.savePlayerTiles();this.applyServerState(e)&&(this.placeTiles(void 0,void 0,!0),!t&&this.localturn?this.restorePlayerTiles(n):this.populateRackTiles())}initMockupGame(){this.tiles={},this.startSquare=If[this.board_type],this.startCoord=Ef[this.board_type],this.alphabet="aábdðeéfghiíjklmnoóprstuúvxyýþæö",this.localturn=!0,this.player=0,this.tile_scores={"?":0,a:1,b:5,d:5,e:3,f:3,g:3,h:4,i:1,j:6,k:2,l:2,m:2,n:1,o:5,p:5,r:1,s:1,t:2,u:2,v:5,x:10,y:6,"á":3,"æ":4,"é":7,"í":4,"ð":2,"ó":3,"ö":6,"ú":4,"ý":5,"þ":7},this.two_letter_words=[[["a",["að","af","ak","al","an","ar","as","at","ax"]],["á",["áa","áð","ái","ál","ám","án","ár","ás","át"]],["b",["bí","bú","bý","bæ"]],["d",["dá","do","dó","dý"]],["e",["eð","ef","eg","ei","ek","el","em","en","er","es","et","ex","ey"]],["é",["ég","él","ét"]],["f",["fa","fá","fé","fæ"]],["g",["gá"]],["h",["ha","há","hí","hó","hý","hæ"]],["i",["ið","il","im"]],["í",["íð","íl","ím","ís"]],["j",["já","je","jó","jú"]],["k",["ká","ku","kú"]],["l",["la","lá","lé","ló","lú","lý","læ"]],["m",["má","mi","mó","mý"]],["n",["ná","né","nó","nú","ný","næ"]],["o",["of","og","oj","ok","op","or"]],["ó",["óa","óð","óf","ói","ók","ól","óm","ón","óp","ós","óx"]],["p",["pí","pu","pú","pæ"]],["r",["rá","re","ré","rí","ró","rú","rý","ræ"]],["s",["sá","sé","sí","so","sú","sý","sæ"]],["t",["tá","te","té","ti","tí","tó","tý"]],["u",["um","un"]],["ú",["úa","úð","úf","úi","úr","út"]],["v",["vá","vé","ví","vó"]],["y",["yl","ym","yr","ys"]],["ý",["ýf","ýg","ýi","ýk","ýl","ýr","ýs","ýt"]],["þ",["þá","þó","þú","þý"]],["æ",["æð","æf","æg","æi","æl","æp","ær","æs","æt"]],["ö",["öl","ör","ös","öt","öx"]]],[["a",["áa","fa","ha","la","óa","úa"]],["á",["dá","fá","gá","há","já","ká","lá","má","ná","rá","sá","tá","vá","þá"]],["ð",["að","áð","eð","ið","íð","óð","úð","æð"]],["e",["je","re","te"]],["é",["fé","lé","né","ré","sé","té","vé"]],["f",["af","ef","of","óf","úf","ýf","æf"]],["g",["eg","ég","og","ýg","æg"]],["i",["ái","ei","mi","ói","ti","úi","ýi","æi"]],["í",["bí","hí","pí","rí","sí","tí","ví"]],["j",["oj"]],["k",["ak","ek","ok","ók","ýk"]],["l",["al","ál","el","él","il","íl","ól","yl","ýl","æl","öl"]],["m",["ám","em","im","ím","óm","um","ym"]],["n",["an","án","en","ón","un"]],["o",["do","so"]],["ó",["dó","hó","jó","ló","mó","nó","ró","tó","vó","þó"]],["p",["op","óp","æp"]],["r",["ar","ár","er","or","úr","yr","ýr","ær","ör"]],["s",["as","ás","es","ís","ós","ys","ýs","æs","ös"]],["t",["at","át","et","ét","út","ýt","æt","öt"]],["u",["ku","pu"]],["ú",["bú","jú","kú","lú","nú","pú","rú","sú","þú"]],["x",["ax","ex","óx","öx"]],["y",["ey"]],["ý",["bý","dý","hý","lý","mý","ný","rý","sý","tý","þý"]],["æ",["bæ","fæ","hæ","læ","næ","pæ","ræ","sæ"]]]];const e=[["t",1],["e",1],["s",1],["t",1],["i",1],["n",1],["g",2]];this.rack=e;for(let t=0;t<e.length;t++){const[n,i]=e[t];this.tiles[`R${t+1}`]={player:0,tile:n,letter:n,score:i,freshtile:!0,draggable:!0,index:t,xchg:!1}}Tf.ingestTwoLetterWords(this.locale,this.two_letter_words[0])}update(e){const t=this.congratulate;for(const e of Object.keys(this.tiles))this.tiles[e].freshtile=!1;this.applyOpponentMove(e),null===this.currentError&&(this.succ_chall?this.resetRack():this.updateScore()),this.saveTiles(),this.isTimed()&&this.resetClock(),!t&&this.congratulate&&this.moveListener&&this.moveListener.notifyGameWon()}async refresh(){try{if(!this.uuid)return;const e=await ip(this.state,{method:"POST",url:"/gamestate",body:{game:this.uuid}});e?.ok&&this.update(e.game)}catch(e){}finally{this.moveInProgress=!1}}notifyUserChange(e){null!==this.player&&(this.nickname[this.player]=e)}buttonState(){const e={};return e.tilesPlaced=this.tilesPlaced().length>0,e.gameOver=this.over,e.congratulate=this.congratulate,e.localTurn=this.localturn,e.gameIsManual=this.manual,e.challengeAllowed=this.chall,e.lastChallenge=this.last_chall,e.showingDialog=null!==this.showingDialog,e.exchangeAllowed=this.xchg,e.wordGood=this.wordGood,e.wordBad=this.wordBad,e.canPlay=!1,e.tardyOpponent=!e.localTurn&&!e.gameOver&&this.overdue,e.showResign=!1,e.showExchange=!1,e.showPass=!1,e.showRecall=!1,e.showScramble=!1,e.showMove=!1,e.showMoveMobile=!1,e.showForceResignMobile=!1,e.showChallenge=!1,e.showChallengeInfo=!1,this.moveInProgress||(e.localTurn&&!e.gameOver&&(e.lastChallenge?(e.showChallenge=!0,e.showPass=!0,e.showChallengeInfo=!0):(e.showMove=e.tilesPlaced,e.showExchange=!e.tilesPlaced,e.showPass=!e.tilesPlaced,e.showResign=!e.tilesPlaced,e.showChallenge=!e.tilesPlaced&&e.gameIsManual&&e.challengeAllowed)),e.showMove&&(e.wordGood||e.gameIsManual)&&(e.canPlay=!0),e.gameOver||(e.tilesPlaced?(e.showRecall=!0,e.showMoveMobile=!0):(e.showScramble=!0,e.tardyOpponent&&(e.showForceResignMobile=!0)))),e}isTimed(){return null!==this.time_info&&this.time_info.duration>=1}showClock(){return!!this.isTimed()&&(!this.over||(!!this.clockText0||!!this.clockText1))}updateClock(){var e=this.calcTimeToGo(0),t=this.calcTimeToGo(1);this.clockText0=e,this.clockText1=t,this.runningOut0="-"===e[0]||e<="02:00",this.runningOut1="-"===t[0]||t<="02:00",this.blinking0=this.runningOut0&&e>="00:00"&&e<="00:30"&&0===this.player,this.blinking1=this.runningOut1&&t>="00:00"&&t<="00:30"&&1===this.player,Fd.redraw()}resetClock(){this.timeBase=new Date,this.updateClock(),this.over&&(this.interval&&(window.clearInterval(this.interval),this.interval=null),this.blinking0=!1,this.blinking1=!1,this.runningOut0=!1,this.runningOut1=!1)}startClock(){this.resetClock(),this.interval||(this.interval=window.setInterval(()=>{this.updateClock()},500))}cleanup(){this.interval&&(window.clearInterval(this.interval),this.interval=null)}calcTimeToGo(e){const t=this.time_info;if(null===t||null===this.timeBase)return"";let n=t.elapsed[e];const i=this.over;if(!i&&this.moves.length%2===e){n+=((new Date).getTime()-this.timeBase.getTime())/1e3,n-60*t.duration>this.maxOvertime&&(this.moveInProgress||(this.moveInProgress=!0,window.setTimeout(()=>{this.refresh()},500)))}const r=Math.max(60*t.duration-n,-this.maxOvertime),s=Math.abs(r),a=Math.floor(s/60),o=Math.floor(s-60*a);return i?(this.penalty0=0,this.penalty1=0):r<0&&(0===e?this.penalty0=-10*Math.floor((60*a+o+59)/60):this.penalty1=-10*Math.floor((60*a+o+59)/60)),(r<0?"-":"")+`0${a.toString()}`.slice(-2)+":"+`0${o.toString()}`.slice(-2)}displayScore(e){return Math.max(this.scores[e]+(0===e?this.penalty0:this.penalty1),0)}isRobotGame(){return this.autoplayer[0]||this.autoplayer[1]}async loadMessages(){if(!this.chatLoading){this.chatLoading=!0,this.messages=[];try{const e=await ip(this.state,{method:"POST",url:"/chatload",body:{channel:`game:${this.uuid}`}});e.ok?this.messages=e.messages||[]:this.messages=[],void 0===e.seen?this.chatSeen=!0:this.chatSeen=e.seen}catch(e){}finally{this.chatLoading=!1}}}async loadStats(){this.stats=void 0;try{const e=await ip(this.state,{method:"POST",url:"/gamestats",body:{game:this.uuid}});if(!e||void 0===e.result)return;if(0!==e.result&&99!==e.result)return;this.stats=e}catch(e){}}async sendMessage(e){try{await ip(this.state,{method:"POST",url:"/chatmsg",body:{channel:`game:${this.uuid}`,msg:e}})}catch(e){}}sendChatSeenMarker(){this.sendMessage(""),this.chatSeen=!0}addChatMessage(e,t,n,i){this.chatLoading||""===t||(null===this.messages&&(this.messages=[]),this.messages.push({from_userid:e,msg:t,ts:n}),"chat"===this.sel?this.sendChatSeenMarker():i||(this.chatSeen=!1))}markChatShown(){return!this.chatSeen&&(this.sendChatSeenMarker(),!0)}placeMove(e,t,n,i){const r=zp(t);let s=r.col,a=r.row,o=!1,l=0;for(let t=0;t<n.length;t++){let c=n[t];if("?"===c){o=!0;continue}const u=Fp(a,s);if(null===u)continue;const h=c;o&&(c="?");const d=this.tilescore(c);u in this.tiles||(this.tiles[u]={player:e,tile:c,letter:h,score:d,draggable:!1,freshtile:!1,index:l,xchg:!1},i&&(null!==this.player?this.tiles[u].highlight=e===this.player?0:1:this.tiles[u].highlight=e,l++)),s+=r.dx,a+=r.dy,o=!1}}setRack(e){this.rack=e}rackAtMove(e){const t=this.racks?.length||0;return t?this.racks[e>=t?t-1:e]:""}isFinalMove(e){return e>=this.num_moves}boardAsStrings(){const e=[];for(const t of sp){let n="";for(let e=0;e<ap;e++){const i=`${t}${e+1}`;if(i in this.tiles){const{tile:e,letter:t}=this.tiles[i];n+="?"===e?t.toLocaleUpperCase():t}else n+="."}e.push(n)}return e}placeTiles(e,t,n){this.tiles={},this.numTileMoves=0;const i=this.moves,r=void 0!==e,s=!r&&!this.lastmove&&this.localturn,a=!t&&(s||r),o=void 0!==e?e:i.length;function l(e){if(e+2>=o)return!1;const[t,[n,r,s]]=i[e+2];return""===n&&("RESP"===r&&s<0)}for(let e=0;e<o;e++){const[t,[n,r]]=i[e];""===n||l(e)||(this.placeMove(t,n,r,e===o-1&&a),this.numTileMoves++)}const c=this.lastmove;if(c&&this.localturn&&!this.succ_chall)for(let e=0;e<c.length;e++){const t=c[e][0];if(!(t in this.tiles))throw`Tile from lastmove not in square ${t}`;this.tiles[t].freshtile=!0,this.tiles[t].index=e}n||this.populateRackTiles()}populateRackTiles(){for(let e=0;e<this.rack.length;e++){const t=`R${e+1}`,[n,i]=this.rack[e],r="?"===n?" ":n;this.tiles[t]={player:this.player?1:0,tile:n,letter:r,score:i,draggable:!0,freshtile:!1,index:0,xchg:!1}}}savePlayerTiles(){const e={};for(const t of this.draggableTiles())e[t]={...this.tiles[t]};return e}restorePlayerTiles(e){const t=[];for(const n of Object.keys(e))n in this.tiles?t.push(n):this.tiles[n]=e[n];let n=1;for(const i of t){for(;`R${n}`in this.tiles;)n++;const t=`R${n}`;this.tiles[t]=e[i],"?"===this.tiles[t].tile&&(this.tiles[t].letter=" ")}}allowDragDrop(){return!this.over&&!this.showingDialog&&!this.moveInProgress}async sendMove(e){this.moveInProgress=!0;try{const t=await ip(this.state,{method:"POST",url:"/submitmove",body:{moves:e,mcount:this.moves.length,uuid:this.uuid}});this.update(t),this.moveListener&&this.moveListener.notifyMove()}catch(e){this.currentError="server",e instanceof Error?this.currentMessage=e.message:this.currentMessage=String(e)}finally{this.moveInProgress=!1}}async forceResign(){this.moveInProgress=!0;try{const e=await ip(this.state,{method:"POST",url:"/forceresign",body:{mcount:this.moves.length,game:this.uuid}});this.update(e)}catch(e){this.currentError="server",e instanceof Error?this.currentMessage=e.message:this.currentMessage=String(e)}finally{this.moveInProgress=!1}}submitMove(){const e=this.tilesPlaced(),t=[];this.selectedSq=null,this.resetKeyboardState();for(let n=0;n<e.length;n++){const i=e[n],{tile:r,letter:s}=this.tiles[i];t.push(`${i}=${r}${"?"===r?s:""}`)}t.length>0&&this.sendMove(t)}submitPass(){this.showingDialog="pass",this.selectedSq=null}submitChallenge(){this.showingDialog="chall",this.selectedSq=null}submitExchange(){this.showingDialog="exchange",this.selectedSq=null;for(let e=1;e<=7;e++){const t=`R${e}`;t in this.tiles&&(this.tiles[t].xchg=!1)}}submitResign(){this.showingDialog="resign",this.selectedSq=null}confirmPass(e){this.showingDialog=null,e&&this.sendMove(["pass"])}confirmChallenge(e){this.showingDialog=null,e&&this.sendMove(["chall"])}confirmExchange(e){let t="";this.showingDialog=null;for(let e=1;e<=7;e++){const n=`R${e}`;n in this.tiles&&this.tiles[n].xchg&&(t+=this.tiles[n].tile,this.tiles[n].xchg=!1)}e&&t.length>0&&this.sendMove([`exch=${t}`])}confirmResign(e){this.showingDialog=null,e&&this.sendMove(["rsgn"])}}const Lf="gata_";function Nf(e,t){return`${Lf}${t}_${e}`}function Df(e,t,n){if(!e||!t)return;const i={date:t,moves:n,timestamp:(new Date).toISOString(),userId:e};try{const n=Nf(e,t);localStorage.setItem(n,JSON.stringify(i)),function(){try{const e=new Date,t=new Date(e);t.setDate(t.getDate()-30);const n=[];for(let e=0;e<localStorage.length;e++){const i=localStorage.key(e);if(i?.startsWith(Lf)){const e=i.split("_");if(e.length>=2){const r=e[1],s=new Date(r);!Number.isNaN(s.getTime())&&s<t&&n.push(i)}}}for(const e of n)localStorage.removeItem(e)}catch(e){console.error("Failed to cleanup old entries:",e)}}()}catch(e){console.error("Failed to save moves to localStorage:",e)}}class Af extends xf{constructor(e,t,n){if(!n.state)throw new Error("No global state in Riddle constructor");super(e,n.state),this.bestPossibleScore=0,this.warmBoundary=0,this.hotBoundary=0,this.globalBestScore=null,this.groupBestScore=null,this.personalBestScore=0,this.playerMoves=[],this.solution=null,this.justAchievedBestScore=!1,this.date=t,this.model=n}buttonState(){const e={};return e.tilesPlaced=this.tilesPlaced().length>0,e.gameOver=!1,e.localTurn=!0,e.showingDialog=null!==this.showingDialog,e.wordGood=this.wordGood,e.wordBad=this.wordBad,e.canPlay=this.wordGood&&e.tilesPlaced,e.showRecall=e.tilesPlaced,e.showScramble=!e.tilesPlaced,e.showMove=!1,e.showMoveMobile=!1,e.showPass=!1,e.showExchange=!1,e.showResign=!1,e.showChallenge=!1,e.showChallengeInfo=!1,e.showForceResignMobile=!1,e}allowDragDrop(){return!this.showingDialog}async load(e,t){const{state:n}=this;try{if(!n)throw new Error("No global state in Riddle.load");const i=await ip(n,{method:"POST",url:"/gatadagsins/riddle",body:{date:e,locale:t}});if(i.ok&&(this.date=e,this.locale=t,this.board_type=i.riddle.board_type||"standard",this.alphabet=i.riddle.alphabet||"",this.tile_scores=i.riddle.tile_scores||{},this.two_letter_words=i.riddle.two_letter_words||[],this.initBoard(i.riddle.board||[]),this.initRack(i.riddle.rack||[]),this.bestPossibleScore=i.riddle.max_score||0,this.globalBestScore=null,this.groupBestScore=null,this.personalBestScore=0,this.solution=i.riddle.solution||null,this.warmBoundary=.25*this.bestPossibleScore,this.hotBoundary=.5*this.bestPossibleScore,Tf.ingestTwoLetterWords(this.locale,this.two_letter_words[0]),n.netskraflUserId)){const t=function(e,t){if(!e||!t)return[];try{const n=Nf(e,t),i=localStorage.getItem(n);if(!i)return[];const r=JSON.parse(i);return r.userId&&r.userId===e&&r.moves||[]}catch(e){return console.error("Failed to load moves from localStorage:",e),[]}}(n.netskraflUserId,e);if(t.length>0){const e=t.filter(e=>e.score<=this.bestPossibleScore);if(e.length>0){this.playerMoves=e.map(e=>({word:e.word,score:e.score,coord:e.coord,timestamp:e.timestamp||(new Date).toISOString()}));const t=e.reduce((e,t)=>t.score>e.score?t:e);this.personalBestScore=t.score}}}}catch(e){console.error("Failed to load daily riddle:",e),this.currentError="Gat ekki lesið gátu dagsins. Reyndu aftur síðar."}}async submitRiddleWord(e){const{state:t}=this;if(t&&t.netskraflUserId)try{await ip(t,{method:"POST",url:"/gatadagsins/submit",body:{date:this.date,locale:this.locale,userId:t.netskraflUserId,groupId:t.userGroupId||null,userDisplayName:t.userFullname||t.userNick||"",move:e}})}catch(e){console.error("Failed to submit move:",e),this.currentError="Netþjónn gat ekki tekið á móti lögninni."}}addToPlayerMoves(e){if(!(this.wordGood&&this.currentScore&&this.currentWordWithBlanks&&this.currentCoord))return;if(this.currentScore>this.bestPossibleScore)return;const t={score:this.currentScore,word:this.currentWordWithBlanks,coord:this.currentCoord,timestamp:e},n=this.playerMoves.find(e=>e.word===t.word&&e.coord===t.coord&&e.score===t.score);return n?void 0:(this.playerMoves.push(t),t)}async updateScore(){await super.updateScore();const e=(new Date).toISOString(),t=this.addToPlayerMoves(e);if(!t)return;const{state:n,date:i,playerMoves:r}=this;if(!n||!n.netskraflUserId)return;const s=r.map(e=>({score:e.score,word:e.word,coord:e.coord,timestamp:e.timestamp}));if(Df(n.netskraflUserId,i,s),t.score<=this.personalBestScore)return;this.personalBestScore=t.score;i===e.split("T")[0]&&(t.score>=this.bestPossibleScore&&(this.justAchievedBestScore=!0),this.submitRiddleWord(t))}updateGlobalBestScore(e){e.score>this.bestPossibleScore||(this.globalBestScore=e)}updateGroupBestScore(e){e.score>this.bestPossibleScore||(this.groupBestScore=e)}recreateWordOnBoard(e,t){this._resetRack();const{row:n,col:i,dx:r,dy:s}=zp(t),a=[];for(let e=1;e<=7;e++){const t=`R${e}`;t in this.tiles&&a.push(t)}let o=n,l=i,c=0;for(;c<e.length;){let t,n=!1;"?"===e[c]?(n=!0,c++,t=e[c]):t=e[c];const i=Fp(o,l);if(!i)return;const u=this.tileAt(o,l);if(u&&!u.draggable){if(u.letter!==t)return}else{if(0===a.length)return;let e=!1;for(let r=0;r<a.length;r++){const s=a[r],o=this.tiles[s];if(o){const l="?"===o.tile?" ":o.tile;if(n){if("?"===o.tile){o.letter=t,this.tiles[i]=o,delete this.tiles[s],a.splice(r,1),e=!0;break}}else if(l===t){this.tiles[i]=o,delete this.tiles[s],a.splice(r,1),e=!0;break}}}if(!e)return}o+=s,l+=r,c++}this.updateScore(),this.saveTiles()}initRack(e){for(let e=1;e<=7;e++)delete this.tiles[`R${e}`];for(let t=0;t<e.length&&t<7;t++){const[n,i]=e[t];this.tiles[`R${t+1}`]={player:0,tile:n,letter:"?"===n?" ":n,score:i,freshtile:!0,draggable:!0,index:t,xchg:!1}}}initBoard(e){this.tiles={};for(let t=0;t<15;t++){const n=e[t]||"";for(let e=0;e<15;e++){const i=n[e]||"",r=Fp(t,e);if(!i||!r)continue;const s=i.toLowerCase(),a=s!==i;if(this.alphabet.includes(s)){const e=a?0:this.tile_scores[s]||1;this.tiles[r]={player:0,tile:a?"?":s,letter:s,score:e,freshtile:!1,draggable:!1,index:-1,xchg:!1}}}}}cleanup(){super.cleanup()}}function Mf(){const e=[{name:"main",route:"/main",mustLogin:!0},{name:"help",route:"/help",mustLogin:!1},{name:"game",route:"/game/:uuid",mustLogin:!0},{name:"review",route:"/review/:uuid",mustLogin:!0}];return{paths:e,defaultRoute:e[0].route}}class Of{constructor(e,t){this.paths=[],this.routeName=void 0,this.params=void 0,this.game=null,this.riddle=null,this.userStats=null,this.leaderboard=[],this.solverCount=0,this.gameList=null,this.numGames=0,this.loadingAllLists=!1,this.loadingGameList=!1,this.challengeList=null,this.numChallenges=0,this.loadingChallengeList=!1,this.oppReady=0,this.recentList=null,this.loadingRecentList=!1,this.userListCriteria=null,this.userList=null,this.loadingUserList=!1,this.eloRatingList=null,this.eloRatingSpec=null,this.ownStats=null,this.user=null,this.userErrors=null,this.userLoadError=!1,this.helpHTML=null,this.spinners=0,this.reviewMove=null,this.bestMoves=null,this.highlightedMove=null,this.maxFreeGames=0,this.isExplo=!1,this.paths=e.paths.slice(),this.state=t,this.isExplo=t.isExplo,this.maxFreeGames=t.isExplo?3:8,bp(t.locale)}async post(e,t){if(!this.state)throw new Error("Model state is not initialized");return ip(this.state,{method:"POST",url:e,body:t})}async getText(e){if(!this.state)throw new Error("Model state is not initialized");return ip(this.state,{method:"GET",url:e,responseType:"text",deserialize:e=>e})}async postText(e,t){if(!this.state)throw new Error("Model state is not initialized");return ip(this.state,{method:"POST",url:e,body:t,responseType:"text",deserialize:e=>e})}async postMoves(e){if(!this.state)throw new Error("Model state is not initialized");return rp(this.state,{method:"POST",url:"/moves",body:e})}async loadGame(e,t,n=!1){try{if(null!==this.game&&(this.game.cleanup(),this.game=null),this.reviewMove=null,this.bestMoves=null,this.highlightedMove=null,!e)return;const i=await this.post("/gamestate",{game:e,delete_zombie:n});i?.ok&&(this.game=new Rf(e,i.game,this,this.state,this.state?.runningLocal?60:600),t?.())}catch(e){}}async loadAllLists(e=!0){if(!this.loadingAllLists){this.loadingAllLists=!0,this.gameList=[],this.challengeList=[],this.recentList=[],this.numGames=0,this.numChallenges=0,this.oppReady=0;try{const t=await this.post("/allgamelists",{zombie:e,count:40});if(!t||0!==t.result)return this.gameList=[],this.challengeList=[],void(this.recentList=[]);this.gameList=t.gamelist||[],this.challengeList=t.challengelist||[],this.recentList=t.recentlist||[],this.numGames=this.gameList.reduce((e,t)=>e+(t.my_turn||t.zombie?1:0),0);for(const e of this.challengeList)e.opp_ready&&this.oppReady++;this.numChallenges=this.oppReady,this.numChallenges+=this.challengeList.reduce((e,t)=>e+(t.received?1:0),0)}catch(e){this.gameList=[],this.challengeList=[],this.recentList=[]}finally{this.loadingAllLists=!1}}}async loadGameList(e=!0){if(!this.loadingGameList){this.loadingGameList=!0,this.gameList=[],this.numGames=0,this.spinners++;try{const t=await this.post("/gamelist",{zombie:e});if(!t||0!==t.result)return void(this.gameList=[]);this.gameList=t.gamelist||[],this.gameList&&(this.numGames=this.gameList.reduce((e,t)=>e+(t.my_turn||t.zombie?1:0),0))}catch(e){this.gameList=[]}finally{this.loadingGameList=!1,this.spinners&&this.spinners--}}}async loadChallengeList(){if(!this.loadingChallengeList){this.loadingChallengeList=!0,this.challengeList=[],this.numChallenges=0,this.oppReady=0,this.spinners++;try{const e=await this.post("/challengelist");if(!e||0!==e.result)return void(this.challengeList=[]);this.challengeList=e.challengelist||[];for(const e of this.challengeList)e.opp_ready&&this.oppReady++;this.numChallenges=this.oppReady,this.numChallenges+=this.challengeList.reduce((e,t)=>e+(t.received?1:0),0)}catch(e){this.challengeList=[]}finally{this.loadingChallengeList=!1,this.spinners&&this.spinners--}}}async loadRecentList(){if(!this.loadingRecentList){this.loadingRecentList=!0,this.recentList=[],this.spinners++;try{const e=await this.post("/recentlist",{versus:null,count:40});if(!e||0!==e.result)return void(this.recentList=[]);this.recentList=e.recentlist||[]}catch(e){this.recentList=[]}finally{this.loadingRecentList=!1,this.spinners&&this.spinners--}}}async loadUserRecentList(e,t,n){n(await this.post("/recentlist",{user:e,versus:t,count:40}))}async loadUserList(e){if("search"===e.query&&""===e.spec)return this.userList=[],this.userListCriteria=e,void Fd.redraw();this.userList=void 0,this.userListCriteria=void 0;const t=e;try{const n=await this.post("/userlist",t);if(!n||0!==n.result)return this.userList=[],void(this.userListCriteria=e);this.userList=n.userlist,this.userListCriteria=e}catch(t){this.userList=[],this.userListCriteria=e}}async loadEloRatingList(e){this.eloRatingList=void 0,this.eloRatingSpec=void 0;const t={kind:e};try{const n=await this.post("/rating",t);if(!n||0!==n.result)return this.eloRatingList=[],void(this.eloRatingSpec=e);this.eloRatingList=n.rating,this.eloRatingSpec=e}catch(t){this.eloRatingList=[],this.eloRatingSpec=e}}async loadOwnStats(){this.ownStats={};try{const e=await this.post("/userstats",{});if(!e||0!==e.result)return;this.ownStats=e}catch(e){}}async loadUserStats(e,t){try{t(await this.post("/userstats",{user:e}))}catch(e){}}async loadPromoContent(e,t){try{t(await this.postText("/promo",{key:e}))}catch(e){}}async loadBestMoves(e){if(!this.game||!this.game.uuid)return;if(!e)return this.reviewMove=0,this.bestMoves=null,this.highlightedMove=null,this.game.setRack([]),void this.game.placeTiles(0);const t=this.game.tile_scores,n=this.game.rackAtMove(e-1);if(!n||this.game.isFinalMove(e-1))return this.reviewMove=e,this.bestMoves=[],this.highlightedMove=null,n?this.game.setRack(n.split("").map(e=>[e,t[e]])):this.game.setRack([]),void this.game.placeTiles(e);this.reviewMove=null,this.spinners++,this.game.placeTiles(e-1,!0,!0);try{const i={locale:this.game.locale,board_type:this.isExplo?"explo":"standard",board:this.game.boardAsStrings(),rack:n,limit:19},r=await this.postMoves(i);if(this.highlightedMove=null,!r||void 0===r.moves)return this.reviewMove=null,void(this.bestMoves=null);this.reviewMove=e,this.bestMoves=r.moves.map(t=>[(e-1)%2,[t.co,t.w,t.sc],!1]),this.game.setRack(n.split("").map(e=>[e,t[e]])),this.game.placeTiles(e)}catch(e){this.highlightedMove=null,this.reviewMove=null,this.bestMoves=null}finally{this.spinners&&this.spinners--}}async loadHelp(){if(null===this.helpHTML)try{const e=this.state?.locale||"is_IS",t=await this.getText(`/rawhelp?version=malstadur&locale=${e}`);this.helpHTML=t}catch(e){this.helpHTML=""}}async loadUser(e){this.user=void 0,e&&this.spinners++;try{const e=await this.post("/loaduserprefs");e&&e.ok?(this.user=e.userprefs,this.userErrors=null,Bp(lg())):(this.user=null,this.userErrors=null,this.userLoadError=!0)}catch(e){this.user=null,this.userErrors=null,this.userLoadError=!0}finally{e&&this.spinners&&this.spinners--}}async saveUser(e){const t=this.user;if(t)try{const n=await this.post("/saveuserprefs",t);if(n?.ok){const n=this.state;null!==n&&(n.userNick=t.nickname,n.beginner=t.beginner,n.fairPlay=t.fairplay,o(n)),Bp(lg()),null!==this.game&&this.game.notifyUserChange(t.nickname),void 0!==e&&e(),this.userErrors=null,this.user=null}else this.userErrors=n.err||null}catch(e){this.userErrors=null}}addChatMessage(e,t,n,i){if(this.game&&this.game.uuid===e){const e=this.state?.netskraflUserId??"";return this.game.addChatMessage(t,n,i,t===e),!0}return!1}handleUserChallengeMessage(e,t){!t&&this.state&&e&&(this.loadChallengeList(),this.userListCriteria&&this.loadUserList(this.userListCriteria),this.loadingGameList||(this.gameList=null),Fd.redraw())}handleUserMoveMessage(e,t){!t&&this.state&&e&&(this.loadingGameList||(this.gameList=null,Fd.redraw()))}handleMoveMessage(e,t){!t&&this.game&&(this.game.update(e),this.state.audio&&null!==this.game.player&&!this.game.isRobotGame()&&Mp(this.state,"your-turn"),Fd.redraw())}notifyMove(){this.loadingGameList||(this.gameList=null)}notifyGameWon(){this.user?.fanfare&&Mp(this.state,"you-win")}moreGamesAllowed(){if(!this.state)return"need_subscription";if(this.loadingGameList)return"need_subscription";if(!this.gameList)return"allowed";const e=this.gameList.length;return e>=50?"limit_reached":this.state.hasPaid||e<this.maxFreeGames?"allowed":"need_subscription"}async initRiddle(e,t){this.riddle=new Af(`gatadagsins-${e}`,e,this),await this.riddle.load(e,t)}}const jf=()=>{let e=!1;return{view:t=>{const{view:n,item:i}=t.attrs,r=n.model.state;if(!r)return;const s=""!==r.plan,a=i.fairplay&&r.fairPlay;return Fd(".modal-dialog",{id:"chall-dialog",style:{visibility:"visible"}},Fd(".ui-widget.ui-widget-content.ui-corner-all",{id:"chall-form"},[Fd(".chall-hdr",Fd("table",Fd("tbody",Fd("tr",[Fd("td",Fd("h1.chall-icon",Rp("hand-right"))),Fd("td.l-border",[Fd(fg,{id:"chall-online",userId:i.userid,state:r}),Fd("h1",i.nick),Fd("h2",i.fullname)])])))),Fd("div",{style:{"text-align":"center"}},[Fd(".promo-fullscreen",[Cp("p",[Cp("strong","Ný áskorun")," - veldu lengd viðureignar:"]),Fd(yg,{initialSelection:0,defaultClass:"chall-time"},[Fd("div",{id:"chall-none",tabindex:1},_p("Viðureign án klukku")),Fd("div",{id:"chall-10",tabindex:2},[Rp("time"),_p("2 x 10 mínútur")]),Fd("div",{id:"chall-15",tabindex:3},[Rp("time"),_p("2 x 15 mínútur")]),Fd("div",{id:"chall-20",tabindex:4},[Rp("time"),_p("2 x 20 mínútur")]),Fd("div",{id:"chall-25",tabindex:5},[Rp("time"),_p("2 x 25 mínútur")]),r?.runningLocal?Fd("div",{id:"chall-3",tabindex:6},[Rp("time"),_p("2 x 3 mínútur")]):Fd("div",{id:"chall-30",tabindex:6},[Rp("time"),_p("2 x 30 mínútur")])])]),Fd(".promo-mobile",[Fd("p",Cp("strong","Ný áskorun")),Fd(".chall-time.selected",{id:"extra-none",tabindex:1},_p("Viðureign án klukku"))])]),s?Fd("div",{id:"chall-manual"},[Cp("span.caption.wide",["Nota ",Cp("strong","handvirka véfengingu"),Fd("br"),'("keppnishamur")']),Fd(".toggler[id='manual-toggler'][tabindex='7']",{onclick:t=>{e=!e,t.preventDefault()}},[Fd(".option"+(e?"":".selected"),Fd("span",Np())),Fd(".option"+(e?".selected":""),Rp("lightbulb"))])]):"",a?Fd("div",{id:"chall-fairplay"},[_p("Báðir leikmenn lýsa því yfir að þeir skrafla "),Fd("br"),Cp("strong","án stafrænna hjálpartækja"),_p(" af nokkru tagi"),"."]):"",Fd(dg,{id:"chall-cancel",title:kp("Hætta við"),tabindex:8,onclick:e=>{n.popDialog(),e.preventDefault()}},Rp("remove")),Fd(dg,{id:"chall-ok",title:kp("Skora á"),tabindex:9,onclick:t=>{let r=document.querySelector("div.chall-time.selected")?.id.slice(6)??"0";r="none"===r?0:parseInt(r,10),i.chall=!0,n.actions.handleChallenge({destuser:i.userid,action:"issue",duration:r,fairplay:a,manual:e}),n.popDialog(),t.preventDefault()}},Rp("ok"))]))}}},Ff=e=>{const{view:t}=e.attrs,{model:n}=t;return{view:()=>{if(!n.state)return;const e=n.state;return Fd(".modal-dialog",{id:"promo-dialog",style:{visibility:"visible"}},Fd(".ui-widget.ui-widget-content.ui-corner-all",{id:"promo-form"},[Fd(".promo-content",[Fd("h2",[Rp("coffee-cup"),Np(),"Komdu í áskrift að Netskrafli!"]),Fd("p","Með áskrift að Netskrafli færðu aðgang að öllu því sem leikurinn hefur að bjóða:"),Fd("ul",[Fd("li",["Sem áskrifandi getur þú haft ",Fd("b","ótakmarkaðan fjölda viðureigna")," í gangi samtímis (í stað ",Fd("b",8..toString())," að hámarki)."]),Fd("li",["Sem áskrifandi hefur þú aðgang að ",Fd("b","yfirliti")," í lok hverrar viðureignar þar sem hún er rakin leik fyrir leik ","og bestu möguleikar í hverri stöðu sýndir."]),Fd("li",["Sem áskrifandi getur þú skorað á aðra leikmenn í ",Fd("b","keppnisham"),". Þá má leggja niður hvaða orð sem er, en andstæðingur getur véfengt þau — alveg eins ","og í borðskrafli og í keppni á skraflmótum. (BÍN er þó áfram endanlegur dómari um ","gild orð.)"]),Fd("li",["Þú getur líka gerst áskrifandi að ",Fd("b","Málstað"),", máltæknivettvangi Miðeindar — og þá er Netskraflið innifalið! ","Á Málstað geturðu látið lesa yfir texta, þýtt á milli tungumála, ","breytt tali í texta, búið til skjátexta, fundargerðir og fleira."])]),Fd("p",Cp("strong","Komdu með — og styrktu íslenska máltækni í leiðinni!"))]),Fd(".btn-promo-yes",{id:"friend-yes",title:kp("Gerast áskrifandi"),tabindex:1,onclick:t=>{t.preventDefault(),gh("click_friend",{userid:e.netskraflUserId,locale:e.locale}),window.location.href=e.subscriptionUrl}},[Rp("ok"),Np(),kp("Gerast áskrifandi")]),Fd(".btn-promo-no",{id:"friend-no",title:kp("Hætta við"),tabindex:2,onclick:e=>{t.popDialog(),e.preventDefault()}},[Rp("remove"),Np(),kp("Nei, takk")])]))}}},zf=e=>{const{view:t}=e.attrs;return{view:()=>Fd(".modal-dialog",{id:"gamelimit-dialog",style:{visibility:"visible"}},Fd(".ui-widget.ui-widget-content.ui-corner-all",{id:"gamelimit-form"},[Fd(".promo-content",[Fd("h2",[Rp("warning-sign"),Np(),kp("Hámarki viðureigna náð")]),Fd("p",[kp("game_limit_message_1")," ",Fd("b",50..toString())," ",kp("game_limit_message_2")]),Fd("p",kp("game_limit_message_3"))]),Fd(".btn-promo-no",{id:"gamelimit-ok",title:kp("Ég skil"),tabindex:1,onclick:e=>{t.popDialog(),e.preventDefault()}},[Rp("ok"),Np(),kp("Ég skil")])]))}},Uf=e=>{const{view:t}=e.attrs,{model:n}=t;return{view:()=>{const{game:e}=n,t=[];return!e||null===e.showingDialog&&!e.last_chall||(e.last_chall&&e.localturn&&t.push(Fd(".chall-info",[Rp("info-sign"),Np(),Cp("span.pass-explain","opponent_emptied_rack")])),"resign"===e.showingDialog&&t.push(Fd(".resign",[Rp("exclamation-sign"),Np(),kp("Viltu gefa leikinn?"),Np(),Fd("span.mobile-break",Fd("br")),Fd("span.yesnobutton",{onclick:()=>e.confirmResign(!0)},[Rp("ok"),kp(" Já")]),Fd("span.mobile-space"),Fd("span.yesnobutton",{onclick:()=>e.confirmResign(!1)},[Rp("remove"),kp(" Nei")])])),"pass"===e.showingDialog&&(e.last_chall?t.push(Fd(".pass-last",[Rp("forward"),Np(),kp("Segja pass?"),Cp("span.pass-explain","Viðureign lýkur þar með"),Np(),Fd("span.mobile-break",Fd("br")),Fd("span.yesnobutton",{onclick:()=>e.confirmPass(!0)},[Rp("ok"),kp(" Já")]),Fd("span.mobile-space"),Fd("span.yesnobutton",{onclick:()=>e.confirmPass(!1)},[Rp("remove"),kp(" Nei")])])):t.push(Fd(".pass",[Rp("forward"),Np(),kp("Segja pass?"),Cp("span.pass-explain","2x3 pöss í röð ljúka viðureign"),Np(),Fd("span.mobile-break",Fd("br")),Fd("span.yesnobutton",{onclick:()=>e.confirmPass(!0)},[Rp("ok"),kp(" Já")]),Fd("span.mobile-space"),Fd("span.yesnobutton",{onclick:()=>e.confirmPass(!1)},[Rp("remove"),kp(" Nei")])]))),"exchange"===e.showingDialog&&t.push(Fd(".exchange",[Rp("refresh"),Np(),kp("Smelltu á flísarnar sem þú vilt skipta"),Np(),Fd("span.mobile-break",Fd("br")),Fd("span.yesnobutton",{title:kp("Skipta"),onclick:()=>e.confirmExchange(!0)},Rp("ok")),Fd("span.mobile-space"),Fd("span.yesnobutton",{title:kp("Hætta við"),onclick:()=>e.confirmExchange(!1)},Rp("remove"))])),"chall"===e.showingDialog&&t.push(Fd(".chall",[Rp("ban-circle"),Np(),kp("Véfengja lögn?"),Cp("span.pass-explain","Röng véfenging kostar 10 stig"),Np(),Fd("span.mobile-break",Fd("br")),Fd("span.yesnobutton",{onclick:()=>e.confirmChallenge(!0)},[Rp("ok"),kp(" Já")]),Fd("span.mobile-space"),Fd("span.yesnobutton",{onclick:()=>e.confirmChallenge(!1)},[Rp("remove"),kp(" Nei")])]))),t}}},$f=()=>({view:e=>{const{bag:t,newbag:n}=e.attrs;let i="";return t.length<=7?i+=".empty":n&&(i+=".new"),Fd(".bag",{title:kp("Flísar sem eftir eru")},Fd(`table.bag-content${i}`,function(e){const t=[];let n=0,i=e.length;for(;i>0;){const r=[];for(let t=0;t<19&&i>0;t++){let t=e[n++];"?"===t&&(t=" "),r.push(Fd("td",Fd.trust(t))),i--}t.push(Fd("tr",r))}return t}(t)))}}),qf=[{icon:":-)",image:"/static/icontexto_emoticons_03.png"},{icon:":-D",image:"/static/icontexto_emoticons_02.png"},{icon:";-)",image:"/static/icontexto_emoticons_04.png"},{icon:":-(",image:"/static/icontexto_emoticons_12.png"},{icon:":-o",image:"/static/icontexto_emoticons_10.png"},{icon:":-O",image:"/static/icontexto_emoticons_10.png"},{icon:":-p",image:"/static/icontexto_emoticons_14.png"},{icon:":-P",image:"/static/icontexto_emoticons_14.png"},{icon:"B-)",image:"/static/icontexto_emoticons_16.png"},{icon:":)",image:"/static/icontexto_emoticons_03.png"},{icon:":D",image:"/static/icontexto_emoticons_02.png"},{icon:";)",image:"/static/icontexto_emoticons_04.png"},{icon:":(",image:"/static/icontexto_emoticons_12.png"},{icon:":o",image:"/static/icontexto_emoticons_10.png"},{icon:":O",image:"/static/icontexto_emoticons_10.png"},{icon:":p",image:"/static/icontexto_emoticons_14.png"},{icon:":P",image:"/static/icontexto_emoticons_14.png"},{icon:"(y)",image:"/static/thumb-up.png"}],Bf=e=>{const{view:t}=e.attrs,n=t.model,i=n.game,r=n.state;function s(e){var t=function(e){return{year:parseInt(e.slice(0,4),10),month:parseInt(e.slice(5,7),10),day:parseInt(e.slice(8,10),10),hour:parseInt(e.slice(11,13),10),minute:parseInt(e.slice(14,16),10),second:parseInt(e.slice(17,19),10)}}(e);return Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second)}let a=null;function o(e,t){const n=s(e);let i=null;if(null===a||(r=a,o=n,Math.round((o-r)/1e3)>=300)){const r=864e5,s=Date.now(),a=s-s%r;let o;o=n<a-r?e.slice(0,-3):n<a?`Í gær ${e.slice(11,16)}`:e.slice(11,16),i=Fd(".chat-ts",{key:t},o)}var r,o;return a=n,i}const l=i?i.player:null;function c(e){if(!r)return e;for(const t of qf)if(e.indexOf(t.icon)>=0){const n=`<img src='${zd(r,t.image)}' height='32' width='32'>`;e=e.split(t.icon).join(n)}return e}function u(){const e=[];if(i?.chatLoading||!i?.messages)return e;var t=0;const r=n.state?.netskraflUserId??"";for(const n of i.messages){let i=l??0;n.from_userid!==r&&(i=1-i);const s=o(n.ts,t);null!==s&&(e.push(s),t++);let a=Dp(n.msg);a=c(a),e.push(Fd(".chat-msg"+(0===i?".left":".right")+(i===l?".local":".remote"),{key:t++},Fd.trust(a)))}return e}function h(){const e=document.querySelectorAll("#chat-area .chat-msg");if(!e.length)return;const t=e[e.length-1];t.parentNode.scrollTop=t.offsetTop}function d(e){t.isDialogShown()||e.dom.focus()}function p(){const e=Ap("msg").trim();i&&e.length>0&&(i.sendMessage(e),function(e,t){document.getElementById(e).value=t}("msg",""))}const g=i?.messages?i.messages.length:0;return{view:()=>Fd(".chat-container",{style:"z-index: 6"},[Fd(".chat-area"+(i?.showClock()?".with-clock":""),{id:"chat-area",oncreate:h,onupdate:h},u()),Fd(".chat-input",[Fd("input.chat-txt",{type:"text",id:"msg",name:"msg",maxlength:254,disabled:g>=250,oncreate:e=>{d(e)},onupdate:e=>{d(e)},onkeypress:e=>{"Enter"===e.key&&(p(),e.preventDefault())}}),Fd(dg,{id:"chat-send",title:kp("Senda"),onclick:e=>{p(),e.preventDefault()}},Rp("chat"))])])}},Vf=()=>{function e(e,t,n,i,r){const s=zp(t);let a=s.col,o=s.row;for(const t of n){if("?"===t)continue;const n=Fp(o,a);n&&n in e.tiles&&(e.tiles[n].highlight=r?i:void 0),a+=s.dx,o+=s.dy}}function t(t,n,i){const{game:r,state:s}=t.model;if(!r||!s)return null;const{leftTotal:a,rightTotal:o,player:l}=i;let{co:c,tiles:u}=i,h=i.score,d="wordmove";const p=c;let g=0;if(""===c)if(d="othermove","PASS"===u)u=` ${kp("Pass")} `,h="";else if(0===u.indexOf("EXCH")){const e=u.slice(5).length,t=kp(1===e?"letter":"letters");u=" "+kp("exchanged",{numtiles:e.toString(),letters:t})+" ",h=""}else"RSGN"===u?u=` ${kp("Gaf viðureign")} `:"CHALL"===u?(u=` ${kp("Véfengdi lögn")} `,h=""):"RESP"===u?h<0?(u=` ${kp("Óleyfileg lögn")} `,g=-1):u=` ${kp("Röng véfenging")} `:"TIME"===u?u=` ${kp("Umframtími")} `:"OVER"===u?(u=kp("Viðureign lokið"),d="gameover"):d="wordmove";else c=`(${c})`,u=u.split("?").join(""),g=1;if("gameover"===d)return function(e,t,n,i){return Fd(".move.gameover",[Fd("span.gameovermsg",i),Fd("span.statsbutton",{onclick:i=>{i.preventDefault(),n.hasPaid?(Fd.route.set(`/review/${t.uuid}`),null!=t&&gh("game_review",{locale:t.locale,uuid:t.uuid})):(gh("click_review",{userid:n.netskraflUserId,locale:n.locale}),e.showFriendPromo())}},_p("Skoða yfirlit"))])}(t,r,s,u);const f=g>0&&!r.manual?kp("Smelltu til að fletta upp"):"";let m=0;const v=r.player;let y;l===v||null===v&&0===l?y="humangrad"+(0===l?"_left":"_right"):(y="autoplayergrad"+(0===l?"_left":"_right"),m=1);const w={};return s.uiFullscreen&&g>0&&(r.manual||"is_IS"===r.locale&&(w.onclick=()=>{window.open(`https://malid.is/leit/${u}`,"malid")},w.title=f),w.onmouseout=()=>{n[2]=!1,e(r,p,u,m,!1)},w.onmouseover=()=>{n[2]=!0,e(r,p,u,m,!0)}),0===l?Fd(`.move.leftmove.${y}`,w,[Fd("span.total"+(l===v?".human":".autoplayer"),a),Fd("span.score"+(n[2]?".highlight":""),h),Fd(`span.${d}`,[Fd("i",u),Np(),c])]):Fd(`.move.rightmove.${y}`,w,[Fd(`span.${d}`,[c,Np(),Fd("i",u)]),Fd("span.score"+(n[2]?".highlight":""),h),Fd("span.total"+(l===v?".human":".autoplayer"),o)])}return{view:e=>{const{view:n,move:i,info:r}=e.attrs;return t(n,i,r)}}},Hf=e=>{const{view:t}=e.attrs,n=t.model;function i(e,n,i,r){t.isMobile()||(i===r?t.pushDialog("userprefs",{}):e.autoplayer[r]||t.showUserInfo(e.userid[r],e.nickname[r],e.fullname[r]),n.stopPropagation(),n.preventDefault())}return{view:e=>{const t=n.game;if(!t)return;const r=t.autoplayer[0],s=t.autoplayer[1],a=t.nickname[0],o=t.nickname[1],l=t.player,c=t.localturn,u=t.over;if("left"===e.attrs.side){if(r)return Fd(".robot-btn.left",[Rp("cog"),Np(),a]);return Fd(`.player-btn.left${u||c!==(0===l)?"":".tomove"}`,{id:"player-0",onclick:e=>i(t,e,l,0)},[Fd("span.left-to-move"),a])}if(s)return Fd(".robot-btn.right",[Rp("cog"),Np(),o]);return Fd(`.player-btn.right${u||c!==(1===l)?"":".tomove"}`,{id:"player-1",onclick:e=>i(t,e,l,1)},[Fd("span.right-to-move"),o])}}},Wf=e=>{const t=e.attrs.view.model;let n=0;function i(e,t){return Fd(".twoletter-word",e?0===n?[Fd("b",t[0]),t[1]]:[t[0],Fd("b",t[1])]:t)}return{view:()=>{if(!t.game)return;const e=t.game,r=e.twoLetterWords()[n],s=[];for(const e of r){const t=e[1],n=[];for(let e=0;e<t.length;e++)n.push(i(0===e,t[e]));s.push(Fd(".twoletter-group",n))}return Fd(".twoletter",{onclick:()=>{n=1-n},style:"z-index: 6"},Fd(".twoletter-area"+(e.showClock()?".with-clock":""),{title:kp(0===n?"Smelltu til að raða eftir seinni staf":"Smelltu til að raða eftir fyrri staf")},s))}}},Gf=e=>{const t=e.attrs.view,n=t.model,i=n.game,r=n.state;function s(){const e=i?i.moves:[],n=[];let r=0,s=0;for(let i=0;i<e.length;i++){const a=e[i],[o,[l,c,u]]=a;0===o?r=Math.max(r+u,0):s=Math.max(s+u,0);const h=Fd(Vf,{view:t,move:a,info:{leftTotal:r,rightTotal:s,player:o,co:l,tiles:c,score:u}});n.push(h)}return n}const a=i?i.bag:"",o=!i||i.newbag;return{view:()=>Fd(".movelist-container",[Fd(".movelist",{onupdate:()=>{setTimeout(jp)}},s()),r?.uiFullscreen?"":Fd($f,{bag:a,newbag:o})])}},Kf=e=>{const t=e.attrs.view.model;return{view:()=>Fd(".games",{style:"z-index: 6"},function(){const e=[];if(t.loadingGameList||t.loadingAllLists)return e;const n=t.gameList;if(null===n)return t.loadGameList(),e;const i=t.game,r=i?i.uuid:"";for(const t of n){if(t.uuid===r)continue;if(!t.my_turn&&!t.zombie)continue;let n;n=null===t.oppid?[Rp("cog"),Np(),t.opp]:[t.opp];const i=t.sc0<t.sc1?".losing":"",s=`Staðan er ${t.sc0}:${t.sc1}`;e.push(Fd(".games-item"+(t.timed?".game-timed":""),{key:t.uuid,title:s},Fd(Fd.route.Link,{href:Op(t.url)},[Fd(".at-top-left",Fd(".tilecount",Fd(".oc",n))),Fd(".at-top-left",Fd(".tilecount.trans",Fd(`.tc${i}`,{style:{width:`${t.tile_count.toString()}%`}},n)))])))}return e}())}},Yf={view:e=>{const{view:t,tabid:n,title:i,icon:r,alert:s,funcSel:a}=e.attrs,o=t.selectedTab||"movelist",l=t.model.game;return Fd(".right-tab"+(o===n?".selected":""),{id:`tab-${n}`,className:s?"chat-alert":"",title:i,onclick:e=>{l&&null===l.showingDialog&&t.setSelectedTab(n)&&(a?.(),"movelist"===n&&setTimeout(jp)),e.preventDefault()}},Rp(r))}},Jf={view:e=>{const{view:t}=e.attrs,{game:n}=t.model,i=n&&!n.isRobotGame()&&null!==n.player,r=[Fd(Yf,{view:t,tabid:"board",title:kp("Borðið"),icon:"grid"}),Fd(Yf,{view:t,tabid:"movelist",title:kp("Leikir"),icon:"show-lines"}),Fd(Yf,{view:t,tabid:"twoletter",title:kp("Tveggja stafa orð"),icon:"life-preserver"}),Fd(Yf,{view:t,tabid:"games",title:kp("Viðureignir"),icon:"flag"})];return i&&r.push(Fd(Yf,{view:t,tabid:"chat",title:kp("Spjall"),icon:"conversation",funcSel:()=>{n.markChatShown()&&Fd.redraw()},alert:!n.chatSeen&&"chat"!==t.selectedTab})),Fd.fragment({},r)}},Zf=e=>{const{view:t}=e.attrs,{model:n}=t,{game:i}=n;function r(){if(!i||!i.showClock())return Fd.fragment({},[]);function e(e,t,n,i){return Fd("h3."+e+(n?".running-out":"")+(i?".blink":""),t)}return Fd.fragment({},[e("clockleft",i.clockText0,i.runningOut0,i.blinking0),e("clockright",i.clockText1,i.runningOut1,i.blinking1),Fd(".clockface",Rp("time"))])}function s(){const e=!!i&&i.fairplay,n=i?i.player:null,s=i?i.displayScore(0).toString():"",a=i?i.displayScore(1).toString():"";return Fd(".heading",[Fd(".logowrapper",Fd(_g)),Fd(".playerwrapper",[Fd(".leftplayer"+(1===n?".autoplayercolor":".humancolor"),[Fd(".player",Fd(Hf,{view:t,side:"left"})),Fd(".scorewrapper",Fd(".scoreleft",s))]),Fd(".rightplayer"+(1===n?".humancolor":".autoplayercolor"),[Fd(".player",Fd(Hf,{view:t,side:"right"})),Fd(".scorewrapper",Fd(".scoreright",a))]),Fd(".fairplay",{style:{visibility:e?"visible":"hidden"}},Fd("span.fairplay-btn.large",{title:kp("Skraflað án hjálpartækja")}))]),r()])}function a(){if(!i)return;let e;switch(t.selectedTab||"movelist"){case"movelist":e=Fd(Gf,{view:t});break;case"twoletter":e=Fd(Wf,{view:t});break;case"chat":e=Fd(Bf,{view:t});break;case"games":e=Fd(Kf,{view:t})}const n=Fd(Jf,{view:t});return Fd(".right-area"+(i?.showClock()?".with-clock":""),e?[n,e]:[n])}return{view:()=>Fd(".rightcol",[s(),a()])}},Xf={view:e=>{const{view:t}=e.attrs,{model:n}=t,{game:i,state:r}=n;if(!i)return Fd("div",[Fd(".game-container"),Fd(bg)]);const{bag:s,newbag:a}=i;return Fd("div.drop-target",{id:"board-background"},[Fd(".game-container",[Fd(Zf,{view:t}),Fd(Gg,{view:t,game:i}),r?.uiFullscreen?Fd($f,{bag:s,newbag:a}):"",i.askingForBlank?Fd(Rg,{game:i}):""]),Fd(bg),r?.beginner?Fd(Hp,{view:t,showClose:!0}):"",Fd(wg)])}},Qf=()=>({view:e=>{const t=e.attrs.ownStats||{},n=[];if(t.highest_score&&(n.push(kp("Hæsta skor ")),n.push(Fd("b",Fd(Fd.route.Link,{href:`/game/${t.highest_score_game}`},t.highest_score)))),t.best_word){n.length&&(e.attrs.myself?n.push(Fd("br")):n.push(" | "));const i=t.best_word,r=[];for(let e=0;e<i.length;e++)"?"===i[e]?(r.push(Fd("span.netskrafl-blanktile",i[e+1])),e+=1):r.push(i[e]);n.push(kp("Besta orð ")),n.push(Fd("span.best-word",r)),n.push(", "),n.push(Fd("b",Fd(Fd.route.Link,{href:`/game/${t.best_word_game}`},t.best_word_score))),n.push(kp(" stig"))}return Fd("p",{id:e.attrs.id},n)}}),em=e=>{const{view:t,item:n,i:i}=e.attrs,{model:r}=t;function s(e){e.preventDefault(),n.received?t.actions.declineChallenge(n.userid,n.key):t.actions.retractChallenge(n.userid,n.key)}function a(e){e.preventDefault();const i=r.moreGamesAllowed();if("allowed"!==i){const e=r.state;return void("limit_reached"===i?(e&&gh("hit_absolute_game_limit",{userid:e.netskraflUserId,locale:e.locale}),t.showGameLimitReached()):(e&&gh("hit_game_limit",{userid:e.netskraflUserId,locale:e.locale,limit:r.maxFreeGames}),t.showFriendPromo()))}n.received?n.prefs&&void 0!==n.prefs.duration&&n.prefs.duration>0?t.pushDialog("wait",{oppId:n.userid,oppNick:n.opp,oppName:n.fullname,duration:n.prefs.duration,challengeKey:n.key}):t.actions.startNewGame(n.userid,!1):t.showAcceptDialog(n.userid,n.opp,n.key)}return{view:()=>{const e=!n.received&&n.opp_ready&&n.prefs&&void 0!==n.prefs.duration&&n.prefs.duration>0,r=n.received||e,o=(l=n.prefs)&&void 0!==l.duration&&0!==l.duration?_p("with_clock",{duration:l.duration.toString()}):_p("Venjuleg ótímabundin viðureign");var l;return Fd(".listitem"+(i%2==0?".oddlist":".evenlist"),[Fd("span.list-ch",{onclick:s},n.received?Rp("thumbs-down",{title:kp("Hafna")}):Rp("hand-right",{title:kp("Afturkalla")})),Fd(r?"a.flex":"span.flex",r?{href:"#",onclick:a,class:e?"opp-ready":""}:{},[Fd("span.list-ts",n.ts),Fd("span.list-nick",{title:n.fullname},n.opp),Fd("span.list-chall",[n.prefs.fairplay?Fd("span.fairplay-btn",{title:kp("Án hjálpartækja")}):"",n.prefs.manual?Fd("span.manual-btn",{title:kp("Keppnishamur")}):"",o])]),Fd(gg,{view:t,item:{userid:n.userid,nick:n.opp,fullname:n.fullname}})])}}},tm={view:e=>{const{view:t,showReceived:n}=e.attrs,{model:i}=t;if(!i.state)return[];null===i.challengeList&&i.loadChallengeList();let r=[];i.challengeList&&(r=n?i.challengeList.filter(e=>e.received):i.challengeList.filter(e=>!e.received));const s=Fd("div",{id:n?"chall-received":"chall-sent"},r.map((e,n)=>Fd(em,{view:t,item:e,i:n})));return n?[Fd(".listitem.listheader",[Fd("span.list-icon",Lp("thumbs-down",{title:kp("Hafna")})),Cp("span.list-ts","Hvenær"),Cp("span.list-nick","Áskorandi"),Cp("span.list-chall","Hvernig"),Cp("span.list-info-hdr","Ferill")]),s]:[Fd(".listitem.listheader",[Fd("span.list-icon",Lp("hand-right",{title:kp("Afturkalla")})),Cp("span.list-ts","Hvenær"),Cp("span.list-nick","Andstæðingur"),Cp("span.list-chall","Hvernig"),Cp("span.list-info-hdr","Ferill")]),s]}},nm={view:e=>{const{loadingGameList:t,loadingAllLists:n,gameList:i}=e.attrs;return t||n||null!==i&&i.length>0?"":Fd(".hint",{style:{display:"block"}},[Fd("p",["Ef þig vantar einhvern til að skrafla við, veldu flipann ",Fd(Fd.route.Link,{href:"/main?tab=2"},[Rp("user"),Np(),"Andstæðingar"])," og skoraðu á tölvuþjarka - ",Rp("cog"),Np(),Fd("b","Amlóða"),", ",Rp("cog"),Np(),Fd("b","Miðlung")," eða ",Rp("cog"),Np(),Fd("b","Fullsterkan")," - eða veldu þér annan leikmann úr stafrófslistunum sem þar er að finna til að skora á."]),Fd("p",["Þú stofnar áskorun með því að smella á bendi-teiknið ",Rp("hand-right",{style:{"margin-left":"6px","margin-right":"6px"}})," vinstra megin við nafn andstæðingsins."]),Fd("p","Tölvuþjarkarnir eru ætíð reiðubúnir að skrafla og viðureign við þá hefst strax. Aðrir leikmenn þurfa að samþykkja áskorun áður en viðureign hefst."),Fd("p.no-mobile-block",[Fd(Fd.route.Link,{href:"/help"},"Hjálp")," má fá með því að smella á bláa ",Rp("info-sign"),Np(),"-",Np(),"teiknið hér til vinstri."]),Fd("p.no-mobile-block","Þú kemst alltaf aftur í þessa aðalsíðu með því að smella á örvarmerkið efst vinstra megin við skraflborðið.")])}},im=()=>{function e(e){const t=null===e.oppid?[Rp("cog"),Np(),e.opp]:e.opp;return Fd("span.list-opp",{title:e.fullname},t)}function t(e){let t="",n="";return e.my_turn?t=kp("Þú átt leik"):e.zombie?(t=kp("Viðureign lokið"),n=".zombie"):(t=kp("opp_move",{opponent:e.opp}),n=".grayed"),Fd("span.list-myturn",Fd(`span.glyphicon.glyphicon-flag${n}`,{title:t}))}function n(e){return e.overdue?Rp("hourglass",{title:e.my_turn?"Er að renna út á tíma":"Getur þvingað fram uppgjöf"}):Lp("hourglass")}function i(e){const t=e.sc0<e.sc1?".losing":"";return Fd(".tilecount",Fd(`.tc${t}`,{style:{width:`${e.tile_count.toString()}%`}}))}return{view:r=>{const{view:s,item:a,i:o}=r.attrs;return Fd(".listitem"+(o%2==0?".oddlist":".evenlist"),[Fd(Fd.route.Link,{href:Op(a.url)},[t(a),Fd("span.list-overdue",n(a)),Fd("span.list-ts-short",a.ts),e(a)]),Fd(gg,{view:s,item:{userid:a.oppid,nick:a.opp,fullname:a.fullname}}),Fd("span.list-s0",a.sc0),Fd("span.list-colon",":"),Fd("span.list-s1",a.sc1),Fd("span.list-tc",i(a)),Fd(vg,{manual:a.prefs?.manual})])}}},rm=()=>({view:e=>{const{view:t,id:n}=e.attrs,{model:i}=t,{gameList:r,loadingGameList:s,loadingAllLists:a}=i;return null===r&&i.loadGameList(),[Fd(".listitem.listheader",[Fd("span.list-myturn",Lp("flag",{title:kp("Átt þú leik?")})),Fd("span.list-overdue",Lp("hourglass",{title:kp("Langt frá síðasta leik?")})),Cp("span.list-ts-short","Síðasti leikur"),Cp("span.list-opp","Andstæðingur"),Cp("span.list-info-hdr","Ferill"),Cp("span.list-scorehdr","Staða"),Cp("span.list-tc","Framvinda"),Fd(vg,{header:!0})]),Fd("div",{id:n},r?r.map((e,n)=>Fd(im,{view:t,item:e,i:n})):""),Fd(nm,{loadingGameList:s,loadingAllLists:a,gameList:r})]}}),sm=()=>{function e(e,t){let n=e.elo_adj?e.elo_adj.toString():"",i=e.human_elo_adj?e.human_elo_adj.toString():"",r="",s="";return null!==e.elo_adj&&(e.elo_adj>0?(n=`+${n}`,r="elo-win"):e.elo_adj<0?r="elo-loss":(r="elo-neutral",n=Rp("stroller",{title:"Byrjandi"})),null!==e.human_elo_adj&&(e.human_elo_adj>0?(i=`+${i}`,s="elo-win"):e.human_elo_adj<0?s="elo-loss":(s="elo-neutral",i=Rp("stroller",{title:"Byrjandi"})))),n=Fd("span",{class:`elo-btn right ${r}${""===n?" invisible":""}`},n),i=Fd("span",{class:"elo-btn left "+s+(""===i?" invisible":"")},i),Fd(".listitem"+(t%2==0?".oddlist":".evenlist"),Fd(Fd.route.Link,{href:Op(e.url)},[Fd("span.list-win",e.sc0>=e.sc1?Rp("bookmark",{title:e.sc0===e.sc1?kp("Jafntefli"):kp("Sigur")}):Lp("bookmark",{title:kp("Tap")})),Fd("span.list-ts-short",e.ts_last_move),Fd("span.list-nick",e.opp_is_robot?[Rp("cog"),Np(),e.opp]:e.opp),Fd("span.list-s0",e.sc0),Fd("span.list-colon",":"),Fd("span.list-s1",e.sc1),Fd("div.list-elo-adj",i),Fd("div.list-elo-adj",n),Fd("span.list-duration",function(){let t="";return e.prefs?.duration?t=[Fd("span.timed-btn",{title:kp("Viðureign með klukku")}),` 2 x ${e.prefs.duration}${kp(" mínútur")}`]:(e.days||e.hours||e.minutes)&&(e.days>1?t=e.days.toString()+kp(" dagar"):1===e.days&&(t=kp("1 dagur")),e.hours>0&&(t.length&&(t+=kp(" og ")),1===e.hours?t+=kp("1 klst"):t+=e.hours.toString()+kp(" klst")),0===e.days&&(t.length&&(t+=kp(" og ")),1===e.minutes?t+=kp("1 mínúta"):t+=e.minutes.toString()+kp(" mínútur"))),t}()),Fd(vg,{manual:e.prefs?.manual})]))}return{view:t=>{const n=t.attrs.recentList;return Fd("div",{id:t.attrs.id},n?n.map(e):"")}}},am=e=>{const t=e.attrs.view,n=t.model;let i,r="";function s(){void 0!==i&&(i.result=!1,i=void 0);if("search"!==(n.userListCriteria?.query||"robots"))return void t.actions.searchUsers(r,!0);if(r===n.userListCriteria?.spec)return;const e={result:!0,p:new Promise(t=>{setTimeout(()=>{t(e.result)},800)})};i=e,i.p.then(e=>{e&&(t.actions.searchUsers(r,!0),i=void 0)})}return{view:()=>{const e=n.userListCriteria?.query||"robots";return Fd(".user-cat[id='user-search']",[Rp("search",{id:"search",className:"search"===e?"shown":"",onclick:()=>{r="",s(),document.getElementById("search-id")?.focus()}}),Np(),Fd("input.text.userid",{type:"text",id:"search-id",name:"search-id",maxlength:16,placeholder:kp("Einkenni eða nafn"),value:r,onfocus:()=>s(),oninput:e=>{r=`${e.target.value}`,s()}})])}}};function om(e,t,n){return[Fd(".settings-row",[Fd("span.settings-label",e),t]),n?Fd(".settings-explain",n):null]}const lm=()=>{let e=ag(),t=lg();function n(t){e=t,og(t)}function i(e){t=e,cg(e)}return{view:()=>Fd(".settings-tab",[Fd(".settings-section",[Fd(".settings-section-title",kp("Tækisstillingar")),om(kp("Þysja sjálfkrafa"),Fd(rf,{state:e,onToggle:n,id:"autozoom",title:kp("Þysja sjálfkrafa"),size:"small"}),kp("autozoom_explain")),om(kp("Eldri litasamsetning"),Fd(rf,{state:t,onToggle:i,id:"legacycolors",title:kp("Eldri litasamsetning"),size:"small"}),kp("legacy_colors_explain"))])])}},cm=()=>{let e=1;function t(e,t,n){var i=void 0===e?"":function(e,t=1e4){const n=e<0?"-":"";return(e=Math.abs(e))<t?`${n}${e}`:`${n}${e=Math.round(e/1e3)}K`}(e);return void 0!==n&&(i+=n),t?[Rp(t),Np(),i]:i}return{view:n=>{var i=n.attrs.ownStats,r=0,s=0,a=0,o=0;return void 0!==i&&void 0!==i.games&&void 0!==i.human_games&&(i.games>0&&(r=Math.round(100*(i.wins??0)/i.games),a=Math.round((i.score??0)/i.games)),i.human_games>0&&(s=Math.round(100*(i.human_wins??0)/i.human_games),o=Math.round((i.human_score??0)/i.human_games))),Fd("div",{id:n.attrs.id},[Fd(".toggler",{id:"own-toggler",title:kp("stats_choice"),onclick:t=>{e=3-e,t.preventDefault()}},[Fd(".option.small"+(1===e?".selected":""),{id:"opt1"},Rp("user")),Fd(".option.small"+(2===e?".selected":""),{id:"opt2"},Rp("cog"))]),1===e?Fd("div",{id:"own-stats-human",className:"stats-box",style:{display:"inline-block"}},[Fd(".stats-fig",{title:kp("Elo-stig")},i?t(i.locale_elo?.human_elo,"crown"):""),Fd(".stats-fig.stats-games",{title:kp("Fjöldi viðureigna")},i?t(i.human_games,"th"):""),Fd(".stats-fig.stats-win-ratio",{title:kp("Vinningshlutfall")},t(s,"bookmark","%")),Fd(".stats-fig.stats-avg-score",{title:kp("Meðalstigafjöldi")},t(o,"dashboard"))]):"",2===e?Fd("div",{id:"own-stats-all",className:"stats-box",style:{display:"inline-block"}},[Fd(".stats-fig",{title:kp("Elo-stig")},i?t(i.locale_elo?.elo,"crown"):""),Fd(".stats-fig.stats-games",{title:kp("Fjöldi viðureigna")},i?t(i.games,"th"):""),Fd(".stats-fig.stats-win-ratio",{title:kp("Vinningshlutfall")},t(r,"bookmark","%")),Fd(".stats-fig.stats-avg-score",{title:kp("Meðalstigafjöldi")},t(a,"dashboard"))]):""])}}},um="/page#!";function hm(e,t,n,i,r){const s=document.getElementById(t);if(!s)return;s.setAttribute("class","ui-tabs ui-widget ui-widget-content ui-corner-all");const a=document.querySelector(`#${t} > ul`);a&&(a.setAttribute("class","ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"),a.setAttribute("role","tablist"));const o=document.querySelectorAll(`#${t} > ul > li > a`),l=document.querySelectorAll(`#${t} > ul > li`),c=[],u=[];for(let e=0;e<o.length;e++){const t=o[e].getAttribute("href");if(!t)continue;c.push(t.slice(1)),o[e].onclick=t=>{pm(r,e),t.preventDefault()},o[e].removeAttribute("href"),o[e].classList.add("ui-tabs-anchor","sp"),o[e].setAttribute("role","presentation"),u.push(l[e]),l[e].classList.add("ui-state-default","ui-corner-top"),l[e].setAttribute("role","tab"),l[e].onmouseover=e=>{e.currentTarget.classList.toggle("ui-state-hover",!0)},l[e].onmouseout=e=>{e.currentTarget.classList.toggle("ui-state-hover",!1)};const n=document.getElementById(c[e]);n&&(n.setAttribute("class","ui-tabs-panel ui-widget-content ui-corner-bottom"),n.setAttribute("role","tabpanel"))}if(r.state.ids=c,r.state.lis=u,r.state.selected=0,i){const t=e.model,n=(e,t)=>{const n=t.slice(7),i=n.indexOf("?"),r=i>=0?n.slice(0,i):n,s=n.slice(r.length+1),a=s.length?function(e){const t=e.split("&"),n={};for(let e=0;e<t.length;e++){const i=t[e].split("=");2===i.length&&(n[i[0]]=decodeURIComponent(i[1]))}return n}(s):{};Fd.route.set(r,a),window.history&&window.history.pushState({},"",t),e.preventDefault()},i=n=>{t?.state?.netskraflUserId&&e.pushDialog("userprefs",{}),n.preventDefault()},a=e=>{pm(r,2),e.preventDefault()},o=e=>{pm(r,3),e.preventDefault()},l=s.querySelectorAll("a");for(let e=0;e<l.length;e++){const t=l[e],r=t.getAttribute("href");r&&r.slice(0,7)===um?t.onclick=e=>n(e,r):r&&"$$userprefs$$"===r?t.onclick=i:r&&"$$twoletter$$"===r?t.onclick=a:r&&"$$newbag$$"===r&&(t.onclick=o)}}n&&n(r),dm(r)}function dm(e){const t=e.state.selected,n=e.state.lis;for(let i=0;i<e.state.ids.length;i++){const r=e.state.ids[i];document.getElementById(r)?.setAttribute("style","display: "+(i===t?"block":"none")),n[i].classList.toggle("ui-tabs-active",i===t),n[i].classList.toggle("ui-state-active",i===t)}}function pm(e,t){e.state.selected=t,dm(e)}function gm(e){var t=Fd.route.param("tab");void 0!==t&&pm(e,parseInt(t,10)||0)}const fm={oninit:e=>{e.state.sel=e.attrs.sel},view:e=>Fd(".toggler[id='elo-toggler']",{title:kp("elo_list_choice")},[Fd(".option.x-small",{className:"human"===e.state.sel?"selected":"",onclick:t=>{e.state.sel="human",e.attrs.onchange(e.state.sel),t.preventDefault()}},Rp("user")),Fd(".option.x-small",{className:"all"===e.state.sel?"selected":"",onclick:t=>{e.state.sel="all",e.attrs.onchange(e.state.sel),t.preventDefault()}},Rp("cog")),Fd(".option.x-small",{className:"manual"===e.state.sel?"selected":"",onclick:t=>{e.state.sel="manual",e.attrs.onchange(e.state.sel),t.preventDefault()}},Rp("lightbulb"))])},mm=e=>{const{spec:t,view:n}=e.attrs;return{view:e=>Fd("div",[Fd(".listitem.listheader",[Fd("span.list-ch",Lp("hand-right",{title:kp("Skora á")})),Cp("span.list-rank","Röð"),Fd("span.list-rank-no-mobile",{title:kp("Röð í gær")},kp("1d")),Fd("span.list-rank-no-mobile",{title:kp("Röð fyrir viku")},kp("7d")),Cp("span.list-nick-elo","Einkenni"),Fd("span.list-elo",{title:kp("Elo-stig")},kp("Elo")),Fd("span.list-elo-no-mobile",{title:kp("Elo-stig í gær")},kp("1d")),Fd("span.list-elo-no-mobile",{title:kp("Elo-stig fyrir viku")},kp("7d")),Fd("span.list-elo-no-mobile",{title:kp("Elo-stig fyrir mánuði")},kp("30d")),Fd("span.list-games",{title:kp("Fjöldi viðureigna")},Rp("th")),Fd("span.list-ratio",{title:kp("Vinningshlutfall")},Rp("bookmark")),Fd("span.list-avgpts",{title:kp("Meðalstigafjöldi")},Rp("dashboard")),Cp("span.list-info-hdr","Ferill"),Fd(fm,{sel:t||"human",onchange:e=>{n.actions.withSpinner(()=>n.model.loadEloRatingList(e))}})]),Fd(vm,{id:e.attrs.id,sel:t,view:e.attrs.view})])}},vm=e=>{const t=e.attrs.view,n=t.model,i=n.state;return{view:e=>{const r=n.eloRatingList||[];return Fd("div",{id:e.attrs.id},r.map(function(n,r){const s=0===n.userid.indexOf("robot-");function a(e,t){return 0===e||void 0!==t&&0===t?"--":e.toString()}let o=n.nick,l=Fd("span.list-ch",Np());const c=i?.netskraflUserId??"";return n.userid===c||n.inactive||(l=Fd(pg,{view:t,item:n})),s&&(o=Fd("span",[Rp("cog"),Np(),o])),n.fairplay&&!s&&(o=Fd("span",[Fd("span.fairplay-btn",{title:kp("Skraflar án hjálpartækja")}),o])),Fd(".listitem",{key:(e.attrs.sel||"sel")+r,className:r%2==0?"oddlist":"evenlist"},[l,Fd("span.list-rank.bold",a(n.rank)),Fd("span.list-rank-no-mobile",a(n.rank_yesterday)),Fd("span.list-rank-no-mobile",a(n.rank_week_ago)),Fd("span.list-nick-elo",{title:n.fullname},o),Fd("span.list-elo.bold",n.elo),Fd("span.list-elo-no-mobile",a(n.elo_yesterday,n.games_yesterday)),Fd("span.list-elo-no-mobile",a(n.elo_week_ago,n.games_week_ago)),Fd("span.list-elo-no-mobile",a(n.elo_month_ago,n.games_month_ago)),Fd("span.list-games.bold",n.games>=1e5?`${Math.round(n.games/1e3)}K`:n.games),Fd("span.list-ratio",`${n.ratio}%`),Fd("span.list-avgpts",n.avgpts),n.userid===c?Np():Fd(gg,{view:t,item:n})])}))}}},ym=()=>{function e(e,t,n){const i=0===t.userid.indexOf("robot-"),r=[];function s(n){n.preventDefault(),function(){const t=e.model.moreGamesAllowed();if("allowed"===t)return!0;const n=e.model.state;return"limit_reached"===t?(n&&gh("hit_absolute_game_limit",{userid:n.netskraflUserId,locale:n.locale}),e.showGameLimitReached()):(n&&gh("hit_game_limit",{userid:n.netskraflUserId,locale:n.locale,limit:e.model.maxFreeGames}),e.showFriendPromo()),!1}()&&e.actions.startRobotGame(t.userid)}return t.ready&&!i&&(r.push(Fd("span.ready-btn",{title:kp("Álínis og tekur við áskorunum")})),r.push(Np())),t.ready_timed&&(r.push(Fd("span.timed-btn",{title:kp("Til í viðureign með klukku")})),r.push(Np())),t.fairplay&&(r.push(Fd("span.fairplay-btn",{title:kp("Skraflar án hjálpartækja")})),r.push(Np())),r.push(t.fullname),Fd(".listitem"+(n%2==0?".oddlist":".evenlist"),[Fd(pg,{view:e,item:t}),i?Fd("span.list-fav",{style:{cursor:"default"}},Rp("star-empty")):Fd("span.list-fav",{title:kp("Uppáhald"),onclick:n=>{e.actions.toggleFavorite(t.userid,t.fav),t.fav=!t.fav,n.preventDefault()}},Rp(t.fav?"star":"star-empty")),i?Fd("a",{href:"",onclick:s},[Fd("span.list-nick",[Rp("cog"),Np(),t.nick]),Fd("span.list-fullname-robot",r)]):[Fd("span.list-nick",t.nick),Fd("span.list-fullname",r),Fd("span.list-human-elo",t.human_elo)],Fd(gg,{view:e,item:t})])}return{view:t=>{const{view:n,id:i}=t.attrs,{model:r}=n,s=r.userListCriteria?.query??"",a=r.userListCriteria?.spec??"",o=void 0===r.eloRatingSpec,l=s||"robots";if("elo"===l||o)return[Fd(mm,{id:"elolist",view:n,spec:r.eloRatingSpec??null,key:"elopage"})];let c=[];void 0===r.userList||(null===r.userList||s!==l?n.actions.loadUsersByType(l,!0):c=r.userList);const u=0===c.length&&"search"===l&&""!==a,h="robots"===l;return[Fd(".listitem.listheader",[Fd("span.list-ch",Lp("hand-right",{title:kp("Skora á")})),Fd("span.list-fav",Rp("star-empty",{title:kp("Uppáhald")})),Cp("span.list-nick","Einkenni"),Cp("span.list-fullname","Nafn og merki"),h?"":Cp("span.list-human-elo[id='usr-list-elo']","Elo"),h?"":Cp("span.list-info-hdr[id='usr-list-info']","Ferill")]),Fd("div",{id:i},c.map((t,i)=>e(n,t,i))),u?Fd("div",{id:"user-no-match",style:{display:"block"}},[Rp("search")," ",Fd("span",{id:"search-prefix"},a),_p(" finnst ekki")]):void 0]}}},wm={view:e=>{const{view:t}=e.attrs,{model:n}=t,{numGames:i,numChallenges:r}=n;return[Fd(_g,{hidden:!0}),Fd("ul",[Fd("li",Fd("a[href='#tabs-1']",[Rp("th"),Fd("span.tab-legend",_p("Viðureignir")),Fd("span",{id:"numgames",style:i?"display: inline-block":""},i)])),Fd("li",Fd("a[href='#tabs-2']",[Rp("hand-right"),Fd("span.tab-legend",_p("Áskoranir")),Fd("span"+(n.oppReady?".opp-ready":""),{id:"numchallenges",style:r?"display: inline-block":""},r)])),Fd("li",Fd("a[href='#tabs-3']",[Rp("user"),Fd("span.tab-legend",_p("Andstæðingar"))])),Fd("li",Fd("a[href='#tabs-4']",[Rp("bookmark"),Fd("span.tab-legend",_p("Ferill"))])),Fd("li.mobile-only-list",Fd("a.sp.narrow[href='#tabs-5']",{title:kp("Stillingar")},[Rp("cog")]))])]}},bm={view:e=>{const{view:t}=e.attrs,{model:n}=t;return null===n.recentList&&n.loadRecentList(),[Fd(".listitem.listheader",[Fd("span.list-win",Lp("bookmark",{title:kp("Sigur")})),Cp("span.list-ts-short","Viðureign lauk"),Cp("span.list-nick","Andstæðingur"),Cp("span.list-scorehdr","Úrslit"),Fd("span.list-elo-hdr",[Fd("span.glyphicon.glyphicon-user.elo-hdr-left",{title:kp("Mennskir andstæðingar")}),_p("Elo"),Fd("span.glyphicon.glyphicon-cog.elo-hdr-right",{title:kp("Allir andstæðingar")})]),Cp("span.list-duration","Lengd"),Fd(vg,{header:!0})]),Fd(sm,{view:t,id:"recentlist",recentList:n.recentList||[]})]}},_m={view:e=>{const{view:t,buttonId:n,icon:i,text:r}=e.attrs,{model:s}=t,a=s.userListCriteria?.query||"robots";return Fd("span",{className:n===a?"shown":"",id:n,onclick:e=>{"elo"===n?(s.userListCriteria={query:"elo",spec:"human"},s.userList=null,t.actions.withSpinner(()=>s.loadEloRatingList("human"))):(t.actions.loadUsersByType(n,!0),s.eloRatingSpec=null,s.eloRatingList=null),e.preventDefault()}},[Rp(i,{style:{padding:0}}),Np(),r])}},km={view:e=>{const{view:t}=e.attrs,{model:n}=t,{ownStats:i}=n;return null===i&&n.loadOwnStats(),i?Fd(cm,{view:t,id:"own-stats",ownStats:i}):null}},Cm={view:e=>{const{view:t}=e.attrs,{model:n}=t,{ownStats:i}=n;return null===i&&n.loadOwnStats(),i?Fd(Qf,{id:"own-best",ownStats:i,myself:!0}):null}},Sm={view:e=>{const{view:t}=e.attrs;return Fd("div",{id:"tabs-1"},[Cp("p.no-mobile-block",[Cp("strong","Viðureignir sem standa yfir"),"click_on_game",Rp("flag")," þú átt leik"]),Fd(rm,{view:t,id:"gamelist"})])}},Tm={view:e=>{const{view:t}=e.attrs;return Fd("div",{id:"tabs-2"},[Cp("p.no-mobile-block",[Cp("strong","Skorað á þig"),"click_on_challenge",Rp("thumbs-down",{style:{"margin-left":"6px","margin-right":"6px"}})," til að hafna henni"]),Fd(tm,{view:t,showReceived:!0}),Cp("p.no-mobile-block",[Cp("strong","Þú skorar á aðra")," - smelltu á ",Rp("hand-right",{style:{"margin-left":"6px","margin-right":"6px"}})," til að afturkalla áskorun"]),Fd(tm,{view:t,showReceived:!1})])}},Im={view:e=>{const{view:t}=e.attrs;return Fd("div",{id:"tabs-3"},[Fd("div",{id:"initials"},[Fd(".user-cat[id='user-headings']",[Fd(_m,{view:t,buttonId:"robots",icon:"cog",text:kp("Þjarkar")})," ",Fd(_m,{view:t,buttonId:"fav",icon:"star",text:kp("Uppáhalds")})," ",Fd(_m,{view:t,buttonId:"live",icon:"flash",text:kp("Álínis")})," ",Fd(_m,{view:t,buttonId:"alike",icon:"resize-small",text:kp("Svipaðir")})," ",Fd(_m,{view:t,buttonId:"elo",icon:"crown",text:kp("Topp 100")})]),Fd(am,{view:t})]),Fd(ym,{view:t,id:"userlist"})])}},Em={view:e=>{const{view:t}=e.attrs;return Fd("div",{id:"tabs-4"},[Fd(km,{view:t}),Fd(Cm,{view:t}),Cp("p.no-mobile-block",[Cp("strong","Nýlegar viðureignir þínar"),"click_to_review"]),Fd(bm,{view:t})])}},Pm={view:e=>{const{view:t}=e.attrs;return Fd("div",{id:"tabs-5"},[Fd(lm,{view:t})])}},xm={view:e=>{const{view:t}=e.attrs;return Fd(".tabbed-page",Fd("div",{id:"main-tabs"},[Fd(wm,{view:t}),Fd("div.tab-scroll-area",[Fd(Sm,{view:t}),Fd(Tm,{view:t}),Fd(Em,{view:t}),Fd(Im,{view:t}),Fd(Pm,{view:t})])]))}},Rm={view:e=>{const{view:t}=e.attrs;return[Fd(bg,{hidden:!0}),Fd(mg,{view:t}),Fd(wg),Fd(Cg,{view:t}),Fd(Sg,{view:t}),Fd("div",{oncreate:e=>{hm(t,"main-tabs",void 0,!1,e)},onupdate:gm},Fd(xm,{view:t}))]}},Lm=(e,t,n)=>{const i=e.model.game;return Fd(".movelist-container",Fd(".movelist.bestmoves",function(){const r=[];if(!i||!t||t>i.moves.length)return r;const s=i.moves[t-1],[a,o,l]=s[1];r.push(function(e,n,i){let r,s="wordmove";if(e.length>0)r=[Fd("i",n.split("?").join("")),` (${e})`];else if(s="othermove","PASS"===n)r=kp("Pass");else if(0===n.indexOf("EXCH")){const e=n.slice(5).length,t=kp(1===e?"letter":"letters");r=kp("exchanged",{numtiles:e.toString(),letters:t})}else"RSGN"===n?r=kp("Gaf viðureign"):"CHALL"===n?r=kp("Véfengdi lögn"):"RESP"===n?r=kp(i<0?"Óleyfileg lögn":"Röng véfenging"):"TIME"===n?r=kp("Umframtími"):"OVER"===n?(r=kp("Viðureign lokið"),s="gameover"):(s="othermove",r="--"===n?kp("Stafaleif: engin"):[kp("Stafaleif: "),Fd("i.upper",n)]);return Fd(".reviewhdr",[Fd("span.movenumber",`#${t}`),Fd("span",{class:s},r)])}(a,o,l));const c=n;for(let n=0;n<c.length;n++){const[i,[s,a,o]]=c[n],l=Nm(e,t,n,c[n],{player:i,co:s,tiles:a,score:o});l&&r.push(l)}return r}()))},Nm=(e,t,n,i,r)=>{const s=e.model;if(!s.game)return;const a=s.game,{player:o,co:l,tiles:c,score:u}=r;function h(e,i,r,l){const c=zp(e);let u=c.col,h=c.row,d=!1;l&&(s.highlightedMove=n,a.placeTiles(t-1,!0));for(let e of i){if("?"===e){d=!0;continue}const t=Fp(h,u);if(null===t)continue;const n=e;d&&(e="?");const i=a.tilescore(e);l&&!(t in a.tiles)&&(a.tiles[t]={player:o,tile:e,letter:n,score:i,draggable:!1,freshtile:!1,index:0,xchg:!1,review:!0,highlight:r}),u+=c.dx,h+=c.dy,d=!1}l||(s.highlightedMove=null,null!==s.reviewMove&&a.placeTiles(s.reviewMove))}const d=`(${l})`,p=c.split("?").join("");let g=0;const f=a.player;let m;o===f||null===f&&0===o?m="humangrad"+(0===o?"_left":"_right"):(m="autoplayergrad"+(0===o?"_left":"_right"),g=1);const v={title:"Smelltu til að fletta upp"};return"is_IS"===a.locale&&(v.onclick=()=>{window.open(`https://malid.is/leit/${p}`,"malid")}),v.onmouseover=()=>{i[2]=!0,h(l,c,g,!0)},v.onmouseout=()=>{i[2]=!1,h(l,c,g,!1)},0===o?Fd(`.move.leftmove.${m}`,v,[Fd("span.score"+(i[2]?".highlight":""),u),Fd("span.wordmove",[Fd("i",p),Np(),d])]):Fd(`.move.rightmove.${m}`,v,[Fd("span.wordmove",[d,Np(),Fd("i",p)]),Fd("span.score"+(i[2]?".highlight":""),u)])},Dm=(e,t)=>{const n=e.model,i=n.game,r=i?.moves.length??0,s=[];if(!(i?.uuid??""))return s;if(s.push(Lg("navbtn",!t,()=>{n.loadBestMoves(t?t-1:0)},"Sjá fyrri leik",Fd("span",{id:"nav-prev-visible"},[Rp("chevron-left")," Fyrri"]),!0,"navprev")),s.push(Lg("navbtn",!t||t>=r,()=>{n.loadBestMoves(t+1)},"Sjá næsta leik",Fd("span",{id:"nav-next-visible"},["Næsti ",Rp("chevron-right")]),!0,"navnext")),null!==n.highlightedMove){const n=((e,t)=>{const n=e.model,i=n.game;if(!i)return;const r=[".scorediff"],s=t?i.moves[t-1]:void 0,a=s?s[1][2]:void 0;let o="";if(void 0===a||null===n.bestMoves||null===n.highlightedMove);else{const e=n.bestMoves[n.highlightedMove][1][2];o=(a-e).toString(),"-"!==o[0]&&"0"!==o[0]&&(o=`+${o}`),a>=e&&r.push("posdiff")}return Fd(r.join("."),{style:{visibility:"visible"}},o)})(e,t);void 0!==n&&s.push(n)}const a=((e,t)=>{const n=e.model.game;if(!n)return;const i=t?n.moves[t-1]:void 0;if(void 0===i)return;const[r,[s,a,o]]=i;if(void 0===o||""===s&&"OVER"===a)return;const l=[".score"];return t>0&&(t%2===(n.player??0)?l.push("opponent"):l.push("localplayer")),Fd(l.join("."),o.toString())})(e,t);return void 0!==a&&s.push(a),s},Am=e=>{const{view:t}=e.attrs;return{view:()=>{const e=[],{model:n}=t,{game:i}=n;if(i){const r=n.reviewMove??0,s=n.bestMoves||[];if(e.push(function(e,n,i){return Fd(".rightcol",[function(){const i=e.fairplay,r=e.player;let s="",a="";if(n){let t=0,i=0;for(let r=0;r<n;r++){const n=e.moves[r];r%2==0?t+=n[1][2]:i+=n[1][2]}s=t.toString(),a=i.toString()}return Fd(".heading",[Fd(".logowrapper",Fd(_g)),Fd(".playerwrapper",[Fd(".leftplayer"+(1===r?".autoplayercolor":".humancolor"),[Fd(".player",Fd(Hf,{view:t,side:"left"})),Fd(".scorewrapper",Fd(".scoreleft",s))]),Fd(".rightplayer"+(1===r?".humancolor":".autoplayercolor"),[Fd(".player",Fd(Hf,{view:t,side:"right"})),Fd(".scorewrapper",Fd(".scoreright",a))]),Fd(".fairplay",{style:{visibility:i?"visible":"hidden"}},Fd("span.fairplay-btn.large",{title:kp("Skraflað án hjálpartækja")}))])])}(),Fd(".right-area",Lm(t,n,i))])}(i,r,s)),e.push(Fd(Mm,{view:t,moveIndex:r})),null!==n.reviewMove&&0===r){const n=(e=>{if(null===e.model.game)return;const t=e.model.game;function n(e,n,i){let r=i;return void 0===r&&t.stats&&(r=t.stats[e]),void 0===r?"":("number"==typeof r?r=void 0!==n&&n>0?r.toFixed(n).replace(".",","):r.toString():Array.isArray(r)&&(r=`${r[0]} - ${r[1]}`),r)}let i,r;return null===t.stats&&t.loadStats(),1===t.player?(r="humancolor",i="autoplayercolor"):(i="humancolor",r="autoplayercolor"),Fd(".gamestats",{style:{visibility:"visible"}},[Fd("div",{style:{position:"relative",width:"100%"}},[Fd(".player.left",{class:i,style:{width:"50%"}},Fd(".robot-btn.left",t.autoplayer[0]?[Rp("cog"),Np(),t.nickname[0]]:t.nickname[0])),Fd(".player.right",{class:r,style:{width:"50%","text-align":"right"}},Fd(".robot-btn.right",t.autoplayer[1]?[Rp("cog"),Np(),t.nickname[1]]:t.nickname[1]))]),Fd("div",{id:"gamestarted"},[Fd("p",["Viðureignin hófst ",Fd("span",n("gamestart")),Fd("br"),"og henni lauk ",Fd("span",n("gameend"))]),t.manual?Fd("p","Leikið var í keppnisham"):""]),Fd(".statscol",{style:{clear:"left"}},[Fd("p",["Fjöldi leikja: ",Fd("span",n("moves0"))]),Fd("p",["Fjöldi bingóa: ",Fd("span",n("bingoes0"))," (bónus ",Fd("span",n("bingopoints0",0,t.stats?50*t.stats.bingoes0:0))," stig)"]),Fd("p",["Stafir lagðir niður: ",Fd("span",n("tiles0"))," (þar af ",Fd("span",n("blanks0"))," auðir)"]),Fd("p",["Meðalstig stafa (án auðra): ",Fd("span",n("average0",2))]),Fd("p",["Samanlögð stafastig: ",Fd("span",n("letterscore0"))]),Fd("p",["Margföldun stafastiga: ",Fd("span",n("multiple0",2))]),Fd("p",["Stig án stafaleifar í lok: ",Fd("span",n("cleantotal0"))]),Fd("p",["Meðalstig hvers leiks: ",Fd("span",n("avgmove0",2))]),t.manual?Fd("p",["Rangar véfengingar andstæðings x 10: ",Fd("span",n("wrongchall0"))]):"",Fd("p",["Stafaleif og frádráttur í lok: ",Fd("span",n("remaining0"))]),Fd("p",["Umframtími: ",Fd("span",n("overtime0"))]),Fd("p",["Stig: ",Fd("span",n("total0",0,t.stats?t.stats.scores[0]:0))," (",Fd("span",n("ratio0",1)),"%)"])]),Fd(".statscol",[Fd("p",["Fjöldi leikja: ",Fd("span",n("moves1"))]),Fd("p",["Fjöldi bingóa: ",Fd("span",n("bingoes1"))," (bónus ",Fd("span",n("bingopoints0",0,t.stats?50*t.stats.bingoes1:0))," stig)"]),Fd("p",["Stafir lagðir niður: ",Fd("span",n("tiles1"))," (þar af ",Fd("span",n("blanks1"))," auðir)"]),Fd("p",["Meðalstig stafa (án auðra): ",Fd("span",n("average1",2))]),Fd("p",["Samanlögð stafastig: ",Fd("span",n("letterscore1"))]),Fd("p",["Margföldun stafastiga: ",Fd("span",n("multiple1",2))]),Fd("p",["Stig án stafaleifar í lok: ",Fd("span",n("cleantotal1"))]),Fd("p",["Meðalstig hvers leiks: ",Fd("span",n("avgmove1",2))]),t.manual?Fd("p",["Rangar véfengingar andstæðings x 10: ",Fd("span",n("wrongchall1"))]):"",Fd("p",["Stafaleif og frádráttur í lok: ",Fd("span",n("remaining1"))]),Fd("p",["Umframtími: ",Fd("span",n("overtime1"))]),Fd("p",["Stig: ",Fd("span",n("total1",0,t.stats?t.stats.scores[1]:0))," (",Fd("span",n("ratio1",1)),"%)"])]),Fd(".closebtn",{id:"review-close",onclick:e=>{setTimeout(()=>{Fd.route.set(`/review/${t.uuid}`,{move:1})}),e.preventDefault()},onmouseover:Pp,onmouseout:xp},[Rp("play")," Rekja"])])})(t);n&&e.push(n)}}return Fd("div",[Fd(".game-container",e),Fd(bg),Fd(wg)])}}},Mm={view:e=>{const{view:t}=e.attrs,n=t.model.game;let i=[];if(n){i=[Fd(Kg,{view:t,game:n,review:!0}),Fd(Vg,{view:t,game:n,review:!0})];const r=e.attrs.moveIndex;null!==r&&(i=i.concat(Dm(t,r)))}return Fd(".board-area",i)}},Om=(e,t)=>{if(t.loadingRecentList)return;t.loadingRecentList=!0;const{model:n}=e.view;n.loadUserRecentList(e.userid,t.versusAll?null:n.state?.netskraflUserId??"",e=>{e&&0===e.result?t.recentList=e.recentlist:t.recentList=[],t.loadingRecentList=!1})},jm=(e,t,n)=>{t.versusAll!==n&&(t.versusAll=n,t.loadingRecentList=!1,Om(e,t))},Fm={oninit:e=>{const{attrs:t,state:n}=e;n.stats={},n.recentList=[],n.versusAll=!0,n.loadingRecentList=!1,n.loadingStats=!1,Om(t,n),((e,t)=>{if(t.loadingStats)return;t.loadingStats=!0;const{model:n}=e.view;n.loadUserStats(e.userid,e=>{e&&0===e.result?t.stats=e:t.stats={},t.loadingStats=!1})})(t,n)},view:e=>{const{attrs:t,state:n}=e,{view:i}=t,{stats:r,recentList:s,versusAll:a}=n;return Fd(".modal-dialog",{id:"usr-info-dialog",style:{visibility:"visible"}},Fd(".ui-widget.ui-widget-content.ui-corner-all",{id:"usr-info-form"},[Fd(".usr-info-hdr",[Fd("h1.usr-info-icon",[e.state.stats.friend?Rp("coffee-cup",{title:kp("Áskrifandi")}):Rp("user"),Np()]),Fd("h1[id='usr-info-nick']",e.attrs.nick),Fd("span.vbar","|"),Fd("h2[id='usr-info-fullname']",e.attrs.fullname),Fd(".usr-info-fav",{title:kp("Uppáhald"),onclick:t=>{t.preventDefault(),i.actions.toggleFavorite(e.attrs.userid,r.favorite??!1),r.favorite=!r.favorite}},r.favorite?Rp("star"):Rp("star-empty"))]),Fd("p",[Fd("strong",_p("Nýjustu viðureignir")),Np(),Fd("span.versus-cat",[Fd("span",{class:a?"shown":"",onclick:()=>{jm(t,n,!0)}},_p(" gegn öllum ")),Fd("span",{class:a?"":"shown",onclick:()=>{jm(t,n,!1)}},_p(" gegn þér "))])]),Fd(".listitem.listheader",[Fd("span.list-win",Lp("bookmark",{title:kp("Sigur")})),Cp("span.list-ts-short","Viðureign lauk"),Cp("span.list-nick","Andstæðingur"),Cp("span.list-scorehdr","Úrslit"),Fd("span.list-elo-hdr",[Fd("span.glyphicon.glyphicon-user.elo-hdr-left",{title:kp("Mennskir andstæðingar")}),"Elo",Fd("span.glyphicon.glyphicon-cog.elo-hdr-right",{title:kp("Allir andstæðingar")})]),Cp("span.list-duration","Lengd"),Fd(vg,{header:!0})]),Fd(sm,{view:i,id:"usr-recent",recentList:s}),Fd(cm,{view:i,id:"usr-stats",ownStats:r}),Fd(Qf,{id:"usr-best",ownStats:r,myself:!1}),Fd(dg,{id:"usr-info-close",title:kp("Loka"),onclick:e=>{i.popDialog(),e.preventDefault()}},Rp("ok"))]))}},zm=e=>{const{view:t}=e.attrs,{model:n}=t;function i(e){const t=(n.userErrors||{})[e]||"";return t?Fd(".errinput",[Rp("arrow-up"),Np(),t]):""}function r(e){const t=document.querySelector(`#${e}-toggler #opt2`)?.classList;return!!t&&t.contains("selected")}function s(){const e=n.user;e&&(e.nickname=Ap("nickname"),e.full_name=Ap("full_name"),e.audio=r("audio"),e.fanfare=r("fanfare"),e.beginner=r("beginner"),e.fairplay=r("fairplay"),n.saveUser(()=>{t.popDialog()}))}function a(e){e.dom.querySelector("#nickname").focus()}function o(e,t,n,i,r){return Fd(dg,{id:e,onclick:n,title:t,tabindex:r},i)}return{view:()=>{if(!n.user)return;const e=n.user;if(!n.state)return;const r=n.state;return Fd(".modal-dialog",{key:"userprefs",id:"user-dialog",oncreate:a},Fd(".ui-widget.ui-widget-content.ui-corner-all",{id:"user-form"},[Fd(".loginhdr",[Rp("address-book"),` ${kp("player_info")}`]),Fd("div",Fd("form",{action:"",id:"frm1",method:"post",name:"frm1"},[Fd(".dialog-spacer",[Fd("span.caption",_p("Einkenni:")),Fd(hg,{initialValue:e.nickname||"",class:"username",maxlength:15,id:"nickname"}),Np(),Fd("span.asterisk","*")]),Fd(".explain",_p("Verður að vera útfyllt")),i("nickname"),Fd(".dialog-spacer",[Fd("span.caption",_p("Fullt nafn:")),Fd(hg,{initialValue:e.full_name||"",class:"fullname",maxlength:32,id:"full_name",autocomplete:"name"})]),Fd(".explain",_p("Valfrjálst - sýnt í notendalistum Netskrafls")),i("full_name"),Fd(".dialog-spacer",[Fd("span.caption.sub",_p("Hljóðmerki:")),Fd(Tg,{view:t,state:e.audio,tabindex:4}),Fd("span.subcaption",_p("Lúðraþytur eftir sigur:")),Fd(Ig,{view:t,state:e.fanfare,tabindex:5})]),Fd(".explain",_p("explain_sound")),Fd(".dialog-spacer",[Fd("span.caption.sub",_p("Sýna reitagildi:")),Fd(Eg,{view:t,state:e.beginner,tabindex:6}),Cp(".subexplain",["Stillir hvort ",Cp("strong","minnismiði")," um margföldunargildi reita er sýndur við borðið"])]),Fd(".dialog-spacer",[Fd("span.caption.sub",_p("Án hjálpartækja:")),Fd(Pg,{view:t,state:e.fairplay,tabindex:7}),Cp(".subexplain",["no_helpers",Cp("strong","án stafrænna hjálpartækja")," af nokkru tagi"])]),Fd(".dialog-spacer",[Fd("span.caption.sub",_p("Eldri litasamsetning:")),Fd(xg,{tabindex:8}),Cp(".subexplain",[_p("use_original"),Cp("strong",_p("upprunalegu")),_p(" litina frá eldri útgáfu Netskrafls")])])])),o("user-ok",kp("Vista"),s,Rp("ok"),9),o("user-cancel",kp("Hætta við"),e=>{t.popDialog(),e.preventDefault()},Rp("remove"),10),e.friend?o("user-unfriend",kp("Þú ert áskrifandi!"),e=>{e.preventDefault()},[Rp("coffee-cup"),kp("Þú ert áskrifandi!")],11):o("user-friend",kp("Gerast áskrifandi"),e=>{e.preventDefault(),gh("click_friend",{userid:r.netskraflUserId,locale:r.locale}),window.location.href=r.subscriptionUrl},[Rp("coffee-cup"),Np(),Np(),kp("Gerast áskrifandi")],12)]))}}},Um={oninit:e=>{const{state:t}=e;t.oppOnline=!1,t.pointOfNoReturn=!1,t.firebasePath=""},oncreate:e=>{const{attrs:t,state:n}=e,{view:i,oppId:r,challengeKey:s}=t,{model:a}=i,o=a.state,l=a.state?.netskraflUserId??"";if(!l||!r)return;n.firebasePath=`user/${l}/wait/${r}`;(async()=>{try{if(s&&o){const e=await ip(o,{method:"POST",url:"/initwait",body:{opp:r,key:s}});e?.online&&e.waiting&&(n.oppOnline=!0)}}catch(e){}})(),dh(n.firebasePath,e=>{!0!==e&&e.game&&(n.pointOfNoReturn=!0,ph(n.firebasePath),Fd.route.set(`/game/${e.game}`))})},view:e=>{const{attrs:t,state:n}=e,{view:i,oppId:r,duration:s,challengeKey:a,oppNick:o,oppName:l}=t,{model:c}=i,u=c.state,h=c.state?.netskraflUserId??"";if(!u)return null;return Fd(".modal-dialog",{id:"wait-dialog",style:{visibility:"visible"}},Fd(".ui-widget.ui-widget-content.ui-corner-all",{id:"wait-form"},[Fd(".chall-hdr",Fd("table",Fd("tbody",Fd("tr",[Fd("td",Fd("h1.chall-icon",Rp("time"))),Fd("td.l-border",[Fd(fg,{id:"chall-online",userId:r,online:n.oppOnline,state:u}),Fd("h1",o),Fd("h2",l)])])))),Fd(".wait-explain",[Cp("p",["Þú ert reiðubúin(n) að taka áskorun um viðureign með klukku,"]),Fd("p",[Fd("strong",["2 x ",s.toString(),kp(" mínútur.")])]),Cp("p",["Beðið er eftir að áskorandinn ",Fd("strong",o)," sé ",n.oppOnline?"":Cp("span#chall-is-online","álínis og "),"til í tuskið."]),Cp("p","Leikur hefst um leið og áskorandinn bregst við. Handahóf ræður hvor byrjar."),Cp("p","Ef þér leiðist biðin geturðu hætt við og reynt aftur síðar.")]),Fd(dg,{id:"wait-cancel",title:kp("Hætta við"),onclick:e=>{n.pointOfNoReturn||(n.firebasePath&&ph(n.firebasePath),(async()=>{if(u)try{ip(u,{method:"POST",url:"/cancelwait",body:{user:h,opp:r,key:a}})}catch(e){}})(),i.popDialog()),e.preventDefault()}},Rp("remove"))]))}},$m={oninit:async e=>{const{attrs:t,state:n}=e,{view:i,oppId:r,challengeKey:s}=t,a=i.model.state;if(a){n.oppReady=!0;try{const e=await ip(a,{method:"POST",url:"/waitcheck",body:{user:r,key:s}});e?.waiting?i.actions.startNewGame(r,!0):n.oppReady=!1}catch(e){n.oppReady=!1}}},view:e=>{const{attrs:t,state:n}=e,{view:i,oppNick:r}=t;return Fd(".modal-dialog",{id:"accept-dialog",style:{visibility:"visible"}},Fd(".ui-widget.ui-widget-content.ui-corner-all",{id:"accept-form"},[Fd(".chall-hdr",Fd("table",Fd("tbody",Fd("tr",[Fd("td",Fd("h1.chall-icon",Rp("time"))),Fd("td.l-border",Fd("h1",r))])))),Fd("div",{style:{"text-align":"center","padding-top":"32px"}},[Fd("p",Cp("strong","Viðureign með klukku")),Cp("p",n.oppReady?"Athuga hvort andstæðingur er reiðubúinn...":["Andstæðingurinn ",Fd("strong",r)," er ekki reiðubúinn"])]),Fd(dg,{id:"accept-cancel",title:kp("Reyna síðar"),onclick:e=>{i.popDialog(),e.preventDefault()}},Rp("remove"))]))}};class qm{get model(){return this.actions.model}constructor(e){this.dialogStack=[],this.boardScale=1,this.zoomAnimationTimeout=null,this.selectedTab="movelist",this.actions=e,this.actions.initMediaListener(this);const t=this.model.state;t&&(t.onFirebaseReady=()=>{this.actions.attachListenerToUser()}),this.model.loadUser(!1)}appView(e){const t=this.model,n=[];switch(e){case"main":n.push(Fd(Rm,{key:"main",view:this}));break;case"game":n.push(Fd(Xf,{key:"game",view:this}));break;case"review":n.push(Fd(Am,{key:"review",view:this}));break;case"help":n.push(this.vwHelp(parseInt(Fd.route.param("tab")||"",10),parseInt(Fd.route.param("faq")||"",10)));break;default:return[Fd("div",{key:"error"},_p("Þessi vefslóð er ekki rétt"))]}for(const e of this.dialogStack){const t=qm.dialogViews[e.name];if(void 0===t)console.error(`Unknown dialog name: ${e.name}`);else{const i=t(this,e.args);i&&n.push(i)}}return t.spinners&&n.push(Fd(ug,{key:"spinner"})),n}isFullScreen(){return this.model.state?.uiFullscreen||!1}isMobile(){return!this.model.state?.uiFullscreen}pushDialog(e,t){this.dialogStack.push({name:e,args:t}),Fd.redraw()}popDialog(){this.dialogStack.length>0&&(this.dialogStack.pop(),Fd.redraw())}popAllDialogs(){this.dialogStack.length>0&&(this.dialogStack=[],Fd.redraw())}isDialogShown(){return this.dialogStack.length>0}startSpinner(){this.actions.showSpinner()}stopSpinner(){this.actions.hideSpinner()}notifyMediaChange(){const e=this.model;e.state?.uiFullscreen||e.state?.uiLandscape?this.setSelectedTab("movelist")&&setTimeout(jp):this.setSelectedTab("board"),this.popAllDialogs()}notifyChatMessage(){Fd.redraw()}zoomIn(){this.boardScale=op}zoomOut(){1!==this.boardScale&&(this.boardScale=1,setTimeout(()=>this.resetScale()))}resetScale(){null!==this.zoomAnimationTimeout&&(clearTimeout(this.zoomAnimationTimeout),this.zoomAnimationTimeout=null),this.boardScale=1;const e=document.getElementById("board-parent"),t=e?.children[0];t&&(t.style.transition="none",t.style.transform="translate(0px, 0px) scale(1)"),e&&e.scrollTo(0,0)}updateScale(){if(!ag())return;const e=this.model,t=e.game||e.riddle,n=e=>{const t=document.getElementById("board-parent"),n=t?.children[0];if(!n||!t)return;const i=zp(e),r=Fp(Math.max(0,i.row-3),Math.max(0,i.col-3)),s=document.getElementById(`sq_${r}`),a=s?.getBoundingClientRect(),o=t.getBoundingClientRect();if(a&&o){const e=t.clientWidth,i=t.clientHeight,r=n.offsetWidth*op-e,s=n.offsetHeight*op-i,l=Math.min(a.left-o.left,r),c=Math.min(a.top-o.top,s);null!==this.zoomAnimationTimeout&&(clearTimeout(this.zoomAnimationTimeout),this.zoomAnimationTimeout=null),n.style.transition="transform 0.3s ease-in-out";const u=`${-l}px, ${-c}px`,h="1.5";n.style.transform=`translate(${u}) scale(${h})`,this.zoomAnimationTimeout=setTimeout(()=>{this.zoomAnimationTimeout=null,n.style.transition="none",n.style.transform="translate(0px, 0px) scale(1.5)",requestAnimationFrame(()=>{t.scrollTo(l,c)})},350)}};if(!t||e.state?.uiFullscreen||t.moveInProgress)return this.boardScale=1,void setTimeout(()=>this.resetScale());const i=t.tilesPlaced(),r=i.length;1===r&&1===this.boardScale?(this.boardScale=op,setTimeout(()=>n(i[0]))):0===r&&this.boardScale>1&&(this.boardScale=1,setTimeout(()=>this.resetScale()))}showUserInfo(e,t,n){this.pushDialog("userinfo",{userid:e,nick:t,fullname:n})}showFriendPromo(){this.pushDialog("friend",{})}showGameLimitReached(){this.pushDialog("gamelimit",{})}showAcceptDialog(e,t,n){this.pushDialog("accept",{oppId:e,oppNick:t,challengeKey:n})}setSelectedTab(e){const t=this.model.state;return"board"===e&&(t?.uiFullscreen||t?.uiLandscape)&&(e="movelist"),this.selectedTab!==e&&(this.selectedTab=e,"chat"!==e&&$p(),!0)}vwTabsFromHtml(e,t,n,i){return e?Fd("div.help-tabs",{oncreate:e=>{hm(this,t,i,!0,e)},oninit:e=>{e.state.selected=n||1}},Fd.trust(e)):""}vwHelp(e,t){const n=this.model;return Fd.fragment({key:"help"},[Fd(bg),Fd(mg,{view:this}),this.vwTabsFromHtml(n.helpHTML||"","tabs",e,function(e){function n(t,n){e.state.selected=1,e.dom.querySelector(n)?.scrollIntoView(),t.preventDefault()}const i=e.dom.querySelectorAll("a");for(const e of i){const t=e.getAttribute("href");t&&"#faq-"===t.slice(0,5)&&(e.onclick=e=>{n(e,t)})}void 0===t||Number.isNaN(t)||(pm(e,1),e.state.selected=1,e.dom.querySelector(`#faq-${t.toString()}`)?.scrollIntoView())})])}vwUserPrefs(){const e=this.model;return null!==e.user||e.userLoadError||e.loadUser(!0),e.user?Fd(zm,{key:"userprefs",view:this}):Fd.fragment({key:"userprefs-empty"},[])}vwWait(e){return Fd(Um,{key:`wait-${e.challengeKey}`,view:this,oppId:e.oppId,oppNick:e.oppNick,oppName:e.oppName,duration:e.duration,challengeKey:e.challengeKey})}vwAccept(e){return Fd($m,{key:`accept-${e.challengeKey}`,view:this,oppId:e.oppId,oppNick:e.oppNick,challengeKey:e.challengeKey})}vwDialogs(){return Fd(Uf,{view:this})}}qm.dialogViews={userprefs:e=>e.vwUserPrefs(),userinfo:(e,t)=>Fd(Fm,{key:`userinfodialog-${t.userid}`,view:e,userid:t.userid,nick:t.nick,fullname:t.fullname}),challenge:(e,t)=>Fd(jf,{key:"challenge",view:e,item:t}),friend:e=>Fd(Ff,{key:"friend",view:e}),gamelimit:e=>Fd(zf,{key:"gamelimit",view:e}),wait:(e,t)=>e.vwWait(t),accept:(e,t)=>e.vwAccept(t)};let Bm=null;const Vm=(e,t)=>{const{userEmail:n}=e;return n?async function(e,t){if(!t)return console.error("No container element found"),"error";try{const n=Mf(),i=new Of(n,e),r=new Vp(i),s=new qm(r);Bm&&Bm.cleanup(),Bm=r;const a=new URLSearchParams(window.location.search).get("date"),o=(new Date).toISOString().split("T")[0],l=a||o,c=/^\d{4}-\d{2}-\d{2}$/.test(l)?l:o,u=e.locale||"is_IS";Fd.mount(t,{view:()=>Fd(mf,{view:s,date:c,locale:u})}),qp(e=>{const t=i.riddle;t&&wf(t,s,e)},e=>{const t=i.riddle;t&&bf(t,s,e)})}catch(e){return console.error("Exception during initialization: ",e),"error"}return"success"}(e,t).then(e=>{if("success"!==e)throw new Error("Failed to mount Gáta Dagsins UI")}):Promise.reject(new Error("No user specified for Gáta Dagsins UI"))},Hm=t.memo(({state:i,tokenExpired:r})=>{const s=t.useRef(null),o=t.useRef(!1),{userEmail:l}=i;return n(()=>{if(!l)return;const e=s.current;if(!e)return void console.error("No container for Gáta Dagsins UI");const t=a({...i,tokenExpired:r});return Vm(t,e).then(()=>{o.current=!0}).catch(e=>{console.error("Failed to mount Gáta Dagsins UI:",e)}),()=>{o.current&&(!function(e){Bm&&(Bm.cleanup(),Bm=null),Fd.mount(e,null),e.innerHTML="";const t=document.body.querySelectorAll("#netskrafl-background, #gatadagsins-background");for(const e of t)e.remove()}(e),o.current=!1)}},[l]),e("div",{className:"gatadagsins",children:e("div",{className:"netskrafl-container",children:e("div",{className:"netskrafl-inner",id:"gatadagsins-container",ref:s})})})});let Wm=null;const Gm=(e,t)=>{const{userEmail:n}=e;return n?async function(e,t){if(!t)return console.error("No container element found"),"error";try{const n=Mf(),i=new Of(n,e),r=new Vp(i),s=new qm(r);Wm&&Wm.cleanup(),Wm=r,qp(e=>{const t=i.game;t&&wf(t,s,e)},e=>{const t=i.game;t&&bf(t,s,e)});const a=function(e,t){return e.model.paths.reduce((n,i)=>(n[i.route]={onmatch:n=>{t.popAllDialogs(),t.resetScale(),e.onNavigateTo(i.name,n,t)},render:()=>t.appView(i.name)},n),{})}(r,s);Fd.route(t,n.defaultRoute,a),Bp(lg())}catch(e){return console.error("Exception during initialization: ",e),"error"}return"success"}(e,t).then(e=>{if("success"!==e)throw new Error("Failed to mount Netskrafl UI")}):Promise.reject(new Error("No user specified for Netskrafl UI"))},Km=t.memo(({state:i,tokenExpired:r})=>{const s=t.useRef(null),o=t.useRef(!1),{userEmail:l}=i;return n(()=>{if(!l)return;const e=s.current;if(!e)return void console.error("No container for Netskrafl UI");const t=a({...i,tokenExpired:r});return Gm(t,e).then(()=>{o.current=!0}).catch(e=>{console.error("Failed to mount Netskrafl UI:",e)}),()=>{o.current&&(!function(e){Wm&&(Wm.cleanup(),Wm=null),Fd.mount(e,null),e.innerHTML="",document.body.querySelectorAll("#netskrafl-background, #gatadagsins-background").forEach(e=>{e.remove()})}(e),o.current=!1)}},[l]),e("div",{className:"netskrafl",children:e("div",{className:"netskrafl-container",children:e("div",{className:"netskrafl-inner",id:"netskrafl-container",ref:s})})})});export{Hm as GataDagsins,Km as Netskrafl};
|
|
3028
|
+
//# sourceMappingURL=index.js.map
|