@mideind/netskrafl-react 2.3.0 → 2.4.0

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/index.js CHANGED
@@ -162,7 +162,7 @@ function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window
162
162
  * See the License for the specific language governing permissions and
163
163
  * limitations under the License.
164
164
  */
165
- function W(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function G(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function K(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function Y(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 J(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(X(n)&&X(s)){if(!J(n,s))return!1}else if(n!==s)return!1}for(const e of i)if(!n.includes(e))return!1;return!0}function X(e){return null!==e&&"object"==typeof e}
165
+ function W(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function G(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function K(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function Y(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 J(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(Z(n)&&Z(s)){if(!J(n,s))return!1}else if(n!==s)return!1}for(const e of i)if(!n.includes(e))return!1;return!0}function Z(e){return null!==e&&"object"==typeof e}
166
166
  /**
167
167
  * @license
168
168
  * Copyright 2017 Google LLC
@@ -178,7 +178,7 @@ function W(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function G(e,t)
178
178
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
179
179
  * See the License for the specific language governing permissions and
180
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("&"):""}
181
+ */function X(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
182
  /**
183
183
  * @license
184
184
  * Copyright 2017 Google LLC
@@ -307,7 +307,7 @@ function W(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function G(e,t)
307
307
  * See the License for the specific language governing permissions and
308
308
  * limitations under the License.
309
309
  */
310
- class De{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 Ae="@firebase/app",Me="0.14.5",Oe=new fe("@firebase/app"),je="@firebase/app-compat",Fe="@firebase/analytics-compat",Ue="@firebase/analytics",ze="@firebase/app-check-compat",$e="@firebase/app-check",qe="@firebase/auth",Ve="@firebase/auth-compat",Be="@firebase/database",He="@firebase/data-connect",We="@firebase/database-compat",Ge="@firebase/functions",Ke="@firebase/functions-compat",Ye="@firebase/installations",Je="@firebase/installations-compat",Xe="@firebase/messaging",Ze="@firebase/messaging-compat",Qe="@firebase/performance",et="@firebase/performance-compat",tt="@firebase/remote-config",nt="@firebase/remote-config-compat",it="@firebase/storage",rt="@firebase/storage-compat",st="@firebase/firestore",ot="@firebase/ai",at="@firebase/firestore-compat",lt="firebase",ct="[DEFAULT]",ut={[Ae]:"fire-core",[je]:"fire-core-compat",[Ue]:"fire-analytics",[Fe]:"fire-analytics-compat",[$e]:"fire-app-check",[ze]:"fire-app-check-compat",[qe]:"fire-auth",[Ve]:"fire-auth-compat",[Be]:"fire-rtdb",[He]:"fire-data-connect",[We]:"fire-rtdb-compat",[Ge]:"fire-fn",[Ke]:"fire-fn-compat",[Ye]:"fire-iid",[Je]:"fire-iid-compat",[Xe]:"fire-fcm",[Ze]:"fire-fcm-compat",[Qe]:"fire-perf",[et]:"fire-perf-compat",[tt]:"fire-rc",[nt]:"fire-rc-compat",[it]:"fire-gcs",[rt]:"fire-gcs-compat",[st]:"fire-fst",[at]:"fire-fst-compat",[ot]:"fire-vertex","fire-js":"fire-js",[lt]:"fire-js-all"},ht=new Map,dt=new Map,pt=new Map;function gt(e,t){try{e.container.addComponent(t)}catch(n){Oe.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function ft(e){const t=e.name;if(pt.has(t))return Oe.debug(`There were multiple attempts to register component ${t}.`),!1;pt.set(t,e);for(const t of ht.values())gt(t,e);for(const t of dt.values())gt(t,e);return!0}function mt(e,t){const n=e.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function vt(e){return null!=e&&void 0!==e.settings}
310
+ class De{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 Ae="@firebase/app",Me="0.14.5",Oe=new fe("@firebase/app"),je="@firebase/app-compat",Fe="@firebase/analytics-compat",Ue="@firebase/analytics",ze="@firebase/app-check-compat",$e="@firebase/app-check",qe="@firebase/auth",Ve="@firebase/auth-compat",Be="@firebase/database",He="@firebase/data-connect",We="@firebase/database-compat",Ge="@firebase/functions",Ke="@firebase/functions-compat",Ye="@firebase/installations",Je="@firebase/installations-compat",Ze="@firebase/messaging",Xe="@firebase/messaging-compat",Qe="@firebase/performance",et="@firebase/performance-compat",tt="@firebase/remote-config",nt="@firebase/remote-config-compat",it="@firebase/storage",rt="@firebase/storage-compat",st="@firebase/firestore",ot="@firebase/ai",at="@firebase/firestore-compat",lt="firebase",ct="[DEFAULT]",ut={[Ae]:"fire-core",[je]:"fire-core-compat",[Ue]:"fire-analytics",[Fe]:"fire-analytics-compat",[$e]:"fire-app-check",[ze]:"fire-app-check-compat",[qe]:"fire-auth",[Ve]:"fire-auth-compat",[Be]:"fire-rtdb",[He]:"fire-data-connect",[We]:"fire-rtdb-compat",[Ge]:"fire-fn",[Ke]:"fire-fn-compat",[Ye]:"fire-iid",[Je]:"fire-iid-compat",[Ze]:"fire-fcm",[Xe]:"fire-fcm-compat",[Qe]:"fire-perf",[et]:"fire-perf-compat",[tt]:"fire-rc",[nt]:"fire-rc-compat",[it]:"fire-gcs",[rt]:"fire-gcs-compat",[st]:"fire-fst",[at]:"fire-fst-compat",[ot]:"fire-vertex","fire-js":"fire-js",[lt]:"fire-js-all"},ht=new Map,dt=new Map,pt=new Map;function gt(e,t){try{e.container.addComponent(t)}catch(n){Oe.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function ft(e){const t=e.name;if(pt.has(t))return Oe.debug(`There were multiple attempts to register component ${t}.`),!1;pt.set(t,e);for(const t of ht.values())gt(t,e);for(const t of dt.values())gt(t,e);return!0}function mt(e,t){const n=e.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function vt(e){return null!=e&&void 0!==e.settings}
311
311
  /**
312
312
  * @license
313
313
  * Copyright 2019 Google LLC
@@ -502,7 +502,7 @@ const Yt=/^[cdef][\w-]{21}$/;function Jt(){try{const e=new Uint8Array(17);(self.
502
502
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
503
503
  * See the License for the specific language governing permissions and
504
504
  * limitations under the License.
505
- */(e);return Yt.test(t)?t:""}catch{return""}}function Xt(e){return`${e.appName}!${e.appId}`}
505
+ */(e);return Yt.test(t)?t:""}catch{return""}}function Zt(e){return`${e.appName}!${e.appId}`}
506
506
  /**
507
507
  * @license
508
508
  * Copyright 2019 Google LLC
@@ -518,7 +518,7 @@ const Yt=/^[cdef][\w-]{21}$/;function Jt(){try{const e=new Uint8Array(17);(self.
518
518
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
519
519
  * See the License for the specific language governing permissions and
520
520
  * limitations under the License.
521
- */const Zt=new Map;function Qt(e,t){const n=Xt(e);en(n,t),function(e,t){const n=function(){!tn&&"BroadcastChannel"in self&&(tn=new BroadcastChannel("[Firebase] FID Change"),tn.onmessage=e=>{en(e.data.key,e.data.fid)});return tn}();n&&n.postMessage({key:e,fid:t});0===Zt.size&&tn&&(tn.close(),tn=null)}(n,t)}function en(e,t){const n=Zt.get(e);if(n)for(const e of n)e(t)}let tn=null;
521
+ */const Xt=new Map;function Qt(e,t){const n=Zt(e);en(n,t),function(e,t){const n=function(){!tn&&"BroadcastChannel"in self&&(tn=new BroadcastChannel("[Firebase] FID Change"),tn.onmessage=e=>{en(e.data.key,e.data.fid)});return tn}();n&&n.postMessage({key:e,fid:t});0===Xt.size&&tn&&(tn.close(),tn=null)}(n,t)}function en(e,t){const n=Xt.get(e);if(n)for(const e of n)e(t)}let tn=null;
522
522
  /**
523
523
  * @license
524
524
  * Copyright 2019 Google LLC
@@ -535,7 +535,7 @@ const Yt=/^[cdef][\w-]{21}$/;function Jt(){try{const e=new Uint8Array(17);(self.
535
535
  * See the License for the specific language governing permissions and
536
536
  * limitations under the License.
537
537
  */
538
- const nn="firebase-installations-store";let rn=null;function sn(){return rn||(rn=Pe("firebase-installations-database",1,{upgrade:(e,t)=>{if(0===t)e.createObjectStore(nn)}})),rn}async function on(e,t){const n=Xt(e),i=(await sn()).transaction(nn,"readwrite"),r=i.objectStore(nn),s=await r.get(n);return await r.put(t,n),await i.done,s&&s.fid===t.fid||Qt(e,t.fid),t}async function an(e){const t=Xt(e),n=(await sn()).transaction(nn,"readwrite");await n.objectStore(nn).delete(t),await n.done}async function ln(e,t){const n=Xt(e),i=(await sn()).transaction(nn,"readwrite"),r=i.objectStore(nn),s=await r.get(n),o=t(s);return void 0===o?await r.delete(n):await r.put(o,n),await i.done,!o||s&&s.fid===o.fid||Qt(e,o.fid),o}
538
+ const nn="firebase-installations-store";let rn=null;function sn(){return rn||(rn=Pe("firebase-installations-database",1,{upgrade:(e,t)=>{if(0===t)e.createObjectStore(nn)}})),rn}async function on(e,t){const n=Zt(e),i=(await sn()).transaction(nn,"readwrite"),r=i.objectStore(nn),s=await r.get(n);return await r.put(t,n),await i.done,s&&s.fid===t.fid||Qt(e,t.fid),t}async function an(e){const t=Zt(e),n=(await sn()).transaction(nn,"readwrite");await n.objectStore(nn).delete(t),await n.done}async function ln(e,t){const n=Zt(e),i=(await sn()).transaction(nn,"readwrite"),r=i.objectStore(nn),s=await r.get(n),o=t(s);return void 0===o?await r.delete(n):await r.put(o,n),await i.done,!o||s&&s.fid===o.fid||Qt(e,o.fid),o}
539
539
  /**
540
540
  * @license
541
541
  * Copyright 2019 Google LLC
@@ -731,7 +731,7 @@ async function(){if(!F())return Sn.warn(Tn.create("indexeddb-unavailable",{error
731
731
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
732
732
  * See the License for the specific language governing permissions and
733
733
  * limitations under the License.
734
- */class On{constructor(e){this.app=e}_delete(){return delete jn[this.app.options.appId],Promise.resolve()}}let jn={},Fn=[];const Un={};let zn,$n,qn="dataLayer",Vn=!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=Tn.create("invalid-analytics-context",{errorInfo:t});Sn.warn(n.message)}}function Hn(e,t,n){Bn();const i=e.options.appId;if(!i)throw Tn.create("no-app-id");if(!e.options.apiKey){if(!e.options.measurementId)throw Tn.create("no-api-key");Sn.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!=jn[i])throw Tn.create("already-exists",{id:i});if(!Vn){!function(e){let t=[];Array.isArray(window[e])?t=window[e]:window[e]=t}(qn);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]=xn(s,e,t,n),{gtagCore:s,wrappedGtag:window[r]}}(jn,Fn,Un,qn,"gtag");$n=e,zn=t,Vn=!0}jn[i]=Mn(e,Fn,Un,t,zn,qn,n);return new On(e)}function Wn(e=kt()){const t=mt(e=se(e),kn);return t.isInitialized()?t.getImmediate():function(e,t={}){const n=mt(e,kn);if(n.isInitialized()){const e=n.getImmediate();if(J(t,n.getOptions()))return e;throw Tn.create("already-initialized")}const i=n.initialize({options:t});return i}(e)}function Gn(e,t,n){e=se(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})}($n,jn[e.app.options.appId],t,n).catch((e=>Sn.error(e)))}function Kn(e,t,n,i){e=se(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})}}($n,jn[e.app.options.appId],t,n,i).catch((e=>Sn.error(e)))}const Yn="@firebase/analytics",Jn="0.10.19";ft(new oe(kn,((e,{options:t})=>Hn(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),t)),"PUBLIC")),ft(new oe("analytics-internal",(function(e){try{const t=e.getProvider(kn).getImmediate();return{logEvent:(e,n,i)=>Kn(t,e,n,i),setUserProperties:(e,n)=>Gn(t,e,n)}}catch(e){throw Tn.create("interop-component-reg-failed",{reason:e})}}),"PRIVATE")),Ct(Yn,Jn),Ct(Yn,Jn,"esm2020");function Xn(){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."}}
734
+ */class On{constructor(e){this.app=e}_delete(){return delete jn[this.app.options.appId],Promise.resolve()}}let jn={},Fn=[];const Un={};let zn,$n,qn="dataLayer",Vn=!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=Tn.create("invalid-analytics-context",{errorInfo:t});Sn.warn(n.message)}}function Hn(e,t,n){Bn();const i=e.options.appId;if(!i)throw Tn.create("no-app-id");if(!e.options.apiKey){if(!e.options.measurementId)throw Tn.create("no-api-key");Sn.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!=jn[i])throw Tn.create("already-exists",{id:i});if(!Vn){!function(e){let t=[];Array.isArray(window[e])?t=window[e]:window[e]=t}(qn);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]=xn(s,e,t,n),{gtagCore:s,wrappedGtag:window[r]}}(jn,Fn,Un,qn,"gtag");$n=e,zn=t,Vn=!0}jn[i]=Mn(e,Fn,Un,t,zn,qn,n);return new On(e)}function Wn(e=kt()){const t=mt(e=se(e),kn);return t.isInitialized()?t.getImmediate():function(e,t={}){const n=mt(e,kn);if(n.isInitialized()){const e=n.getImmediate();if(J(t,n.getOptions()))return e;throw Tn.create("already-initialized")}const i=n.initialize({options:t});return i}(e)}function Gn(e,t,n){e=se(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})}($n,jn[e.app.options.appId],t,n).catch((e=>Sn.error(e)))}function Kn(e,t,n,i){e=se(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})}}($n,jn[e.app.options.appId],t,n,i).catch((e=>Sn.error(e)))}const Yn="@firebase/analytics",Jn="0.10.19";ft(new oe(kn,((e,{options:t})=>Hn(e.getProvider("app").getImmediate(),e.getProvider("installations-internal").getImmediate(),t)),"PUBLIC")),ft(new oe("analytics-internal",(function(e){try{const t=e.getProvider(kn).getImmediate();return{logEvent:(e,n,i)=>Kn(t,e,n,i),setUserProperties:(e,n)=>Gn(t,e,n)}}catch(e){throw Tn.create("interop-component-reg-failed",{reason:e})}}),"PRIVATE")),Ct(Yn,Jn),Ct(Yn,Jn,"esm2020");function Zn(){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
735
  /**
736
736
  * @license
737
737
  * Copyright 2020 Google LLC
@@ -748,7 +748,7 @@ async function(){if(!F())return Sn.warn(Tn.create("indexeddb-unavailable",{error
748
748
  * See the License for the specific language governing permissions and
749
749
  * limitations under the License.
750
750
  */
751
- Ct("firebase","12.5.0","app");const Zn=Xn,Qn=new $("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."}),ei=new fe("@firebase/auth");function ti(e,...t){ei.logLevel<=ue.ERROR&&ei.error(`Auth (${bt}): ${e}`,...t)}
751
+ Ct("firebase","12.5.0","app");const Xn=Zn,Qn=new $("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."}),ei=new fe("@firebase/auth");function ti(e,...t){ei.logLevel<=ue.ERROR&&ei.error(`Auth (${bt}): ${e}`,...t)}
752
752
  /**
753
753
  * @license
754
754
  * Copyright 2020 Google LLC
@@ -764,7 +764,7 @@ Ct("firebase","12.5.0","app");const Zn=Xn,Qn=new $("auth","Firebase",{"dependent
764
764
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
765
765
  * See the License for the specific language governing permissions and
766
766
  * limitations under the License.
767
- */function ni(e,...t){throw oi(e,...t)}function ii(e,...t){return oi(e,...t)}function ri(e,t,n){const i={...Zn(),[t]:n};return new $("auth","Firebase",i).create(t,{appName:e.name})}function si(e){return ri(e,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function oi(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 Qn.create(e,...t)}function ai(e,t,...n){if(!e)throw oi(t,...n)}function li(e){const t="INTERNAL ASSERTION FAILED: "+e;throw ti(t),new Error(t)}function ci(e,t){e||li(t)}
767
+ */function ni(e,...t){throw oi(e,...t)}function ii(e,...t){return oi(e,...t)}function ri(e,t,n){const i={...Xn(),[t]:n};return new $("auth","Firebase",i).create(t,{appName:e.name})}function si(e){return ri(e,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function oi(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 Qn.create(e,...t)}function ai(e,t,...n){if(!e)throw oi(t,...n)}function li(e){const t="INTERNAL ASSERTION FAILED: "+e;throw ti(t),new Error(t)}function ci(e,t){e||li(t)}
768
768
  /**
769
769
  * @license
770
770
  * Copyright 2020 Google LLC
@@ -877,7 +877,7 @@ class pi{constructor(e,t){this.shortDelay=e,this.longDelay=t,ci(t>e,"Short delay
877
877
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
878
878
  * See the License for the specific language governing permissions and
879
879
  * limitations under the License.
880
- */function wi(e,t){return e.tenantId&&!t.tenantId?{...t,tenantId:e.tenantId}:t}async function bi(e,t,n,i,r={}){return _i(e,r,(async()=>{let r={},s={};i&&("GET"===t?s=i:r={body:JSON.stringify(i)});const o=Z({key:e.config.apiKey,...s}).slice(1),a=await e._getAdditionalHeaders();a["Content-Type"]="application/json",e.languageCode&&(a["X-Firebase-Locale"]=e.languageCode);const l={method:t,headers:a,...r};return"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||(l.referrerPolicy="no-referrer"),e.emulatorConfig&&P(e.emulatorConfig.host)&&(l.credentials="include"),fi.fetch()(await Ci(e,e.config.apiHost,n,o),l)}))}async function _i(e,t,n){e._canInitEmulator=!1;const i={...mi,...t};try{const t=new Si(e),r=await Promise.race([n(),t.promise]);t.clearNetworkTimeout();const s=await r.json();if("needConfirmation"in s)throw Ti(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,o]=t.split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===n)throw Ti(e,"credential-already-in-use",s);if("EMAIL_EXISTS"===n)throw Ti(e,"email-already-in-use",s);if("USER_DISABLED"===n)throw Ti(e,"user-disabled",s);const a=i[n]||n.toLowerCase().replace(/[_\s]+/g,"-");if(o)throw ri(e,a,o);ni(e,a)}}catch(t){if(t instanceof z)throw t;ni(e,"network-request-failed",{message:String(t)})}}async function ki(e,t,n,i,r={}){const s=await bi(e,t,n,i,r);return"mfaPendingCredential"in s&&ni(e,"multi-factor-auth-required",{_serverResponse:s}),s}async function Ci(e,t,n,i){const r=`${t}${n}?${i}`,s=e,o=s.config.emulator?gi(e.config,r):`${e.config.apiScheme}://${r}`;if(vi.includes(n)&&(await s._persistenceManagerAvailable,"COOKIE"===s._getPersistenceType())){return s._getPersistence()._getFinalTarget(o).toString()}return o}class Si{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise(((e,t)=>{this.timer=setTimeout((()=>t(ii(this.auth,"network-request-failed"))),yi.get())}))}}function Ti(e,t,n){const i={appName:e.name};n.email&&(i.email=n.email),n.phoneNumber&&(i.phoneNumber=n.phoneNumber);const r=ii(e,t,i);return r.customData._tokenResponse=n,r}
880
+ */function wi(e,t){return e.tenantId&&!t.tenantId?{...t,tenantId:e.tenantId}:t}async function bi(e,t,n,i,r={}){return _i(e,r,(async()=>{let r={},s={};i&&("GET"===t?s=i:r={body:JSON.stringify(i)});const o=X({key:e.config.apiKey,...s}).slice(1),a=await e._getAdditionalHeaders();a["Content-Type"]="application/json",e.languageCode&&(a["X-Firebase-Locale"]=e.languageCode);const l={method:t,headers:a,...r};return"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||(l.referrerPolicy="no-referrer"),e.emulatorConfig&&P(e.emulatorConfig.host)&&(l.credentials="include"),fi.fetch()(await Ci(e,e.config.apiHost,n,o),l)}))}async function _i(e,t,n){e._canInitEmulator=!1;const i={...mi,...t};try{const t=new Si(e),r=await Promise.race([n(),t.promise]);t.clearNetworkTimeout();const s=await r.json();if("needConfirmation"in s)throw Ti(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,o]=t.split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===n)throw Ti(e,"credential-already-in-use",s);if("EMAIL_EXISTS"===n)throw Ti(e,"email-already-in-use",s);if("USER_DISABLED"===n)throw Ti(e,"user-disabled",s);const a=i[n]||n.toLowerCase().replace(/[_\s]+/g,"-");if(o)throw ri(e,a,o);ni(e,a)}}catch(t){if(t instanceof z)throw t;ni(e,"network-request-failed",{message:String(t)})}}async function ki(e,t,n,i,r={}){const s=await bi(e,t,n,i,r);return"mfaPendingCredential"in s&&ni(e,"multi-factor-auth-required",{_serverResponse:s}),s}async function Ci(e,t,n,i){const r=`${t}${n}?${i}`,s=e,o=s.config.emulator?gi(e.config,r):`${e.config.apiScheme}://${r}`;if(vi.includes(n)&&(await s._persistenceManagerAvailable,"COOKIE"===s._getPersistenceType())){return s._getPersistence()._getFinalTarget(o).toString()}return o}class Si{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise(((e,t)=>{this.timer=setTimeout((()=>t(ii(this.auth,"network-request-failed"))),yi.get())}))}}function Ti(e,t,n){const i={appName:e.name};n.email&&(i.email=n.email),n.phoneNumber&&(i.phoneNumber=n.phoneNumber);const r=ii(e,t,i);return r.customData._tokenResponse=n,r}
881
881
  /**
882
882
  * @license
883
883
  * Copyright 2020 Google LLC
@@ -1006,7 +1006,7 @@ class pi{constructor(e,t){this.shortDelay=e,this.longDelay=t,ci(t>e,"Short delay
1006
1006
  * See the License for the specific language governing permissions and
1007
1007
  * limitations under the License.
1008
1008
  */
1009
- class Oi{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):Ri(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){ai(0!==e.length,"internal-error");const t=Ri(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 _i(e,{},(async()=>{const n=Z({grant_type:"refresh_token",refresh_token:t}).slice(1),{tokenApiHost:i,apiKey:r}=e.config,s=await Ci(e,i,"/v1/token",`key=${r}`),o=await e._getAdditionalHeaders();o["Content-Type"]="application/x-www-form-urlencoded";const a={method:"POST",headers:o,body:n};return e.emulatorConfig&&P(e.emulatorConfig.host)&&(a.credentials="include"),fi.fetch()(s,a)}));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 Oi;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 Oi,this.toJSON())}_performRefresh(){return li("not implemented")}}
1009
+ class Oi{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):Ri(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){ai(0!==e.length,"internal-error");const t=Ri(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 _i(e,{},(async()=>{const n=X({grant_type:"refresh_token",refresh_token:t}).slice(1),{tokenApiHost:i,apiKey:r}=e.config,s=await Ci(e,i,"/v1/token",`key=${r}`),o=await e._getAdditionalHeaders();o["Content-Type"]="application/x-www-form-urlencoded";const a={method:"POST",headers:o,body:n};return e.emulatorConfig&&P(e.emulatorConfig.host)&&(a.credentials="include"),fi.fetch()(s,a)}));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 Oi;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 Oi,this.toJSON())}_performRefresh(){return li("not implemented")}}
1010
1010
  /**
1011
1011
  * @license
1012
1012
  * Copyright 2020 Google LLC
@@ -1086,7 +1086,7 @@ class Oi{constructor(){this.refreshToken=null,this.accessToken=null,this.expirat
1086
1086
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1087
1087
  * See the License for the specific language governing permissions and
1088
1088
  * limitations under the License.
1089
- */function Hi(e){const t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";if(Yi(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(Wi(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(Xi(t))return"Blackberry";if(Zi(t))return"Webos";if(Gi(t))return"Safari";if((t.includes("chrome/")||Ki(t))&&!t.includes("edge/"))return"Chrome";if(Ji(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 Wi(e=D()){return/firefox\//i.test(e)}function Gi(e=D()){const t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function Ki(e=D()){return/crios\//i.test(e)}function Yi(e=D()){return/iemobile/i.test(e)}function Ji(e=D()){return/android/i.test(e)}function Xi(e=D()){return/blackberry/i.test(e)}function Zi(e=D()){return/webos/i.test(e)}function Qi(e=D()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function er(){return function(){const e=D();return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0}()&&10===document.documentMode}function tr(e=D()){return Qi(e)||Ji(e)||Zi(e)||Xi(e)||/windows phone/i.test(e)||Yi(e)}
1089
+ */function Hi(e){const t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";if(Yi(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(Wi(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(Zi(t))return"Blackberry";if(Xi(t))return"Webos";if(Gi(t))return"Safari";if((t.includes("chrome/")||Ki(t))&&!t.includes("edge/"))return"Chrome";if(Ji(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 Wi(e=D()){return/firefox\//i.test(e)}function Gi(e=D()){const t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function Ki(e=D()){return/crios\//i.test(e)}function Yi(e=D()){return/iemobile/i.test(e)}function Ji(e=D()){return/android/i.test(e)}function Zi(e=D()){return/blackberry/i.test(e)}function Xi(e=D()){return/webos/i.test(e)}function Qi(e=D()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function er(){return function(){const e=D();return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0}()&&10===document.documentMode}function tr(e=D()){return Qi(e)||Ji(e)||Xi(e)||Zi(e)||/windows phone/i.test(e)||Yi(e)}
1090
1090
  /**
1091
1091
  * @license
1092
1092
  * Copyright 2020 Google LLC
@@ -1230,7 +1230,7 @@ class Oi{constructor(){this.refreshToken=null,this.accessToken=null,this.expirat
1230
1230
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1231
1231
  * See the License for the specific language governing permissions and
1232
1232
  * limitations under the License.
1233
- */class gr extends dr{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new gr(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):ni("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 gr(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 pr(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,pr(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,pr(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}}
1233
+ */class gr extends dr{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new gr(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):ni("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 gr(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 pr(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,pr(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,pr(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=X(t)}return e}}
1234
1234
  /**
1235
1235
  * @license
1236
1236
  * Copyright 2020 Google LLC
@@ -1626,7 +1626,7 @@ async function(e,t,n=!1){const{auth:i}=e;if(vt(i.app))return Promise.reject(si(i
1626
1626
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1627
1627
  * See the License for the specific language governing permissions and
1628
1628
  * limitations under the License.
1629
- */class Xr{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:o}=e;if(s)return void this.reject(s);const a={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(o)(a))}catch(e){this.reject(e)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return Kr;case"linkViaPopup":case"linkViaRedirect":return Jr;case"reauthViaPopup":case"reauthViaRedirect":return Yr;default:ni(this.auth,"internal-error")}}resolve(e){ci(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){ci(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()}}
1629
+ */class Zr{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:o}=e;if(s)return void this.reject(s);const a={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(o)(a))}catch(e){this.reject(e)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return Kr;case"linkViaPopup":case"linkViaRedirect":return Jr;case"reauthViaPopup":case"reauthViaRedirect":return Yr;default:ni(this.auth,"internal-error")}}resolve(e){ci(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){ci(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
1630
  /**
1631
1631
  * @license
1632
1632
  * Copyright 2020 Google LLC
@@ -1642,7 +1642,7 @@ async function(e,t,n=!1){const{auth:i}=e;if(vt(i.app))return Promise.reject(si(i
1642
1642
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1643
1643
  * See the License for the specific language governing permissions and
1644
1644
  * limitations under the License.
1645
- */const Zr=new pi(2e3,1e4);class Qr extends Xr{constructor(e,t,n,i,r){super(e,t,i,r),this.provider=n,this.authWindow=null,this.pollId=null,Qr.currentPopupAction&&Qr.currentPopupAction.cancel(),Qr.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return ai(e,this.auth,"internal-error"),e}async onExecution(){ci(1===this.filter.length,"Popup operations only handle one event");const e=Dr();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(ii(this.auth,"web-storage-unsupported"))})),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(ii(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Qr.currentPopupAction=null}pollUserCancellation(){const e=()=>{this.authWindow?.window?.closed?this.pollId=window.setTimeout((()=>{this.pollId=null,this.reject(ii(this.auth,"popup-closed-by-user"))}),8e3):this.pollId=window.setTimeout(e,Zr.get())};e()}}Qr.currentPopupAction=null;
1645
+ */const Xr=new pi(2e3,1e4);class Qr extends Zr{constructor(e,t,n,i,r){super(e,t,i,r),this.provider=n,this.authWindow=null,this.pollId=null,Qr.currentPopupAction&&Qr.currentPopupAction.cancel(),Qr.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return ai(e,this.auth,"internal-error"),e}async onExecution(){ci(1===this.filter.length,"Popup operations only handle one event");const e=Dr();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(ii(this.auth,"web-storage-unsupported"))})),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(ii(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Qr.currentPopupAction=null}pollUserCancellation(){const e=()=>{this.authWindow?.window?.closed?this.pollId=window.setTimeout((()=>{this.pollId=null,this.reject(ii(this.auth,"popup-closed-by-user"))}),8e3):this.pollId=window.setTimeout(e,Xr.get())};e()}}Qr.currentPopupAction=null;
1646
1646
  /**
1647
1647
  * @license
1648
1648
  * Copyright 2020 Google LLC
@@ -1659,7 +1659,7 @@ async function(e,t,n=!1){const{auth:i}=e;if(vt(i.app))return Promise.reject(si(i
1659
1659
  * See the License for the specific language governing permissions and
1660
1660
  * limitations under the License.
1661
1661
  */
1662
- const es="pendingRedirect",ts=new Map;class ns extends Xr{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let e=ts.get(this.auth._key());if(!e){try{const t=await async function(e,t){const n=function(e){return Vi(es,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)}ts.set(this.auth._key(),e)}return this.bypassAuthState||ts.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 is(e,t){ts.set(e._key(),t)}async function rs(e,t,n=!1){if(vt(e.app))return Promise.reject(si(e));const i=or(e),r=
1662
+ const es="pendingRedirect",ts=new Map;class ns extends Zr{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let e=ts.get(this.auth._key());if(!e){try{const t=await async function(e,t){const n=function(e){return Vi(es,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)}ts.set(this.auth._key(),e)}return this.bypassAuthState||ts.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 is(e,t){ts.set(e._key(),t)}async function rs(e,t,n=!1){if(vt(e.app))return Promise.reject(si(e));const i=or(e),r=
1663
1663
  /**
1664
1664
  * @license
1665
1665
  * Copyright 2021 Google LLC
@@ -1758,7 +1758,7 @@ const ls=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,cs=/^https?/;async function us(e
1758
1758
  * See the License for the specific language governing permissions and
1759
1759
  * limitations under the License.
1760
1760
  */
1761
- const ms=new pi(5e3,15e3),vs={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},ys=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function ws(e){const t=e.config;ai(t.authDomain,e,"auth-domain-config-required");const n=t.emulator?gi(t,"emulator/auth/iframe"):`https://${e.config.authDomain}/__/auth/iframe`,i={apiKey:t.apiKey,appName:e.name,v:bt},r=ys.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 bs(e){const t=await function(e){return fs=fs||gs(e),fs}(e),n=Mr().gapi;return ai(n,e,"internal-error"),t.open({where:document.body,url:ws(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:vs,dontclear:!0},(t=>new Promise((async(n,i)=>{await t.restyle({setHideOnLeave:!1});const r=ii(e,"network-request-failed"),s=Mr().setTimeout((()=>{i(r)}),ms.get());function o(){Mr().clearTimeout(s),n(t)}t.ping(o).then(o,(()=>{i(r)}))}))))}
1761
+ const ms=new pi(5e3,15e3),vs={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},ys=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function ws(e){const t=e.config;ai(t.authDomain,e,"auth-domain-config-required");const n=t.emulator?gi(t,"emulator/auth/iframe"):`https://${e.config.authDomain}/__/auth/iframe`,i={apiKey:t.apiKey,appName:e.name,v:bt},r=ys.get(e.config.apiHost);r&&(i.eid=r);const s=e._getFrameworks();return s.length&&(i.fw=s.join(",")),`${n}?${X(i).slice(1)}`}async function bs(e){const t=await function(e){return fs=fs||gs(e),fs}(e),n=Mr().gapi;return ai(n,e,"internal-error"),t.open({where:document.body,url:ws(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:vs,dontclear:!0},(t=>new Promise((async(n,i)=>{await t.restyle({setHideOnLeave:!1});const r=ii(e,"network-request-failed"),s=Mr().setTimeout((()=>{i(r)}),ms.get());function o(){Mr().clearTimeout(s),n(t)}t.ping(o).then(o,(()=>{i(r)}))}))))}
1762
1762
  /**
1763
1763
  * @license
1764
1764
  * Copyright 2020 Google LLC.
@@ -1806,7 +1806,7 @@ const ms=new pi(5e3,15e3),vs={style:{position:"absolute",top:"-100px",width:"1px
1806
1806
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1807
1807
  * See the License for the specific language governing permissions and
1808
1808
  * limitations under the License.
1809
- */(e)}?${Z(a).slice(1)}${c}`}const Ps="webStorageSupport";const xs=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Lr,this._completeRedirectFn=rs,this._overrideRedirectResult=is}async _openPopup(e,t,n,i){ci(this.eventManagers[e._key()]?.manager,"_initialize() not called before _openPopup()");return Cs(e,await Es(e,t,n,ui(),i),Dr())}async _openRedirect(e,t,n,i){await this._originValidation(e);return function(e){Mr().location.href=e}(await Es(e,t,n,ui(),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):(ci(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 bs(e),n=new ss(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(Ps,{type:Ps},(n=>{const i=n?.[0]?.[Ps];void 0!==i&&t(!!i),ni(e,"internal-error")}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=us(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return tr()||Gi()||Qi()}};var Rs="@firebase/auth",Ls="1.11.1";
1809
+ */(e)}?${X(a).slice(1)}${c}`}const Ps="webStorageSupport";const xs=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Lr,this._completeRedirectFn=rs,this._overrideRedirectResult=is}async _openPopup(e,t,n,i){ci(this.eventManagers[e._key()]?.manager,"_initialize() not called before _openPopup()");return Cs(e,await Es(e,t,n,ui(),i),Dr())}async _openRedirect(e,t,n,i){await this._originValidation(e);return function(e){Mr().location.href=e}(await Es(e,t,n,ui(),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):(ci(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 bs(e),n=new ss(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(Ps,{type:Ps},(n=>{const i=n?.[0]?.[Ps];void 0!==i&&t(!!i),ni(e,"internal-error")}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=us(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return tr()||Gi()||Qi()}};var Rs="@firebase/auth",Ls="1.11.1";
1810
1810
  /**
1811
1811
  * @license
1812
1812
  * Copyright 2020 Google LLC
@@ -1939,7 +1939,7 @@ class $s{constructor(e){this.domStorage_=e,this.prefix_="firebase:"}set(e,t){nul
1939
1939
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1940
1940
  * See the License for the specific language governing permissions and
1941
1941
  * limitations under the License.
1942
- */const Vs=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 $s(t)}}catch(e){}return new qs},Bs=Vs("localStorage"),Hs=Vs("sessionStorage"),Ws=new fe("@firebase/database"),Gs=function(){let e=1;return function(){return e++}}(),Ks=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++,d(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 Q;n.update(t);const i=n.digest();return f.encodeByteArray(i)},Ys=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+=Ys.apply(null,i):t+="object"==typeof i?B(i):i,t+=" "}return t};let Js=null,Xs=!0;const Zs=function(...e){var t;if(!0===Xs&&(Xs=!1,null===Js&&!0===Hs.get("logging_enabled")&&(d(!t,"Can't turn on custom loggers persistently."),Ws.logLevel=ue.VERBOSE,Js=Ws.log.bind(Ws))),Js){const t=Ys.apply(null,e);Js(t)}},Qs=function(e){return function(...t){Zs(e,...t)}},eo=function(...e){const t="FIREBASE INTERNAL ERROR: "+Ys(...e);Ws.error(t)},to=function(...e){const t=`FIREBASE FATAL ERROR: ${Ys(...e)}`;throw Ws.error(t),new Error(t)},no=function(...e){const t="FIREBASE WARNING: "+Ys(...e);Ws.warn(t)},io=function(e){return"number"==typeof e&&(e!=e||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY)},ro="[MIN_NAME]",so="[MAX_NAME]",oo=function(e,t){if(e===t)return 0;if(e===ro||t===so)return-1;if(t===ro||e===so)return 1;{const n=fo(e),i=fo(t);return null!==n?null!==i?n-i==0?e.length-t.length:n-i:-1:null!==i?1:e<t?-1:1}},ao=function(e,t){return e===t?0:e<t?-1:1},lo=function(e,t){if(t&&e in t)return t[e];throw new Error("Missing required key ("+e+") in object: "+B(t))},co=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+=co(e[t[i]]);return n+="}",n},uo=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 ho(e,t){for(const n in e)e.hasOwnProperty(n)&&t(n,e[n])}const po=function(e){d(!io(e),"Invalid JSON number");const t=1023;let n,i,r,s,o;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 a=[];for(o=52;o;o-=1)a.push(r%2?1:0),r=Math.floor(r/2);for(o=11;o;o-=1)a.push(i%2?1:0),i=Math.floor(i/2);a.push(n?1:0),a.reverse();const l=a.join("");let c="";for(o=0;o<64;o+=8){let e=parseInt(l.substr(o,8),2).toString(16);1===e.length&&(e="0"+e),c+=e}return c.toLowerCase()};const go=new RegExp("^-?(0*)\\d{1,10}$"),fo=function(e){if(go.test(e)){const t=Number(e);if(t>=-2147483648&&t<=2147483647)return t}return null},mo=function(e){try{e()}catch(e){setTimeout((()=>{const t=e.stack||"";throw no("Exception was thrown by user callback.",t),e}),Math.floor(0))}},vo=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};
1942
+ */const Vs=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 $s(t)}}catch(e){}return new qs},Bs=Vs("localStorage"),Hs=Vs("sessionStorage"),Ws=new fe("@firebase/database"),Gs=function(){let e=1;return function(){return e++}}(),Ks=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++,d(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 Q;n.update(t);const i=n.digest();return f.encodeByteArray(i)},Ys=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+=Ys.apply(null,i):t+="object"==typeof i?B(i):i,t+=" "}return t};let Js=null,Zs=!0;const Xs=function(...e){var t;if(!0===Zs&&(Zs=!1,null===Js&&!0===Hs.get("logging_enabled")&&(d(!t,"Can't turn on custom loggers persistently."),Ws.logLevel=ue.VERBOSE,Js=Ws.log.bind(Ws))),Js){const t=Ys.apply(null,e);Js(t)}},Qs=function(e){return function(...t){Xs(e,...t)}},eo=function(...e){const t="FIREBASE INTERNAL ERROR: "+Ys(...e);Ws.error(t)},to=function(...e){const t=`FIREBASE FATAL ERROR: ${Ys(...e)}`;throw Ws.error(t),new Error(t)},no=function(...e){const t="FIREBASE WARNING: "+Ys(...e);Ws.warn(t)},io=function(e){return"number"==typeof e&&(e!=e||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY)},ro="[MIN_NAME]",so="[MAX_NAME]",oo=function(e,t){if(e===t)return 0;if(e===ro||t===so)return-1;if(t===ro||e===so)return 1;{const n=fo(e),i=fo(t);return null!==n?null!==i?n-i==0?e.length-t.length:n-i:-1:null!==i?1:e<t?-1:1}},ao=function(e,t){return e===t?0:e<t?-1:1},lo=function(e,t){if(t&&e in t)return t[e];throw new Error("Missing required key ("+e+") in object: "+B(t))},co=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+=co(e[t[i]]);return n+="}",n},uo=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 ho(e,t){for(const n in e)e.hasOwnProperty(n)&&t(n,e[n])}const po=function(e){d(!io(e),"Invalid JSON number");const t=1023;let n,i,r,s,o;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 a=[];for(o=52;o;o-=1)a.push(r%2?1:0),r=Math.floor(r/2);for(o=11;o;o-=1)a.push(i%2?1:0),i=Math.floor(i/2);a.push(n?1:0),a.reverse();const l=a.join("");let c="";for(o=0;o<64;o+=8){let e=parseInt(l.substr(o,8),2).toString(16);1===e.length&&(e="0"+e),c+=e}return c.toLowerCase()};const go=new RegExp("^-?(0*)\\d{1,10}$"),fo=function(e){if(go.test(e)){const t=Number(e);if(t>=-2147483648&&t<=2147483647)return t}return null},mo=function(e){try{e()}catch(e){setTimeout((()=>{const t=e.stack||"";throw no("Exception was thrown by user callback.",t),e}),Math.floor(0))}},vo=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
1943
  /**
1944
1944
  * @license
1945
1945
  * Copyright 2021 Google LLC
@@ -1972,7 +1972,7 @@ class yo{constructor(e,t){this.appCheckProvider=t,this.appName=e.name,vt(e)&&e.s
1972
1972
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1973
1973
  * See the License for the specific language governing permissions and
1974
1974
  * limitations under the License.
1975
- */class wo{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/.',no(e)}}class bo{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}bo.OWNER="owner";
1975
+ */class wo{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?(Xs("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/.',no(e)}}class bo{constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}bo.OWNER="owner";
1976
1976
  /**
1977
1977
  * @license
1978
1978
  * Copyright 2017 Google LLC
@@ -2071,7 +2071,7 @@ class Lo{constructor(e){this.onMessage_=e,this.pendingResponses=[],this.currentR
2071
2071
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2072
2072
  * See the License for the specific language governing permissions and
2073
2073
  * limitations under the License.
2074
- */const No="start";class Do{constructor(e,t,n,i,r,s,o){this.connId=e,this.repoInfo=t,this.applicationId=n,this.appCheckToken=i,this.authToken=r,this.transportSessionId=s,this.lastSessionId=o,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=Qs(e),this.stats_=Ro(t),this.urlFn=e=>(this.appCheckToken&&(e[ko]=this.appCheckToken),Io(t,So,e))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new Lo(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 Ao(((...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===No)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[No]="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[ko]=this.appCheckToken),"undefined"!=typeof location&&location.hostname&&_o.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(){Do.forceAllow_=!0}static forceDisallow(){Do.forceDisallow_=!0}static isAvailable(){return!!Do.forceAllow_||!(Do.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=v(t),i=uo(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 Ao{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=Gs(),window["pLPCommand"+this.uniqueCallbackIdentifier]=e,window["pRTLPCB"+this.uniqueCallbackIdentifier]=t,this.myIFrame=Ao.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))}}
2074
+ */const No="start";class Do{constructor(e,t,n,i,r,s,o){this.connId=e,this.repoInfo=t,this.applicationId=n,this.appCheckToken=i,this.authToken=r,this.transportSessionId=s,this.lastSessionId=o,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=Qs(e),this.stats_=Ro(t),this.urlFn=e=>(this.appCheckToken&&(e[ko]=this.appCheckToken),Io(t,So,e))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new Lo(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 Ao(((...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===No)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[No]="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[ko]=this.appCheckToken),"undefined"!=typeof location&&location.hostname&&_o.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(){Do.forceAllow_=!0}static forceDisallow(){Do.forceDisallow_=!0}static isAvailable(){return!!Do.forceAllow_||!(Do.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=v(t),i=uo(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 Ao{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=Gs(),window["pLPCommand"+this.uniqueCallbackIdentifier]=e,window["pRTLPCB"+this.uniqueCallbackIdentifier]=t,this.myIFrame=Ao.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){Xs("frame writing exception"),e.stack&&Xs(e.stack),Xs(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||Xs("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=()=>{Xs("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(n)}catch(e){}}),Math.floor(1))}}
2075
2075
  /**
2076
2076
  * @license
2077
2077
  * Copyright 2017 Google LLC
@@ -2168,7 +2168,7 @@ class jo{static get ALL_TRANSPORTS(){return[Do,Oo]}static get IS_TRANSPORT_INITI
2168
2168
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2169
2169
  * See the License for the specific language governing permissions and
2170
2170
  * limitations under the License.
2171
- */class qo{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 Vo(){return new qo("")}function Bo(e){return e.pieceNum_>=e.pieces_.length?null:e.pieces_[e.pieceNum_]}function Ho(e){return e.pieces_.length-e.pieceNum_}function Wo(e){let t=e.pieceNum_;return t<e.pieces_.length&&t++,new qo(e.pieces_,t)}function Go(e){return e.pieceNum_<e.pieces_.length?e.pieces_[e.pieces_.length-1]:null}function Ko(e,t=0){return e.pieces_.slice(e.pieceNum_+t)}function Yo(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 qo(t,0)}function Jo(e,t){const n=[];for(let t=e.pieceNum_;t<e.pieces_.length;t++)n.push(e.pieces_[t]);if(t instanceof qo)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 qo(n,0)}function Xo(e){return e.pieceNum_>=e.pieces_.length}function Zo(e,t){const n=Bo(e),i=Bo(t);if(null===n)return t;if(n===i)return Zo(Wo(e),Wo(t));throw new Error("INTERNAL ERROR: innerPath ("+t+") is not within outerPath ("+e+")")}function Qo(e,t){const n=Ko(e,0),i=Ko(t,0);for(let e=0;e<n.length&&e<i.length;e++){const t=oo(n[e],i[e]);if(0!==t)return t}return n.length===i.length?0:n.length<i.length?-1:1}function ea(e,t){if(Ho(e)!==Ho(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 ta(e,t){let n=e.pieceNum_,i=t.pieceNum_;if(Ho(e)>Ho(t))return!1;for(;n<e.pieces_.length;){if(e.pieces_[n]!==t.pieces_[i])return!1;++n,++i}return!0}class na{constructor(e,t){this.errorPrefix_=t,this.parts_=Ko(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let e=0;e<this.parts_.length;e++)this.byteLength_+=ie(this.parts_[e]);ia(this)}}function ia(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 "+ra(e))}function ra(e){return 0===e.parts_.length?"":"in property '"+e.parts_.join(".")+"'"}
2171
+ */class qo{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 Vo(){return new qo("")}function Bo(e){return e.pieceNum_>=e.pieces_.length?null:e.pieces_[e.pieceNum_]}function Ho(e){return e.pieces_.length-e.pieceNum_}function Wo(e){let t=e.pieceNum_;return t<e.pieces_.length&&t++,new qo(e.pieces_,t)}function Go(e){return e.pieceNum_<e.pieces_.length?e.pieces_[e.pieces_.length-1]:null}function Ko(e,t=0){return e.pieces_.slice(e.pieceNum_+t)}function Yo(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 qo(t,0)}function Jo(e,t){const n=[];for(let t=e.pieceNum_;t<e.pieces_.length;t++)n.push(e.pieces_[t]);if(t instanceof qo)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 qo(n,0)}function Zo(e){return e.pieceNum_>=e.pieces_.length}function Xo(e,t){const n=Bo(e),i=Bo(t);if(null===n)return t;if(n===i)return Xo(Wo(e),Wo(t));throw new Error("INTERNAL ERROR: innerPath ("+t+") is not within outerPath ("+e+")")}function Qo(e,t){const n=Ko(e,0),i=Ko(t,0);for(let e=0;e<n.length&&e<i.length;e++){const t=oo(n[e],i[e]);if(0!==t)return t}return n.length===i.length?0:n.length<i.length?-1:1}function ea(e,t){if(Ho(e)!==Ho(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 ta(e,t){let n=e.pieceNum_,i=t.pieceNum_;if(Ho(e)>Ho(t))return!1;for(;n<e.pieces_.length;){if(e.pieces_[n]!==t.pieces_[i])return!1;++n,++i}return!0}class na{constructor(e,t){this.errorPrefix_=t,this.parts_=Ko(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let e=0;e<this.parts_.length;e++)this.byteLength_+=ie(this.parts_[e]);ia(this)}}function ia(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 "+ra(e))}function ra(e){return 0===e.parts_.length?"":"in property '"+e.parts_.join(".")+"'"}
2172
2172
  /**
2173
2173
  * @license
2174
2174
  * Copyright 2017 Google LLC
@@ -2200,7 +2200,7 @@ class jo{static get ALL_TRANSPORTS(){return[Do,Oo]}static get IS_TRANSPORT_INITI
2200
2200
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2201
2201
  * See the License for the specific language governing permissions and
2202
2202
  * limitations under the License.
2203
- */const oa=1e3;class aa extends Uo{constructor(e,t,n,i,r,s,o,a){if(super(),this.repoInfo_=e,this.applicationId_=t,this.onDataUpdate_=n,this.onConnectStatus_=i,this.onServerInfoUpdate_=r,this.authTokenProvider_=s,this.appCheckTokenProvider_=o,this.authOverride_=a,this.id=aa.nextPersistentConnectionId_++,this.log_=Qs("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_=oa,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,a&&!j())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");sa.getInstance().on("visible",this.onVisible_,this),-1===e.host.indexOf("fblocal")&&$o.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)),d(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),d(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),d(!this.listens.get(s).has(r),"listen() called twice for same path/queryId.");const o={onComplete:i,hashFn:t,query:e,tag:n};this.listens.get(s).set(r,o),this.connected_&&this.sendListen_(o)}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,o=r.s;aa.warnOnListenWarnings_(s,t);(this.listens.get(n)&&this.listens.get(n).get(i))===e&&(this.log_("listen response",r),"ok"!==o&&this.removeListen_(n,i),e.onComplete&&e.onComplete(o,s))}))}static warnOnListenWarnings_(e,t){if(e&&"object"==typeof e&&W(e,"w")){const n=G(e,"w");if(Array.isArray(n)&&~n.indexOf("no_index")){const e='".indexOn": "'+t._queryParams.getIndex().toString()+'"',n=t._path.toString();no(`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=H(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=H(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),d(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 o=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(o):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):eo("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){d(!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_=oa,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=oa,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_=oa),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+":"+aa.nextConnectionId_++,r=this.lastSessionId;let s=!1,o=null;const a=function(){o?o.close():(s=!0,n())},l=function(e){d(o,"sendRequest call when we're not connected not allowed."),o.sendRequest(e)};this.realtime_={close:a,sendRequest:l};const c=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[a,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_=a&&a.accessToken,this.appCheckToken_=l&&l.token,o=new Fo(i,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,t,n,(e=>{no(e+" ("+this.repoInfo_.toString()+")"),this.interrupt("server_kill")}),r))}catch(e){this.log_("Failed to get token: "+e),s||(this.repoInfo_.nodeAdmin&&no(e),a())}}}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],K(this.interruptReasons_)&&(this.reconnectDelay_=oa,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=>co(e))).join("$"):"default";const i=this.removeListen_(e,n);i&&i.onComplete&&i.onComplete("permission_denied")}removeListen_(e,t){const n=new qo(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=$o.getInstance().currentlyOnline();return K(this.interruptReasons_)&&e}}aa.nextPersistentConnectionId_=0,aa.nextConnectionId_=0;
2203
+ */const oa=1e3;class aa extends Uo{constructor(e,t,n,i,r,s,o,a){if(super(),this.repoInfo_=e,this.applicationId_=t,this.onDataUpdate_=n,this.onConnectStatus_=i,this.onServerInfoUpdate_=r,this.authTokenProvider_=s,this.appCheckTokenProvider_=o,this.authOverride_=a,this.id=aa.nextPersistentConnectionId_++,this.log_=Qs("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_=oa,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,a&&!j())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");sa.getInstance().on("visible",this.onVisible_,this),-1===e.host.indexOf("fblocal")&&$o.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)),d(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),d(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),d(!this.listens.get(s).has(r),"listen() called twice for same path/queryId.");const o={onComplete:i,hashFn:t,query:e,tag:n};this.listens.get(s).set(r,o),this.connected_&&this.sendListen_(o)}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,o=r.s;aa.warnOnListenWarnings_(s,t);(this.listens.get(n)&&this.listens.get(n).get(i))===e&&(this.log_("listen response",r),"ok"!==o&&this.removeListen_(n,i),e.onComplete&&e.onComplete(o,s))}))}static warnOnListenWarnings_(e,t){if(e&&"object"==typeof e&&W(e,"w")){const n=G(e,"w");if(Array.isArray(n)&&~n.indexOf("no_index")){const e='".indexOn": "'+t._queryParams.getIndex().toString()+'"',n=t._path.toString();no(`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=H(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=H(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),d(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 o=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(o):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):eo("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){d(!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_=oa,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=oa,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_=oa),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+":"+aa.nextConnectionId_++,r=this.lastSessionId;let s=!1,o=null;const a=function(){o?o.close():(s=!0,n())},l=function(e){d(o,"sendRequest call when we're not connected not allowed."),o.sendRequest(e)};this.realtime_={close:a,sendRequest:l};const c=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[a,l]=await Promise.all([this.authTokenProvider_.getToken(c),this.appCheckTokenProvider_.getToken(c)]);s?Xs("getToken() completed but was canceled"):(Xs("getToken() completed. Creating connection."),this.authToken_=a&&a.accessToken,this.appCheckToken_=l&&l.token,o=new Fo(i,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,t,n,(e=>{no(e+" ("+this.repoInfo_.toString()+")"),this.interrupt("server_kill")}),r))}catch(e){this.log_("Failed to get token: "+e),s||(this.repoInfo_.nodeAdmin&&no(e),a())}}}interrupt(e){Xs("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){Xs("Resuming connection for reason: "+e),delete this.interruptReasons_[e],K(this.interruptReasons_)&&(this.reconnectDelay_=oa,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=>co(e))).join("$"):"default";const i=this.removeListen_(e,n);i&&i.onComplete&&i.onComplete("permission_denied")}removeListen_(e,t){const n=new qo(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){Xs("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){Xs("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=$o.getInstance().currentlyOnline();return K(this.interruptReasons_)&&e}}aa.nextPersistentConnectionId_=0,aa.nextConnectionId_=0;
2204
2204
  /**
2205
2205
  * @license
2206
2206
  * Copyright 2017 Google LLC
@@ -2315,7 +2315,7 @@ function ma(e,t){return oo(e.name,t.name)}function va(e,t){return oo(e,t)}
2315
2315
  * See the License for the specific language governing permissions and
2316
2316
  * limitations under the License.
2317
2317
  */
2318
- let _a,ka,Ca;class Sa{static set __childrenNodeConstructor(e){_a=e}static get __childrenNodeConstructor(){return _a}constructor(e,t=Sa.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=t,this.lazyHash_=null,d(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),ba(this.priorityNode_)}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new Sa(this.value_,e)}getImmediateChild(e){return".priority"===e?this.priorityNode_:Sa.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return Xo(e)?this:".priority"===Bo(e)?this.priorityNode_:Sa.__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:Sa.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){const n=Bo(e);return null===n?t:t.isEmpty()&&".priority"!==n?this:(d(".priority"!==n||1===Ho(e),".priority must be the last token in a path"),this.updateImmediateChild(n,Sa.__childrenNodeConstructor.EMPTY_NODE.updateChild(Wo(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:"+wa(this.priorityNode_.val())+":");const t=typeof this.value_;e+=t+":",e+="number"===t?po(this.value_):this.value_,this.lazyHash_=Ks(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===Sa.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof Sa.__childrenNodeConstructor?-1:(d(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){const t=typeof e.value_,n=typeof this.value_,i=Sa.VALUE_TYPE_ORDER.indexOf(t),r=Sa.VALUE_TYPE_ORDER.indexOf(n);return d(i>=0,"Unknown leaf type: "+t),d(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}}Sa.VALUE_TYPE_ORDER=["object","boolean","number","string"];const Ta=new class extends ca{compare(e,t){const n=e.node.getPriority(),i=t.node.getPriority(),r=n.compareTo(i);return 0===r?oo(e.name,t.name):r}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return la.MIN}maxPost(){return new la(so,new Sa("[PRIORITY-POST]",Ca))}makePost(e,t){const n=ka(e);return new la(t,new Sa("[PRIORITY-POST]",n))}toString(){return".priority"}},Ia=Math.log(2);
2318
+ let _a,ka,Ca;class Sa{static set __childrenNodeConstructor(e){_a=e}static get __childrenNodeConstructor(){return _a}constructor(e,t=Sa.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=t,this.lazyHash_=null,d(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),ba(this.priorityNode_)}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new Sa(this.value_,e)}getImmediateChild(e){return".priority"===e?this.priorityNode_:Sa.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return Zo(e)?this:".priority"===Bo(e)?this.priorityNode_:Sa.__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:Sa.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){const n=Bo(e);return null===n?t:t.isEmpty()&&".priority"!==n?this:(d(".priority"!==n||1===Ho(e),".priority must be the last token in a path"),this.updateImmediateChild(n,Sa.__childrenNodeConstructor.EMPTY_NODE.updateChild(Wo(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:"+wa(this.priorityNode_.val())+":");const t=typeof this.value_;e+=t+":",e+="number"===t?po(this.value_):this.value_,this.lazyHash_=Ks(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===Sa.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof Sa.__childrenNodeConstructor?-1:(d(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){const t=typeof e.value_,n=typeof this.value_,i=Sa.VALUE_TYPE_ORDER.indexOf(t),r=Sa.VALUE_TYPE_ORDER.indexOf(n);return d(i>=0,"Unknown leaf type: "+t),d(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}}Sa.VALUE_TYPE_ORDER=["object","boolean","number","string"];const Ta=new class extends ca{compare(e,t){const n=e.node.getPriority(),i=t.node.getPriority(),r=n.compareTo(i);return 0===r?oo(e.name,t.name):r}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return la.MIN}maxPost(){return new la(so,new Sa("[PRIORITY-POST]",Ca))}makePost(e,t){const n=ka(e);return new la(t,new Sa("[PRIORITY-POST]",n))}toString(){return".priority"}},Ia=Math.log(2);
2319
2319
  /**
2320
2320
  * @license
2321
2321
  * Copyright 2017 Google LLC
@@ -2380,7 +2380,7 @@ let _a,ka,Ca;class Sa{static set __childrenNodeConstructor(e){_a=e}static get __
2380
2380
  * See the License for the specific language governing permissions and
2381
2381
  * limitations under the License.
2382
2382
  */
2383
- class Oa extends ca{constructor(e){super(),this.indexPath_=e,d(!Xo(e)&&".priority"!==Bo(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?oo(e.name,t.name):r}makePost(e,t){const n=Ma(e),i=Da.EMPTY_NODE.updateChild(this.indexPath_,n);return new la(t,i)}maxPost(){const e=Da.EMPTY_NODE.updateChild(this.indexPath_,Aa);return new la(so,e)}toString(){return Ko(this.indexPath_,0).join("/")}}
2383
+ class Oa extends ca{constructor(e){super(),this.indexPath_=e,d(!Zo(e)&&".priority"!==Bo(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?oo(e.name,t.name):r}makePost(e,t){const n=Ma(e),i=Da.EMPTY_NODE.updateChild(this.indexPath_,n);return new la(t,i)}maxPost(){const e=Da.EMPTY_NODE.updateChild(this.indexPath_,Aa);return new la(so,e)}toString(){return Ko(this.indexPath_,0).join("/")}}
2384
2384
  /**
2385
2385
  * @license
2386
2386
  * Copyright 2017 Google LLC
@@ -2493,7 +2493,7 @@ class qa{constructor(e){this.index_=e}updateChild(e,t,n,i,r,s){d(e.isIndexed(thi
2493
2493
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2494
2494
  * See the License for the specific language governing permissions and
2495
2495
  * limitations under the License.
2496
- */class Ka extends Uo{reportStats(e){throw new Error("Method not implemented.")}static getListenId_(e,t){return void 0!==t?"tag$"+t:(d(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_=Qs("p:rest:"),this.listens_={}}listen(e,t,n,i){const r=e._path.toString();this.log_("Listen called for "+r+" "+e._queryIdentifier);const s=Ka.getListenId_(e,n),o={};this.listens_[s]=o;const a=Wa(e._queryParams);this.restRequest_(r+".json",a,((e,t)=>{let a=t;if(404===e&&(a=null,e=null),null===e&&this.onDataUpdate_(r,a,!1,n),G(this.listens_,s)===o){let t;t=e?401===e?"permission_denied":"rest_error:"+e:"ok",i(t,null)}}))}unlisten(e,t){const n=Ka.getListenId_(e,t);delete this.listens_[n]}get(e){const t=Wa(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 o=new XMLHttpRequest;o.onreadystatechange=()=>{if(n&&4===o.readyState){this.log_("REST Response for "+s+" received. status:",o.status,"response:",o.responseText);let e=null;if(o.status>=200&&o.status<300){try{e=V(o.responseText)}catch(e){no("Failed to parse JSON response for "+s+": "+o.responseText)}n(null,e)}else 401!==o.status&&404!==o.status&&no("Got unsuccessful REST response for "+s+" Status: "+o.status),n(o.status);n=null}},o.open("GET",s,!0),o.send()}))}}
2496
+ */class Ka extends Uo{reportStats(e){throw new Error("Method not implemented.")}static getListenId_(e,t){return void 0!==t?"tag$"+t:(d(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_=Qs("p:rest:"),this.listens_={}}listen(e,t,n,i){const r=e._path.toString();this.log_("Listen called for "+r+" "+e._queryIdentifier);const s=Ka.getListenId_(e,n),o={};this.listens_[s]=o;const a=Wa(e._queryParams);this.restRequest_(r+".json",a,((e,t)=>{let a=t;if(404===e&&(a=null,e=null),null===e&&this.onDataUpdate_(r,a,!1,n),G(this.listens_,s)===o){let t;t=e?401===e?"permission_denied":"rest_error:"+e:"ok",i(t,null)}}))}unlisten(e,t){const n=Ka.getListenId_(e,t);delete this.listens_[n]}get(e){const t=Wa(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+X(t);this.log_("Sending REST request for "+s);const o=new XMLHttpRequest;o.onreadystatechange=()=>{if(n&&4===o.readyState){this.log_("REST Response for "+s+" received. status:",o.status,"response:",o.responseText);let e=null;if(o.status>=200&&o.status<300){try{e=V(o.responseText)}catch(e){no("Failed to parse JSON response for "+s+": "+o.responseText)}n(null,e)}else 401!==o.status&&404!==o.status&&no("Got unsuccessful REST response for "+s+" Status: "+o.status),n(o.status);n=null}},o.open("GET",s,!0),o.send()}))}}
2497
2497
  /**
2498
2498
  * @license
2499
2499
  * Copyright 2017 Google LLC
@@ -2525,7 +2525,7 @@ class qa{constructor(e){this.index_=e}updateChild(e,t,n,i,r,s){d(e.isIndexed(thi
2525
2525
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2526
2526
  * See the License for the specific language governing permissions and
2527
2527
  * limitations under the License.
2528
- */function Ja(){return{value:null,children:new Map}}function Xa(e,t,n){if(Xo(t))e.value=n,e.children.clear();else if(null!==e.value)e.value=e.value.updateChild(t,n);else{const i=Bo(t);e.children.has(i)||e.children.set(i,Ja());Xa(e.children.get(i),t=Wo(t),n)}}function Za(e,t){if(Xo(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(Ta,((t,n)=>{Xa(e,new qo(t),n)})),Za(e,t)}}if(e.children.size>0){const n=Bo(t);if(t=Wo(t),e.children.has(n)){Za(e.children.get(n),t)&&e.children.delete(n)}return 0===e.children.size}return!0}function Qa(e,t,n){null!==e.value?n(t,e.value):function(e,t){e.children.forEach(((e,n)=>{t(n,e)}))}
2528
+ */function Ja(){return{value:null,children:new Map}}function Za(e,t,n){if(Zo(t))e.value=n,e.children.clear();else if(null!==e.value)e.value=e.value.updateChild(t,n);else{const i=Bo(t);e.children.has(i)||e.children.set(i,Ja());Za(e.children.get(i),t=Wo(t),n)}}function Xa(e,t){if(Zo(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(Ta,((t,n)=>{Za(e,new qo(t),n)})),Xa(e,t)}}if(e.children.size>0){const n=Bo(t);if(t=Wo(t),e.children.has(n)){Xa(e.children.get(n),t)&&e.children.delete(n)}return 0===e.children.size}return!0}function Qa(e,t,n){null!==e.value?n(t,e.value):function(e,t){e.children.forEach(((e,n)=>{t(n,e)}))}
2529
2529
  /**
2530
2530
  * @license
2531
2531
  * Copyright 2017 Google LLC
@@ -2589,7 +2589,7 @@ class qa{constructor(e){this.index_=e}updateChild(e,t,n,i,r,s){d(e.isIndexed(thi
2589
2589
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2590
2590
  * See the License for the specific language governing permissions and
2591
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"}(nl||(nl={}));class rl{constructor(e,t,n){this.path=e,this.affectedTree=t,this.revert=n,this.type=nl.ACK_USER_WRITE,this.source={fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}operationForChild(e){if(Xo(this.path)){if(null!=this.affectedTree.value)return d(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const t=this.affectedTree.subtree(new qo(e));return new rl(Vo(),t,this.revert)}}return d(Bo(this.path)===e,"operationForChild called for unrelated child."),new rl(Wo(this.path),this.affectedTree,this.revert)}}
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"}(nl||(nl={}));class rl{constructor(e,t,n){this.path=e,this.affectedTree=t,this.revert=n,this.type=nl.ACK_USER_WRITE,this.source={fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}operationForChild(e){if(Zo(this.path)){if(null!=this.affectedTree.value)return d(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const t=this.affectedTree.subtree(new qo(e));return new rl(Vo(),t,this.revert)}}return d(Bo(this.path)===e,"operationForChild called for unrelated child."),new rl(Wo(this.path),this.affectedTree,this.revert)}}
2593
2593
  /**
2594
2594
  * @license
2595
2595
  * Copyright 2017 Google LLC
@@ -2605,7 +2605,7 @@ class qa{constructor(e){this.index_=e}updateChild(e,t,n,i,r,s){d(e.isIndexed(thi
2605
2605
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2606
2606
  * See the License for the specific language governing permissions and
2607
2607
  * limitations under the License.
2608
- */class sl{constructor(e,t){this.source=e,this.path=t,this.type=nl.LISTEN_COMPLETE}operationForChild(e){return Xo(this.path)?new sl(this.source,Vo()):new sl(this.source,Wo(this.path))}}
2608
+ */class sl{constructor(e,t){this.source=e,this.path=t,this.type=nl.LISTEN_COMPLETE}operationForChild(e){return Zo(this.path)?new sl(this.source,Vo()):new sl(this.source,Wo(this.path))}}
2609
2609
  /**
2610
2610
  * @license
2611
2611
  * Copyright 2017 Google LLC
@@ -2621,7 +2621,7 @@ class qa{constructor(e){this.index_=e}updateChild(e,t,n,i,r,s){d(e.isIndexed(thi
2621
2621
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2622
2622
  * See the License for the specific language governing permissions and
2623
2623
  * limitations under the License.
2624
- */class ol{constructor(e,t,n){this.source=e,this.path=t,this.snap=n,this.type=nl.OVERWRITE}operationForChild(e){return Xo(this.path)?new ol(this.source,Vo(),this.snap.getImmediateChild(e)):new ol(this.source,Wo(this.path),this.snap)}}
2624
+ */class ol{constructor(e,t,n){this.source=e,this.path=t,this.snap=n,this.type=nl.OVERWRITE}operationForChild(e){return Zo(this.path)?new ol(this.source,Vo(),this.snap.getImmediateChild(e)):new ol(this.source,Wo(this.path),this.snap)}}
2625
2625
  /**
2626
2626
  * @license
2627
2627
  * Copyright 2017 Google LLC
@@ -2637,7 +2637,7 @@ class qa{constructor(e){this.index_=e}updateChild(e,t,n,i,r,s){d(e.isIndexed(thi
2637
2637
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2638
2638
  * See the License for the specific language governing permissions and
2639
2639
  * limitations under the License.
2640
- */class al{constructor(e,t,n){this.source=e,this.path=t,this.children=n,this.type=nl.MERGE}operationForChild(e){if(Xo(this.path)){const t=this.children.subtree(new qo(e));return t.isEmpty()?null:t.value?new ol(this.source,Vo(),t.value):new al(this.source,Vo(),t)}return d(Bo(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new al(this.source,Wo(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}
2640
+ */class al{constructor(e,t,n){this.source=e,this.path=t,this.children=n,this.type=nl.MERGE}operationForChild(e){if(Zo(this.path)){const t=this.children.subtree(new qo(e));return t.isEmpty()?null:t.value?new ol(this.source,Vo(),t.value):new al(this.source,Vo(),t)}return d(Bo(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new al(this.source,Wo(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}
2641
2641
  /**
2642
2642
  * @license
2643
2643
  * Copyright 2017 Google LLC
@@ -2653,7 +2653,7 @@ class qa{constructor(e){this.index_=e}updateChild(e,t,n,i,r,s){d(e.isIndexed(thi
2653
2653
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2654
2654
  * See the License for the specific language governing permissions and
2655
2655
  * limitations under the License.
2656
- */class ll{constructor(e,t,n){this.node_=e,this.fullyInitialized_=t,this.filtered_=n}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(Xo(e))return this.isFullyInitialized()&&!this.filtered_;const t=Bo(e);return this.isCompleteForChild(t)}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}
2656
+ */class ll{constructor(e,t,n){this.node_=e,this.fullyInitialized_=t,this.filtered_=n}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(Zo(e))return this.isFullyInitialized()&&!this.filtered_;const t=Bo(e);return this.isCompleteForChild(t)}isCompleteForChild(e){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}
2657
2657
  /**
2658
2658
  * @license
2659
2659
  * Copyright 2017 Google LLC
@@ -2701,7 +2701,7 @@ class qa{constructor(e){this.index_=e}updateChild(e,t,n,i,r,s){d(e.isIndexed(thi
2701
2701
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2702
2702
  * See the License for the specific language governing permissions and
2703
2703
  * limitations under the License.
2704
- */let ml;class vl{static fromObject(e){let t=new vl(null);return ho(e,((e,n)=>{t=t.set(new qo(e),n)})),t}constructor(e,t=(()=>(ml||(ml=new fa(ao)),ml))()){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:Vo(),value:this.value};if(Xo(e))return null;{const n=Bo(e),i=this.children.get(n);if(null!==i){const r=i.findRootMostMatchingPathAndValue(Wo(e),t);if(null!=r){return{path:Jo(new qo(n),r.path),value:r.value}}return null}return null}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,(()=>!0))}subtree(e){if(Xo(e))return this;{const t=Bo(e),n=this.children.get(t);return null!==n?n.subtree(Wo(e)):new vl(null)}}set(e,t){if(Xo(e))return new vl(t,this.children);{const n=Bo(e),i=(this.children.get(n)||new vl(null)).set(Wo(e),t),r=this.children.insert(n,i);return new vl(this.value,r)}}remove(e){if(Xo(e))return this.children.isEmpty()?new vl(null):new vl(null,this.children);{const t=Bo(e),n=this.children.get(t);if(n){const i=n.remove(Wo(e));let r;return r=i.isEmpty()?this.children.remove(t):this.children.insert(t,i),null===this.value&&r.isEmpty()?new vl(null):new vl(this.value,r)}return this}}get(e){if(Xo(e))return this.value;{const t=Bo(e),n=this.children.get(t);return n?n.get(Wo(e)):null}}setTree(e,t){if(Xo(e))return t;{const n=Bo(e),i=(this.children.get(n)||new vl(null)).setTree(Wo(e),t);let r;return r=i.isEmpty()?this.children.remove(n):this.children.insert(n,i),new vl(this.value,r)}}fold(e){return this.fold_(Vo(),e)}fold_(e,t){const n={};return this.children.inorderTraversal(((i,r)=>{n[i]=r.fold_(Jo(e,i),t)})),t(e,this.value,n)}findOnPath(e,t){return this.findOnPath_(e,Vo(),t)}findOnPath_(e,t,n){const i=!!this.value&&n(t,this.value);if(i)return i;if(Xo(e))return null;{const i=Bo(e),r=this.children.get(i);return r?r.findOnPath_(Wo(e),Jo(t,i),n):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,Vo(),t)}foreachOnPath_(e,t,n){if(Xo(e))return this;{this.value&&n(t,this.value);const i=Bo(e),r=this.children.get(i);return r?r.foreachOnPath_(Wo(e),Jo(t,i),n):new vl(null)}}foreach(e){this.foreach_(Vo(),e)}foreach_(e,t){this.children.inorderTraversal(((n,i)=>{i.foreach_(Jo(e,n),t)})),this.value&&t(e,this.value)}foreachChild(e){this.children.inorderTraversal(((t,n)=>{n.value&&e(t,n.value)}))}}
2704
+ */let ml;class vl{static fromObject(e){let t=new vl(null);return ho(e,((e,n)=>{t=t.set(new qo(e),n)})),t}constructor(e,t=(()=>(ml||(ml=new fa(ao)),ml))()){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:Vo(),value:this.value};if(Zo(e))return null;{const n=Bo(e),i=this.children.get(n);if(null!==i){const r=i.findRootMostMatchingPathAndValue(Wo(e),t);if(null!=r){return{path:Jo(new qo(n),r.path),value:r.value}}return null}return null}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,(()=>!0))}subtree(e){if(Zo(e))return this;{const t=Bo(e),n=this.children.get(t);return null!==n?n.subtree(Wo(e)):new vl(null)}}set(e,t){if(Zo(e))return new vl(t,this.children);{const n=Bo(e),i=(this.children.get(n)||new vl(null)).set(Wo(e),t),r=this.children.insert(n,i);return new vl(this.value,r)}}remove(e){if(Zo(e))return this.children.isEmpty()?new vl(null):new vl(null,this.children);{const t=Bo(e),n=this.children.get(t);if(n){const i=n.remove(Wo(e));let r;return r=i.isEmpty()?this.children.remove(t):this.children.insert(t,i),null===this.value&&r.isEmpty()?new vl(null):new vl(this.value,r)}return this}}get(e){if(Zo(e))return this.value;{const t=Bo(e),n=this.children.get(t);return n?n.get(Wo(e)):null}}setTree(e,t){if(Zo(e))return t;{const n=Bo(e),i=(this.children.get(n)||new vl(null)).setTree(Wo(e),t);let r;return r=i.isEmpty()?this.children.remove(n):this.children.insert(n,i),new vl(this.value,r)}}fold(e){return this.fold_(Vo(),e)}fold_(e,t){const n={};return this.children.inorderTraversal(((i,r)=>{n[i]=r.fold_(Jo(e,i),t)})),t(e,this.value,n)}findOnPath(e,t){return this.findOnPath_(e,Vo(),t)}findOnPath_(e,t,n){const i=!!this.value&&n(t,this.value);if(i)return i;if(Zo(e))return null;{const i=Bo(e),r=this.children.get(i);return r?r.findOnPath_(Wo(e),Jo(t,i),n):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,Vo(),t)}foreachOnPath_(e,t,n){if(Zo(e))return this;{this.value&&n(t,this.value);const i=Bo(e),r=this.children.get(i);return r?r.foreachOnPath_(Wo(e),Jo(t,i),n):new vl(null)}}foreach(e){this.foreach_(Vo(),e)}foreach_(e,t){this.children.inorderTraversal(((n,i)=>{i.foreach_(Jo(e,n),t)})),this.value&&t(e,this.value)}foreachChild(e){this.children.inorderTraversal(((t,n)=>{n.value&&e(t,n.value)}))}}
2705
2705
  /**
2706
2706
  * @license
2707
2707
  * Copyright 2017 Google LLC
@@ -2717,7 +2717,7 @@ class qa{constructor(e){this.index_=e}updateChild(e,t,n,i,r,s){d(e.isIndexed(thi
2717
2717
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2718
2718
  * See the License for the specific language governing permissions and
2719
2719
  * limitations under the License.
2720
- */class yl{constructor(e){this.writeTree_=e}static empty(){return new yl(new vl(null))}}function wl(e,t,n){if(Xo(t))return new yl(new vl(n));{const i=e.writeTree_.findRootMostValueAndPath(t);if(null!=i){const r=i.path;let s=i.value;const o=Zo(r,t);return s=s.updateChild(o,n),new yl(e.writeTree_.set(r,s))}{const i=new vl(n),r=e.writeTree_.setTree(t,i);return new yl(r)}}}function bl(e,t,n){let i=e;return ho(n,((e,n)=>{i=wl(i,Jo(t,e),n)})),i}function _l(e,t){if(Xo(t))return yl.empty();{const n=e.writeTree_.setTree(t,new vl(null));return new yl(n)}}function kl(e,t){return null!=Cl(e,t)}function Cl(e,t){const n=e.writeTree_.findRootMostValueAndPath(t);return null!=n?e.writeTree_.get(n.path).getChild(Zo(n.path,t)):null}function Sl(e){const t=[],n=e.writeTree_.value;return null!=n?n.isLeafNode()||n.forEachChild(Ta,((e,n)=>{t.push(new la(e,n))})):e.writeTree_.children.inorderTraversal(((e,n)=>{null!=n.value&&t.push(new la(e,n.value))})),t}function Tl(e,t){if(Xo(t))return e;{const n=Cl(e,t);return new yl(null!=n?new vl(n):e.writeTree_.subtree(t))}}function Il(e){return e.writeTree_.isEmpty()}function El(e,t){return Pl(Vo(),e.writeTree_,t)}function Pl(e,t,n){if(null!=t.value)return n.updateChild(e,t.value);{let i=null;return t.children.inorderTraversal(((t,r)=>{".priority"===t?(d(null!==r.value,"Priority writes must always be leaf nodes"),i=r.value):n=Pl(Jo(e,t),r,n)})),n.getChild(e).isEmpty()||null===i||(n=n.updateChild(Jo(e,".priority"),i)),n}}
2720
+ */class yl{constructor(e){this.writeTree_=e}static empty(){return new yl(new vl(null))}}function wl(e,t,n){if(Zo(t))return new yl(new vl(n));{const i=e.writeTree_.findRootMostValueAndPath(t);if(null!=i){const r=i.path;let s=i.value;const o=Xo(r,t);return s=s.updateChild(o,n),new yl(e.writeTree_.set(r,s))}{const i=new vl(n),r=e.writeTree_.setTree(t,i);return new yl(r)}}}function bl(e,t,n){let i=e;return ho(n,((e,n)=>{i=wl(i,Jo(t,e),n)})),i}function _l(e,t){if(Zo(t))return yl.empty();{const n=e.writeTree_.setTree(t,new vl(null));return new yl(n)}}function kl(e,t){return null!=Cl(e,t)}function Cl(e,t){const n=e.writeTree_.findRootMostValueAndPath(t);return null!=n?e.writeTree_.get(n.path).getChild(Xo(n.path,t)):null}function Sl(e){const t=[],n=e.writeTree_.value;return null!=n?n.isLeafNode()||n.forEachChild(Ta,((e,n)=>{t.push(new la(e,n))})):e.writeTree_.children.inorderTraversal(((e,n)=>{null!=n.value&&t.push(new la(e,n.value))})),t}function Tl(e,t){if(Zo(t))return e;{const n=Cl(e,t);return new yl(null!=n?new vl(n):e.writeTree_.subtree(t))}}function Il(e){return e.writeTree_.isEmpty()}function El(e,t){return Pl(Vo(),e.writeTree_,t)}function Pl(e,t,n){if(null!=t.value)return n.updateChild(e,t.value);{let i=null;return t.children.inorderTraversal(((t,r)=>{".priority"===t?(d(null!==r.value,"Priority writes must always be leaf nodes"),i=r.value):n=Pl(Jo(e,t),r,n)})),n.getChild(e).isEmpty()||null===i||(n=n.updateChild(Jo(e,".priority"),i)),n}}
2721
2721
  /**
2722
2722
  * @license
2723
2723
  * Copyright 2017 Google LLC
@@ -2733,7 +2733,7 @@ class qa{constructor(e){this.index_=e}updateChild(e,t,n,i,r,s){d(e.isIndexed(thi
2733
2733
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2734
2734
  * See the License for the specific language governing permissions and
2735
2735
  * limitations under the License.
2736
- */function xl(e,t){return ql(t,e)}function Rl(e,t){const n=e.allWrites.findIndex((e=>e.writeId===t));d(n>=0,"removeWrite called with nonexistent writeId.");const i=e.allWrites[n];e.allWrites.splice(n,1);let r=i.visible,s=!1,o=e.allWrites.length-1;for(;r&&o>=0;){const t=e.allWrites[o];t.visible&&(o>=n&&Ll(t,i.path)?r=!1:ta(i.path,t.path)&&(s=!0)),o--}if(r){if(s)return function(e){e.visibleWrites=Dl(e.allWrites,Nl,Vo()),e.allWrites.length>0?e.lastWriteId=e.allWrites[e.allWrites.length-1].writeId:e.lastWriteId=-1}(e),!0;if(i.snap)e.visibleWrites=_l(e.visibleWrites,i.path);else{ho(i.children,(t=>{e.visibleWrites=_l(e.visibleWrites,Jo(i.path,t))}))}return!0}return!1}function Ll(e,t){if(e.snap)return ta(e.path,t);for(const n in e.children)if(e.children.hasOwnProperty(n)&&ta(Jo(e.path,n),t))return!0;return!1}function Nl(e){return e.visible}function Dl(e,t,n){let i=yl.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)ta(n,e)?(t=Zo(n,e),i=wl(i,t,s.snap)):ta(e,n)&&(t=Zo(e,n),i=wl(i,Vo(),s.snap.getChild(t)));else{if(!s.children)throw p("WriteRecord should have .snap or .children");if(ta(n,e))t=Zo(n,e),i=bl(i,t,s.children);else if(ta(e,n))if(t=Zo(e,n),Xo(t))i=bl(i,Vo(),s.children);else{const e=G(s.children,Bo(t));if(e){const n=e.getChild(Wo(t));i=wl(i,Vo(),n)}}}}}return i}function Al(e,t,n,i,r){if(i||r){const s=Tl(e.visibleWrites,t);if(!r&&Il(s))return n;if(r||null!=n||kl(s,Vo())){const s=function(e){return(e.visible||r)&&(!i||!~i.indexOf(e.writeId))&&(ta(e.path,t)||ta(t,e.path))};return El(Dl(e.allWrites,s,t),n||Da.EMPTY_NODE)}return null}{const i=Cl(e.visibleWrites,t);if(null!=i)return i;{const i=Tl(e.visibleWrites,t);if(Il(i))return n;if(null!=n||kl(i,Vo())){return El(i,n||Da.EMPTY_NODE)}return null}}}function Ml(e,t,n,i){return Al(e.writeTree,e.treePath,t,n,i)}function Ol(e,t){return function(e,t,n){let i=Da.EMPTY_NODE;const r=Cl(e.visibleWrites,t);if(r)return r.isLeafNode()||r.forEachChild(Ta,((e,t)=>{i=i.updateImmediateChild(e,t)})),i;if(n){const r=Tl(e.visibleWrites,t);return n.forEachChild(Ta,((e,t)=>{const n=El(Tl(r,new qo(e)),t);i=i.updateImmediateChild(e,n)})),Sl(r).forEach((e=>{i=i.updateImmediateChild(e.name,e.node)})),i}return Sl(Tl(e.visibleWrites,t)).forEach((e=>{i=i.updateImmediateChild(e.name,e.node)})),i}(e.writeTree,e.treePath,t)}function jl(e,t,n,i){return function(e,t,n,i,r){d(i||r,"Either existingEventSnap or existingServerSnap must exist");const s=Jo(t,n);if(kl(e.visibleWrites,s))return null;{const t=Tl(e.visibleWrites,s);return Il(t)?r.getChild(n):El(t,r.getChild(n))}}(e.writeTree,e.treePath,t,n,i)}function Fl(e,t){return function(e,t){return Cl(e.visibleWrites,t)}(e.writeTree,Jo(e.treePath,t))}function Ul(e,t,n,i,r,s){return function(e,t,n,i,r,s,o){let a;const l=Tl(e.visibleWrites,t),c=Cl(l,Vo());if(null!=c)a=c;else{if(null==n)return[];a=El(l,n)}if(a=a.withIndex(o),a.isEmpty()||a.isLeafNode())return[];{const e=[],t=o.getCompare(),n=s?a.getReverseIteratorFrom(i,o):a.getIteratorFrom(i,o);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=Jo(t,n),s=Cl(e.visibleWrites,r);if(null!=s)return s;if(i.isCompleteForChild(n))return El(Tl(e.visibleWrites,r),i.getNode().getImmediateChild(n));return null}(e.writeTree,e.treePath,t,n)}function $l(e,t){return ql(Jo(e.treePath,t),e.writeTree)}function ql(e,t){return{treePath:e,writeTree:t}}
2736
+ */function xl(e,t){return ql(t,e)}function Rl(e,t){const n=e.allWrites.findIndex((e=>e.writeId===t));d(n>=0,"removeWrite called with nonexistent writeId.");const i=e.allWrites[n];e.allWrites.splice(n,1);let r=i.visible,s=!1,o=e.allWrites.length-1;for(;r&&o>=0;){const t=e.allWrites[o];t.visible&&(o>=n&&Ll(t,i.path)?r=!1:ta(i.path,t.path)&&(s=!0)),o--}if(r){if(s)return function(e){e.visibleWrites=Dl(e.allWrites,Nl,Vo()),e.allWrites.length>0?e.lastWriteId=e.allWrites[e.allWrites.length-1].writeId:e.lastWriteId=-1}(e),!0;if(i.snap)e.visibleWrites=_l(e.visibleWrites,i.path);else{ho(i.children,(t=>{e.visibleWrites=_l(e.visibleWrites,Jo(i.path,t))}))}return!0}return!1}function Ll(e,t){if(e.snap)return ta(e.path,t);for(const n in e.children)if(e.children.hasOwnProperty(n)&&ta(Jo(e.path,n),t))return!0;return!1}function Nl(e){return e.visible}function Dl(e,t,n){let i=yl.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)ta(n,e)?(t=Xo(n,e),i=wl(i,t,s.snap)):ta(e,n)&&(t=Xo(e,n),i=wl(i,Vo(),s.snap.getChild(t)));else{if(!s.children)throw p("WriteRecord should have .snap or .children");if(ta(n,e))t=Xo(n,e),i=bl(i,t,s.children);else if(ta(e,n))if(t=Xo(e,n),Zo(t))i=bl(i,Vo(),s.children);else{const e=G(s.children,Bo(t));if(e){const n=e.getChild(Wo(t));i=wl(i,Vo(),n)}}}}}return i}function Al(e,t,n,i,r){if(i||r){const s=Tl(e.visibleWrites,t);if(!r&&Il(s))return n;if(r||null!=n||kl(s,Vo())){const s=function(e){return(e.visible||r)&&(!i||!~i.indexOf(e.writeId))&&(ta(e.path,t)||ta(t,e.path))};return El(Dl(e.allWrites,s,t),n||Da.EMPTY_NODE)}return null}{const i=Cl(e.visibleWrites,t);if(null!=i)return i;{const i=Tl(e.visibleWrites,t);if(Il(i))return n;if(null!=n||kl(i,Vo())){return El(i,n||Da.EMPTY_NODE)}return null}}}function Ml(e,t,n,i){return Al(e.writeTree,e.treePath,t,n,i)}function Ol(e,t){return function(e,t,n){let i=Da.EMPTY_NODE;const r=Cl(e.visibleWrites,t);if(r)return r.isLeafNode()||r.forEachChild(Ta,((e,t)=>{i=i.updateImmediateChild(e,t)})),i;if(n){const r=Tl(e.visibleWrites,t);return n.forEachChild(Ta,((e,t)=>{const n=El(Tl(r,new qo(e)),t);i=i.updateImmediateChild(e,n)})),Sl(r).forEach((e=>{i=i.updateImmediateChild(e.name,e.node)})),i}return Sl(Tl(e.visibleWrites,t)).forEach((e=>{i=i.updateImmediateChild(e.name,e.node)})),i}(e.writeTree,e.treePath,t)}function jl(e,t,n,i){return function(e,t,n,i,r){d(i||r,"Either existingEventSnap or existingServerSnap must exist");const s=Jo(t,n);if(kl(e.visibleWrites,s))return null;{const t=Tl(e.visibleWrites,s);return Il(t)?r.getChild(n):El(t,r.getChild(n))}}(e.writeTree,e.treePath,t,n,i)}function Fl(e,t){return function(e,t){return Cl(e.visibleWrites,t)}(e.writeTree,Jo(e.treePath,t))}function Ul(e,t,n,i,r,s){return function(e,t,n,i,r,s,o){let a;const l=Tl(e.visibleWrites,t),c=Cl(l,Vo());if(null!=c)a=c;else{if(null==n)return[];a=El(l,n)}if(a=a.withIndex(o),a.isEmpty()||a.isLeafNode())return[];{const e=[],t=o.getCompare(),n=s?a.getReverseIteratorFrom(i,o):a.getIteratorFrom(i,o);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=Jo(t,n),s=Cl(e.visibleWrites,r);if(null!=s)return s;if(i.isCompleteForChild(n))return El(Tl(e.visibleWrites,r),i.getNode().getImmediateChild(n));return null}(e.writeTree,e.treePath,t,n)}function $l(e,t){return ql(Jo(e.treePath,t),e.writeTree)}function ql(e,t){return{treePath:e,writeTree:t}}
2737
2737
  /**
2738
2738
  * @license
2739
2739
  * Copyright 2017 Google LLC
@@ -2781,7 +2781,7 @@ class qa{constructor(e){this.index_=e}updateChild(e,t,n,i,r,s){d(e.isIndexed(thi
2781
2781
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2782
2782
  * See the License for the specific language governing permissions and
2783
2783
  * limitations under the License.
2784
- */function Wl(e,t,n,i,r){const s=new Vl;let o,a;if(n.type===nl.OVERWRITE){const l=n;l.source.fromUser?o=Yl(e,t,l.path,l.snap,i,r,s):(d(l.source.fromServer,"Unknown source."),a=l.source.tagged||t.serverCache.isFiltered()&&!Xo(l.path),o=Kl(e,t,l.path,l.snap,i,r,a,s))}else if(n.type===nl.MERGE){const l=n;l.source.fromUser?o=function(e,t,n,i,r,s,o){let a=t;return i.foreach(((i,l)=>{const c=Jo(n,i);Jl(t,Bo(c))&&(a=Yl(e,a,c,l,r,s,o))})),i.foreach(((i,l)=>{const c=Jo(n,i);Jl(t,Bo(c))||(a=Yl(e,a,c,l,r,s,o))})),a}(e,t,l.path,l.children,i,r,s):(d(l.source.fromServer,"Unknown source."),a=l.source.tagged||t.serverCache.isFiltered(),o=Zl(e,t,l.path,l.children,i,r,a,s))}else if(n.type===nl.ACK_USER_WRITE){const a=n;o=a.revert?function(e,t,n,i,r,s){let o;if(null!=Fl(i,n))return t;{const a=new Hl(i,t,r),l=t.eventCache.getNode();let c;if(Xo(n)||".priority"===Bo(n)){let n;if(t.serverCache.isFullyInitialized())n=Ml(i,fl(t));else{const e=t.serverCache.getNode();d(e instanceof Da,"serverChildren would be complete if leaf node"),n=Ol(i,e)}c=e.filter.updateFullNode(l,n,s)}else{const r=Bo(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,Wo(n),a,s):t.eventCache.getNode().hasChild(r)?e.filter.updateChild(l,r,Da.EMPTY_NODE,Wo(n),a,s):l,c.isEmpty()&&t.serverCache.isFullyInitialized()&&(o=Ml(i,fl(t)),o.isLeafNode()&&(c=e.filter.updateFullNode(c,o,s)))}return o=t.serverCache.isFullyInitialized()||null!=Fl(i,Vo()),dl(t,c,o,e.filter.filtersNodes())}}
2784
+ */function Wl(e,t,n,i,r){const s=new Vl;let o,a;if(n.type===nl.OVERWRITE){const l=n;l.source.fromUser?o=Yl(e,t,l.path,l.snap,i,r,s):(d(l.source.fromServer,"Unknown source."),a=l.source.tagged||t.serverCache.isFiltered()&&!Zo(l.path),o=Kl(e,t,l.path,l.snap,i,r,a,s))}else if(n.type===nl.MERGE){const l=n;l.source.fromUser?o=function(e,t,n,i,r,s,o){let a=t;return i.foreach(((i,l)=>{const c=Jo(n,i);Jl(t,Bo(c))&&(a=Yl(e,a,c,l,r,s,o))})),i.foreach(((i,l)=>{const c=Jo(n,i);Jl(t,Bo(c))||(a=Yl(e,a,c,l,r,s,o))})),a}(e,t,l.path,l.children,i,r,s):(d(l.source.fromServer,"Unknown source."),a=l.source.tagged||t.serverCache.isFiltered(),o=Xl(e,t,l.path,l.children,i,r,a,s))}else if(n.type===nl.ACK_USER_WRITE){const a=n;o=a.revert?function(e,t,n,i,r,s){let o;if(null!=Fl(i,n))return t;{const a=new Hl(i,t,r),l=t.eventCache.getNode();let c;if(Zo(n)||".priority"===Bo(n)){let n;if(t.serverCache.isFullyInitialized())n=Ml(i,fl(t));else{const e=t.serverCache.getNode();d(e instanceof Da,"serverChildren would be complete if leaf node"),n=Ol(i,e)}c=e.filter.updateFullNode(l,n,s)}else{const r=Bo(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,Wo(n),a,s):t.eventCache.getNode().hasChild(r)?e.filter.updateChild(l,r,Da.EMPTY_NODE,Wo(n),a,s):l,c.isEmpty()&&t.serverCache.isFullyInitialized()&&(o=Ml(i,fl(t)),o.isLeafNode()&&(c=e.filter.updateFullNode(c,o,s)))}return o=t.serverCache.isFullyInitialized()||null!=Fl(i,Vo()),dl(t,c,o,e.filter.filtersNodes())}}
2785
2785
  /**
2786
2786
  * @license
2787
2787
  * Copyright 2017 Google LLC
@@ -2797,7 +2797,7 @@ class qa{constructor(e){this.index_=e}updateChild(e,t,n,i,r,s){d(e.isIndexed(thi
2797
2797
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2798
2798
  * See the License for the specific language governing permissions and
2799
2799
  * limitations under the License.
2800
- */(e,t,a.path,i,r,s):function(e,t,n,i,r,s,o){if(null!=Fl(r,n))return t;const a=t.serverCache.isFiltered(),l=t.serverCache;if(null!=i.value){if(Xo(n)&&l.isFullyInitialized()||l.isCompleteForPath(n))return Kl(e,t,n,l.getNode().getChild(n),r,s,a,o);if(Xo(n)){let i=new vl(null);return l.getNode().forEachChild(da,((e,t)=>{i=i.set(new qo(e),t)})),Zl(e,t,n,i,r,s,a,o)}return t}{let c=new vl(null);return i.foreach(((e,t)=>{const i=Jo(n,e);l.isCompleteForPath(i)&&(c=c.set(e,l.getNode().getChild(i)))})),Zl(e,t,n,c,r,s,a,o)}}(e,t,a.path,a.affectedTree,i,r,s)}else{if(n.type!==nl.LISTEN_COMPLETE)throw p("Unknown operation type: "+n.type);o=function(e,t,n,i,r){const s=t.serverCache,o=pl(t,s.getNode(),s.isFullyInitialized()||Xo(n),s.isFiltered());return Gl(e,o,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=gl(e);(n.length>0||!e.eventCache.isFullyInitialized()||r&&!i.getNode().equals(s)||!i.getNode().getPriority().equals(s.getPriority()))&&n.push(Fa(gl(t)))}}(t,o,l),{viewCache:o,changes:l}}function Gl(e,t,n,i,r,s){const o=t.eventCache;if(null!=Fl(i,n))return t;{let a,l;if(Xo(n))if(d(t.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),t.serverCache.isFiltered()){const n=fl(t),r=Ol(i,n instanceof Da?n:Da.EMPTY_NODE);a=e.filter.updateFullNode(t.eventCache.getNode(),r,s)}else{const n=Ml(i,fl(t));a=e.filter.updateFullNode(t.eventCache.getNode(),n,s)}else{const c=Bo(n);if(".priority"===c){d(1===Ho(n),"Can't have a priority with additional path components");const r=o.getNode();l=t.serverCache.getNode();const s=jl(i,n,r,l);a=null!=s?e.filter.updatePriority(r,s):o.getNode()}else{const u=Wo(n);let h;if(o.isCompleteForChild(c)){l=t.serverCache.getNode();const e=jl(i,n,o.getNode(),l);h=null!=e?o.getNode().getImmediateChild(c).updateChild(u,e):o.getNode().getImmediateChild(c)}else h=zl(i,c,t.serverCache);a=null!=h?e.filter.updateChild(o.getNode(),c,h,u,r,s):o.getNode()}}return dl(t,a,o.isFullyInitialized()||Xo(n),e.filter.filtersNodes())}}function Kl(e,t,n,i,r,s,o,a){const l=t.serverCache;let c;const u=o?e.filter:e.filter.getIndexedFilter();if(Xo(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=Bo(n);if(!l.isCompleteForPath(n)&&Ho(n)>1)return t;const r=Wo(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=pl(t,c,l.isFullyInitialized()||Xo(n),u.filtersNodes());return Gl(e,h,n,r,new Hl(r,h,s),a)}function Yl(e,t,n,i,r,s,o){const a=t.eventCache;let l,c;const u=new Hl(r,t,s);if(Xo(n))c=e.filter.updateFullNode(t.eventCache.getNode(),i,o),l=dl(t,c,!0,e.filter.filtersNodes());else{const r=Bo(n);if(".priority"===r)c=e.filter.updatePriority(t.eventCache.getNode(),i),l=dl(t,c,a.isFullyInitialized(),a.isFiltered());else{const s=Wo(n),c=a.getNode().getImmediateChild(r);let h;if(Xo(s))h=i;else{const e=u.getCompleteChild(r);h=null!=e?".priority"===Go(s)&&e.getChild(Yo(s)).isEmpty()?e:e.updateChild(s,i):Da.EMPTY_NODE}if(c.equals(h))l=t;else{l=dl(t,e.filter.updateChild(a.getNode(),r,h,s,u,o),a.isFullyInitialized(),e.filter.filtersNodes())}}}return l}function Jl(e,t){return e.eventCache.isCompleteForChild(t)}function Xl(e,t,n){return n.foreach(((e,n)=>{t=t.updateChild(e,n)})),t}function Zl(e,t,n,i,r,s,o,a){if(t.serverCache.getNode().isEmpty()&&!t.serverCache.isFullyInitialized())return t;let l,c=t;l=Xo(n)?i:new vl(null).setTree(n,i);const u=t.serverCache.getNode();return l.children.inorderTraversal(((n,i)=>{if(u.hasChild(n)){const l=Xl(0,t.serverCache.getNode().getImmediateChild(n),i);c=Kl(e,c,new qo(n),l,r,s,o,a)}})),l.children.inorderTraversal(((n,i)=>{const l=!t.serverCache.isCompleteForChild(n)&&null===i.value;if(!u.hasChild(n)&&!l){const l=Xl(0,t.serverCache.getNode().getImmediateChild(n),i);c=Kl(e,c,new qo(n),l,r,s,o,a)}})),c}let Ql,ec,tc=class{constructor(e,t){this.query_=e,this.eventRegistrations_=[];const n=this.query_._queryParams,i=new qa(n.getIndex()),r=(s=n).loadsAllData()?new qa(s.getIndex()):s.hasLimit()?new Ba(s):new Va(s);var s;this.processor_=function(e){return{filter:e}}(r);const o=t.serverCache,a=t.eventCache,l=i.updateFullNode(Da.EMPTY_NODE,o.getNode(),null),c=r.updateFullNode(Da.EMPTY_NODE,a.getNode(),null),u=new ll(l,o.isFullyInitialized(),i.filtersNodes()),h=new ll(c,a.isFullyInitialized(),r.filtersNodes());this.viewCache_=hl(h,u),this.eventGenerator_=new cl(this.query_)}get query(){return this.query_}};function nc(e,t){const n=fl(e.viewCache_);return n&&(e.query._queryParams.loadsAllData()||!Xo(t)&&!n.getImmediateChild(Bo(t)).isEmpty())?n.getChild(t):null}function ic(e){return 0===e.eventRegistrations_.length}function rc(e,t,n){const i=[];if(n){d(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 sc(e,t,n,i){t.type===nl.MERGE&&null!==t.source.queryId&&(d(fl(e.viewCache_),"We should always have a full cache before handling merges"),d(gl(e.viewCache_),"Missing event cache, even though we have a server cache"));const r=e.viewCache_,s=Wl(e.processor_,r,t,n,i);var o,a;return o=e.processor_,a=s.viewCache,d(a.eventCache.getNode().isIndexed(o.filter.getIndex()),"Event snap not indexed"),d(a.serverCache.getNode().isIndexed(o.filter.getIndex()),"Server snap not indexed"),d(s.viewCache.serverCache.isFullyInitialized()||!r.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),e.viewCache_=s.viewCache,oc(e,s.changes,s.viewCache.eventCache.getNode(),null)}function oc(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}))})),ul(e,r,"child_removed",t,i,n),ul(e,r,"child_added",t,i,n),ul(e,r,"child_moved",s,i,n),ul(e,r,"child_changed",t,i,n),ul(e,r,"value",t,i,n),r}(e.eventGenerator_,t,n,r)}
2800
+ */(e,t,a.path,i,r,s):function(e,t,n,i,r,s,o){if(null!=Fl(r,n))return t;const a=t.serverCache.isFiltered(),l=t.serverCache;if(null!=i.value){if(Zo(n)&&l.isFullyInitialized()||l.isCompleteForPath(n))return Kl(e,t,n,l.getNode().getChild(n),r,s,a,o);if(Zo(n)){let i=new vl(null);return l.getNode().forEachChild(da,((e,t)=>{i=i.set(new qo(e),t)})),Xl(e,t,n,i,r,s,a,o)}return t}{let c=new vl(null);return i.foreach(((e,t)=>{const i=Jo(n,e);l.isCompleteForPath(i)&&(c=c.set(e,l.getNode().getChild(i)))})),Xl(e,t,n,c,r,s,a,o)}}(e,t,a.path,a.affectedTree,i,r,s)}else{if(n.type!==nl.LISTEN_COMPLETE)throw p("Unknown operation type: "+n.type);o=function(e,t,n,i,r){const s=t.serverCache,o=pl(t,s.getNode(),s.isFullyInitialized()||Zo(n),s.isFiltered());return Gl(e,o,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=gl(e);(n.length>0||!e.eventCache.isFullyInitialized()||r&&!i.getNode().equals(s)||!i.getNode().getPriority().equals(s.getPriority()))&&n.push(Fa(gl(t)))}}(t,o,l),{viewCache:o,changes:l}}function Gl(e,t,n,i,r,s){const o=t.eventCache;if(null!=Fl(i,n))return t;{let a,l;if(Zo(n))if(d(t.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),t.serverCache.isFiltered()){const n=fl(t),r=Ol(i,n instanceof Da?n:Da.EMPTY_NODE);a=e.filter.updateFullNode(t.eventCache.getNode(),r,s)}else{const n=Ml(i,fl(t));a=e.filter.updateFullNode(t.eventCache.getNode(),n,s)}else{const c=Bo(n);if(".priority"===c){d(1===Ho(n),"Can't have a priority with additional path components");const r=o.getNode();l=t.serverCache.getNode();const s=jl(i,n,r,l);a=null!=s?e.filter.updatePriority(r,s):o.getNode()}else{const u=Wo(n);let h;if(o.isCompleteForChild(c)){l=t.serverCache.getNode();const e=jl(i,n,o.getNode(),l);h=null!=e?o.getNode().getImmediateChild(c).updateChild(u,e):o.getNode().getImmediateChild(c)}else h=zl(i,c,t.serverCache);a=null!=h?e.filter.updateChild(o.getNode(),c,h,u,r,s):o.getNode()}}return dl(t,a,o.isFullyInitialized()||Zo(n),e.filter.filtersNodes())}}function Kl(e,t,n,i,r,s,o,a){const l=t.serverCache;let c;const u=o?e.filter:e.filter.getIndexedFilter();if(Zo(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=Bo(n);if(!l.isCompleteForPath(n)&&Ho(n)>1)return t;const r=Wo(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=pl(t,c,l.isFullyInitialized()||Zo(n),u.filtersNodes());return Gl(e,h,n,r,new Hl(r,h,s),a)}function Yl(e,t,n,i,r,s,o){const a=t.eventCache;let l,c;const u=new Hl(r,t,s);if(Zo(n))c=e.filter.updateFullNode(t.eventCache.getNode(),i,o),l=dl(t,c,!0,e.filter.filtersNodes());else{const r=Bo(n);if(".priority"===r)c=e.filter.updatePriority(t.eventCache.getNode(),i),l=dl(t,c,a.isFullyInitialized(),a.isFiltered());else{const s=Wo(n),c=a.getNode().getImmediateChild(r);let h;if(Zo(s))h=i;else{const e=u.getCompleteChild(r);h=null!=e?".priority"===Go(s)&&e.getChild(Yo(s)).isEmpty()?e:e.updateChild(s,i):Da.EMPTY_NODE}if(c.equals(h))l=t;else{l=dl(t,e.filter.updateChild(a.getNode(),r,h,s,u,o),a.isFullyInitialized(),e.filter.filtersNodes())}}}return l}function Jl(e,t){return e.eventCache.isCompleteForChild(t)}function Zl(e,t,n){return n.foreach(((e,n)=>{t=t.updateChild(e,n)})),t}function Xl(e,t,n,i,r,s,o,a){if(t.serverCache.getNode().isEmpty()&&!t.serverCache.isFullyInitialized())return t;let l,c=t;l=Zo(n)?i:new vl(null).setTree(n,i);const u=t.serverCache.getNode();return l.children.inorderTraversal(((n,i)=>{if(u.hasChild(n)){const l=Zl(0,t.serverCache.getNode().getImmediateChild(n),i);c=Kl(e,c,new qo(n),l,r,s,o,a)}})),l.children.inorderTraversal(((n,i)=>{const l=!t.serverCache.isCompleteForChild(n)&&null===i.value;if(!u.hasChild(n)&&!l){const l=Zl(0,t.serverCache.getNode().getImmediateChild(n),i);c=Kl(e,c,new qo(n),l,r,s,o,a)}})),c}let Ql,ec,tc=class{constructor(e,t){this.query_=e,this.eventRegistrations_=[];const n=this.query_._queryParams,i=new qa(n.getIndex()),r=(s=n).loadsAllData()?new qa(s.getIndex()):s.hasLimit()?new Ba(s):new Va(s);var s;this.processor_=function(e){return{filter:e}}(r);const o=t.serverCache,a=t.eventCache,l=i.updateFullNode(Da.EMPTY_NODE,o.getNode(),null),c=r.updateFullNode(Da.EMPTY_NODE,a.getNode(),null),u=new ll(l,o.isFullyInitialized(),i.filtersNodes()),h=new ll(c,a.isFullyInitialized(),r.filtersNodes());this.viewCache_=hl(h,u),this.eventGenerator_=new cl(this.query_)}get query(){return this.query_}};function nc(e,t){const n=fl(e.viewCache_);return n&&(e.query._queryParams.loadsAllData()||!Zo(t)&&!n.getImmediateChild(Bo(t)).isEmpty())?n.getChild(t):null}function ic(e){return 0===e.eventRegistrations_.length}function rc(e,t,n){const i=[];if(n){d(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 sc(e,t,n,i){t.type===nl.MERGE&&null!==t.source.queryId&&(d(fl(e.viewCache_),"We should always have a full cache before handling merges"),d(gl(e.viewCache_),"Missing event cache, even though we have a server cache"));const r=e.viewCache_,s=Wl(e.processor_,r,t,n,i);var o,a;return o=e.processor_,a=s.viewCache,d(a.eventCache.getNode().isIndexed(o.filter.getIndex()),"Event snap not indexed"),d(a.serverCache.getNode().isIndexed(o.filter.getIndex()),"Server snap not indexed"),d(s.viewCache.serverCache.isFullyInitialized()||!r.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),e.viewCache_=s.viewCache,oc(e,s.changes,s.viewCache.eventCache.getNode(),null)}function oc(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}))})),ul(e,r,"child_removed",t,i,n),ul(e,r,"child_added",t,i,n),ul(e,r,"child_moved",s,i,n),ul(e,r,"child_changed",t,i,n),ul(e,r,"value",t,i,n),r}(e.eventGenerator_,t,n,r)}
2801
2801
  /**
2802
2802
  * @license
2803
2803
  * Copyright 2017 Google LLC
@@ -2829,7 +2829,7 @@ class qa{constructor(e){this.index_=e}updateChild(e,t,n,i,r,s){d(e.isIndexed(thi
2829
2829
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2830
2830
  * See the License for the specific language governing permissions and
2831
2831
  * limitations under the License.
2832
- */let vc=1;class yc{constructor(e){this.listenProvider_=e,this.syncPointTree_=new vl(null),this.pendingWriteTree_={visibleWrites:yl.empty(),allWrites:[],lastWriteId:-1},this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function wc(e,t,n,i,r){return function(e,t,n,i,r){d(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=wl(e.visibleWrites,t,n)),e.lastWriteId=i}(e.pendingWriteTree_,t,n,i,r),r?Tc(e,new ol({fromUser:!0,fromServer:!1,queryId:null,tagged:!1},t,n)):[]}function bc(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(Rl(e.pendingWriteTree_,t)){let t=new vl(null);return null!=i.snap?t=t.set(Vo(),!0):ho(i.children,(e=>{t=t.set(new qo(e),!0)})),Tc(e,new rl(i.path,t,n))}return[]}function _c(e,t,n){return Tc(e,new ol({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},t,n))}function kc(e,t,n,i,r=!1){const s=t._path,o=e.syncPointTree_.get(s);let a=[];if(o&&("default"===t._queryIdentifier||gc(o,t))){const l=uc(o,t,n,i);0===o.views.size&&(e.syncPointTree_=e.syncPointTree_.remove(s));const c=l.removed;if(a=l.events,!r){const n=-1!==c.findIndex((e=>e._queryParams.loadsAllData())),r=e.syncPointTree_.findOnPath(s,((e,t)=>fc(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&&fc(t)){return[mc(t)]}{let e=[];return t&&(e=hc(t)),ho(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=Pc(e,i);e.listenProvider_.startListening(Ac(r),xc(e,r),s.hashFn,s.onComplete)}}}if(!r&&c.length>0&&!i)if(n){const n=null;e.listenProvider_.stopListening(Ac(t),n)}else c.forEach((t=>{const n=e.queryToTagMap.get(Rc(t));e.listenProvider_.stopListening(Ac(t),n)}))}!function(e,t){for(let n=0;n<t.length;++n){const i=t[n];if(!i._queryParams.loadsAllData()){const t=Rc(i),n=e.queryToTagMap.get(t);e.queryToTagMap.delete(t),e.tagToQueryMap.delete(n)}}}(e,c)}return a}function Cc(e,t,n,i=!1){const r=t._path;let s=null,o=!1;e.syncPointTree_.foreachOnPath(r,((e,t)=>{const n=Zo(e,r);s=s||dc(t,n),o=o||fc(t)}));let a,l=e.syncPointTree_.get(r);if(l?(o=o||fc(l),s=s||dc(l,Vo())):(l=new ac,e.syncPointTree_=e.syncPointTree_.set(r,l)),null!=s)a=!0;else{a=!1,s=Da.EMPTY_NODE;e.syncPointTree_.subtree(r).foreachChild(((e,t)=>{const n=dc(t,Vo());n&&(s=s.updateImmediateChild(e,n))}))}const c=gc(l,t);if(!c&&!t._queryParams.loadsAllData()){const n=Rc(t);d(!e.queryToTagMap.has(n),"View does not exist, but we have a tag");const i=vc++;e.queryToTagMap.set(n,i),e.tagToQueryMap.set(i,n)}let u=cc(l,t,n,xl(e.pendingWriteTree_,r),s,a);if(!c&&!o&&!i){const n=pc(l,t);u=u.concat(function(e,t,n){const i=t._path,r=xc(e,t),s=Pc(e,n),o=e.listenProvider_.startListening(Ac(t),r,s.hashFn,s.onComplete),a=e.syncPointTree_.subtree(i);if(r)d(!fc(a.value),"If we're adding a query, it shouldn't be shadowed");else{const t=a.fold(((e,t,n)=>{if(!Xo(e)&&t&&fc(t))return[mc(t).query];{let e=[];return t&&(e=e.concat(hc(t).map((e=>e.query)))),ho(n,((t,n)=>{e=e.concat(n)})),e}}));for(let n=0;n<t.length;++n){const i=t[n];e.listenProvider_.stopListening(Ac(i),xc(e,i))}}return o}
2832
+ */let vc=1;class yc{constructor(e){this.listenProvider_=e,this.syncPointTree_=new vl(null),this.pendingWriteTree_={visibleWrites:yl.empty(),allWrites:[],lastWriteId:-1},this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function wc(e,t,n,i,r){return function(e,t,n,i,r){d(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=wl(e.visibleWrites,t,n)),e.lastWriteId=i}(e.pendingWriteTree_,t,n,i,r),r?Tc(e,new ol({fromUser:!0,fromServer:!1,queryId:null,tagged:!1},t,n)):[]}function bc(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(Rl(e.pendingWriteTree_,t)){let t=new vl(null);return null!=i.snap?t=t.set(Vo(),!0):ho(i.children,(e=>{t=t.set(new qo(e),!0)})),Tc(e,new rl(i.path,t,n))}return[]}function _c(e,t,n){return Tc(e,new ol({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},t,n))}function kc(e,t,n,i,r=!1){const s=t._path,o=e.syncPointTree_.get(s);let a=[];if(o&&("default"===t._queryIdentifier||gc(o,t))){const l=uc(o,t,n,i);0===o.views.size&&(e.syncPointTree_=e.syncPointTree_.remove(s));const c=l.removed;if(a=l.events,!r){const n=-1!==c.findIndex((e=>e._queryParams.loadsAllData())),r=e.syncPointTree_.findOnPath(s,((e,t)=>fc(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&&fc(t)){return[mc(t)]}{let e=[];return t&&(e=hc(t)),ho(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=Pc(e,i);e.listenProvider_.startListening(Ac(r),xc(e,r),s.hashFn,s.onComplete)}}}if(!r&&c.length>0&&!i)if(n){const n=null;e.listenProvider_.stopListening(Ac(t),n)}else c.forEach((t=>{const n=e.queryToTagMap.get(Rc(t));e.listenProvider_.stopListening(Ac(t),n)}))}!function(e,t){for(let n=0;n<t.length;++n){const i=t[n];if(!i._queryParams.loadsAllData()){const t=Rc(i),n=e.queryToTagMap.get(t);e.queryToTagMap.delete(t),e.tagToQueryMap.delete(n)}}}(e,c)}return a}function Cc(e,t,n,i=!1){const r=t._path;let s=null,o=!1;e.syncPointTree_.foreachOnPath(r,((e,t)=>{const n=Xo(e,r);s=s||dc(t,n),o=o||fc(t)}));let a,l=e.syncPointTree_.get(r);if(l?(o=o||fc(l),s=s||dc(l,Vo())):(l=new ac,e.syncPointTree_=e.syncPointTree_.set(r,l)),null!=s)a=!0;else{a=!1,s=Da.EMPTY_NODE;e.syncPointTree_.subtree(r).foreachChild(((e,t)=>{const n=dc(t,Vo());n&&(s=s.updateImmediateChild(e,n))}))}const c=gc(l,t);if(!c&&!t._queryParams.loadsAllData()){const n=Rc(t);d(!e.queryToTagMap.has(n),"View does not exist, but we have a tag");const i=vc++;e.queryToTagMap.set(n,i),e.tagToQueryMap.set(i,n)}let u=cc(l,t,n,xl(e.pendingWriteTree_,r),s,a);if(!c&&!o&&!i){const n=pc(l,t);u=u.concat(function(e,t,n){const i=t._path,r=xc(e,t),s=Pc(e,n),o=e.listenProvider_.startListening(Ac(t),r,s.hashFn,s.onComplete),a=e.syncPointTree_.subtree(i);if(r)d(!fc(a.value),"If we're adding a query, it shouldn't be shadowed");else{const t=a.fold(((e,t,n)=>{if(!Zo(e)&&t&&fc(t))return[mc(t).query];{let e=[];return t&&(e=e.concat(hc(t).map((e=>e.query)))),ho(n,((t,n)=>{e=e.concat(n)})),e}}));for(let n=0;n<t.length;++n){const i=t[n];e.listenProvider_.stopListening(Ac(i),xc(e,i))}}return o}
2833
2833
  /**
2834
2834
  * @license
2835
2835
  * Copyright 2017 Google LLC
@@ -2845,7 +2845,7 @@ class qa{constructor(e){this.index_=e}updateChild(e,t,n,i,r,s){d(e.isIndexed(thi
2845
2845
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2846
2846
  * See the License for the specific language governing permissions and
2847
2847
  * limitations under the License.
2848
- */(e,t,n))}return u}function Sc(e,t,n){const i=e.pendingWriteTree_,r=e.syncPointTree_.findOnPath(t,((e,n)=>{const i=dc(n,Zo(e,t));if(i)return i}));return Al(i,t,r,n,!0)}function Tc(e,t){return Ic(t,e.syncPointTree_,null,xl(e.pendingWriteTree_,Vo()))}function Ic(e,t,n,i){if(Xo(e.path))return Ec(e,t,n,i);{const r=t.get(Vo());null==n&&null!=r&&(n=dc(r,Vo()));let s=[];const o=Bo(e.path),a=e.operationForChild(o),l=t.children.get(o);if(l&&a){const e=n?n.getImmediateChild(o):null,t=$l(i,o);s=s.concat(Ic(a,l,e,t))}return r&&(s=s.concat(lc(r,e,i,n))),s}}function Ec(e,t,n,i){const r=t.get(Vo());null==n&&null!=r&&(n=dc(r,Vo()));let s=[];return t.children.inorderTraversal(((t,r)=>{const o=n?n.getImmediateChild(t):null,a=$l(i,t),l=e.operationForChild(t);l&&(s=s.concat(Ec(l,r,o,a)))})),r&&(s=s.concat(lc(r,e,i,n))),s}function Pc(e,t){const n=t.query,i=xc(e,n);return{hashFn:()=>{const e=function(e){return e.viewCache_.serverCache.getNode()}(t)||Da.EMPTY_NODE;return e.hash()},onComplete:t=>{if("ok"===t)return i?function(e,t,n){const i=Lc(e,n);if(i){const n=Nc(i),r=n.path,s=n.queryId,o=Zo(r,t);return Dc(e,r,new sl(il(s),o))}return[]}(e,n._path,i):function(e,t){return Tc(e,new sl({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 kc(e,n,null,i)}}}}function xc(e,t){const n=Rc(t);return e.queryToTagMap.get(n)}function Rc(e){return e._path.toString()+"$"+e._queryIdentifier}function Lc(e,t){return e.tagToQueryMap.get(t)}function Nc(e){const t=e.indexOf("$");return d(-1!==t&&t<e.length-1,"Bad queryKey."),{queryId:e.substr(t+1),path:new qo(e.substr(0,t))}}function Dc(e,t,n){const i=e.syncPointTree_.get(t);d(i,"Missing sync point for query tag that we're tracking");return lc(i,n,xl(e.pendingWriteTree_,t),null)}function Ac(e){return e._queryParams.loadsAllData()&&!e._queryParams.isDefault()?new(d(ec,"Reference.ts has not been loaded"),ec)(e._repo,e._path):e}class Mc{constructor(e){this.node_=e}getImmediateChild(e){const t=this.node_.getImmediateChild(e);return new Mc(t)}node(){return this.node_}}class Oc{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){const t=Jo(this.path_,e);return new Oc(this.syncTree_,t)}node(){return Sc(this.syncTree_,this.path_)}}const jc=function(e,t,n){return e&&"object"==typeof e?(d(".sv"in e,"Unexpected leaf node or priority contents"),"string"==typeof e[".sv"]?Fc(e[".sv"],t,n):"object"==typeof e[".sv"]?Uc(e[".sv"],t):void d(!1,"Unexpected server value: "+JSON.stringify(e,null,2))):e},Fc=function(e,t,n){if("timestamp"===e)return n.timestamp;d(!1,"Unexpected server value: "+e)},Uc=function(e,t,n){e.hasOwnProperty("increment")||d(!1,"Unexpected server value: "+JSON.stringify(e,null,2));const i=e.increment;"number"!=typeof i&&d(!1,"Unexpected increment value: "+i);const r=t.node();if(d(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 $c(e,new Mc(t),n)};function $c(e,t,n){const i=e.getPriority().val(),r=jc(i,t.getImmediateChild(".priority"),n);let s;if(e.isLeafNode()){const i=e,s=jc(i.getValue(),t,n);return s!==i.getValue()||r!==i.getPriority().val()?new Sa(s,Ma(r)):e}{const i=e;return s=i,r!==i.getPriority().val()&&(s=s.updatePriority(new Sa(r))),i.forEachChild(Ta,((e,i)=>{const r=$c(i,t.getImmediateChild(e),n);r!==i&&(s=s.updateImmediateChild(e,r))})),s}}
2848
+ */(e,t,n))}return u}function Sc(e,t,n){const i=e.pendingWriteTree_,r=e.syncPointTree_.findOnPath(t,((e,n)=>{const i=dc(n,Xo(e,t));if(i)return i}));return Al(i,t,r,n,!0)}function Tc(e,t){return Ic(t,e.syncPointTree_,null,xl(e.pendingWriteTree_,Vo()))}function Ic(e,t,n,i){if(Zo(e.path))return Ec(e,t,n,i);{const r=t.get(Vo());null==n&&null!=r&&(n=dc(r,Vo()));let s=[];const o=Bo(e.path),a=e.operationForChild(o),l=t.children.get(o);if(l&&a){const e=n?n.getImmediateChild(o):null,t=$l(i,o);s=s.concat(Ic(a,l,e,t))}return r&&(s=s.concat(lc(r,e,i,n))),s}}function Ec(e,t,n,i){const r=t.get(Vo());null==n&&null!=r&&(n=dc(r,Vo()));let s=[];return t.children.inorderTraversal(((t,r)=>{const o=n?n.getImmediateChild(t):null,a=$l(i,t),l=e.operationForChild(t);l&&(s=s.concat(Ec(l,r,o,a)))})),r&&(s=s.concat(lc(r,e,i,n))),s}function Pc(e,t){const n=t.query,i=xc(e,n);return{hashFn:()=>{const e=function(e){return e.viewCache_.serverCache.getNode()}(t)||Da.EMPTY_NODE;return e.hash()},onComplete:t=>{if("ok"===t)return i?function(e,t,n){const i=Lc(e,n);if(i){const n=Nc(i),r=n.path,s=n.queryId,o=Xo(r,t);return Dc(e,r,new sl(il(s),o))}return[]}(e,n._path,i):function(e,t){return Tc(e,new sl({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 kc(e,n,null,i)}}}}function xc(e,t){const n=Rc(t);return e.queryToTagMap.get(n)}function Rc(e){return e._path.toString()+"$"+e._queryIdentifier}function Lc(e,t){return e.tagToQueryMap.get(t)}function Nc(e){const t=e.indexOf("$");return d(-1!==t&&t<e.length-1,"Bad queryKey."),{queryId:e.substr(t+1),path:new qo(e.substr(0,t))}}function Dc(e,t,n){const i=e.syncPointTree_.get(t);d(i,"Missing sync point for query tag that we're tracking");return lc(i,n,xl(e.pendingWriteTree_,t),null)}function Ac(e){return e._queryParams.loadsAllData()&&!e._queryParams.isDefault()?new(d(ec,"Reference.ts has not been loaded"),ec)(e._repo,e._path):e}class Mc{constructor(e){this.node_=e}getImmediateChild(e){const t=this.node_.getImmediateChild(e);return new Mc(t)}node(){return this.node_}}class Oc{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){const t=Jo(this.path_,e);return new Oc(this.syncTree_,t)}node(){return Sc(this.syncTree_,this.path_)}}const jc=function(e,t,n){return e&&"object"==typeof e?(d(".sv"in e,"Unexpected leaf node or priority contents"),"string"==typeof e[".sv"]?Fc(e[".sv"],t,n):"object"==typeof e[".sv"]?Uc(e[".sv"],t):void d(!1,"Unexpected server value: "+JSON.stringify(e,null,2))):e},Fc=function(e,t,n){if("timestamp"===e)return n.timestamp;d(!1,"Unexpected server value: "+e)},Uc=function(e,t,n){e.hasOwnProperty("increment")||d(!1,"Unexpected server value: "+JSON.stringify(e,null,2));const i=e.increment;"number"!=typeof i&&d(!1,"Unexpected increment value: "+i);const r=t.node();if(d(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 $c(e,new Mc(t),n)};function $c(e,t,n){const i=e.getPriority().val(),r=jc(i,t.getImmediateChild(".priority"),n);let s;if(e.isLeafNode()){const i=e,s=jc(i.getValue(),t,n);return s!==i.getValue()||r!==i.getPriority().val()?new Sa(s,Ma(r)):e}{const i=e;return s=i,r!==i.getPriority().val()&&(s=s.updatePriority(new Sa(r))),i.forEachChild(Ta,((e,i)=>{const r=$c(i,t.getImmediateChild(e),n);r!==i&&(s=s.updateImmediateChild(e,r))})),s}}
2849
2849
  /**
2850
2850
  * @license
2851
2851
  * Copyright 2017 Google LLC
@@ -2877,7 +2877,7 @@ class qa{constructor(e){this.index_=e}updateChild(e,t,n,i,r,s){d(e.isIndexed(thi
2877
2877
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2878
2878
  * See the License for the specific language governing permissions and
2879
2879
  * limitations under the License.
2880
- */(e.parent,e.name,e)}const Xc=/[\[\].#$\/\u0000-\u001F\u007F]/,Zc=/[\[\].#$\u0000-\u001F\u007F]/,Qc=10485760,eu=function(e){return"string"==typeof e&&0!==e.length&&!Xc.test(e)},tu=function(e){return"string"==typeof e&&0!==e.length&&!Zc.test(e)},nu=function(e){return null===e||"string"==typeof e||"number"==typeof e&&!io(e)||e&&"object"==typeof e&&W(e,".sv")},iu=function(e,t,n,i){i&&void 0===t||ru(ne(e,"value"),t,n)},ru=function(e,t,n){const i=n instanceof qo?new na(n,e):n;if(void 0===t)throw new Error(e+"contains undefined "+ra(i));if("function"==typeof t)throw new Error(e+"contains a function "+ra(i)+" with contents = "+t.toString());if(io(t))throw new Error(e+"contains "+t.toString()+" "+ra(i));if("string"==typeof t&&t.length>Qc/3&&ie(t)>Qc)throw new Error(e+"contains a string greater than "+Qc+" utf8 bytes "+ra(i)+" ('"+t.substring(0,50)+"...')");if(t&&"object"==typeof t){let n=!1,r=!1;if(ho(t,((t,s)=>{if(".value"===t)n=!0;else if(".priority"!==t&&".sv"!==t&&(r=!0,!eu(t)))throw new Error(e+" contains an invalid key ("+t+") "+ra(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_+=ie(t),ia(e)}(i,t),ru(e,s,i),function(e){const t=e.parts_.pop();e.byteLength_-=ie(t),e.parts_.length>0&&(e.byteLength_-=1)}(i)})),n&&r)throw new Error(e+' contains ".value" child '+ra(i)+" in addition to actual children.")}},su=function(e,t,n,i){const r=ne(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=[];ho(t,((e,t)=>{const i=new qo(e);if(ru(r,t,Jo(n,i)),".priority"===Go(i)&&!nu(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=Ko(i);for(let t=0;t<r.length;t++)if(".priority"===r[t]&&t===r.length-1);else if(!eu(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(Qo);let r=null;for(n=0;n<t.length;n++){if(i=t[n],null!==r&&ta(r,i))throw new Error(e+"contains a path "+r.toString()+" that is ancestor of another path "+i.toString());r=i}}(r,s)},ou=function(e,t,n,i){if(!tu(n))throw new Error(ne(e,t)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')},au=function(e,t){if(".info"===Bo(t))throw new Error(e+" failed = Can't modify data under /.info/")},lu=function(e,t){const n=t.path.toString();if("string"!=typeof t.repoInfo.host||0===t.repoInfo.host.length||!eu(t.repoInfo.namespace)&&"localhost"!==t.repoInfo.host.split(":")[0]||0!==n.length&&!function(e){return e&&(e=e.replace(/^\/*\.info(\/|$)/,"/")),tu(e)}(n))throw new Error(ne(e,"url")+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')};
2880
+ */(e.parent,e.name,e)}const Zc=/[\[\].#$\/\u0000-\u001F\u007F]/,Xc=/[\[\].#$\u0000-\u001F\u007F]/,Qc=10485760,eu=function(e){return"string"==typeof e&&0!==e.length&&!Zc.test(e)},tu=function(e){return"string"==typeof e&&0!==e.length&&!Xc.test(e)},nu=function(e){return null===e||"string"==typeof e||"number"==typeof e&&!io(e)||e&&"object"==typeof e&&W(e,".sv")},iu=function(e,t,n,i){i&&void 0===t||ru(ne(e,"value"),t,n)},ru=function(e,t,n){const i=n instanceof qo?new na(n,e):n;if(void 0===t)throw new Error(e+"contains undefined "+ra(i));if("function"==typeof t)throw new Error(e+"contains a function "+ra(i)+" with contents = "+t.toString());if(io(t))throw new Error(e+"contains "+t.toString()+" "+ra(i));if("string"==typeof t&&t.length>Qc/3&&ie(t)>Qc)throw new Error(e+"contains a string greater than "+Qc+" utf8 bytes "+ra(i)+" ('"+t.substring(0,50)+"...')");if(t&&"object"==typeof t){let n=!1,r=!1;if(ho(t,((t,s)=>{if(".value"===t)n=!0;else if(".priority"!==t&&".sv"!==t&&(r=!0,!eu(t)))throw new Error(e+" contains an invalid key ("+t+") "+ra(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_+=ie(t),ia(e)}(i,t),ru(e,s,i),function(e){const t=e.parts_.pop();e.byteLength_-=ie(t),e.parts_.length>0&&(e.byteLength_-=1)}(i)})),n&&r)throw new Error(e+' contains ".value" child '+ra(i)+" in addition to actual children.")}},su=function(e,t,n,i){const r=ne(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=[];ho(t,((e,t)=>{const i=new qo(e);if(ru(r,t,Jo(n,i)),".priority"===Go(i)&&!nu(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=Ko(i);for(let t=0;t<r.length;t++)if(".priority"===r[t]&&t===r.length-1);else if(!eu(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(Qo);let r=null;for(n=0;n<t.length;n++){if(i=t[n],null!==r&&ta(r,i))throw new Error(e+"contains a path "+r.toString()+" that is ancestor of another path "+i.toString());r=i}}(r,s)},ou=function(e,t,n,i){if(!tu(n))throw new Error(ne(e,t)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')},au=function(e,t){if(".info"===Bo(t))throw new Error(e+" failed = Can't modify data under /.info/")},lu=function(e,t){const n=t.path.toString();if("string"!=typeof t.repoInfo.host||0===t.repoInfo.host.length||!eu(t.repoInfo.namespace)&&"localhost"!==t.repoInfo.host.split(":")[0]||0!==n.length&&!function(e){return e&&(e=e.replace(/^\/*\.info(\/|$)/,"/")),tu(e)}(n))throw new Error(ne(e,"url")+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')};
2881
2881
  /**
2882
2882
  * @license
2883
2883
  * Copyright 2017 Google LLC
@@ -2894,7 +2894,7 @@ class qa{constructor(e){this.index_=e}updateChild(e,t,n,i,r,s){d(e.isIndexed(thi
2894
2894
  * See the License for the specific language governing permissions and
2895
2895
  * limitations under the License.
2896
2896
  */
2897
- class cu{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function uu(e,t){let n=null;for(let i=0;i<t.length;i++){const r=t[i],s=r.getPath();null===n||ea(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 hu(e,t,n){uu(e,n),pu(e,(e=>ea(e,t)))}function du(e,t,n){uu(e,n),pu(e,(e=>ta(e,t)||ta(t,e)))}function pu(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)?(gu(e.eventLists_[i]),e.eventLists_[i]=null):n=!1}}n&&(e.eventLists_=[]),e.recursionDepth_--}function gu(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();Js&&Zs("event: "+n.toString()),mo(i)}}}
2897
+ class cu{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function uu(e,t){let n=null;for(let i=0;i<t.length;i++){const r=t[i],s=r.getPath();null===n||ea(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 hu(e,t,n){uu(e,n),pu(e,(e=>ea(e,t)))}function du(e,t,n){uu(e,n),pu(e,(e=>ta(e,t)||ta(t,e)))}function pu(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)?(gu(e.eventLists_[i]),e.eventLists_[i]=null):n=!1}}n&&(e.eventLists_=[]),e.recursionDepth_--}function gu(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();Js&&Xs("event: "+n.toString()),mo(i)}}}
2898
2898
  /**
2899
2899
  * @license
2900
2900
  * Copyright 2017 Google LLC
@@ -2910,7 +2910,7 @@ class cu{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function uu(e
2910
2910
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2911
2911
  * See the License for the specific language governing permissions and
2912
2912
  * limitations under the License.
2913
- */class fu{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 cu,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=Ja(),this.transactionQueueTree_=new qc,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function mu(e,t,n){if(e.stats_=Ro(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 Ka(e.repoInfo_,((t,n,i,r)=>{wu(e,t,n,i,r)}),e.authTokenProvider_,e.appCheckProvider_),setTimeout((()=>bu(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 aa(e.repoInfo_,t,((t,n,i,r)=>{wu(e,t,n,i,r)}),(t=>{bu(e,t)}),(t=>{!function(e,t){ho(t,((t,n)=>{_u(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 xo[n]||(xo[n]=t()),xo[n]}(e.repoInfo_,(()=>new tl(e.stats_,e.server_))),e.infoData_=new Ya,e.infoSyncTree_=new yc({startListening:(t,n,i,r)=>{let s=[];const o=e.infoData_.getNode(t._path);return o.isEmpty()||(s=_c(e.infoSyncTree_,t._path,o),setTimeout((()=>{r("ok")}),0)),s},stopListening:()=>{}}),_u(e,"connected",!1),e.serverSyncTree_=new yc({startListening:(t,n,i,r)=>(e.server_.listen(t,i,n,((n,i)=>{const s=r(n,i);du(e.eventQueue_,t._path,s)})),[]),stopListening:(t,n)=>{e.server_.unlisten(t,n)}})}function vu(e){const t=e.infoData_.getNode(new qo(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+t}function yu(e){return(t=(t={timestamp:vu(e)})||{}).timestamp=t.timestamp||(new Date).getTime(),t;var t}function wu(e,t,n,i,r){e.dataUpdateCount++;const s=new qo(t);n=e.interceptServerDataCallback_?e.interceptServerDataCallback_(t,n):n;let o=[];if(r)if(i){const t=Y(n,(e=>Ma(e)));o=function(e,t,n,i){const r=Lc(e,i);if(r){const i=Nc(r),s=i.path,o=i.queryId,a=Zo(s,t),l=vl.fromObject(n);return Dc(e,s,new al(il(o),a,l))}return[]}(e.serverSyncTree_,s,t,r)}else{const t=Ma(n);o=function(e,t,n,i){const r=Lc(e,i);if(null!=r){const i=Nc(r),s=i.path,o=i.queryId,a=Zo(s,t);return Dc(e,s,new ol(il(o),a,n))}return[]}(e.serverSyncTree_,s,t,r)}else if(i){const t=Y(n,(e=>Ma(e)));o=function(e,t,n){const i=vl.fromObject(n);return Tc(e,new al({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},t,i))}(e.serverSyncTree_,s,t)}else{const t=Ma(n);o=_c(e.serverSyncTree_,s,t)}let a=s;o.length>0&&(a=Ru(e,s)),du(e.eventQueue_,a,o)}function bu(e,t){_u(e,"connected",t),!1===t&&function(e){Iu(e,"onDisconnectEvents");const t=yu(e),n=Ja();Qa(e.onDisconnect_,Vo(),((i,r)=>{const s=function(e,t,n,i){return $c(t,new Oc(n,e),i)}(i,r,e.serverSyncTree_,t);Xa(n,i,s)}));let i=[];Qa(n,Vo(),((t,n)=>{i=i.concat(_c(e.serverSyncTree_,t,n));const r=Mu(e,t);Ru(e,r)})),e.onDisconnect_=Ja(),du(e.eventQueue_,Vo(),i)}(e)}function _u(e,t,n){const i=new qo("/.info/"+t),r=Ma(n);e.infoData_.updateSnapshot(i,r);const s=_c(e.infoSyncTree_,i,r);du(e.eventQueue_,i,s)}function ku(e){return e.nextWriteId_++}function Cu(e,t,n){e.server_.onDisconnectCancel(t.toString(),((i,r)=>{"ok"===i&&Za(e.onDisconnect_,t),Eu(e,n,i,r)}))}function Su(e,t,n,i){const r=Ma(n);e.server_.onDisconnectPut(t.toString(),r.val(!0),((n,s)=>{"ok"===n&&Xa(e.onDisconnect_,t,r),Eu(e,i,n,s)}))}function Tu(e,t,n){let i;i=".info"===Bo(t._path)?kc(e.infoSyncTree_,t,n):kc(e.serverSyncTree_,t,n),hu(e.eventQueue_,t._path,i)}function Iu(e,...t){let n="";e.persistentConnection_&&(n=e.persistentConnection_.id+":"),Zs(n,...t)}function Eu(e,t,n,i){t&&mo((()=>{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 Pu(e,t,n){return Sc(e.serverSyncTree_,t,n)||Da.EMPTY_NODE}function xu(e,t=e.transactionQueueTree_){if(t||Au(e,t),Bc(t)){const n=Nu(e,t);d(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=Pu(e,t,i);let s=r;const o=r.hash();for(let e=0;e<n.length;e++){const i=n[e];d(0===i.status,"tryToSendTransactionQueue_: items in queue should all be run."),i.status=1,i.retryCount++;const r=Zo(t,i.path);s=s.updateChild(r,i.currentOutputSnapshotRaw)}const a=s.val(!0),l=t;e.server_.put(l.toString(),a,(i=>{Iu(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(bc(e.serverSyncTree_,n[t].currentWriteId)),n[t].onComplete&&i.push((()=>n[t].onComplete(null,!0,n[t].currentOutputSnapshotResolved))),n[t].unwatcher();Au(e,Vc(e.transactionQueueTree_,t)),xu(e,e.transactionQueueTree_),du(e.eventQueue_,t,r);for(let e=0;e<i.length;e++)mo(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{no("transaction at "+l.toString()+" failed: "+i);for(let e=0;e<n.length;e++)n[e].status=4,n[e].abortReason=i}Ru(e,t)}}),o)}(e,Yc(t),n)}else Wc(t)&&Gc(t,(t=>{xu(e,t)}))}function Ru(e,t){const n=Lu(e,t),i=Yc(n);return function(e,t,n){if(0===t.length)return;const i=[];let r=[];const s=t.filter((e=>0===e.status)),o=s.map((e=>e.currentWriteId));for(let s=0;s<t.length;s++){const l=t[s],c=Zo(n,l.path);let u,h=!1;if(d(null!==c,"rerunTransactionsUnderNode_: relativePath should not be null."),4===l.status)h=!0,u=l.abortReason,r=r.concat(bc(e.serverSyncTree_,l.currentWriteId,!0));else if(0===l.status)if(l.retryCount>=25)h=!0,u="maxretry",r=r.concat(bc(e.serverSyncTree_,l.currentWriteId,!0));else{const n=Pu(e,l.path,o);l.currentInputSnapshot=n;const i=t[s].update(n.val());if(void 0!==i){ru("transaction failed: Data returned ",i,l.path);let t=Ma(i);"object"==typeof i&&null!=i&&W(i,".priority")||(t=t.updatePriority(n.getPriority()));const s=l.currentWriteId,a=yu(e),c=zc(t,n,a);l.currentOutputSnapshotRaw=t,l.currentOutputSnapshotResolved=c,l.currentWriteId=ku(e),o.splice(o.indexOf(s),1),r=r.concat(wc(e.serverSyncTree_,l.path,c,l.currentWriteId,l.applyLocally)),r=r.concat(bc(e.serverSyncTree_,s,!0))}else h=!0,u="nodata",r=r.concat(bc(e.serverSyncTree_,l.currentWriteId,!0))}du(e.eventQueue_,n,r),r=[],h&&(t[s].status=2,a=t[s].unwatcher,setTimeout(a,Math.floor(0)),t[s].onComplete&&("nodata"===u?i.push((()=>t[s].onComplete(null,!1,t[s].currentInputSnapshot))):i.push((()=>t[s].onComplete(new Error(u),!1,null)))))}var a;Au(e,e.transactionQueueTree_);for(let e=0;e<i.length;e++)mo(i[e]);xu(e,e.transactionQueueTree_)}(e,Nu(e,n),i),i}function Lu(e,t){let n,i=e.transactionQueueTree_;for(n=Bo(t);null!==n&&void 0===Bc(i);)i=Vc(i,n),n=Bo(t=Wo(t));return i}function Nu(e,t){const n=[];return Du(e,t,n),n.sort(((e,t)=>e.order-t.order)),n}function Du(e,t,n){const i=Bc(t);if(i)for(let e=0;e<i.length;e++)n.push(i[e]);Gc(t,(t=>{Du(e,t,n)}))}function Au(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,Hc(t,n.length>0?n:void 0)}Gc(t,(t=>{Au(e,t)}))}function Mu(e,t){const n=Yc(Lu(e,t)),i=Vc(e.transactionQueueTree_,t);return function(e,t){let n=e.parent;for(;null!==n;){if(t(n))return!0;n=n.parent}}(i,(t=>{Ou(e,t)})),Ou(e,i),Kc(i,(t=>{Ou(e,t)})),n}function Ou(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?(d(s===t-1,"All SENT items should be at beginning of queue."),s=t,n[t].status=3,n[t].abortReason="set"):(d(0===n[t].status,"Unexpected transaction status in abort"),n[t].unwatcher(),r=r.concat(bc(e.serverSyncTree_,n[t].currentWriteId,!0)),n[t].onComplete&&i.push(n[t].onComplete.bind(null,new Error("set"),!1,null))));-1===s?Hc(t,void 0):n.length=s+1,du(e.eventQueue_,Yc(t),r);for(let e=0;e<i.length;e++)mo(i[e])}}
2913
+ */class fu{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 cu,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=Ja(),this.transactionQueueTree_=new qc,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function mu(e,t,n){if(e.stats_=Ro(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 Ka(e.repoInfo_,((t,n,i,r)=>{wu(e,t,n,i,r)}),e.authTokenProvider_,e.appCheckProvider_),setTimeout((()=>bu(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 aa(e.repoInfo_,t,((t,n,i,r)=>{wu(e,t,n,i,r)}),(t=>{bu(e,t)}),(t=>{!function(e,t){ho(t,((t,n)=>{_u(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 xo[n]||(xo[n]=t()),xo[n]}(e.repoInfo_,(()=>new tl(e.stats_,e.server_))),e.infoData_=new Ya,e.infoSyncTree_=new yc({startListening:(t,n,i,r)=>{let s=[];const o=e.infoData_.getNode(t._path);return o.isEmpty()||(s=_c(e.infoSyncTree_,t._path,o),setTimeout((()=>{r("ok")}),0)),s},stopListening:()=>{}}),_u(e,"connected",!1),e.serverSyncTree_=new yc({startListening:(t,n,i,r)=>(e.server_.listen(t,i,n,((n,i)=>{const s=r(n,i);du(e.eventQueue_,t._path,s)})),[]),stopListening:(t,n)=>{e.server_.unlisten(t,n)}})}function vu(e){const t=e.infoData_.getNode(new qo(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+t}function yu(e){return(t=(t={timestamp:vu(e)})||{}).timestamp=t.timestamp||(new Date).getTime(),t;var t}function wu(e,t,n,i,r){e.dataUpdateCount++;const s=new qo(t);n=e.interceptServerDataCallback_?e.interceptServerDataCallback_(t,n):n;let o=[];if(r)if(i){const t=Y(n,(e=>Ma(e)));o=function(e,t,n,i){const r=Lc(e,i);if(r){const i=Nc(r),s=i.path,o=i.queryId,a=Xo(s,t),l=vl.fromObject(n);return Dc(e,s,new al(il(o),a,l))}return[]}(e.serverSyncTree_,s,t,r)}else{const t=Ma(n);o=function(e,t,n,i){const r=Lc(e,i);if(null!=r){const i=Nc(r),s=i.path,o=i.queryId,a=Xo(s,t);return Dc(e,s,new ol(il(o),a,n))}return[]}(e.serverSyncTree_,s,t,r)}else if(i){const t=Y(n,(e=>Ma(e)));o=function(e,t,n){const i=vl.fromObject(n);return Tc(e,new al({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},t,i))}(e.serverSyncTree_,s,t)}else{const t=Ma(n);o=_c(e.serverSyncTree_,s,t)}let a=s;o.length>0&&(a=Ru(e,s)),du(e.eventQueue_,a,o)}function bu(e,t){_u(e,"connected",t),!1===t&&function(e){Iu(e,"onDisconnectEvents");const t=yu(e),n=Ja();Qa(e.onDisconnect_,Vo(),((i,r)=>{const s=function(e,t,n,i){return $c(t,new Oc(n,e),i)}(i,r,e.serverSyncTree_,t);Za(n,i,s)}));let i=[];Qa(n,Vo(),((t,n)=>{i=i.concat(_c(e.serverSyncTree_,t,n));const r=Mu(e,t);Ru(e,r)})),e.onDisconnect_=Ja(),du(e.eventQueue_,Vo(),i)}(e)}function _u(e,t,n){const i=new qo("/.info/"+t),r=Ma(n);e.infoData_.updateSnapshot(i,r);const s=_c(e.infoSyncTree_,i,r);du(e.eventQueue_,i,s)}function ku(e){return e.nextWriteId_++}function Cu(e,t,n){e.server_.onDisconnectCancel(t.toString(),((i,r)=>{"ok"===i&&Xa(e.onDisconnect_,t),Eu(e,n,i,r)}))}function Su(e,t,n,i){const r=Ma(n);e.server_.onDisconnectPut(t.toString(),r.val(!0),((n,s)=>{"ok"===n&&Za(e.onDisconnect_,t,r),Eu(e,i,n,s)}))}function Tu(e,t,n){let i;i=".info"===Bo(t._path)?kc(e.infoSyncTree_,t,n):kc(e.serverSyncTree_,t,n),hu(e.eventQueue_,t._path,i)}function Iu(e,...t){let n="";e.persistentConnection_&&(n=e.persistentConnection_.id+":"),Xs(n,...t)}function Eu(e,t,n,i){t&&mo((()=>{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 Pu(e,t,n){return Sc(e.serverSyncTree_,t,n)||Da.EMPTY_NODE}function xu(e,t=e.transactionQueueTree_){if(t||Au(e,t),Bc(t)){const n=Nu(e,t);d(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=Pu(e,t,i);let s=r;const o=r.hash();for(let e=0;e<n.length;e++){const i=n[e];d(0===i.status,"tryToSendTransactionQueue_: items in queue should all be run."),i.status=1,i.retryCount++;const r=Xo(t,i.path);s=s.updateChild(r,i.currentOutputSnapshotRaw)}const a=s.val(!0),l=t;e.server_.put(l.toString(),a,(i=>{Iu(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(bc(e.serverSyncTree_,n[t].currentWriteId)),n[t].onComplete&&i.push((()=>n[t].onComplete(null,!0,n[t].currentOutputSnapshotResolved))),n[t].unwatcher();Au(e,Vc(e.transactionQueueTree_,t)),xu(e,e.transactionQueueTree_),du(e.eventQueue_,t,r);for(let e=0;e<i.length;e++)mo(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{no("transaction at "+l.toString()+" failed: "+i);for(let e=0;e<n.length;e++)n[e].status=4,n[e].abortReason=i}Ru(e,t)}}),o)}(e,Yc(t),n)}else Wc(t)&&Gc(t,(t=>{xu(e,t)}))}function Ru(e,t){const n=Lu(e,t),i=Yc(n);return function(e,t,n){if(0===t.length)return;const i=[];let r=[];const s=t.filter((e=>0===e.status)),o=s.map((e=>e.currentWriteId));for(let s=0;s<t.length;s++){const l=t[s],c=Xo(n,l.path);let u,h=!1;if(d(null!==c,"rerunTransactionsUnderNode_: relativePath should not be null."),4===l.status)h=!0,u=l.abortReason,r=r.concat(bc(e.serverSyncTree_,l.currentWriteId,!0));else if(0===l.status)if(l.retryCount>=25)h=!0,u="maxretry",r=r.concat(bc(e.serverSyncTree_,l.currentWriteId,!0));else{const n=Pu(e,l.path,o);l.currentInputSnapshot=n;const i=t[s].update(n.val());if(void 0!==i){ru("transaction failed: Data returned ",i,l.path);let t=Ma(i);"object"==typeof i&&null!=i&&W(i,".priority")||(t=t.updatePriority(n.getPriority()));const s=l.currentWriteId,a=yu(e),c=zc(t,n,a);l.currentOutputSnapshotRaw=t,l.currentOutputSnapshotResolved=c,l.currentWriteId=ku(e),o.splice(o.indexOf(s),1),r=r.concat(wc(e.serverSyncTree_,l.path,c,l.currentWriteId,l.applyLocally)),r=r.concat(bc(e.serverSyncTree_,s,!0))}else h=!0,u="nodata",r=r.concat(bc(e.serverSyncTree_,l.currentWriteId,!0))}du(e.eventQueue_,n,r),r=[],h&&(t[s].status=2,a=t[s].unwatcher,setTimeout(a,Math.floor(0)),t[s].onComplete&&("nodata"===u?i.push((()=>t[s].onComplete(null,!1,t[s].currentInputSnapshot))):i.push((()=>t[s].onComplete(new Error(u),!1,null)))))}var a;Au(e,e.transactionQueueTree_);for(let e=0;e<i.length;e++)mo(i[e]);xu(e,e.transactionQueueTree_)}(e,Nu(e,n),i),i}function Lu(e,t){let n,i=e.transactionQueueTree_;for(n=Bo(t);null!==n&&void 0===Bc(i);)i=Vc(i,n),n=Bo(t=Wo(t));return i}function Nu(e,t){const n=[];return Du(e,t,n),n.sort(((e,t)=>e.order-t.order)),n}function Du(e,t,n){const i=Bc(t);if(i)for(let e=0;e<i.length;e++)n.push(i[e]);Gc(t,(t=>{Du(e,t,n)}))}function Au(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,Hc(t,n.length>0?n:void 0)}Gc(t,(t=>{Au(e,t)}))}function Mu(e,t){const n=Yc(Lu(e,t)),i=Vc(e.transactionQueueTree_,t);return function(e,t){let n=e.parent;for(;null!==n;){if(t(n))return!0;n=n.parent}}(i,(t=>{Ou(e,t)})),Ou(e,i),Kc(i,(t=>{Ou(e,t)})),n}function Ou(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?(d(s===t-1,"All SENT items should be at beginning of queue."),s=t,n[t].status=3,n[t].abortReason="set"):(d(0===n[t].status,"Unexpected transaction status in abort"),n[t].unwatcher(),r=r.concat(bc(e.serverSyncTree_,n[t].currentWriteId,!0)),n[t].onComplete&&i.push(n[t].onComplete.bind(null,new Error("set"),!1,null))));-1===s?Hc(t,void 0):n.length=s+1,du(e.eventQueue_,Yc(t),r);for(let e=0;e<i.length;e++)mo(i[e])}}
2914
2914
  /**
2915
2915
  * @license
2916
2916
  * Copyright 2017 Google LLC
@@ -2975,7 +2975,7 @@ class $u{constructor(e,t,n,i){this.eventType=e,this.eventRegistration=t,this.sna
2975
2975
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2976
2976
  * See the License for the specific language governing permissions and
2977
2977
  * limitations under the License.
2978
- */class Bu{constructor(e,t){this._repo=e,this._path=t}cancel(){const e=new E;return Cu(this._repo,this._path,e.wrapCallback((()=>{}))),e.promise}remove(){au("OnDisconnect.remove",this._path);const e=new E;return Su(this._repo,this._path,null,e.wrapCallback((()=>{}))),e.promise}set(e){au("OnDisconnect.set",this._path),iu("OnDisconnect.set",e,this._path,!1);const t=new E;return Su(this._repo,this._path,e,t.wrapCallback((()=>{}))),t.promise}setWithPriority(e,t){au("OnDisconnect.setWithPriority",this._path),iu("OnDisconnect.setWithPriority",e,this._path,!1),function(e,t){if(io(t))throw new Error(ne(e,"priority")+"is "+t.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!nu(t))throw new Error(ne(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=Ma(n,i);e.server_.onDisconnectPut(t.toString(),s.val(!0),((n,i)=>{"ok"===n&&Xa(e.onDisconnect_,t,s),Eu(0,r,n,i)}))}(this._repo,this._path,e,t,n.wrapCallback((()=>{}))),n.promise}update(e){au("OnDisconnect.update",this._path),su("OnDisconnect.update",e,this._path);const t=new E;return function(e,t,n,i){if(K(n))return Zs("onDisconnect().update() called with empty data. Don't do anything."),void Eu(0,i,"ok",void 0);e.server_.onDisconnectMerge(t.toString(),n,((r,s)=>{"ok"===r&&ho(n,((n,i)=>{const r=Ma(i);Xa(e.onDisconnect_,Jo(t,n),r)})),Eu(0,i,r,s)}))}(this._repo,this._path,e,t.wrapCallback((()=>{}))),t.promise}}
2978
+ */class Bu{constructor(e,t){this._repo=e,this._path=t}cancel(){const e=new E;return Cu(this._repo,this._path,e.wrapCallback((()=>{}))),e.promise}remove(){au("OnDisconnect.remove",this._path);const e=new E;return Su(this._repo,this._path,null,e.wrapCallback((()=>{}))),e.promise}set(e){au("OnDisconnect.set",this._path),iu("OnDisconnect.set",e,this._path,!1);const t=new E;return Su(this._repo,this._path,e,t.wrapCallback((()=>{}))),t.promise}setWithPriority(e,t){au("OnDisconnect.setWithPriority",this._path),iu("OnDisconnect.setWithPriority",e,this._path,!1),function(e,t){if(io(t))throw new Error(ne(e,"priority")+"is "+t.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!nu(t))throw new Error(ne(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=Ma(n,i);e.server_.onDisconnectPut(t.toString(),s.val(!0),((n,i)=>{"ok"===n&&Za(e.onDisconnect_,t,s),Eu(0,r,n,i)}))}(this._repo,this._path,e,t,n.wrapCallback((()=>{}))),n.promise}update(e){au("OnDisconnect.update",this._path),su("OnDisconnect.update",e,this._path);const t=new E;return function(e,t,n,i){if(K(n))return Xs("onDisconnect().update() called with empty data. Don't do anything."),void Eu(0,i,"ok",void 0);e.server_.onDisconnectMerge(t.toString(),n,((r,s)=>{"ok"===r&&ho(n,((n,i)=>{const r=Ma(i);Za(e.onDisconnect_,Jo(t,n),r)})),Eu(0,i,r,s)}))}(this._repo,this._path,e,t.wrapCallback((()=>{}))),t.promise}}
2979
2979
  /**
2980
2980
  * @license
2981
2981
  * Copyright 2020 Google LLC
@@ -2991,7 +2991,7 @@ class $u{constructor(e,t,n,i){this.eventType=e,this.eventRegistration=t,this.sna
2991
2991
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2992
2992
  * See the License for the specific language governing permissions and
2993
2993
  * limitations under the License.
2994
- */class Hu{constructor(e,t,n,i){this._repo=e,this._path=t,this._queryParams=n,this._orderByCalled=i}get key(){return Xo(this._path)?null:Go(this._path)}get ref(){return new Wu(this._repo,this._path)}get _queryIdentifier(){const e=Ga(this._queryParams),t=co(e);return"{}"===t?"default":t}get _queryObject(){return Ga(this._queryParams)}isEqual(e){if(!((e=se(e))instanceof Hu))return!1;const t=this._repo===e._repo,n=ea(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 Wu extends Hu{constructor(e,t){super(e,t,new Ha,!1)}get parent(){const e=Yo(this._path);return null===e?null:new Wu(this._repo,e)}get root(){let e=this;for(;null!==e.parent;)e=e.parent;return e}}class Gu{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 qo(e),n=Yu(this.ref,e);return new Gu(this._node.getChild(t),n,Ta)}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 Gu(n,Yu(this.ref,t),Ta))))}hasChild(e){const t=new qo(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 Ku(e,t){return(e=se(e))._checkNotDeleted("ref"),void 0!==t?Yu(e._root,t):e._root}function Yu(e,t){var n,i,r;return null===Bo((e=se(e))._path)?(n="child",i="path",(r=t)&&(r=r.replace(/^\/*\.info(\/|$)/,"/")),ou(n,i,r)):ou("child","path",t),new Wu(e._repo,Jo(e._path,t))}function Ju(e,t){e=se(e),au("set",e._path),iu("set",t,e._path,!1);const n=new E;return function(e,t,n,i,r){Iu(e,"set",{path:t.toString(),value:n,priority:i});const s=yu(e),o=Ma(n,i),a=Sc(e.serverSyncTree_,t),l=zc(o,a,s),c=ku(e),u=wc(e.serverSyncTree_,t,l,c,!0);uu(e.eventQueue_,u),e.server_.put(t.toString(),o.val(!0),((n,i)=>{const s="ok"===n;s||no("set at "+t+" failed: "+n);const o=bc(e.serverSyncTree_,c,!s);du(e.eventQueue_,t,o),Eu(0,r,n,i)}));const h=Mu(e,t);Ru(e,h),du(e.eventQueue_,h,[])}(e._repo,e._path,t,null,n.wrapCallback((()=>{}))),n.promise}class Xu{constructor(e){this.callbackContext=e}respondsTo(e){return"value"===e}createEvent(e,t){const n=t._queryParams.getIndex();return new $u("value",this,new Gu(e.snapshotNode,new Wu(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 qu(this,e,t):null}matches(e){return e instanceof Xu&&(!e.callbackContext||!this.callbackContext||e.callbackContext.matches(this.callbackContext))}hasAnyCallback(){return null!==this.callbackContext}}function Zu(e,t,n,i,r){const s=new Vu(n,void 0),o=new Xu(s);return function(e,t,n){let i;i=".info"===Bo(t._path)?Cc(e.infoSyncTree_,t,n):Cc(e.serverSyncTree_,t,n),hu(e.eventQueue_,t._path,i)}(e._repo,e,o),()=>Tu(e._repo,e,o)}function Qu(e,t,n,i){return Zu(e,0,t)}!function(e){d(!Ql,"__referenceConstructor has already been defined"),Ql=e}(Wu),function(e){d(!ec,"__referenceConstructor has already been defined"),ec=e}(Wu);
2994
+ */class Hu{constructor(e,t,n,i){this._repo=e,this._path=t,this._queryParams=n,this._orderByCalled=i}get key(){return Zo(this._path)?null:Go(this._path)}get ref(){return new Wu(this._repo,this._path)}get _queryIdentifier(){const e=Ga(this._queryParams),t=co(e);return"{}"===t?"default":t}get _queryObject(){return Ga(this._queryParams)}isEqual(e){if(!((e=se(e))instanceof Hu))return!1;const t=this._repo===e._repo,n=ea(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 Wu extends Hu{constructor(e,t){super(e,t,new Ha,!1)}get parent(){const e=Yo(this._path);return null===e?null:new Wu(this._repo,e)}get root(){let e=this;for(;null!==e.parent;)e=e.parent;return e}}class Gu{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 qo(e),n=Yu(this.ref,e);return new Gu(this._node.getChild(t),n,Ta)}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 Gu(n,Yu(this.ref,t),Ta))))}hasChild(e){const t=new qo(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 Ku(e,t){return(e=se(e))._checkNotDeleted("ref"),void 0!==t?Yu(e._root,t):e._root}function Yu(e,t){var n,i,r;return null===Bo((e=se(e))._path)?(n="child",i="path",(r=t)&&(r=r.replace(/^\/*\.info(\/|$)/,"/")),ou(n,i,r)):ou("child","path",t),new Wu(e._repo,Jo(e._path,t))}function Ju(e,t){e=se(e),au("set",e._path),iu("set",t,e._path,!1);const n=new E;return function(e,t,n,i,r){Iu(e,"set",{path:t.toString(),value:n,priority:i});const s=yu(e),o=Ma(n,i),a=Sc(e.serverSyncTree_,t),l=zc(o,a,s),c=ku(e),u=wc(e.serverSyncTree_,t,l,c,!0);uu(e.eventQueue_,u),e.server_.put(t.toString(),o.val(!0),((n,i)=>{const s="ok"===n;s||no("set at "+t+" failed: "+n);const o=bc(e.serverSyncTree_,c,!s);du(e.eventQueue_,t,o),Eu(0,r,n,i)}));const h=Mu(e,t);Ru(e,h),du(e.eventQueue_,h,[])}(e._repo,e._path,t,null,n.wrapCallback((()=>{}))),n.promise}class Zu{constructor(e){this.callbackContext=e}respondsTo(e){return"value"===e}createEvent(e,t){const n=t._queryParams.getIndex();return new $u("value",this,new Gu(e.snapshotNode,new Wu(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 qu(this,e,t):null}matches(e){return e instanceof Zu&&(!e.callbackContext||!this.callbackContext||e.callbackContext.matches(this.callbackContext))}hasAnyCallback(){return null!==this.callbackContext}}function Xu(e,t,n,i,r){const s=new Vu(n,void 0),o=new Zu(s);return function(e,t,n){let i;i=".info"===Bo(t._path)?Cc(e.infoSyncTree_,t,n):Cc(e.serverSyncTree_,t,n),hu(e.eventQueue_,t._path,i)}(e._repo,e,o),()=>Tu(e._repo,e,o)}function Qu(e,t,n,i){return Xu(e,0,t)}!function(e){d(!Ql,"__referenceConstructor has already been defined"),Ql=e}(Wu),function(e){d(!ec,"__referenceConstructor has already been defined"),ec=e}(Wu);
2995
2995
  /**
2996
2996
  * @license
2997
2997
  * Copyright 2020 Google LLC
@@ -3008,7 +3008,7 @@ class $u{constructor(e,t,n,i){this.eventType=e,this.eventRegistration=t,this.sna
3008
3008
  * See the License for the specific language governing permissions and
3009
3009
  * limitations under the License.
3010
3010
  */
3011
- const eh={};let th,nh,ih,rh,sh=!1;function oh(e,t,n,i,r){let s=i||e.options.databaseURL;void 0===s&&(e.options.projectId||to("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 o,a=ju(s,r),l=a.repoInfo;"undefined"!=typeof process&&process.env&&(o=process.env.FIREBASE_DATABASE_EMULATOR_HOST),o?(s=`http://${o}?ns=${l.namespace}`,a=ju(s,r),l=a.repoInfo):a.repoInfo.secure;const c=new wo(e.name,e.options,t);lu("Invalid Firebase Database URL",a),Xo(a.path)||to("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=eh[t.name];r||(r={},eh[t.name]=r);let s=r[e.toURLString()];s&&to("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call.");return s=new fu(e,sh,n,i),r[e.toURLString()]=s,s}(l,e,c,new yo(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||(mu(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new Wu(this._repo,Vo())),this._rootInternal}_delete(){return null!==this._rootInternal&&(!function(e,t){const n=eh[t];n&&n[e.key]===e||to(`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&&to("Cannot call "+e+" on a deleted database.")}}function lh(e=kt(),t){const n=mt(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=se(e),e._checkNotDeleted("useEmulator");const r=`${t}:${n}`,s=e._repoInternal;if(e._instanceStarted){if(r===e._repoInternal.repoInfo_.host&&J(i,s.repoInfo_.emulatorOptions))return;to("connectDatabaseEmulator() cannot initialize or alter the emulator configuration after the database instance has started.")}let o;if(s.repoInfo_.nodeAdmin)i.mockUserToken&&to('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),o=new bo(bo.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[y(JSON.stringify({alg:"none",type:"JWT"})),y(JSON.stringify(s)),""].join(".")}(i.mockUserToken,e.app.options.projectId);o=new bo(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 To(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,o)}
3011
+ const eh={};let th,nh,ih,rh,sh=!1;function oh(e,t,n,i,r){let s=i||e.options.databaseURL;void 0===s&&(e.options.projectId||to("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),Xs("Using default host for project ",e.options.projectId),s=`${e.options.projectId}-default-rtdb.firebaseio.com`);let o,a=ju(s,r),l=a.repoInfo;"undefined"!=typeof process&&process.env&&(o=process.env.FIREBASE_DATABASE_EMULATOR_HOST),o?(s=`http://${o}?ns=${l.namespace}`,a=ju(s,r),l=a.repoInfo):a.repoInfo.secure;const c=new wo(e.name,e.options,t);lu("Invalid Firebase Database URL",a),Zo(a.path)||to("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=eh[t.name];r||(r={},eh[t.name]=r);let s=r[e.toURLString()];s&&to("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call.");return s=new fu(e,sh,n,i),r[e.toURLString()]=s,s}(l,e,c,new yo(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||(mu(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new Wu(this._repo,Vo())),this._rootInternal}_delete(){return null!==this._rootInternal&&(!function(e,t){const n=eh[t];n&&n[e.key]===e||to(`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&&to("Cannot call "+e+" on a deleted database.")}}function lh(e=kt(),t){const n=mt(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=se(e),e._checkNotDeleted("useEmulator");const r=`${t}:${n}`,s=e._repoInternal;if(e._instanceStarted){if(r===e._repoInternal.repoInfo_.host&&J(i,s.repoInfo_.emulatorOptions))return;to("connectDatabaseEmulator() cannot initialize or alter the emulator configuration after the database instance has started.")}let o;if(s.repoInfo_.nodeAdmin)i.mockUserToken&&to('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),o=new bo(bo.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[y(JSON.stringify({alg:"none",type:"JWT"})),y(JSON.stringify(s)),""].join(".")}(i.mockUserToken,e.app.options.projectId);o=new bo(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 To(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,o)}
3012
3012
  /**
3013
3013
  * @license
3014
3014
  * Copyright 2021 Google LLC
@@ -3024,5 +3024,5 @@ const eh={};let th,nh,ih,rh,sh=!1;function oh(e,t,n,i,r){let s=i||e.options.data
3024
3024
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3025
3025
  * See the License for the specific language governing permissions and
3026
3026
  * limitations under the License.
3027
- */(n,...e)}return n}aa.prototype.simpleListen=function(e,t){this.sendRequest("q",{p:e},t)},aa.prototype.echo=function(e,t){this.sendRequest("echo",{d:e},t)},function(e){!function(e){zs=e}(bt),ft(new oe("database",((e,{instanceIdentifier:t})=>oh(e.getProvider("app").getImmediate(),e.getProvider("auth-internal"),e.getProvider("app-check-internal"),t)),"PUBLIC").setMultipleInstances(!0)),Ct(Fs,Us,e),Ct(Fs,Us,"esm2020")}();let ch=[];function uh(e){const t=[...ch];ch=[],t.forEach((e=>{e()})),e.onFirebaseReady?.()}function hh(e){try{const{projectId:t,firebaseApiKey:n,databaseUrl:i,firebaseSenderId:r,firebaseAppId:s,measurementId:o}=e;if(th=_t({projectId:t,apiKey:n,authDomain:`${t}.firebaseapp.com`,databaseURL:i,storageBucket:`${t}.firebasestorage.app`,messagingSenderId:r,appId:s,measurementId:o},t),!th)return console.error("Failed to initialize Firebase"),!1}catch(e){return console.error("Failed to initialize Firebase",e),!1}return!0}async function dh(e,t,n){if(!th&&!hh(e))return;const{netskraflUserId:i,locale:r,projectId:s,loginMethod:o}=e;nh=Ms(th),nh?function(e,t,n,i){se(e).onAuthStateChanged(t,n,i)}(nh,(t=>{null!==t&&(e.newUser&&fh("sign_up",{locale:r,method:o,userid:i}),fh("login",{locale:r,method:o,userid:i}))})):console.error("Failed to initialize Firebase Auth"),await Tr(nh,t),ih=lh(th),ih?uh(e):console.error("Failed to initialize Firebase Database"),rh=Wn(th),rh||console.error("Failed to initialize Firebase Analytics"),function(e,t,n){if(!ih)return;const i=Ku(ih,".info/connected"),r="netskrafl"===e?`connection/${t}`:`connection/${n}/${t}`,s=function(e,t){e=se(e),au("push",e._path),iu("push",t,e._path,!0);const n=vu(e._repo),i=zu(n),r=Yu(e,i),s=Yu(e,i);let o;return o=Promise.resolve(s),r.then=o.then.bind(o),r.catch=o.then.bind(o,void 0),r}(Ku(ih,r));Qu(i,(e=>{e.val()?(function(e){return e=se(e),new Bu(e._repo,e._path)}(s).remove(),Ju(s,!0)):function(e){au("remove",e._path),Ju(e,null)}(s)}))}(s,i,r)}function ph(e,t){if(!ih)return void ch.push((()=>ph(e,t)));let n=0;Qu(Ku(ih,e),(e=>{n++;const i=e.val();i&&t(i,1===n)}))}function gh(e){if(!ih)return;const t=Ku(ih,e);var n;Tu((n=t)._repo,n,null)}function fh(e,t){rh&&Kn(rh,e,t)}function mh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var vh,yh,wh,bh,_h,kh,Ch,Sh,Th,Ih,Eh,Ph,xh,Rh,Lh,Nh,Dh,Ah,Mh,Oh,jh,Fh,Uh,zh,$h,qh,Vh,Bh,Hh,Wh,Gh,Kh,Yh,Jh,Xh,Zh,Qh,ed,td,nd,id,rd,sd,od,ad,ld,cd,ud,hd,dd,pd,gd,fd,md;function vd(){if(yh)return vh;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 yh=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},vh=e}function yd(){if(bh)return wh;bh=1;var e=vd();return wh=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 wd(){return kh?_h:(kh=1,_h={}.hasOwnProperty)}function bd(){return Sh?Ch:(Sh=1,Ch={})}function _d(){if(Ih)return Th;Ih=1;var e=bd();return Th=new Map([[e,!0]])}function kd(){if(Ph)return Eh;Ph=1;var e=vd(),t=yd(),n=wd(),i=bd(),r=_d(),s=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,o=Object.create(null);function a(e){for(var t,a,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,("value"===(a=t[4])||"checked"===a||"selectedIndex"===a||"selected"===a)&&(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,o[e]={tag:l,attrs:u,is:u.is}}return Eh=function(r,s,...l){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,l);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}(o[r]||a(r),c):(null==c.attrs&&(c.attrs={}),c.tag=r,c)},Eh}function Cd(){if(Ah)return Dh;Ah=1;var e=kd();return e.trust=function(){if(Rh)return xh;Rh=1;var e=vd();return xh=function(t){return null==t&&(t=""),e("<",void 0,void 0,t,void 0,void 0)}}(),e.fragment=function(){if(Nh)return Lh;Nh=1;var e=vd(),t=yd();return Lh=function(n,...i){var r=t(n,i);return null==r.attrs&&(r.attrs={}),r.tag="[",r.children=e.normalizeChildren(r.children),r},Lh}(),Dh=e}function Sd(){return Oh?Mh:(Oh=1,Mh=new WeakMap)}function Td(){if(Fh)return jh;Fh=1;var e=Sd();return jh=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)},jh}function Id(){if(zh)return Uh;zh=1;var e=vd(),t=Sd(),n=Td(),i=_d();return Uh=function(){var r,s,o={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"};function a(e){return e.ownerDocument}function l(e){return e.attrs&&e.attrs.xmlns||o[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 a(e).activeElement}catch(e){return null}}function d(e,t,n,i,r,s,o){for(var a=n;a<i;a++){var l=t[a];null!=l&&p(e,l,r,o,s)}}function p(t,n,i,r,s){var o=n.tag;if("string"==typeof o)switch(n.state={},null!=n.attrs&&F(n.attrs,n,i),o){case"#":!function(e,t,n){t.dom=a(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=a(e).createDocumentFragment();if(null!=t.children){var o=t.children;d(s,o,0,o.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,o=t.attrs,c=t.is;i=l(t)||i;var u=i?c?a(e).createElementNS(i,s,{is:c}):a(e).createElementNS(i,s):c?a(e).createElement(s,{is:c}):a(e).createElement(s);t.dom=u,null!=o&&function(e,t,n){for(var i in t)L(e,i,null,t[i],n)}(t,o,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!=o&&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,o)}}(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=a(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 o,l=a(e).createDocumentFragment();o=s.firstChild;)l.appendChild(o);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 o=null!=t[0]&&null!=t[0].key,a=null!=n[0]&&null!=n[0].key,l=0,c=0;if(!o)for(;c<t.length&&null==t[c];)c++;if(!a)for(;l<n.length&&null==n[l];)l++;if(o!==a)T(e,t,c,t.length),d(e,n,l,n.length,i,r,s);else if(a){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 o=t[t.length-1];if(e[o]<e[r])b[r]=o,t.push(r);else{for(n=0,i=t.length-1;n<i;){var a=(n>>>1)+(i>>>1)+(n&i&1);e[t[a]]<e[r]?n=a+1:i=a}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,o,a){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&&U(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,a,o);break;case"[":!function(e,t,n,i,r,s){m(e,t.children,n.children,i,r,s);var o=0,a=n.children;if(n.dom=null,null!=a)for(var l=0;l<a.length;l++){var c=a[l];null!=c&&null!=c.dom&&(null==n.dom&&(n.dom=c.dom),o+=c.domSize||1)}n.domSize=o}(t,n,r,s,o,a);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 o 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[o])||null!=n&&null!=n[o]||N(e,o,s,r);if(null!=n)for(var o in n)L(e,o,t&&t[o],n[o],r)}(t,e.attrs,t.attrs,r);S(t)||m(s,e.children,t.children,n,null,r)}(n,r,s,a)}else!function(t,n,i,r,s,o){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");U(i.state,i,r),null!=i.attrs&&U(i.attrs,i,r);null!=i.instance?(null==n.instance?p(t,i.instance,r,o,s):v(t,n.instance,i.instance,r,s,o),i.dom=i.instance.dom,i.domSize=i.instance.domSize):(null!=n.instance&&P(t,n.instance),i.domSize=0)}(t,n,r,s,o,a)}else P(t,n),p(t,r,s,a,o)}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=a(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,o){var a=i.state,l=u.call(r.onbeforeremove,i);if(null!=l){var h=s;for(var d of n(i))t.set(d,h);o.v++,Promise.resolve(l).finally((function(){c(i,a),E(e,i,o)}))}}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 U(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 o=r,a=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=o,w=a}}},Uh}function Ed(){return qh?$h:(qh=1,$h=Id()())}function Pd(){if(Wh)return Hh;Wh=1;var e=Ed();return Hh=function(){if(Bh)return Vh;Bh=1;var e=vd();return Vh=function(t,n,i){var r=[],s=!1,o=-1;function a(){for(o=0;o<r.length;o+=2)try{t(r[o],e(r[o+1]),l)}catch(e){i.error(e)}o=-1}function l(){s||(s=!0,n((function(){s=!1,a()})))}return l.sync=a,{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<=o&&(o-=2),t(n,[])),null!=i&&(r.push(n,i),t(n,e(i),l))},redraw:l}},Vh}()(e,"undefined"!=typeof requestAnimationFrame?requestAnimationFrame:null,"undefined"!=typeof console?console:null),Hh}function xd(){return Kh?Gh:(Kh=1,Gh=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 Rd(){if(Jh)return Yh;Jh=1;var e=xd();return Yh=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,o=i<0?s:i,a=t.slice(0,o),l={};Object.assign(l,n);var c=a.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},Yh}function Ld(){if(Zh)return Xh;Zh=1;var e=Rd(),t=wd();return Xh=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(o,a){"string"!=typeof o?(a=o,o=o.url):null==a&&(a={});var l=function(i,r){return new Promise((function(o,a){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);o(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,a(n)};0===p.status?setTimeout((function(){f||c()})):c()}}catch(e){a(e)}},p.ontimeout=function(e){f=!0;var t=new Error("Request timed out");t.code=e.target.status,a(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))}))}(o,a);if(!0===a.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)}}},Xh}function Nd(){if(nd)return td;nd=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 td=function(t){return String(t).replace(e,decodeURIComponent)}}function Dd(){if(rd)return id;rd=1;var e=Nd();return id=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 o=n[s].split("="),a=e(o[0]),l=2===o.length?e(o[1]):"";"true"===l?l=!0:"false"===l&&(l=!1);var c=a.split(/\]\[?|\[/),u=r;a.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[a=c.slice(0,h).join()]&&(i[a]=Array.isArray(u)?u.length:0),d=i[a]++;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 Ad(){if(od)return sd;od=1;var e=Dd();return sd=function(t){var n=t.indexOf("?"),i=t.indexOf("#"),r=i<0?t.length:i,s=n<0?r:n,o=t.slice(0,s).replace(/\/{2,}/g,"/");return o?"/"!==o[0]&&(o="/"+o):o="/",{path:o,params:n<0?{}:e(t.slice(n+1,r))}}}function Md(){if(ld)return ad;ld=1;var e=Ad();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 o=s.exec(e.path);if(null==o)return!1;for(t=0;t<r.length;t++)e.params[r[t].k]=r[t].r?o[t+1]:decodeURIComponent(o[t+1]);return!0}},ad}function Od(){if(ud)return cd;ud=1;var e=wd(),t=/^(?:key|oninit|oncreate|onbeforeupdate|onupdate|onbeforeremove|onremove)$/;return cd=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 jd(){if(gd)return pd;gd=1;var e=Pd();return pd=function(){if(dd)return hd;dd=1;var e=vd(),t=kd(),n=Nd(),i=Rd(),r=Ad(),s=Md(),o=Od();return hd=function(a,l){var c,u,h,d,p,g,f,m,v=Promise.resolve(),y=!1,w=!1,b=!1,_={onremove:function(){w=b=!1,a.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=a.location.hash;"#"!==T.prefix[0]&&(e=a.location.search+e,"?"!==T.prefix[0]&&"/"!==(e=a.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,a.history.state),function e(n){for(;n<u.length;n++)if(u[n].check(i)){var r=u[n].component,o=u[n].route,a=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(a)):r.onmatch?v.then((function(){return r.onmatch(i.params,t,o)})).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,a.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?a.history.replaceState(r,s,T.prefix+e):a.history.pushState(r,s,T.prefix+e)}else a.location.href=T.prefix+e},T.get=function(){return f},T.prefix="#!",T.Link={view:function(e){var n,r,s,a=t(e.attrs.selector||"a",o(e.attrs,["options","params","selector","onclick"]),e.children);return(a.attrs.disabled=Boolean(a.attrs.disabled))?(a.attrs.href=null,a.attrs["aria-disabled"]="true"):(n=e.attrs.options,r=e.attrs.onclick,s=i(a.attrs.href,e.attrs.params),a.attrs.href=T.prefix+s,a.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))}),a}},T.param=function(e){return g&&null!=e?g[e]:g},T},hd}()("undefined"!=typeof window?window:null,e),pd}var Fd=function(){if(md)return fd;md=1;var e=Cd(),t=Pd(),n=function(){if(ed)return Qh;ed=1;var e=Pd();return Qh=Ld()("undefined"!=typeof window?window:null,e.redraw)}(),i=jd(),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=Ed(),r.redraw=t.redraw,r.request=n.request,r.parseQueryString=Dd(),r.buildQueryString=xd(),r.parsePathname=Ad(),r.buildPathname=Rd(),r.vnode=vd(),r.censor=Od(),r.domFor=Td(),fd=r}(),Ud=mh(Fd);const zd=(e,t)=>`${e.serverUrl}${t}`,$d=async e=>{const{userEmail:t,userNick:n,userFullname:i,token:r}=e;return((e,t)=>Ud.request({withCredentials:!0,...t,url:zd(e,t.url)}))(e,{method:"POST",url:"/login_malstadur",body:{email:t,nickname:n,fullname:i,token:r}})},qd=12e4;let Vd=null,Bd=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))),Xd=e=>{const t=500*2**(e-1);return Math.min(t,5e3)},Zd=()=>{Bd=0,Wd=!1,Gd=0},Qd=()=>{Wd=!0,Gd=Date.now()+qd,Bd=0,console.error(`Circuit breaker opened. Login attempts blocked until ${new Date(Gd).toLocaleTimeString()}`)},ep=async e=>{if(Wd&&Date.now()>=Gd&&Zd(),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(Vd)return void await Vd;const t=Date.now()-Hd;if(t<500&&Bd>0)throw console.warn(`Login attempt too soon (${t}ms since last attempt)`),new Yd("Please wait a moment before trying again.");let n=!0;for(;n&&Bd<3;){if(n=!1,Bd++,Hd=Date.now(),Bd>=2){const e=Xd(Bd-1);console.warn(`Login retry ${Bd}/3, waiting ${e}ms...`),await Jd(e)}Vd=$d(e);try{const t=await Vd;if("expired"===t.status){if(e.tokenExpired)try{e.tokenExpired(),n=!0,l();continue}catch(e){throw console.error("Token refresh failed:",e),l(),new Error(`Failed to refresh authentication token: ${e instanceof Error?e.message:String(e)}`)}throw l(),new Error("Authentication token has expired. Please log in again.")}if("success"!==t.status)throw l(),new Error(`Authentication failed: ${t.message||t.status}`);e.netskraflUserId=t.user_id||e.netskraflUserId,e.account=t.account||e.netskraflUserId,e.userNick=t.nickname||e.userNick,e.firebaseApiKey=t.firebase_api_key||e.firebaseApiKey,e.beginner=t.prefs?.beginner??!0,e.fairPlay=t.prefs?.fairplay??!1,e.ready=t.prefs?.ready??!0,e.readyTimed=t.prefs?.ready_timed??!0,e.audio=t.prefs?.audio??!1,e.fanfare=t.prefs?.fanfare??!1,e.hasPaid=t.prefs?.haspaid??!1,a({userEmail:e.userEmail,netskraflUserId:e.netskraflUserId,userNick:e.userNick,firebaseApiKey:e.firebaseApiKey,beginner:e.beginner,fairPlay:e.fairPlay,ready:e.ready,readyTimed:e.readyTimed,audio:e.audio,fanfare:e.fanfare}),Ud.redraw(),await dh(e,t.firebase_token),Zd()}catch(e){if(Bd>=3)throw Qd(),new Error(`Login failed after 3 attempts. Please wait ${Math.ceil(2)} minutes before trying again.`);if(!n)throw e}finally{Vd=null}}if(Bd>=3)throw Qd(),new Error("Maximum login attempts exceeded. Please try again later.")},tp=async(e,t,n=0)=>{n||function(e){if(nh||(th||hh(e),th&&(nh=Ms(th))),!nh||null===nh.currentUser)return!1;if(!ih&&th){if(ih=lh(th),!ih)return console.error("Failed to initialize Firebase Database"),!1;uh(e),rh||(rh=Wn(th),rh||console.error("Failed to initialize Firebase Analytics"))}return!0}(e)||await ep(e);try{return await Ud.request({withCredentials:!0,...t,url:zd(e,t.url),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),tp(e,t,n+1);throw i}},np=(e,t)=>tp(e,t),ip=(e,t)=>{const n=`${e.movesUrl}${t.url}`,i={"Content-Type":"application/json; charset=UTF-8",Authorization:`Bearer ${e.movesAccessKey}`,...t?.headers};return Ud.request({withCredentials:!1,method:"POST",...t,url:n,headers:i})},rp="ABCDEFGHIJKLMNO",sp=15,op=1.5,ap="2025-11-01",lp={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 cp{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 up=null;function hp(e,t){return up||(up=new cp(e,t)),up}var dp={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:"User identifier:",nb:"Brukeridentifikator:",nn:"Brukaridentifikator:",pl:"Identyfikator użytkownika:",ga:"Aitheantóir Úsáideora:"},"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:"Poengsum",nn:"Poengsum",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:"Identifier",nb:"Identifikator",nn:"Identifikator",pl:"Identyfikator",ga:"Aitheantóir"},"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:"Identifier or name",nb:"Identifikator eller navn",nn:"Identifikator eller namn",pl:"Identyfikator lub nazwa",ga:"Aitheantóir 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:"Rangering",nn:"Rangering",pl:"Ranking",ga:"Rang"},"Röð í gær":{en:"Rank yesterday",nb:"Rangering i går",nn:"Rangering i går",pl:"Ranking wczoraj",ga:"Rang inné"},"Röð fyrir viku":{en:"Rank a week ago",nb:"Rangering for en uke siden",nn:"Rangering for ei veke sidan",pl:"Ranking tydzień temu",ga:"Rang 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"},"[sentinel]":{}};let pp="is_IS",gp="is";const fp=/{\s*(\w+)\s*}/g;let mp={},vp=!1;function yp(e,t){for(const n in e)if(void 0!==e[n][t])return!0;return!1}function wp(e){!function(e,t){pp=e,gp=e.split("_")[0],yp(t,pp)||yp(t,gp)||(pp="en_US",gp="en"),mp={};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===mp[e]&&(mp[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,o=i.indexOf(`</${r.slice(1)}`,s);o<0?t=s:(n.index>0&&e.push(i.slice(t,t+n.index)),e.push(Ud(r.slice(1,-1),i.slice(s,o))),t=o+r.length+1)}t<i.length&&e.push(i.slice(t)),i=e}mp[e][n]=i}vp=!0}(function(){const e=new URLSearchParams(window.location.search).get("lang");return e?e.replace("-","_"):null}()||e,dp)}function bp(e,t={}){const n=mp[e];if(void 0===n)return vp?e:"";const i=n[pp]||n[gp]||e;return Object.keys(t).length?Cp(i,t):i}function _p(e,t={}){const n=mp[e];if(void 0===n)return vp?e:"";const i=n[pp]||n[gp]||e;return"string"!=typeof i?"":Object.keys(t).length?function(e,t){return e.replace(fp,((e,n)=>t[n]||e))}(i,t):i}function kp(e,t){return"string"==typeof t?Ud(e,bp(t)):Array.isArray(t)?Ud(e,t.map((e=>"string"==typeof e?bp(e):e))):Ud(e,t)}function Cp(e,t){return"string"==typeof e?e.replace(fp,((e,n)=>t[n]||e)):Array.isArray(e)?e.map((e=>Cp(e,t))):e}const Sp=new WeakMap;const Tp="/board?game=",Ip=["january","february","march","april","may","june","july","august","september","october","november","december"];function Ep(e){const t=e.currentTarget.classList;void 0===t||t.contains("disabled")||t.add("over"),e.redraw=!1}function Pp(e){const t=e.currentTarget.classList;void 0!==t&&t.remove("over"),e.redraw=!1}function xp(e,t,n){return Ud(`span.glyphicon.glyphicon-${e}${n?".grayed":""}`,t??{})}function Rp(e,t){return Ud(`span.glyphicon.glyphicon-${e}.grayed`,t??{})}function Lp(e){return Ud.trust("&nbsp;")}function Np(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};return String(e).replace(/[&<>"'/]/g,(e=>t[e]??""))}function Dp(e){return document.getElementById(e).value}function Ap(e,t){hp(e).play(t)}function Mp(e){e.slice(0,12)===Tp&&(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 Op(){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 jp(e,t,n=!1){return e<0||e>=sp||t<0||t>=sp?null:n?`${t+1}${rp[e]}`:`${rp[e]}${t+1}`}function Fp(e){var t=0,n=0,i=0,r=rp.indexOf(e[0]);return r>=0?(i=parseInt(e.slice(1),10)-1,t=1):(r=rp.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=_p(Ip[t.getUTCMonth()]);return _p("date_format",{day:n,month:i})}function zp(e=0){const t=()=>{const e=document.querySelector(".netskrafl-container");e?.focus()};e>0?setTimeout(t,e):setTimeout(t)}function $p(e,t=100){setTimeout((()=>{const t=document.querySelector(".netskrafl-container");t&&(t.tabIndex=0,t.addEventListener("keydown",e),t.focus())}),t)}class qp{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(Op),n.isMobile()&&n.setSelectedTab("board"),zp(100)}),e),null!==i.game&&void 0!==i.game&&fh("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(Op),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(),fh("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&&Ap(t,"new-msg")}}onFullScreen(e){const t=this.model.state;t&&!t.uiFullscreen&&(t.uiFullscreen=!0,e&&(e.resetScale(),e.notifyMediaChange()),Ud.redraw())}onMobileScreen(e){const t=this.model.state;t&&!1!==t.uiFullscreen&&(t.uiFullscreen=!1,e&&e.notifyMediaChange(),Ud.redraw())}onLandscapeScreen(e){const t=this.model.state;t&&!t.uiLandscape&&(t.uiLandscape=!0,e&&e.notifyMediaChange(),Ud.redraw())}onPortraitScreen(e){const t=this.model.state;t&&!1!==t.uiLandscape&&(t.uiLandscape=!1,e&&e.notifyMediaChange(),Ud.redraw())}mediaMinWidth667(e,t){e.matches?this.onLandscapeScreen(t):this.onPortraitScreen(t)}mediaMinWidth768(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)");n&&(this.mediaMinWidth667(n,e),t(n,(()=>this.mediaMinWidth667(n,e)))),n=window.matchMedia("(min-width: 768px)"),n&&(this.mediaMinWidth768(n,e),t(n,(()=>this.mediaMinWidth768(n,e))))}attachListenerToUser(){const e=this.model.state;e&&e.netskraflUserId&&(ph(`user/${e.netskraflUserId}/challenge`,((e,t)=>this.onUserChallengeMessage(e,t))),ph(`user/${e.netskraflUserId}/move`,((e,t)=>this.onUserMoveMessage(e,t))))}detachListenerFromUser(){const e=this.model.state;e?.netskraflUserId&&gh(`user/${e.netskraflUserId}`)}attachListenerToGame(e,t){const n=this.model.state;if(!e||!n)return;const i=`game/${e}/${n.netskraflUserId}/`;ph(`${i}move`,((e,t)=>this.onMoveMessage(e,t))),ph(`${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}/`;gh(`${n}move`),gh(`${n}chat`)}async markFavorite(e,t){if(this.model.state)try{await np(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 np(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),fh(`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 np(this.model.state,i);if(r?.ok){const e=this.model.state?.locale||"is_IS";fh("new_game",{uuid:r.uuid,timed:t,locale:e}),Ud.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++,Ud.redraw()}hideSpinner(){this.model.spinners>0&&(this.model.spinners--,Ud.redraw())}async withSpinner(e){this.showSpinner();try{return await e()}finally{this.hideSpinner()}}async setUserPref(e){if(this.model.state)try{await np(this.model.state,{method:"POST",url:"/setuserpref",body:e}),a(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 np(t,{method:"POST",url:"/cancelplan",body:{}});if(n?.ok)return e.friend=!1,t.hasPaid=!1,t.plan="",fh("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}/`;ph(`${i}count`,((e,t)=>this.onSolverCountUpdate(e,t))),ph(`${i}best`,((e,t)=>this.onRiddleGlobalScoreUpdate(e,t))),n?.userGroupId&&ph(`${i}group/${n.userGroupId}/best`,((e,t)=>this.onRiddleGroupScoreUpdate(e,t))),ph(`${i}leaders`,((e,t)=>this.onLeaderboardUpdate(e,t))),n?.netskraflUserId&&(ph(`gatadagsins/users/${t}/${n.netskraflUserId}/stats`,((e,t)=>this.onUserStatsUpdate(e,t))),ph(`${i}achievements/${n.netskraflUserId}`,((e,t)=>this.onPersonalBestScoreUpdate(e,t))))}detachListenerFromRiddle(e,t){const{state:n}=this.model,i=`gatadagsins/${e}/${t}/`;gh(`${i}count`),gh(`${i}best`),n?.userGroupId&&gh(`${i}group/${n.userGroupId}/best`),gh(`${i}leaders`),n?.netskraflUserId&&(gh(`gatadagsins/users/${t}/${n.netskraflUserId}/stats`),gh(`${i}achievements/${n.netskraflUserId}`))}onSolverCountUpdate(e,t){this.model.solverCount=e??0,Ud.redraw()}onRiddleGlobalScoreUpdate(e,t){const{riddle:n}=this.model,{score:i}=e;!n||!i||i<=0||(n.updateGlobalBestScore(e),Ud.redraw())}onRiddleGroupScoreUpdate(e,t){const{riddle:n}=this.model,{score:i}=e;!n||!i||i<=0||(n.updateGroupBestScore(e),Ud.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=[];Ud.redraw()}onUserStatsUpdate(e,t){this.model.userStats=e||null,Ud.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||"",o=e.timestamp||(new Date).toISOString();if(i<=n.personalBestScore||!r||!s)return;n.personalBestScore=i;const a=n.playerMoves.some((e=>e.word===r&&e.coord===s&&e.score===i));a||n.playerMoves.push({word:r,score:i,coord:s,timestamp:o}),Ud.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<ap||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(),Ud.redraw()}finally{this.riddleLoading=!1}}}}const Vp=e=>{const{view:t,showClose:n}=e.attrs,{model:i,actions:r}=t,s=i.state;return{view:()=>Ud(".board-help",{title:_p("Hvernig reitirnir margfalda stigin")},[n?Ud(".board-help-close",{title:_p("Loka þessari hjálp"),onclick:e=>{s&&(s.beginner=!1,r.setUserPref({beginner:!1})),e.preventDefault()}},xp("remove")):null,Ud(".board-colors",[Ud(".board-color[id='triple-word']",["3 x",Ud("br"),bp("orð")]),Ud(".board-color[id='double-word']",["2 x",Ud("br"),bp("orð")]),Ud(".board-color[id='triple-letter']",["3 x",Ud("br"),bp("stafur")]),Ud(".board-color[id='double-letter']",["2 x",Ud("br"),bp("stafur")]),Ud(".board-color[id='single-letter']",["1 x",Ud("br"),bp("stafur")])])])}},Bp=182,Hp=210,Wp=['<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"/>'],Gp=`\n<svg preserveAspectRatio="xMidYMid meet" width="100%" height="100%" viewBox="0 0 182 210" fill="none" xmlns="http://www.w3.org/2000/svg">\n${Wp.join("\n")}\n</svg>`,Kp=Ud.trust(Gp),Yp=Math.max(Bp,Hp)+40,Jp=`\n<svg preserveAspectRatio="xMidYMid meet" width="100%" height="100%" viewBox="0 0 ${Yp} ${Yp}" fill="none" xmlns="http://www.w3.org/2000/svg">\n ${`<circle cx="${Yp/2}" cy="${Yp/2}" r="${Yp/2-5}" fill="#ffffff"/>`}\n <svg x="${(Yp-Bp)/2}" y="${(Yp-Hp)/2}" width="182" height="210" viewBox="0 0 182 210">\n ${Wp.join("\n")}\n </svg>\n</svg>`,Xp=Ud.trust(Jp),Zp=e=>{const{attrs:t}=e,{width:n,withCircle:i}=t;return{view:()=>{const e={};return void 0!==n&&(e.width=`${n}px`),Ud(".animated-netskrafl-logo",{style:e},i?Xp:Kp)}}},Qp={oninit:e=>{e.state.show=!1,e.state.ival=setTimeout((()=>{e.state.show=!0,e.state.ival=0,Ud.redraw()}),800)},onremove:e=>{e.state.ival&&clearTimeout(e.state.ival),e.state.ival=0},view:e=>{if(e.state.show)return Ud(".modal-dialog",{id:"spinner-dialog",style:{visibility:"visible"}},Ud(".animated-spinner",Ud(Zp,{withCircle:!0})))}},eg=()=>{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:o}=n.attrs;return Ud(`input.text${t}`,{id:i,name:i,maxlength:r,tabindex:s,autocomplete:o,value:e,oninput:t=>{e=`${t.target.value}`}})}}},tg={view:e=>{const t={onmouseout:Pp,onmouseover:Ep};return Object.assign(t,e.attrs),Ud(".modal-close",t,e.children)}},ng={view:e=>{const t=e.attrs.item,n=e.attrs.view,i=n.actions,r=0===t.userid.indexOf("robot-");return Ud("span.list-ch",{title:_p("Skora á"),onclick:e=>{t.chall?(t.chall=!1,i.retractChallenge(t.userid,"")):r?i.startRobotGame(t.userid):n.pushDialog("challenge",t),e.preventDefault()}},xp("hand-right",void 0,!t.chall))}},ig={view:e=>{const t=e.attrs.item,n=e.attrs.view,i=!t.userid||0===t.userid.indexOf("robot-");return Ud("span.list-info",{title:_p("Skoða feril"),onclick:e=>{i||n.showUserInfo(t.userid,t.nick,t.fullname),e.preventDefault()}},i?"":Ud("span.usr-info"))}},rg={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 np(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 Ud("span",{id:t.id,title:_p(i?"Er álínis":"Álínis?"),class:i?"online":""})}},sg={view:e=>{const t=e.attrs.view,n=t.model;return n.state?.netskraflUserId?Ud(".userid",{title:_p("player_info"),onclick:e=>{t.pushDialog("userprefs",{}),e.preventDefault()}},[xp("address-book"),Lp(),n.state.userNick]):""}},og={view:e=>{const{manual:t,header:n}=e.attrs,i=_p("Keppnishamur"),r=!0===t&&!n;return Ud("span.list-manual",r||n?{title:i}:{},xp("lightbulb",void 0,!r))}},ag=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 Ud("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})))}}},lg={view:()=>Ud(".info",{title:_p("Upplýsingar og hjálp")},Ud(Ud.route.Link,{href:"/help",class:"iconlink"},xp("info-sign")))},cg={view:e=>Ud(".logo"+(e.attrs.hidden?".hidden":""),Ud(Ud.route.Link,{href:"/main",class:"nodecorate"},xp("home")))},ug={view:e=>Ud(".header-logo"+(e.attrs.hidden?".hidden":""),Ud(Ud.route.Link,{href:"/main",class:"backlink"},xp("home")))},hg=()=>{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:o,opt1:a,opt2:l}})=>{const c=`${t}-toggler`,u=".option"+(n?".small":"");return Ud.fragment({},[Ud(`input.checkbox.${t}`,{type:"checkbox",id:t,name:t,checked:r,value:"True"}),Ud(".toggler",{id:c,tabindex:s,title:o,onclick:t=>{e(c,i),t.preventDefault()},onkeypress:t=>{" "===t.key&&(e(c,i),t.preventDefault())}},[Ud(u+(r?"":".selected"),{id:"opt1"},a),Ud(u+(r?".selected":""),{id:"opt2"},l)])])}}},dg=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:()=>Ud(hg,{id:"ready",state:n.state?.ready??!1,tabindex:2,opt1:Lp(),opt2:xp("thumbs-up"),funcToggle:i,small:!0,title:_p("Tek við áskorunum!")})}},pg=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:()=>Ud(hg,{id:"timed",state:n.state?.readyTimed??!1,tabindex:3,opt1:Lp(),opt2:xp("time"),funcToggle:i,small:!0,title:_p("Til í viðureign með klukku!")})}},gg=e=>{const{model:t}=e.attrs.view;function n(e){e&&null!==t.state&&Ap(t.state,"your-turn")}return{view:({attrs:{state:e,tabindex:t}})=>Ud(hg,{id:"audio",state:e,tabindex:t,opt1:xp("volume-off"),opt2:xp("volume-up"),funcToggle:n,small:!0,title:_p("Hljóð á/af")})}},fg=e=>{const{model:t}=e.attrs.view;function n(e){e&&null!==t.state&&Ap(t.state,"you-win")}return{view:({attrs:{state:e,tabindex:t}})=>Ud(hg,{id:"fanfare",state:e,tabindex:t,opt1:xp("volume-off"),opt2:xp("volume-up"),funcToggle:n,small:!0,title:_p("Lúðraþytur á/af")})}},mg=()=>({view:({attrs:{state:e,tabindex:t}})=>Ud(hg,{id:"beginner",state:e,tabindex:t,opt1:Lp(),opt2:xp("ok"),small:!0})}),vg=()=>({view:({attrs:{state:e,tabindex:t}})=>Ud(hg,{id:"fairplay",state:e,tabindex:t,opt1:Lp(),opt2:xp("edit"),small:!0})}),yg=()=>{function e(e){e.cancelBlankDialog(),zp()}function t(e,t){e.placeBlank(t),zp()}function n(e){const n=e.alphabet;let i=n.length,r=0;const s=[];for(;i>0;){const o=[];for(let s=0;s<6&&i>0;s++){const s=n[r++];o.push(Ud("td",{onclick:n=>{n.preventDefault(),t(e,s)},onmouseover:Ep,onmouseout:Pp},Ud(".blank-choice.netskrafl-tile.netskrafl-racktile",s))),i--}s.push(Ud("tr",o))}return s}return{view:i=>{const{game:r}=i.attrs;if(r)return Ud(".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(),void e(n);const s=r.normalize("NFC");if(1===s.length){const e=s.toLowerCase();n.alphabet.includes(e)&&(i.preventDefault(),t(n,e))}}(r,n),oncreate:e=>e.dom.focus()},Ud(".ui-widget.ui-widget-content.ui-corner-all",{id:"blank-form"},[kp("p","Hvaða staf táknar auða flísin?"),Ud(".rack.blank-rack",Ud("table.board",{id:"blank-meaning"},n(r))),Ud(tg,{id:"blank-close",title:_p("Hætta við"),onclick:t=>{t.preventDefault(),e(r)}},xp("remove"))]))}}};function wg(e,t,n,i,r,s,o){const a={onmouseout:Pp,onmouseover:Ep,style:{visibility:!1===s?"hidden":"visible"}};return i&&(a.title=i),o&&(a.id=o),a.onclick=t?e=>e.preventDefault():e=>{n?.(),e.preventDefault()},Ud(`.${e}${t?".disabled":""}`,a,r)}const bg={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 Ud(n.join("."),{title:i},i)}},_g={view:e=>{const{view:t,game:n,disabled:i,visible:r=!0}=e.attrs;if(n)return wg("recallbtn",!!i,(()=>{n.resetRack(),t.updateScale()}),_p("Færa stafi aftur í rekka"),xp("down-arrow"),r)}},kg={view:e=>{const{game:t,disabled:n,visible:i=!0}=e.attrs;if(t)return wg("scramblebtn",!!n,(()=>t.rescrambleRack()),_p("Stokka upp rekka"),xp("random"),i)}},Cg={view:e=>{const{view:t,game:n}=e.attrs;if(!n)return;const i=n.buttonState();if(i.showRecall&&!i.showingDialog)return Ud(_g,{view:t,game:n});const r=i.showScramble&&!i.tilesPlaced,s=i.showingDialog;return Ud(kg,{view:t,game:n,visible:r,disabled:s})}},Sg={view:e=>{const{view:t}=e.attrs,{game:n}=t.model,i=[];if(!n)return i;const r=n.buttonState();if(i.push(Ud(".word-check"+(r.wordGood?".word-good":"")+(r.wordBad?".word-bad":""))),r.showChallenge){const e=(r.tilesPlaced||r.showingDialog)&&!r.lastChallenge;i.push(wg("challenge",e,(()=>n.submitChallenge()),"Véfenging (röng kostar 10 stig)",xp("ban-circle")))}if(r.showRecall&&i.push(Ud(_g,{view:t,game:n,disabled:r.showingDialog})),r.showScramble&&i.push(Ud(kg,{view:t,game:n,disabled:r.showingDialog})),r.showMove){const e=_p("submit_move"),s=!r.tilesPlaced||r.showingDialog;i.push(wg("submitmove",s,(()=>{n.submitMove(),t.updateScale()}),e,[e,xp("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 o=void 0===n.currentScore?"?":n.currentScore.toString(),a=[Ud("span.score-mobile",o)];let l;r.canPlay&&s?a.push(xp("play")):a.push(xp("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(wg(e.join("."),r.showingDialog,l,o,a,!0,"move-mobile"))}if(r.showForceResignMobile){const e=_p("Þvinga til uppgjafar");i.push(wg("force-resign",r.showingDialog,(()=>n.forceResign()),e,e))}if(r.showPass){const e=(r.tilesPlaced||r.showingDialog)&&!r.lastChallenge;i.push(wg("submitpass",e,(()=>n.submitPass()),_p("Pass"),xp("forward")))}if(r.showExchange){const e=!r.exchangeAllowed||r.tilesPlaced||r.showingDialog;i.push(wg("submitexchange",e,(()=>n.submitExchange()),_p("Skipta stöfum"),xp("refresh")))}if(r.showResign&&i.push(wg("submitresign",r.showingDialog,(()=>n.submitResign()),_p("Gefa viðureign"),xp("fire"))),!r.gameOver&&!r.localTurn&&!n.moveInProgress&&null!==n.player){const e=n.nickname[1-n.player];i.push(Ud(".opp-turn",{style:{visibility:"visible"}},[Ud("span.move-indicator"),Lp(),Ud("strong",_p("opp_move",{opponent:e})),Lp(),r.tardyOpponent?Ud("span.yesnobutton",{id:"force-resign",onclick:e=>{e.preventDefault(),n.forceResign()},onmouseout:Pp,onmouseover:Ep,title:_p("14 dagar liðnir án leiks")},_p("Þvinga til uppgjafar")):""]))}if(r.tilesPlaced){const e=Ud(bg,{game:n});e&&i.push(e)}return n?.moveInProgress&&i.push(Ud(".waitmove",Ud(".animated-waitmove",Ud(Zp,{withCircle:!1})))),Ud(".buttons",i)}};class Tg{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:o,cancelDrag:a}=this.boundEventHandlers;e instanceof MouseEvent?(document.addEventListener("mousemove",s),document.addEventListener("mouseup",o),document.addEventListener("mouseleave",a)):e instanceof TouchEvent&&(document.addEventListener("touchmove",s,{passive:!1}),document.addEventListener("touchend",o),document.addEventListener("touchcancel",o)),document.addEventListener("visibilitychange",a),window.addEventListener("blur",a)}initiateDrag(e){e.preventDefault(),this.dragStarted=!0;const t=this.draggedElement,n=t.getBoundingClientRect(),{offsetWidth:i,offsetHeight:r}=t;t.classList.add("dragging"),document.body.appendChild(t);const{offsetWidth:s,offsetHeight:o}=t;this.offsetX=this.startX-n.left+(s-i)/2,this.offsetY=this.startY-n.top+(o-r)/2,this.centerX=s/2,this.centerY=o/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&&Tg.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"),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 Ig=(e,t,n)=>i=>{var r,s,o;return s=(i,r)=>{if(!t)return;const s=r.id;if(!s)return;let o="";if("board-background"===s?o="R1":s.startsWith("sq_")&&(o=s.slice(3)),o)try{t.attemptMove(n,o),e.updateScale(),Ud.redraw()}catch(e){console.error(e)}},o=()=>{t&&(n===t.selectedSq?t.selectedSq=null:t.selectedSq=n,Ud.redraw())},(r=i).stopPropagation(),new Tg(r,s,o),i.redraw=!1,!1},Eg=()=>({view:e=>{const{view:t,game:n,coord:i,opponent:r}=e.attrs;if(!n)return;const s="R"===i[0],o=n.tiles[i],a=[".netskrafl-tile"],l={};if("?"===o.tile&&a.push("netskrafl-blanktile"),"q".includes(o.letter)?a.push("netskrafl-extra-wide"):"zxmæ".includes(o.letter)&&a.push("netskrafl-wide"),s||o.draggable?(a.push(r?"netskrafl-freshtile":"netskrafl-racktile"),s&&"exchange"===n.showingDialog&&(o.xchg&&a.push("netskrafl-xchgsel"),l.onclick=e=>{o.xchg=!o.xchg,e.preventDefault()})):o.freshtile&&a.push("netskrafl-freshtile"),o.index){const e=150,t=`${(o.index*e).toString()}ms`;l.style=`animation-delay: ${t}`}if(i===n.selectedSq&&a.push("sel"),void 0!==o.highlight&&a.push(`highlight${o.highlight}`),o.draggable&&n.allowDragDrop()){const e=Ig(t,n,i);l.onmousedown=e,l.ontouchstart=e}return Ud(a.join("."),l,[" "===o.letter?Lp():o.letter,Ud(".letterscore",o.score)])}}),Pg={view:e=>{const{view:t,game:n,coord:i}=e.attrs;if(n)return Ud("td.not-target",{id:`sq_${i}`,class:n.squareClass(i)},Ud(Eg,{view:t,game:n,coord:i,opponent:!1}))}},xg={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",Ud(`td${i}`,{id:`sq_${n}`},e.children)}},Rg={view:e=>{const{view:t,game:n,coord:i,isKeyboardTarget:r,keyboardDirection:s}=e.attrs;if(!n)return;let o=n.squareClass(i)||"";return o&&(o=`.${o}`),null!==n.askingForBlank&&n.askingForBlank.to===i&&(o+=".blinking"),i===n.startSquare&&n.localturn&&(o+=".center"),r&&(o+=".keyboard-target","V"===s&&(o+=".vertical")),Ud(`td.drop-target${o}`,{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)}},Lg={view:e=>{const{view:t,game:n,review:i}=e.attrs;if(!n)return;const{model:r}=t,s=[],o=r.reviewMove??0,a=i&&0===o,l=i&&o>0&&o%2===n.player;for(let e=1;e<=7;e++){const r=`R${e}`;!a&&n&&r in n.tiles?i?s.push(Ud(xg,{key:r,view:t,game:n,coord:r,opponent:l},Ud(Eg,{view:t,game:n,coord:r,opponent:l}))):s.push(Ud(Rg,{key:r,view:t,game:n,coord:r},Ud(Eg,{view:t,game:n,coord:r,opponent:!1}))):i?s.push(Ud(xg,{key:r,view:t,game:n,coord:r,opponent:!1})):s.push(Ud(Rg,{key:r,view:t,game:n,coord:r}))}return Ud("table.board",Ud("tbody",Ud("tr",s)))}},Ng={view:e=>{const{view:t,game:n,review:i}=e.attrs;return Ud(".rack-row",[Ud(".rack-left",Ud(Cg,{view:t,game:n})),Ud(".rack",Ud(Lg,{view:t,game:n,review:i}))])}},Dg={view:e=>{const{game:t}=e.attrs;return t.congratulate?Ud("div",{id:"congrats"},[xp("bookmark")," ",kp("strong","Til hamingju með sigurinn!")]):t.over?Ud("div",{id:"gameover"},[xp("info-sign")," ",kp("strong","Viðureigninni er lokið")]):void 0}},Ag={view:e=>{const{game:t}=e.attrs,n=t.currentError||"";if(n&&n in lp){const e=t.currentMessage||"",i=_p(lp[n]),r=i.indexOf("{word}");let s;return s=r>=0?[i.slice(0,r),Ud("span.errword",e),i.slice(r+6)]:[i],Ud(".error",{style:{visibility:"visible"},onclick:e=>{t.resetError(),e.preventDefault()}},[xp("exclamation-sign"),...s])}}},Mg={view:e=>{const{view:t,game:n}=e.attrs;let i=[];return n&&(i=[Ud(Og,{view:t,game:n,review:!1}),Ud(Ng,{view:t,game:n,review:!1}),Ud(Sg,{view:t}),Ud(Ag,{game:n}),Ud(Dg,{game:n})],i=i.concat(t.vwDialogs())),Ud(".board-area",i)}};const Og={oninit:e=>{e.state.columnIdentifiers=function(){const e=[];e.push(Ud("td"));for(let t=1;t<=15;t++)e.push(Ud("td",t.toString()));return Ud("tr.colid",e)}()},view:e=>{const{view:t,game:n,review:i}=e.attrs,r=t.isMobile(),s=i||r?null:n.getNextKeyboardSquare();function o(e){const r=[];r.push(Ud("td.rowid",{key:`R${e}`},e));for(let o=1;o<=15;o++){const a=e+o.toString();n&&a in n.tiles?r.push(Ud(Pg,{view:t,game:n,key:a,coord:a,opponent:!1})):i?r.push(Ud(xg,{view:t,game:n,key:a,coord:a,opponent:!1})):r.push(Ud(Rg,{view:t,game:n,key:a,coord:a,isKeyboardTarget:a===s,keyboardDirection:n?.getEffectiveKeyboardDirection()}))}return Ud("tr",r)}const a=Ud("tbody",function(){const t=[];t.push(e.state.columnIdentifiers);for(const e of"ABCDEFGHIJKLMNO")t.push(o(e));return t}()),l=Ud("table.board",{},a);return Ud(".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=Sp.get(t)||0;return Sp.set(t,n),n-i<300}(e)&&(e.stopPropagation(),t.zoomOut())}},l)}},jg={view:e=>{const{riddle:t,mode:n="desktop"}=e.attrs;if(!t)return Ud("div");const i=t.currentScore,r=void 0!==i,s=["mobile"===n?".mobile-score":".gata-dagsins-score"];let o="0";t.tilesPlaced().length>0?r?t.wordGood?(o=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"),o=i.toString()):(s.push(".illegal"),o="?"):(s.push(".disabled"),o="0");const a="mobile"===n?".mobile-score-legend":".gata-dagsins-legend";return Ud(`div${s.join("")}`,Ud(`span${a}`,o))}},Fg={view:e=>{const{view:t}=e.attrs,{riddle:n}=t.model;if(!n)return Ud(".gatadagsins-board-rack-wrapper","");const i=n.wordGood&&(n.currentScore||0)>=n.bestPossibleScore;return Ud(".gatadagsins-board-rack-wrapper",[Ud(".gatadagsins-board-area"+(i?".celebrate":""),[n?Ud(Og,{view:t,game:n,review:!1}):""]),Ud(".gatadagsins-rack-area",[Ud(".rack-left",Ud(Cg,{view:t,game:n})),Ud(".rack",Ud(Lg,{view:t,game:n,review:!1})),Ud(jg,{riddle:n})])])}},Ug={view:e=>{const t=e.attrs.onClose;return[Ud(".modal-backdrop-netskrafl",{onclick:e=>{e.preventDefault()},onwheel:e=>{e.preventDefault(),e.stopPropagation()},ontouchmove:e=>{e.preventDefault(),e.stopPropagation()}}),Ud(".modal-dialog.gatadagsins-help",Ud(".modal-content",[Ud("button.close",{onclick:t,"aria-label":"Loka"},xp("remove")),Ud(".modal-header",Ud("h2","Um Gátu dagsins")),Ud(".modal-body",[Ud("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."),Ud("h3","Hvernig á að spila"),Ud("ul",[Ud("li","Þú færð borð með allmörgum stöfum sem þegar hafa verið lagðir."),Ud("li","Neðst á skjánum eru stafaflísar sem þú getur notað til að mynda orð."),Ud("li","Dragðu flísar á borðið til að mynda orð, annaðhvort lárétt eða lóðrétt."),Ud("li","Orðin verða að tengjast við stafi sem fyrir eru á borðinu."),Ud("li","Þú sérð jafnóðum hvort lögnin á borðinu er gild og hversu mörg stig hún gefur."),Ud("li","Þú getur prófað eins mörg orð og þú vilt - besta skorið þitt er vistað.")]),Ud("h3","Stigagjöf"),Ud("p","Þú færð stig fyrir hvern staf í orðinu, auk bónusstiga fyrir lengri orð:"),Ud("ul",[Ud("li","Hver stafur gefur 1-10 stig eftir gildi hans"),Ud("li","Orð sem nota allar 7 stafaflísarnar gefa 50 stiga bónus"),Ud("li",["Sumir reitir á borðinu ",Ud("span.help-bonus-square.double-letter"),"tvöfalda eða ",Ud("span.help-bonus-square.triple-letter"),"þrefalda stafgildið"]),Ud("li",["Sumir reitir ",Ud("span.help-bonus-square.double-word"),"tvöfalda eða ",Ud("span.help-bonus-square.triple-word"),"þrefalda heildarorðgildið"])]),Ud("h3","Hitamælir"),Ud("p","Hitamælirinn hægra megin við borðið (sést ekki á farsímum) sýnir:"),Ud("ul",[Ud("li",Ud("strong","Besta mögulega lögn:")," Hæstu stig sem hægt er að ná á þessu borði."),Ud("li",Ud("strong","Besta skor dagsins:")," Hæstu stig sem einhver leikmaður hefur náð í dag."),Ud("li",Ud("strong","Þín bestu orð:")," Orðin sem þú hefur lagt og stigin fyrir þau."),Ud("li","Þú getur smellt á orð á hitamælinum til að fá þá lögn aftur á borðið.")]),Ud("h3","Ábendingar"),Ud("ul",[Ud("li","Reyndu að nota dýra stafi (eins og X, Ý, Þ) á tvöföldunar- eða þreföldunarreitum."),Ud("li","Lengri orð gefa mun fleiri stig vegna bónussins."),Ud("li","Þú getur dregið allar flísar til baka með bláa endurkalls-hnappnum."),Ud("li","Ný gáta birtist á hverjum nýjum degi - klukkan 00:00!")]),Ud("h3","Um leikinn"),Ud("p",["Gáta dagsins er systkini ",Ud("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."])]),Ud(".modal-footer",Ud("button.btn.btn-primary",{onclick:t},"Loka"))]))]}},zg={view:e=>{const{view:t}=e.attrs,{model:n}=t.actions,{solverCount:i}=n;return i<=0?null:Ud(".solver-count-pill",{title:_p("Leikmenn sem hafa leyst gátuna")},i)}},$g={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]},o=(new Date).toISOString().split("T")[0],a=s(n,-1),l=s(n,1),c=r.isRiddleLoading,u=!c&&a>=ap,h=!c&&l<=o,d=e=>{const t=new URL(window.location.href);e===o?t.searchParams.delete("date"):t.searchParams.set("date",e),window.history.pushState({},"",t.toString()),r.loadRiddle(e,i)},p=(e,t)=>{if(e)return e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),t())}},g=_p("Fyrri dagur"),f=_p("Næsti dagur"),m=n>="2025-12-05";return Ud(".date-navigator",[Ud(".nav-arrow.prev"+(u?"":".disabled"),{role:"button",tabindex:u?0:-1,"aria-disabled":!u,"aria-label":g,onclick:u?()=>d(a):void 0,onkeydown:p(u,(()=>d(a))),title:u?g:""},xp("chevron-left")),Ud(".nav-date",Up(n)),m?Ud(zg,{view:t}):null,Ud(".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:""},xp("chevron-right"))])}},qg={view:e=>{const{animate:t=!1,size:n=80}=e.attrs,i=n/2,r=n/3;return Ud("div.sun-corona"+(t?".rotating":""),[Ud.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 `)])}},Vg=()=>{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:o}=n.model;if(!o)return null;const{bestPossibleScore:a,globalBestScore:l,personalBestScore:c}=o,u=i&&""!==i.word,h=(new Date).toISOString().split("T")[0],d=o.date<h,p=d?o.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=_p("Tölfræði og stigatafla");return Ud(".mobile-status-container",[Ud(".mobile-status-item.left",Ud(jg,{riddle:o,mode:"mobile"})),Ud(".mobile-status-card",{role:"button",tabindex:0,"aria-label":y,onclick:s,onkeydown:e(s),title:y},[Ud(".mobile-status-card-item.player-best",[Ud(".mobile-status-label",_p("Þín besta")),Ud(".mobile-status-score",c.toString())]),Ud(".mobile-status-card-item.leader"+(f?".is-player":""),[Ud(".mobile-status-label",_p(f?"Þú leiðir!":"Best til þessa")),Ud(".mobile-status-score",g.toString())]),Ud(".mobile-status-card-icon",xp("chevron-down"))]),Ud(".mobile-status-item.right.best-possible"+(u?".celebrate":""),{role:m?"button":void 0,tabindex:m?0:void 0,"aria-label":m?_p("Sýna besta leik"):void 0,onclick:v,onkeydown:m?e(v):void 0},[Ud(".mobile-best-score-wrapper",[u?Ud(qg,{animate:!0,size:100}):null,Ud(".mobile-status-score",a.toString())])])])}}};const Bg={view:e=>{const{leaderboard:t,currentUserId:n,loading:i=!1}=e.attrs;return i?Ud(".leaderboard-view.loading",Ud(".loading-message",_p("Hleð stigatöflu..."))):t&&0!==t.length?Ud(".leaderboard-view",[Ud(".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 Ud(".leaderboard-entry"+(r?".current-user":""),{key:e.userId},[Ud(".entry-rank",[s?Ud("span.medal",s):Ud("span.rank-number",i.toString())]),Ud(".entry-name",r?[Ud("span.entry-star",xp("star")),_p("Þú")]:e.displayName),Ud(".entry-score",e.score.toString())])})))]):Ud(".leaderboard-view.empty",Ud(".empty-message",_p("Engin stig skráð enn")))}},Hg={view:e=>{const{stats:t,loading:n=!1}=e.attrs;if(n)return Ud(".stats-view.loading",Ud(".loading-message",_p("Sæki tölfræði...")));if(!t)return Ud(".stats-view.empty",Ud(".empty-message",_p("Engin tölfræði til að sýna")));const i=[{iconGlyph:"fire",label:_p("Núverandi striklota"),value:t.currentStreak,highlight:t.currentStreak>0},{iconGlyph:"star",label:_p("Lengsta striklota"),value:t.longestStreak},{iconGlyph:"tower",label:_p("Hæsta skori náð"),value:t.totalTopScores},{iconGlyph:"certificate",label:_p("Striklota hæsta skors"),value:t.topScoreStreak,highlight:t.topScoreStreak>0},{iconGlyph:"calendar",label:_p("Heildarfjöldi daga"),value:t.totalDaysPlayed}];return Ud(".stats-view",Ud(".stats-grid",i.map(((e,t)=>Ud(".stat-item"+(e.highlight?".highlight":""),{key:t},[Ud(".stat-icon",xp(e.iconGlyph)),Ud(".stat-info",[Ud(".stat-label",e.label),Ud(".stat-value",e.value.toString())])])))))}},Wg={view:e=>{const{tabs:t,activeTab:n,onTabChange:i}=e.attrs;return Ud(".tab-bar[role=tablist]",t.map((e=>{const t=n===e.id;return Ud(".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))})},[Ud("span.tab-icon-wrapper",[e.iconGlyph?Ud("span.tab-icon",xp(e.iconGlyph)):e.icon?Ud("span.tab-icon",e.icon):null,e.badgeGlyph?Ud("span.tab-badge",xp(e.badgeGlyph)):null]),Ud("span.tab-label",e.label)]);var r})))}};function Gg(e){return e.replace(/\?/g,"")}const Kg={view:e=>{const{score:t,bestMove:n,onMoveClick:i,solution:r}=e.attrs;let s;const o=n&&""!==n.word;s=o?Gg(n.word):_p("Besta mögulega lögn");const a=r&&!o?_p("Smelltu til að sjá lausn"):"",l=!(!r&&!o),c=()=>{r?i(r.word,r.coord):o&&i(n.word,n.coord)},u=l?e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),c())}:void 0;return Ud(".thermometer-best-score"+(o?".celebrate":""),Ud(".thermometer-best-score-container",{role:l?"button":void 0,tabindex:l?0:void 0,"aria-label":l?_p("Sýna besta leik"):void 0,onclick:c,onkeydown:u,title:a},[o?Ud(qg,{animate:!0}):null,Ud(".thermometer-best-circle",t.toString()),Ud(".thermometer-best-label",s)]))}},Yg={view:e=>{const{score:t,thisPlayer:n}=e.attrs;return Ud(".thermometer-current-score"+(n?".this-player":""),[Ud(".thermometer-current-circle",t.toString())])}},Jg={view:e=>{const{zoneHeights:t,zoneAllocation:n,onMoveClick:i}=e.attrs,r=t.cold,s=r+t.warm,o=[];function a(e,t,n,r){const s=e.length,a=r/(s+1);e.forEach(((e,r)=>{const l=n+a*(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;o.push(Ud(`.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?`${_p("Sýna leik")}: ${Gg(e.word)}`:void 0,onclick:u,onkeydown:h},function(e){return e.isGlobalBestScore?""===e.word?[Ud(Yg,{thisPlayer:!1,score:e.score})]:[Ud(Yg,{thisPlayer:!0,score:e.score}),Ud(".thermometer-move-word",Gg(e.word)),Ud(".thermometer-move-coord",`(${e.coord})`)]:[Ud(".thermometer-move-score",e.score.toString()),Ud(".thermometer-move-word",Gg(e.word)),Ud(".thermometer-move-coord",`(${e.coord})`)]}(e)))}))}return a(n.cold,"cold",0,t.cold),a(n.warm,"warm",r,t.warm),a(n.hot,"hot",s,t.hot),Ud(".thermometer-moves-overlay-wrapper",o)}},Xg={view:e=>{const{riddle:t,selectedMoves:n,bestMove:i,onMoveClick:r}=e.attrs,{warmBoundary:s,hotBoundary:o,bestPossibleScore:a,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,o,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),o=Math.max(15,8*i),a=r+s+o;if(a>100){const e=100/a;return{hot:r*e,warm:s*e,cold:o*e}}const l=100-a,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:o+i*u+h}}(c),h=(new Date).toISOString().split("T")[0],d=t.date<h?t.solution||l:null;return Ud(".thermometer-container",[Ud(".thermometer-body",[Ud(".thermometer-zones",[Ud(".thermometer-zone.hot",{style:`--zone-size: ${u.hot+u.warm+u.cold}%`}),Ud(".thermometer-zone.warm",{style:`--zone-size: ${u.warm+u.cold}%`}),Ud(".thermometer-zone.cold",{style:`--zone-size: ${u.cold}%`})]),Ud(Jg,{moves:n,maxScore:a,zoneHeights:u,zoneAllocation:c,onMoveClick:r})]),Ud(Kg,{score:a,bestMove:i,onMoveClick:r,solution:d})])}},Zg=()=>{let e="performance";return{view:t=>{const{view:n,selectedMoves:i,bestMove:r,onMoveClick:s}=t.attrs,{riddle:o,state:a,leaderboard:l}=n.model;if(!o)return Ud(".gatadagsins-right-side-tabs","");const c=a?.netskraflUserId||"",u=l?.some((e=>e.userId===c)),h=[{id:"performance",label:_p("Frammistaða"),iconGlyph:"dashboard"},{id:"stats",label:_p("Tölfræði"),iconGlyph:"stats"},{id:"leaderboard",label:_p("Stigatafla"),iconGlyph:"tower",badgeGlyph:u?"star":void 0}];return Ud(".gatadagsins-right-side-tabs",[Ud(Wg,{tabs:h,activeTab:e,onTabChange:t=>{e=t}}),Ud(".tab-content",["performance"===e?Ud(Xg,{riddle:o,selectedMoves:i,bestMove:r,onMoveClick:s}):null,"stats"===e?Ud(Hg,{stats:n.model.userStats||null,loading:!1}):null,"leaderboard"===e?Ud(Bg,{leaderboard:n.model.leaderboard||[],currentUserId:a?.netskraflUserId||"",loading:!1}):null])])}}},Qg={view:e=>{const{view:t,selectedMoves:n,bestMove:i,onStatsClick:r}=e.attrs,{riddle:s}=t.model,o=(e,t)=>{s&&e&&t&&s.recreateWordOnBoard(e,t)};return Ud(".gatadagsins-right-side-wrapper",s?[Ud(".gatadagsins-mobile-wrapper",[Ud(".mobile-date-nav-container",Ud($g,{view:t,date:s.date,locale:s.locale})),Ud(".gatadagsins-mobile-status",Ud(Vg,{view:t,selectedMoves:n,bestMove:i,onMoveClick:o,onStatsClick:r}))]),Ud(".gatadagsins-thermometer-column",[Ud(".desktop-date-nav-container",Ud($g,{view:t,date:s.date,locale:s.locale})),Ud(Zg,{view:t,selectedMoves:n,bestMove:i,onMoveClick:o})])]:null)}};const ef=()=>{let e=!1,t=null;return{onremove:()=>{t&&(clearTimeout(t),t=null)},view:n=>{const{score:i,position:r,word:s,onClose:o}=n.attrs,a=_p("share_text_template",{position:String(r)});return[Ud(".modal-backdrop-netskrafl",{onclick:e=>(e.preventDefault(),o(),!1),onwheel:e=>(e.preventDefault(),e.stopPropagation(),!1),ontouchmove:e=>(e.preventDefault(),e.stopPropagation(),!1)}),Ud(".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(),o())},onwheel:e=>(e.stopPropagation(),!1),ontouchmove:e=>(e.stopPropagation(),!1)},[Ud(".modal-content",[Ud("button.close",{onclick:o,"aria-label":_p("Loka")},xp("remove")),Ud(".share-popup-celebration",[Ud(qg,{animate:!0,size:84}),Ud(".share-popup-score-circle",[Ud(".share-popup-score",String(i))])]),Ud(".share-popup-title",{id:"share-popup-title"},_p("share_popup_title")),Ud(".share-popup-subtitle",_p("share_popup_subtitle")),Ud(".share-popup-word",s.toUpperCase()),Ud(".share-popup-text-preview",a),Ud(".share-popup-buttons",[Ud("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}}(a)&&(e=!0,Ud.redraw(),t=setTimeout((()=>{e=!1,t=null,Ud.redraw()}),2e3))}},[xp(e?"ok":"copy")," ",_p(e?"share_copied_confirmation":"share_button_copy")]),"undefined"!=typeof navigator&&"function"==typeof navigator.share?Ud("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}}(a)}},[xp("share")," ",_p("share_button_share")]):null])])])]}}},tf=()=>{let e="stats";return{view:t=>{const{view:n,onClose:i}=t.attrs,{riddle:r,state:s,leaderboard:o}=n.model;if(!r)return null;const a=s?.netskraflUserId||"",l=o?.some((e=>e.userId===a)),c=[{id:"stats",label:_p("Tölfræði"),iconGlyph:"stats"},{id:"leaderboard",label:_p("Stigatafla"),iconGlyph:"tower",badgeGlyph:l?"star":void 0}];return[Ud(".modal-backdrop-netskrafl",{onclick:e=>(e.preventDefault(),!1),onwheel:e=>(e.preventDefault(),e.stopPropagation(),!1),ontouchmove:e=>(e.preventDefault(),e.stopPropagation(),!1)}),Ud(".modal-dialog.stats-modal",{onwheel:e=>(e.stopPropagation(),!1),ontouchmove:e=>(e.stopPropagation(),!1)},[Ud(".modal-content",[Ud("button.close",{onclick:i,"aria-label":"Loka"},xp("remove")),Ud(Wg,{tabs:c,activeTab:e,onTabChange:t=>{e=t}}),Ud(".modal-body",["stats"===e?Ud(Hg,{stats:n.model.userStats||null,loading:!1}):null,"leaderboard"===e?Ud(Bg,{leaderboard:n.model.leaderboard||[],currentUserId:s?.netskraflUserId||"",loading:!1}):null])])])]}}},nf={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:o,bestMove:a}=s?rf(s):{selectedMoves:[],bestMove:void 0},l=()=>{n.showHelp=!n.showHelp,Ud.redraw()},c=()=>{n.showStatsModal=!n.showStatsModal,Ud.redraw()};return Ud("div.drop-target",{id:"gatadagsins-background"},[Ud(".gatadagsins-container",[s?Ud(".gatadagsins-main",[Ud(Fg,{view:i}),Ud(Qg,{view:i,selectedMoves:o,bestMove:a,onStatsClick:c}),s.askingForBlank?Ud(yg,{game:s}):""]):"",r.state?.beginner?Ud(Vp,{view:i,showClose:!1}):"",Ud(".info",{title:_p("Upplýsingar og hjálp")},Ud("a.iconlink",{href:"#",onclick:e=>{e.preventDefault(),l()}},xp("info-sign"))),n.showHelp?Ud(Ug,{onClose:l}):""]),n.showStatsModal?Ud(tf,{view:i,onClose:c}):"",s?.justAchievedBestScore&&a?Ud(ef,{score:a.score,position:r.solverCount+1,word:a.word,onClose:()=>{s&&(s.justAchievedBestScore=!1),Ud.redraw()}}):""])}},rf=e=>{const t=e.model.state?.netskraflUserId||"",{bestPossibleScore:n,globalBestScore:i,playerMoves:r}=e;let s;const o=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;(o[0]?.score??0)>=e?o[0].isGlobalBestScore=!0:i.player===t?o.unshift({score:e,isGlobalBestScore:!0,word:n,coord:r}):o.unshift({score:e,isGlobalBestScore:!0,word:"",coord:""})}return o.length>0&&o[0].score===n&&(s=o.shift()),{selectedMoves:o,bestMove:s}};function sf(e,t,n){const i=n.target;if("INPUT"===i.tagName||"TEXTAREA"===i.tagName||"SELECT"===i.tagName||i.isContentEditable)return;if(t.isMobile())return;if(e.showingDialog)return;if(null!==e.askingForBlank)return;const{key:r}=n;if("ArrowRight"===r)return n.preventDefault(),e.setKeyboardDirection("H"),void Ud.redraw();if("ArrowDown"===r)return n.preventDefault(),e.setKeyboardDirection("V"),void Ud.redraw();if("Backspace"===r)return n.preventDefault(),void(e.undoLastKeyboardTile()&&Ud.redraw());if("Escape"===r)return n.preventDefault(),e.resetRack(),void Ud.redraw();const s=r.normalize("NFC");if(1===s.length){const t=s.toLowerCase();if(e.alphabet.includes(t))return n.preventDefault(),void(e.placeKeyboardTile(t)&&Ud.redraw())}}let of=null;class af{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 lf{getLocalTile(e){return""}getLocalTileSq(e){return""}setLocalTile(e,t){}setLocalTileSq(e,t){}clearTiles(){}saveTiles(e){}loadTiles(){return[]}}const cf=e=>function(){if(null===of)try{of="localStorage"in window&&null!==window.localStorage&&void 0!==window.localStorage}catch(e){of=!1}return of}()?new af(e):new lf;const uf=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 ip(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}},hf={standard:"H8",explo:"D4"},df={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 gf{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=cf(e),this.board_type=n,this.startSquare=hf[n],this.startCoord=df[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}=Fp(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}tilesPlaced(){const e=[];for(const t of Object.keys(this.tiles))"R"!==t[0]&&this.tiles[t].draggable&&e.push(t);return e}resetRack(){this.selectedSq=null,this._resetRack(),this.saveTiles()}_resetRack(){const e=this.tilesPlaced();if(e.length){let t=1;for(let n=0;n<e.length;n++){for(;`R${t}`in this.tiles;)t++;const i=`R${t}`;this.tiles[i]=this.tiles[e[n]],delete this.tiles[e[n]],"?"===this.tiles[i].tile&&(this.tiles[i].letter=" "),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){this.tiles={}}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 uf.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=sp,r=sp,s=0,o=0,a=0,l=0,c="",u="";const h=[],d=Object.values(this.tiles).filter((e=>!e.draggable)).length;if(this.tilesPlaced().forEach((t=>{const l=rp.indexOf(t.charAt(0)),c=parseInt(t.slice(1),10)-1,u=this.tiles[t];e+=u.score*this.letterScore(l,c),a++,n*=this.wordScore(l,c),l<i&&(i=l),c<r&&(r=c),l>s&&(s=l),c>o&&(o=c)})),!a)return;if(i!==s&&r!==o)return;let p=r,g=i,f=0,m=0;for(i!==s?m=1:r!==o||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=jp(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<=o||m&&g<=s?void 0:(h.push(c),{word:c,wordWithBlanks:u,words:h,score:e*n+t+(7===a?50:0),coord:v})}calcCrossScore(e,t,n,i){let r,s=0,o=!1,a=t,l=e,c="";for(;null!==this.tileAt(l-n,a-i);)a-=i,l-=n;for(;null!==(r=this.tileAt(l,a));){let u=r.score;a===t&&l===e?u*=this.letterScore(l,a):o=!0,c+=r.letter,s+=u,a+=i,l+=n}return o?{score:s*this.wordScore(e,t),word:c}:{score:-1,word:""}}tileAt(e,t){const n=jp(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,o=t;for(;s>=0&&s<sp&&o>=0&&o<sp;){const e=jp(s,o);if(e&&!(e in this.tiles))return e;s+=r,o+=i}return null}canContinueInDirection(e,t){const n=Fp(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=rp.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,o="V"===n?1:0;return this.findNextEmptySquare(i+o,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 ff extends gf{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()}init(e){if(e){if(this.over=99===e.result,!this.over&&0!==e.result)return this.currentError=e.result||"server",void(this.currentMessage=e.msg||"");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=hf[this.board_type],this.startCoord=df[this.board_type],this.congratulate=this.over&&null!==this.player&&this.scores[this.player]>this.scores[1-this.player],null===this.currentError&&this.placeTiles(),uf.ingestTwoLetterWords(this.locale,this.two_letter_words[0])}else super.init()}initMockupGame(){this.tiles={},this.startSquare=hf[this.board_type],this.startCoord=df[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}}uf.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.init(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 np(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,Ud.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),o=Math.floor(s/60),a=Math.floor(s-60*o);return i?(this.penalty0=0,this.penalty1=0):r<0&&(0===e?this.penalty0=-10*Math.floor((60*o+a+59)/60):this.penalty1=-10*Math.floor((60*o+a+59)/60)),(r<0?"-":"")+`0${o.toString()}`.slice(-2)+":"+`0${a.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 np(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 np(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 np(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=Fp(t);let s=r.col,o=r.row,a=!1,l=0;for(let t=0;t<n.length;t++){let c=n[t];if("?"===c){a=!0;continue}const u=jp(o,s);if(null===u)continue;const h=c;a&&(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&&(e===this.player?this.tiles[u].highlight=0:1-e===this.player&&(this.tiles[u].highlight=1),l++)),s+=r.dx,o+=r.dy,a=!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 rp){let n="";for(let e=0;e<sp;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){this.tiles={},this.numTileMoves=0;const n=this.moves,i=void 0!==e,r=!i&&!this.lastmove&&this.localturn,s=!t&&(r||i),o=void 0!==e?e:n.length;function a(e){if(e+2>=o)return!1;const[t,[i,r,s]]=n[e+2];return""===i&&("RESP"===r&&s<0)}for(let e=0;e<o;e++){const[t,[i,r]]=n[e];""===i||a(e)||(this.placeMove(t,i,r,e===o-1&&s),this.numTileMoves++)}const l=this.lastmove;if(l&&this.localturn)for(let e=0;e<l.length;e++){const t=l[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}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}}}allowDragDrop(){return!this.over&&!this.showingDialog&&!this.moveInProgress}async sendMove(e){this.moveInProgress=!0;try{const t=await np(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 np(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;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 mf="gata_";function vf(e,t){return`${mf}${t}_${e}`}function yf(e,t,n){if(!e||!t)return;const i={date:t,moves:n,timestamp:(new Date).toISOString(),userId:e};try{const n=vf(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(mf)){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 wf extends gf{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 np(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,uf.ingestTwoLetterWords(this.locale,this.two_letter_words[0]),n.netskraflUserId)){const t=function(e,t){if(!e||!t)return[];try{const n=vf(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 np(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(yf(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}=Fp(t),o=[];for(let e=1;e<=7;e++){const t=`R${e}`;t in this.tiles&&o.push(t)}let a=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=jp(a,l);if(!i)return;const u=this.tileAt(a,l);if(u&&!u.draggable){if(u.letter!==t)return}else{if(0===o.length)return;let e=!1;for(let r=0;r<o.length;r++){const s=o[r],a=this.tiles[s];if(a){const l="?"===a.tile?" ":a.tile;if(n){if("?"===a.tile){a.letter=t,this.tiles[i]=a,delete this.tiles[s],o.splice(r,1),e=!0;break}}else if(l===t){this.tiles[i]=a,delete this.tiles[s],o.splice(r,1),e=!0;break}}}if(!e)return}a+=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=jp(t,e);if(!i||!r)continue;const s=i.toLowerCase(),o=s!==i;if(this.alphabet.includes(s)){const e=o?0:this.tile_scores[s]||1;this.tiles[r]={player:0,tile:o?"?":s,letter:s,score:e,freshtile:!1,draggable:!1,index:-1,xchg:!1}}}}}cleanup(){super.cleanup()}}function bf(){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 _f{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,wp(t.locale)}async post(e,t){if(!this.state)throw new Error("Model state is not initialized");return np(this.state,{method:"POST",url:e,body:t})}async getText(e){if(!this.state)throw new Error("Model state is not initialized");return np(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 np(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 ip(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 ff(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 Ud.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++;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):(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,a(n)),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),Ud.redraw())}handleUserMoveMessage(e,t){!t&&this.state&&e&&(this.loadingGameList||(this.gameList=null,Ud.redraw()))}handleMoveMessage(e,t){!t&&this.game&&(this.game.update(e),this.state.audio&&null!==this.game.player&&!this.game.isRobotGame()&&Ap(this.state,"your-turn"),Ud.redraw())}notifyMove(){this.loadingGameList||(this.gameList=null)}notifyGameWon(){this.user?.fanfare&&Ap(this.state,"you-win")}moreGamesAllowed(){if(!this.state)return!1;if(this.loadingGameList)return!1;if(!this.gameList)return!0;return!(this.gameList.length>=50)&&(!!this.state.hasPaid||this.gameList.length<this.maxFreeGames)}async initRiddle(e,t){this.riddle=new wf(`gatadagsins-${e}`,e,this),await this.riddle.load(e,t)}}const kf=()=>{let e=!1;return{view:t=>{const{view:n,item:i}=t.attrs,r=n.model.state;if(!r)return;const s=""!==r.plan,o=i.fairplay&&r.fairPlay;return Ud(".modal-dialog",{id:"chall-dialog",style:{visibility:"visible"}},Ud(".ui-widget.ui-widget-content.ui-corner-all",{id:"chall-form"},[Ud(".chall-hdr",Ud("table",Ud("tbody",Ud("tr",[Ud("td",Ud("h1.chall-icon",xp("hand-right"))),Ud("td.l-border",[Ud(rg,{id:"chall-online",userId:i.userid,state:r}),Ud("h1",i.nick),Ud("h2",i.fullname)])])))),Ud("div",{style:{"text-align":"center"}},[Ud(".promo-fullscreen",[kp("p",[kp("strong","Ný áskorun")," - veldu lengd viðureignar:"]),Ud(ag,{initialSelection:0,defaultClass:"chall-time"},[Ud("div",{id:"chall-none",tabindex:1},bp("Viðureign án klukku")),Ud("div",{id:"chall-10",tabindex:2},[xp("time"),bp("2 x 10 mínútur")]),Ud("div",{id:"chall-15",tabindex:3},[xp("time"),bp("2 x 15 mínútur")]),Ud("div",{id:"chall-20",tabindex:4},[xp("time"),bp("2 x 20 mínútur")]),Ud("div",{id:"chall-25",tabindex:5},[xp("time"),bp("2 x 25 mínútur")]),r?.runningLocal?Ud("div",{id:"chall-3",tabindex:6},[xp("time"),bp("2 x 3 mínútur")]):Ud("div",{id:"chall-30",tabindex:6},[xp("time"),bp("2 x 30 mínútur")])])]),Ud(".promo-mobile",[Ud("p",kp("strong","Ný áskorun")),Ud(".chall-time.selected",{id:"extra-none",tabindex:1},bp("Viðureign án klukku"))])]),s?Ud("div",{id:"chall-manual"},[kp("span.caption.wide",["Nota ",kp("strong","handvirka véfengingu"),Ud("br"),'("keppnishamur")']),Ud(".toggler[id='manual-toggler'][tabindex='7']",{onclick:t=>{e=!e,t.preventDefault()}},[Ud(".option"+(e?"":".selected"),Ud("span",Lp())),Ud(".option"+(e?".selected":""),xp("lightbulb"))])]):"",o?Ud("div",{id:"chall-fairplay"},[bp("Báðir leikmenn lýsa því yfir að þeir skrafla "),Ud("br"),kp("strong","án stafrænna hjálpartækja"),bp(" af nokkru tagi"),"."]):"",Ud(tg,{id:"chall-cancel",title:_p("Hætta við"),tabindex:8,onclick:e=>{n.popDialog(),e.preventDefault()}},xp("remove")),Ud(tg,{id:"chall-ok",title:_p("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:o,manual:e}),n.popDialog(),t.preventDefault()}},xp("ok"))]))}}},Cf=e=>{const{view:t}=e.attrs,{model:n}=t;return{view:()=>{if(!n.state)return;const e=n.state;return Ud(".modal-dialog",{id:"promo-dialog",style:{visibility:"visible"}},Ud(".ui-widget.ui-widget-content.ui-corner-all",{id:"promo-form"},[Ud(".promo-content",[Ud("h2",[xp("coffee-cup"),Lp(),"Komdu í áskrift að Netskrafli!"]),Ud("p","Með áskrift að Netskrafli færðu aðgang að öllu því sem leikurinn hefur að bjóða:"),Ud("ul",[Ud("li",["Sem áskrifandi getur þú haft ",Ud("b","ótakmarkaðan fjölda viðureigna")," í gangi samtímis (í stað ",Ud("b",8..toString())," að hámarki)."]),Ud("li",["Sem áskrifandi hefur þú aðgang að ",Ud("b","yfirliti")," í lok hverrar viðureignar þar sem hún er rakin leik fyrir leik ","og bestu möguleikar í hverri stöðu sýndir."]),Ud("li",["Sem áskrifandi getur þú skorað á aðra leikmenn í ",Ud("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ð.)"]),Ud("li",["Þú getur líka gerst áskrifandi að ",Ud("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."])]),Ud("p",kp("strong","Komdu með — og styrktu íslenska máltækni í leiðinni!"))]),Ud(".btn-promo-yes",{id:"friend-yes",title:_p("Gerast áskrifandi"),tabindex:1,onclick:t=>{t.preventDefault(),fh("click_friend",{userid:e.netskraflUserId,locale:e.locale}),window.location.href=e.subscriptionUrl}},[xp("ok"),Lp(),_p("Gerast áskrifandi")]),Ud(".btn-promo-no",{id:"friend-no",title:_p("Hætta við"),tabindex:2,onclick:e=>{t.popDialog(),e.preventDefault()}},[xp("remove"),Lp(),_p("Nei, takk")])]))}}},Sf=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(Ud(".chall-info",[xp("info-sign"),Lp(),kp("span.pass-explain","opponent_emptied_rack")])),"resign"===e.showingDialog&&t.push(Ud(".resign",[xp("exclamation-sign"),Lp(),_p("Viltu gefa leikinn?"),Lp(),Ud("span.mobile-break",Ud("br")),Ud("span.yesnobutton",{onclick:()=>e.confirmResign(!0)},[xp("ok"),_p(" Já")]),Ud("span.mobile-space"),Ud("span.yesnobutton",{onclick:()=>e.confirmResign(!1)},[xp("remove"),_p(" Nei")])])),"pass"===e.showingDialog&&(e.last_chall?t.push(Ud(".pass-last",[xp("forward"),Lp(),_p("Segja pass?"),kp("span.pass-explain","Viðureign lýkur þar með"),Lp(),Ud("span.mobile-break",Ud("br")),Ud("span.yesnobutton",{onclick:()=>e.confirmPass(!0)},[xp("ok"),_p(" Já")]),Ud("span.mobile-space"),Ud("span.yesnobutton",{onclick:()=>e.confirmPass(!1)},[xp("remove"),_p(" Nei")])])):t.push(Ud(".pass",[xp("forward"),Lp(),_p("Segja pass?"),kp("span.pass-explain","2x3 pöss í röð ljúka viðureign"),Lp(),Ud("span.mobile-break",Ud("br")),Ud("span.yesnobutton",{onclick:()=>e.confirmPass(!0)},[xp("ok"),_p(" Já")]),Ud("span.mobile-space"),Ud("span.yesnobutton",{onclick:()=>e.confirmPass(!1)},[xp("remove"),_p(" Nei")])]))),"exchange"===e.showingDialog&&t.push(Ud(".exchange",[xp("refresh"),Lp(),_p("Smelltu á flísarnar sem þú vilt skipta"),Lp(),Ud("span.mobile-break",Ud("br")),Ud("span.yesnobutton",{title:_p("Skipta"),onclick:()=>e.confirmExchange(!0)},xp("ok")),Ud("span.mobile-space"),Ud("span.yesnobutton",{title:_p("Hætta við"),onclick:()=>e.confirmExchange(!1)},xp("remove"))])),"chall"===e.showingDialog&&t.push(Ud(".chall",[xp("ban-circle"),Lp(),_p("Véfengja lögn?"),kp("span.pass-explain","Röng véfenging kostar 10 stig"),Lp(),Ud("span.mobile-break",Ud("br")),Ud("span.yesnobutton",{onclick:()=>e.confirmChallenge(!0)},[xp("ok"),_p(" Já")]),Ud("span.mobile-space"),Ud("span.yesnobutton",{onclick:()=>e.confirmChallenge(!1)},[xp("remove"),_p(" Nei")])]))),t}}},Tf=()=>({view:e=>{const{bag:t,newbag:n}=e.attrs;let i="";return t.length<=7?i+=".empty":n&&(i+=".new"),Ud(".bag",{title:_p("Flísar sem eftir eru")},Ud(`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="&nbsp;"),r.push(Ud("td",Ud.trust(t))),i--}t.push(Ud("tr",r))}return t}(t)))}}),If=[{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"}],Ef=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 o=null;function a(e,t){const n=s(e);let i=null;if(null===o||(r=o,a=n,Math.round((a-r)/1e3)>=300)){const r=864e5,s=Date.now(),o=s-s%r;let a;a=n<o-r?e.slice(0,-3):n<o?`Í gær ${e.slice(11,16)}`:e.slice(11,16),i=Ud(".chat-ts",{key:t},a)}var r,a;return o=n,i}const l=i?i.player:null;function c(e){if(!r)return e;for(const t of If)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=a(n.ts,t);null!==s&&(e.push(s),t++);let o=Np(n.msg);o=c(o),e.push(Ud(".chat-msg"+(0===i?".left":".right")+(i===l?".local":".remote"),{key:t++},Ud.trust(o)))}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=Dp("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:()=>Ud(".chat-container",{style:"z-index: 6"},[Ud(".chat-area"+(i?.showClock()?".with-clock":""),{id:"chat-area",oncreate:h,onupdate:h},u()),Ud(".chat-input",[Ud("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())}}),Ud(tg,{id:"chat-send",title:_p("Senda"),onclick:e=>{p(),e.preventDefault()}},xp("chat"))])])}},Pf=()=>{function e(e,t,n,i,r){const s=Fp(t);let o=s.col,a=s.row;for(const t of n){if("?"===t)continue;const n=jp(a,o);n&&n in e.tiles&&(e.tiles[n].highlight=r?i:void 0),o+=s.dx,a+=s.dy}}function t(t,n,i){const{game:r,state:s}=t.model;if(!r||!s)return null;const{leftTotal:o,rightTotal:a,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=` ${_p("Pass")} `,h="";else if(0===u.indexOf("EXCH")){const e=u.slice(5).length,t=_p(1===e?"letter":"letters");u=" "+_p("exchanged",{numtiles:e.toString(),letters:t})+" ",h=""}else"RSGN"===u?u=` ${_p("Gaf viðureign")} `:"CHALL"===u?(u=` ${_p("Véfengdi lögn")} `,h=""):"RESP"===u?h<0?(u=` ${_p("Óleyfileg lögn")} `,g=-1):u=` ${_p("Röng véfenging")} `:"TIME"===u?u=` ${_p("Umframtími")} `:"OVER"===u?(u=_p("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 Ud(".move.gameover",[Ud("span.gameovermsg",i),Ud("span.statsbutton",{onclick:i=>{i.preventDefault(),n.hasPaid?(Ud.route.set(`/review/${t.uuid}`),null!=t&&fh("game_review",{locale:t.locale,uuid:t.uuid})):(fh("click_review",{userid:n.netskraflUserId,locale:n.locale}),e.showFriendPromo())}},bp("Skoða yfirlit"))])}(t,r,s,u);const f=g>0&&!r.manual?_p("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?Ud(`.move.leftmove.${y}`,w,[Ud("span.total"+(l===v?".human":".autoplayer"),o),Ud("span.score"+(n[2]?".highlight":""),h),Ud(`span.${d}`,[Ud("i",u),Lp(),c])]):Ud(`.move.rightmove.${y}`,w,[Ud(`span.${d}`,[c,Lp(),Ud("i",u)]),Ud("span.score"+(n[2]?".highlight":""),h),Ud("span.total"+(l===v?".human":".autoplayer"),a)])}return{view:e=>{const{view:n,move:i,info:r}=e.attrs;return t(n,i,r)}}},xf=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],o=t.nickname[0],a=t.nickname[1],l=t.player,c=t.localturn,u=t.over;if("left"===e.attrs.side){if(r)return Ud(".robot-btn.left",[xp("cog"),Lp(),o]);return Ud(`.player-btn.left${u||c!==(0===l)?"":".tomove"}`,{id:"player-0",onclick:e=>i(t,e,l,0)},[Ud("span.left-to-move"),o])}if(s)return Ud(".robot-btn.right",[xp("cog"),Lp(),a]);return Ud(`.player-btn.right${u||c!==(1===l)?"":".tomove"}`,{id:"player-1",onclick:e=>i(t,e,l,1)},[Ud("span.right-to-move"),a])}}},Rf=e=>{const t=e.attrs.view.model;let n=0;return{view:()=>{if(!t.game)return;const e=t.game,i=e.twoLetterWords()[n],r=[];for(const e of i){const t=e[1],i=[];for(let e=0;e<t.length;e++)i.push((s=0===e,o=t[e],Ud(".twoletter-word",s?0===n?[Ud("b",o[0]),o[1]]:[o[0],Ud("b",o[1])]:o)));r.push(Ud(".twoletter-group",i))}var s,o;return Ud(".twoletter",{onclick:()=>{n=1-n},style:"z-index: 6"},Ud(".twoletter-area"+(e.showClock()?".with-clock":""),{title:_p(0===n?"Smelltu til að raða eftir seinni staf":"Smelltu til að raða eftir fyrri staf")},r))}}},Lf=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 o=e[i],[a,[l,c,u]]=o;0===a?r=Math.max(r+u,0):s=Math.max(s+u,0);const h=Ud(Pf,{view:t,move:o,info:{leftTotal:r,rightTotal:s,player:a,co:l,tiles:c,score:u}});n.push(h)}return n}const o=i?i.bag:"",a=!i||i.newbag;return{view:()=>Ud(".movelist-container",[Ud(".movelist",{onupdate:()=>{setTimeout(Op)}},s()),r?.uiFullscreen?"":Ud(Tf,{bag:o,newbag:a})])}},Nf=e=>{const t=e.attrs.view.model;return{view:()=>Ud(".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?[xp("cog"),Lp(),t.opp]:[t.opp];const i=t.sc0<t.sc1?".losing":"",s=`Staðan er ${t.sc0}:${t.sc1}`;e.push(Ud(".games-item"+(t.timed?".game-timed":""),{key:t.uuid,title:s},Ud(Ud.route.Link,{href:Mp(t.url)},[Ud(".at-top-left",Ud(".tilecount",Ud(".oc",n))),Ud(".at-top-left",Ud(".tilecount.trans",Ud(`.tc${i}`,{style:{width:`${t.tile_count.toString()}%`}},n)))])))}return e}())}},Df={view:e=>{const{view:t,tabid:n,title:i,icon:r,alert:s,funcSel:o}=e.attrs,a=t.selectedTab||"movelist",l=t.model.game;return Ud(".right-tab"+(a===n?".selected":""),{id:`tab-${n}`,className:s?"chat-alert":"",title:i,onclick:e=>{l&&null===l.showingDialog&&t.setSelectedTab(n)&&(o?.(),"movelist"===n&&setTimeout(Op)),e.preventDefault()}},xp(r))}},Af={view:e=>{const{view:t}=e.attrs,{game:n}=t.model,i=n&&!n.isRobotGame()&&null!==n.player,r=[Ud(Df,{view:t,tabid:"board",title:_p("Borðið"),icon:"grid"}),Ud(Df,{view:t,tabid:"movelist",title:_p("Leikir"),icon:"show-lines"}),Ud(Df,{view:t,tabid:"twoletter",title:_p("Tveggja stafa orð"),icon:"life-preserver"}),Ud(Df,{view:t,tabid:"games",title:_p("Viðureignir"),icon:"flag"})];return i&&r.push(Ud(Df,{view:t,tabid:"chat",title:_p("Spjall"),icon:"conversation",funcSel:()=>{n.markChatShown()&&Ud.redraw()},alert:!n.chatSeen&&"chat"!==t.selectedTab})),Ud.fragment({},r)}},Mf=e=>{const{view:t}=e.attrs,{model:n}=t,{game:i}=n;function r(){if(!i||!i.showClock())return Ud.fragment({},[]);function e(e,t,n,i){return Ud("h3."+e+(n?".running-out":"")+(i?".blink":""),t)}return Ud.fragment({},[e("clockleft",i.clockText0,i.runningOut0,i.blinking0),e("clockright",i.clockText1,i.runningOut1,i.blinking1),Ud(".clockface",xp("time"))])}function s(){const e=!!i&&i.fairplay,n=i?i.player:null,s=i?i.displayScore(0).toString():"",o=i?i.displayScore(1).toString():"";return Ud(".heading",[Ud(".logowrapper",Ud(ug)),Ud(".playerwrapper",[Ud(".leftplayer"+(1===n?".autoplayercolor":".humancolor"),[Ud(".player",Ud(xf,{view:t,side:"left"})),Ud(".scorewrapper",Ud(".scoreleft",s))]),Ud(".rightplayer"+(1===n?".humancolor":".autoplayercolor"),[Ud(".player",Ud(xf,{view:t,side:"right"})),Ud(".scorewrapper",Ud(".scoreright",o))]),Ud(".fairplay",{style:{visibility:e?"visible":"hidden"}},Ud("span.fairplay-btn.large",{title:_p("Skraflað án hjálpartækja")}))]),r()])}function o(){if(!i)return;let e;switch(t.selectedTab||"movelist"){case"movelist":e=Ud(Lf,{view:t});break;case"twoletter":e=Ud(Rf,{view:t});break;case"chat":e=Ud(Ef,{view:t});break;case"games":e=Ud(Nf,{view:t})}const n=Ud(Af,{view:t});return Ud(".right-area"+(i?.showClock()?".with-clock":""),e?[n,e]:[n])}return{view:()=>Ud(".rightcol",[s(),o()])}},Of={view:e=>{const{view:t}=e.attrs,{model:n}=t,{game:i,state:r}=n;if(!i)return Ud("div",[Ud(".game-container"),Ud(cg)]);const{bag:s,newbag:o}=i;return Ud("div.drop-target",{id:"board-background"},[Ud(".game-container",[Ud(Mf,{view:t}),Ud(Mg,{view:t,game:i}),r?.uiFullscreen?Ud(Tf,{bag:s,newbag:o}):"",i.askingForBlank?Ud(yg,{game:i}):""]),Ud(cg),r?.beginner?Ud(Vp,{view:t,showClose:!0}):"",Ud(lg)])}},jf=()=>({view:e=>{const t=e.attrs.ownStats||{},n=[];if(t.highest_score&&(n.push(_p("Hæsta skor ")),n.push(Ud("b",Ud(Ud.route.Link,{href:`/game/${t.highest_score_game}`},t.highest_score)))),t.best_word){n.length&&(e.attrs.myself?n.push(Ud("br")):n.push(" | "));const i=t.best_word,r=[];for(let e=0;e<i.length;e++)"?"===i[e]?(r.push(Ud("span.netskrafl-blanktile",i[e+1])),e+=1):r.push(i[e]);n.push(_p("Besta orð ")),n.push(Ud("span.best-word",r)),n.push(", "),n.push(Ud("b",Ud(Ud.route.Link,{href:`/game/${t.best_word_game}`},t.best_word_score))),n.push(_p(" stig"))}return Ud("p",{id:e.attrs.id},n)}}),Ff=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 o(e){if(e.preventDefault(),!r.moreGamesAllowed()){const e=r.state;return e&&fh("hit_game_limit",{userid:e.netskraflUserId,locale:e.locale,limit:r.maxFreeGames}),void 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,a=(l=n.prefs)&&void 0!==l.duration&&0!==l.duration?bp("with_clock",{duration:l.duration.toString()}):bp("Venjuleg ótímabundin viðureign");var l;return Ud(".listitem"+(i%2==0?".oddlist":".evenlist"),[Ud("span.list-ch",{onclick:s},n.received?xp("thumbs-down",{title:_p("Hafna")}):xp("hand-right",{title:_p("Afturkalla")})),Ud(r?"a.flex":"span.flex",r?{href:"#",onclick:o,class:e?"opp-ready":""}:{},[Ud("span.list-ts",n.ts),Ud("span.list-nick",{title:n.fullname},n.opp),Ud("span.list-chall",[n.prefs.fairplay?Ud("span.fairplay-btn",{title:_p("Án hjálpartækja")}):"",n.prefs.manual?Ud("span.manual-btn",{title:_p("Keppnishamur")}):"",a])]),Ud(ig,{view:t,item:{userid:n.userid,nick:n.opp,fullname:n.fullname}})])}}},Uf={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=Ud("div",{id:n?"chall-received":"chall-sent"},r.map(((e,n)=>Ud(Ff,{view:t,item:e,i:n}))));return n?[Ud(".listitem.listheader",[Ud("span.list-icon",Rp("thumbs-down",{title:_p("Hafna")})),kp("span.list-ts","Hvenær"),kp("span.list-nick","Áskorandi"),kp("span.list-chall","Hvernig"),kp("span.list-info-hdr","Ferill")]),s]:[Ud(".listitem.listheader",[Ud("span.list-icon",Rp("hand-right",{title:_p("Afturkalla")})),kp("span.list-ts","Hvenær"),kp("span.list-nick","Andstæðingur"),kp("span.list-chall","Hvernig"),kp("span.list-info-hdr","Ferill")]),s]}},zf={view:e=>{const{loadingGameList:t,loadingAllLists:n,gameList:i}=e.attrs;return t||n||null!==i&&i.length>0?"":Ud(".hint",{style:{display:"block"}},[Ud("p",["Ef þig vantar einhvern til að skrafla við, veldu flipann ",Ud(Ud.route.Link,{href:"/main?tab=2"},[xp("user"),Lp(),"Andstæðingar"])," og skoraðu á tölvuþjarka - ",xp("cog"),Lp(),Ud("b","Amlóða"),", ",xp("cog"),Lp(),Ud("b","Miðlung")," eða ",xp("cog"),Lp(),Ud("b","Fullsterkan")," - eða veldu þér annan leikmann úr stafrófs­listunum sem þar er að finna til að skora á."]),Ud("p",["Þú stofnar áskorun með því að smella á bendi-teiknið ",xp("hand-right",{style:{"margin-left":"6px","margin-right":"6px"}})," vinstra megin við nafn andstæðingsins."]),Ud("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."),Ud("p.no-mobile-block",[Ud(Ud.route.Link,{href:"/help"},"Hjálp")," má fá með því að smella á bláa ",xp("info-sign"),Lp(),"-",Lp(),"teiknið hér til vinstri."]),Ud("p.no-mobile-block","Þú kemst alltaf aftur í þessa aðalsíðu með því að smella á örvarmerkið efst vinstra megin við skraflborðið.")])}},$f=()=>{function e(e){const t=null===e.oppid?[xp("cog"),Lp(),e.opp]:e.opp;return Ud("span.list-opp",{title:e.fullname},t)}function t(e){let t="",n="";return e.my_turn?t=_p("Þú átt leik"):e.zombie?(t=_p("Viðureign lokið"),n=".zombie"):(t=_p("opp_move",{opponent:e.opp}),n=".grayed"),Ud("span.list-myturn",Ud(`span.glyphicon.glyphicon-flag${n}`,{title:t}))}function n(e){return e.overdue?xp("hourglass",{title:e.my_turn?"Er að renna út á tíma":"Getur þvingað fram uppgjöf"}):Rp("hourglass")}function i(e){const t=e.sc0<e.sc1?".losing":"";return Ud(".tilecount",Ud(`.tc${t}`,{style:{width:`${e.tile_count.toString()}%`}}))}return{view:r=>{const{view:s,item:o,i:a}=r.attrs;return Ud(".listitem"+(a%2==0?".oddlist":".evenlist"),[Ud(Ud.route.Link,{href:Mp(o.url)},[t(o),Ud("span.list-overdue",n(o)),Ud("span.list-ts-short",o.ts),e(o)]),Ud(ig,{view:s,item:{userid:o.oppid,nick:o.opp,fullname:o.fullname}}),Ud("span.list-s0",o.sc0),Ud("span.list-colon",":"),Ud("span.list-s1",o.sc1),Ud("span.list-tc",i(o)),Ud(og,{manual:o.prefs?.manual})])}}},qf=()=>({view:e=>{const{view:t,id:n}=e.attrs,{model:i}=t,{gameList:r,loadingGameList:s,loadingAllLists:o}=i;return null===r&&i.loadGameList(),[Ud(".listitem.listheader",[Ud("span.list-myturn",Rp("flag",{title:_p("Átt þú leik?")})),Ud("span.list-overdue",Rp("hourglass",{title:_p("Langt frá síðasta leik?")})),kp("span.list-ts-short","Síðasti leikur"),kp("span.list-opp","Andstæðingur"),kp("span.list-info-hdr","Ferill"),kp("span.list-scorehdr","Staða"),kp("span.list-tc","Framvinda"),Ud(og,{header:!0})]),Ud("div",{id:n},r?r.map(((e,n)=>Ud($f,{view:t,item:e,i:n}))):""),Ud(zf,{loadingGameList:s,loadingAllLists:o,gameList:r})]}}),Vf=()=>{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=xp("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=xp("stroller",{title:"Byrjandi"})))),n=Ud("span",{class:`elo-btn right ${r}${""===n?" invisible":""}`},n),i=Ud("span",{class:"elo-btn left "+s+(""===i?" invisible":"")},i),Ud(".listitem"+(t%2==0?".oddlist":".evenlist"),Ud(Ud.route.Link,{href:Mp(e.url)},[Ud("span.list-win",e.sc0>=e.sc1?xp("bookmark",{title:e.sc0===e.sc1?_p("Jafntefli"):_p("Sigur")}):Rp("bookmark",{title:_p("Tap")})),Ud("span.list-ts-short",e.ts_last_move),Ud("span.list-nick",e.opp_is_robot?[xp("cog"),Lp(),e.opp]:e.opp),Ud("span.list-s0",e.sc0),Ud("span.list-colon",":"),Ud("span.list-s1",e.sc1),Ud("div.list-elo-adj",i),Ud("div.list-elo-adj",n),Ud("span.list-duration",function(){let t="";return e.prefs?.duration?t=[Ud("span.timed-btn",{title:_p("Viðureign með klukku")}),` 2 x ${e.prefs.duration}${_p(" mínútur")}`]:(e.days||e.hours||e.minutes)&&(e.days>1?t=e.days.toString()+_p(" dagar"):1===e.days&&(t=_p("1 dagur")),e.hours>0&&(t.length&&(t+=_p(" og ")),1===e.hours?t+=_p("1 klst"):t+=e.hours.toString()+_p(" klst")),0===e.days&&(t.length&&(t+=_p(" og ")),1===e.minutes?t+=_p("1 mínúta"):t+=e.minutes.toString()+_p(" mínútur"))),t}()),Ud(og,{manual:e.prefs?.manual})]))}return{view:t=>{const n=t.attrs.recentList;return Ud("div",{id:t.attrs.id},n?n.map(e):"")}}},Bf=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 Ud(".user-cat[id='user-search']",[xp("search",{id:"search",className:"search"===e?"shown":"",onclick:()=>{r="",s(),document.getElementById("search-id")?.focus()}}),Lp(),Ud("input.text.userid",{type:"text",id:"search-id",name:"search-id",maxlength:16,placeholder:_p("Einkenni eða nafn"),value:r,onfocus:()=>s(),oninput:e=>{r=`${e.target.value}`,s()}})])}}},Hf=()=>{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?[xp(t),Lp(),i]:i}return{view:n=>{var i=n.attrs.ownStats,r=0,s=0,o=0,a=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),o=Math.round((i.score??0)/i.games)),i.human_games>0&&(s=Math.round(100*(i.human_wins??0)/i.human_games),a=Math.round((i.human_score??0)/i.human_games))),Ud("div",{id:n.attrs.id},[Ud(".toggler",{id:"own-toggler",title:_p("stats_choice"),onclick:t=>{e=3-e,t.preventDefault()}},[Ud(".option.small"+(1===e?".selected":""),{id:"opt1"},xp("user")),Ud(".option.small"+(2===e?".selected":""),{id:"opt2"},xp("cog"))]),1===e?Ud("div",{id:"own-stats-human",className:"stats-box",style:{display:"inline-block"}},[Ud(".stats-fig",{title:_p("Elo-stig")},i?t(i.locale_elo?.human_elo,"crown"):""),Ud(".stats-fig.stats-games",{title:_p("Fjöldi viðureigna")},i?t(i.human_games,"th"):""),Ud(".stats-fig.stats-win-ratio",{title:_p("Vinningshlutfall")},t(s,"bookmark","%")),Ud(".stats-fig.stats-avg-score",{title:_p("Meðalstigafjöldi")},t(a,"dashboard"))]):"",2===e?Ud("div",{id:"own-stats-all",className:"stats-box",style:{display:"inline-block"}},[Ud(".stats-fig",{title:_p("Elo-stig")},i?t(i.locale_elo?.elo,"crown"):""),Ud(".stats-fig.stats-games",{title:_p("Fjöldi viðureigna")},i?t(i.games,"th"):""),Ud(".stats-fig.stats-win-ratio",{title:_p("Vinningshlutfall")},t(r,"bookmark","%")),Ud(".stats-fig.stats-avg-score",{title:_p("Meðalstigafjöldi")},t(o,"dashboard"))]):""])}}},Wf="/page#!";function Gf(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 o=document.querySelector(`#${t} > ul`);o&&(o.setAttribute("class","ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"),o.setAttribute("role","tablist"));const a=document.querySelectorAll(`#${t} > ul > li > a`),l=document.querySelectorAll(`#${t} > ul > li`),c=[],u=[];for(let e=0;e<a.length;e++){const t=a[e].getAttribute("href");if(!t)continue;c.push(t.slice(1)),a[e].onclick=t=>{Yf(r,e),t.preventDefault()},a[e].removeAttribute("href"),a[e].setAttribute("class","ui-tabs-anchor sp"),a[e].setAttribute("role","presentation"),u.push(l[e]),l[e].setAttribute("class","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),o=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):{};Ud.route.set(r,o),window.history&&window.history.pushState({},"",t),e.preventDefault()},i=n=>{t?.state?.netskraflUserId&&e.pushDialog("userprefs",{}),n.preventDefault()},o=e=>{Yf(r,2),e.preventDefault()},a=e=>{Yf(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)===Wf?t.onclick=e=>n(e,r):r&&"$$userprefs$$"===r?t.onclick=i:r&&"$$twoletter$$"===r?t.onclick=o:r&&"$$newbag$$"===r&&(t.onclick=a)}}n&&n(r),Kf(r)}function Kf(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 Yf(e,t){e.state.selected=t,Kf(e)}function Jf(e){var t=Ud.route.param("tab");void 0!==t&&Yf(e,parseInt(t,10)||0)}const Xf={oninit:e=>{e.state.sel=e.attrs.sel},view:e=>Ud(".toggler[id='elo-toggler']",{title:_p("elo_list_choice")},[Ud(".option.x-small",{className:"human"===e.state.sel?"selected":"",onclick:t=>{e.state.sel="human",e.attrs.onchange(e.state.sel),t.preventDefault()}},xp("user")),Ud(".option.x-small",{className:"all"===e.state.sel?"selected":"",onclick:t=>{e.state.sel="all",e.attrs.onchange(e.state.sel),t.preventDefault()}},xp("cog")),Ud(".option.x-small",{className:"manual"===e.state.sel?"selected":"",onclick:t=>{e.state.sel="manual",e.attrs.onchange(e.state.sel),t.preventDefault()}},xp("lightbulb"))])},Zf=e=>{const{spec:t,view:n}=e.attrs;return{view:e=>Ud("div",[Ud(".listitem.listheader",[Ud("span.list-ch",Rp("hand-right",{title:_p("Skora á")})),kp("span.list-rank","Röð"),Ud("span.list-rank-no-mobile",{title:_p("Röð í gær")},_p("1d")),Ud("span.list-rank-no-mobile",{title:_p("Röð fyrir viku")},_p("7d")),kp("span.list-nick-elo","Einkenni"),Ud("span.list-elo",{title:_p("Elo-stig")},_p("Elo")),Ud("span.list-elo-no-mobile",{title:_p("Elo-stig í gær")},_p("1d")),Ud("span.list-elo-no-mobile",{title:_p("Elo-stig fyrir viku")},_p("7d")),Ud("span.list-elo-no-mobile",{title:_p("Elo-stig fyrir mánuði")},_p("30d")),Ud("span.list-games",{title:_p("Fjöldi viðureigna")},xp("th")),Ud("span.list-ratio",{title:_p("Vinningshlutfall")},xp("bookmark")),Ud("span.list-avgpts",{title:_p("Meðalstigafjöldi")},xp("dashboard")),kp("span.list-info-hdr","Ferill"),Ud(Xf,{sel:t||"human",onchange:e=>{n.actions.withSpinner((()=>n.model.loadEloRatingList(e)))}})]),Ud(Qf,{id:e.attrs.id,sel:t,view:e.attrs.view})])}},Qf=e=>{const t=e.attrs.view,n=t.model,i=n.state;return{view:e=>{const r=n.eloRatingList||[];return Ud("div",{id:e.attrs.id},r.map((function(n,r){const s=0===n.userid.indexOf("robot-");function o(e,t){return 0===e||void 0!==t&&0===t?"--":e.toString()}let a=n.nick,l=Ud("span.list-ch",Lp());const c=i?.netskraflUserId??"";return n.userid===c||n.inactive||(l=Ud(ng,{view:t,item:n})),s&&(a=Ud("span",[xp("cog"),Lp(),a])),n.fairplay&&!s&&(a=Ud("span",[Ud("span.fairplay-btn",{title:_p("Skraflar án hjálpartækja")}),a])),Ud(".listitem",{key:(e.attrs.sel||"sel")+r,className:r%2==0?"oddlist":"evenlist"},[l,Ud("span.list-rank.bold",o(n.rank)),Ud("span.list-rank-no-mobile",o(n.rank_yesterday)),Ud("span.list-rank-no-mobile",o(n.rank_week_ago)),Ud("span.list-nick-elo",{title:n.fullname},a),Ud("span.list-elo.bold",n.elo),Ud("span.list-elo-no-mobile",o(n.elo_yesterday,n.games_yesterday)),Ud("span.list-elo-no-mobile",o(n.elo_week_ago,n.games_week_ago)),Ud("span.list-elo-no-mobile",o(n.elo_month_ago,n.games_month_ago)),Ud("span.list-games.bold",n.games>=1e5?`${Math.round(n.games/1e3)}K`:n.games),Ud("span.list-ratio",`${n.ratio}%`),Ud("span.list-avgpts",n.avgpts),n.userid===c?Lp():Ud(ig,{view:t,item:n})])})))}}},em=()=>({view:e=>{const{view:t,id:n}=e.attrs,{model:i}=t,r=i.userListCriteria?.query??"",s=i.userListCriteria?.spec??"",o=void 0===i.eloRatingSpec,a=r||"robots";if("elo"===a||o)return[Ud(Zf,{id:"elolist",view:t,spec:i.eloRatingSpec??null,key:"elopage"})];let l=[];void 0===i.userList||(null===i.userList||r!==a?t.actions.loadUsersByType(a,!0):l=i.userList);const c=0===l.length&&"search"===a&&""!==s,u="robots"===a;return[Ud(".listitem.listheader",[Ud("span.list-ch",Rp("hand-right",{title:_p("Skora á")})),Ud("span.list-fav",xp("star-empty",{title:_p("Uppáhald")})),kp("span.list-nick","Einkenni"),kp("span.list-fullname","Nafn og merki"),u?"":kp("span.list-human-elo[id='usr-list-elo']","Elo"),u?"":kp("span.list-info-hdr[id='usr-list-info']","Ferill")]),Ud("div",{id:n},l.map(((e,n)=>function(e,t,n){const i=0===t.userid.indexOf("robot-"),r=[];return t.ready&&!i&&(r.push(Ud("span.ready-btn",{title:_p("Álínis og tekur við áskorunum")})),r.push(Lp())),t.ready_timed&&(r.push(Ud("span.timed-btn",{title:_p("Til í viðureign með klukku")})),r.push(Lp())),t.fairplay&&(r.push(Ud("span.fairplay-btn",{title:_p("Skraflar án hjálpartækja")})),r.push(Lp())),r.push(t.fullname),Ud(".listitem"+(n%2==0?".oddlist":".evenlist"),[Ud(ng,{view:e,item:t}),i?Ud("span.list-fav",{style:{cursor:"default"}},xp("star-empty")):Ud("span.list-fav",{title:_p("Uppáhald"),onclick:n=>{e.actions.toggleFavorite(t.userid,t.fav),t.fav=!t.fav,n.preventDefault()}},xp(t.fav?"star":"star-empty")),i?Ud("a",{href:"",onclick:n=>{e.actions.startRobotGame(t.userid),n.preventDefault()}},[Ud("span.list-nick",[xp("cog"),Lp(),t.nick]),Ud("span.list-fullname-robot",r)]):[Ud("span.list-nick",t.nick),Ud("span.list-fullname",r),Ud("span.list-human-elo",t.human_elo)],Ud(ig,{view:e,item:t})])}(t,e,n)))),c?Ud("div",{id:"user-no-match",style:{display:"block"}},[xp("search")," ",Ud("span",{id:"search-prefix"},s),bp(" finnst ekki")]):void 0]}}),tm={view:e=>{const{view:t}=e.attrs,{model:n}=t,{numGames:i,numChallenges:r}=n;return[Ud(ug,{hidden:!0}),Ud("ul",[Ud("li",Ud("a[href='#tabs-1']",[xp("th"),Ud("span.tab-legend",bp("Viðureignir")),Ud("span",{id:"numgames",style:i?"display: inline-block":""},i)])),Ud("li",Ud("a[href='#tabs-2']",[xp("hand-right"),Ud("span.tab-legend",bp("Áskoranir")),Ud("span"+(n.oppReady?".opp-ready":""),{id:"numchallenges",style:r?"display: inline-block":""},r)])),Ud("li",Ud("a[href='#tabs-3']",[xp("user"),Ud("span.tab-legend",bp("Andstæðingar"))])),Ud("li.no-mobile-list",Ud("a[href='#tabs-4']",[xp("bookmark"),Ud("span.tab-legend",bp("Ferill"))]))])]}},nm={view:e=>{const{view:t}=e.attrs,{model:n}=t;return null===n.recentList&&n.loadRecentList(),[Ud(".listitem.listheader",[Ud("span.list-win",Rp("bookmark",{title:_p("Sigur")})),kp("span.list-ts-short","Viðureign lauk"),kp("span.list-nick","Andstæðingur"),kp("span.list-scorehdr","Úrslit"),Ud("span.list-elo-hdr",[Ud("span.glyphicon.glyphicon-user.elo-hdr-left",{title:_p("Mennskir andstæðingar")}),bp("Elo"),Ud("span.glyphicon.glyphicon-cog.elo-hdr-right",{title:_p("Allir andstæðingar")})]),kp("span.list-duration","Lengd"),Ud(og,{header:!0})]),Ud(Vf,{view:t,id:"recentlist",recentList:n.recentList||[]})]}},im={view:e=>{const{view:t,buttonId:n,icon:i,text:r}=e.attrs,{model:s}=t,o=s.userListCriteria?.query||"robots";return Ud("span",{className:n===o?"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()}},[xp(i,{style:{padding:0}}),Lp(),r])}},rm={view:e=>{const{view:t}=e.attrs,{model:n}=t,{ownStats:i}=n;return null===i&&n.loadOwnStats(),i?Ud(Hf,{view:t,id:"own-stats",ownStats:i}):null}},sm={view:e=>{const{view:t}=e.attrs,{model:n}=t,{ownStats:i}=n;return null===i&&n.loadOwnStats(),i?Ud(jf,{id:"own-best",ownStats:i,myself:!0}):null}},om={view:e=>{const{view:t}=e.attrs;return Ud("div",{id:"tabs-1"},[kp("p.no-mobile-block",[kp("strong","Viðureignir sem standa yfir"),"click_on_game",xp("flag")," þú átt leik"]),Ud(qf,{view:t,id:"gamelist"})])}},am={view:e=>{const{view:t}=e.attrs;return Ud("div",{id:"tabs-2"},[kp("p.no-mobile-block",[kp("strong","Skorað á þig"),"click_on_challenge",xp("thumbs-down",{style:{"margin-left":"6px","margin-right":"6px"}})," til að hafna henni"]),Ud(Uf,{view:t,showReceived:!0}),kp("p.no-mobile-block",[kp("strong","Þú skorar á aðra")," - smelltu á ",xp("hand-right",{style:{"margin-left":"6px","margin-right":"6px"}})," til að afturkalla áskorun"]),Ud(Uf,{view:t,showReceived:!1})])}},lm={view:e=>{const{view:t}=e.attrs;return Ud("div",{id:"tabs-3"},[Ud("div",{id:"initials"},[Ud(".user-cat[id='user-headings']",[Ud(im,{view:t,buttonId:"robots",icon:"cog",text:_p("Þjarkar")})," ",Ud(im,{view:t,buttonId:"fav",icon:"star",text:_p("Uppáhalds")})," ",Ud(im,{view:t,buttonId:"live",icon:"flash",text:_p("Álínis")})," ",Ud(im,{view:t,buttonId:"alike",icon:"resize-small",text:_p("Svipaðir")})," ",Ud(im,{view:t,buttonId:"elo",icon:"crown",text:_p("Topp 100")})]),Ud(Bf,{view:t})]),Ud(em,{view:t,id:"userlist"})])}},cm={view:e=>{const{view:t}=e.attrs;return Ud("div",{id:"tabs-4"},[Ud(rm,{view:t}),Ud(sm,{view:t}),kp("p.no-mobile-block",[kp("strong","Nýlegar viðureignir þínar"),"click_to_review"]),Ud(nm,{view:t})])}},um={view:e=>{const{view:t}=e.attrs;return Ud(".tabbed-page",Ud("div",{id:"main-tabs"},[Ud(tm,{view:t}),Ud("div.tab-scroll-area",[Ud(om,{view:t}),Ud(am,{view:t}),Ud(cm,{view:t}),Ud(lm,{view:t})])]))}},hm={view:e=>{const{view:t}=e.attrs;return[Ud(cg,{hidden:!0}),Ud(sg,{view:t}),Ud(lg),Ud(dg,{view:t}),Ud(pg,{view:t}),Ud("div",{oncreate:e=>{Gf(t,"main-tabs",void 0,!1,e)},onupdate:Jf},Ud(um,{view:t}))]}},dm=(e,t,n)=>{const i=e.model.game;return Ud(".movelist-container",Ud(".movelist.bestmoves",function(){const r=[];if(!i||!t||t>i.moves.length)return r;const s=i.moves[t-1],[o,a,l]=s[1];r.push(function(e,n,i){let r,s="wordmove";if(e.length>0)r=[Ud("i",n.split("?").join("")),` (${e})`];else if(s="othermove","PASS"===n)r=_p("Pass");else if(0===n.indexOf("EXCH")){const e=n.slice(5).length,t=_p(1===e?"letter":"letters");r=_p("exchanged",{numtiles:e.toString(),letters:t})}else"RSGN"===n?r=_p("Gaf viðureign"):"CHALL"===n?r=_p("Véfengdi lögn"):"RESP"===n?r=_p(i<0?"Óleyfileg lögn":"Röng véfenging"):"TIME"===n?r=_p("Umframtími"):"OVER"===n?(r=_p("Viðureign lokið"),s="gameover"):(s="othermove",r="--"===n?_p("Stafaleif: engin"):[_p("Stafaleif: "),Ud("i.upper",n)]);return Ud(".reviewhdr",[Ud("span.movenumber",`#${t}`),Ud("span",{class:s},r)])}(o,a,l));const c=n;for(let n=0;n<c.length;n++){const[i,[s,o,a]]=c[n],l=pm(e,t,n,c[n],{player:i,co:s,tiles:o,score:a});l&&r.push(l)}return r}()))},pm=(e,t,n,i,r)=>{const s=e.model;if(!s.game)return;const o=s.game,{player:a,co:l,tiles:c,score:u}=r;function h(e,i,r,l){const c=Fp(e);let u=c.col,h=c.row,d=!1;l&&(s.highlightedMove=n,o.placeTiles(t-1,!0));for(let e of i){if("?"===e){d=!0;continue}const t=jp(h,u);if(null===t)continue;const n=e;d&&(e="?");const i=o.tilescore(e);l&&(t in o.tiles?o.tiles[t].highlight=r:o.tiles[t]={player:a,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&&o.placeTiles(s.reviewMove))}const d=`(${l})`,p=c.split("?").join("");let g=0;const f=o.player;let m;a===f||null===f&&0===a?m="humangrad"+(0===a?"_left":"_right"):(m="autoplayergrad"+(0===a?"_left":"_right"),g=1);const v={title:"Smelltu til að fletta upp"};return"is_IS"===o.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===a?Ud(`.move.leftmove.${m}`,v,[Ud("span.score"+(i[2]?".highlight":""),u),Ud("span.wordmove",[Ud("i",p),Lp(),d])]):Ud(`.move.rightmove.${m}`,v,[Ud("span.wordmove",[d,Lp(),Ud("i",p)]),Ud("span.score"+(i[2]?".highlight":""),u)])},gm=(e,t)=>{const n=e.model,i=n.game,r=i?.moves.length??0,s=[];if(!(i?.uuid??""))return s;if(s.push(wg("navbtn",!t,(()=>{n.loadBestMoves(t?t-1:0)}),"Sjá fyrri leik",Ud("span",{id:"nav-prev-visible"},[xp("chevron-left")," Fyrri"]),!0,"navprev")),s.push(wg("navbtn",!t||t>=r,(()=>{n.loadBestMoves(t+1)}),"Sjá næsta leik",Ud("span",{id:"nav-next-visible"},["Næsti ",xp("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,o=s?s[1][2]:void 0;let a="";if(void 0===o||null===n.bestMoves||null===n.highlightedMove);else{const e=n.bestMoves[n.highlightedMove][1][2];a=(o-e).toString(),"-"!==a[0]&&"0"!==a[0]&&(a=`+${a}`),o>=e&&r.push("posdiff")}return Ud(r.join("."),{style:{visibility:"visible"}},a)})(e,t);void 0!==n&&s.push(n)}const o=((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,o,a]]=i;if(void 0===a||""===s&&"OVER"===o)return;const l=[".score"];return t>0&&(t%2===(n.player??0)?l.push("opponent"):l.push("localplayer")),Ud(l.join("."),a.toString())})(e,t);return void 0!==o&&s.push(o),s},fm=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 Ud(".rightcol",[function(){const i=e.fairplay,r=e.player;let s="",o="";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(),o=i.toString()}return Ud(".heading",[Ud(".logowrapper",Ud(ug)),Ud(".playerwrapper",[Ud(".leftplayer"+(1===r?".autoplayercolor":".humancolor"),[Ud(".player",Ud(xf,{view:t,side:"left"})),Ud(".scorewrapper",Ud(".scoreleft",s))]),Ud(".rightplayer"+(1===r?".humancolor":".autoplayercolor"),[Ud(".player",Ud(xf,{view:t,side:"right"})),Ud(".scorewrapper",Ud(".scoreright",o))]),Ud(".fairplay",{style:{visibility:i?"visible":"hidden"}},Ud("span.fairplay-btn.large",{title:_p("Skraflað án hjálpartækja")}))])])}(),Ud(".right-area",dm(t,n,i))])}(i,r,s)),e.push(Ud(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"),Ud(".gamestats",{style:{visibility:"visible"}},[Ud("div",{style:{position:"relative",width:"100%"}},[Ud(".player.left",{class:i,style:{width:"50%"}},Ud(".robot-btn.left",t.autoplayer[0]?[xp("cog"),Lp(),t.nickname[0]]:t.nickname[0])),Ud(".player.right",{class:r,style:{width:"50%","text-align":"right"}},Ud(".robot-btn.right",t.autoplayer[1]?[xp("cog"),Lp(),t.nickname[1]]:t.nickname[1]))]),Ud("div",{id:"gamestarted"},[Ud("p",["Viðureignin hófst ",Ud("span",n("gamestart")),Ud("br"),"og henni lauk ",Ud("span",n("gameend"))]),t.manual?Ud("p","Leikið var í keppnisham"):""]),Ud(".statscol",{style:{clear:"left"}},[Ud("p",["Fjöldi leikja: ",Ud("span",n("moves0"))]),Ud("p",["Fjöldi bingóa: ",Ud("span",n("bingoes0"))," (bónus ",Ud("span",n("bingopoints0",0,t.stats?50*t.stats.bingoes0:0))," stig)"]),Ud("p",["Stafir lagðir niður: ",Ud("span",n("tiles0"))," (þar af ",Ud("span",n("blanks0"))," auðir)"]),Ud("p",["Meðalstig stafa (án auðra): ",Ud("span",n("average0",2))]),Ud("p",["Samanlögð stafastig: ",Ud("span",n("letterscore0"))]),Ud("p",["Margföldun stafastiga: ",Ud("span",n("multiple0",2))]),Ud("p",["Stig án stafaleifar í lok: ",Ud("span",n("cleantotal0"))]),Ud("p",["Meðalstig hvers leiks: ",Ud("span",n("avgmove0",2))]),t.manual?Ud("p",["Rangar véfengingar andstæðings x 10: ",Ud("span",n("wrongchall0"))]):"",Ud("p",["Stafaleif og frádráttur í lok: ",Ud("span",n("remaining0"))]),Ud("p",["Umframtími: ",Ud("span",n("overtime0"))]),Ud("p",["Stig: ",Ud("span",n("total0",0,t.stats?t.stats.scores[0]:0))," (",Ud("span",n("ratio0",1)),"%)"])]),Ud(".statscol",[Ud("p",["Fjöldi leikja: ",Ud("span",n("moves1"))]),Ud("p",["Fjöldi bingóa: ",Ud("span",n("bingoes1"))," (bónus ",Ud("span",n("bingopoints0",0,t.stats?50*t.stats.bingoes1:0))," stig)"]),Ud("p",["Stafir lagðir niður: ",Ud("span",n("tiles1"))," (þar af ",Ud("span",n("blanks1"))," auðir)"]),Ud("p",["Meðalstig stafa (án auðra): ",Ud("span",n("average1",2))]),Ud("p",["Samanlögð stafastig: ",Ud("span",n("letterscore1"))]),Ud("p",["Margföldun stafastiga: ",Ud("span",n("multiple1",2))]),Ud("p",["Stig án stafaleifar í lok: ",Ud("span",n("cleantotal1"))]),Ud("p",["Meðalstig hvers leiks: ",Ud("span",n("avgmove1",2))]),t.manual?Ud("p",["Rangar véfengingar andstæðings x 10: ",Ud("span",n("wrongchall1"))]):"",Ud("p",["Stafaleif og frádráttur í lok: ",Ud("span",n("remaining1"))]),Ud("p",["Umframtími: ",Ud("span",n("overtime1"))]),Ud("p",["Stig: ",Ud("span",n("total1",0,t.stats?t.stats.scores[1]:0))," (",Ud("span",n("ratio1",1)),"%)"])]),Ud(".closebtn",{id:"review-close",onclick:e=>{setTimeout((()=>{Ud.route.set(`/review/${t.uuid}`,{move:1})})),e.preventDefault()},onmouseover:Ep,onmouseout:Pp},[xp("play")," Rekja"])])})(t);n&&e.push(n)}}return Ud("div",[Ud(".game-container",e),Ud(cg),Ud(lg)])}}},mm={view:e=>{const{view:t}=e.attrs,n=t.model.game;let i=[];if(n){i=[Ud(Og,{view:t,game:n,review:!0}),Ud(Ng,{view:t,game:n,review:!0})];const r=e.attrs.moveIndex;null!==r&&(i=i.concat(gm(t,r)))}return Ud(".board-area",i)}},vm=(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}))},ym=(e,t,n)=>{t.versusAll!==n&&(t.versusAll=n,t.loadingRecentList=!1,vm(e,t))},wm={oninit:e=>{const{attrs:t,state:n}=e;n.stats={},n.recentList=[],n.versusAll=!0,n.loadingRecentList=!1,n.loadingStats=!1,vm(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:o}=n;return Ud(".modal-dialog",{id:"usr-info-dialog",style:{visibility:"visible"}},Ud(".ui-widget.ui-widget-content.ui-corner-all",{id:"usr-info-form"},[Ud(".usr-info-hdr",[Ud("h1.usr-info-icon",[e.state.stats.friend?xp("coffee-cup",{title:_p("Áskrifandi")}):xp("user"),Lp()]),Ud("h1[id='usr-info-nick']",e.attrs.nick),Ud("span.vbar","|"),Ud("h2[id='usr-info-fullname']",e.attrs.fullname),Ud(".usr-info-fav",{title:_p("Uppáhald"),onclick:t=>{t.preventDefault(),i.actions.toggleFavorite(e.attrs.userid,r.favorite??!1),r.favorite=!r.favorite}},r.favorite?xp("star"):xp("star-empty"))]),Ud("p",[Ud("strong",bp("Nýjustu viðureignir")),Lp(),Ud("span.versus-cat",[Ud("span",{class:o?"shown":"",onclick:()=>{ym(t,n,!0)}},bp(" gegn öllum ")),Ud("span",{class:o?"":"shown",onclick:()=>{ym(t,n,!1)}},bp(" gegn þér "))])]),Ud(".listitem.listheader",[Ud("span.list-win",Rp("bookmark",{title:_p("Sigur")})),kp("span.list-ts-short","Viðureign lauk"),kp("span.list-nick","Andstæðingur"),kp("span.list-scorehdr","Úrslit"),Ud("span.list-elo-hdr",[Ud("span.glyphicon.glyphicon-user.elo-hdr-left",{title:_p("Mennskir andstæðingar")}),"Elo",Ud("span.glyphicon.glyphicon-cog.elo-hdr-right",{title:_p("Allir andstæðingar")})]),kp("span.list-duration","Lengd"),Ud(og,{header:!0})]),Ud(Vf,{view:i,id:"usr-recent",recentList:s}),Ud(Hf,{view:i,id:"usr-stats",ownStats:r}),Ud(jf,{id:"usr-best",ownStats:r,myself:!1}),Ud(tg,{id:"usr-info-close",title:_p("Loka"),onclick:e=>{i.popDialog(),e.preventDefault()}},xp("ok"))]))}},bm=e=>{const{view:t}=e.attrs,{model:n}=t;function i(e){const t=(n.userErrors||{})[e]||"";return t?Ud(".errinput",[xp("arrow-up"),Lp(),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=Dp("nickname"),e.full_name=Dp("full_name"),e.audio=r("audio"),e.fanfare=r("fanfare"),e.beginner=r("beginner"),e.fairplay=r("fairplay"),n.saveUser((()=>{t.popDialog()})))}function o(e){e.dom.querySelector("#nickname").focus()}function a(e,t,n,i,r){return Ud(tg,{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 Ud(".modal-dialog",{key:"userprefs",id:"user-dialog",oncreate:o},Ud(".ui-widget.ui-widget-content.ui-corner-all",{id:"user-form"},[Ud(".loginhdr",[xp("address-book"),` ${_p("player_info")}`]),Ud("div",Ud("form",{action:"",id:"frm1",method:"post",name:"frm1"},[Ud(".dialog-spacer",[Ud("span.caption",bp("Einkenni:")),Ud(eg,{initialValue:e.nickname||"",class:"username",maxlength:15,id:"nickname"}),Lp(),Ud("span.asterisk","*")]),Ud(".explain",bp("Verður að vera útfyllt")),i("nickname"),Ud(".dialog-spacer",[Ud("span.caption",bp("Fullt nafn:")),Ud(eg,{initialValue:e.full_name||"",class:"fullname",maxlength:32,id:"full_name",autocomplete:"name"})]),Ud(".explain",bp("Valfrjálst - sýnt í notendalistum Netskrafls")),i("full_name"),Ud(".dialog-spacer",[Ud("span.caption.sub",bp("Hljóðmerki:")),Ud(gg,{view:t,state:e.audio,tabindex:4}),Ud("span.subcaption",bp("Lúðraþytur eftir sigur:")),Ud(fg,{view:t,state:e.fanfare,tabindex:5})]),Ud(".explain",bp("explain_sound")),Ud(".dialog-spacer",[Ud("span.caption.sub",bp("Sýna reitagildi:")),Ud(mg,{view:t,state:e.beginner,tabindex:6}),kp(".subexplain",["Stillir hvort ",kp("strong","minnismiði")," um margföldunargildi reita er sýndur við borðið"])]),Ud(".dialog-spacer",[Ud("span.caption.sub",bp("Án hjálpartækja:")),Ud(vg,{view:t,state:e.fairplay,tabindex:7}),kp(".subexplain",["no_helpers",kp("strong","án stafrænna hjálpartækja")," af nokkru tagi"])])])),a("user-ok",_p("Vista"),s,xp("ok"),8),a("user-cancel",_p("Hætta við"),(e=>{t.popDialog(),e.preventDefault()}),xp("remove"),9),e.friend?a("user-unfriend",_p("Þú ert áskrifandi!"),(e=>{e.preventDefault()}),[xp("coffee-cup"),_p("Þú ert áskrifandi!")],10):a("user-friend",_p("Gerast áskrifandi"),(e=>{e.preventDefault(),fh("click_friend",{userid:r.netskraflUserId,locale:r.locale}),window.location.href=r.subscriptionUrl}),[xp("coffee-cup"),Lp(),Lp(),_p("Gerast áskrifandi")],11)]))}}},_m={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:o}=i,a=o.state,l=o.state?.netskraflUserId??"";if(!l||!r)return;n.firebasePath=`user/${l}/wait/${r}`;(async()=>{try{if(s&&a){const e=await np(a,{method:"POST",url:"/initwait",body:{opp:r,key:s}});e?.online&&e.waiting&&(n.oppOnline=!0)}}catch(e){}})(),ph(n.firebasePath,(e=>{!0!==e&&e.game&&(n.pointOfNoReturn=!0,gh(n.firebasePath),Ud.route.set(`/game/${e.game}`))}))},view:e=>{const{attrs:t,state:n}=e,{view:i,oppId:r,duration:s,challengeKey:o,oppNick:a,oppName:l}=t,{model:c}=i,u=c.state,h=c.state?.netskraflUserId??"";if(!u)return null;return Ud(".modal-dialog",{id:"wait-dialog",style:{visibility:"visible"}},Ud(".ui-widget.ui-widget-content.ui-corner-all",{id:"wait-form"},[Ud(".chall-hdr",Ud("table",Ud("tbody",Ud("tr",[Ud("td",Ud("h1.chall-icon",xp("time"))),Ud("td.l-border",[Ud(rg,{id:"chall-online",userId:r,online:n.oppOnline,state:u}),Ud("h1",a),Ud("h2",l)])])))),Ud(".wait-explain",[kp("p",["Þú ert reiðubúin(n) að taka áskorun um viðureign með klukku,"]),Ud("p",[Ud("strong",["2 x ",s.toString(),_p(" mínútur.")])]),kp("p",["Beðið er eftir að áskorandinn ",Ud("strong",a)," sé ",n.oppOnline?"":kp("span#chall-is-online","álínis og "),"til í tuskið."]),kp("p","Leikur hefst um leið og áskorandinn bregst við. Handahóf ræður hvor byrjar."),kp("p","Ef þér leiðist biðin geturðu hætt við og reynt aftur síðar.")]),Ud(tg,{id:"wait-cancel",title:_p("Hætta við"),onclick:e=>{n.pointOfNoReturn||(n.firebasePath&&gh(n.firebasePath),(async()=>{if(u)try{np(u,{method:"POST",url:"/cancelwait",body:{user:h,opp:r,key:o}})}catch(e){}})(),i.popDialog()),e.preventDefault()}},xp("remove"))]))}},km={oninit:async e=>{const{attrs:t,state:n}=e,{view:i,oppId:r,challengeKey:s}=t,o=i.model.state;if(o){n.oppReady=!0;try{const e=await np(o,{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 Ud(".modal-dialog",{id:"accept-dialog",style:{visibility:"visible"}},Ud(".ui-widget.ui-widget-content.ui-corner-all",{id:"accept-form"},[Ud(".chall-hdr",Ud("table",Ud("tbody",Ud("tr",[Ud("td",Ud("h1.chall-icon",xp("time"))),Ud("td.l-border",Ud("h1",r))])))),Ud("div",{style:{"text-align":"center","padding-top":"32px"}},[Ud("p",kp("strong","Viðureign með klukku")),kp("p",n.oppReady?"Athuga hvort andstæðingur er reiðubúinn...":["Andstæðingurinn ",Ud("strong",r)," er ekki reiðubúinn"])]),Ud(tg,{id:"accept-cancel",title:_p("Reyna síðar"),onclick:e=>{i.popDialog(),e.preventDefault()}},xp("remove"))]))}};class Cm{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(Ud(hm,{key:"main",view:this}));break;case"game":n.push(Ud(Of,{key:"game",view:this}));break;case"review":n.push(Ud(fm,{key:"review",view:this}));break;case"help":n.push(this.vwHelp(parseInt(Ud.route.param("tab")||"",10),parseInt(Ud.route.param("faq")||"",10)));break;default:return[Ud("div",{key:"error"},bp("Þessi vefslóð er ekki rétt"))]}for(const e of this.dialogStack){const t=Cm.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(Ud(Qp,{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}),Ud.redraw()}popDialog(){this.dialogStack.length>0&&(this.dialogStack.pop(),Ud.redraw())}popAllDialogs(){this.dialogStack.length>0&&(this.dialogStack=[],Ud.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(Op):this.setSelectedTab("board"),this.popAllDialogs()}notifyChatMessage(){Ud.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(){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=Fp(e),r=jp(Math.max(0,i.row-3),Math.max(0,i.col-3)),s=document.getElementById(`sq_${r}`),o=s?.getBoundingClientRect(),a=t.getBoundingClientRect();if(o&&a){const e=t.clientWidth,i=t.clientHeight,r=n.offsetWidth*op-e,s=n.offsetHeight*op-i,l=Math.min(o.left-a.left,r),c=Math.min(o.top-a.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",{})}showAcceptDialog(e,t,n){this.pushDialog("accept",{oppId:e,oppNick:t,challengeKey:n})}setSelectedTab(e){return this.selectedTab!==e&&(this.selectedTab=e,"chat"!==e&&zp(),!0)}vwTabsFromHtml(e,t,n,i){return e?Ud("div.help-tabs",{oncreate:e=>{Gf(this,t,i,!0,e)},oninit:e=>{e.state.selected=n||1}},Ud.trust(e)):""}vwHelp(e,t){const n=this.model;return Ud.fragment({key:"help"},[Ud(cg),Ud(sg,{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)||(Yf(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?Ud(bm,{key:"userprefs",view:this}):Ud.fragment({key:"userprefs-empty"},[])}vwWait(e){return Ud(_m,{key:`wait-${e.challengeKey}`,view:this,oppId:e.oppId,oppNick:e.oppNick,oppName:e.oppName,duration:e.duration,challengeKey:e.challengeKey})}vwAccept(e){return Ud(km,{key:`accept-${e.challengeKey}`,view:this,oppId:e.oppId,oppNick:e.oppNick,challengeKey:e.challengeKey})}vwDialogs(){return Ud(Sf,{view:this})}}Cm.dialogViews={userprefs:e=>e.vwUserPrefs(),userinfo:(e,t)=>Ud(wm,{key:`userinfodialog-${t.userid}`,view:e,userid:t.userid,nick:t.nick,fullname:t.fullname}),challenge:(e,t)=>Ud(kf,{key:"challenge",view:e,item:t}),friend:e=>Ud(Cf,{key:"friend",view:e}),wait:(e,t)=>e.vwWait(t),accept:(e,t)=>e.vwAccept(t)};let Sm=null;const Tm=(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=bf(),i=new _f(n,e),r=new qp(i),s=new Cm(r);Sm&&Sm.cleanup(),Sm=r;const o=new URLSearchParams(window.location.search).get("date"),a=(new Date).toISOString().split("T")[0],l=o||a,c=/^\d{4}-\d{2}-\d{2}$/.test(l)?l:a,u=e.locale||"is_IS";Ud.mount(t,{view:()=>Ud(nf,{view:s,date:c,locale:u})}),$p((e=>{const t=i.riddle;t&&sf(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"))},Im=t.memo((({state:i,tokenExpired:r})=>{const s=t.useRef(null),a=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=o({...i,tokenExpired:r});return Tm(t,e).then((()=>{a.current=!0})).catch((e=>{console.error("Failed to mount Gáta Dagsins UI:",e)})),()=>{a.current&&(!function(e){Sm&&(Sm.cleanup(),Sm=null),Ud.mount(e,null),e.innerHTML="",document.body.querySelectorAll("#netskrafl-background, #gatadagsins-background").forEach((e=>e.remove()))}(e),a.current=!1)}}),[l]),e("div",{className:"gatadagsins",children:e("div",{className:"netskrafl-container",id:"gatadagsins-container",ref:s})})}));let Em=null;const Pm=(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=bf(),i=new _f(n,e),r=new qp(i),s=new Cm(r);Em&&Em.cleanup(),Em=r,$p((e=>{const t=i.game;t&&sf(t,s,e)}));const o=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);Ud.route(t,n.defaultRoute,o)}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"))},xm=t.memo((({state:i,tokenExpired:r})=>{const s=t.useRef(null),a=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=o({...i,tokenExpired:r});return Pm(t,e).then((()=>{a.current=!0})).catch((e=>{console.error("Failed to mount Netskrafl UI:",e)})),()=>{a.current&&(!function(e){Em&&(Em.cleanup(),Em=null),Ud.mount(e,null),e.innerHTML="",document.body.querySelectorAll("#netskrafl-background, #gatadagsins-background").forEach((e=>{e.remove()}))}(e),a.current=!1)}}),[l]),e("div",{className:"netskrafl",children:e("div",{className:"netskrafl-container",id:"netskrafl-container",ref:s})})}));export{Im as GataDagsins,xm as Netskrafl};
3027
+ */(n,...e)}return n}aa.prototype.simpleListen=function(e,t){this.sendRequest("q",{p:e},t)},aa.prototype.echo=function(e,t){this.sendRequest("echo",{d:e},t)},function(e){!function(e){zs=e}(bt),ft(new oe("database",((e,{instanceIdentifier:t})=>oh(e.getProvider("app").getImmediate(),e.getProvider("auth-internal"),e.getProvider("app-check-internal"),t)),"PUBLIC").setMultipleInstances(!0)),Ct(Fs,Us,e),Ct(Fs,Us,"esm2020")}();let ch=[];function uh(e){const t=[...ch];ch=[],t.forEach((e=>{e()})),e.onFirebaseReady?.()}function hh(e){try{const{projectId:t,firebaseApiKey:n,databaseUrl:i,firebaseSenderId:r,firebaseAppId:s,measurementId:o}=e;if(th=_t({projectId:t,apiKey:n,authDomain:`${t}.firebaseapp.com`,databaseURL:i,storageBucket:`${t}.firebasestorage.app`,messagingSenderId:r,appId:s,measurementId:o},t),!th)return console.error("Failed to initialize Firebase"),!1}catch(e){return console.error("Failed to initialize Firebase",e),!1}return!0}async function dh(e,t,n){if(!th&&!hh(e))return;const{netskraflUserId:i,locale:r,projectId:s,loginMethod:o}=e;nh=Ms(th),nh?function(e,t,n,i){se(e).onAuthStateChanged(t,n,i)}(nh,(t=>{null!==t&&(e.newUser&&fh("sign_up",{locale:r,method:o,userid:i}),fh("login",{locale:r,method:o,userid:i}))})):console.error("Failed to initialize Firebase Auth"),await Tr(nh,t),ih=lh(th),ih?uh(e):console.error("Failed to initialize Firebase Database"),rh=Wn(th),rh||console.error("Failed to initialize Firebase Analytics"),function(e,t,n){if(!ih)return;const i=Ku(ih,".info/connected"),r="netskrafl"===e?`connection/${t}`:`connection/${n}/${t}`,s=function(e,t){e=se(e),au("push",e._path),iu("push",t,e._path,!0);const n=vu(e._repo),i=zu(n),r=Yu(e,i),s=Yu(e,i);let o;return o=Promise.resolve(s),r.then=o.then.bind(o),r.catch=o.then.bind(o,void 0),r}(Ku(ih,r));Qu(i,(e=>{e.val()?(function(e){return e=se(e),new Bu(e._repo,e._path)}(s).remove(),Ju(s,!0)):function(e){au("remove",e._path),Ju(e,null)}(s)}))}(s,i,r)}function ph(e,t){if(!ih)return void ch.push((()=>ph(e,t)));let n=0;Qu(Ku(ih,e),(e=>{n++;const i=e.val();i&&t(i,1===n)}))}function gh(e){if(!ih)return;const t=Ku(ih,e);var n;Tu((n=t)._repo,n,null)}function fh(e,t){rh&&Kn(rh,e,t)}function mh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var vh,yh,wh,bh,_h,kh,Ch,Sh,Th,Ih,Eh,Ph,xh,Rh,Lh,Nh,Dh,Ah,Mh,Oh,jh,Fh,Uh,zh,$h,qh,Vh,Bh,Hh,Wh,Gh,Kh,Yh,Jh,Zh,Xh,Qh,ed,td,nd,id,rd,sd,od,ad,ld,cd,ud,hd,dd,pd,gd,fd,md;function vd(){if(yh)return vh;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 yh=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},vh=e}function yd(){if(bh)return wh;bh=1;var e=vd();return wh=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 wd(){return kh?_h:(kh=1,_h={}.hasOwnProperty)}function bd(){return Sh?Ch:(Sh=1,Ch={})}function _d(){if(Ih)return Th;Ih=1;var e=bd();return Th=new Map([[e,!0]])}function kd(){if(Ph)return Eh;Ph=1;var e=vd(),t=yd(),n=wd(),i=bd(),r=_d(),s=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,o=Object.create(null);function a(e){for(var t,a,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,("value"===(a=t[4])||"checked"===a||"selectedIndex"===a||"selected"===a)&&(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,o[e]={tag:l,attrs:u,is:u.is}}return Eh=function(r,s,...l){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,l);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}(o[r]||a(r),c):(null==c.attrs&&(c.attrs={}),c.tag=r,c)},Eh}function Cd(){if(Ah)return Dh;Ah=1;var e=kd();return e.trust=function(){if(Rh)return xh;Rh=1;var e=vd();return xh=function(t){return null==t&&(t=""),e("<",void 0,void 0,t,void 0,void 0)}}(),e.fragment=function(){if(Nh)return Lh;Nh=1;var e=vd(),t=yd();return Lh=function(n,...i){var r=t(n,i);return null==r.attrs&&(r.attrs={}),r.tag="[",r.children=e.normalizeChildren(r.children),r},Lh}(),Dh=e}function Sd(){return Oh?Mh:(Oh=1,Mh=new WeakMap)}function Td(){if(Fh)return jh;Fh=1;var e=Sd();return jh=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)},jh}function Id(){if(zh)return Uh;zh=1;var e=vd(),t=Sd(),n=Td(),i=_d();return Uh=function(){var r,s,o={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"};function a(e){return e.ownerDocument}function l(e){return e.attrs&&e.attrs.xmlns||o[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 a(e).activeElement}catch(e){return null}}function d(e,t,n,i,r,s,o){for(var a=n;a<i;a++){var l=t[a];null!=l&&p(e,l,r,o,s)}}function p(t,n,i,r,s){var o=n.tag;if("string"==typeof o)switch(n.state={},null!=n.attrs&&F(n.attrs,n,i),o){case"#":!function(e,t,n){t.dom=a(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=a(e).createDocumentFragment();if(null!=t.children){var o=t.children;d(s,o,0,o.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,o=t.attrs,c=t.is;i=l(t)||i;var u=i?c?a(e).createElementNS(i,s,{is:c}):a(e).createElementNS(i,s):c?a(e).createElement(s,{is:c}):a(e).createElement(s);t.dom=u,null!=o&&function(e,t,n){for(var i in t)L(e,i,null,t[i],n)}(t,o,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!=o&&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,o)}}(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=a(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 o,l=a(e).createDocumentFragment();o=s.firstChild;)l.appendChild(o);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 o=null!=t[0]&&null!=t[0].key,a=null!=n[0]&&null!=n[0].key,l=0,c=0;if(!o)for(;c<t.length&&null==t[c];)c++;if(!a)for(;l<n.length&&null==n[l];)l++;if(o!==a)T(e,t,c,t.length),d(e,n,l,n.length,i,r,s);else if(a){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 o=t[t.length-1];if(e[o]<e[r])b[r]=o,t.push(r);else{for(n=0,i=t.length-1;n<i;){var a=(n>>>1)+(i>>>1)+(n&i&1);e[t[a]]<e[r]?n=a+1:i=a}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,o,a){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&&U(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,a,o);break;case"[":!function(e,t,n,i,r,s){m(e,t.children,n.children,i,r,s);var o=0,a=n.children;if(n.dom=null,null!=a)for(var l=0;l<a.length;l++){var c=a[l];null!=c&&null!=c.dom&&(null==n.dom&&(n.dom=c.dom),o+=c.domSize||1)}n.domSize=o}(t,n,r,s,o,a);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 o 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[o])||null!=n&&null!=n[o]||N(e,o,s,r);if(null!=n)for(var o in n)L(e,o,t&&t[o],n[o],r)}(t,e.attrs,t.attrs,r);S(t)||m(s,e.children,t.children,n,null,r)}(n,r,s,a)}else!function(t,n,i,r,s,o){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");U(i.state,i,r),null!=i.attrs&&U(i.attrs,i,r);null!=i.instance?(null==n.instance?p(t,i.instance,r,o,s):v(t,n.instance,i.instance,r,s,o),i.dom=i.instance.dom,i.domSize=i.instance.domSize):(null!=n.instance&&P(t,n.instance),i.domSize=0)}(t,n,r,s,o,a)}else P(t,n),p(t,r,s,a,o)}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=a(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,o){var a=i.state,l=u.call(r.onbeforeremove,i);if(null!=l){var h=s;for(var d of n(i))t.set(d,h);o.v++,Promise.resolve(l).finally((function(){c(i,a),E(e,i,o)}))}}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 U(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 o=r,a=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=o,w=a}}},Uh}function Ed(){return qh?$h:(qh=1,$h=Id()())}function Pd(){if(Wh)return Hh;Wh=1;var e=Ed();return Hh=function(){if(Bh)return Vh;Bh=1;var e=vd();return Vh=function(t,n,i){var r=[],s=!1,o=-1;function a(){for(o=0;o<r.length;o+=2)try{t(r[o],e(r[o+1]),l)}catch(e){i.error(e)}o=-1}function l(){s||(s=!0,n((function(){s=!1,a()})))}return l.sync=a,{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<=o&&(o-=2),t(n,[])),null!=i&&(r.push(n,i),t(n,e(i),l))},redraw:l}},Vh}()(e,"undefined"!=typeof requestAnimationFrame?requestAnimationFrame:null,"undefined"!=typeof console?console:null),Hh}function xd(){return Kh?Gh:(Kh=1,Gh=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 Rd(){if(Jh)return Yh;Jh=1;var e=xd();return Yh=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,o=i<0?s:i,a=t.slice(0,o),l={};Object.assign(l,n);var c=a.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},Yh}function Ld(){if(Xh)return Zh;Xh=1;var e=Rd(),t=wd();return Zh=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(o,a){"string"!=typeof o?(a=o,o=o.url):null==a&&(a={});var l=function(i,r){return new Promise((function(o,a){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);o(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,a(n)};0===p.status?setTimeout((function(){f||c()})):c()}}catch(e){a(e)}},p.ontimeout=function(e){f=!0;var t=new Error("Request timed out");t.code=e.target.status,a(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))}))}(o,a);if(!0===a.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)}}},Zh}function Nd(){if(nd)return td;nd=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 td=function(t){return String(t).replace(e,decodeURIComponent)}}function Dd(){if(rd)return id;rd=1;var e=Nd();return id=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 o=n[s].split("="),a=e(o[0]),l=2===o.length?e(o[1]):"";"true"===l?l=!0:"false"===l&&(l=!1);var c=a.split(/\]\[?|\[/),u=r;a.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[a=c.slice(0,h).join()]&&(i[a]=Array.isArray(u)?u.length:0),d=i[a]++;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 Ad(){if(od)return sd;od=1;var e=Dd();return sd=function(t){var n=t.indexOf("?"),i=t.indexOf("#"),r=i<0?t.length:i,s=n<0?r:n,o=t.slice(0,s).replace(/\/{2,}/g,"/");return o?"/"!==o[0]&&(o="/"+o):o="/",{path:o,params:n<0?{}:e(t.slice(n+1,r))}}}function Md(){if(ld)return ad;ld=1;var e=Ad();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 o=s.exec(e.path);if(null==o)return!1;for(t=0;t<r.length;t++)e.params[r[t].k]=r[t].r?o[t+1]:decodeURIComponent(o[t+1]);return!0}},ad}function Od(){if(ud)return cd;ud=1;var e=wd(),t=/^(?:key|oninit|oncreate|onbeforeupdate|onupdate|onbeforeremove|onremove)$/;return cd=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 jd(){if(gd)return pd;gd=1;var e=Pd();return pd=function(){if(dd)return hd;dd=1;var e=vd(),t=kd(),n=Nd(),i=Rd(),r=Ad(),s=Md(),o=Od();return hd=function(a,l){var c,u,h,d,p,g,f,m,v=Promise.resolve(),y=!1,w=!1,b=!1,_={onremove:function(){w=b=!1,a.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=a.location.hash;"#"!==T.prefix[0]&&(e=a.location.search+e,"?"!==T.prefix[0]&&"/"!==(e=a.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,a.history.state),function e(n){for(;n<u.length;n++)if(u[n].check(i)){var r=u[n].component,o=u[n].route,a=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(a)):r.onmatch?v.then((function(){return r.onmatch(i.params,t,o)})).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,a.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?a.history.replaceState(r,s,T.prefix+e):a.history.pushState(r,s,T.prefix+e)}else a.location.href=T.prefix+e},T.get=function(){return f},T.prefix="#!",T.Link={view:function(e){var n,r,s,a=t(e.attrs.selector||"a",o(e.attrs,["options","params","selector","onclick"]),e.children);return(a.attrs.disabled=Boolean(a.attrs.disabled))?(a.attrs.href=null,a.attrs["aria-disabled"]="true"):(n=e.attrs.options,r=e.attrs.onclick,s=i(a.attrs.href,e.attrs.params),a.attrs.href=T.prefix+s,a.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))}),a}},T.param=function(e){return g&&null!=e?g[e]:g},T},hd}()("undefined"!=typeof window?window:null,e),pd}var Fd=function(){if(md)return fd;md=1;var e=Cd(),t=Pd(),n=function(){if(ed)return Qh;ed=1;var e=Pd();return Qh=Ld()("undefined"!=typeof window?window:null,e.redraw)}(),i=jd(),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=Ed(),r.redraw=t.redraw,r.request=n.request,r.parseQueryString=Dd(),r.buildQueryString=xd(),r.parsePathname=Ad(),r.buildPathname=Rd(),r.vnode=vd(),r.censor=Od(),r.domFor=Td(),fd=r}(),Ud=mh(Fd);const zd=(e,t)=>`${e.serverUrl}${t}`,$d=async e=>{const{userEmail:t,userNick:n,userFullname:i,token:r}=e;return((e,t)=>Ud.request({withCredentials:!0,...t,url:zd(e,t.url)}))(e,{method:"POST",url:"/login_malstadur",body:{email:t,nickname:n,fullname:i,token:r}})},qd=12e4;let Vd=null,Bd=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=()=>{Bd=0,Wd=!1,Gd=0},Qd=()=>{Wd=!0,Gd=Date.now()+qd,Bd=0,console.error(`Circuit breaker opened. Login attempts blocked until ${new Date(Gd).toLocaleTimeString()}`)},ep=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(Vd)return void await Vd;const t=Date.now()-Hd;if(t<500&&Bd>0)throw console.warn(`Login attempt too soon (${t}ms since last attempt)`),new Yd("Please wait a moment before trying again.");let n=!0;for(;n&&Bd<3;){if(n=!1,Bd++,Hd=Date.now(),Bd>=2){const e=Zd(Bd-1);console.warn(`Login retry ${Bd}/3, waiting ${e}ms...`),await Jd(e)}Vd=$d(e);try{const t=await Vd;if("expired"===t.status){if(e.tokenExpired)try{e.tokenExpired(),n=!0,l();continue}catch(e){throw console.error("Token refresh failed:",e),l(),new Error(`Failed to refresh authentication token: ${e instanceof Error?e.message:String(e)}`)}throw l(),new Error("Authentication token has expired. Please log in again.")}if("success"!==t.status)throw l(),new Error(`Authentication failed: ${t.message||t.status}`);e.netskraflUserId=t.user_id||e.netskraflUserId,e.account=t.account||e.netskraflUserId,e.userNick=t.nickname||e.userNick,e.firebaseApiKey=t.firebase_api_key||e.firebaseApiKey,e.beginner=t.prefs?.beginner??!0,e.fairPlay=t.prefs?.fairplay??!1,e.ready=t.prefs?.ready??!0,e.readyTimed=t.prefs?.ready_timed??!0,e.audio=t.prefs?.audio??!1,e.fanfare=t.prefs?.fanfare??!1,e.hasPaid=t.prefs?.haspaid??!1,a({userEmail:e.userEmail,netskraflUserId:e.netskraflUserId,userNick:e.userNick,firebaseApiKey:e.firebaseApiKey,beginner:e.beginner,fairPlay:e.fairPlay,ready:e.ready,readyTimed:e.readyTimed,audio:e.audio,fanfare:e.fanfare}),Ud.redraw(),await dh(e,t.firebase_token),Xd()}catch(e){if(Bd>=3)throw Qd(),new Error(`Login failed after 3 attempts. Please wait ${Math.ceil(2)} minutes before trying again.`);if(!n)throw e}finally{Vd=null}}if(Bd>=3)throw Qd(),new Error("Maximum login attempts exceeded. Please try again later.")},tp=async(e,t,n=0)=>{n||function(e){if(nh||(th||hh(e),th&&(nh=Ms(th))),!nh||null===nh.currentUser)return!1;if(!ih&&th){if(ih=lh(th),!ih)return console.error("Failed to initialize Firebase Database"),!1;uh(e),rh||(rh=Wn(th),rh||console.error("Failed to initialize Firebase Analytics"))}return!0}(e)||await ep(e);try{return await Ud.request({withCredentials:!0,...t,url:zd(e,t.url),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),tp(e,t,n+1);throw i}},np=(e,t)=>tp(e,t),ip=(e,t)=>{const n=`${e.movesUrl}${t.url}`,i={"Content-Type":"application/json; charset=UTF-8",Authorization:`Bearer ${e.movesAccessKey}`,...t?.headers};return Ud.request({withCredentials:!1,method:"POST",...t,url:n,headers:i})},rp="ABCDEFGHIJKLMNO",sp=15,op=1.5,ap="2025-11-01",lp={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 cp{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 up=null;function hp(e,t){return up||(up=new cp(e,t)),up}var dp={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"},"[sentinel]":{}};let pp="is_IS",gp="is";const fp=/{\s*(\w+)\s*}/g;let mp={},vp=!1;function yp(e,t){for(const n in e)if(void 0!==e[n][t])return!0;return!1}function wp(e){!function(e,t){pp=e,gp=e.split("_")[0],yp(t,pp)||yp(t,gp)||(pp="en_US",gp="en"),mp={};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===mp[e]&&(mp[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,o=i.indexOf(`</${r.slice(1)}`,s);o<0?t=s:(n.index>0&&e.push(i.slice(t,t+n.index)),e.push(Ud(r.slice(1,-1),i.slice(s,o))),t=o+r.length+1)}t<i.length&&e.push(i.slice(t)),i=e}mp[e][n]=i}vp=!0}(function(){const e=new URLSearchParams(window.location.search).get("lang");return e?e.replace("-","_"):null}()||e,dp)}function bp(e,t={}){const n=mp[e];if(void 0===n)return vp?e:"";const i=n[pp]||n[gp]||e;return Object.keys(t).length?Cp(i,t):i}function _p(e,t={}){const n=mp[e];if(void 0===n)return vp?e:"";const i=n[pp]||n[gp]||e;return"string"!=typeof i?"":Object.keys(t).length?function(e,t){return e.replace(fp,((e,n)=>t[n]||e))}(i,t):i}function kp(e,t){return"string"==typeof t?Ud(e,bp(t)):Array.isArray(t)?Ud(e,t.map((e=>"string"==typeof e?bp(e):e))):Ud(e,t)}function Cp(e,t){return"string"==typeof e?e.replace(fp,((e,n)=>t[n]||e)):Array.isArray(e)?e.map((e=>Cp(e,t))):e}const Sp=new WeakMap;const Tp="/board?game=",Ip=["january","february","march","april","may","june","july","august","september","october","november","december"];function Ep(e){const t=e.currentTarget.classList;void 0===t||t.contains("disabled")||t.add("over"),e.redraw=!1}function Pp(e){const t=e.currentTarget.classList;void 0!==t&&t.remove("over"),e.redraw=!1}function xp(e,t,n){return Ud(`span.glyphicon.glyphicon-${e}${n?".grayed":""}`,t??{})}function Rp(e,t){return Ud(`span.glyphicon.glyphicon-${e}.grayed`,t??{})}function Lp(e){return Ud.trust("&nbsp;")}function Np(e){const t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};return String(e).replace(/[&<>"'/]/g,(e=>t[e]??""))}function Dp(e){return document.getElementById(e).value}function Ap(e,t){hp(e).play(t)}function Mp(e){e.slice(0,12)===Tp&&(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 Op(){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 jp(e,t,n=!1){return e<0||e>=sp||t<0||t>=sp?null:n?`${t+1}${rp[e]}`:`${rp[e]}${t+1}`}function Fp(e){var t=0,n=0,i=0,r=rp.indexOf(e[0]);return r>=0?(i=parseInt(e.slice(1),10)-1,t=1):(r=rp.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=_p(Ip[t.getUTCMonth()]);return _p("date_format",{day:n,month:i})}function zp(e=0){const t=()=>{const e=document.querySelector(".netskrafl-container");e?.focus()};e>0?setTimeout(t,e):setTimeout(t)}function $p(e,t=100){setTimeout((()=>{const t=document.querySelector(".netskrafl-container");t&&(t.tabIndex=0,t.addEventListener("keydown",e),t.focus())}),t)}class qp{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(Op),n.isMobile()&&n.setSelectedTab("board"),zp(100)}),e),null!==i.game&&void 0!==i.game&&fh("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(Op),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(),fh("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&&Ap(t,"new-msg")}}onFullScreen(e){const t=this.model.state;t&&!t.uiFullscreen&&(t.uiFullscreen=!0,e&&(e.resetScale(),e.notifyMediaChange()),Ud.redraw())}onMobileScreen(e){const t=this.model.state;t&&!1!==t.uiFullscreen&&(t.uiFullscreen=!1,e&&e.notifyMediaChange(),Ud.redraw())}onLandscapeScreen(e){const t=this.model.state;t&&!t.uiLandscape&&(t.uiLandscape=!0,e&&e.notifyMediaChange(),Ud.redraw())}onPortraitScreen(e){const t=this.model.state;t&&!1!==t.uiLandscape&&(t.uiLandscape=!1,e&&e.notifyMediaChange(),Ud.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&&(ph(`user/${e.netskraflUserId}/challenge`,((e,t)=>this.onUserChallengeMessage(e,t))),ph(`user/${e.netskraflUserId}/move`,((e,t)=>this.onUserMoveMessage(e,t))))}detachListenerFromUser(){const e=this.model.state;e?.netskraflUserId&&gh(`user/${e.netskraflUserId}`)}attachListenerToGame(e,t){const n=this.model.state;if(!e||!n)return;const i=`game/${e}/${n.netskraflUserId}/`;ph(`${i}move`,((e,t)=>this.onMoveMessage(e,t))),ph(`${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}/`;gh(`${n}move`),gh(`${n}chat`)}async markFavorite(e,t){if(this.model.state)try{await np(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 np(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),fh(`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 np(this.model.state,i);if(r?.ok){const e=this.model.state?.locale||"is_IS";fh("new_game",{uuid:r.uuid,timed:t,locale:e}),Ud.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++,Ud.redraw()}hideSpinner(){this.model.spinners>0&&(this.model.spinners--,Ud.redraw())}async withSpinner(e){this.showSpinner();try{return await e()}finally{this.hideSpinner()}}async setUserPref(e){if(this.model.state)try{await np(this.model.state,{method:"POST",url:"/setuserpref",body:e}),a(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 np(t,{method:"POST",url:"/cancelplan",body:{}});if(n?.ok)return e.friend=!1,t.hasPaid=!1,t.plan="",fh("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}/`;ph(`${i}count`,((e,t)=>this.onSolverCountUpdate(e,t))),ph(`${i}best`,((e,t)=>this.onRiddleGlobalScoreUpdate(e,t))),n?.userGroupId&&ph(`${i}group/${n.userGroupId}/best`,((e,t)=>this.onRiddleGroupScoreUpdate(e,t))),ph(`${i}leaders`,((e,t)=>this.onLeaderboardUpdate(e,t))),n?.netskraflUserId&&(ph(`gatadagsins/users/${t}/${n.netskraflUserId}/stats`,((e,t)=>this.onUserStatsUpdate(e,t))),ph(`${i}achievements/${n.netskraflUserId}`,((e,t)=>this.onPersonalBestScoreUpdate(e,t))))}detachListenerFromRiddle(e,t){const{state:n}=this.model,i=`gatadagsins/${e}/${t}/`;gh(`${i}count`),gh(`${i}best`),n?.userGroupId&&gh(`${i}group/${n.userGroupId}/best`),gh(`${i}leaders`),n?.netskraflUserId&&(gh(`gatadagsins/users/${t}/${n.netskraflUserId}/stats`),gh(`${i}achievements/${n.netskraflUserId}`))}onSolverCountUpdate(e,t){this.model.solverCount=e??0,Ud.redraw()}onRiddleGlobalScoreUpdate(e,t){const{riddle:n}=this.model,{score:i}=e;!n||!i||i<=0||(n.updateGlobalBestScore(e),Ud.redraw())}onRiddleGroupScoreUpdate(e,t){const{riddle:n}=this.model,{score:i}=e;!n||!i||i<=0||(n.updateGroupBestScore(e),Ud.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=[];Ud.redraw()}onUserStatsUpdate(e,t){this.model.userStats=e||null,Ud.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||"",o=e.timestamp||(new Date).toISOString();if(i<=n.personalBestScore||!r||!s)return;n.personalBestScore=i;const a=n.playerMoves.some((e=>e.word===r&&e.coord===s&&e.score===i));a||n.playerMoves.push({word:r,score:i,coord:s,timestamp:o}),Ud.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<ap||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(),Ud.redraw()}finally{this.riddleLoading=!1}}}}const Vp=e=>{const{view:t,showClose:n}=e.attrs,{model:i,actions:r}=t,s=i.state;return{view:()=>Ud(".board-help",{title:_p("Hvernig reitirnir margfalda stigin")},[n?Ud(".board-help-close",{title:_p("Loka þessari hjálp"),onclick:e=>{s&&(s.beginner=!1,r.setUserPref({beginner:!1})),e.preventDefault()}},xp("remove")):null,Ud(".board-colors",[Ud(".board-color[id='triple-word']",["3 x",Ud("br"),bp("orð")]),Ud(".board-color[id='double-word']",["2 x",Ud("br"),bp("orð")]),Ud(".board-color[id='triple-letter']",["3 x",Ud("br"),bp("stafur")]),Ud(".board-color[id='double-letter']",["2 x",Ud("br"),bp("stafur")]),Ud(".board-color[id='single-letter']",["1 x",Ud("br"),bp("stafur")])])])}},Bp=182,Hp=210,Wp=['<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"/>'],Gp=`\n<svg preserveAspectRatio="xMidYMid meet" width="100%" height="100%" viewBox="0 0 182 210" fill="none" xmlns="http://www.w3.org/2000/svg">\n${Wp.join("\n")}\n</svg>`,Kp=Ud.trust(Gp),Yp=Math.max(Bp,Hp)+40,Jp=`\n<svg preserveAspectRatio="xMidYMid meet" width="100%" height="100%" viewBox="0 0 ${Yp} ${Yp}" fill="none" xmlns="http://www.w3.org/2000/svg">\n ${`<circle cx="${Yp/2}" cy="${Yp/2}" r="${Yp/2-5}" fill="#ffffff"/>`}\n <svg x="${(Yp-Bp)/2}" y="${(Yp-Hp)/2}" width="182" height="210" viewBox="0 0 182 210">\n ${Wp.join("\n")}\n </svg>\n</svg>`,Zp=Ud.trust(Jp),Xp=e=>{const{attrs:t}=e,{width:n,withCircle:i}=t;return{view:()=>{const e={};return void 0!==n&&(e.width=`${n}px`),Ud(".animated-netskrafl-logo",{style:e},i?Zp:Kp)}}},Qp={oninit:e=>{e.state.show=!1,e.state.ival=setTimeout((()=>{e.state.show=!0,e.state.ival=0,Ud.redraw()}),800)},onremove:e=>{e.state.ival&&clearTimeout(e.state.ival),e.state.ival=0},view:e=>{if(e.state.show)return Ud(".modal-dialog",{id:"spinner-dialog",style:{visibility:"visible"}},Ud(".animated-spinner",Ud(Xp,{withCircle:!0})))}},eg=()=>{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:o}=n.attrs;return Ud(`input.text${t}`,{id:i,name:i,maxlength:r,tabindex:s,autocomplete:o,value:e,oninput:t=>{e=`${t.target.value}`}})}}},tg={view:e=>{const t={onmouseout:Pp,onmouseover:Ep};return Object.assign(t,e.attrs),Ud(".modal-close",t,e.children)}},ng={view:e=>{const t=e.attrs.item,n=e.attrs.view,i=n.actions,r=0===t.userid.indexOf("robot-");return Ud("span.list-ch",{title:_p("Skora á"),onclick:e=>{t.chall?(t.chall=!1,i.retractChallenge(t.userid,"")):r?i.startRobotGame(t.userid):n.pushDialog("challenge",t),e.preventDefault()}},xp("hand-right",void 0,!t.chall))}},ig={view:e=>{const t=e.attrs.item,n=e.attrs.view,i=!t.userid||0===t.userid.indexOf("robot-");return Ud("span.list-info",{title:_p("Skoða feril"),onclick:e=>{i||n.showUserInfo(t.userid,t.nick,t.fullname),e.preventDefault()}},i?"":Ud("span.usr-info"))}},rg={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 np(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 Ud("span",{id:t.id,title:_p(i?"Er álínis":"Álínis?"),class:i?"online":""})}},sg={view:e=>{const t=e.attrs.view,n=t.model;return n.state?.netskraflUserId?Ud(".userid",{title:_p("player_info"),onclick:e=>{t.pushDialog("userprefs",{}),e.preventDefault()}},[xp("address-book"),Lp(),n.state.userNick]):""}},og={view:e=>{const{manual:t,header:n}=e.attrs,i=_p("Keppnishamur"),r=!0===t&&!n;return Ud("span.list-manual",r||n?{title:i}:{},xp("lightbulb",void 0,!r))}},ag=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 Ud("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})))}}},lg={view:()=>Ud(".info",{title:_p("Upplýsingar og hjálp")},Ud(Ud.route.Link,{href:"/help",class:"iconlink"},xp("info-sign")))},cg={view:e=>Ud(".logo"+(e.attrs.hidden?".hidden":""),Ud(Ud.route.Link,{href:"/main",class:"nodecorate"},xp("home")))},ug={view:e=>Ud(".header-logo"+(e.attrs.hidden?".hidden":""),Ud(Ud.route.Link,{href:"/main",class:"backlink"},xp("home")))},hg=()=>{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:o,opt1:a,opt2:l}})=>{const c=`${t}-toggler`,u=".option"+(n?".small":"");return Ud.fragment({},[Ud(`input.checkbox.${t}`,{type:"checkbox",id:t,name:t,checked:r,value:"True"}),Ud(".toggler",{id:c,tabindex:s,title:o,onclick:t=>{e(c,i),t.preventDefault()},onkeypress:t=>{" "===t.key&&(e(c,i),t.preventDefault())}},[Ud(u+(r?"":".selected"),{id:"opt1"},a),Ud(u+(r?".selected":""),{id:"opt2"},l)])])}}},dg=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:()=>Ud(hg,{id:"ready",state:n.state?.ready??!1,tabindex:2,opt1:Lp(),opt2:xp("thumbs-up"),funcToggle:i,small:!0,title:_p("Tek við áskorunum!")})}},pg=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:()=>Ud(hg,{id:"timed",state:n.state?.readyTimed??!1,tabindex:3,opt1:Lp(),opt2:xp("time"),funcToggle:i,small:!0,title:_p("Til í viðureign með klukku!")})}},gg=e=>{const{model:t}=e.attrs.view;function n(e){e&&null!==t.state&&Ap(t.state,"your-turn")}return{view:({attrs:{state:e,tabindex:t}})=>Ud(hg,{id:"audio",state:e,tabindex:t,opt1:xp("volume-off"),opt2:xp("volume-up"),funcToggle:n,small:!0,title:_p("Hljóð á/af")})}},fg=e=>{const{model:t}=e.attrs.view;function n(e){e&&null!==t.state&&Ap(t.state,"you-win")}return{view:({attrs:{state:e,tabindex:t}})=>Ud(hg,{id:"fanfare",state:e,tabindex:t,opt1:xp("volume-off"),opt2:xp("volume-up"),funcToggle:n,small:!0,title:_p("Lúðraþytur á/af")})}},mg=()=>({view:({attrs:{state:e,tabindex:t}})=>Ud(hg,{id:"beginner",state:e,tabindex:t,opt1:Lp(),opt2:xp("ok"),small:!0})}),vg=()=>({view:({attrs:{state:e,tabindex:t}})=>Ud(hg,{id:"fairplay",state:e,tabindex:t,opt1:Lp(),opt2:xp("edit"),small:!0})}),yg=()=>{function e(e){e.cancelBlankDialog(),zp()}function t(e,t){e.placeBlank(t),zp()}function n(e){const n=e.alphabet;let i=n.length,r=0;const s=[];for(;i>0;){const o=[];for(let s=0;s<6&&i>0;s++){const s=n[r++];o.push(Ud("td",{onclick:n=>{n.preventDefault(),t(e,s)},onmouseover:Ep,onmouseout:Pp},Ud(".blank-choice.netskrafl-tile.netskrafl-racktile",s))),i--}s.push(Ud("tr",o))}return s}return{view:i=>{const{game:r}=i.attrs;if(r)return Ud(".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(),void e(n);const s=r.normalize("NFC");if(1===s.length){const e=s.toLowerCase();n.alphabet.includes(e)&&(i.preventDefault(),t(n,e))}}(r,n),oncreate:e=>e.dom.focus()},Ud(".ui-widget.ui-widget-content.ui-corner-all",{id:"blank-form"},[kp("p","Hvaða staf táknar auða flísin?"),Ud(".rack.blank-rack",Ud("table.board",{id:"blank-meaning"},n(r))),Ud(tg,{id:"blank-close",title:_p("Hætta við"),onclick:t=>{t.preventDefault(),e(r)}},xp("remove"))]))}}};function wg(e,t,n,i,r,s,o){const a={onmouseout:Pp,onmouseover:Ep,style:{visibility:!1===s?"hidden":"visible"}};return i&&(a.title=i),o&&(a.id=o),a.onclick=t?e=>e.preventDefault():e=>{n?.(),e.preventDefault()},Ud(`.${e}${t?".disabled":""}`,a,r)}const bg={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 Ud(n.join("."),{title:i},i)}},_g={view:e=>{const{view:t,game:n,disabled:i,visible:r=!0}=e.attrs;if(n)return wg("recallbtn",!!i,(()=>{n.resetRack(),t.updateScale()}),_p("Færa stafi aftur í rekka"),xp("down-arrow"),r)}},kg={view:e=>{const{game:t,disabled:n,visible:i=!0}=e.attrs;if(t)return wg("scramblebtn",!!n,(()=>t.rescrambleRack()),_p("Stokka upp rekka"),xp("random"),i)}},Cg={view:e=>{const{view:t,game:n}=e.attrs;if(!n)return;const i=n.buttonState();if(i.showRecall&&!i.showingDialog)return Ud(_g,{view:t,game:n});const r=i.showScramble&&!i.tilesPlaced,s=i.showingDialog;return Ud(kg,{view:t,game:n,visible:r,disabled:s})}},Sg={view:e=>{const{view:t}=e.attrs,{game:n}=t.model,i=[];if(!n)return i;const r=n.buttonState();if(i.push(Ud(".word-check"+(r.wordGood?".word-good":"")+(r.wordBad?".word-bad":""))),r.showChallenge){const e=(r.tilesPlaced||r.showingDialog)&&!r.lastChallenge;i.push(wg("challenge",e,(()=>n.submitChallenge()),"Véfenging (röng kostar 10 stig)",xp("ban-circle")))}if(r.showRecall&&i.push(Ud(_g,{view:t,game:n,disabled:r.showingDialog})),r.showScramble&&i.push(Ud(kg,{view:t,game:n,disabled:r.showingDialog})),r.showMove){const e=_p("submit_move"),s=!r.tilesPlaced||r.showingDialog;i.push(wg("submitmove",s,(()=>{n.submitMove(),t.updateScale()}),e,[e,xp("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 o=void 0===n.currentScore?"?":n.currentScore.toString(),a=[Ud("span.score-mobile",o)];let l;r.canPlay&&s?a.push(xp("play")):a.push(xp("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(wg(e.join("."),r.showingDialog,l,o,a,!0,"move-mobile"))}if(r.showForceResignMobile){const e=_p("Þvinga til uppgjafar");i.push(wg("force-resign",r.showingDialog,(()=>n.forceResign()),e,e))}if(r.showPass){const e=(r.tilesPlaced||r.showingDialog)&&!r.lastChallenge;i.push(wg("submitpass",e,(()=>n.submitPass()),_p("Pass"),xp("forward")))}if(r.showExchange){const e=!r.exchangeAllowed||r.tilesPlaced||r.showingDialog;i.push(wg("submitexchange",e,(()=>n.submitExchange()),_p("Skipta stöfum"),xp("refresh")))}if(r.showResign&&i.push(wg("submitresign",r.showingDialog,(()=>n.submitResign()),_p("Gefa viðureign"),xp("fire"))),!r.gameOver&&!r.localTurn&&!n.moveInProgress&&null!==n.player){const e=n.nickname[1-n.player];i.push(Ud(".opp-turn",{style:{visibility:"visible"}},[Ud("span.move-indicator"),Lp(),Ud("strong",_p("opp_move",{opponent:e})),Lp(),r.tardyOpponent?Ud("span.yesnobutton",{id:"force-resign",onclick:e=>{e.preventDefault(),n.forceResign()},onmouseout:Pp,onmouseover:Ep,title:_p("14 dagar liðnir án leiks")},_p("Þvinga til uppgjafar")):""]))}if(r.tilesPlaced){const e=Ud(bg,{game:n});e&&i.push(e)}return n?.moveInProgress&&i.push(Ud(".waitmove",Ud(".animated-waitmove",Ud(Xp,{withCircle:!1})))),Ud(".buttons",i)}};class Tg{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:o,cancelDrag:a}=this.boundEventHandlers;e instanceof MouseEvent?(document.addEventListener("mousemove",s),document.addEventListener("mouseup",o),document.addEventListener("mouseleave",a)):e instanceof TouchEvent&&(document.addEventListener("touchmove",s,{passive:!1}),document.addEventListener("touchend",o),document.addEventListener("touchcancel",o)),document.addEventListener("visibilitychange",a),window.addEventListener("blur",a)}initiateDrag(e){e.preventDefault(),this.dragStarted=!0;const t=this.draggedElement,n=t.getBoundingClientRect(),{offsetWidth:i,offsetHeight:r}=t;t.classList.add("dragging"),document.body.appendChild(t);const{offsetWidth:s,offsetHeight:o}=t;this.offsetX=this.startX-n.left+(s-i)/2,this.offsetY=this.startY-n.top+(o-r)/2,this.centerX=s/2,this.centerY=o/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&&Tg.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"),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 Ig=(e,t,n)=>i=>{var r,s,o;return s=(i,r)=>{if(!t)return;const s=r.id;if(!s)return;let o="";if("board-background"===s?o="R1":s.startsWith("sq_")&&(o=s.slice(3)),o)try{t.attemptMove(n,o),e.updateScale(),Ud.redraw()}catch(e){console.error(e)}},o=()=>{t&&(n===t.selectedSq?t.selectedSq=null:t.selectedSq=n,Ud.redraw())},(r=i).stopPropagation(),new Tg(r,s,o),i.redraw=!1,!1},Eg=()=>({view:e=>{const{view:t,game:n,coord:i,opponent:r}=e.attrs;if(!n)return;const s="R"===i[0],o=n.tiles[i],a=[".netskrafl-tile"],l={};if("?"===o.tile&&a.push("netskrafl-blanktile"),"q".includes(o.letter)?a.push("netskrafl-extra-wide"):"zxmæ".includes(o.letter)&&a.push("netskrafl-wide"),s||o.draggable?(a.push(r?"netskrafl-freshtile":"netskrafl-racktile"),s&&"exchange"===n.showingDialog&&(o.xchg&&a.push("netskrafl-xchgsel"),l.onclick=e=>{o.xchg=!o.xchg,e.preventDefault()})):o.freshtile&&a.push("netskrafl-freshtile"),o.index){const e=150,t=`${(o.index*e).toString()}ms`;l.style=`animation-delay: ${t}`}if(i===n.selectedSq&&a.push("sel"),void 0!==o.highlight&&a.push(`highlight${o.highlight}`),o.draggable&&n.allowDragDrop()){const e=Ig(t,n,i);l.onmousedown=e,l.ontouchstart=e}return Ud(a.join("."),l,[" "===o.letter?Lp():o.letter,Ud(".letterscore",o.score)])}}),Pg={view:e=>{const{view:t,game:n,coord:i}=e.attrs;if(n)return Ud("td.not-target",{id:`sq_${i}`,class:n.squareClass(i)},Ud(Eg,{view:t,game:n,coord:i,opponent:!1}))}},xg={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",Ud(`td${i}`,{id:`sq_${n}`},e.children)}},Rg={view:e=>{const{view:t,game:n,coord:i,isKeyboardTarget:r,keyboardDirection:s}=e.attrs;if(!n)return;let o=n.squareClass(i)||"";return o&&(o=`.${o}`),null!==n.askingForBlank&&n.askingForBlank.to===i&&(o+=".blinking"),i===n.startSquare&&n.localturn&&(o+=".center"),r&&(o+=".keyboard-target","V"===s&&(o+=".vertical")),Ud(`td.drop-target${o}`,{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)}},Lg={view:e=>{const{view:t,game:n,review:i}=e.attrs;if(!n)return;const{model:r}=t,s=[],o=r.reviewMove??0,a=i&&0===o,l=i&&o>0&&o%2===n.player;for(let e=1;e<=7;e++){const r=`R${e}`;!a&&n&&r in n.tiles?i?s.push(Ud(xg,{key:r,view:t,game:n,coord:r,opponent:l},Ud(Eg,{view:t,game:n,coord:r,opponent:l}))):s.push(Ud(Rg,{key:r,view:t,game:n,coord:r},Ud(Eg,{view:t,game:n,coord:r,opponent:!1}))):i?s.push(Ud(xg,{key:r,view:t,game:n,coord:r,opponent:!1})):s.push(Ud(Rg,{key:r,view:t,game:n,coord:r}))}return Ud("table.board",Ud("tbody",Ud("tr",s)))}},Ng={view:e=>{const{view:t,game:n,review:i}=e.attrs;return Ud(".rack-row",[Ud(".rack-left",Ud(Cg,{view:t,game:n})),Ud(".rack",Ud(Lg,{view:t,game:n,review:i}))])}},Dg={view:e=>{const{game:t}=e.attrs;return t.congratulate?Ud("div",{id:"congrats"},[xp("bookmark")," ",kp("strong","Til hamingju með sigurinn!")]):t.over?Ud("div",{id:"gameover"},[xp("info-sign")," ",kp("strong","Viðureigninni er lokið")]):void 0}},Ag={view:e=>{const{game:t}=e.attrs,n=t.currentError||"";if(n&&n in lp){const e=t.currentMessage||"",i=_p(lp[n]),r=i.indexOf("{word}");let s;return s=r>=0?[i.slice(0,r),Ud("span.errword",e),i.slice(r+6)]:[i],Ud(".error",{style:{visibility:"visible"},onclick:e=>{t.resetError(),e.preventDefault()}},[xp("exclamation-sign"),...s])}}},Mg={view:e=>{const{view:t,game:n}=e.attrs;let i=[];return n&&(i=[Ud(Og,{view:t,game:n,review:!1}),Ud(Ng,{view:t,game:n,review:!1}),Ud(Sg,{view:t}),Ud(Ag,{game:n}),Ud(Dg,{game:n})],i=i.concat(t.vwDialogs())),Ud(".board-area",i)}};const Og={oninit:e=>{e.state.columnIdentifiers=function(){const e=[];e.push(Ud("td"));for(let t=1;t<=15;t++)e.push(Ud("td",t.toString()));return Ud("tr.colid",e)}()},view:e=>{const{view:t,game:n,review:i}=e.attrs,r=t.isMobile(),s=i||r?null:n.getNextKeyboardSquare();function o(e){const r=[];r.push(Ud("td.rowid",{key:`R${e}`},e));for(let o=1;o<=15;o++){const a=e+o.toString();n&&a in n.tiles?r.push(Ud(Pg,{view:t,game:n,key:a,coord:a,opponent:!1})):i?r.push(Ud(xg,{view:t,game:n,key:a,coord:a,opponent:!1})):r.push(Ud(Rg,{view:t,game:n,key:a,coord:a,isKeyboardTarget:a===s,keyboardDirection:n?.getEffectiveKeyboardDirection()}))}return Ud("tr",r)}const a=Ud("tbody",function(){const t=[];t.push(e.state.columnIdentifiers);for(const e of"ABCDEFGHIJKLMNO")t.push(o(e));return t}()),l=Ud("table.board",{},a);return Ud(".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=Sp.get(t)||0;return Sp.set(t,n),n-i<300}(e)&&(e.stopPropagation(),t.zoomOut())}},l)}},jg={view:e=>{const{riddle:t,mode:n="desktop"}=e.attrs;if(!t)return Ud("div");const i=t.currentScore,r=void 0!==i,s=["mobile"===n?".mobile-score":".gata-dagsins-score"];let o="0";t.tilesPlaced().length>0?r?t.wordGood?(o=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"),o=i.toString()):(s.push(".illegal"),o="?"):(s.push(".disabled"),o="0");const a="mobile"===n?".mobile-score-legend":".gata-dagsins-legend";return Ud(`div${s.join("")}`,Ud(`span${a}`,o))}},Fg={view:e=>{const{view:t}=e.attrs,{riddle:n}=t.model;if(!n)return Ud(".gatadagsins-board-rack-wrapper","");const i=n.wordGood&&(n.currentScore||0)>=n.bestPossibleScore;return Ud(".gatadagsins-board-rack-wrapper",[Ud(".gatadagsins-board-area"+(i?".celebrate":""),[n?Ud(Og,{view:t,game:n,review:!1}):""]),Ud(".gatadagsins-rack-area",[Ud(".rack-left",Ud(Cg,{view:t,game:n})),Ud(".rack",Ud(Lg,{view:t,game:n,review:!1})),Ud(jg,{riddle:n})])])}},Ug={view:e=>{const t=e.attrs.onClose;return[Ud(".modal-backdrop-netskrafl",{onclick:e=>{e.preventDefault()},onwheel:e=>{e.preventDefault(),e.stopPropagation()},ontouchmove:e=>{e.preventDefault(),e.stopPropagation()}}),Ud(".modal-dialog.gatadagsins-help",Ud(".modal-content",[Ud("button.close",{onclick:t,"aria-label":"Loka"},xp("remove")),Ud(".modal-header",Ud("h2","Um Gátu dagsins")),Ud(".modal-body",[Ud("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."),Ud("h3","Hvernig á að spila"),Ud("ul",[Ud("li","Þú færð borð með allmörgum stöfum sem þegar hafa verið lagðir."),Ud("li","Neðst á skjánum eru stafaflísar sem þú getur notað til að mynda orð."),Ud("li","Dragðu flísar á borðið til að mynda orð, annaðhvort lárétt eða lóðrétt."),Ud("li","Orðin verða að tengjast við stafi sem fyrir eru á borðinu."),Ud("li","Þú sérð jafnóðum hvort lögnin á borðinu er gild og hversu mörg stig hún gefur."),Ud("li","Þú getur prófað eins mörg orð og þú vilt - besta skorið þitt er vistað.")]),Ud("h3","Stigagjöf"),Ud("p","Þú færð stig fyrir hvern staf í orðinu, auk bónusstiga fyrir lengri orð:"),Ud("ul",[Ud("li","Hver stafur gefur 1-10 stig eftir gildi hans"),Ud("li","Orð sem nota allar 7 stafaflísarnar gefa 50 stiga bónus"),Ud("li",["Sumir reitir á borðinu ",Ud("span.help-bonus-square.double-letter"),"tvöfalda eða ",Ud("span.help-bonus-square.triple-letter"),"þrefalda stafgildið"]),Ud("li",["Sumir reitir ",Ud("span.help-bonus-square.double-word"),"tvöfalda eða ",Ud("span.help-bonus-square.triple-word"),"þrefalda heildarorðgildið"])]),Ud("h3","Hitamælir"),Ud("p","Hitamælirinn hægra megin við borðið (sést ekki á farsímum) sýnir:"),Ud("ul",[Ud("li",Ud("strong","Besta mögulega lögn:")," Hæstu stig sem hægt er að ná á þessu borði."),Ud("li",Ud("strong","Besta skor dagsins:")," Hæstu stig sem einhver leikmaður hefur náð í dag."),Ud("li",Ud("strong","Þín bestu orð:")," Orðin sem þú hefur lagt og stigin fyrir þau."),Ud("li","Þú getur smellt á orð á hitamælinum til að fá þá lögn aftur á borðið.")]),Ud("h3","Ábendingar"),Ud("ul",[Ud("li","Reyndu að nota dýra stafi (eins og X, Ý, Þ) á tvöföldunar- eða þreföldunarreitum."),Ud("li","Lengri orð gefa mun fleiri stig vegna bónussins."),Ud("li","Þú getur dregið allar flísar til baka með bláa endurkalls-hnappnum."),Ud("li","Ný gáta birtist á hverjum nýjum degi - klukkan 00:00!")]),Ud("h3","Um leikinn"),Ud("p",["Gáta dagsins er systkini ",Ud("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."])]),Ud(".modal-footer",Ud("button.btn.btn-primary",{onclick:t},"Loka"))]))]}},zg={view:e=>{const{view:t}=e.attrs,{model:n}=t.actions,{solverCount:i}=n;return i<=0?null:Ud(".solver-count-pill",{title:_p("Leikmenn sem hafa leyst gátuna")},i)}},$g={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]},o=(new Date).toISOString().split("T")[0],a=s(n,-1),l=s(n,1),c=r.isRiddleLoading,u=!c&&a>=ap,h=!c&&l<=o,d=e=>{const t=new URL(window.location.href);e===o?t.searchParams.delete("date"):t.searchParams.set("date",e),window.history.pushState({},"",t.toString()),r.loadRiddle(e,i)},p=(e,t)=>{if(e)return e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),t())}},g=_p("Fyrri dagur"),f=_p("Næsti dagur"),m=n>="2025-12-05";return Ud(".date-navigator",[Ud(".nav-arrow.prev"+(u?"":".disabled"),{role:"button",tabindex:u?0:-1,"aria-disabled":!u,"aria-label":g,onclick:u?()=>d(a):void 0,onkeydown:p(u,(()=>d(a))),title:u?g:""},xp("chevron-left")),Ud(".nav-date",Up(n)),m?Ud(zg,{view:t}):null,Ud(".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:""},xp("chevron-right"))])}},qg={view:e=>{const{animate:t=!1,size:n=80}=e.attrs,i=n/2,r=n/3;return Ud("div.sun-corona"+(t?".rotating":""),[Ud.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 `)])}},Vg=()=>{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:o}=n.model;if(!o)return null;const{bestPossibleScore:a,globalBestScore:l,personalBestScore:c}=o,u=i&&""!==i.word,h=(new Date).toISOString().split("T")[0],d=o.date<h,p=d?o.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=_p("Tölfræði og stigatafla");return Ud(".mobile-status-container",[Ud(".mobile-status-item.left",Ud(jg,{riddle:o,mode:"mobile"})),Ud(".mobile-status-card",{role:"button",tabindex:0,"aria-label":y,onclick:s,onkeydown:e(s),title:y},[Ud(".mobile-status-card-item.player-best",[Ud(".mobile-status-label",_p("Þín besta")),Ud(".mobile-status-score",c.toString())]),Ud(".mobile-status-card-item.leader"+(f?".is-player":""),[Ud(".mobile-status-label",_p(f?"Þú leiðir!":"Best til þessa")),Ud(".mobile-status-score",g.toString())]),Ud(".mobile-status-card-icon",xp("chevron-down"))]),Ud(".mobile-status-item.right.best-possible"+(u?".celebrate":""),{role:m?"button":void 0,tabindex:m?0:void 0,"aria-label":m?_p("Sýna besta leik"):void 0,onclick:v,onkeydown:m?e(v):void 0},[Ud(".mobile-best-score-wrapper",[u?Ud(qg,{animate:!0,size:100}):null,Ud(".mobile-status-score",a.toString())])])])}}};const Bg={view:e=>{const{leaderboard:t,currentUserId:n,loading:i=!1}=e.attrs;return i?Ud(".leaderboard-view.loading",Ud(".loading-message",_p("Hleð stigatöflu..."))):t&&0!==t.length?Ud(".leaderboard-view",[Ud(".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 Ud(".leaderboard-entry"+(r?".current-user":""),{key:e.userId},[Ud(".entry-rank",[s?Ud("span.medal",s):Ud("span.rank-number",i.toString())]),Ud(".entry-name",r?[Ud("span.entry-star",xp("star")),_p("Þú")]:e.displayName),Ud(".entry-score",e.score.toString())])})))]):Ud(".leaderboard-view.empty",Ud(".empty-message",_p("Engin stig skráð enn")))}},Hg="netskrafl_settings",Wg={autoZoom:!0};let Gg=null;function Kg(){if(Gg)return Gg;try{const e=localStorage.getItem(Hg);if(e){const t={...Wg,...JSON.parse(e)};return Gg=t,t}}catch(e){console.error("Failed to load settings:",e)}const e={...Wg};return Gg=e,e}function Yg(){return Kg().autoZoom}function Jg(e){const t=Kg();t.autoZoom=e,function(e){try{localStorage.setItem(Hg,JSON.stringify(e)),Gg=e}catch(e){console.error("Failed to save settings:",e)}}(t)}const Zg=()=>({view:({attrs:e})=>{const{state:t,onToggle:n,id:i,tabindex:r=0,title:s,disabled:o=!1,size:a="medium"}=e;return Ud(`.sliding-toggle${"medium"!==a?`.toggle-${a}`:""}${t?".on":""}${o?".disabled":""}`,{id:i,tabindex:o?-1:r,title:s,role:"switch","aria-checked":t?"true":"false","aria-disabled":o?"true":void 0,onclick:()=>{o||n(!t)},onkeydown:e=>{o||" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),n(!t))}},Ud(".sliding-toggle-thumb"))}}),Xg=e=>{let t=Yg();const{view:n}=e.attrs;function i(e){t=e,Jg(e),e||n.zoomOut()}return{view:e=>{const{stats:n,loading:r=!1}=e.attrs;if(r)return Ud(".stats-view.loading",Ud(".loading-message",_p("Sæki tölfræði...")));if(!n)return Ud(".stats-view.empty",Ud(".empty-message",_p("Engin tölfræði til að sýna")));const s=[{iconGlyph:"fire",label:_p("Núverandi striklota"),value:n.currentStreak,highlight:n.currentStreak>0},{iconGlyph:"star",label:_p("Lengsta striklota"),value:n.longestStreak},{iconGlyph:"tower",label:_p("Hæsta skori náð"),value:n.totalTopScores},{iconGlyph:"certificate",label:_p("Striklota hæsta skors"),value:n.topScoreStreak,highlight:n.topScoreStreak>0},{iconGlyph:"calendar",label:_p("Heildarfjöldi daga"),value:n.totalDaysPlayed}];return Ud(".stats-view",[Ud(".stats-grid",s.map(((e,t)=>Ud(".stat-item"+(e.highlight?".highlight":""),{key:t},[Ud(".stat-icon",xp(e.iconGlyph)),Ud(".stat-info",[Ud(".stat-label",e.label),Ud(".stat-value",e.value.toString())])])))),Ud(".stats-settings",[Ud(".settings-row",[Ud("span.settings-label",_p("Þysja sjálfkrafa")),Ud(Zg,{state:t,onToggle:i,id:"autozoom-gata",title:_p("Þysja sjálfkrafa"),size:"small"})]),Ud(".settings-explain",_p("autozoom_explain"))])])}}},Qg={view:e=>{const{tabs:t,activeTab:n,onTabChange:i}=e.attrs;return Ud(".tab-bar[role=tablist]",t.map((e=>{const t=n===e.id;return Ud(".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))})},[Ud("span.tab-icon-wrapper",[e.iconGlyph?Ud("span.tab-icon",xp(e.iconGlyph)):e.icon?Ud("span.tab-icon",e.icon):null,e.badgeGlyph?Ud("span.tab-badge",xp(e.badgeGlyph)):null]),Ud("span.tab-label",e.label)]);var r})))}};function ef(e){return e.replace(/\?/g,"")}const tf={view:e=>{const{score:t,bestMove:n,onMoveClick:i,solution:r}=e.attrs;let s;const o=n&&""!==n.word;s=o?ef(n.word):_p("Besta mögulega lögn");const a=r&&!o?_p("Smelltu til að sjá lausn"):"",l=!(!r&&!o),c=()=>{r?i(r.word,r.coord):o&&i(n.word,n.coord)},u=l?e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),c())}:void 0;return Ud(".thermometer-best-score"+(o?".celebrate":""),Ud(".thermometer-best-score-container",{role:l?"button":void 0,tabindex:l?0:void 0,"aria-label":l?_p("Sýna besta leik"):void 0,onclick:c,onkeydown:u,title:a},[o?Ud(qg,{animate:!0}):null,Ud(".thermometer-best-circle",t.toString()),Ud(".thermometer-best-label",s)]))}},nf={view:e=>{const{score:t,thisPlayer:n}=e.attrs;return Ud(".thermometer-current-score"+(n?".this-player":""),[Ud(".thermometer-current-circle",t.toString())])}},rf={view:e=>{const{zoneHeights:t,zoneAllocation:n,onMoveClick:i}=e.attrs,r=t.cold,s=r+t.warm,o=[];function a(e,t,n,r){const s=e.length,a=r/(s+1);e.forEach(((e,r)=>{const l=n+a*(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;o.push(Ud(`.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?`${_p("Sýna leik")}: ${ef(e.word)}`:void 0,onclick:u,onkeydown:h},function(e){return e.isGlobalBestScore?""===e.word?[Ud(nf,{thisPlayer:!1,score:e.score})]:[Ud(nf,{thisPlayer:!0,score:e.score}),Ud(".thermometer-move-word",ef(e.word)),Ud(".thermometer-move-coord",`(${e.coord})`)]:[Ud(".thermometer-move-score",e.score.toString()),Ud(".thermometer-move-word",ef(e.word)),Ud(".thermometer-move-coord",`(${e.coord})`)]}(e)))}))}return a(n.cold,"cold",0,t.cold),a(n.warm,"warm",r,t.warm),a(n.hot,"hot",s,t.hot),Ud(".thermometer-moves-overlay-wrapper",o)}},sf={view:e=>{const{riddle:t,selectedMoves:n,bestMove:i,onMoveClick:r}=e.attrs,{warmBoundary:s,hotBoundary:o,bestPossibleScore:a,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,o,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),o=Math.max(15,8*i),a=r+s+o;if(a>100){const e=100/a;return{hot:r*e,warm:s*e,cold:o*e}}const l=100-a,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:o+i*u+h}}(c),h=(new Date).toISOString().split("T")[0],d=t.date<h?t.solution||l:null;return Ud(".thermometer-container",[Ud(".thermometer-body",[Ud(".thermometer-zones",[Ud(".thermometer-zone.hot",{style:`--zone-size: ${u.hot+u.warm+u.cold}%`}),Ud(".thermometer-zone.warm",{style:`--zone-size: ${u.warm+u.cold}%`}),Ud(".thermometer-zone.cold",{style:`--zone-size: ${u.cold}%`})]),Ud(rf,{moves:n,maxScore:a,zoneHeights:u,zoneAllocation:c,onMoveClick:r})]),Ud(tf,{score:a,bestMove:i,onMoveClick:r,solution:d})])}},of=()=>{let e="performance";return{view:t=>{const{view:n,selectedMoves:i,bestMove:r,onMoveClick:s}=t.attrs,{riddle:o,state:a,leaderboard:l}=n.model;if(!o)return Ud(".gatadagsins-right-side-tabs","");const c=a?.netskraflUserId||"",u=l?.some((e=>e.userId===c)),h=[{id:"performance",label:_p("Frammistaða"),iconGlyph:"dashboard"},{id:"stats",label:_p("Tölfræði"),iconGlyph:"stats"},{id:"leaderboard",label:_p("Stigatafla"),iconGlyph:"tower",badgeGlyph:u?"star":void 0}];return Ud(".gatadagsins-right-side-tabs",[Ud(Qg,{tabs:h,activeTab:e,onTabChange:t=>{e=t}}),Ud(".tab-content",["performance"===e?Ud(sf,{riddle:o,selectedMoves:i,bestMove:r,onMoveClick:s}):null,"stats"===e?Ud(Xg,{view:n,stats:n.model.userStats||null,loading:!1}):null,"leaderboard"===e?Ud(Bg,{leaderboard:n.model.leaderboard||[],currentUserId:a?.netskraflUserId||"",loading:!1}):null])])}}},af={view:e=>{const{view:t,selectedMoves:n,bestMove:i,onStatsClick:r}=e.attrs,{riddle:s}=t.model,o=(e,t)=>{s&&e&&t&&s.recreateWordOnBoard(e,t)};return Ud(".gatadagsins-right-side-wrapper",s?[Ud(".gatadagsins-mobile-wrapper",[Ud(".mobile-date-nav-container",Ud($g,{view:t,date:s.date,locale:s.locale})),Ud(".gatadagsins-mobile-status",Ud(Vg,{view:t,selectedMoves:n,bestMove:i,onMoveClick:o,onStatsClick:r}))]),Ud(".gatadagsins-thermometer-column",[Ud(".desktop-date-nav-container",Ud($g,{view:t,date:s.date,locale:s.locale})),Ud(of,{view:t,selectedMoves:n,bestMove:i,onMoveClick:o})])]:null)}};const lf=()=>{let e=!1,t=null;return{onremove:()=>{t&&(clearTimeout(t),t=null)},view:n=>{const{score:i,position:r,word:s,onClose:o}=n.attrs,a=s.replace(/\?/g,"").toUpperCase(),l=_p("share_text_template",{position:String(r)});return[Ud(".modal-backdrop-netskrafl",{onclick:e=>(e.preventDefault(),o(),!1),onwheel:e=>(e.preventDefault(),e.stopPropagation(),!1),ontouchmove:e=>(e.preventDefault(),e.stopPropagation(),!1)}),Ud(".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(),o())},onwheel:e=>(e.stopPropagation(),!1),ontouchmove:e=>(e.stopPropagation(),!1)},[Ud(".modal-content",[Ud("button.close",{onclick:o,"aria-label":_p("Loka")},xp("remove")),Ud(".share-popup-celebration",[Ud(qg,{animate:!0,size:84}),Ud(".share-popup-score-circle",[Ud(".share-popup-score",String(i))])]),Ud(".share-popup-title",{id:"share-popup-title"},_p("share_popup_title")),Ud(".share-popup-subtitle",_p("share_popup_subtitle")),Ud(".share-popup-word",a),Ud(".share-popup-text-preview",l),Ud(".share-popup-buttons",[Ud("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,Ud.redraw(),t=setTimeout((()=>{e=!1,t=null,Ud.redraw()}),2e3))}},[xp(e?"ok":"copy")," ",_p(e?"share_copied_confirmation":"share_button_copy")]),"undefined"!=typeof navigator&&"function"==typeof navigator.share?Ud("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)}},[xp("share")," ",_p("share_button_share")]):null])])])]}}},cf=()=>{let e="stats";return{view:t=>{const{view:n,onClose:i}=t.attrs,{riddle:r,state:s,leaderboard:o}=n.model;if(!r)return null;const a=s?.netskraflUserId||"",l=o?.some((e=>e.userId===a)),c=[{id:"stats",label:_p("Tölfræði"),iconGlyph:"stats"},{id:"leaderboard",label:_p("Stigatafla"),iconGlyph:"tower",badgeGlyph:l?"star":void 0}];return[Ud(".modal-backdrop-netskrafl",{onclick:e=>(e.preventDefault(),!1),onwheel:e=>(e.preventDefault(),e.stopPropagation(),!1),ontouchmove:e=>(e.preventDefault(),e.stopPropagation(),!1)}),Ud(".modal-dialog.stats-modal",{onwheel:e=>(e.stopPropagation(),!1),ontouchmove:e=>(e.stopPropagation(),!1)},[Ud(".modal-content",[Ud("button.close",{onclick:i,"aria-label":"Loka"},xp("remove")),Ud(Qg,{tabs:c,activeTab:e,onTabChange:t=>{e=t}}),Ud(".modal-body",["stats"===e?Ud(Xg,{view:n,stats:n.model.userStats||null,loading:!1}):null,"leaderboard"===e?Ud(Bg,{leaderboard:n.model.leaderboard||[],currentUserId:s?.netskraflUserId||"",loading:!1}):null])])])]}}},uf={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:o,bestMove:a}=s?hf(s):{selectedMoves:[],bestMove:void 0},l=()=>{n.showHelp=!n.showHelp,Ud.redraw()},c=()=>{n.showStatsModal=!n.showStatsModal,Ud.redraw()};return Ud("div.drop-target",{id:"gatadagsins-background"},[Ud(".gatadagsins-container",[s?Ud(".gatadagsins-main",[Ud(Fg,{view:i}),Ud(af,{view:i,selectedMoves:o,bestMove:a,onStatsClick:c}),s.askingForBlank?Ud(yg,{game:s}):""]):"",r.state?.beginner?Ud(Vp,{view:i,showClose:!1}):"",Ud(".info",{title:_p("Upplýsingar og hjálp")},Ud("a.iconlink",{href:"#",onclick:e=>{e.preventDefault(),l()}},xp("info-sign"))),n.showHelp?Ud(Ug,{onClose:l}):""]),n.showStatsModal?Ud(cf,{view:i,onClose:c}):"",s?.justAchievedBestScore&&a?Ud(lf,{score:a.score,position:r.solverCount,word:a.word,onClose:()=>{s&&(s.justAchievedBestScore=!1),Ud.redraw()}}):""])}},hf=e=>{const t=e.model.state?.netskraflUserId||"",{bestPossibleScore:n,globalBestScore:i,playerMoves:r}=e;let s;const o=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;(o[0]?.score??0)>=e?o[0].isGlobalBestScore=!0:i.player===t?o.unshift({score:e,isGlobalBestScore:!0,word:n,coord:r}):o.unshift({score:e,isGlobalBestScore:!0,word:"",coord:""})}return o.length>0&&o[0].score===n&&(s=o.shift()),{selectedMoves:o,bestMove:s}};function df(e,t,n){const i=n.target;if("INPUT"===i.tagName||"TEXTAREA"===i.tagName||"SELECT"===i.tagName||i.isContentEditable)return;if(t.isMobile())return;if(e.showingDialog)return;if(null!==e.askingForBlank)return;const{key:r}=n;if("ArrowRight"===r)return n.preventDefault(),e.setKeyboardDirection("H"),void Ud.redraw();if("ArrowDown"===r)return n.preventDefault(),e.setKeyboardDirection("V"),void Ud.redraw();if("Backspace"===r)return n.preventDefault(),void(e.undoLastKeyboardTile()&&Ud.redraw());if("Escape"===r)return n.preventDefault(),e.resetRack(),void Ud.redraw();const s=r.normalize("NFC");if(1===s.length){const t=s.toLowerCase();if(e.alphabet.includes(t))return n.preventDefault(),void(e.placeKeyboardTile(t)&&Ud.redraw())}}let pf=null;class gf{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 ff{getLocalTile(e){return""}getLocalTileSq(e){return""}setLocalTile(e,t){}setLocalTileSq(e,t){}clearTiles(){}saveTiles(e){}loadTiles(){return[]}}const mf=e=>function(){if(null===pf)try{pf="localStorage"in window&&null!==window.localStorage&&void 0!==window.localStorage}catch(e){pf=!1}return pf}()?new gf(e):new ff;const vf=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 ip(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}},yf={standard:"H8",explo:"D4"},wf={standard:[7,7],explo:[3,3]},bf={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 _f{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=mf(e),this.board_type=n,this.startSquare=yf[n],this.startCoord=wf[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}=Fp(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=bf[this.board_type].WORDSCORE;return parseInt(n[e].charAt(t),10)||1}letterScore(e,t){const n=bf[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){this.tiles={}}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 vf.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=sp,r=sp,s=0,o=0,a=0,l=0,c="",u="";const h=[],d=Object.values(this.tiles).filter((e=>!e.draggable)).length;if(this.tilesPlaced().forEach((t=>{const l=rp.indexOf(t.charAt(0)),c=parseInt(t.slice(1),10)-1,u=this.tiles[t];e+=u.score*this.letterScore(l,c),a++,n*=this.wordScore(l,c),l<i&&(i=l),c<r&&(r=c),l>s&&(s=l),c>o&&(o=c)})),!a)return;if(i!==s&&r!==o)return;let p=r,g=i,f=0,m=0;for(i!==s?m=1:r!==o||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=jp(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<=o||m&&g<=s?void 0:(h.push(c),{word:c,wordWithBlanks:u,words:h,score:e*n+t+(7===a?50:0),coord:v})}calcCrossScore(e,t,n,i){let r,s=0,o=!1,a=t,l=e,c="";for(;null!==this.tileAt(l-n,a-i);)a-=i,l-=n;for(;null!==(r=this.tileAt(l,a));){let u=r.score;a===t&&l===e?u*=this.letterScore(l,a):o=!0,c+=r.letter,s+=u,a+=i,l+=n}return o?{score:s*this.wordScore(e,t),word:c}:{score:-1,word:""}}tileAt(e,t){const n=jp(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,o=t;for(;s>=0&&s<sp&&o>=0&&o<sp;){const e=jp(s,o);if(e&&!(e in this.tiles))return e;s+=r,o+=i}return null}canContinueInDirection(e,t){const n=Fp(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=rp.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,o="V"===n?1:0;return this.findNextEmptySquare(i+o,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 kf extends _f{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=yf[this.board_type],this.startCoord=wf[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(),this.populateRackTiles(),vf.ingestTwoLetterWords(this.locale,this.two_letter_words[0])):super.init()}applyOpponentMove(e){const t=this.localturn,n=this.savePlayerTiles();this.applyServerState(e)&&(this.placeTiles(),!t&&this.localturn?this.restorePlayerTiles(n):this.populateRackTiles())}initMockupGame(){this.tiles={},this.startSquare=yf[this.board_type],this.startCoord=wf[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}}vf.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 np(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,Ud.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),o=Math.floor(s/60),a=Math.floor(s-60*o);return i?(this.penalty0=0,this.penalty1=0):r<0&&(0===e?this.penalty0=-10*Math.floor((60*o+a+59)/60):this.penalty1=-10*Math.floor((60*o+a+59)/60)),(r<0?"-":"")+`0${o.toString()}`.slice(-2)+":"+`0${a.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 np(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 np(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 np(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=Fp(t);let s=r.col,o=r.row,a=!1,l=0;for(let t=0;t<n.length;t++){let c=n[t];if("?"===c){a=!0;continue}const u=jp(o,s);if(null===u)continue;const h=c;a&&(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&&(e===this.player?this.tiles[u].highlight=0:1-e===this.player&&(this.tiles[u].highlight=1),l++)),s+=r.dx,o+=r.dy,a=!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 rp){let n="";for(let e=0;e<sp;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){this.tiles={},this.numTileMoves=0;const n=this.moves,i=void 0!==e,r=!i&&!this.lastmove&&this.localturn,s=!t&&(r||i),o=void 0!==e?e:n.length;function a(e){if(e+2>=o)return!1;const[t,[i,r,s]]=n[e+2];return""===i&&("RESP"===r&&s<0)}for(let e=0;e<o;e++){const[t,[i,r]]=n[e];""===i||a(e)||(this.placeMove(t,i,r,e===o-1&&s),this.numTileMoves++)}const l=this.lastmove;if(l&&this.localturn&&!this.succ_chall)for(let e=0;e<l.length;e++){const t=l[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}}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 np(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 np(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;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 Cf="gata_";function Sf(e,t){return`${Cf}${t}_${e}`}function Tf(e,t,n){if(!e||!t)return;const i={date:t,moves:n,timestamp:(new Date).toISOString(),userId:e};try{const n=Sf(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(Cf)){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 If extends _f{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 np(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,vf.ingestTwoLetterWords(this.locale,this.two_letter_words[0]),n.netskraflUserId)){const t=function(e,t){if(!e||!t)return[];try{const n=Sf(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 np(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(Tf(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}=Fp(t),o=[];for(let e=1;e<=7;e++){const t=`R${e}`;t in this.tiles&&o.push(t)}let a=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=jp(a,l);if(!i)return;const u=this.tileAt(a,l);if(u&&!u.draggable){if(u.letter!==t)return}else{if(0===o.length)return;let e=!1;for(let r=0;r<o.length;r++){const s=o[r],a=this.tiles[s];if(a){const l="?"===a.tile?" ":a.tile;if(n){if("?"===a.tile){a.letter=t,this.tiles[i]=a,delete this.tiles[s],o.splice(r,1),e=!0;break}}else if(l===t){this.tiles[i]=a,delete this.tiles[s],o.splice(r,1),e=!0;break}}}if(!e)return}a+=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=jp(t,e);if(!i||!r)continue;const s=i.toLowerCase(),o=s!==i;if(this.alphabet.includes(s)){const e=o?0:this.tile_scores[s]||1;this.tiles[r]={player:0,tile:o?"?":s,letter:s,score:e,freshtile:!1,draggable:!1,index:-1,xchg:!1}}}}}cleanup(){super.cleanup()}}function Ef(){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 Pf{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,wp(t.locale)}async post(e,t){if(!this.state)throw new Error("Model state is not initialized");return np(this.state,{method:"POST",url:e,body:t})}async getText(e){if(!this.state)throw new Error("Model state is not initialized");return np(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 np(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 ip(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 kf(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 Ud.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++;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):(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,a(n)),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),Ud.redraw())}handleUserMoveMessage(e,t){!t&&this.state&&e&&(this.loadingGameList||(this.gameList=null,Ud.redraw()))}handleMoveMessage(e,t){!t&&this.game&&(this.game.update(e),this.state.audio&&null!==this.game.player&&!this.game.isRobotGame()&&Ap(this.state,"your-turn"),Ud.redraw())}notifyMove(){this.loadingGameList||(this.gameList=null)}notifyGameWon(){this.user?.fanfare&&Ap(this.state,"you-win")}moreGamesAllowed(){if(!this.state)return!1;if(this.loadingGameList)return!1;if(!this.gameList)return!0;return!(this.gameList.length>=50)&&(!!this.state.hasPaid||this.gameList.length<this.maxFreeGames)}async initRiddle(e,t){this.riddle=new If(`gatadagsins-${e}`,e,this),await this.riddle.load(e,t)}}const xf=()=>{let e=!1;return{view:t=>{const{view:n,item:i}=t.attrs,r=n.model.state;if(!r)return;const s=""!==r.plan,o=i.fairplay&&r.fairPlay;return Ud(".modal-dialog",{id:"chall-dialog",style:{visibility:"visible"}},Ud(".ui-widget.ui-widget-content.ui-corner-all",{id:"chall-form"},[Ud(".chall-hdr",Ud("table",Ud("tbody",Ud("tr",[Ud("td",Ud("h1.chall-icon",xp("hand-right"))),Ud("td.l-border",[Ud(rg,{id:"chall-online",userId:i.userid,state:r}),Ud("h1",i.nick),Ud("h2",i.fullname)])])))),Ud("div",{style:{"text-align":"center"}},[Ud(".promo-fullscreen",[kp("p",[kp("strong","Ný áskorun")," - veldu lengd viðureignar:"]),Ud(ag,{initialSelection:0,defaultClass:"chall-time"},[Ud("div",{id:"chall-none",tabindex:1},bp("Viðureign án klukku")),Ud("div",{id:"chall-10",tabindex:2},[xp("time"),bp("2 x 10 mínútur")]),Ud("div",{id:"chall-15",tabindex:3},[xp("time"),bp("2 x 15 mínútur")]),Ud("div",{id:"chall-20",tabindex:4},[xp("time"),bp("2 x 20 mínútur")]),Ud("div",{id:"chall-25",tabindex:5},[xp("time"),bp("2 x 25 mínútur")]),r?.runningLocal?Ud("div",{id:"chall-3",tabindex:6},[xp("time"),bp("2 x 3 mínútur")]):Ud("div",{id:"chall-30",tabindex:6},[xp("time"),bp("2 x 30 mínútur")])])]),Ud(".promo-mobile",[Ud("p",kp("strong","Ný áskorun")),Ud(".chall-time.selected",{id:"extra-none",tabindex:1},bp("Viðureign án klukku"))])]),s?Ud("div",{id:"chall-manual"},[kp("span.caption.wide",["Nota ",kp("strong","handvirka véfengingu"),Ud("br"),'("keppnishamur")']),Ud(".toggler[id='manual-toggler'][tabindex='7']",{onclick:t=>{e=!e,t.preventDefault()}},[Ud(".option"+(e?"":".selected"),Ud("span",Lp())),Ud(".option"+(e?".selected":""),xp("lightbulb"))])]):"",o?Ud("div",{id:"chall-fairplay"},[bp("Báðir leikmenn lýsa því yfir að þeir skrafla "),Ud("br"),kp("strong","án stafrænna hjálpartækja"),bp(" af nokkru tagi"),"."]):"",Ud(tg,{id:"chall-cancel",title:_p("Hætta við"),tabindex:8,onclick:e=>{n.popDialog(),e.preventDefault()}},xp("remove")),Ud(tg,{id:"chall-ok",title:_p("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:o,manual:e}),n.popDialog(),t.preventDefault()}},xp("ok"))]))}}},Rf=e=>{const{view:t}=e.attrs,{model:n}=t;return{view:()=>{if(!n.state)return;const e=n.state;return Ud(".modal-dialog",{id:"promo-dialog",style:{visibility:"visible"}},Ud(".ui-widget.ui-widget-content.ui-corner-all",{id:"promo-form"},[Ud(".promo-content",[Ud("h2",[xp("coffee-cup"),Lp(),"Komdu í áskrift að Netskrafli!"]),Ud("p","Með áskrift að Netskrafli færðu aðgang að öllu því sem leikurinn hefur að bjóða:"),Ud("ul",[Ud("li",["Sem áskrifandi getur þú haft ",Ud("b","ótakmarkaðan fjölda viðureigna")," í gangi samtímis (í stað ",Ud("b",8..toString())," að hámarki)."]),Ud("li",["Sem áskrifandi hefur þú aðgang að ",Ud("b","yfirliti")," í lok hverrar viðureignar þar sem hún er rakin leik fyrir leik ","og bestu möguleikar í hverri stöðu sýndir."]),Ud("li",["Sem áskrifandi getur þú skorað á aðra leikmenn í ",Ud("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ð.)"]),Ud("li",["Þú getur líka gerst áskrifandi að ",Ud("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."])]),Ud("p",kp("strong","Komdu með — og styrktu íslenska máltækni í leiðinni!"))]),Ud(".btn-promo-yes",{id:"friend-yes",title:_p("Gerast áskrifandi"),tabindex:1,onclick:t=>{t.preventDefault(),fh("click_friend",{userid:e.netskraflUserId,locale:e.locale}),window.location.href=e.subscriptionUrl}},[xp("ok"),Lp(),_p("Gerast áskrifandi")]),Ud(".btn-promo-no",{id:"friend-no",title:_p("Hætta við"),tabindex:2,onclick:e=>{t.popDialog(),e.preventDefault()}},[xp("remove"),Lp(),_p("Nei, takk")])]))}}},Lf=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(Ud(".chall-info",[xp("info-sign"),Lp(),kp("span.pass-explain","opponent_emptied_rack")])),"resign"===e.showingDialog&&t.push(Ud(".resign",[xp("exclamation-sign"),Lp(),_p("Viltu gefa leikinn?"),Lp(),Ud("span.mobile-break",Ud("br")),Ud("span.yesnobutton",{onclick:()=>e.confirmResign(!0)},[xp("ok"),_p(" Já")]),Ud("span.mobile-space"),Ud("span.yesnobutton",{onclick:()=>e.confirmResign(!1)},[xp("remove"),_p(" Nei")])])),"pass"===e.showingDialog&&(e.last_chall?t.push(Ud(".pass-last",[xp("forward"),Lp(),_p("Segja pass?"),kp("span.pass-explain","Viðureign lýkur þar með"),Lp(),Ud("span.mobile-break",Ud("br")),Ud("span.yesnobutton",{onclick:()=>e.confirmPass(!0)},[xp("ok"),_p(" Já")]),Ud("span.mobile-space"),Ud("span.yesnobutton",{onclick:()=>e.confirmPass(!1)},[xp("remove"),_p(" Nei")])])):t.push(Ud(".pass",[xp("forward"),Lp(),_p("Segja pass?"),kp("span.pass-explain","2x3 pöss í röð ljúka viðureign"),Lp(),Ud("span.mobile-break",Ud("br")),Ud("span.yesnobutton",{onclick:()=>e.confirmPass(!0)},[xp("ok"),_p(" Já")]),Ud("span.mobile-space"),Ud("span.yesnobutton",{onclick:()=>e.confirmPass(!1)},[xp("remove"),_p(" Nei")])]))),"exchange"===e.showingDialog&&t.push(Ud(".exchange",[xp("refresh"),Lp(),_p("Smelltu á flísarnar sem þú vilt skipta"),Lp(),Ud("span.mobile-break",Ud("br")),Ud("span.yesnobutton",{title:_p("Skipta"),onclick:()=>e.confirmExchange(!0)},xp("ok")),Ud("span.mobile-space"),Ud("span.yesnobutton",{title:_p("Hætta við"),onclick:()=>e.confirmExchange(!1)},xp("remove"))])),"chall"===e.showingDialog&&t.push(Ud(".chall",[xp("ban-circle"),Lp(),_p("Véfengja lögn?"),kp("span.pass-explain","Röng véfenging kostar 10 stig"),Lp(),Ud("span.mobile-break",Ud("br")),Ud("span.yesnobutton",{onclick:()=>e.confirmChallenge(!0)},[xp("ok"),_p(" Já")]),Ud("span.mobile-space"),Ud("span.yesnobutton",{onclick:()=>e.confirmChallenge(!1)},[xp("remove"),_p(" Nei")])]))),t}}},Nf=()=>({view:e=>{const{bag:t,newbag:n}=e.attrs;let i="";return t.length<=7?i+=".empty":n&&(i+=".new"),Ud(".bag",{title:_p("Flísar sem eftir eru")},Ud(`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="&nbsp;"),r.push(Ud("td",Ud.trust(t))),i--}t.push(Ud("tr",r))}return t}(t)))}}),Df=[{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"}],Af=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 o=null;function a(e,t){const n=s(e);let i=null;if(null===o||(r=o,a=n,Math.round((a-r)/1e3)>=300)){const r=864e5,s=Date.now(),o=s-s%r;let a;a=n<o-r?e.slice(0,-3):n<o?`Í gær ${e.slice(11,16)}`:e.slice(11,16),i=Ud(".chat-ts",{key:t},a)}var r,a;return o=n,i}const l=i?i.player:null;function c(e){if(!r)return e;for(const t of Df)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=a(n.ts,t);null!==s&&(e.push(s),t++);let o=Np(n.msg);o=c(o),e.push(Ud(".chat-msg"+(0===i?".left":".right")+(i===l?".local":".remote"),{key:t++},Ud.trust(o)))}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=Dp("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:()=>Ud(".chat-container",{style:"z-index: 6"},[Ud(".chat-area"+(i?.showClock()?".with-clock":""),{id:"chat-area",oncreate:h,onupdate:h},u()),Ud(".chat-input",[Ud("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())}}),Ud(tg,{id:"chat-send",title:_p("Senda"),onclick:e=>{p(),e.preventDefault()}},xp("chat"))])])}},Mf=()=>{function e(e,t,n,i,r){const s=Fp(t);let o=s.col,a=s.row;for(const t of n){if("?"===t)continue;const n=jp(a,o);n&&n in e.tiles&&(e.tiles[n].highlight=r?i:void 0),o+=s.dx,a+=s.dy}}function t(t,n,i){const{game:r,state:s}=t.model;if(!r||!s)return null;const{leftTotal:o,rightTotal:a,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=` ${_p("Pass")} `,h="";else if(0===u.indexOf("EXCH")){const e=u.slice(5).length,t=_p(1===e?"letter":"letters");u=" "+_p("exchanged",{numtiles:e.toString(),letters:t})+" ",h=""}else"RSGN"===u?u=` ${_p("Gaf viðureign")} `:"CHALL"===u?(u=` ${_p("Véfengdi lögn")} `,h=""):"RESP"===u?h<0?(u=` ${_p("Óleyfileg lögn")} `,g=-1):u=` ${_p("Röng véfenging")} `:"TIME"===u?u=` ${_p("Umframtími")} `:"OVER"===u?(u=_p("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 Ud(".move.gameover",[Ud("span.gameovermsg",i),Ud("span.statsbutton",{onclick:i=>{i.preventDefault(),n.hasPaid?(Ud.route.set(`/review/${t.uuid}`),null!=t&&fh("game_review",{locale:t.locale,uuid:t.uuid})):(fh("click_review",{userid:n.netskraflUserId,locale:n.locale}),e.showFriendPromo())}},bp("Skoða yfirlit"))])}(t,r,s,u);const f=g>0&&!r.manual?_p("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?Ud(`.move.leftmove.${y}`,w,[Ud("span.total"+(l===v?".human":".autoplayer"),o),Ud("span.score"+(n[2]?".highlight":""),h),Ud(`span.${d}`,[Ud("i",u),Lp(),c])]):Ud(`.move.rightmove.${y}`,w,[Ud(`span.${d}`,[c,Lp(),Ud("i",u)]),Ud("span.score"+(n[2]?".highlight":""),h),Ud("span.total"+(l===v?".human":".autoplayer"),a)])}return{view:e=>{const{view:n,move:i,info:r}=e.attrs;return t(n,i,r)}}},Of=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],o=t.nickname[0],a=t.nickname[1],l=t.player,c=t.localturn,u=t.over;if("left"===e.attrs.side){if(r)return Ud(".robot-btn.left",[xp("cog"),Lp(),o]);return Ud(`.player-btn.left${u||c!==(0===l)?"":".tomove"}`,{id:"player-0",onclick:e=>i(t,e,l,0)},[Ud("span.left-to-move"),o])}if(s)return Ud(".robot-btn.right",[xp("cog"),Lp(),a]);return Ud(`.player-btn.right${u||c!==(1===l)?"":".tomove"}`,{id:"player-1",onclick:e=>i(t,e,l,1)},[Ud("span.right-to-move"),a])}}},jf=e=>{const t=e.attrs.view.model;let n=0;return{view:()=>{if(!t.game)return;const e=t.game,i=e.twoLetterWords()[n],r=[];for(const e of i){const t=e[1],i=[];for(let e=0;e<t.length;e++)i.push((s=0===e,o=t[e],Ud(".twoletter-word",s?0===n?[Ud("b",o[0]),o[1]]:[o[0],Ud("b",o[1])]:o)));r.push(Ud(".twoletter-group",i))}var s,o;return Ud(".twoletter",{onclick:()=>{n=1-n},style:"z-index: 6"},Ud(".twoletter-area"+(e.showClock()?".with-clock":""),{title:_p(0===n?"Smelltu til að raða eftir seinni staf":"Smelltu til að raða eftir fyrri staf")},r))}}},Ff=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 o=e[i],[a,[l,c,u]]=o;0===a?r=Math.max(r+u,0):s=Math.max(s+u,0);const h=Ud(Mf,{view:t,move:o,info:{leftTotal:r,rightTotal:s,player:a,co:l,tiles:c,score:u}});n.push(h)}return n}const o=i?i.bag:"",a=!i||i.newbag;return{view:()=>Ud(".movelist-container",[Ud(".movelist",{onupdate:()=>{setTimeout(Op)}},s()),r?.uiFullscreen?"":Ud(Nf,{bag:o,newbag:a})])}},Uf=e=>{const t=e.attrs.view.model;return{view:()=>Ud(".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?[xp("cog"),Lp(),t.opp]:[t.opp];const i=t.sc0<t.sc1?".losing":"",s=`Staðan er ${t.sc0}:${t.sc1}`;e.push(Ud(".games-item"+(t.timed?".game-timed":""),{key:t.uuid,title:s},Ud(Ud.route.Link,{href:Mp(t.url)},[Ud(".at-top-left",Ud(".tilecount",Ud(".oc",n))),Ud(".at-top-left",Ud(".tilecount.trans",Ud(`.tc${i}`,{style:{width:`${t.tile_count.toString()}%`}},n)))])))}return e}())}},zf={view:e=>{const{view:t,tabid:n,title:i,icon:r,alert:s,funcSel:o}=e.attrs,a=t.selectedTab||"movelist",l=t.model.game;return Ud(".right-tab"+(a===n?".selected":""),{id:`tab-${n}`,className:s?"chat-alert":"",title:i,onclick:e=>{l&&null===l.showingDialog&&t.setSelectedTab(n)&&(o?.(),"movelist"===n&&setTimeout(Op)),e.preventDefault()}},xp(r))}},$f={view:e=>{const{view:t}=e.attrs,{game:n}=t.model,i=n&&!n.isRobotGame()&&null!==n.player,r=[Ud(zf,{view:t,tabid:"board",title:_p("Borðið"),icon:"grid"}),Ud(zf,{view:t,tabid:"movelist",title:_p("Leikir"),icon:"show-lines"}),Ud(zf,{view:t,tabid:"twoletter",title:_p("Tveggja stafa orð"),icon:"life-preserver"}),Ud(zf,{view:t,tabid:"games",title:_p("Viðureignir"),icon:"flag"})];return i&&r.push(Ud(zf,{view:t,tabid:"chat",title:_p("Spjall"),icon:"conversation",funcSel:()=>{n.markChatShown()&&Ud.redraw()},alert:!n.chatSeen&&"chat"!==t.selectedTab})),Ud.fragment({},r)}},qf=e=>{const{view:t}=e.attrs,{model:n}=t,{game:i}=n;function r(){if(!i||!i.showClock())return Ud.fragment({},[]);function e(e,t,n,i){return Ud("h3."+e+(n?".running-out":"")+(i?".blink":""),t)}return Ud.fragment({},[e("clockleft",i.clockText0,i.runningOut0,i.blinking0),e("clockright",i.clockText1,i.runningOut1,i.blinking1),Ud(".clockface",xp("time"))])}function s(){const e=!!i&&i.fairplay,n=i?i.player:null,s=i?i.displayScore(0).toString():"",o=i?i.displayScore(1).toString():"";return Ud(".heading",[Ud(".logowrapper",Ud(ug)),Ud(".playerwrapper",[Ud(".leftplayer"+(1===n?".autoplayercolor":".humancolor"),[Ud(".player",Ud(Of,{view:t,side:"left"})),Ud(".scorewrapper",Ud(".scoreleft",s))]),Ud(".rightplayer"+(1===n?".humancolor":".autoplayercolor"),[Ud(".player",Ud(Of,{view:t,side:"right"})),Ud(".scorewrapper",Ud(".scoreright",o))]),Ud(".fairplay",{style:{visibility:e?"visible":"hidden"}},Ud("span.fairplay-btn.large",{title:_p("Skraflað án hjálpartækja")}))]),r()])}function o(){if(!i)return;let e;switch(t.selectedTab||"movelist"){case"movelist":e=Ud(Ff,{view:t});break;case"twoletter":e=Ud(jf,{view:t});break;case"chat":e=Ud(Af,{view:t});break;case"games":e=Ud(Uf,{view:t})}const n=Ud($f,{view:t});return Ud(".right-area"+(i?.showClock()?".with-clock":""),e?[n,e]:[n])}return{view:()=>Ud(".rightcol",[s(),o()])}},Vf={view:e=>{const{view:t}=e.attrs,{model:n}=t,{game:i,state:r}=n;if(!i)return Ud("div",[Ud(".game-container"),Ud(cg)]);const{bag:s,newbag:o}=i;return Ud("div.drop-target",{id:"board-background"},[Ud(".game-container",[Ud(qf,{view:t}),Ud(Mg,{view:t,game:i}),r?.uiFullscreen?Ud(Nf,{bag:s,newbag:o}):"",i.askingForBlank?Ud(yg,{game:i}):""]),Ud(cg),r?.beginner?Ud(Vp,{view:t,showClose:!0}):"",Ud(lg)])}},Bf=()=>({view:e=>{const t=e.attrs.ownStats||{},n=[];if(t.highest_score&&(n.push(_p("Hæsta skor ")),n.push(Ud("b",Ud(Ud.route.Link,{href:`/game/${t.highest_score_game}`},t.highest_score)))),t.best_word){n.length&&(e.attrs.myself?n.push(Ud("br")):n.push(" | "));const i=t.best_word,r=[];for(let e=0;e<i.length;e++)"?"===i[e]?(r.push(Ud("span.netskrafl-blanktile",i[e+1])),e+=1):r.push(i[e]);n.push(_p("Besta orð ")),n.push(Ud("span.best-word",r)),n.push(", "),n.push(Ud("b",Ud(Ud.route.Link,{href:`/game/${t.best_word_game}`},t.best_word_score))),n.push(_p(" stig"))}return Ud("p",{id:e.attrs.id},n)}}),Hf=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 o(e){if(e.preventDefault(),!r.moreGamesAllowed()){const e=r.state;return e&&fh("hit_game_limit",{userid:e.netskraflUserId,locale:e.locale,limit:r.maxFreeGames}),void 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,a=(l=n.prefs)&&void 0!==l.duration&&0!==l.duration?bp("with_clock",{duration:l.duration.toString()}):bp("Venjuleg ótímabundin viðureign");var l;return Ud(".listitem"+(i%2==0?".oddlist":".evenlist"),[Ud("span.list-ch",{onclick:s},n.received?xp("thumbs-down",{title:_p("Hafna")}):xp("hand-right",{title:_p("Afturkalla")})),Ud(r?"a.flex":"span.flex",r?{href:"#",onclick:o,class:e?"opp-ready":""}:{},[Ud("span.list-ts",n.ts),Ud("span.list-nick",{title:n.fullname},n.opp),Ud("span.list-chall",[n.prefs.fairplay?Ud("span.fairplay-btn",{title:_p("Án hjálpartækja")}):"",n.prefs.manual?Ud("span.manual-btn",{title:_p("Keppnishamur")}):"",a])]),Ud(ig,{view:t,item:{userid:n.userid,nick:n.opp,fullname:n.fullname}})])}}},Wf={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=Ud("div",{id:n?"chall-received":"chall-sent"},r.map(((e,n)=>Ud(Hf,{view:t,item:e,i:n}))));return n?[Ud(".listitem.listheader",[Ud("span.list-icon",Rp("thumbs-down",{title:_p("Hafna")})),kp("span.list-ts","Hvenær"),kp("span.list-nick","Áskorandi"),kp("span.list-chall","Hvernig"),kp("span.list-info-hdr","Ferill")]),s]:[Ud(".listitem.listheader",[Ud("span.list-icon",Rp("hand-right",{title:_p("Afturkalla")})),kp("span.list-ts","Hvenær"),kp("span.list-nick","Andstæðingur"),kp("span.list-chall","Hvernig"),kp("span.list-info-hdr","Ferill")]),s]}},Gf={view:e=>{const{loadingGameList:t,loadingAllLists:n,gameList:i}=e.attrs;return t||n||null!==i&&i.length>0?"":Ud(".hint",{style:{display:"block"}},[Ud("p",["Ef þig vantar einhvern til að skrafla við, veldu flipann ",Ud(Ud.route.Link,{href:"/main?tab=2"},[xp("user"),Lp(),"Andstæðingar"])," og skoraðu á tölvuþjarka - ",xp("cog"),Lp(),Ud("b","Amlóða"),", ",xp("cog"),Lp(),Ud("b","Miðlung")," eða ",xp("cog"),Lp(),Ud("b","Fullsterkan")," - eða veldu þér annan leikmann úr stafrófs­listunum sem þar er að finna til að skora á."]),Ud("p",["Þú stofnar áskorun með því að smella á bendi-teiknið ",xp("hand-right",{style:{"margin-left":"6px","margin-right":"6px"}})," vinstra megin við nafn andstæðingsins."]),Ud("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."),Ud("p.no-mobile-block",[Ud(Ud.route.Link,{href:"/help"},"Hjálp")," má fá með því að smella á bláa ",xp("info-sign"),Lp(),"-",Lp(),"teiknið hér til vinstri."]),Ud("p.no-mobile-block","Þú kemst alltaf aftur í þessa aðalsíðu með því að smella á örvarmerkið efst vinstra megin við skraflborðið.")])}},Kf=()=>{function e(e){const t=null===e.oppid?[xp("cog"),Lp(),e.opp]:e.opp;return Ud("span.list-opp",{title:e.fullname},t)}function t(e){let t="",n="";return e.my_turn?t=_p("Þú átt leik"):e.zombie?(t=_p("Viðureign lokið"),n=".zombie"):(t=_p("opp_move",{opponent:e.opp}),n=".grayed"),Ud("span.list-myturn",Ud(`span.glyphicon.glyphicon-flag${n}`,{title:t}))}function n(e){return e.overdue?xp("hourglass",{title:e.my_turn?"Er að renna út á tíma":"Getur þvingað fram uppgjöf"}):Rp("hourglass")}function i(e){const t=e.sc0<e.sc1?".losing":"";return Ud(".tilecount",Ud(`.tc${t}`,{style:{width:`${e.tile_count.toString()}%`}}))}return{view:r=>{const{view:s,item:o,i:a}=r.attrs;return Ud(".listitem"+(a%2==0?".oddlist":".evenlist"),[Ud(Ud.route.Link,{href:Mp(o.url)},[t(o),Ud("span.list-overdue",n(o)),Ud("span.list-ts-short",o.ts),e(o)]),Ud(ig,{view:s,item:{userid:o.oppid,nick:o.opp,fullname:o.fullname}}),Ud("span.list-s0",o.sc0),Ud("span.list-colon",":"),Ud("span.list-s1",o.sc1),Ud("span.list-tc",i(o)),Ud(og,{manual:o.prefs?.manual})])}}},Yf=()=>({view:e=>{const{view:t,id:n}=e.attrs,{model:i}=t,{gameList:r,loadingGameList:s,loadingAllLists:o}=i;return null===r&&i.loadGameList(),[Ud(".listitem.listheader",[Ud("span.list-myturn",Rp("flag",{title:_p("Átt þú leik?")})),Ud("span.list-overdue",Rp("hourglass",{title:_p("Langt frá síðasta leik?")})),kp("span.list-ts-short","Síðasti leikur"),kp("span.list-opp","Andstæðingur"),kp("span.list-info-hdr","Ferill"),kp("span.list-scorehdr","Staða"),kp("span.list-tc","Framvinda"),Ud(og,{header:!0})]),Ud("div",{id:n},r?r.map(((e,n)=>Ud(Kf,{view:t,item:e,i:n}))):""),Ud(Gf,{loadingGameList:s,loadingAllLists:o,gameList:r})]}}),Jf=()=>{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=xp("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=xp("stroller",{title:"Byrjandi"})))),n=Ud("span",{class:`elo-btn right ${r}${""===n?" invisible":""}`},n),i=Ud("span",{class:"elo-btn left "+s+(""===i?" invisible":"")},i),Ud(".listitem"+(t%2==0?".oddlist":".evenlist"),Ud(Ud.route.Link,{href:Mp(e.url)},[Ud("span.list-win",e.sc0>=e.sc1?xp("bookmark",{title:e.sc0===e.sc1?_p("Jafntefli"):_p("Sigur")}):Rp("bookmark",{title:_p("Tap")})),Ud("span.list-ts-short",e.ts_last_move),Ud("span.list-nick",e.opp_is_robot?[xp("cog"),Lp(),e.opp]:e.opp),Ud("span.list-s0",e.sc0),Ud("span.list-colon",":"),Ud("span.list-s1",e.sc1),Ud("div.list-elo-adj",i),Ud("div.list-elo-adj",n),Ud("span.list-duration",function(){let t="";return e.prefs?.duration?t=[Ud("span.timed-btn",{title:_p("Viðureign með klukku")}),` 2 x ${e.prefs.duration}${_p(" mínútur")}`]:(e.days||e.hours||e.minutes)&&(e.days>1?t=e.days.toString()+_p(" dagar"):1===e.days&&(t=_p("1 dagur")),e.hours>0&&(t.length&&(t+=_p(" og ")),1===e.hours?t+=_p("1 klst"):t+=e.hours.toString()+_p(" klst")),0===e.days&&(t.length&&(t+=_p(" og ")),1===e.minutes?t+=_p("1 mínúta"):t+=e.minutes.toString()+_p(" mínútur"))),t}()),Ud(og,{manual:e.prefs?.manual})]))}return{view:t=>{const n=t.attrs.recentList;return Ud("div",{id:t.attrs.id},n?n.map(e):"")}}},Zf=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 Ud(".user-cat[id='user-search']",[xp("search",{id:"search",className:"search"===e?"shown":"",onclick:()=>{r="",s(),document.getElementById("search-id")?.focus()}}),Lp(),Ud("input.text.userid",{type:"text",id:"search-id",name:"search-id",maxlength:16,placeholder:_p("Einkenni eða nafn"),value:r,onfocus:()=>s(),oninput:e=>{r=`${e.target.value}`,s()}})])}}};const Xf=()=>{let e=Yg();function t(t){e=t,Jg(t)}return{view:()=>{return Ud(".settings-tab",[Ud(".settings-section",[Ud(".settings-section-title",_p("Tækisstillingar")),(n=_p("Þysja sjálfkrafa"),i=Ud(Zg,{state:e,onToggle:t,id:"autozoom",title:_p("Þysja sjálfkrafa"),size:"small"}),r=_p("autozoom_explain"),[Ud(".settings-row",[Ud("span.settings-label",n),i]),r?Ud(".settings-explain",r):null])])]);var n,i,r}}},Qf=()=>{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?[xp(t),Lp(),i]:i}return{view:n=>{var i=n.attrs.ownStats,r=0,s=0,o=0,a=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),o=Math.round((i.score??0)/i.games)),i.human_games>0&&(s=Math.round(100*(i.human_wins??0)/i.human_games),a=Math.round((i.human_score??0)/i.human_games))),Ud("div",{id:n.attrs.id},[Ud(".toggler",{id:"own-toggler",title:_p("stats_choice"),onclick:t=>{e=3-e,t.preventDefault()}},[Ud(".option.small"+(1===e?".selected":""),{id:"opt1"},xp("user")),Ud(".option.small"+(2===e?".selected":""),{id:"opt2"},xp("cog"))]),1===e?Ud("div",{id:"own-stats-human",className:"stats-box",style:{display:"inline-block"}},[Ud(".stats-fig",{title:_p("Elo-stig")},i?t(i.locale_elo?.human_elo,"crown"):""),Ud(".stats-fig.stats-games",{title:_p("Fjöldi viðureigna")},i?t(i.human_games,"th"):""),Ud(".stats-fig.stats-win-ratio",{title:_p("Vinningshlutfall")},t(s,"bookmark","%")),Ud(".stats-fig.stats-avg-score",{title:_p("Meðalstigafjöldi")},t(a,"dashboard"))]):"",2===e?Ud("div",{id:"own-stats-all",className:"stats-box",style:{display:"inline-block"}},[Ud(".stats-fig",{title:_p("Elo-stig")},i?t(i.locale_elo?.elo,"crown"):""),Ud(".stats-fig.stats-games",{title:_p("Fjöldi viðureigna")},i?t(i.games,"th"):""),Ud(".stats-fig.stats-win-ratio",{title:_p("Vinningshlutfall")},t(r,"bookmark","%")),Ud(".stats-fig.stats-avg-score",{title:_p("Meðalstigafjöldi")},t(o,"dashboard"))]):""])}}},em="/page#!";function tm(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 o=document.querySelector(`#${t} > ul`);o&&(o.setAttribute("class","ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"),o.setAttribute("role","tablist"));const a=document.querySelectorAll(`#${t} > ul > li > a`),l=document.querySelectorAll(`#${t} > ul > li`),c=[],u=[];for(let e=0;e<a.length;e++){const t=a[e].getAttribute("href");if(!t)continue;c.push(t.slice(1)),a[e].onclick=t=>{im(r,e),t.preventDefault()},a[e].removeAttribute("href"),a[e].classList.add("ui-tabs-anchor","sp"),a[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),o=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):{};Ud.route.set(r,o),window.history&&window.history.pushState({},"",t),e.preventDefault()},i=n=>{t?.state?.netskraflUserId&&e.pushDialog("userprefs",{}),n.preventDefault()},o=e=>{im(r,2),e.preventDefault()},a=e=>{im(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)===em?t.onclick=e=>n(e,r):r&&"$$userprefs$$"===r?t.onclick=i:r&&"$$twoletter$$"===r?t.onclick=o:r&&"$$newbag$$"===r&&(t.onclick=a)}}n&&n(r),nm(r)}function nm(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 im(e,t){e.state.selected=t,nm(e)}function rm(e){var t=Ud.route.param("tab");void 0!==t&&im(e,parseInt(t,10)||0)}const sm={oninit:e=>{e.state.sel=e.attrs.sel},view:e=>Ud(".toggler[id='elo-toggler']",{title:_p("elo_list_choice")},[Ud(".option.x-small",{className:"human"===e.state.sel?"selected":"",onclick:t=>{e.state.sel="human",e.attrs.onchange(e.state.sel),t.preventDefault()}},xp("user")),Ud(".option.x-small",{className:"all"===e.state.sel?"selected":"",onclick:t=>{e.state.sel="all",e.attrs.onchange(e.state.sel),t.preventDefault()}},xp("cog")),Ud(".option.x-small",{className:"manual"===e.state.sel?"selected":"",onclick:t=>{e.state.sel="manual",e.attrs.onchange(e.state.sel),t.preventDefault()}},xp("lightbulb"))])},om=e=>{const{spec:t,view:n}=e.attrs;return{view:e=>Ud("div",[Ud(".listitem.listheader",[Ud("span.list-ch",Rp("hand-right",{title:_p("Skora á")})),kp("span.list-rank","Röð"),Ud("span.list-rank-no-mobile",{title:_p("Röð í gær")},_p("1d")),Ud("span.list-rank-no-mobile",{title:_p("Röð fyrir viku")},_p("7d")),kp("span.list-nick-elo","Einkenni"),Ud("span.list-elo",{title:_p("Elo-stig")},_p("Elo")),Ud("span.list-elo-no-mobile",{title:_p("Elo-stig í gær")},_p("1d")),Ud("span.list-elo-no-mobile",{title:_p("Elo-stig fyrir viku")},_p("7d")),Ud("span.list-elo-no-mobile",{title:_p("Elo-stig fyrir mánuði")},_p("30d")),Ud("span.list-games",{title:_p("Fjöldi viðureigna")},xp("th")),Ud("span.list-ratio",{title:_p("Vinningshlutfall")},xp("bookmark")),Ud("span.list-avgpts",{title:_p("Meðalstigafjöldi")},xp("dashboard")),kp("span.list-info-hdr","Ferill"),Ud(sm,{sel:t||"human",onchange:e=>{n.actions.withSpinner((()=>n.model.loadEloRatingList(e)))}})]),Ud(am,{id:e.attrs.id,sel:t,view:e.attrs.view})])}},am=e=>{const t=e.attrs.view,n=t.model,i=n.state;return{view:e=>{const r=n.eloRatingList||[];return Ud("div",{id:e.attrs.id},r.map((function(n,r){const s=0===n.userid.indexOf("robot-");function o(e,t){return 0===e||void 0!==t&&0===t?"--":e.toString()}let a=n.nick,l=Ud("span.list-ch",Lp());const c=i?.netskraflUserId??"";return n.userid===c||n.inactive||(l=Ud(ng,{view:t,item:n})),s&&(a=Ud("span",[xp("cog"),Lp(),a])),n.fairplay&&!s&&(a=Ud("span",[Ud("span.fairplay-btn",{title:_p("Skraflar án hjálpartækja")}),a])),Ud(".listitem",{key:(e.attrs.sel||"sel")+r,className:r%2==0?"oddlist":"evenlist"},[l,Ud("span.list-rank.bold",o(n.rank)),Ud("span.list-rank-no-mobile",o(n.rank_yesterday)),Ud("span.list-rank-no-mobile",o(n.rank_week_ago)),Ud("span.list-nick-elo",{title:n.fullname},a),Ud("span.list-elo.bold",n.elo),Ud("span.list-elo-no-mobile",o(n.elo_yesterday,n.games_yesterday)),Ud("span.list-elo-no-mobile",o(n.elo_week_ago,n.games_week_ago)),Ud("span.list-elo-no-mobile",o(n.elo_month_ago,n.games_month_ago)),Ud("span.list-games.bold",n.games>=1e5?`${Math.round(n.games/1e3)}K`:n.games),Ud("span.list-ratio",`${n.ratio}%`),Ud("span.list-avgpts",n.avgpts),n.userid===c?Lp():Ud(ig,{view:t,item:n})])})))}}},lm=()=>({view:e=>{const{view:t,id:n}=e.attrs,{model:i}=t,r=i.userListCriteria?.query??"",s=i.userListCriteria?.spec??"",o=void 0===i.eloRatingSpec,a=r||"robots";if("elo"===a||o)return[Ud(om,{id:"elolist",view:t,spec:i.eloRatingSpec??null,key:"elopage"})];let l=[];void 0===i.userList||(null===i.userList||r!==a?t.actions.loadUsersByType(a,!0):l=i.userList);const c=0===l.length&&"search"===a&&""!==s,u="robots"===a;return[Ud(".listitem.listheader",[Ud("span.list-ch",Rp("hand-right",{title:_p("Skora á")})),Ud("span.list-fav",xp("star-empty",{title:_p("Uppáhald")})),kp("span.list-nick","Einkenni"),kp("span.list-fullname","Nafn og merki"),u?"":kp("span.list-human-elo[id='usr-list-elo']","Elo"),u?"":kp("span.list-info-hdr[id='usr-list-info']","Ferill")]),Ud("div",{id:n},l.map(((e,n)=>function(e,t,n){const i=0===t.userid.indexOf("robot-"),r=[];return t.ready&&!i&&(r.push(Ud("span.ready-btn",{title:_p("Álínis og tekur við áskorunum")})),r.push(Lp())),t.ready_timed&&(r.push(Ud("span.timed-btn",{title:_p("Til í viðureign með klukku")})),r.push(Lp())),t.fairplay&&(r.push(Ud("span.fairplay-btn",{title:_p("Skraflar án hjálpartækja")})),r.push(Lp())),r.push(t.fullname),Ud(".listitem"+(n%2==0?".oddlist":".evenlist"),[Ud(ng,{view:e,item:t}),i?Ud("span.list-fav",{style:{cursor:"default"}},xp("star-empty")):Ud("span.list-fav",{title:_p("Uppáhald"),onclick:n=>{e.actions.toggleFavorite(t.userid,t.fav),t.fav=!t.fav,n.preventDefault()}},xp(t.fav?"star":"star-empty")),i?Ud("a",{href:"",onclick:n=>{e.actions.startRobotGame(t.userid),n.preventDefault()}},[Ud("span.list-nick",[xp("cog"),Lp(),t.nick]),Ud("span.list-fullname-robot",r)]):[Ud("span.list-nick",t.nick),Ud("span.list-fullname",r),Ud("span.list-human-elo",t.human_elo)],Ud(ig,{view:e,item:t})])}(t,e,n)))),c?Ud("div",{id:"user-no-match",style:{display:"block"}},[xp("search")," ",Ud("span",{id:"search-prefix"},s),bp(" finnst ekki")]):void 0]}}),cm={view:e=>{const{view:t}=e.attrs,{model:n}=t,{numGames:i,numChallenges:r}=n;return[Ud(ug,{hidden:!0}),Ud("ul",[Ud("li",Ud("a[href='#tabs-1']",[xp("th"),Ud("span.tab-legend",bp("Viðureignir")),Ud("span",{id:"numgames",style:i?"display: inline-block":""},i)])),Ud("li",Ud("a[href='#tabs-2']",[xp("hand-right"),Ud("span.tab-legend",bp("Áskoranir")),Ud("span"+(n.oppReady?".opp-ready":""),{id:"numchallenges",style:r?"display: inline-block":""},r)])),Ud("li",Ud("a[href='#tabs-3']",[xp("user"),Ud("span.tab-legend",bp("Andstæðingar"))])),Ud("li",Ud("a[href='#tabs-4']",[xp("bookmark"),Ud("span.tab-legend",bp("Ferill"))])),Ud("li.mobile-only-list",Ud("a.sp.narrow[href='#tabs-5']",{title:_p("Stillingar")},[xp("cog")]))])]}},um={view:e=>{const{view:t}=e.attrs,{model:n}=t;return null===n.recentList&&n.loadRecentList(),[Ud(".listitem.listheader",[Ud("span.list-win",Rp("bookmark",{title:_p("Sigur")})),kp("span.list-ts-short","Viðureign lauk"),kp("span.list-nick","Andstæðingur"),kp("span.list-scorehdr","Úrslit"),Ud("span.list-elo-hdr",[Ud("span.glyphicon.glyphicon-user.elo-hdr-left",{title:_p("Mennskir andstæðingar")}),bp("Elo"),Ud("span.glyphicon.glyphicon-cog.elo-hdr-right",{title:_p("Allir andstæðingar")})]),kp("span.list-duration","Lengd"),Ud(og,{header:!0})]),Ud(Jf,{view:t,id:"recentlist",recentList:n.recentList||[]})]}},hm={view:e=>{const{view:t,buttonId:n,icon:i,text:r}=e.attrs,{model:s}=t,o=s.userListCriteria?.query||"robots";return Ud("span",{className:n===o?"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()}},[xp(i,{style:{padding:0}}),Lp(),r])}},dm={view:e=>{const{view:t}=e.attrs,{model:n}=t,{ownStats:i}=n;return null===i&&n.loadOwnStats(),i?Ud(Qf,{view:t,id:"own-stats",ownStats:i}):null}},pm={view:e=>{const{view:t}=e.attrs,{model:n}=t,{ownStats:i}=n;return null===i&&n.loadOwnStats(),i?Ud(Bf,{id:"own-best",ownStats:i,myself:!0}):null}},gm={view:e=>{const{view:t}=e.attrs;return Ud("div",{id:"tabs-1"},[kp("p.no-mobile-block",[kp("strong","Viðureignir sem standa yfir"),"click_on_game",xp("flag")," þú átt leik"]),Ud(Yf,{view:t,id:"gamelist"})])}},fm={view:e=>{const{view:t}=e.attrs;return Ud("div",{id:"tabs-2"},[kp("p.no-mobile-block",[kp("strong","Skorað á þig"),"click_on_challenge",xp("thumbs-down",{style:{"margin-left":"6px","margin-right":"6px"}})," til að hafna henni"]),Ud(Wf,{view:t,showReceived:!0}),kp("p.no-mobile-block",[kp("strong","Þú skorar á aðra")," - smelltu á ",xp("hand-right",{style:{"margin-left":"6px","margin-right":"6px"}})," til að afturkalla áskorun"]),Ud(Wf,{view:t,showReceived:!1})])}},mm={view:e=>{const{view:t}=e.attrs;return Ud("div",{id:"tabs-3"},[Ud("div",{id:"initials"},[Ud(".user-cat[id='user-headings']",[Ud(hm,{view:t,buttonId:"robots",icon:"cog",text:_p("Þjarkar")})," ",Ud(hm,{view:t,buttonId:"fav",icon:"star",text:_p("Uppáhalds")})," ",Ud(hm,{view:t,buttonId:"live",icon:"flash",text:_p("Álínis")})," ",Ud(hm,{view:t,buttonId:"alike",icon:"resize-small",text:_p("Svipaðir")})," ",Ud(hm,{view:t,buttonId:"elo",icon:"crown",text:_p("Topp 100")})]),Ud(Zf,{view:t})]),Ud(lm,{view:t,id:"userlist"})])}},vm={view:e=>{const{view:t}=e.attrs;return Ud("div",{id:"tabs-4"},[Ud(dm,{view:t}),Ud(pm,{view:t}),kp("p.no-mobile-block",[kp("strong","Nýlegar viðureignir þínar"),"click_to_review"]),Ud(um,{view:t})])}},ym={view:e=>{const{view:t}=e.attrs;return Ud("div",{id:"tabs-5"},[Ud(Xf,{view:t})])}},wm={view:e=>{const{view:t}=e.attrs;return Ud(".tabbed-page",Ud("div",{id:"main-tabs"},[Ud(cm,{view:t}),Ud("div.tab-scroll-area",[Ud(gm,{view:t}),Ud(fm,{view:t}),Ud(vm,{view:t}),Ud(mm,{view:t}),Ud(ym,{view:t})])]))}},bm={view:e=>{const{view:t}=e.attrs;return[Ud(cg,{hidden:!0}),Ud(sg,{view:t}),Ud(lg),Ud(dg,{view:t}),Ud(pg,{view:t}),Ud("div",{oncreate:e=>{tm(t,"main-tabs",void 0,!1,e)},onupdate:rm},Ud(wm,{view:t}))]}},_m=(e,t,n)=>{const i=e.model.game;return Ud(".movelist-container",Ud(".movelist.bestmoves",function(){const r=[];if(!i||!t||t>i.moves.length)return r;const s=i.moves[t-1],[o,a,l]=s[1];r.push(function(e,n,i){let r,s="wordmove";if(e.length>0)r=[Ud("i",n.split("?").join("")),` (${e})`];else if(s="othermove","PASS"===n)r=_p("Pass");else if(0===n.indexOf("EXCH")){const e=n.slice(5).length,t=_p(1===e?"letter":"letters");r=_p("exchanged",{numtiles:e.toString(),letters:t})}else"RSGN"===n?r=_p("Gaf viðureign"):"CHALL"===n?r=_p("Véfengdi lögn"):"RESP"===n?r=_p(i<0?"Óleyfileg lögn":"Röng véfenging"):"TIME"===n?r=_p("Umframtími"):"OVER"===n?(r=_p("Viðureign lokið"),s="gameover"):(s="othermove",r="--"===n?_p("Stafaleif: engin"):[_p("Stafaleif: "),Ud("i.upper",n)]);return Ud(".reviewhdr",[Ud("span.movenumber",`#${t}`),Ud("span",{class:s},r)])}(o,a,l));const c=n;for(let n=0;n<c.length;n++){const[i,[s,o,a]]=c[n],l=km(e,t,n,c[n],{player:i,co:s,tiles:o,score:a});l&&r.push(l)}return r}()))},km=(e,t,n,i,r)=>{const s=e.model;if(!s.game)return;const o=s.game,{player:a,co:l,tiles:c,score:u}=r;function h(e,i,r,l){const c=Fp(e);let u=c.col,h=c.row,d=!1;l&&(s.highlightedMove=n,o.placeTiles(t-1,!0));for(let e of i){if("?"===e){d=!0;continue}const t=jp(h,u);if(null===t)continue;const n=e;d&&(e="?");const i=o.tilescore(e);l&&(t in o.tiles?o.tiles[t].highlight=r:o.tiles[t]={player:a,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&&o.placeTiles(s.reviewMove))}const d=`(${l})`,p=c.split("?").join("");let g=0;const f=o.player;let m;a===f||null===f&&0===a?m="humangrad"+(0===a?"_left":"_right"):(m="autoplayergrad"+(0===a?"_left":"_right"),g=1);const v={title:"Smelltu til að fletta upp"};return"is_IS"===o.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===a?Ud(`.move.leftmove.${m}`,v,[Ud("span.score"+(i[2]?".highlight":""),u),Ud("span.wordmove",[Ud("i",p),Lp(),d])]):Ud(`.move.rightmove.${m}`,v,[Ud("span.wordmove",[d,Lp(),Ud("i",p)]),Ud("span.score"+(i[2]?".highlight":""),u)])},Cm=(e,t)=>{const n=e.model,i=n.game,r=i?.moves.length??0,s=[];if(!(i?.uuid??""))return s;if(s.push(wg("navbtn",!t,(()=>{n.loadBestMoves(t?t-1:0)}),"Sjá fyrri leik",Ud("span",{id:"nav-prev-visible"},[xp("chevron-left")," Fyrri"]),!0,"navprev")),s.push(wg("navbtn",!t||t>=r,(()=>{n.loadBestMoves(t+1)}),"Sjá næsta leik",Ud("span",{id:"nav-next-visible"},["Næsti ",xp("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,o=s?s[1][2]:void 0;let a="";if(void 0===o||null===n.bestMoves||null===n.highlightedMove);else{const e=n.bestMoves[n.highlightedMove][1][2];a=(o-e).toString(),"-"!==a[0]&&"0"!==a[0]&&(a=`+${a}`),o>=e&&r.push("posdiff")}return Ud(r.join("."),{style:{visibility:"visible"}},a)})(e,t);void 0!==n&&s.push(n)}const o=((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,o,a]]=i;if(void 0===a||""===s&&"OVER"===o)return;const l=[".score"];return t>0&&(t%2===(n.player??0)?l.push("opponent"):l.push("localplayer")),Ud(l.join("."),a.toString())})(e,t);return void 0!==o&&s.push(o),s},Sm=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 Ud(".rightcol",[function(){const i=e.fairplay,r=e.player;let s="",o="";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(),o=i.toString()}return Ud(".heading",[Ud(".logowrapper",Ud(ug)),Ud(".playerwrapper",[Ud(".leftplayer"+(1===r?".autoplayercolor":".humancolor"),[Ud(".player",Ud(Of,{view:t,side:"left"})),Ud(".scorewrapper",Ud(".scoreleft",s))]),Ud(".rightplayer"+(1===r?".humancolor":".autoplayercolor"),[Ud(".player",Ud(Of,{view:t,side:"right"})),Ud(".scorewrapper",Ud(".scoreright",o))]),Ud(".fairplay",{style:{visibility:i?"visible":"hidden"}},Ud("span.fairplay-btn.large",{title:_p("Skraflað án hjálpartækja")}))])])}(),Ud(".right-area",_m(t,n,i))])}(i,r,s)),e.push(Ud(Tm,{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"),Ud(".gamestats",{style:{visibility:"visible"}},[Ud("div",{style:{position:"relative",width:"100%"}},[Ud(".player.left",{class:i,style:{width:"50%"}},Ud(".robot-btn.left",t.autoplayer[0]?[xp("cog"),Lp(),t.nickname[0]]:t.nickname[0])),Ud(".player.right",{class:r,style:{width:"50%","text-align":"right"}},Ud(".robot-btn.right",t.autoplayer[1]?[xp("cog"),Lp(),t.nickname[1]]:t.nickname[1]))]),Ud("div",{id:"gamestarted"},[Ud("p",["Viðureignin hófst ",Ud("span",n("gamestart")),Ud("br"),"og henni lauk ",Ud("span",n("gameend"))]),t.manual?Ud("p","Leikið var í keppnisham"):""]),Ud(".statscol",{style:{clear:"left"}},[Ud("p",["Fjöldi leikja: ",Ud("span",n("moves0"))]),Ud("p",["Fjöldi bingóa: ",Ud("span",n("bingoes0"))," (bónus ",Ud("span",n("bingopoints0",0,t.stats?50*t.stats.bingoes0:0))," stig)"]),Ud("p",["Stafir lagðir niður: ",Ud("span",n("tiles0"))," (þar af ",Ud("span",n("blanks0"))," auðir)"]),Ud("p",["Meðalstig stafa (án auðra): ",Ud("span",n("average0",2))]),Ud("p",["Samanlögð stafastig: ",Ud("span",n("letterscore0"))]),Ud("p",["Margföldun stafastiga: ",Ud("span",n("multiple0",2))]),Ud("p",["Stig án stafaleifar í lok: ",Ud("span",n("cleantotal0"))]),Ud("p",["Meðalstig hvers leiks: ",Ud("span",n("avgmove0",2))]),t.manual?Ud("p",["Rangar véfengingar andstæðings x 10: ",Ud("span",n("wrongchall0"))]):"",Ud("p",["Stafaleif og frádráttur í lok: ",Ud("span",n("remaining0"))]),Ud("p",["Umframtími: ",Ud("span",n("overtime0"))]),Ud("p",["Stig: ",Ud("span",n("total0",0,t.stats?t.stats.scores[0]:0))," (",Ud("span",n("ratio0",1)),"%)"])]),Ud(".statscol",[Ud("p",["Fjöldi leikja: ",Ud("span",n("moves1"))]),Ud("p",["Fjöldi bingóa: ",Ud("span",n("bingoes1"))," (bónus ",Ud("span",n("bingopoints0",0,t.stats?50*t.stats.bingoes1:0))," stig)"]),Ud("p",["Stafir lagðir niður: ",Ud("span",n("tiles1"))," (þar af ",Ud("span",n("blanks1"))," auðir)"]),Ud("p",["Meðalstig stafa (án auðra): ",Ud("span",n("average1",2))]),Ud("p",["Samanlögð stafastig: ",Ud("span",n("letterscore1"))]),Ud("p",["Margföldun stafastiga: ",Ud("span",n("multiple1",2))]),Ud("p",["Stig án stafaleifar í lok: ",Ud("span",n("cleantotal1"))]),Ud("p",["Meðalstig hvers leiks: ",Ud("span",n("avgmove1",2))]),t.manual?Ud("p",["Rangar véfengingar andstæðings x 10: ",Ud("span",n("wrongchall1"))]):"",Ud("p",["Stafaleif og frádráttur í lok: ",Ud("span",n("remaining1"))]),Ud("p",["Umframtími: ",Ud("span",n("overtime1"))]),Ud("p",["Stig: ",Ud("span",n("total1",0,t.stats?t.stats.scores[1]:0))," (",Ud("span",n("ratio1",1)),"%)"])]),Ud(".closebtn",{id:"review-close",onclick:e=>{setTimeout((()=>{Ud.route.set(`/review/${t.uuid}`,{move:1})})),e.preventDefault()},onmouseover:Ep,onmouseout:Pp},[xp("play")," Rekja"])])})(t);n&&e.push(n)}}return Ud("div",[Ud(".game-container",e),Ud(cg),Ud(lg)])}}},Tm={view:e=>{const{view:t}=e.attrs,n=t.model.game;let i=[];if(n){i=[Ud(Og,{view:t,game:n,review:!0}),Ud(Ng,{view:t,game:n,review:!0})];const r=e.attrs.moveIndex;null!==r&&(i=i.concat(Cm(t,r)))}return Ud(".board-area",i)}},Im=(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}))},Em=(e,t,n)=>{t.versusAll!==n&&(t.versusAll=n,t.loadingRecentList=!1,Im(e,t))},Pm={oninit:e=>{const{attrs:t,state:n}=e;n.stats={},n.recentList=[],n.versusAll=!0,n.loadingRecentList=!1,n.loadingStats=!1,Im(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:o}=n;return Ud(".modal-dialog",{id:"usr-info-dialog",style:{visibility:"visible"}},Ud(".ui-widget.ui-widget-content.ui-corner-all",{id:"usr-info-form"},[Ud(".usr-info-hdr",[Ud("h1.usr-info-icon",[e.state.stats.friend?xp("coffee-cup",{title:_p("Áskrifandi")}):xp("user"),Lp()]),Ud("h1[id='usr-info-nick']",e.attrs.nick),Ud("span.vbar","|"),Ud("h2[id='usr-info-fullname']",e.attrs.fullname),Ud(".usr-info-fav",{title:_p("Uppáhald"),onclick:t=>{t.preventDefault(),i.actions.toggleFavorite(e.attrs.userid,r.favorite??!1),r.favorite=!r.favorite}},r.favorite?xp("star"):xp("star-empty"))]),Ud("p",[Ud("strong",bp("Nýjustu viðureignir")),Lp(),Ud("span.versus-cat",[Ud("span",{class:o?"shown":"",onclick:()=>{Em(t,n,!0)}},bp(" gegn öllum ")),Ud("span",{class:o?"":"shown",onclick:()=>{Em(t,n,!1)}},bp(" gegn þér "))])]),Ud(".listitem.listheader",[Ud("span.list-win",Rp("bookmark",{title:_p("Sigur")})),kp("span.list-ts-short","Viðureign lauk"),kp("span.list-nick","Andstæðingur"),kp("span.list-scorehdr","Úrslit"),Ud("span.list-elo-hdr",[Ud("span.glyphicon.glyphicon-user.elo-hdr-left",{title:_p("Mennskir andstæðingar")}),"Elo",Ud("span.glyphicon.glyphicon-cog.elo-hdr-right",{title:_p("Allir andstæðingar")})]),kp("span.list-duration","Lengd"),Ud(og,{header:!0})]),Ud(Jf,{view:i,id:"usr-recent",recentList:s}),Ud(Qf,{view:i,id:"usr-stats",ownStats:r}),Ud(Bf,{id:"usr-best",ownStats:r,myself:!1}),Ud(tg,{id:"usr-info-close",title:_p("Loka"),onclick:e=>{i.popDialog(),e.preventDefault()}},xp("ok"))]))}},xm=e=>{const{view:t}=e.attrs,{model:n}=t;function i(e){const t=(n.userErrors||{})[e]||"";return t?Ud(".errinput",[xp("arrow-up"),Lp(),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=Dp("nickname"),e.full_name=Dp("full_name"),e.audio=r("audio"),e.fanfare=r("fanfare"),e.beginner=r("beginner"),e.fairplay=r("fairplay"),n.saveUser((()=>{t.popDialog()})))}function o(e){e.dom.querySelector("#nickname").focus()}function a(e,t,n,i,r){return Ud(tg,{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 Ud(".modal-dialog",{key:"userprefs",id:"user-dialog",oncreate:o},Ud(".ui-widget.ui-widget-content.ui-corner-all",{id:"user-form"},[Ud(".loginhdr",[xp("address-book"),` ${_p("player_info")}`]),Ud("div",Ud("form",{action:"",id:"frm1",method:"post",name:"frm1"},[Ud(".dialog-spacer",[Ud("span.caption",bp("Einkenni:")),Ud(eg,{initialValue:e.nickname||"",class:"username",maxlength:15,id:"nickname"}),Lp(),Ud("span.asterisk","*")]),Ud(".explain",bp("Verður að vera útfyllt")),i("nickname"),Ud(".dialog-spacer",[Ud("span.caption",bp("Fullt nafn:")),Ud(eg,{initialValue:e.full_name||"",class:"fullname",maxlength:32,id:"full_name",autocomplete:"name"})]),Ud(".explain",bp("Valfrjálst - sýnt í notendalistum Netskrafls")),i("full_name"),Ud(".dialog-spacer",[Ud("span.caption.sub",bp("Hljóðmerki:")),Ud(gg,{view:t,state:e.audio,tabindex:4}),Ud("span.subcaption",bp("Lúðraþytur eftir sigur:")),Ud(fg,{view:t,state:e.fanfare,tabindex:5})]),Ud(".explain",bp("explain_sound")),Ud(".dialog-spacer",[Ud("span.caption.sub",bp("Sýna reitagildi:")),Ud(mg,{view:t,state:e.beginner,tabindex:6}),kp(".subexplain",["Stillir hvort ",kp("strong","minnismiði")," um margföldunargildi reita er sýndur við borðið"])]),Ud(".dialog-spacer",[Ud("span.caption.sub",bp("Án hjálpartækja:")),Ud(vg,{view:t,state:e.fairplay,tabindex:7}),kp(".subexplain",["no_helpers",kp("strong","án stafrænna hjálpartækja")," af nokkru tagi"])])])),a("user-ok",_p("Vista"),s,xp("ok"),8),a("user-cancel",_p("Hætta við"),(e=>{t.popDialog(),e.preventDefault()}),xp("remove"),9),e.friend?a("user-unfriend",_p("Þú ert áskrifandi!"),(e=>{e.preventDefault()}),[xp("coffee-cup"),_p("Þú ert áskrifandi!")],10):a("user-friend",_p("Gerast áskrifandi"),(e=>{e.preventDefault(),fh("click_friend",{userid:r.netskraflUserId,locale:r.locale}),window.location.href=r.subscriptionUrl}),[xp("coffee-cup"),Lp(),Lp(),_p("Gerast áskrifandi")],11)]))}}},Rm={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:o}=i,a=o.state,l=o.state?.netskraflUserId??"";if(!l||!r)return;n.firebasePath=`user/${l}/wait/${r}`;(async()=>{try{if(s&&a){const e=await np(a,{method:"POST",url:"/initwait",body:{opp:r,key:s}});e?.online&&e.waiting&&(n.oppOnline=!0)}}catch(e){}})(),ph(n.firebasePath,(e=>{!0!==e&&e.game&&(n.pointOfNoReturn=!0,gh(n.firebasePath),Ud.route.set(`/game/${e.game}`))}))},view:e=>{const{attrs:t,state:n}=e,{view:i,oppId:r,duration:s,challengeKey:o,oppNick:a,oppName:l}=t,{model:c}=i,u=c.state,h=c.state?.netskraflUserId??"";if(!u)return null;return Ud(".modal-dialog",{id:"wait-dialog",style:{visibility:"visible"}},Ud(".ui-widget.ui-widget-content.ui-corner-all",{id:"wait-form"},[Ud(".chall-hdr",Ud("table",Ud("tbody",Ud("tr",[Ud("td",Ud("h1.chall-icon",xp("time"))),Ud("td.l-border",[Ud(rg,{id:"chall-online",userId:r,online:n.oppOnline,state:u}),Ud("h1",a),Ud("h2",l)])])))),Ud(".wait-explain",[kp("p",["Þú ert reiðubúin(n) að taka áskorun um viðureign með klukku,"]),Ud("p",[Ud("strong",["2 x ",s.toString(),_p(" mínútur.")])]),kp("p",["Beðið er eftir að áskorandinn ",Ud("strong",a)," sé ",n.oppOnline?"":kp("span#chall-is-online","álínis og "),"til í tuskið."]),kp("p","Leikur hefst um leið og áskorandinn bregst við. Handahóf ræður hvor byrjar."),kp("p","Ef þér leiðist biðin geturðu hætt við og reynt aftur síðar.")]),Ud(tg,{id:"wait-cancel",title:_p("Hætta við"),onclick:e=>{n.pointOfNoReturn||(n.firebasePath&&gh(n.firebasePath),(async()=>{if(u)try{np(u,{method:"POST",url:"/cancelwait",body:{user:h,opp:r,key:o}})}catch(e){}})(),i.popDialog()),e.preventDefault()}},xp("remove"))]))}},Lm={oninit:async e=>{const{attrs:t,state:n}=e,{view:i,oppId:r,challengeKey:s}=t,o=i.model.state;if(o){n.oppReady=!0;try{const e=await np(o,{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 Ud(".modal-dialog",{id:"accept-dialog",style:{visibility:"visible"}},Ud(".ui-widget.ui-widget-content.ui-corner-all",{id:"accept-form"},[Ud(".chall-hdr",Ud("table",Ud("tbody",Ud("tr",[Ud("td",Ud("h1.chall-icon",xp("time"))),Ud("td.l-border",Ud("h1",r))])))),Ud("div",{style:{"text-align":"center","padding-top":"32px"}},[Ud("p",kp("strong","Viðureign með klukku")),kp("p",n.oppReady?"Athuga hvort andstæðingur er reiðubúinn...":["Andstæðingurinn ",Ud("strong",r)," er ekki reiðubúinn"])]),Ud(tg,{id:"accept-cancel",title:_p("Reyna síðar"),onclick:e=>{i.popDialog(),e.preventDefault()}},xp("remove"))]))}};class Nm{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(Ud(bm,{key:"main",view:this}));break;case"game":n.push(Ud(Vf,{key:"game",view:this}));break;case"review":n.push(Ud(Sm,{key:"review",view:this}));break;case"help":n.push(this.vwHelp(parseInt(Ud.route.param("tab")||"",10),parseInt(Ud.route.param("faq")||"",10)));break;default:return[Ud("div",{key:"error"},bp("Þessi vefslóð er ekki rétt"))]}for(const e of this.dialogStack){const t=Nm.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(Ud(Qp,{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}),Ud.redraw()}popDialog(){this.dialogStack.length>0&&(this.dialogStack.pop(),Ud.redraw())}popAllDialogs(){this.dialogStack.length>0&&(this.dialogStack=[],Ud.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(Op):this.setSelectedTab("board"),this.popAllDialogs()}notifyChatMessage(){Ud.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(!Yg())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=Fp(e),r=jp(Math.max(0,i.row-3),Math.max(0,i.col-3)),s=document.getElementById(`sq_${r}`),o=s?.getBoundingClientRect(),a=t.getBoundingClientRect();if(o&&a){const e=t.clientWidth,i=t.clientHeight,r=n.offsetWidth*op-e,s=n.offsetHeight*op-i,l=Math.min(o.left-a.left,r),c=Math.min(o.top-a.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",{})}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&&zp(),!0)}vwTabsFromHtml(e,t,n,i){return e?Ud("div.help-tabs",{oncreate:e=>{tm(this,t,i,!0,e)},oninit:e=>{e.state.selected=n||1}},Ud.trust(e)):""}vwHelp(e,t){const n=this.model;return Ud.fragment({key:"help"},[Ud(cg),Ud(sg,{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)||(im(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?Ud(xm,{key:"userprefs",view:this}):Ud.fragment({key:"userprefs-empty"},[])}vwWait(e){return Ud(Rm,{key:`wait-${e.challengeKey}`,view:this,oppId:e.oppId,oppNick:e.oppNick,oppName:e.oppName,duration:e.duration,challengeKey:e.challengeKey})}vwAccept(e){return Ud(Lm,{key:`accept-${e.challengeKey}`,view:this,oppId:e.oppId,oppNick:e.oppNick,challengeKey:e.challengeKey})}vwDialogs(){return Ud(Lf,{view:this})}}Nm.dialogViews={userprefs:e=>e.vwUserPrefs(),userinfo:(e,t)=>Ud(Pm,{key:`userinfodialog-${t.userid}`,view:e,userid:t.userid,nick:t.nick,fullname:t.fullname}),challenge:(e,t)=>Ud(xf,{key:"challenge",view:e,item:t}),friend:e=>Ud(Rf,{key:"friend",view:e}),wait:(e,t)=>e.vwWait(t),accept:(e,t)=>e.vwAccept(t)};let Dm=null;const Am=(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=Ef(),i=new Pf(n,e),r=new qp(i),s=new Nm(r);Dm&&Dm.cleanup(),Dm=r;const o=new URLSearchParams(window.location.search).get("date"),a=(new Date).toISOString().split("T")[0],l=o||a,c=/^\d{4}-\d{2}-\d{2}$/.test(l)?l:a,u=e.locale||"is_IS";Ud.mount(t,{view:()=>Ud(uf,{view:s,date:c,locale:u})}),$p((e=>{const t=i.riddle;t&&df(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"))},Mm=t.memo((({state:i,tokenExpired:r})=>{const s=t.useRef(null),a=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=o({...i,tokenExpired:r});return Am(t,e).then((()=>{a.current=!0})).catch((e=>{console.error("Failed to mount Gáta Dagsins UI:",e)})),()=>{a.current&&(!function(e){Dm&&(Dm.cleanup(),Dm=null),Ud.mount(e,null),e.innerHTML="",document.body.querySelectorAll("#netskrafl-background, #gatadagsins-background").forEach((e=>e.remove()))}(e),a.current=!1)}}),[l]),e("div",{className:"gatadagsins",children:e("div",{className:"netskrafl-container",id:"gatadagsins-container",ref:s})})}));let Om=null;const jm=(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=Ef(),i=new Pf(n,e),r=new qp(i),s=new Nm(r);Om&&Om.cleanup(),Om=r,$p((e=>{const t=i.game;t&&df(t,s,e)}));const o=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);Ud.route(t,n.defaultRoute,o)}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"))},Fm=t.memo((({state:i,tokenExpired:r})=>{const s=t.useRef(null),a=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=o({...i,tokenExpired:r});return jm(t,e).then((()=>{a.current=!0})).catch((e=>{console.error("Failed to mount Netskrafl UI:",e)})),()=>{a.current&&(!function(e){Om&&(Om.cleanup(),Om=null),Ud.mount(e,null),e.innerHTML="",document.body.querySelectorAll("#netskrafl-background, #gatadagsins-background").forEach((e=>{e.remove()}))}(e),a.current=!1)}}),[l]),e("div",{className:"netskrafl",children:e("div",{className:"netskrafl-container",id:"netskrafl-container",ref:s})})}));export{Mm as GataDagsins,Fm as Netskrafl};
3028
3028
  //# sourceMappingURL=index.js.map