@fleox-agent-crm/agentcrm 0.0.0-stage → 0.3.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.
Files changed (129) hide show
  1. package/LICENSE +143 -0
  2. package/README.md +223 -2
  3. package/changelog.json +57 -0
  4. package/dist/admin/admin-files.json +26 -0
  5. package/dist/admin/assets/chartsImpl-CE2akJat.js +91 -0
  6. package/dist/admin/assets/firebase-BHSUggRo.js +2 -0
  7. package/dist/admin/assets/gitJson-BulGh2KV.js +3 -0
  8. package/dist/admin/assets/index-DidVVK7L.js +1181 -0
  9. package/dist/admin/assets/index-hMXwHSvN.css +1 -0
  10. package/dist/admin/assets/index.esm-BFc7vwnl.js +400 -0
  11. package/dist/admin/assets/index.esm-CtEQZRb1.js +1651 -0
  12. package/dist/admin/assets/index.esm-Dum0J07z.js +16 -0
  13. package/dist/admin/assets/index.esm2017-EOzKbpUS.js +390 -0
  14. package/dist/admin/assets/lucide-react.min-DEDlHCPj.js +6 -0
  15. package/dist/admin/assets/sdk-CnrLnlRo.js +1717 -0
  16. package/dist/admin/config.js +3 -0
  17. package/dist/admin/favicon.svg +1 -0
  18. package/dist/admin/index.html +139 -0
  19. package/dist/admin/runtime/agentcrm-runtime.js +104 -0
  20. package/dist/admin/runtime/lucide-react.js +791 -0
  21. package/dist/admin/runtime/react-dom-client.js +17 -0
  22. package/dist/admin/runtime/react-dom.js +20 -0
  23. package/dist/admin/runtime/react-i18next.js +19 -0
  24. package/dist/admin/runtime/react-jsx-runtime.js +17 -0
  25. package/dist/admin/runtime/react.js +22 -0
  26. package/dist/agent/agentcrm.mjs +3932 -0
  27. package/dist/agent/chunks/_commonjsHelpers-ClciMIcB.mjs +14 -0
  28. package/dist/agent/chunks/activities-Cj_SIOay.mjs +227 -0
  29. package/dist/agent/chunks/api-B6OqNVWp.mjs +97 -0
  30. package/dist/agent/chunks/appearance-BaShelzt.mjs +174 -0
  31. package/dist/agent/chunks/automations-BWrvLqP6.mjs +698 -0
  32. package/dist/agent/chunks/backup-ClSmxmFZ.mjs +103 -0
  33. package/dist/agent/chunks/batch-CVETiJj5.mjs +142 -0
  34. package/dist/agent/chunks/compact-CsFPaAAq.mjs +69 -0
  35. package/dist/agent/chunks/context-CxFfqS4D.mjs +65 -0
  36. package/dist/agent/chunks/core-Dy7vY9H6.mjs +255 -0
  37. package/dist/agent/chunks/dedupe-BepmsaHv.mjs +123 -0
  38. package/dist/agent/chunks/encoding-C9MzdP95.mjs +36 -0
  39. package/dist/agent/chunks/exportCsv-B5hRvkNm.mjs +95 -0
  40. package/dist/agent/chunks/extCheck--7lmVvl7.mjs +193 -0
  41. package/dist/agent/chunks/extPackage-BGl5Oqs8.mjs +115 -0
  42. package/dist/agent/chunks/extScaffold-DqxI7R1e.mjs +320 -0
  43. package/dist/agent/chunks/extensionActions-D2HtpQz4.mjs +48 -0
  44. package/dist/agent/chunks/extensions-BP1k60md.mjs +151 -0
  45. package/dist/agent/chunks/featureRegistry-C9nbVShp.mjs +149 -0
  46. package/dist/agent/chunks/fields-B0bitgmr.mjs +476 -0
  47. package/dist/agent/chunks/files-CjsPJSR6.mjs +158 -0
  48. package/dist/agent/chunks/files-q8Xu5bft.mjs +367 -0
  49. package/dist/agent/chunks/firebase-DxGVQV9E.mjs +454 -0
  50. package/dist/agent/chunks/firebaseRules-iori-s7U.mjs +221 -0
  51. package/dist/agent/chunks/forms-BKU5F9WF.mjs +847 -0
  52. package/dist/agent/chunks/gitJson-fjr8mcHe.mjs +528 -0
  53. package/dist/agent/chunks/hosting-Bme7LxPc.mjs +144 -0
  54. package/dist/agent/chunks/http-Bk9ICb7I.mjs +127 -0
  55. package/dist/agent/chunks/ids-CvnmrMJX.mjs +59 -0
  56. package/dist/agent/chunks/ids-u-noYcy5.mjs +14 -0
  57. package/dist/agent/chunks/importCsv-DmE_sBch.mjs +334 -0
  58. package/dist/agent/chunks/index-B-4W0-P4.mjs +535 -0
  59. package/dist/agent/chunks/index-BM8qeGOb.mjs +2489 -0
  60. package/dist/agent/chunks/index-Bnmav-Oh.mjs +311 -0
  61. package/dist/agent/chunks/index-CRkw3_iF.mjs +147 -0
  62. package/dist/agent/chunks/index-CWrrF1wl.mjs +111 -0
  63. package/dist/agent/chunks/index-DUSdTBkz.mjs +2988 -0
  64. package/dist/agent/chunks/index-RCmo-uld.mjs +26 -0
  65. package/dist/agent/chunks/index-w03ReRs4.mjs +9780 -0
  66. package/dist/agent/chunks/install-CpHoUFtL.mjs +188 -0
  67. package/dist/agent/chunks/jsx-runtime-Ca2uwGDr.mjs +76 -0
  68. package/dist/agent/chunks/loader-C9nm3iwx.mjs +184 -0
  69. package/dist/agent/chunks/lucide-react.min-Bt3gtepY.mjs +64 -0
  70. package/dist/agent/chunks/memory-WNR3VHUJ.mjs +56 -0
  71. package/dist/agent/chunks/migrate-CsClnnN8.mjs +182 -0
  72. package/dist/agent/chunks/modules-CqdVQVJb.mjs +177 -0
  73. package/dist/agent/chunks/nodeImport-BPCt5uMu.mjs +38 -0
  74. package/dist/agent/chunks/package-DWbn3t2R.mjs +194 -0
  75. package/dist/agent/chunks/papaparse-DjBYnQM2.mjs +1285 -0
  76. package/dist/agent/chunks/pipelines-DCdRBNBV.mjs +234 -0
  77. package/dist/agent/chunks/plan-C0TBrU92.mjs +254 -0
  78. package/dist/agent/chunks/pluginRegistry-DyHtlkcr.mjs +83 -0
  79. package/dist/agent/chunks/query-C5nJB_3C.mjs +192 -0
  80. package/dist/agent/chunks/records-DoqiT9xR.mjs +2191 -0
  81. package/dist/agent/chunks/registry-Ceexawxl.mjs +182 -0
  82. package/dist/agent/chunks/registry-DijAKZ24.mjs +431 -0
  83. package/dist/agent/chunks/relations-B9TynBmA.mjs +191 -0
  84. package/dist/agent/chunks/reports-BB59N6ke.mjs +189 -0
  85. package/dist/agent/chunks/runtime-DHo7ZEEO.mjs +14852 -0
  86. package/dist/agent/chunks/runtimeConfig-CCOFg1RM.mjs +250 -0
  87. package/dist/agent/chunks/s3-Dz50-NuA.mjs +903 -0
  88. package/dist/agent/chunks/schema-7-4-qtSS.mjs +203 -0
  89. package/dist/agent/chunks/schema-DlHt2PxI.mjs +367 -0
  90. package/dist/agent/chunks/sdk-whvfg786.mjs +43644 -0
  91. package/dist/agent/chunks/seed-CugPGYZL.mjs +523 -0
  92. package/dist/agent/chunks/server-ISwlDRCN.mjs +242 -0
  93. package/dist/agent/chunks/settings-BtvR_jdm.mjs +76 -0
  94. package/dist/agent/chunks/standardObjects-CheqfDqa.mjs +243 -0
  95. package/dist/agent/chunks/stats-CfeJssSS.mjs +51 -0
  96. package/dist/agent/chunks/store-5gqRSKXg.mjs +122 -0
  97. package/dist/agent/chunks/themes-DPZFv3yc.mjs +43 -0
  98. package/dist/agent/chunks/tools-Bew8lxKx.mjs +844 -0
  99. package/dist/agent/chunks/types-BOy9PUl7.mjs +44 -0
  100. package/dist/agent/chunks/users-DI1BvS0f.mjs +107 -0
  101. package/dist/agent/chunks/utils-DmI8FtXP.mjs +83 -0
  102. package/dist/agent/chunks/views-fO_BM5U_.mjs +109 -0
  103. package/dist/version.json +7 -0
  104. package/package.json +97 -4
  105. package/plugin/.claude-plugin/plugin.json +17 -0
  106. package/plugin/skills/agentcrm-admin/SKILL.md +191 -0
  107. package/plugin/skills/agentcrm-admin/references/appearance.md +26 -0
  108. package/plugin/skills/agentcrm-admin/references/import.md +16 -0
  109. package/plugin/skills/agentcrm-admin/references/records.md +30 -0
  110. package/plugin/skills/agentcrm-admin/references/schema.md +59 -0
  111. package/plugin/skills/agentcrm-extensions/SKILL.md +93 -0
  112. package/plugin/skills/agentcrm-extensions/references/module-recipes.md +213 -0
  113. package/plugin/skills/agentcrm-extensions/references/runtime-api.md +41 -0
  114. package/plugin/skills/agentcrm-extensions/references/testing.md +76 -0
  115. package/plugin/skills/agentcrm-extensions/references/theme-recipes.md +65 -0
  116. package/plugin/skills/agentcrm-install/SKILL.md +116 -0
  117. package/plugin/skills/agentcrm-install/references/firebase.md +18 -0
  118. package/plugin/skills/agentcrm-install/references/github.md +20 -0
  119. package/plugin/skills/agentcrm-install/references/mcp.md +17 -0
  120. package/plugin/skills/agentcrm-install/references/plans.md +45 -0
  121. package/plugin/skills/agentcrm-install/references/s3.md +24 -0
  122. package/plugin/skills/agentcrm-manage/SKILL.md +108 -0
  123. package/plugin/skills/agentcrm-manage/references/cron.md +11 -0
  124. package/plugin/skills/agentcrm-manage/references/doctor.md +18 -0
  125. package/plugin/skills/agentcrm-sales/SKILL.md +92 -0
  126. package/plugin/skills/agentcrm-sales/references/enrichment.md +13 -0
  127. package/plugin/skills/agentcrm-sales/references/playbooks.md +29 -0
  128. package/plugin/skills/agentcrm-sales/references/weekly-report.md +27 -0
  129. package/types/agentcrm-runtime.d.ts +894 -0
@@ -0,0 +1,1717 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index.esm-BFc7vwnl.js","./index.esm2017-EOzKbpUS.js"])))=>i.map(i=>d[i]);
2
+ import{_ as Tl}from"./index-DidVVK7L.js";import"./index.esm-Dum0J07z.js";import{getAuth as vl,onAuthStateChanged as so,signOut as Il,sendEmailVerification as Al,sendPasswordResetEmail as wl,GoogleAuthProvider as Rl,signInWithPopup as Pl,signInWithEmailAndPassword as Vl}from"./index.esm-CtEQZRb1.js";import{q as kt,e as ua,y as la,u as Is,v as ca,m as Sl,t as Cl,F as bl,w as Dl,x as Nl,L as kl,z as qt,A as xl,B as Ol,S as Ml,i as Fl,C as Ll,r as io,h as Ul,g as ql,n as jl}from"./index.esm2017-EOzKbpUS.js";import{DELETE_FIELD as Bl}from"./firebase-BHSUggRo.js";var oo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
3
+ Copyright The Closure Library Authors.
4
+ SPDX-License-Identifier: Apache-2.0
5
+ */var Xt,ha;(function(){var r;/** @license
6
+
7
+ Copyright The Closure Library Authors.
8
+ SPDX-License-Identifier: Apache-2.0
9
+ */function t(v,m){function _(){}_.prototype=m.prototype,v.D=m.prototype,v.prototype=new _,v.prototype.constructor=v,v.C=function(y,T,A){for(var g=Array(arguments.length-2),Ft=2;Ft<arguments.length;Ft++)g[Ft-2]=arguments[Ft];return m.prototype[T].apply(y,g)}}function e(){this.blockSize=-1}function n(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}t(n,e),n.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function i(v,m,_){_||(_=0);var y=Array(16);if(typeof m=="string")for(var T=0;16>T;++T)y[T]=m.charCodeAt(_++)|m.charCodeAt(_++)<<8|m.charCodeAt(_++)<<16|m.charCodeAt(_++)<<24;else for(T=0;16>T;++T)y[T]=m[_++]|m[_++]<<8|m[_++]<<16|m[_++]<<24;m=v.g[0],_=v.g[1],T=v.g[2];var A=v.g[3],g=m+(A^_&(T^A))+y[0]+3614090360&4294967295;m=_+(g<<7&4294967295|g>>>25),g=A+(T^m&(_^T))+y[1]+3905402710&4294967295,A=m+(g<<12&4294967295|g>>>20),g=T+(_^A&(m^_))+y[2]+606105819&4294967295,T=A+(g<<17&4294967295|g>>>15),g=_+(m^T&(A^m))+y[3]+3250441966&4294967295,_=T+(g<<22&4294967295|g>>>10),g=m+(A^_&(T^A))+y[4]+4118548399&4294967295,m=_+(g<<7&4294967295|g>>>25),g=A+(T^m&(_^T))+y[5]+1200080426&4294967295,A=m+(g<<12&4294967295|g>>>20),g=T+(_^A&(m^_))+y[6]+2821735955&4294967295,T=A+(g<<17&4294967295|g>>>15),g=_+(m^T&(A^m))+y[7]+4249261313&4294967295,_=T+(g<<22&4294967295|g>>>10),g=m+(A^_&(T^A))+y[8]+1770035416&4294967295,m=_+(g<<7&4294967295|g>>>25),g=A+(T^m&(_^T))+y[9]+2336552879&4294967295,A=m+(g<<12&4294967295|g>>>20),g=T+(_^A&(m^_))+y[10]+4294925233&4294967295,T=A+(g<<17&4294967295|g>>>15),g=_+(m^T&(A^m))+y[11]+2304563134&4294967295,_=T+(g<<22&4294967295|g>>>10),g=m+(A^_&(T^A))+y[12]+1804603682&4294967295,m=_+(g<<7&4294967295|g>>>25),g=A+(T^m&(_^T))+y[13]+4254626195&4294967295,A=m+(g<<12&4294967295|g>>>20),g=T+(_^A&(m^_))+y[14]+2792965006&4294967295,T=A+(g<<17&4294967295|g>>>15),g=_+(m^T&(A^m))+y[15]+1236535329&4294967295,_=T+(g<<22&4294967295|g>>>10),g=m+(T^A&(_^T))+y[1]+4129170786&4294967295,m=_+(g<<5&4294967295|g>>>27),g=A+(_^T&(m^_))+y[6]+3225465664&4294967295,A=m+(g<<9&4294967295|g>>>23),g=T+(m^_&(A^m))+y[11]+643717713&4294967295,T=A+(g<<14&4294967295|g>>>18),g=_+(A^m&(T^A))+y[0]+3921069994&4294967295,_=T+(g<<20&4294967295|g>>>12),g=m+(T^A&(_^T))+y[5]+3593408605&4294967295,m=_+(g<<5&4294967295|g>>>27),g=A+(_^T&(m^_))+y[10]+38016083&4294967295,A=m+(g<<9&4294967295|g>>>23),g=T+(m^_&(A^m))+y[15]+3634488961&4294967295,T=A+(g<<14&4294967295|g>>>18),g=_+(A^m&(T^A))+y[4]+3889429448&4294967295,_=T+(g<<20&4294967295|g>>>12),g=m+(T^A&(_^T))+y[9]+568446438&4294967295,m=_+(g<<5&4294967295|g>>>27),g=A+(_^T&(m^_))+y[14]+3275163606&4294967295,A=m+(g<<9&4294967295|g>>>23),g=T+(m^_&(A^m))+y[3]+4107603335&4294967295,T=A+(g<<14&4294967295|g>>>18),g=_+(A^m&(T^A))+y[8]+1163531501&4294967295,_=T+(g<<20&4294967295|g>>>12),g=m+(T^A&(_^T))+y[13]+2850285829&4294967295,m=_+(g<<5&4294967295|g>>>27),g=A+(_^T&(m^_))+y[2]+4243563512&4294967295,A=m+(g<<9&4294967295|g>>>23),g=T+(m^_&(A^m))+y[7]+1735328473&4294967295,T=A+(g<<14&4294967295|g>>>18),g=_+(A^m&(T^A))+y[12]+2368359562&4294967295,_=T+(g<<20&4294967295|g>>>12),g=m+(_^T^A)+y[5]+4294588738&4294967295,m=_+(g<<4&4294967295|g>>>28),g=A+(m^_^T)+y[8]+2272392833&4294967295,A=m+(g<<11&4294967295|g>>>21),g=T+(A^m^_)+y[11]+1839030562&4294967295,T=A+(g<<16&4294967295|g>>>16),g=_+(T^A^m)+y[14]+4259657740&4294967295,_=T+(g<<23&4294967295|g>>>9),g=m+(_^T^A)+y[1]+2763975236&4294967295,m=_+(g<<4&4294967295|g>>>28),g=A+(m^_^T)+y[4]+1272893353&4294967295,A=m+(g<<11&4294967295|g>>>21),g=T+(A^m^_)+y[7]+4139469664&4294967295,T=A+(g<<16&4294967295|g>>>16),g=_+(T^A^m)+y[10]+3200236656&4294967295,_=T+(g<<23&4294967295|g>>>9),g=m+(_^T^A)+y[13]+681279174&4294967295,m=_+(g<<4&4294967295|g>>>28),g=A+(m^_^T)+y[0]+3936430074&4294967295,A=m+(g<<11&4294967295|g>>>21),g=T+(A^m^_)+y[3]+3572445317&4294967295,T=A+(g<<16&4294967295|g>>>16),g=_+(T^A^m)+y[6]+76029189&4294967295,_=T+(g<<23&4294967295|g>>>9),g=m+(_^T^A)+y[9]+3654602809&4294967295,m=_+(g<<4&4294967295|g>>>28),g=A+(m^_^T)+y[12]+3873151461&4294967295,A=m+(g<<11&4294967295|g>>>21),g=T+(A^m^_)+y[15]+530742520&4294967295,T=A+(g<<16&4294967295|g>>>16),g=_+(T^A^m)+y[2]+3299628645&4294967295,_=T+(g<<23&4294967295|g>>>9),g=m+(T^(_|~A))+y[0]+4096336452&4294967295,m=_+(g<<6&4294967295|g>>>26),g=A+(_^(m|~T))+y[7]+1126891415&4294967295,A=m+(g<<10&4294967295|g>>>22),g=T+(m^(A|~_))+y[14]+2878612391&4294967295,T=A+(g<<15&4294967295|g>>>17),g=_+(A^(T|~m))+y[5]+4237533241&4294967295,_=T+(g<<21&4294967295|g>>>11),g=m+(T^(_|~A))+y[12]+1700485571&4294967295,m=_+(g<<6&4294967295|g>>>26),g=A+(_^(m|~T))+y[3]+2399980690&4294967295,A=m+(g<<10&4294967295|g>>>22),g=T+(m^(A|~_))+y[10]+4293915773&4294967295,T=A+(g<<15&4294967295|g>>>17),g=_+(A^(T|~m))+y[1]+2240044497&4294967295,_=T+(g<<21&4294967295|g>>>11),g=m+(T^(_|~A))+y[8]+1873313359&4294967295,m=_+(g<<6&4294967295|g>>>26),g=A+(_^(m|~T))+y[15]+4264355552&4294967295,A=m+(g<<10&4294967295|g>>>22),g=T+(m^(A|~_))+y[6]+2734768916&4294967295,T=A+(g<<15&4294967295|g>>>17),g=_+(A^(T|~m))+y[13]+1309151649&4294967295,_=T+(g<<21&4294967295|g>>>11),g=m+(T^(_|~A))+y[4]+4149444226&4294967295,m=_+(g<<6&4294967295|g>>>26),g=A+(_^(m|~T))+y[11]+3174756917&4294967295,A=m+(g<<10&4294967295|g>>>22),g=T+(m^(A|~_))+y[2]+718787259&4294967295,T=A+(g<<15&4294967295|g>>>17),g=_+(A^(T|~m))+y[9]+3951481745&4294967295,v.g[0]=v.g[0]+m&4294967295,v.g[1]=v.g[1]+(T+(g<<21&4294967295|g>>>11))&4294967295,v.g[2]=v.g[2]+T&4294967295,v.g[3]=v.g[3]+A&4294967295}n.prototype.u=function(v,m){m===void 0&&(m=v.length);for(var _=m-this.blockSize,y=this.B,T=this.h,A=0;A<m;){if(T==0)for(;A<=_;)i(this,v,A),A+=this.blockSize;if(typeof v=="string"){for(;A<m;)if(y[T++]=v.charCodeAt(A++),T==this.blockSize){i(this,y),T=0;break}}else for(;A<m;)if(y[T++]=v[A++],T==this.blockSize){i(this,y),T=0;break}}this.h=T,this.o+=m},n.prototype.v=function(){var v=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);v[0]=128;for(var m=1;m<v.length-8;++m)v[m]=0;var _=8*this.o;for(m=v.length-8;m<v.length;++m)v[m]=_&255,_/=256;for(this.u(v),v=Array(16),m=_=0;4>m;++m)for(var y=0;32>y;y+=8)v[_++]=this.g[m]>>>y&255;return v};function o(v,m){var _=c;return Object.prototype.hasOwnProperty.call(_,v)?_[v]:_[v]=m(v)}function u(v,m){this.h=m;for(var _=[],y=!0,T=v.length-1;0<=T;T--){var A=v[T]|0;y&&A==m||(_[T]=A,y=!1)}this.g=_}var c={};function h(v){return-128<=v&&128>v?o(v,function(m){return new u([m|0],0>m?-1:0)}):new u([v|0],0>v?-1:0)}function f(v){if(isNaN(v)||!isFinite(v))return E;if(0>v)return b(f(-v));for(var m=[],_=1,y=0;v>=_;y++)m[y]=v/_|0,_*=4294967296;return new u(m,0)}function p(v,m){if(v.length==0)throw Error("number format error: empty string");if(m=m||10,2>m||36<m)throw Error("radix out of range: "+m);if(v.charAt(0)=="-")return b(p(v.substring(1),m));if(0<=v.indexOf("-"))throw Error('number format error: interior "-" character');for(var _=f(Math.pow(m,8)),y=E,T=0;T<v.length;T+=8){var A=Math.min(8,v.length-T),g=parseInt(v.substring(T,T+A),m);8>A?(A=f(Math.pow(m,A)),y=y.j(A).add(f(g))):(y=y.j(_),y=y.add(f(g)))}return y}var E=h(0),R=h(1),S=h(16777216);r=u.prototype,r.m=function(){if(x(this))return-b(this).m();for(var v=0,m=1,_=0;_<this.g.length;_++){var y=this.i(_);v+=(0<=y?y:4294967296+y)*m,m*=4294967296}return v},r.toString=function(v){if(v=v||10,2>v||36<v)throw Error("radix out of range: "+v);if(D(this))return"0";if(x(this))return"-"+b(this).toString(v);for(var m=f(Math.pow(v,6)),_=this,y="";;){var T=it(_,m).g;_=$(_,T.j(m));var A=((0<_.g.length?_.g[0]:_.h)>>>0).toString(v);if(_=T,D(_))return A+y;for(;6>A.length;)A="0"+A;y=A+y}},r.i=function(v){return 0>v?0:v<this.g.length?this.g[v]:this.h};function D(v){if(v.h!=0)return!1;for(var m=0;m<v.g.length;m++)if(v.g[m]!=0)return!1;return!0}function x(v){return v.h==-1}r.l=function(v){return v=$(this,v),x(v)?-1:D(v)?0:1};function b(v){for(var m=v.g.length,_=[],y=0;y<m;y++)_[y]=~v.g[y];return new u(_,~v.h).add(R)}r.abs=function(){return x(this)?b(this):this},r.add=function(v){for(var m=Math.max(this.g.length,v.g.length),_=[],y=0,T=0;T<=m;T++){var A=y+(this.i(T)&65535)+(v.i(T)&65535),g=(A>>>16)+(this.i(T)>>>16)+(v.i(T)>>>16);y=g>>>16,A&=65535,g&=65535,_[T]=g<<16|A}return new u(_,_[_.length-1]&-2147483648?-1:0)};function $(v,m){return v.add(b(m))}r.j=function(v){if(D(this)||D(v))return E;if(x(this))return x(v)?b(this).j(b(v)):b(b(this).j(v));if(x(v))return b(this.j(b(v)));if(0>this.l(S)&&0>v.l(S))return f(this.m()*v.m());for(var m=this.g.length+v.g.length,_=[],y=0;y<2*m;y++)_[y]=0;for(y=0;y<this.g.length;y++)for(var T=0;T<v.g.length;T++){var A=this.i(y)>>>16,g=this.i(y)&65535,Ft=v.i(T)>>>16,Fe=v.i(T)&65535;_[2*y+2*T]+=g*Fe,B(_,2*y+2*T),_[2*y+2*T+1]+=A*Fe,B(_,2*y+2*T+1),_[2*y+2*T+1]+=g*Ft,B(_,2*y+2*T+1),_[2*y+2*T+2]+=A*Ft,B(_,2*y+2*T+2)}for(y=0;y<m;y++)_[y]=_[2*y+1]<<16|_[2*y];for(y=m;y<2*m;y++)_[y]=0;return new u(_,0)};function B(v,m){for(;(v[m]&65535)!=v[m];)v[m+1]+=v[m]>>>16,v[m]&=65535,m++}function K(v,m){this.g=v,this.h=m}function it(v,m){if(D(m))throw Error("division by zero");if(D(v))return new K(E,E);if(x(v))return m=it(b(v),m),new K(b(m.g),b(m.h));if(x(m))return m=it(v,b(m)),new K(b(m.g),m.h);if(30<v.g.length){if(x(v)||x(m))throw Error("slowDivide_ only works with positive integers.");for(var _=R,y=m;0>=y.l(v);)_=Mt(_),y=Mt(y);var T=at(_,1),A=at(y,1);for(y=at(y,2),_=at(_,2);!D(y);){var g=A.add(y);0>=g.l(v)&&(T=T.add(_),A=g),y=at(y,1),_=at(_,1)}return m=$(v,T.j(m)),new K(T,m)}for(T=E;0<=v.l(m);){for(_=Math.max(1,Math.floor(v.m()/m.m())),y=Math.ceil(Math.log(_)/Math.LN2),y=48>=y?1:Math.pow(2,y-48),A=f(_),g=A.j(m);x(g)||0<g.l(v);)_-=y,A=f(_),g=A.j(m);D(A)&&(A=R),T=T.add(A),v=$(v,g)}return new K(T,v)}r.A=function(v){return it(this,v).h},r.and=function(v){for(var m=Math.max(this.g.length,v.g.length),_=[],y=0;y<m;y++)_[y]=this.i(y)&v.i(y);return new u(_,this.h&v.h)},r.or=function(v){for(var m=Math.max(this.g.length,v.g.length),_=[],y=0;y<m;y++)_[y]=this.i(y)|v.i(y);return new u(_,this.h|v.h)},r.xor=function(v){for(var m=Math.max(this.g.length,v.g.length),_=[],y=0;y<m;y++)_[y]=this.i(y)^v.i(y);return new u(_,this.h^v.h)};function Mt(v){for(var m=v.g.length+1,_=[],y=0;y<m;y++)_[y]=v.i(y)<<1|v.i(y-1)>>>31;return new u(_,v.h)}function at(v,m){var _=m>>5;m%=32;for(var y=v.g.length-_,T=[],A=0;A<y;A++)T[A]=0<m?v.i(A+_)>>>m|v.i(A+_+1)<<32-m:v.i(A+_);return new u(T,v.h)}n.prototype.digest=n.prototype.v,n.prototype.reset=n.prototype.s,n.prototype.update=n.prototype.u,ha=n,u.prototype.add=u.prototype.add,u.prototype.multiply=u.prototype.j,u.prototype.modulo=u.prototype.A,u.prototype.compare=u.prototype.l,u.prototype.toNumber=u.prototype.m,u.prototype.toString=u.prototype.toString,u.prototype.getBits=u.prototype.i,u.fromNumber=f,u.fromString=p,Xt=u}).apply(typeof oo<"u"?oo:typeof self<"u"?self:typeof window<"u"?window:{});var Gn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
10
+ Copyright The Closure Library Authors.
11
+ SPDX-License-Identifier: Apache-2.0
12
+ */var da,en,fa,Xn,is,ma,pa,ga;(function(){var r,t=typeof Object.defineProperties=="function"?Object.defineProperty:function(s,a,l){return s==Array.prototype||s==Object.prototype||(s[a]=l.value),s};function e(s){s=[typeof globalThis=="object"&&globalThis,s,typeof window=="object"&&window,typeof self=="object"&&self,typeof Gn=="object"&&Gn];for(var a=0;a<s.length;++a){var l=s[a];if(l&&l.Math==Math)return l}throw Error("Cannot find global object")}var n=e(this);function i(s,a){if(a)t:{var l=n;s=s.split(".");for(var d=0;d<s.length-1;d++){var I=s[d];if(!(I in l))break t;l=l[I]}s=s[s.length-1],d=l[s],a=a(d),a!=d&&a!=null&&t(l,s,{configurable:!0,writable:!0,value:a})}}function o(s,a){s instanceof String&&(s+="");var l=0,d=!1,I={next:function(){if(!d&&l<s.length){var w=l++;return{value:a(w,s[w]),done:!1}}return d=!0,{done:!0,value:void 0}}};return I[Symbol.iterator]=function(){return I},I}i("Array.prototype.values",function(s){return s||function(){return o(this,function(a,l){return l})}});/** @license
13
+
14
+ Copyright The Closure Library Authors.
15
+ SPDX-License-Identifier: Apache-2.0
16
+ */var u=u||{},c=this||self;function h(s){var a=typeof s;return a=a!="object"?a:s?Array.isArray(s)?"array":a:"null",a=="array"||a=="object"&&typeof s.length=="number"}function f(s){var a=typeof s;return a=="object"&&s!=null||a=="function"}function p(s,a,l){return s.call.apply(s.bind,arguments)}function E(s,a,l){if(!s)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var I=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(I,d),s.apply(a,I)}}return function(){return s.apply(a,arguments)}}function R(s,a,l){return R=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?p:E,R.apply(null,arguments)}function S(s,a){var l=Array.prototype.slice.call(arguments,1);return function(){var d=l.slice();return d.push.apply(d,arguments),s.apply(this,d)}}function D(s,a){function l(){}l.prototype=a.prototype,s.aa=a.prototype,s.prototype=new l,s.prototype.constructor=s,s.Qb=function(d,I,w){for(var C=Array(arguments.length-2),Q=2;Q<arguments.length;Q++)C[Q-2]=arguments[Q];return a.prototype[I].apply(d,C)}}function x(s){const a=s.length;if(0<a){const l=Array(a);for(let d=0;d<a;d++)l[d]=s[d];return l}return[]}function b(s,a){for(let l=1;l<arguments.length;l++){const d=arguments[l];if(h(d)){const I=s.length||0,w=d.length||0;s.length=I+w;for(let C=0;C<w;C++)s[I+C]=d[C]}else s.push(d)}}class ${constructor(a,l){this.i=a,this.j=l,this.h=0,this.g=null}get(){let a;return 0<this.h?(this.h--,a=this.g,this.g=a.next,a.next=null):a=this.i(),a}}function B(s){return/^[\s\xa0]*$/.test(s)}function K(){var s=c.navigator;return s&&(s=s.userAgent)?s:""}function it(s){return it[" "](s),s}it[" "]=function(){};var Mt=K().indexOf("Gecko")!=-1&&!(K().toLowerCase().indexOf("webkit")!=-1&&K().indexOf("Edge")==-1)&&!(K().indexOf("Trident")!=-1||K().indexOf("MSIE")!=-1)&&K().indexOf("Edge")==-1;function at(s,a,l){for(const d in s)a.call(l,s[d],d,s)}function v(s,a){for(const l in s)a.call(void 0,s[l],l,s)}function m(s){const a={};for(const l in s)a[l]=s[l];return a}const _="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function y(s,a){let l,d;for(let I=1;I<arguments.length;I++){d=arguments[I];for(l in d)s[l]=d[l];for(let w=0;w<_.length;w++)l=_[w],Object.prototype.hasOwnProperty.call(d,l)&&(s[l]=d[l])}}function T(s){var a=1;s=s.split(":");const l=[];for(;0<a&&s.length;)l.push(s.shift()),a--;return s.length&&l.push(s.join(":")),l}function A(s){c.setTimeout(()=>{throw s},0)}function g(){var s=br;let a=null;return s.g&&(a=s.g,s.g=s.g.next,s.g||(s.h=null),a.next=null),a}class Ft{constructor(){this.h=this.g=null}add(a,l){const d=Fe.get();d.set(a,l),this.h?this.h.next=d:this.g=d,this.h=d}}var Fe=new $(()=>new Uu,s=>s.reset());class Uu{constructor(){this.next=this.g=this.h=null}set(a,l){this.h=a,this.g=l,this.next=null}reset(){this.next=this.g=this.h=null}}let Le,Ue=!1,br=new Ft,si=()=>{const s=c.Promise.resolve(void 0);Le=()=>{s.then(qu)}};var qu=()=>{for(var s;s=g();){try{s.h.call(s.g)}catch(l){A(l)}var a=Fe;a.j(s),100>a.h&&(a.h++,s.next=a.g,a.g=s)}Ue=!1};function Gt(){this.s=this.s,this.C=this.C}Gt.prototype.s=!1,Gt.prototype.ma=function(){this.s||(this.s=!0,this.N())},Gt.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function dt(s,a){this.type=s,this.g=this.target=a,this.defaultPrevented=!1}dt.prototype.h=function(){this.defaultPrevented=!0};var ju=(function(){if(!c.addEventListener||!Object.defineProperty)return!1;var s=!1,a=Object.defineProperty({},"passive",{get:function(){s=!0}});try{const l=()=>{};c.addEventListener("test",l,a),c.removeEventListener("test",l,a)}catch{}return s})();function qe(s,a){if(dt.call(this,s?s.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,s){var l=this.type=s.type,d=s.changedTouches&&s.changedTouches.length?s.changedTouches[0]:null;if(this.target=s.target||s.srcElement,this.g=a,a=s.relatedTarget){if(Mt){t:{try{it(a.nodeName);var I=!0;break t}catch{}I=!1}I||(a=null)}}else l=="mouseover"?a=s.fromElement:l=="mouseout"&&(a=s.toElement);this.relatedTarget=a,d?(this.clientX=d.clientX!==void 0?d.clientX:d.pageX,this.clientY=d.clientY!==void 0?d.clientY:d.pageY,this.screenX=d.screenX||0,this.screenY=d.screenY||0):(this.clientX=s.clientX!==void 0?s.clientX:s.pageX,this.clientY=s.clientY!==void 0?s.clientY:s.pageY,this.screenX=s.screenX||0,this.screenY=s.screenY||0),this.button=s.button,this.key=s.key||"",this.ctrlKey=s.ctrlKey,this.altKey=s.altKey,this.shiftKey=s.shiftKey,this.metaKey=s.metaKey,this.pointerId=s.pointerId||0,this.pointerType=typeof s.pointerType=="string"?s.pointerType:Bu[s.pointerType]||"",this.state=s.state,this.i=s,s.defaultPrevented&&qe.aa.h.call(this)}}D(qe,dt);var Bu={2:"touch",3:"pen",4:"mouse"};qe.prototype.h=function(){qe.aa.h.call(this);var s=this.i;s.preventDefault?s.preventDefault():s.returnValue=!1};var Pn="closure_listenable_"+(1e6*Math.random()|0),zu=0;function $u(s,a,l,d,I){this.listener=s,this.proxy=null,this.src=a,this.type=l,this.capture=!!d,this.ha=I,this.key=++zu,this.da=this.fa=!1}function Vn(s){s.da=!0,s.listener=null,s.proxy=null,s.src=null,s.ha=null}function Sn(s){this.src=s,this.g={},this.h=0}Sn.prototype.add=function(s,a,l,d,I){var w=s.toString();s=this.g[w],s||(s=this.g[w]=[],this.h++);var C=Nr(s,a,d,I);return-1<C?(a=s[C],l||(a.fa=!1)):(a=new $u(a,this.src,w,!!d,I),a.fa=l,s.push(a)),a};function Dr(s,a){var l=a.type;if(l in s.g){var d=s.g[l],I=Array.prototype.indexOf.call(d,a,void 0),w;(w=0<=I)&&Array.prototype.splice.call(d,I,1),w&&(Vn(a),s.g[l].length==0&&(delete s.g[l],s.h--))}}function Nr(s,a,l,d){for(var I=0;I<s.length;++I){var w=s[I];if(!w.da&&w.listener==a&&w.capture==!!l&&w.ha==d)return I}return-1}var kr="closure_lm_"+(1e6*Math.random()|0),xr={};function ii(s,a,l,d,I){if(Array.isArray(a)){for(var w=0;w<a.length;w++)ii(s,a[w],l,d,I);return null}return l=ui(l),s&&s[Pn]?s.K(a,l,f(d)?!!d.capture:!1,I):Gu(s,a,l,!1,d,I)}function Gu(s,a,l,d,I,w){if(!a)throw Error("Invalid event type");var C=f(I)?!!I.capture:!!I,Q=Mr(s);if(Q||(s[kr]=Q=new Sn(s)),l=Q.add(a,l,d,C,w),l.proxy)return l;if(d=Ku(),l.proxy=d,d.src=s,d.listener=l,s.addEventListener)ju||(I=C),I===void 0&&(I=!1),s.addEventListener(a.toString(),d,I);else if(s.attachEvent)s.attachEvent(ai(a.toString()),d);else if(s.addListener&&s.removeListener)s.addListener(d);else throw Error("addEventListener and attachEvent are unavailable.");return l}function Ku(){function s(l){return a.call(s.src,s.listener,l)}const a=Qu;return s}function oi(s,a,l,d,I){if(Array.isArray(a))for(var w=0;w<a.length;w++)oi(s,a[w],l,d,I);else d=f(d)?!!d.capture:!!d,l=ui(l),s&&s[Pn]?(s=s.i,a=String(a).toString(),a in s.g&&(w=s.g[a],l=Nr(w,l,d,I),-1<l&&(Vn(w[l]),Array.prototype.splice.call(w,l,1),w.length==0&&(delete s.g[a],s.h--)))):s&&(s=Mr(s))&&(a=s.g[a.toString()],s=-1,a&&(s=Nr(a,l,d,I)),(l=-1<s?a[s]:null)&&Or(l))}function Or(s){if(typeof s!="number"&&s&&!s.da){var a=s.src;if(a&&a[Pn])Dr(a.i,s);else{var l=s.type,d=s.proxy;a.removeEventListener?a.removeEventListener(l,d,s.capture):a.detachEvent?a.detachEvent(ai(l),d):a.addListener&&a.removeListener&&a.removeListener(d),(l=Mr(a))?(Dr(l,s),l.h==0&&(l.src=null,a[kr]=null)):Vn(s)}}}function ai(s){return s in xr?xr[s]:xr[s]="on"+s}function Qu(s,a){if(s.da)s=!0;else{a=new qe(a,this);var l=s.listener,d=s.ha||s.src;s.fa&&Or(s),s=l.call(d,a)}return s}function Mr(s){return s=s[kr],s instanceof Sn?s:null}var Fr="__closure_events_fn_"+(1e9*Math.random()>>>0);function ui(s){return typeof s=="function"?s:(s[Fr]||(s[Fr]=function(a){return s.handleEvent(a)}),s[Fr])}function ft(){Gt.call(this),this.i=new Sn(this),this.M=this,this.F=null}D(ft,Gt),ft.prototype[Pn]=!0,ft.prototype.removeEventListener=function(s,a,l,d){oi(this,s,a,l,d)};function Et(s,a){var l,d=s.F;if(d)for(l=[];d;d=d.F)l.push(d);if(s=s.M,d=a.type||a,typeof a=="string")a=new dt(a,s);else if(a instanceof dt)a.target=a.target||s;else{var I=a;a=new dt(d,s),y(a,I)}if(I=!0,l)for(var w=l.length-1;0<=w;w--){var C=a.g=l[w];I=Cn(C,d,!0,a)&&I}if(C=a.g=s,I=Cn(C,d,!0,a)&&I,I=Cn(C,d,!1,a)&&I,l)for(w=0;w<l.length;w++)C=a.g=l[w],I=Cn(C,d,!1,a)&&I}ft.prototype.N=function(){if(ft.aa.N.call(this),this.i){var s=this.i,a;for(a in s.g){for(var l=s.g[a],d=0;d<l.length;d++)Vn(l[d]);delete s.g[a],s.h--}}this.F=null},ft.prototype.K=function(s,a,l,d){return this.i.add(String(s),a,!1,l,d)},ft.prototype.L=function(s,a,l,d){return this.i.add(String(s),a,!0,l,d)};function Cn(s,a,l,d){if(a=s.i.g[String(a)],!a)return!0;a=a.concat();for(var I=!0,w=0;w<a.length;++w){var C=a[w];if(C&&!C.da&&C.capture==l){var Q=C.listener,ut=C.ha||C.src;C.fa&&Dr(s.i,C),I=Q.call(ut,d)!==!1&&I}}return I&&!d.defaultPrevented}function li(s,a,l){if(typeof s=="function")l&&(s=R(s,l));else if(s&&typeof s.handleEvent=="function")s=R(s.handleEvent,s);else throw Error("Invalid listener argument");return 2147483647<Number(a)?-1:c.setTimeout(s,a||0)}function ci(s){s.g=li(()=>{s.g=null,s.i&&(s.i=!1,ci(s))},s.l);const a=s.h;s.h=null,s.m.apply(null,a)}class Wu extends Gt{constructor(a,l){super(),this.m=a,this.l=l,this.h=null,this.i=!1,this.g=null}j(a){this.h=arguments,this.g?this.i=!0:ci(this)}N(){super.N(),this.g&&(c.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function je(s){Gt.call(this),this.h=s,this.g={}}D(je,Gt);var hi=[];function di(s){at(s.g,function(a,l){this.g.hasOwnProperty(l)&&Or(a)},s),s.g={}}je.prototype.N=function(){je.aa.N.call(this),di(this)},je.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Lr=c.JSON.stringify,Hu=c.JSON.parse,Xu=class{stringify(s){return c.JSON.stringify(s,void 0)}parse(s){return c.JSON.parse(s,void 0)}};function Ur(){}Ur.prototype.h=null;function fi(s){return s.h||(s.h=s.i())}function mi(){}var Be={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function qr(){dt.call(this,"d")}D(qr,dt);function jr(){dt.call(this,"c")}D(jr,dt);var ae={},pi=null;function bn(){return pi=pi||new ft}ae.La="serverreachability";function gi(s){dt.call(this,ae.La,s)}D(gi,dt);function ze(s){const a=bn();Et(a,new gi(a))}ae.STAT_EVENT="statevent";function _i(s,a){dt.call(this,ae.STAT_EVENT,s),this.stat=a}D(_i,dt);function Tt(s){const a=bn();Et(a,new _i(a,s))}ae.Ma="timingevent";function yi(s,a){dt.call(this,ae.Ma,s),this.size=a}D(yi,dt);function $e(s,a){if(typeof s!="function")throw Error("Fn must not be null and must be a function");return c.setTimeout(function(){s()},a)}function Ge(){this.g=!0}Ge.prototype.xa=function(){this.g=!1};function Yu(s,a,l,d,I,w){s.info(function(){if(s.g)if(w)for(var C="",Q=w.split("&"),ut=0;ut<Q.length;ut++){var z=Q[ut].split("=");if(1<z.length){var mt=z[0];z=z[1];var pt=mt.split("_");C=2<=pt.length&&pt[1]=="type"?C+(mt+"="+z+"&"):C+(mt+"=redacted&")}}else C=null;else C=w;return"XMLHTTP REQ ("+d+") [attempt "+I+"]: "+a+`
17
+ `+l+`
18
+ `+C})}function Ju(s,a,l,d,I,w,C){s.info(function(){return"XMLHTTP RESP ("+d+") [ attempt "+I+"]: "+a+`
19
+ `+l+`
20
+ `+w+" "+C})}function ye(s,a,l,d){s.info(function(){return"XMLHTTP TEXT ("+a+"): "+tl(s,l)+(d?" "+d:"")})}function Zu(s,a){s.info(function(){return"TIMEOUT: "+a})}Ge.prototype.info=function(){};function tl(s,a){if(!s.g)return a;if(!a)return null;try{var l=JSON.parse(a);if(l){for(s=0;s<l.length;s++)if(Array.isArray(l[s])){var d=l[s];if(!(2>d.length)){var I=d[1];if(Array.isArray(I)&&!(1>I.length)){var w=I[0];if(w!="noop"&&w!="stop"&&w!="close")for(var C=1;C<I.length;C++)I[C]=""}}}}return Lr(l)}catch{return a}}var Dn={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},Ei={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"},Br;function Nn(){}D(Nn,Ur),Nn.prototype.g=function(){return new XMLHttpRequest},Nn.prototype.i=function(){return{}},Br=new Nn;function Kt(s,a,l,d){this.j=s,this.i=a,this.l=l,this.R=d||1,this.U=new je(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new Ti}function Ti(){this.i=null,this.g="",this.h=!1}var vi={},zr={};function $r(s,a,l){s.L=1,s.v=Mn(Lt(a)),s.m=l,s.P=!0,Ii(s,null)}function Ii(s,a){s.F=Date.now(),kn(s),s.A=Lt(s.v);var l=s.A,d=s.R;Array.isArray(d)||(d=[String(d)]),Mi(l.i,"t",d),s.C=0,l=s.j.J,s.h=new Ti,s.g=to(s.j,l?a:null,!s.m),0<s.O&&(s.M=new Wu(R(s.Y,s,s.g),s.O)),a=s.U,l=s.g,d=s.ca;var I="readystatechange";Array.isArray(I)||(I&&(hi[0]=I.toString()),I=hi);for(var w=0;w<I.length;w++){var C=ii(l,I[w],d||a.handleEvent,!1,a.h||a);if(!C)break;a.g[C.key]=C}a=s.H?m(s.H):{},s.m?(s.u||(s.u="POST"),a["Content-Type"]="application/x-www-form-urlencoded",s.g.ea(s.A,s.u,s.m,a)):(s.u="GET",s.g.ea(s.A,s.u,null,a)),ze(),Yu(s.i,s.u,s.A,s.l,s.R,s.m)}Kt.prototype.ca=function(s){s=s.target;const a=this.M;a&&Ut(s)==3?a.j():this.Y(s)},Kt.prototype.Y=function(s){try{if(s==this.g)t:{const pt=Ut(this.g);var a=this.g.Ba();const ve=this.g.Z();if(!(3>pt)&&(pt!=3||this.g&&(this.h.h||this.g.oa()||zi(this.g)))){this.J||pt!=4||a==7||(a==8||0>=ve?ze(3):ze(2)),Gr(this);var l=this.g.Z();this.X=l;e:if(Ai(this)){var d=zi(this.g);s="";var I=d.length,w=Ut(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){ue(this),Ke(this);var C="";break e}this.h.i=new c.TextDecoder}for(a=0;a<I;a++)this.h.h=!0,s+=this.h.i.decode(d[a],{stream:!(w&&a==I-1)});d.length=0,this.h.g+=s,this.C=0,C=this.h.g}else C=this.g.oa();if(this.o=l==200,Ju(this.i,this.u,this.A,this.l,this.R,pt,l),this.o){if(this.T&&!this.K){e:{if(this.g){var Q,ut=this.g;if((Q=ut.g?ut.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!B(Q)){var z=Q;break e}}z=null}if(l=z)ye(this.i,this.l,l,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,Kr(this,l);else{this.o=!1,this.s=3,Tt(12),ue(this),Ke(this);break t}}if(this.P){l=!0;let Pt;for(;!this.J&&this.C<C.length;)if(Pt=el(this,C),Pt==zr){pt==4&&(this.s=4,Tt(14),l=!1),ye(this.i,this.l,null,"[Incomplete Response]");break}else if(Pt==vi){this.s=4,Tt(15),ye(this.i,this.l,C,"[Invalid Chunk]"),l=!1;break}else ye(this.i,this.l,Pt,null),Kr(this,Pt);if(Ai(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),pt!=4||C.length!=0||this.h.h||(this.s=1,Tt(16),l=!1),this.o=this.o&&l,!l)ye(this.i,this.l,C,"[Invalid Chunked Response]"),ue(this),Ke(this);else if(0<C.length&&!this.W){this.W=!0;var mt=this.j;mt.g==this&&mt.ba&&!mt.M&&(mt.j.info("Great, no buffering proxy detected. Bytes received: "+C.length),Jr(mt),mt.M=!0,Tt(11))}}else ye(this.i,this.l,C,null),Kr(this,C);pt==4&&ue(this),this.o&&!this.J&&(pt==4?Xi(this.j,this):(this.o=!1,kn(this)))}else yl(this.g),l==400&&0<C.indexOf("Unknown SID")?(this.s=3,Tt(12)):(this.s=0,Tt(13)),ue(this),Ke(this)}}}catch{}finally{}};function Ai(s){return s.g?s.u=="GET"&&s.L!=2&&s.j.Ca:!1}function el(s,a){var l=s.C,d=a.indexOf(`
21
+ `,l);return d==-1?zr:(l=Number(a.substring(l,d)),isNaN(l)?vi:(d+=1,d+l>a.length?zr:(a=a.slice(d,d+l),s.C=d+l,a)))}Kt.prototype.cancel=function(){this.J=!0,ue(this)};function kn(s){s.S=Date.now()+s.I,wi(s,s.I)}function wi(s,a){if(s.B!=null)throw Error("WatchDog timer not null");s.B=$e(R(s.ba,s),a)}function Gr(s){s.B&&(c.clearTimeout(s.B),s.B=null)}Kt.prototype.ba=function(){this.B=null;const s=Date.now();0<=s-this.S?(Zu(this.i,this.A),this.L!=2&&(ze(),Tt(17)),ue(this),this.s=2,Ke(this)):wi(this,this.S-s)};function Ke(s){s.j.G==0||s.J||Xi(s.j,s)}function ue(s){Gr(s);var a=s.M;a&&typeof a.ma=="function"&&a.ma(),s.M=null,di(s.U),s.g&&(a=s.g,s.g=null,a.abort(),a.ma())}function Kr(s,a){try{var l=s.j;if(l.G!=0&&(l.g==s||Qr(l.h,s))){if(!s.K&&Qr(l.h,s)&&l.G==3){try{var d=l.Da.g.parse(a)}catch{d=null}if(Array.isArray(d)&&d.length==3){var I=d;if(I[0]==0){t:if(!l.u){if(l.g)if(l.g.F+3e3<s.F)Bn(l),qn(l);else break t;Yr(l),Tt(18)}}else l.za=I[1],0<l.za-l.T&&37500>I[2]&&l.F&&l.v==0&&!l.C&&(l.C=$e(R(l.Za,l),6e3));if(1>=Vi(l.h)&&l.ca){try{l.ca()}catch{}l.ca=void 0}}else ce(l,11)}else if((s.K||l.g==s)&&Bn(l),!B(a))for(I=l.Da.g.parse(a),a=0;a<I.length;a++){let z=I[a];if(l.T=z[0],z=z[1],l.G==2)if(z[0]=="c"){l.K=z[1],l.ia=z[2];const mt=z[3];mt!=null&&(l.la=mt,l.j.info("VER="+l.la));const pt=z[4];pt!=null&&(l.Aa=pt,l.j.info("SVER="+l.Aa));const ve=z[5];ve!=null&&typeof ve=="number"&&0<ve&&(d=1.5*ve,l.L=d,l.j.info("backChannelRequestTimeoutMs_="+d)),d=l;const Pt=s.g;if(Pt){const $n=Pt.g?Pt.g.getResponseHeader("X-Client-Wire-Protocol"):null;if($n){var w=d.h;w.g||$n.indexOf("spdy")==-1&&$n.indexOf("quic")==-1&&$n.indexOf("h2")==-1||(w.j=w.l,w.g=new Set,w.h&&(Wr(w,w.h),w.h=null))}if(d.D){const Zr=Pt.g?Pt.g.getResponseHeader("X-HTTP-Session-Id"):null;Zr&&(d.ya=Zr,H(d.I,d.D,Zr))}}l.G=3,l.l&&l.l.ua(),l.ba&&(l.R=Date.now()-s.F,l.j.info("Handshake RTT: "+l.R+"ms")),d=l;var C=s;if(d.qa=Zi(d,d.J?d.ia:null,d.W),C.K){Si(d.h,C);var Q=C,ut=d.L;ut&&(Q.I=ut),Q.B&&(Gr(Q),kn(Q)),d.g=C}else Wi(d);0<l.i.length&&jn(l)}else z[0]!="stop"&&z[0]!="close"||ce(l,7);else l.G==3&&(z[0]=="stop"||z[0]=="close"?z[0]=="stop"?ce(l,7):Xr(l):z[0]!="noop"&&l.l&&l.l.ta(z),l.v=0)}}ze(4)}catch{}}var nl=class{constructor(s,a){this.g=s,this.map=a}};function Ri(s){this.l=s||10,c.PerformanceNavigationTiming?(s=c.performance.getEntriesByType("navigation"),s=0<s.length&&(s[0].nextHopProtocol=="hq"||s[0].nextHopProtocol=="h2")):s=!!(c.chrome&&c.chrome.loadTimes&&c.chrome.loadTimes()&&c.chrome.loadTimes().wasFetchedViaSpdy),this.j=s?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function Pi(s){return s.h?!0:s.g?s.g.size>=s.j:!1}function Vi(s){return s.h?1:s.g?s.g.size:0}function Qr(s,a){return s.h?s.h==a:s.g?s.g.has(a):!1}function Wr(s,a){s.g?s.g.add(a):s.h=a}function Si(s,a){s.h&&s.h==a?s.h=null:s.g&&s.g.has(a)&&s.g.delete(a)}Ri.prototype.cancel=function(){if(this.i=Ci(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const s of this.g.values())s.cancel();this.g.clear()}};function Ci(s){if(s.h!=null)return s.i.concat(s.h.D);if(s.g!=null&&s.g.size!==0){let a=s.i;for(const l of s.g.values())a=a.concat(l.D);return a}return x(s.i)}function rl(s){if(s.V&&typeof s.V=="function")return s.V();if(typeof Map<"u"&&s instanceof Map||typeof Set<"u"&&s instanceof Set)return Array.from(s.values());if(typeof s=="string")return s.split("");if(h(s)){for(var a=[],l=s.length,d=0;d<l;d++)a.push(s[d]);return a}a=[],l=0;for(d in s)a[l++]=s[d];return a}function sl(s){if(s.na&&typeof s.na=="function")return s.na();if(!s.V||typeof s.V!="function"){if(typeof Map<"u"&&s instanceof Map)return Array.from(s.keys());if(!(typeof Set<"u"&&s instanceof Set)){if(h(s)||typeof s=="string"){var a=[];s=s.length;for(var l=0;l<s;l++)a.push(l);return a}a=[],l=0;for(const d in s)a[l++]=d;return a}}}function bi(s,a){if(s.forEach&&typeof s.forEach=="function")s.forEach(a,void 0);else if(h(s)||typeof s=="string")Array.prototype.forEach.call(s,a,void 0);else for(var l=sl(s),d=rl(s),I=d.length,w=0;w<I;w++)a.call(void 0,d[w],l&&l[w],s)}var Di=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function il(s,a){if(s){s=s.split("&");for(var l=0;l<s.length;l++){var d=s[l].indexOf("="),I=null;if(0<=d){var w=s[l].substring(0,d);I=s[l].substring(d+1)}else w=s[l];a(w,I?decodeURIComponent(I.replace(/\+/g," ")):"")}}}function le(s){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,s instanceof le){this.h=s.h,xn(this,s.j),this.o=s.o,this.g=s.g,On(this,s.s),this.l=s.l;var a=s.i,l=new He;l.i=a.i,a.g&&(l.g=new Map(a.g),l.h=a.h),Ni(this,l),this.m=s.m}else s&&(a=String(s).match(Di))?(this.h=!1,xn(this,a[1]||"",!0),this.o=Qe(a[2]||""),this.g=Qe(a[3]||"",!0),On(this,a[4]),this.l=Qe(a[5]||"",!0),Ni(this,a[6]||"",!0),this.m=Qe(a[7]||"")):(this.h=!1,this.i=new He(null,this.h))}le.prototype.toString=function(){var s=[],a=this.j;a&&s.push(We(a,ki,!0),":");var l=this.g;return(l||a=="file")&&(s.push("//"),(a=this.o)&&s.push(We(a,ki,!0),"@"),s.push(encodeURIComponent(String(l)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),l=this.s,l!=null&&s.push(":",String(l))),(l=this.l)&&(this.g&&l.charAt(0)!="/"&&s.push("/"),s.push(We(l,l.charAt(0)=="/"?ul:al,!0))),(l=this.i.toString())&&s.push("?",l),(l=this.m)&&s.push("#",We(l,cl)),s.join("")};function Lt(s){return new le(s)}function xn(s,a,l){s.j=l?Qe(a,!0):a,s.j&&(s.j=s.j.replace(/:$/,""))}function On(s,a){if(a){if(a=Number(a),isNaN(a)||0>a)throw Error("Bad port number "+a);s.s=a}else s.s=null}function Ni(s,a,l){a instanceof He?(s.i=a,hl(s.i,s.h)):(l||(a=We(a,ll)),s.i=new He(a,s.h))}function H(s,a,l){s.i.set(a,l)}function Mn(s){return H(s,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),s}function Qe(s,a){return s?a?decodeURI(s.replace(/%25/g,"%2525")):decodeURIComponent(s):""}function We(s,a,l){return typeof s=="string"?(s=encodeURI(s).replace(a,ol),l&&(s=s.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),s):null}function ol(s){return s=s.charCodeAt(0),"%"+(s>>4&15).toString(16)+(s&15).toString(16)}var ki=/[#\/\?@]/g,al=/[#\?:]/g,ul=/[#\?]/g,ll=/[#\?@]/g,cl=/#/g;function He(s,a){this.h=this.g=null,this.i=s||null,this.j=!!a}function Qt(s){s.g||(s.g=new Map,s.h=0,s.i&&il(s.i,function(a,l){s.add(decodeURIComponent(a.replace(/\+/g," ")),l)}))}r=He.prototype,r.add=function(s,a){Qt(this),this.i=null,s=Ee(this,s);var l=this.g.get(s);return l||this.g.set(s,l=[]),l.push(a),this.h+=1,this};function xi(s,a){Qt(s),a=Ee(s,a),s.g.has(a)&&(s.i=null,s.h-=s.g.get(a).length,s.g.delete(a))}function Oi(s,a){return Qt(s),a=Ee(s,a),s.g.has(a)}r.forEach=function(s,a){Qt(this),this.g.forEach(function(l,d){l.forEach(function(I){s.call(a,I,d,this)},this)},this)},r.na=function(){Qt(this);const s=Array.from(this.g.values()),a=Array.from(this.g.keys()),l=[];for(let d=0;d<a.length;d++){const I=s[d];for(let w=0;w<I.length;w++)l.push(a[d])}return l},r.V=function(s){Qt(this);let a=[];if(typeof s=="string")Oi(this,s)&&(a=a.concat(this.g.get(Ee(this,s))));else{s=Array.from(this.g.values());for(let l=0;l<s.length;l++)a=a.concat(s[l])}return a},r.set=function(s,a){return Qt(this),this.i=null,s=Ee(this,s),Oi(this,s)&&(this.h-=this.g.get(s).length),this.g.set(s,[a]),this.h+=1,this},r.get=function(s,a){return s?(s=this.V(s),0<s.length?String(s[0]):a):a};function Mi(s,a,l){xi(s,a),0<l.length&&(s.i=null,s.g.set(Ee(s,a),x(l)),s.h+=l.length)}r.toString=function(){if(this.i)return this.i;if(!this.g)return"";const s=[],a=Array.from(this.g.keys());for(var l=0;l<a.length;l++){var d=a[l];const w=encodeURIComponent(String(d)),C=this.V(d);for(d=0;d<C.length;d++){var I=w;C[d]!==""&&(I+="="+encodeURIComponent(String(C[d]))),s.push(I)}}return this.i=s.join("&")};function Ee(s,a){return a=String(a),s.j&&(a=a.toLowerCase()),a}function hl(s,a){a&&!s.j&&(Qt(s),s.i=null,s.g.forEach(function(l,d){var I=d.toLowerCase();d!=I&&(xi(this,d),Mi(this,I,l))},s)),s.j=a}function dl(s,a){const l=new Ge;if(c.Image){const d=new Image;d.onload=S(Wt,l,"TestLoadImage: loaded",!0,a,d),d.onerror=S(Wt,l,"TestLoadImage: error",!1,a,d),d.onabort=S(Wt,l,"TestLoadImage: abort",!1,a,d),d.ontimeout=S(Wt,l,"TestLoadImage: timeout",!1,a,d),c.setTimeout(function(){d.ontimeout&&d.ontimeout()},1e4),d.src=s}else a(!1)}function fl(s,a){const l=new Ge,d=new AbortController,I=setTimeout(()=>{d.abort(),Wt(l,"TestPingServer: timeout",!1,a)},1e4);fetch(s,{signal:d.signal}).then(w=>{clearTimeout(I),w.ok?Wt(l,"TestPingServer: ok",!0,a):Wt(l,"TestPingServer: server error",!1,a)}).catch(()=>{clearTimeout(I),Wt(l,"TestPingServer: error",!1,a)})}function Wt(s,a,l,d,I){try{I&&(I.onload=null,I.onerror=null,I.onabort=null,I.ontimeout=null),d(l)}catch{}}function ml(){this.g=new Xu}function pl(s,a,l){const d=l||"";try{bi(s,function(I,w){let C=I;f(I)&&(C=Lr(I)),a.push(d+w+"="+encodeURIComponent(C))})}catch(I){throw a.push(d+"type="+encodeURIComponent("_badmap")),I}}function Fn(s){this.l=s.Ub||null,this.j=s.eb||!1}D(Fn,Ur),Fn.prototype.g=function(){return new Ln(this.l,this.j)},Fn.prototype.i=(function(s){return function(){return s}})({});function Ln(s,a){ft.call(this),this.D=s,this.o=a,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}D(Ln,ft),r=Ln.prototype,r.open=function(s,a){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=s,this.A=a,this.readyState=1,Ye(this)},r.send=function(s){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;const a={headers:this.u,method:this.B,credentials:this.m,cache:void 0};s&&(a.body=s),(this.D||c).fetch(new Request(this.A,a)).then(this.Sa.bind(this),this.ga.bind(this))},r.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&this.readyState!=4&&(this.g=!1,Xe(this)),this.readyState=0},r.Sa=function(s){if(this.g&&(this.l=s,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=s.headers,this.readyState=2,Ye(this)),this.g&&(this.readyState=3,Ye(this),this.g)))if(this.responseType==="arraybuffer")s.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof c.ReadableStream<"u"&&"body"in s){if(this.j=s.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;Fi(this)}else s.text().then(this.Ra.bind(this),this.ga.bind(this))};function Fi(s){s.j.read().then(s.Pa.bind(s)).catch(s.ga.bind(s))}r.Pa=function(s){if(this.g){if(this.o&&s.value)this.response.push(s.value);else if(!this.o){var a=s.value?s.value:new Uint8Array(0);(a=this.v.decode(a,{stream:!s.done}))&&(this.response=this.responseText+=a)}s.done?Xe(this):Ye(this),this.readyState==3&&Fi(this)}},r.Ra=function(s){this.g&&(this.response=this.responseText=s,Xe(this))},r.Qa=function(s){this.g&&(this.response=s,Xe(this))},r.ga=function(){this.g&&Xe(this)};function Xe(s){s.readyState=4,s.l=null,s.j=null,s.v=null,Ye(s)}r.setRequestHeader=function(s,a){this.u.append(s,a)},r.getResponseHeader=function(s){return this.h&&this.h.get(s.toLowerCase())||""},r.getAllResponseHeaders=function(){if(!this.h)return"";const s=[],a=this.h.entries();for(var l=a.next();!l.done;)l=l.value,s.push(l[0]+": "+l[1]),l=a.next();return s.join(`\r
22
+ `)};function Ye(s){s.onreadystatechange&&s.onreadystatechange.call(s)}Object.defineProperty(Ln.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(s){this.m=s?"include":"same-origin"}});function Li(s){let a="";return at(s,function(l,d){a+=d,a+=":",a+=l,a+=`\r
23
+ `}),a}function Hr(s,a,l){t:{for(d in l){var d=!1;break t}d=!0}d||(l=Li(l),typeof s=="string"?l!=null&&encodeURIComponent(String(l)):H(s,a,l))}function J(s){ft.call(this),this.headers=new Map,this.o=s||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}D(J,ft);var gl=/^https?$/i,_l=["POST","PUT"];r=J.prototype,r.Ha=function(s){this.J=s},r.ea=function(s,a,l,d){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+s);a=a?a.toUpperCase():"GET",this.D=s,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():Br.g(),this.v=this.o?fi(this.o):fi(Br),this.g.onreadystatechange=R(this.Ea,this);try{this.B=!0,this.g.open(a,String(s),!0),this.B=!1}catch(w){Ui(this,w);return}if(s=l||"",l=new Map(this.headers),d)if(Object.getPrototypeOf(d)===Object.prototype)for(var I in d)l.set(I,d[I]);else if(typeof d.keys=="function"&&typeof d.get=="function")for(const w of d.keys())l.set(w,d.get(w));else throw Error("Unknown input type for opt_headers: "+String(d));d=Array.from(l.keys()).find(w=>w.toLowerCase()=="content-type"),I=c.FormData&&s instanceof c.FormData,!(0<=Array.prototype.indexOf.call(_l,a,void 0))||d||I||l.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[w,C]of l)this.g.setRequestHeader(w,C);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{Bi(this),this.u=!0,this.g.send(s),this.u=!1}catch(w){Ui(this,w)}};function Ui(s,a){s.h=!1,s.g&&(s.j=!0,s.g.abort(),s.j=!1),s.l=a,s.m=5,qi(s),Un(s)}function qi(s){s.A||(s.A=!0,Et(s,"complete"),Et(s,"error"))}r.abort=function(s){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=s||7,Et(this,"complete"),Et(this,"abort"),Un(this))},r.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Un(this,!0)),J.aa.N.call(this)},r.Ea=function(){this.s||(this.B||this.u||this.j?ji(this):this.bb())},r.bb=function(){ji(this)};function ji(s){if(s.h&&typeof u<"u"&&(!s.v[1]||Ut(s)!=4||s.Z()!=2)){if(s.u&&Ut(s)==4)li(s.Ea,0,s);else if(Et(s,"readystatechange"),Ut(s)==4){s.h=!1;try{const C=s.Z();t:switch(C){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var a=!0;break t;default:a=!1}var l;if(!(l=a)){var d;if(d=C===0){var I=String(s.D).match(Di)[1]||null;!I&&c.self&&c.self.location&&(I=c.self.location.protocol.slice(0,-1)),d=!gl.test(I?I.toLowerCase():"")}l=d}if(l)Et(s,"complete"),Et(s,"success");else{s.m=6;try{var w=2<Ut(s)?s.g.statusText:""}catch{w=""}s.l=w+" ["+s.Z()+"]",qi(s)}}finally{Un(s)}}}}function Un(s,a){if(s.g){Bi(s);const l=s.g,d=s.v[0]?()=>{}:null;s.g=null,s.v=null,a||Et(s,"ready");try{l.onreadystatechange=d}catch{}}}function Bi(s){s.I&&(c.clearTimeout(s.I),s.I=null)}r.isActive=function(){return!!this.g};function Ut(s){return s.g?s.g.readyState:0}r.Z=function(){try{return 2<Ut(this)?this.g.status:-1}catch{return-1}},r.oa=function(){try{return this.g?this.g.responseText:""}catch{return""}},r.Oa=function(s){if(this.g){var a=this.g.responseText;return s&&a.indexOf(s)==0&&(a=a.substring(s.length)),Hu(a)}};function zi(s){try{if(!s.g)return null;if("response"in s.g)return s.g.response;switch(s.H){case"":case"text":return s.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in s.g)return s.g.mozResponseArrayBuffer}return null}catch{return null}}function yl(s){const a={};s=(s.g&&2<=Ut(s)&&s.g.getAllResponseHeaders()||"").split(`\r
24
+ `);for(let d=0;d<s.length;d++){if(B(s[d]))continue;var l=T(s[d]);const I=l[0];if(l=l[1],typeof l!="string")continue;l=l.trim();const w=a[I]||[];a[I]=w,w.push(l)}v(a,function(d){return d.join(", ")})}r.Ba=function(){return this.m},r.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function Je(s,a,l){return l&&l.internalChannelParams&&l.internalChannelParams[s]||a}function $i(s){this.Aa=0,this.i=[],this.j=new Ge,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=Je("failFast",!1,s),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=Je("baseRetryDelayMs",5e3,s),this.cb=Je("retryDelaySeedMs",1e4,s),this.Wa=Je("forwardChannelMaxRetries",2,s),this.wa=Je("forwardChannelRequestTimeoutMs",2e4,s),this.pa=s&&s.xmlHttpFactory||void 0,this.Xa=s&&s.Tb||void 0,this.Ca=s&&s.useFetchStreams||!1,this.L=void 0,this.J=s&&s.supportsCrossDomainXhr||!1,this.K="",this.h=new Ri(s&&s.concurrentRequestLimit),this.Da=new ml,this.P=s&&s.fastHandshake||!1,this.O=s&&s.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=s&&s.Rb||!1,s&&s.xa&&this.j.xa(),s&&s.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&s&&s.detectBufferingProxy||!1,this.ja=void 0,s&&s.longPollingTimeout&&0<s.longPollingTimeout&&(this.ja=s.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}r=$i.prototype,r.la=8,r.G=1,r.connect=function(s,a,l,d){Tt(0),this.W=s,this.H=a||{},l&&d!==void 0&&(this.H.OSID=l,this.H.OAID=d),this.F=this.X,this.I=Zi(this,null,this.W),jn(this)};function Xr(s){if(Gi(s),s.G==3){var a=s.U++,l=Lt(s.I);if(H(l,"SID",s.K),H(l,"RID",a),H(l,"TYPE","terminate"),Ze(s,l),a=new Kt(s,s.j,a),a.L=2,a.v=Mn(Lt(l)),l=!1,c.navigator&&c.navigator.sendBeacon)try{l=c.navigator.sendBeacon(a.v.toString(),"")}catch{}!l&&c.Image&&(new Image().src=a.v,l=!0),l||(a.g=to(a.j,null),a.g.ea(a.v)),a.F=Date.now(),kn(a)}Ji(s)}function qn(s){s.g&&(Jr(s),s.g.cancel(),s.g=null)}function Gi(s){qn(s),s.u&&(c.clearTimeout(s.u),s.u=null),Bn(s),s.h.cancel(),s.s&&(typeof s.s=="number"&&c.clearTimeout(s.s),s.s=null)}function jn(s){if(!Pi(s.h)&&!s.s){s.s=!0;var a=s.Ga;Le||si(),Ue||(Le(),Ue=!0),br.add(a,s),s.B=0}}function El(s,a){return Vi(s.h)>=s.h.j-(s.s?1:0)?!1:s.s?(s.i=a.D.concat(s.i),!0):s.G==1||s.G==2||s.B>=(s.Va?0:s.Wa)?!1:(s.s=$e(R(s.Ga,s,a),Yi(s,s.B)),s.B++,!0)}r.Ga=function(s){if(this.s)if(this.s=null,this.G==1){if(!s){this.U=Math.floor(1e5*Math.random()),s=this.U++;const I=new Kt(this,this.j,s);let w=this.o;if(this.S&&(w?(w=m(w),y(w,this.S)):w=this.S),this.m!==null||this.O||(I.H=w,w=null),this.P)t:{for(var a=0,l=0;l<this.i.length;l++){e:{var d=this.i[l];if("__data__"in d.map&&(d=d.map.__data__,typeof d=="string")){d=d.length;break e}d=void 0}if(d===void 0)break;if(a+=d,4096<a){a=l;break t}if(a===4096||l===this.i.length-1){a=l+1;break t}}a=1e3}else a=1e3;a=Qi(this,I,a),l=Lt(this.I),H(l,"RID",s),H(l,"CVER",22),this.D&&H(l,"X-HTTP-Session-Id",this.D),Ze(this,l),w&&(this.O?a="headers="+encodeURIComponent(String(Li(w)))+"&"+a:this.m&&Hr(l,this.m,w)),Wr(this.h,I),this.Ua&&H(l,"TYPE","init"),this.P?(H(l,"$req",a),H(l,"SID","null"),I.T=!0,$r(I,l,null)):$r(I,l,a),this.G=2}}else this.G==3&&(s?Ki(this,s):this.i.length==0||Pi(this.h)||Ki(this))};function Ki(s,a){var l;a?l=a.l:l=s.U++;const d=Lt(s.I);H(d,"SID",s.K),H(d,"RID",l),H(d,"AID",s.T),Ze(s,d),s.m&&s.o&&Hr(d,s.m,s.o),l=new Kt(s,s.j,l,s.B+1),s.m===null&&(l.H=s.o),a&&(s.i=a.D.concat(s.i)),a=Qi(s,l,1e3),l.I=Math.round(.5*s.wa)+Math.round(.5*s.wa*Math.random()),Wr(s.h,l),$r(l,d,a)}function Ze(s,a){s.H&&at(s.H,function(l,d){H(a,d,l)}),s.l&&bi({},function(l,d){H(a,d,l)})}function Qi(s,a,l){l=Math.min(s.i.length,l);var d=s.l?R(s.l.Na,s.l,s):null;t:{var I=s.i;let w=-1;for(;;){const C=["count="+l];w==-1?0<l?(w=I[0].g,C.push("ofs="+w)):w=0:C.push("ofs="+w);let Q=!0;for(let ut=0;ut<l;ut++){let z=I[ut].g;const mt=I[ut].map;if(z-=w,0>z)w=Math.max(0,I[ut].g-100),Q=!1;else try{pl(mt,C,"req"+z+"_")}catch{d&&d(mt)}}if(Q){d=C.join("&");break t}}}return s=s.i.splice(0,l),a.D=s,d}function Wi(s){if(!s.g&&!s.u){s.Y=1;var a=s.Fa;Le||si(),Ue||(Le(),Ue=!0),br.add(a,s),s.v=0}}function Yr(s){return s.g||s.u||3<=s.v?!1:(s.Y++,s.u=$e(R(s.Fa,s),Yi(s,s.v)),s.v++,!0)}r.Fa=function(){if(this.u=null,Hi(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var s=2*this.R;this.j.info("BP detection timer enabled: "+s),this.A=$e(R(this.ab,this),s)}},r.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,Tt(10),qn(this),Hi(this))};function Jr(s){s.A!=null&&(c.clearTimeout(s.A),s.A=null)}function Hi(s){s.g=new Kt(s,s.j,"rpc",s.Y),s.m===null&&(s.g.H=s.o),s.g.O=0;var a=Lt(s.qa);H(a,"RID","rpc"),H(a,"SID",s.K),H(a,"AID",s.T),H(a,"CI",s.F?"0":"1"),!s.F&&s.ja&&H(a,"TO",s.ja),H(a,"TYPE","xmlhttp"),Ze(s,a),s.m&&s.o&&Hr(a,s.m,s.o),s.L&&(s.g.I=s.L);var l=s.g;s=s.ia,l.L=1,l.v=Mn(Lt(a)),l.m=null,l.P=!0,Ii(l,s)}r.Za=function(){this.C!=null&&(this.C=null,qn(this),Yr(this),Tt(19))};function Bn(s){s.C!=null&&(c.clearTimeout(s.C),s.C=null)}function Xi(s,a){var l=null;if(s.g==a){Bn(s),Jr(s),s.g=null;var d=2}else if(Qr(s.h,a))l=a.D,Si(s.h,a),d=1;else return;if(s.G!=0){if(a.o)if(d==1){l=a.m?a.m.length:0,a=Date.now()-a.F;var I=s.B;d=bn(),Et(d,new yi(d,l)),jn(s)}else Wi(s);else if(I=a.s,I==3||I==0&&0<a.X||!(d==1&&El(s,a)||d==2&&Yr(s)))switch(l&&0<l.length&&(a=s.h,a.i=a.i.concat(l)),I){case 1:ce(s,5);break;case 4:ce(s,10);break;case 3:ce(s,6);break;default:ce(s,2)}}}function Yi(s,a){let l=s.Ta+Math.floor(Math.random()*s.cb);return s.isActive()||(l*=2),l*a}function ce(s,a){if(s.j.info("Error code "+a),a==2){var l=R(s.fb,s),d=s.Xa;const I=!d;d=new le(d||"//www.google.com/images/cleardot.gif"),c.location&&c.location.protocol=="http"||xn(d,"https"),Mn(d),I?dl(d.toString(),l):fl(d.toString(),l)}else Tt(2);s.G=0,s.l&&s.l.sa(a),Ji(s),Gi(s)}r.fb=function(s){s?(this.j.info("Successfully pinged google.com"),Tt(2)):(this.j.info("Failed to ping google.com"),Tt(1))};function Ji(s){if(s.G=0,s.ka=[],s.l){const a=Ci(s.h);(a.length!=0||s.i.length!=0)&&(b(s.ka,a),b(s.ka,s.i),s.h.i.length=0,x(s.i),s.i.length=0),s.l.ra()}}function Zi(s,a,l){var d=l instanceof le?Lt(l):new le(l);if(d.g!="")a&&(d.g=a+"."+d.g),On(d,d.s);else{var I=c.location;d=I.protocol,a=a?a+"."+I.hostname:I.hostname,I=+I.port;var w=new le(null);d&&xn(w,d),a&&(w.g=a),I&&On(w,I),l&&(w.l=l),d=w}return l=s.D,a=s.ya,l&&a&&H(d,l,a),H(d,"VER",s.la),Ze(s,d),d}function to(s,a,l){if(a&&!s.J)throw Error("Can't create secondary domain capable XhrIo object.");return a=s.Ca&&!s.pa?new J(new Fn({eb:l})):new J(s.pa),a.Ha(s.J),a}r.isActive=function(){return!!this.l&&this.l.isActive(this)};function eo(){}r=eo.prototype,r.ua=function(){},r.ta=function(){},r.sa=function(){},r.ra=function(){},r.isActive=function(){return!0},r.Na=function(){};function zn(){}zn.prototype.g=function(s,a){return new At(s,a)};function At(s,a){ft.call(this),this.g=new $i(a),this.l=s,this.h=a&&a.messageUrlParams||null,s=a&&a.messageHeaders||null,a&&a.clientProtocolHeaderRequired&&(s?s["X-Client-Protocol"]="webchannel":s={"X-Client-Protocol":"webchannel"}),this.g.o=s,s=a&&a.initMessageHeaders||null,a&&a.messageContentType&&(s?s["X-WebChannel-Content-Type"]=a.messageContentType:s={"X-WebChannel-Content-Type":a.messageContentType}),a&&a.va&&(s?s["X-WebChannel-Client-Profile"]=a.va:s={"X-WebChannel-Client-Profile":a.va}),this.g.S=s,(s=a&&a.Sb)&&!B(s)&&(this.g.m=s),this.v=a&&a.supportsCrossDomainXhr||!1,this.u=a&&a.sendRawJson||!1,(a=a&&a.httpSessionIdParam)&&!B(a)&&(this.g.D=a,s=this.h,s!==null&&a in s&&(s=this.h,a in s&&delete s[a])),this.j=new Te(this)}D(At,ft),At.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},At.prototype.close=function(){Xr(this.g)},At.prototype.o=function(s){var a=this.g;if(typeof s=="string"){var l={};l.__data__=s,s=l}else this.u&&(l={},l.__data__=Lr(s),s=l);a.i.push(new nl(a.Ya++,s)),a.G==3&&jn(a)},At.prototype.N=function(){this.g.l=null,delete this.j,Xr(this.g),delete this.g,At.aa.N.call(this)};function no(s){qr.call(this),s.__headers__&&(this.headers=s.__headers__,this.statusCode=s.__status__,delete s.__headers__,delete s.__status__);var a=s.__sm__;if(a){t:{for(const l in a){s=l;break t}s=void 0}(this.i=s)&&(s=this.i,a=a!==null&&s in a?a[s]:void 0),this.data=a}else this.data=s}D(no,qr);function ro(){jr.call(this),this.status=1}D(ro,jr);function Te(s){this.g=s}D(Te,eo),Te.prototype.ua=function(){Et(this.g,"a")},Te.prototype.ta=function(s){Et(this.g,new no(s))},Te.prototype.sa=function(s){Et(this.g,new ro)},Te.prototype.ra=function(){Et(this.g,"b")},zn.prototype.createWebChannel=zn.prototype.g,At.prototype.send=At.prototype.o,At.prototype.open=At.prototype.m,At.prototype.close=At.prototype.close,ga=function(){return new zn},pa=function(){return bn()},ma=ae,is={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},Dn.NO_ERROR=0,Dn.TIMEOUT=8,Dn.HTTP_ERROR=6,Xn=Dn,Ei.COMPLETE="complete",fa=Ei,mi.EventType=Be,Be.OPEN="a",Be.CLOSE="b",Be.ERROR="c",Be.MESSAGE="d",ft.prototype.listen=ft.prototype.K,en=mi,J.prototype.listenOnce=J.prototype.L,J.prototype.getLastError=J.prototype.Ka,J.prototype.getLastErrorCode=J.prototype.Ba,J.prototype.getStatus=J.prototype.Z,J.prototype.getResponseJson=J.prototype.Oa,J.prototype.getResponseText=J.prototype.oa,J.prototype.send=J.prototype.ea,J.prototype.setWithCredentials=J.prototype.Ha,da=J}).apply(typeof Gn<"u"?Gn:typeof self<"u"?self:typeof window<"u"?window:{});const ao="@firebase/firestore",uo="4.8.0";/**
25
+ * @license
26
+ * Copyright 2017 Google LLC
27
+ *
28
+ * Licensed under the Apache License, Version 2.0 (the "License");
29
+ * you may not use this file except in compliance with the License.
30
+ * You may obtain a copy of the License at
31
+ *
32
+ * http://www.apache.org/licenses/LICENSE-2.0
33
+ *
34
+ * Unless required by applicable law or agreed to in writing, software
35
+ * distributed under the License is distributed on an "AS IS" BASIS,
36
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37
+ * See the License for the specific language governing permissions and
38
+ * limitations under the License.
39
+ */class _t{constructor(t){this.uid=t}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(t){return t.uid===this.uid}}_t.UNAUTHENTICATED=new _t(null),_t.GOOGLE_CREDENTIALS=new _t("google-credentials-uid"),_t.FIRST_PARTY=new _t("first-party-uid"),_t.MOCK_USER=new _t("mock-user");/**
40
+ * @license
41
+ * Copyright 2017 Google LLC
42
+ *
43
+ * Licensed under the Apache License, Version 2.0 (the "License");
44
+ * you may not use this file except in compliance with the License.
45
+ * You may obtain a copy of the License at
46
+ *
47
+ * http://www.apache.org/licenses/LICENSE-2.0
48
+ *
49
+ * Unless required by applicable law or agreed to in writing, software
50
+ * distributed under the License is distributed on an "AS IS" BASIS,
51
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
52
+ * See the License for the specific language governing permissions and
53
+ * limitations under the License.
54
+ */let ke="11.10.0";/**
55
+ * @license
56
+ * Copyright 2017 Google LLC
57
+ *
58
+ * Licensed under the Apache License, Version 2.0 (the "License");
59
+ * you may not use this file except in compliance with the License.
60
+ * You may obtain a copy of the License at
61
+ *
62
+ * http://www.apache.org/licenses/LICENSE-2.0
63
+ *
64
+ * Unless required by applicable law or agreed to in writing, software
65
+ * distributed under the License is distributed on an "AS IS" BASIS,
66
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
67
+ * See the License for the specific language governing permissions and
68
+ * limitations under the License.
69
+ */const me=new kl("@firebase/firestore");function Ie(){return me.logLevel}function N(r,...t){if(me.logLevel<=qt.DEBUG){const e=t.map(As);me.debug(`Firestore (${ke}): ${r}`,...e)}}function zt(r,...t){if(me.logLevel<=qt.ERROR){const e=t.map(As);me.error(`Firestore (${ke}): ${r}`,...e)}}function Jt(r,...t){if(me.logLevel<=qt.WARN){const e=t.map(As);me.warn(`Firestore (${ke}): ${r}`,...e)}}function As(r){if(typeof r=="string")return r;try{/**
70
+ * @license
71
+ * Copyright 2020 Google LLC
72
+ *
73
+ * Licensed under the Apache License, Version 2.0 (the "License");
74
+ * you may not use this file except in compliance with the License.
75
+ * You may obtain a copy of the License at
76
+ *
77
+ * http://www.apache.org/licenses/LICENSE-2.0
78
+ *
79
+ * Unless required by applicable law or agreed to in writing, software
80
+ * distributed under the License is distributed on an "AS IS" BASIS,
81
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
82
+ * See the License for the specific language governing permissions and
83
+ * limitations under the License.
84
+ */return(function(e){return JSON.stringify(e)})(r)}catch{return r}}/**
85
+ * @license
86
+ * Copyright 2017 Google LLC
87
+ *
88
+ * Licensed under the Apache License, Version 2.0 (the "License");
89
+ * you may not use this file except in compliance with the License.
90
+ * You may obtain a copy of the License at
91
+ *
92
+ * http://www.apache.org/licenses/LICENSE-2.0
93
+ *
94
+ * Unless required by applicable law or agreed to in writing, software
95
+ * distributed under the License is distributed on an "AS IS" BASIS,
96
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
97
+ * See the License for the specific language governing permissions and
98
+ * limitations under the License.
99
+ */function M(r,t,e){let n="Unexpected state";typeof t=="string"?n=t:e=t,_a(r,n,e)}function _a(r,t,e){let n=`FIRESTORE (${ke}) INTERNAL ASSERTION FAILED: ${t} (ID: ${r.toString(16)})`;if(e!==void 0)try{n+=" CONTEXT: "+JSON.stringify(e)}catch{n+=" CONTEXT: "+e}throw zt(n),new Error(n)}function G(r,t,e,n){let i="Unexpected state";typeof e=="string"?i=e:n=e,r||_a(t,i,n)}function L(r,t){return r}/**
100
+ * @license
101
+ * Copyright 2017 Google LLC
102
+ *
103
+ * Licensed under the Apache License, Version 2.0 (the "License");
104
+ * you may not use this file except in compliance with the License.
105
+ * You may obtain a copy of the License at
106
+ *
107
+ * http://www.apache.org/licenses/LICENSE-2.0
108
+ *
109
+ * Unless required by applicable law or agreed to in writing, software
110
+ * distributed under the License is distributed on an "AS IS" BASIS,
111
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
112
+ * See the License for the specific language governing permissions and
113
+ * limitations under the License.
114
+ */const P={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class k extends bl{constructor(t,e){super(t,e),this.code=t,this.message=e,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/**
115
+ * @license
116
+ * Copyright 2017 Google LLC
117
+ *
118
+ * Licensed under the Apache License, Version 2.0 (the "License");
119
+ * you may not use this file except in compliance with the License.
120
+ * You may obtain a copy of the License at
121
+ *
122
+ * http://www.apache.org/licenses/LICENSE-2.0
123
+ *
124
+ * Unless required by applicable law or agreed to in writing, software
125
+ * distributed under the License is distributed on an "AS IS" BASIS,
126
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127
+ * See the License for the specific language governing permissions and
128
+ * limitations under the License.
129
+ */class jt{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}}/**
130
+ * @license
131
+ * Copyright 2017 Google LLC
132
+ *
133
+ * Licensed under the Apache License, Version 2.0 (the "License");
134
+ * you may not use this file except in compliance with the License.
135
+ * You may obtain a copy of the License at
136
+ *
137
+ * http://www.apache.org/licenses/LICENSE-2.0
138
+ *
139
+ * Unless required by applicable law or agreed to in writing, software
140
+ * distributed under the License is distributed on an "AS IS" BASIS,
141
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
142
+ * See the License for the specific language governing permissions and
143
+ * limitations under the License.
144
+ */class ya{constructor(t,e){this.user=e,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${t}`)}}class zl{getToken(){return Promise.resolve(null)}invalidateToken(){}start(t,e){t.enqueueRetryable((()=>e(_t.UNAUTHENTICATED)))}shutdown(){}}class $l{constructor(t){this.token=t,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(t,e){this.changeListener=e,t.enqueueRetryable((()=>e(this.token.user)))}shutdown(){this.changeListener=null}}class Gl{constructor(t){this.t=t,this.currentUser=_t.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(t,e){G(this.o===void 0,42304);let n=this.i;const i=h=>this.i!==n?(n=this.i,e(h)):Promise.resolve();let o=new jt;this.o=()=>{this.i++,this.currentUser=this.u(),o.resolve(),o=new jt,t.enqueueRetryable((()=>i(this.currentUser)))};const u=()=>{const h=o;t.enqueueRetryable((async()=>{await h.promise,await i(this.currentUser)}))},c=h=>{N("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=h,this.o&&(this.auth.addAuthTokenListener(this.o),u())};this.t.onInit((h=>c(h))),setTimeout((()=>{if(!this.auth){const h=this.t.getImmediate({optional:!0});h?c(h):(N("FirebaseAuthCredentialsProvider","Auth not yet detected"),o.resolve(),o=new jt)}}),0),u()}getToken(){const t=this.i,e=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(e).then((n=>this.i!==t?(N("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):n?(G(typeof n.accessToken=="string",31837,{l:n}),new ya(n.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const t=this.auth&&this.auth.getUid();return G(t===null||typeof t=="string",2055,{h:t}),new _t(t)}}class Kl{constructor(t,e,n){this.P=t,this.T=e,this.I=n,this.type="FirstParty",this.user=_t.FIRST_PARTY,this.A=new Map}R(){return this.I?this.I():null}get headers(){this.A.set("X-Goog-AuthUser",this.P);const t=this.R();return t&&this.A.set("Authorization",t),this.T&&this.A.set("X-Goog-Iam-Authorization-Token",this.T),this.A}}class Ql{constructor(t,e,n){this.P=t,this.T=e,this.I=n}getToken(){return Promise.resolve(new Kl(this.P,this.T,this.I))}start(t,e){t.enqueueRetryable((()=>e(_t.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class lo{constructor(t){this.value=t,this.type="AppCheck",this.headers=new Map,t&&t.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class Wl{constructor(t,e){this.V=e,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,Ul(t)&&t.settings.appCheckToken&&(this.p=t.settings.appCheckToken)}start(t,e){G(this.o===void 0,3512);const n=o=>{o.error!=null&&N("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${o.error.message}`);const u=o.token!==this.m;return this.m=o.token,N("FirebaseAppCheckTokenProvider",`Received ${u?"new":"existing"} token.`),u?e(o.token):Promise.resolve()};this.o=o=>{t.enqueueRetryable((()=>n(o)))};const i=o=>{N("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=o,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit((o=>i(o))),setTimeout((()=>{if(!this.appCheck){const o=this.V.getImmediate({optional:!0});o?i(o):N("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){if(this.p)return Promise.resolve(new lo(this.p));const t=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(t).then((e=>e?(G(typeof e.token=="string",44558,{tokenResult:e}),this.m=e.token,new lo(e.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}/**
145
+ * @license
146
+ * Copyright 2020 Google LLC
147
+ *
148
+ * Licensed under the Apache License, Version 2.0 (the "License");
149
+ * you may not use this file except in compliance with the License.
150
+ * You may obtain a copy of the License at
151
+ *
152
+ * http://www.apache.org/licenses/LICENSE-2.0
153
+ *
154
+ * Unless required by applicable law or agreed to in writing, software
155
+ * distributed under the License is distributed on an "AS IS" BASIS,
156
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
157
+ * See the License for the specific language governing permissions and
158
+ * limitations under the License.
159
+ */function Hl(r){const t=typeof self<"u"&&(self.crypto||self.msCrypto),e=new Uint8Array(r);if(t&&typeof t.getRandomValues=="function")t.getRandomValues(e);else for(let n=0;n<r;n++)e[n]=Math.floor(256*Math.random());return e}/**
160
+ * @license
161
+ * Copyright 2023 Google LLC
162
+ *
163
+ * Licensed under the Apache License, Version 2.0 (the "License");
164
+ * you may not use this file except in compliance with the License.
165
+ * You may obtain a copy of the License at
166
+ *
167
+ * http://www.apache.org/licenses/LICENSE-2.0
168
+ *
169
+ * Unless required by applicable law or agreed to in writing, software
170
+ * distributed under the License is distributed on an "AS IS" BASIS,
171
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
172
+ * See the License for the specific language governing permissions and
173
+ * limitations under the License.
174
+ */function Ea(){return new TextEncoder}/**
175
+ * @license
176
+ * Copyright 2017 Google LLC
177
+ *
178
+ * Licensed under the Apache License, Version 2.0 (the "License");
179
+ * you may not use this file except in compliance with the License.
180
+ * You may obtain a copy of the License at
181
+ *
182
+ * http://www.apache.org/licenses/LICENSE-2.0
183
+ *
184
+ * Unless required by applicable law or agreed to in writing, software
185
+ * distributed under the License is distributed on an "AS IS" BASIS,
186
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
187
+ * See the License for the specific language governing permissions and
188
+ * limitations under the License.
189
+ */class ws{static newId(){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=62*Math.floor(4.129032258064516);let n="";for(;n.length<20;){const i=Hl(40);for(let o=0;o<i.length;++o)n.length<20&&i[o]<e&&(n+=t.charAt(i[o]%62))}return n}}function U(r,t){return r<t?-1:r>t?1:0}function os(r,t){let e=0;for(;e<r.length&&e<t.length;){const n=r.codePointAt(e),i=t.codePointAt(e);if(n!==i){if(n<128&&i<128)return U(n,i);{const o=Ea(),u=Xl(o.encode(co(r,e)),o.encode(co(t,e)));return u!==0?u:U(n,i)}}e+=n>65535?2:1}return U(r.length,t.length)}function co(r,t){return r.codePointAt(t)>65535?r.substring(t,t+2):r.substring(t,t+1)}function Xl(r,t){for(let e=0;e<r.length&&e<t.length;++e)if(r[e]!==t[e])return U(r[e],t[e]);return U(r.length,t.length)}function Ve(r,t,e){return r.length===t.length&&r.every(((n,i)=>e(n,t[i])))}/**
190
+ * @license
191
+ * Copyright 2017 Google LLC
192
+ *
193
+ * Licensed under the Apache License, Version 2.0 (the "License");
194
+ * you may not use this file except in compliance with the License.
195
+ * You may obtain a copy of the License at
196
+ *
197
+ * http://www.apache.org/licenses/LICENSE-2.0
198
+ *
199
+ * Unless required by applicable law or agreed to in writing, software
200
+ * distributed under the License is distributed on an "AS IS" BASIS,
201
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ * See the License for the specific language governing permissions and
203
+ * limitations under the License.
204
+ */const ho="__name__";class St{constructor(t,e,n){e===void 0?e=0:e>t.length&&M(637,{offset:e,range:t.length}),n===void 0?n=t.length-e:n>t.length-e&&M(1746,{length:n,range:t.length-e}),this.segments=t,this.offset=e,this.len=n}get length(){return this.len}isEqual(t){return St.comparator(this,t)===0}child(t){const e=this.segments.slice(this.offset,this.limit());return t instanceof St?t.forEach((n=>{e.push(n)})):e.push(t),this.construct(e)}limit(){return this.offset+this.length}popFirst(t){return t=t===void 0?1:t,this.construct(this.segments,this.offset+t,this.length-t)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(t){return this.segments[this.offset+t]}isEmpty(){return this.length===0}isPrefixOf(t){if(t.length<this.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}isImmediateParentOf(t){if(this.length+1!==t.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}forEach(t){for(let e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(t,e){const n=Math.min(t.length,e.length);for(let i=0;i<n;i++){const o=St.compareSegments(t.get(i),e.get(i));if(o!==0)return o}return U(t.length,e.length)}static compareSegments(t,e){const n=St.isNumericId(t),i=St.isNumericId(e);return n&&!i?-1:!n&&i?1:n&&i?St.extractNumericId(t).compare(St.extractNumericId(e)):os(t,e)}static isNumericId(t){return t.startsWith("__id")&&t.endsWith("__")}static extractNumericId(t){return Xt.fromString(t.substring(4,t.length-2))}}class X extends St{construct(t,e,n){return new X(t,e,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...t){const e=[];for(const n of t){if(n.indexOf("//")>=0)throw new k(P.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);e.push(...n.split("/").filter((i=>i.length>0)))}return new X(e)}static emptyPath(){return new X([])}}const Yl=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class ct extends St{construct(t,e,n){return new ct(t,e,n)}static isValidIdentifier(t){return Yl.test(t)}canonicalString(){return this.toArray().map((t=>(t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),ct.isValidIdentifier(t)||(t="`"+t+"`"),t))).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===ho}static keyField(){return new ct([ho])}static fromServerFormat(t){const e=[];let n="",i=0;const o=()=>{if(n.length===0)throw new k(P.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);e.push(n),n=""};let u=!1;for(;i<t.length;){const c=t[i];if(c==="\\"){if(i+1===t.length)throw new k(P.INVALID_ARGUMENT,"Path has trailing escape character: "+t);const h=t[i+1];if(h!=="\\"&&h!=="."&&h!=="`")throw new k(P.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);n+=h,i+=2}else c==="`"?(u=!u,i++):c!=="."||u?(n+=c,i++):(o(),i++)}if(o(),u)throw new k(P.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new ct(e)}static emptyPath(){return new ct([])}}/**
205
+ * @license
206
+ * Copyright 2017 Google LLC
207
+ *
208
+ * Licensed under the Apache License, Version 2.0 (the "License");
209
+ * you may not use this file except in compliance with the License.
210
+ * You may obtain a copy of the License at
211
+ *
212
+ * http://www.apache.org/licenses/LICENSE-2.0
213
+ *
214
+ * Unless required by applicable law or agreed to in writing, software
215
+ * distributed under the License is distributed on an "AS IS" BASIS,
216
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
217
+ * See the License for the specific language governing permissions and
218
+ * limitations under the License.
219
+ */class O{constructor(t){this.path=t}static fromPath(t){return new O(X.fromString(t))}static fromName(t){return new O(X.fromString(t).popFirst(5))}static empty(){return new O(X.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(t){return t!==null&&X.comparator(this.path,t.path)===0}toString(){return this.path.toString()}static comparator(t,e){return X.comparator(t.path,e.path)}static isDocumentKey(t){return t.length%2==0}static fromSegments(t){return new O(new X(t.slice()))}}/**
220
+ * @license
221
+ * Copyright 2017 Google LLC
222
+ *
223
+ * Licensed under the Apache License, Version 2.0 (the "License");
224
+ * you may not use this file except in compliance with the License.
225
+ * You may obtain a copy of the License at
226
+ *
227
+ * http://www.apache.org/licenses/LICENSE-2.0
228
+ *
229
+ * Unless required by applicable law or agreed to in writing, software
230
+ * distributed under the License is distributed on an "AS IS" BASIS,
231
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
232
+ * See the License for the specific language governing permissions and
233
+ * limitations under the License.
234
+ */function Ta(r,t,e){if(!e)throw new k(P.INVALID_ARGUMENT,`Function ${r}() cannot be called with an empty ${t}.`)}function Jl(r,t,e,n){if(t===!0&&n===!0)throw new k(P.INVALID_ARGUMENT,`${r} and ${e} cannot be used together.`)}function fo(r){if(!O.isDocumentKey(r))throw new k(P.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${r} has ${r.length}.`)}function mo(r){if(O.isDocumentKey(r))throw new k(P.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${r} has ${r.length}.`)}function va(r){return typeof r=="object"&&r!==null&&(Object.getPrototypeOf(r)===Object.prototype||Object.getPrototypeOf(r)===null)}function Rs(r){if(r===void 0)return"undefined";if(r===null)return"null";if(typeof r=="string")return r.length>20&&(r=`${r.substring(0,20)}...`),JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean")return""+r;if(typeof r=="object"){if(r instanceof Array)return"an array";{const t=(function(n){return n.constructor?n.constructor.name:null})(r);return t?`a custom ${t} object`:"an object"}}return typeof r=="function"?"a function":M(12329,{type:typeof r})}function Bt(r,t){if("_delegate"in r&&(r=r._delegate),!(r instanceof t)){if(t.name===r.constructor.name)throw new k(P.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const e=Rs(r);throw new k(P.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${e}`)}}return r}/**
235
+ * @license
236
+ * Copyright 2025 Google LLC
237
+ *
238
+ * Licensed under the Apache License, Version 2.0 (the "License");
239
+ * you may not use this file except in compliance with the License.
240
+ * You may obtain a copy of the License at
241
+ *
242
+ * http://www.apache.org/licenses/LICENSE-2.0
243
+ *
244
+ * Unless required by applicable law or agreed to in writing, software
245
+ * distributed under the License is distributed on an "AS IS" BASIS,
246
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
247
+ * See the License for the specific language governing permissions and
248
+ * limitations under the License.
249
+ */function et(r,t){const e={typeString:r};return t&&(e.value=t),e}function yn(r,t){if(!va(r))throw new k(P.INVALID_ARGUMENT,"JSON must be an object");let e;for(const n in t)if(t[n]){const i=t[n].typeString,o="value"in t[n]?{value:t[n].value}:void 0;if(!(n in r)){e=`JSON missing required field: '${n}'`;break}const u=r[n];if(i&&typeof u!==i){e=`JSON field '${n}' must be a ${i}.`;break}if(o!==void 0&&u!==o.value){e=`Expected '${n}' field to equal '${o.value}'`;break}}if(e)throw new k(P.INVALID_ARGUMENT,e);return!0}/**
250
+ * @license
251
+ * Copyright 2017 Google LLC
252
+ *
253
+ * Licensed under the Apache License, Version 2.0 (the "License");
254
+ * you may not use this file except in compliance with the License.
255
+ * You may obtain a copy of the License at
256
+ *
257
+ * http://www.apache.org/licenses/LICENSE-2.0
258
+ *
259
+ * Unless required by applicable law or agreed to in writing, software
260
+ * distributed under the License is distributed on an "AS IS" BASIS,
261
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
262
+ * See the License for the specific language governing permissions and
263
+ * limitations under the License.
264
+ */const po=-62135596800,go=1e6;class W{static now(){return W.fromMillis(Date.now())}static fromDate(t){return W.fromMillis(t.getTime())}static fromMillis(t){const e=Math.floor(t/1e3),n=Math.floor((t-1e3*e)*go);return new W(e,n)}constructor(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new k(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new k(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<po)throw new k(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new k(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/go}_compareTo(t){return this.seconds===t.seconds?U(this.nanoseconds,t.nanoseconds):U(this.seconds,t.seconds)}isEqual(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:W._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(t){if(yn(t,W._jsonSchema))return new W(t.seconds,t.nanoseconds)}valueOf(){const t=this.seconds-po;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}W._jsonSchemaVersion="firestore/timestamp/1.0",W._jsonSchema={type:et("string",W._jsonSchemaVersion),seconds:et("number"),nanoseconds:et("number")};/**
265
+ * @license
266
+ * Copyright 2017 Google LLC
267
+ *
268
+ * Licensed under the Apache License, Version 2.0 (the "License");
269
+ * you may not use this file except in compliance with the License.
270
+ * You may obtain a copy of the License at
271
+ *
272
+ * http://www.apache.org/licenses/LICENSE-2.0
273
+ *
274
+ * Unless required by applicable law or agreed to in writing, software
275
+ * distributed under the License is distributed on an "AS IS" BASIS,
276
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
277
+ * See the License for the specific language governing permissions and
278
+ * limitations under the License.
279
+ */class F{static fromTimestamp(t){return new F(t)}static min(){return new F(new W(0,0))}static max(){return new F(new W(253402300799,999999999))}constructor(t){this.timestamp=t}compareTo(t){return this.timestamp._compareTo(t.timestamp)}isEqual(t){return this.timestamp.isEqual(t.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}/**
280
+ * @license
281
+ * Copyright 2021 Google LLC
282
+ *
283
+ * Licensed under the Apache License, Version 2.0 (the "License");
284
+ * you may not use this file except in compliance with the License.
285
+ * You may obtain a copy of the License at
286
+ *
287
+ * http://www.apache.org/licenses/LICENSE-2.0
288
+ *
289
+ * Unless required by applicable law or agreed to in writing, software
290
+ * distributed under the License is distributed on an "AS IS" BASIS,
291
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
292
+ * See the License for the specific language governing permissions and
293
+ * limitations under the License.
294
+ */const hn=-1;function Zl(r,t){const e=r.toTimestamp().seconds,n=r.toTimestamp().nanoseconds+1,i=F.fromTimestamp(n===1e9?new W(e+1,0):new W(e,n));return new Zt(i,O.empty(),t)}function tc(r){return new Zt(r.readTime,r.key,hn)}class Zt{constructor(t,e,n){this.readTime=t,this.documentKey=e,this.largestBatchId=n}static min(){return new Zt(F.min(),O.empty(),hn)}static max(){return new Zt(F.max(),O.empty(),hn)}}function ec(r,t){let e=r.readTime.compareTo(t.readTime);return e!==0?e:(e=O.comparator(r.documentKey,t.documentKey),e!==0?e:U(r.largestBatchId,t.largestBatchId))}/**
295
+ * @license
296
+ * Copyright 2020 Google LLC
297
+ *
298
+ * Licensed under the Apache License, Version 2.0 (the "License");
299
+ * you may not use this file except in compliance with the License.
300
+ * You may obtain a copy of the License at
301
+ *
302
+ * http://www.apache.org/licenses/LICENSE-2.0
303
+ *
304
+ * Unless required by applicable law or agreed to in writing, software
305
+ * distributed under the License is distributed on an "AS IS" BASIS,
306
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
307
+ * See the License for the specific language governing permissions and
308
+ * limitations under the License.
309
+ */const nc="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class rc{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(t){this.onCommittedListeners.push(t)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((t=>t()))}}/**
310
+ * @license
311
+ * Copyright 2017 Google LLC
312
+ *
313
+ * Licensed under the Apache License, Version 2.0 (the "License");
314
+ * you may not use this file except in compliance with the License.
315
+ * You may obtain a copy of the License at
316
+ *
317
+ * http://www.apache.org/licenses/LICENSE-2.0
318
+ *
319
+ * Unless required by applicable law or agreed to in writing, software
320
+ * distributed under the License is distributed on an "AS IS" BASIS,
321
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
322
+ * See the License for the specific language governing permissions and
323
+ * limitations under the License.
324
+ */async function xe(r){if(r.code!==P.FAILED_PRECONDITION||r.message!==nc)throw r;N("LocalStore","Unexpectedly lost primary lease")}/**
325
+ * @license
326
+ * Copyright 2017 Google LLC
327
+ *
328
+ * Licensed under the Apache License, Version 2.0 (the "License");
329
+ * you may not use this file except in compliance with the License.
330
+ * You may obtain a copy of the License at
331
+ *
332
+ * http://www.apache.org/licenses/LICENSE-2.0
333
+ *
334
+ * Unless required by applicable law or agreed to in writing, software
335
+ * distributed under the License is distributed on an "AS IS" BASIS,
336
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
337
+ * See the License for the specific language governing permissions and
338
+ * limitations under the License.
339
+ */class V{constructor(t){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t((e=>{this.isDone=!0,this.result=e,this.nextCallback&&this.nextCallback(e)}),(e=>{this.isDone=!0,this.error=e,this.catchCallback&&this.catchCallback(e)}))}catch(t){return this.next(void 0,t)}next(t,e){return this.callbackAttached&&M(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(e,this.error):this.wrapSuccess(t,this.result):new V(((n,i)=>{this.nextCallback=o=>{this.wrapSuccess(t,o).next(n,i)},this.catchCallback=o=>{this.wrapFailure(e,o).next(n,i)}}))}toPromise(){return new Promise(((t,e)=>{this.next(t,e)}))}wrapUserFunction(t){try{const e=t();return e instanceof V?e:V.resolve(e)}catch(e){return V.reject(e)}}wrapSuccess(t,e){return t?this.wrapUserFunction((()=>t(e))):V.resolve(e)}wrapFailure(t,e){return t?this.wrapUserFunction((()=>t(e))):V.reject(e)}static resolve(t){return new V(((e,n)=>{e(t)}))}static reject(t){return new V(((e,n)=>{n(t)}))}static waitFor(t){return new V(((e,n)=>{let i=0,o=0,u=!1;t.forEach((c=>{++i,c.next((()=>{++o,u&&o===i&&e()}),(h=>n(h)))})),u=!0,o===i&&e()}))}static or(t){let e=V.resolve(!1);for(const n of t)e=e.next((i=>i?V.resolve(i):n()));return e}static forEach(t,e){const n=[];return t.forEach(((i,o)=>{n.push(e.call(this,i,o))})),this.waitFor(n)}static mapArray(t,e){return new V(((n,i)=>{const o=t.length,u=new Array(o);let c=0;for(let h=0;h<o;h++){const f=h;e(t[f]).next((p=>{u[f]=p,++c,c===o&&n(u)}),(p=>i(p)))}}))}static doWhile(t,e){return new V(((n,i)=>{const o=()=>{t()===!0?e().next((()=>{o()}),i):n()};o()}))}}function sc(r){const t=r.match(/Android ([\d.]+)/i),e=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(e)}function Oe(r){return r.name==="IndexedDbTransactionError"}/**
340
+ * @license
341
+ * Copyright 2018 Google LLC
342
+ *
343
+ * Licensed under the Apache License, Version 2.0 (the "License");
344
+ * you may not use this file except in compliance with the License.
345
+ * You may obtain a copy of the License at
346
+ *
347
+ * http://www.apache.org/licenses/LICENSE-2.0
348
+ *
349
+ * Unless required by applicable law or agreed to in writing, software
350
+ * distributed under the License is distributed on an "AS IS" BASIS,
351
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
352
+ * See the License for the specific language governing permissions and
353
+ * limitations under the License.
354
+ */class mr{constructor(t,e){this.previousValue=t,e&&(e.sequenceNumberHandler=n=>this._e(n),this.ae=n=>e.writeSequenceNumber(n))}_e(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue}next(){const t=++this.previousValue;return this.ae&&this.ae(t),t}}mr.ue=-1;/**
355
+ * @license
356
+ * Copyright 2017 Google LLC
357
+ *
358
+ * Licensed under the Apache License, Version 2.0 (the "License");
359
+ * you may not use this file except in compliance with the License.
360
+ * You may obtain a copy of the License at
361
+ *
362
+ * http://www.apache.org/licenses/LICENSE-2.0
363
+ *
364
+ * Unless required by applicable law or agreed to in writing, software
365
+ * distributed under the License is distributed on an "AS IS" BASIS,
366
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
367
+ * See the License for the specific language governing permissions and
368
+ * limitations under the License.
369
+ */const Ps=-1;function pr(r){return r==null}function nr(r){return r===0&&1/r==-1/0}function ic(r){return typeof r=="number"&&Number.isInteger(r)&&!nr(r)&&r<=Number.MAX_SAFE_INTEGER&&r>=Number.MIN_SAFE_INTEGER}/**
370
+ * @license
371
+ * Copyright 2017 Google LLC
372
+ *
373
+ * Licensed under the Apache License, Version 2.0 (the "License");
374
+ * you may not use this file except in compliance with the License.
375
+ * You may obtain a copy of the License at
376
+ *
377
+ * http://www.apache.org/licenses/LICENSE-2.0
378
+ *
379
+ * Unless required by applicable law or agreed to in writing, software
380
+ * distributed under the License is distributed on an "AS IS" BASIS,
381
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
382
+ * See the License for the specific language governing permissions and
383
+ * limitations under the License.
384
+ */const Ia="";function oc(r){let t="";for(let e=0;e<r.length;e++)t.length>0&&(t=_o(t)),t=ac(r.get(e),t);return _o(t)}function ac(r,t){let e=t;const n=r.length;for(let i=0;i<n;i++){const o=r.charAt(i);switch(o){case"\0":e+="";break;case Ia:e+="";break;default:e+=o}}return e}function _o(r){return r+Ia+""}/**
385
+ * @license
386
+ * Copyright 2017 Google LLC
387
+ *
388
+ * Licensed under the Apache License, Version 2.0 (the "License");
389
+ * you may not use this file except in compliance with the License.
390
+ * You may obtain a copy of the License at
391
+ *
392
+ * http://www.apache.org/licenses/LICENSE-2.0
393
+ *
394
+ * Unless required by applicable law or agreed to in writing, software
395
+ * distributed under the License is distributed on an "AS IS" BASIS,
396
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
397
+ * See the License for the specific language governing permissions and
398
+ * limitations under the License.
399
+ */function yo(r){let t=0;for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&t++;return t}function ie(r,t){for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&t(e,r[e])}function Aa(r){for(const t in r)if(Object.prototype.hasOwnProperty.call(r,t))return!1;return!0}/**
400
+ * @license
401
+ * Copyright 2017 Google LLC
402
+ *
403
+ * Licensed under the Apache License, Version 2.0 (the "License");
404
+ * you may not use this file except in compliance with the License.
405
+ * You may obtain a copy of the License at
406
+ *
407
+ * http://www.apache.org/licenses/LICENSE-2.0
408
+ *
409
+ * Unless required by applicable law or agreed to in writing, software
410
+ * distributed under the License is distributed on an "AS IS" BASIS,
411
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
412
+ * See the License for the specific language governing permissions and
413
+ * limitations under the License.
414
+ */class Y{constructor(t,e){this.comparator=t,this.root=e||lt.EMPTY}insert(t,e){return new Y(this.comparator,this.root.insert(t,e,this.comparator).copy(null,null,lt.BLACK,null,null))}remove(t){return new Y(this.comparator,this.root.remove(t,this.comparator).copy(null,null,lt.BLACK,null,null))}get(t){let e=this.root;for(;!e.isEmpty();){const n=this.comparator(t,e.key);if(n===0)return e.value;n<0?e=e.left:n>0&&(e=e.right)}return null}indexOf(t){let e=0,n=this.root;for(;!n.isEmpty();){const i=this.comparator(t,n.key);if(i===0)return e+n.left.size;i<0?n=n.left:(e+=n.left.size+1,n=n.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(t){return this.root.inorderTraversal(t)}forEach(t){this.inorderTraversal(((e,n)=>(t(e,n),!1)))}toString(){const t=[];return this.inorderTraversal(((e,n)=>(t.push(`${e}:${n}`),!1))),`{${t.join(", ")}}`}reverseTraversal(t){return this.root.reverseTraversal(t)}getIterator(){return new Kn(this.root,null,this.comparator,!1)}getIteratorFrom(t){return new Kn(this.root,t,this.comparator,!1)}getReverseIterator(){return new Kn(this.root,null,this.comparator,!0)}getReverseIteratorFrom(t){return new Kn(this.root,t,this.comparator,!0)}}class Kn{constructor(t,e,n,i){this.isReverse=i,this.nodeStack=[];let o=1;for(;!t.isEmpty();)if(o=e?n(t.key,e):1,e&&i&&(o*=-1),o<0)t=this.isReverse?t.left:t.right;else{if(o===0){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}getNext(){let t=this.nodeStack.pop();const e={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return e}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}}}class lt{constructor(t,e,n,i,o){this.key=t,this.value=e,this.color=n??lt.RED,this.left=i??lt.EMPTY,this.right=o??lt.EMPTY,this.size=this.left.size+1+this.right.size}copy(t,e,n,i,o){return new lt(t??this.key,e??this.value,n??this.color,i??this.left,o??this.right)}isEmpty(){return!1}inorderTraversal(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)}reverseTraversal(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(t,e,n){let i=this;const o=n(t,i.key);return i=o<0?i.copy(null,null,null,i.left.insert(t,e,n),null):o===0?i.copy(null,e,null,null,null):i.copy(null,null,null,null,i.right.insert(t,e,n)),i.fixUp()}removeMin(){if(this.left.isEmpty())return lt.EMPTY;let t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),t=t.copy(null,null,null,t.left.removeMin(),null),t.fixUp()}remove(t,e){let n,i=this;if(e(t,i.key)<0)i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(t,e),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),e(t,i.key)===0){if(i.right.isEmpty())return lt.EMPTY;n=i.right.min(),i=i.copy(n.key,n.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(t,e))}return i.fixUp()}isRed(){return this.color}fixUp(){let t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t}moveRedLeft(){let t=this.colorFlip();return t.right.left.isRed()&&(t=t.copy(null,null,null,null,t.right.rotateRight()),t=t.rotateLeft(),t=t.colorFlip()),t}moveRedRight(){let t=this.colorFlip();return t.left.left.isRed()&&(t=t.rotateRight(),t=t.colorFlip()),t}rotateLeft(){const t=this.copy(null,null,lt.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight(){const t=this.copy(null,null,lt.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}colorFlip(){const t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)}checkMaxDepth(){const t=this.check();return Math.pow(2,t)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw M(43730,{key:this.key,value:this.value});if(this.right.isRed())throw M(14113,{key:this.key,value:this.value});const t=this.left.check();if(t!==this.right.check())throw M(27949);return t+(this.isRed()?0:1)}}lt.EMPTY=null,lt.RED=!0,lt.BLACK=!1;lt.EMPTY=new class{constructor(){this.size=0}get key(){throw M(57766)}get value(){throw M(16141)}get color(){throw M(16727)}get left(){throw M(29726)}get right(){throw M(36894)}copy(t,e,n,i,o){return this}insert(t,e,n){return new lt(t,e)}remove(t,e){return this}isEmpty(){return!0}inorderTraversal(t){return!1}reverseTraversal(t){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};/**
415
+ * @license
416
+ * Copyright 2017 Google LLC
417
+ *
418
+ * Licensed under the Apache License, Version 2.0 (the "License");
419
+ * you may not use this file except in compliance with the License.
420
+ * You may obtain a copy of the License at
421
+ *
422
+ * http://www.apache.org/licenses/LICENSE-2.0
423
+ *
424
+ * Unless required by applicable law or agreed to in writing, software
425
+ * distributed under the License is distributed on an "AS IS" BASIS,
426
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
427
+ * See the License for the specific language governing permissions and
428
+ * limitations under the License.
429
+ */class st{constructor(t){this.comparator=t,this.data=new Y(this.comparator)}has(t){return this.data.get(t)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(t){return this.data.indexOf(t)}forEach(t){this.data.inorderTraversal(((e,n)=>(t(e),!1)))}forEachInRange(t,e){const n=this.data.getIteratorFrom(t[0]);for(;n.hasNext();){const i=n.getNext();if(this.comparator(i.key,t[1])>=0)return;e(i.key)}}forEachWhile(t,e){let n;for(n=e!==void 0?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return}firstAfterOrEqual(t){const e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null}getIterator(){return new Eo(this.data.getIterator())}getIteratorFrom(t){return new Eo(this.data.getIteratorFrom(t))}add(t){return this.copy(this.data.remove(t).insert(t,!0))}delete(t){return this.has(t)?this.copy(this.data.remove(t)):this}isEmpty(){return this.data.isEmpty()}unionWith(t){let e=this;return e.size<t.size&&(e=t,t=this),t.forEach((n=>{e=e.add(n)})),e}isEqual(t){if(!(t instanceof st)||this.size!==t.size)return!1;const e=this.data.getIterator(),n=t.data.getIterator();for(;e.hasNext();){const i=e.getNext().key,o=n.getNext().key;if(this.comparator(i,o)!==0)return!1}return!0}toArray(){const t=[];return this.forEach((e=>{t.push(e)})),t}toString(){const t=[];return this.forEach((e=>t.push(e))),"SortedSet("+t.toString()+")"}copy(t){const e=new st(this.comparator);return e.data=t,e}}class Eo{constructor(t){this.iter=t}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}/**
430
+ * @license
431
+ * Copyright 2020 Google LLC
432
+ *
433
+ * Licensed under the Apache License, Version 2.0 (the "License");
434
+ * you may not use this file except in compliance with the License.
435
+ * You may obtain a copy of the License at
436
+ *
437
+ * http://www.apache.org/licenses/LICENSE-2.0
438
+ *
439
+ * Unless required by applicable law or agreed to in writing, software
440
+ * distributed under the License is distributed on an "AS IS" BASIS,
441
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
442
+ * See the License for the specific language governing permissions and
443
+ * limitations under the License.
444
+ */class wt{constructor(t){this.fields=t,t.sort(ct.comparator)}static empty(){return new wt([])}unionWith(t){let e=new st(ct.comparator);for(const n of this.fields)e=e.add(n);for(const n of t)e=e.add(n);return new wt(e.toArray())}covers(t){for(const e of this.fields)if(e.isPrefixOf(t))return!0;return!1}isEqual(t){return Ve(this.fields,t.fields,((e,n)=>e.isEqual(n)))}}/**
445
+ * @license
446
+ * Copyright 2023 Google LLC
447
+ *
448
+ * Licensed under the Apache License, Version 2.0 (the "License");
449
+ * you may not use this file except in compliance with the License.
450
+ * You may obtain a copy of the License at
451
+ *
452
+ * http://www.apache.org/licenses/LICENSE-2.0
453
+ *
454
+ * Unless required by applicable law or agreed to in writing, software
455
+ * distributed under the License is distributed on an "AS IS" BASIS,
456
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
457
+ * See the License for the specific language governing permissions and
458
+ * limitations under the License.
459
+ */class wa extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/**
460
+ * @license
461
+ * Copyright 2020 Google LLC
462
+ *
463
+ * Licensed under the Apache License, Version 2.0 (the "License");
464
+ * you may not use this file except in compliance with the License.
465
+ * You may obtain a copy of the License at
466
+ *
467
+ * http://www.apache.org/licenses/LICENSE-2.0
468
+ *
469
+ * Unless required by applicable law or agreed to in writing, software
470
+ * distributed under the License is distributed on an "AS IS" BASIS,
471
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
472
+ * See the License for the specific language governing permissions and
473
+ * limitations under the License.
474
+ */class ht{constructor(t){this.binaryString=t}static fromBase64String(t){const e=(function(i){try{return atob(i)}catch(o){throw typeof DOMException<"u"&&o instanceof DOMException?new wa("Invalid base64 string: "+o):o}})(t);return new ht(e)}static fromUint8Array(t){const e=(function(i){let o="";for(let u=0;u<i.length;++u)o+=String.fromCharCode(i[u]);return o})(t);return new ht(e)}[Symbol.iterator](){let t=0;return{next:()=>t<this.binaryString.length?{value:this.binaryString.charCodeAt(t++),done:!1}:{value:void 0,done:!0}}}toBase64(){return(function(e){return btoa(e)})(this.binaryString)}toUint8Array(){return(function(e){const n=new Uint8Array(e.length);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);return n})(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(t){return U(this.binaryString,t.binaryString)}isEqual(t){return this.binaryString===t.binaryString}}ht.EMPTY_BYTE_STRING=new ht("");const uc=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function te(r){if(G(!!r,39018),typeof r=="string"){let t=0;const e=uc.exec(r);if(G(!!e,46558,{timestamp:r}),e[1]){let i=e[1];i=(i+"000000000").substr(0,9),t=Number(i)}const n=new Date(r);return{seconds:Math.floor(n.getTime()/1e3),nanos:t}}return{seconds:Z(r.seconds),nanos:Z(r.nanos)}}function Z(r){return typeof r=="number"?r:typeof r=="string"?Number(r):0}function ee(r){return typeof r=="string"?ht.fromBase64String(r):ht.fromUint8Array(r)}/**
475
+ * @license
476
+ * Copyright 2020 Google LLC
477
+ *
478
+ * Licensed under the Apache License, Version 2.0 (the "License");
479
+ * you may not use this file except in compliance with the License.
480
+ * You may obtain a copy of the License at
481
+ *
482
+ * http://www.apache.org/licenses/LICENSE-2.0
483
+ *
484
+ * Unless required by applicable law or agreed to in writing, software
485
+ * distributed under the License is distributed on an "AS IS" BASIS,
486
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
487
+ * See the License for the specific language governing permissions and
488
+ * limitations under the License.
489
+ */const Ra="server_timestamp",Pa="__type__",Va="__previous_value__",Sa="__local_write_time__";function Vs(r){var t,e;return((e=(((t=r==null?void 0:r.mapValue)===null||t===void 0?void 0:t.fields)||{})[Pa])===null||e===void 0?void 0:e.stringValue)===Ra}function gr(r){const t=r.mapValue.fields[Va];return Vs(t)?gr(t):t}function dn(r){const t=te(r.mapValue.fields[Sa].timestampValue);return new W(t.seconds,t.nanos)}/**
490
+ * @license
491
+ * Copyright 2017 Google LLC
492
+ *
493
+ * Licensed under the Apache License, Version 2.0 (the "License");
494
+ * you may not use this file except in compliance with the License.
495
+ * You may obtain a copy of the License at
496
+ *
497
+ * http://www.apache.org/licenses/LICENSE-2.0
498
+ *
499
+ * Unless required by applicable law or agreed to in writing, software
500
+ * distributed under the License is distributed on an "AS IS" BASIS,
501
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
502
+ * See the License for the specific language governing permissions and
503
+ * limitations under the License.
504
+ */class lc{constructor(t,e,n,i,o,u,c,h,f,p){this.databaseId=t,this.appId=e,this.persistenceKey=n,this.host=i,this.ssl=o,this.forceLongPolling=u,this.autoDetectLongPolling=c,this.longPollingOptions=h,this.useFetchStreams=f,this.isUsingEmulator=p}}const fn="(default)";class mn{constructor(t,e){this.projectId=t,this.database=e||fn}static empty(){return new mn("","")}get isDefaultDatabase(){return this.database===fn}isEqual(t){return t instanceof mn&&t.projectId===this.projectId&&t.database===this.database}}/**
505
+ * @license
506
+ * Copyright 2020 Google LLC
507
+ *
508
+ * Licensed under the Apache License, Version 2.0 (the "License");
509
+ * you may not use this file except in compliance with the License.
510
+ * You may obtain a copy of the License at
511
+ *
512
+ * http://www.apache.org/licenses/LICENSE-2.0
513
+ *
514
+ * Unless required by applicable law or agreed to in writing, software
515
+ * distributed under the License is distributed on an "AS IS" BASIS,
516
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
517
+ * See the License for the specific language governing permissions and
518
+ * limitations under the License.
519
+ */const Ca="__type__",cc="__max__",Qn={mapValue:{}},ba="__vector__",rr="value";function ne(r){return"nullValue"in r?0:"booleanValue"in r?1:"integerValue"in r||"doubleValue"in r?2:"timestampValue"in r?3:"stringValue"in r?5:"bytesValue"in r?6:"referenceValue"in r?7:"geoPointValue"in r?8:"arrayValue"in r?9:"mapValue"in r?Vs(r)?4:dc(r)?9007199254740991:hc(r)?10:11:M(28295,{value:r})}function xt(r,t){if(r===t)return!0;const e=ne(r);if(e!==ne(t))return!1;switch(e){case 0:case 9007199254740991:return!0;case 1:return r.booleanValue===t.booleanValue;case 4:return dn(r).isEqual(dn(t));case 3:return(function(i,o){if(typeof i.timestampValue=="string"&&typeof o.timestampValue=="string"&&i.timestampValue.length===o.timestampValue.length)return i.timestampValue===o.timestampValue;const u=te(i.timestampValue),c=te(o.timestampValue);return u.seconds===c.seconds&&u.nanos===c.nanos})(r,t);case 5:return r.stringValue===t.stringValue;case 6:return(function(i,o){return ee(i.bytesValue).isEqual(ee(o.bytesValue))})(r,t);case 7:return r.referenceValue===t.referenceValue;case 8:return(function(i,o){return Z(i.geoPointValue.latitude)===Z(o.geoPointValue.latitude)&&Z(i.geoPointValue.longitude)===Z(o.geoPointValue.longitude)})(r,t);case 2:return(function(i,o){if("integerValue"in i&&"integerValue"in o)return Z(i.integerValue)===Z(o.integerValue);if("doubleValue"in i&&"doubleValue"in o){const u=Z(i.doubleValue),c=Z(o.doubleValue);return u===c?nr(u)===nr(c):isNaN(u)&&isNaN(c)}return!1})(r,t);case 9:return Ve(r.arrayValue.values||[],t.arrayValue.values||[],xt);case 10:case 11:return(function(i,o){const u=i.mapValue.fields||{},c=o.mapValue.fields||{};if(yo(u)!==yo(c))return!1;for(const h in u)if(u.hasOwnProperty(h)&&(c[h]===void 0||!xt(u[h],c[h])))return!1;return!0})(r,t);default:return M(52216,{left:r})}}function pn(r,t){return(r.values||[]).find((e=>xt(e,t)))!==void 0}function Se(r,t){if(r===t)return 0;const e=ne(r),n=ne(t);if(e!==n)return U(e,n);switch(e){case 0:case 9007199254740991:return 0;case 1:return U(r.booleanValue,t.booleanValue);case 2:return(function(o,u){const c=Z(o.integerValue||o.doubleValue),h=Z(u.integerValue||u.doubleValue);return c<h?-1:c>h?1:c===h?0:isNaN(c)?isNaN(h)?0:-1:1})(r,t);case 3:return To(r.timestampValue,t.timestampValue);case 4:return To(dn(r),dn(t));case 5:return os(r.stringValue,t.stringValue);case 6:return(function(o,u){const c=ee(o),h=ee(u);return c.compareTo(h)})(r.bytesValue,t.bytesValue);case 7:return(function(o,u){const c=o.split("/"),h=u.split("/");for(let f=0;f<c.length&&f<h.length;f++){const p=U(c[f],h[f]);if(p!==0)return p}return U(c.length,h.length)})(r.referenceValue,t.referenceValue);case 8:return(function(o,u){const c=U(Z(o.latitude),Z(u.latitude));return c!==0?c:U(Z(o.longitude),Z(u.longitude))})(r.geoPointValue,t.geoPointValue);case 9:return vo(r.arrayValue,t.arrayValue);case 10:return(function(o,u){var c,h,f,p;const E=o.fields||{},R=u.fields||{},S=(c=E[rr])===null||c===void 0?void 0:c.arrayValue,D=(h=R[rr])===null||h===void 0?void 0:h.arrayValue,x=U(((f=S==null?void 0:S.values)===null||f===void 0?void 0:f.length)||0,((p=D==null?void 0:D.values)===null||p===void 0?void 0:p.length)||0);return x!==0?x:vo(S,D)})(r.mapValue,t.mapValue);case 11:return(function(o,u){if(o===Qn.mapValue&&u===Qn.mapValue)return 0;if(o===Qn.mapValue)return 1;if(u===Qn.mapValue)return-1;const c=o.fields||{},h=Object.keys(c),f=u.fields||{},p=Object.keys(f);h.sort(),p.sort();for(let E=0;E<h.length&&E<p.length;++E){const R=os(h[E],p[E]);if(R!==0)return R;const S=Se(c[h[E]],f[p[E]]);if(S!==0)return S}return U(h.length,p.length)})(r.mapValue,t.mapValue);default:throw M(23264,{le:e})}}function To(r,t){if(typeof r=="string"&&typeof t=="string"&&r.length===t.length)return U(r,t);const e=te(r),n=te(t),i=U(e.seconds,n.seconds);return i!==0?i:U(e.nanos,n.nanos)}function vo(r,t){const e=r.values||[],n=t.values||[];for(let i=0;i<e.length&&i<n.length;++i){const o=Se(e[i],n[i]);if(o)return o}return U(e.length,n.length)}function Ce(r){return as(r)}function as(r){return"nullValue"in r?"null":"booleanValue"in r?""+r.booleanValue:"integerValue"in r?""+r.integerValue:"doubleValue"in r?""+r.doubleValue:"timestampValue"in r?(function(e){const n=te(e);return`time(${n.seconds},${n.nanos})`})(r.timestampValue):"stringValue"in r?r.stringValue:"bytesValue"in r?(function(e){return ee(e).toBase64()})(r.bytesValue):"referenceValue"in r?(function(e){return O.fromName(e).toString()})(r.referenceValue):"geoPointValue"in r?(function(e){return`geo(${e.latitude},${e.longitude})`})(r.geoPointValue):"arrayValue"in r?(function(e){let n="[",i=!0;for(const o of e.values||[])i?i=!1:n+=",",n+=as(o);return n+"]"})(r.arrayValue):"mapValue"in r?(function(e){const n=Object.keys(e.fields||{}).sort();let i="{",o=!0;for(const u of n)o?o=!1:i+=",",i+=`${u}:${as(e.fields[u])}`;return i+"}"})(r.mapValue):M(61005,{value:r})}function Yn(r){switch(ne(r)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const t=gr(r);return t?16+Yn(t):16;case 5:return 2*r.stringValue.length;case 6:return ee(r.bytesValue).approximateByteSize();case 7:return r.referenceValue.length;case 9:return(function(n){return(n.values||[]).reduce(((i,o)=>i+Yn(o)),0)})(r.arrayValue);case 10:case 11:return(function(n){let i=0;return ie(n.fields,((o,u)=>{i+=o.length+Yn(u)})),i})(r.mapValue);default:throw M(13486,{value:r})}}function us(r){return!!r&&"integerValue"in r}function Ss(r){return!!r&&"arrayValue"in r}function Io(r){return!!r&&"nullValue"in r}function Ao(r){return!!r&&"doubleValue"in r&&isNaN(Number(r.doubleValue))}function Jn(r){return!!r&&"mapValue"in r}function hc(r){var t,e;return((e=(((t=r==null?void 0:r.mapValue)===null||t===void 0?void 0:t.fields)||{})[Ca])===null||e===void 0?void 0:e.stringValue)===ba}function on(r){if(r.geoPointValue)return{geoPointValue:Object.assign({},r.geoPointValue)};if(r.timestampValue&&typeof r.timestampValue=="object")return{timestampValue:Object.assign({},r.timestampValue)};if(r.mapValue){const t={mapValue:{fields:{}}};return ie(r.mapValue.fields,((e,n)=>t.mapValue.fields[e]=on(n))),t}if(r.arrayValue){const t={arrayValue:{values:[]}};for(let e=0;e<(r.arrayValue.values||[]).length;++e)t.arrayValue.values[e]=on(r.arrayValue.values[e]);return t}return Object.assign({},r)}function dc(r){return(((r.mapValue||{}).fields||{}).__type__||{}).stringValue===cc}/**
520
+ * @license
521
+ * Copyright 2017 Google LLC
522
+ *
523
+ * Licensed under the Apache License, Version 2.0 (the "License");
524
+ * you may not use this file except in compliance with the License.
525
+ * You may obtain a copy of the License at
526
+ *
527
+ * http://www.apache.org/licenses/LICENSE-2.0
528
+ *
529
+ * Unless required by applicable law or agreed to in writing, software
530
+ * distributed under the License is distributed on an "AS IS" BASIS,
531
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
532
+ * See the License for the specific language governing permissions and
533
+ * limitations under the License.
534
+ */class It{constructor(t){this.value=t}static empty(){return new It({mapValue:{}})}field(t){if(t.isEmpty())return this.value;{let e=this.value;for(let n=0;n<t.length-1;++n)if(e=(e.mapValue.fields||{})[t.get(n)],!Jn(e))return null;return e=(e.mapValue.fields||{})[t.lastSegment()],e||null}}set(t,e){this.getFieldsMap(t.popLast())[t.lastSegment()]=on(e)}setAll(t){let e=ct.emptyPath(),n={},i=[];t.forEach(((u,c)=>{if(!e.isImmediateParentOf(c)){const h=this.getFieldsMap(e);this.applyChanges(h,n,i),n={},i=[],e=c.popLast()}u?n[c.lastSegment()]=on(u):i.push(c.lastSegment())}));const o=this.getFieldsMap(e);this.applyChanges(o,n,i)}delete(t){const e=this.field(t.popLast());Jn(e)&&e.mapValue.fields&&delete e.mapValue.fields[t.lastSegment()]}isEqual(t){return xt(this.value,t.value)}getFieldsMap(t){let e=this.value;e.mapValue.fields||(e.mapValue={fields:{}});for(let n=0;n<t.length;++n){let i=e.mapValue.fields[t.get(n)];Jn(i)&&i.mapValue.fields||(i={mapValue:{fields:{}}},e.mapValue.fields[t.get(n)]=i),e=i}return e.mapValue.fields}applyChanges(t,e,n){ie(e,((i,o)=>t[i]=o));for(const i of n)delete t[i]}clone(){return new It(on(this.value))}}function Da(r){const t=[];return ie(r.fields,((e,n)=>{const i=new ct([e]);if(Jn(n)){const o=Da(n.mapValue).fields;if(o.length===0)t.push(i);else for(const u of o)t.push(i.child(u))}else t.push(i)})),new wt(t)}/**
535
+ * @license
536
+ * Copyright 2017 Google LLC
537
+ *
538
+ * Licensed under the Apache License, Version 2.0 (the "License");
539
+ * you may not use this file except in compliance with the License.
540
+ * You may obtain a copy of the License at
541
+ *
542
+ * http://www.apache.org/licenses/LICENSE-2.0
543
+ *
544
+ * Unless required by applicable law or agreed to in writing, software
545
+ * distributed under the License is distributed on an "AS IS" BASIS,
546
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
547
+ * See the License for the specific language governing permissions and
548
+ * limitations under the License.
549
+ */class yt{constructor(t,e,n,i,o,u,c){this.key=t,this.documentType=e,this.version=n,this.readTime=i,this.createTime=o,this.data=u,this.documentState=c}static newInvalidDocument(t){return new yt(t,0,F.min(),F.min(),F.min(),It.empty(),0)}static newFoundDocument(t,e,n,i){return new yt(t,1,e,F.min(),n,i,0)}static newNoDocument(t,e){return new yt(t,2,e,F.min(),F.min(),It.empty(),0)}static newUnknownDocument(t,e){return new yt(t,3,e,F.min(),F.min(),It.empty(),2)}convertToFoundDocument(t,e){return!this.createTime.isEqual(F.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=t),this.version=t,this.documentType=1,this.data=e,this.documentState=0,this}convertToNoDocument(t){return this.version=t,this.documentType=2,this.data=It.empty(),this.documentState=0,this}convertToUnknownDocument(t){return this.version=t,this.documentType=3,this.data=It.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=F.min(),this}setReadTime(t){return this.readTime=t,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(t){return t instanceof yt&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}mutableCopy(){return new yt(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}/**
550
+ * @license
551
+ * Copyright 2022 Google LLC
552
+ *
553
+ * Licensed under the Apache License, Version 2.0 (the "License");
554
+ * you may not use this file except in compliance with the License.
555
+ * You may obtain a copy of the License at
556
+ *
557
+ * http://www.apache.org/licenses/LICENSE-2.0
558
+ *
559
+ * Unless required by applicable law or agreed to in writing, software
560
+ * distributed under the License is distributed on an "AS IS" BASIS,
561
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
562
+ * See the License for the specific language governing permissions and
563
+ * limitations under the License.
564
+ */class sr{constructor(t,e){this.position=t,this.inclusive=e}}function wo(r,t,e){let n=0;for(let i=0;i<r.position.length;i++){const o=t[i],u=r.position[i];if(o.field.isKeyField()?n=O.comparator(O.fromName(u.referenceValue),e.key):n=Se(u,e.data.field(o.field)),o.dir==="desc"&&(n*=-1),n!==0)break}return n}function Ro(r,t){if(r===null)return t===null;if(t===null||r.inclusive!==t.inclusive||r.position.length!==t.position.length)return!1;for(let e=0;e<r.position.length;e++)if(!xt(r.position[e],t.position[e]))return!1;return!0}/**
565
+ * @license
566
+ * Copyright 2022 Google LLC
567
+ *
568
+ * Licensed under the Apache License, Version 2.0 (the "License");
569
+ * you may not use this file except in compliance with the License.
570
+ * You may obtain a copy of the License at
571
+ *
572
+ * http://www.apache.org/licenses/LICENSE-2.0
573
+ *
574
+ * Unless required by applicable law or agreed to in writing, software
575
+ * distributed under the License is distributed on an "AS IS" BASIS,
576
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
577
+ * See the License for the specific language governing permissions and
578
+ * limitations under the License.
579
+ */class ir{constructor(t,e="asc"){this.field=t,this.dir=e}}function fc(r,t){return r.dir===t.dir&&r.field.isEqual(t.field)}/**
580
+ * @license
581
+ * Copyright 2022 Google LLC
582
+ *
583
+ * Licensed under the Apache License, Version 2.0 (the "License");
584
+ * you may not use this file except in compliance with the License.
585
+ * You may obtain a copy of the License at
586
+ *
587
+ * http://www.apache.org/licenses/LICENSE-2.0
588
+ *
589
+ * Unless required by applicable law or agreed to in writing, software
590
+ * distributed under the License is distributed on an "AS IS" BASIS,
591
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
592
+ * See the License for the specific language governing permissions and
593
+ * limitations under the License.
594
+ */class Na{}class nt extends Na{constructor(t,e,n){super(),this.field=t,this.op=e,this.value=n}static create(t,e,n){return t.isKeyField()?e==="in"||e==="not-in"?this.createKeyFieldInFilter(t,e,n):new pc(t,e,n):e==="array-contains"?new yc(t,n):e==="in"?new Ec(t,n):e==="not-in"?new Tc(t,n):e==="array-contains-any"?new vc(t,n):new nt(t,e,n)}static createKeyFieldInFilter(t,e,n){return e==="in"?new gc(t,n):new _c(t,n)}matches(t){const e=t.data.field(this.field);return this.op==="!="?e!==null&&e.nullValue===void 0&&this.matchesComparison(Se(e,this.value)):e!==null&&ne(this.value)===ne(e)&&this.matchesComparison(Se(e,this.value))}matchesComparison(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return t===0;case"!=":return t!==0;case">":return t>0;case">=":return t>=0;default:return M(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class Ot extends Na{constructor(t,e){super(),this.filters=t,this.op=e,this.he=null}static create(t,e){return new Ot(t,e)}matches(t){return ka(this)?this.filters.find((e=>!e.matches(t)))===void 0:this.filters.find((e=>e.matches(t)))!==void 0}getFlattenedFilters(){return this.he!==null||(this.he=this.filters.reduce(((t,e)=>t.concat(e.getFlattenedFilters())),[])),this.he}getFilters(){return Object.assign([],this.filters)}}function ka(r){return r.op==="and"}function xa(r){return mc(r)&&ka(r)}function mc(r){for(const t of r.filters)if(t instanceof Ot)return!1;return!0}function ls(r){if(r instanceof nt)return r.field.canonicalString()+r.op.toString()+Ce(r.value);if(xa(r))return r.filters.map((t=>ls(t))).join(",");{const t=r.filters.map((e=>ls(e))).join(",");return`${r.op}(${t})`}}function Oa(r,t){return r instanceof nt?(function(n,i){return i instanceof nt&&n.op===i.op&&n.field.isEqual(i.field)&&xt(n.value,i.value)})(r,t):r instanceof Ot?(function(n,i){return i instanceof Ot&&n.op===i.op&&n.filters.length===i.filters.length?n.filters.reduce(((o,u,c)=>o&&Oa(u,i.filters[c])),!0):!1})(r,t):void M(19439)}function Ma(r){return r instanceof nt?(function(e){return`${e.field.canonicalString()} ${e.op} ${Ce(e.value)}`})(r):r instanceof Ot?(function(e){return e.op.toString()+" {"+e.getFilters().map(Ma).join(" ,")+"}"})(r):"Filter"}class pc extends nt{constructor(t,e,n){super(t,e,n),this.key=O.fromName(n.referenceValue)}matches(t){const e=O.comparator(t.key,this.key);return this.matchesComparison(e)}}class gc extends nt{constructor(t,e){super(t,"in",e),this.keys=Fa("in",e)}matches(t){return this.keys.some((e=>e.isEqual(t.key)))}}class _c extends nt{constructor(t,e){super(t,"not-in",e),this.keys=Fa("not-in",e)}matches(t){return!this.keys.some((e=>e.isEqual(t.key)))}}function Fa(r,t){var e;return(((e=t.arrayValue)===null||e===void 0?void 0:e.values)||[]).map((n=>O.fromName(n.referenceValue)))}class yc extends nt{constructor(t,e){super(t,"array-contains",e)}matches(t){const e=t.data.field(this.field);return Ss(e)&&pn(e.arrayValue,this.value)}}class Ec extends nt{constructor(t,e){super(t,"in",e)}matches(t){const e=t.data.field(this.field);return e!==null&&pn(this.value.arrayValue,e)}}class Tc extends nt{constructor(t,e){super(t,"not-in",e)}matches(t){if(pn(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const e=t.data.field(this.field);return e!==null&&e.nullValue===void 0&&!pn(this.value.arrayValue,e)}}class vc extends nt{constructor(t,e){super(t,"array-contains-any",e)}matches(t){const e=t.data.field(this.field);return!(!Ss(e)||!e.arrayValue.values)&&e.arrayValue.values.some((n=>pn(this.value.arrayValue,n)))}}/**
595
+ * @license
596
+ * Copyright 2019 Google LLC
597
+ *
598
+ * Licensed under the Apache License, Version 2.0 (the "License");
599
+ * you may not use this file except in compliance with the License.
600
+ * You may obtain a copy of the License at
601
+ *
602
+ * http://www.apache.org/licenses/LICENSE-2.0
603
+ *
604
+ * Unless required by applicable law or agreed to in writing, software
605
+ * distributed under the License is distributed on an "AS IS" BASIS,
606
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
607
+ * See the License for the specific language governing permissions and
608
+ * limitations under the License.
609
+ */class Ic{constructor(t,e=null,n=[],i=[],o=null,u=null,c=null){this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=i,this.limit=o,this.startAt=u,this.endAt=c,this.Pe=null}}function Po(r,t=null,e=[],n=[],i=null,o=null,u=null){return new Ic(r,t,e,n,i,o,u)}function Cs(r){const t=L(r);if(t.Pe===null){let e=t.path.canonicalString();t.collectionGroup!==null&&(e+="|cg:"+t.collectionGroup),e+="|f:",e+=t.filters.map((n=>ls(n))).join(","),e+="|ob:",e+=t.orderBy.map((n=>(function(o){return o.field.canonicalString()+o.dir})(n))).join(","),pr(t.limit)||(e+="|l:",e+=t.limit),t.startAt&&(e+="|lb:",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map((n=>Ce(n))).join(",")),t.endAt&&(e+="|ub:",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map((n=>Ce(n))).join(",")),t.Pe=e}return t.Pe}function bs(r,t){if(r.limit!==t.limit||r.orderBy.length!==t.orderBy.length)return!1;for(let e=0;e<r.orderBy.length;e++)if(!fc(r.orderBy[e],t.orderBy[e]))return!1;if(r.filters.length!==t.filters.length)return!1;for(let e=0;e<r.filters.length;e++)if(!Oa(r.filters[e],t.filters[e]))return!1;return r.collectionGroup===t.collectionGroup&&!!r.path.isEqual(t.path)&&!!Ro(r.startAt,t.startAt)&&Ro(r.endAt,t.endAt)}function cs(r){return O.isDocumentKey(r.path)&&r.collectionGroup===null&&r.filters.length===0}/**
610
+ * @license
611
+ * Copyright 2017 Google LLC
612
+ *
613
+ * Licensed under the Apache License, Version 2.0 (the "License");
614
+ * you may not use this file except in compliance with the License.
615
+ * You may obtain a copy of the License at
616
+ *
617
+ * http://www.apache.org/licenses/LICENSE-2.0
618
+ *
619
+ * Unless required by applicable law or agreed to in writing, software
620
+ * distributed under the License is distributed on an "AS IS" BASIS,
621
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
622
+ * See the License for the specific language governing permissions and
623
+ * limitations under the License.
624
+ */class _r{constructor(t,e=null,n=[],i=[],o=null,u="F",c=null,h=null){this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=i,this.limit=o,this.limitType=u,this.startAt=c,this.endAt=h,this.Te=null,this.Ie=null,this.de=null,this.startAt,this.endAt}}function Ac(r,t,e,n,i,o,u,c){return new _r(r,t,e,n,i,o,u,c)}function yr(r){return new _r(r)}function Vo(r){return r.filters.length===0&&r.limit===null&&r.startAt==null&&r.endAt==null&&(r.explicitOrderBy.length===0||r.explicitOrderBy.length===1&&r.explicitOrderBy[0].field.isKeyField())}function wc(r){return r.collectionGroup!==null}function an(r){const t=L(r);if(t.Te===null){t.Te=[];const e=new Set;for(const o of t.explicitOrderBy)t.Te.push(o),e.add(o.field.canonicalString());const n=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc";(function(u){let c=new st(ct.comparator);return u.filters.forEach((h=>{h.getFlattenedFilters().forEach((f=>{f.isInequality()&&(c=c.add(f.field))}))})),c})(t).forEach((o=>{e.has(o.canonicalString())||o.isKeyField()||t.Te.push(new ir(o,n))})),e.has(ct.keyField().canonicalString())||t.Te.push(new ir(ct.keyField(),n))}return t.Te}function Ct(r){const t=L(r);return t.Ie||(t.Ie=Rc(t,an(r))),t.Ie}function Rc(r,t){if(r.limitType==="F")return Po(r.path,r.collectionGroup,t,r.filters,r.limit,r.startAt,r.endAt);{t=t.map((i=>{const o=i.dir==="desc"?"asc":"desc";return new ir(i.field,o)}));const e=r.endAt?new sr(r.endAt.position,r.endAt.inclusive):null,n=r.startAt?new sr(r.startAt.position,r.startAt.inclusive):null;return Po(r.path,r.collectionGroup,t,r.filters,r.limit,e,n)}}function hs(r,t,e){return new _r(r.path,r.collectionGroup,r.explicitOrderBy.slice(),r.filters.slice(),t,e,r.startAt,r.endAt)}function Er(r,t){return bs(Ct(r),Ct(t))&&r.limitType===t.limitType}function La(r){return`${Cs(Ct(r))}|lt:${r.limitType}`}function Ae(r){return`Query(target=${(function(e){let n=e.path.canonicalString();return e.collectionGroup!==null&&(n+=" collectionGroup="+e.collectionGroup),e.filters.length>0&&(n+=`, filters: [${e.filters.map((i=>Ma(i))).join(", ")}]`),pr(e.limit)||(n+=", limit: "+e.limit),e.orderBy.length>0&&(n+=`, orderBy: [${e.orderBy.map((i=>(function(u){return`${u.field.canonicalString()} (${u.dir})`})(i))).join(", ")}]`),e.startAt&&(n+=", startAt: ",n+=e.startAt.inclusive?"b:":"a:",n+=e.startAt.position.map((i=>Ce(i))).join(",")),e.endAt&&(n+=", endAt: ",n+=e.endAt.inclusive?"a:":"b:",n+=e.endAt.position.map((i=>Ce(i))).join(",")),`Target(${n})`})(Ct(r))}; limitType=${r.limitType})`}function Tr(r,t){return t.isFoundDocument()&&(function(n,i){const o=i.key.path;return n.collectionGroup!==null?i.key.hasCollectionId(n.collectionGroup)&&n.path.isPrefixOf(o):O.isDocumentKey(n.path)?n.path.isEqual(o):n.path.isImmediateParentOf(o)})(r,t)&&(function(n,i){for(const o of an(n))if(!o.field.isKeyField()&&i.data.field(o.field)===null)return!1;return!0})(r,t)&&(function(n,i){for(const o of n.filters)if(!o.matches(i))return!1;return!0})(r,t)&&(function(n,i){return!(n.startAt&&!(function(u,c,h){const f=wo(u,c,h);return u.inclusive?f<=0:f<0})(n.startAt,an(n),i)||n.endAt&&!(function(u,c,h){const f=wo(u,c,h);return u.inclusive?f>=0:f>0})(n.endAt,an(n),i))})(r,t)}function Pc(r){return r.collectionGroup||(r.path.length%2==1?r.path.lastSegment():r.path.get(r.path.length-2))}function Ua(r){return(t,e)=>{let n=!1;for(const i of an(r)){const o=Vc(i,t,e);if(o!==0)return o;n=n||i.field.isKeyField()}return 0}}function Vc(r,t,e){const n=r.field.isKeyField()?O.comparator(t.key,e.key):(function(o,u,c){const h=u.data.field(o),f=c.data.field(o);return h!==null&&f!==null?Se(h,f):M(42886)})(r.field,t,e);switch(r.dir){case"asc":return n;case"desc":return-1*n;default:return M(19790,{direction:r.dir})}}/**
625
+ * @license
626
+ * Copyright 2017 Google LLC
627
+ *
628
+ * Licensed under the Apache License, Version 2.0 (the "License");
629
+ * you may not use this file except in compliance with the License.
630
+ * You may obtain a copy of the License at
631
+ *
632
+ * http://www.apache.org/licenses/LICENSE-2.0
633
+ *
634
+ * Unless required by applicable law or agreed to in writing, software
635
+ * distributed under the License is distributed on an "AS IS" BASIS,
636
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
637
+ * See the License for the specific language governing permissions and
638
+ * limitations under the License.
639
+ */class ge{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.innerSize=0}get(t){const e=this.mapKeyFn(t),n=this.inner[e];if(n!==void 0){for(const[i,o]of n)if(this.equalsFn(i,t))return o}}has(t){return this.get(t)!==void 0}set(t,e){const n=this.mapKeyFn(t),i=this.inner[n];if(i===void 0)return this.inner[n]=[[t,e]],void this.innerSize++;for(let o=0;o<i.length;o++)if(this.equalsFn(i[o][0],t))return void(i[o]=[t,e]);i.push([t,e]),this.innerSize++}delete(t){const e=this.mapKeyFn(t),n=this.inner[e];if(n===void 0)return!1;for(let i=0;i<n.length;i++)if(this.equalsFn(n[i][0],t))return n.length===1?delete this.inner[e]:n.splice(i,1),this.innerSize--,!0;return!1}forEach(t){ie(this.inner,((e,n)=>{for(const[i,o]of n)t(i,o)}))}isEmpty(){return Aa(this.inner)}size(){return this.innerSize}}/**
640
+ * @license
641
+ * Copyright 2017 Google LLC
642
+ *
643
+ * Licensed under the Apache License, Version 2.0 (the "License");
644
+ * you may not use this file except in compliance with the License.
645
+ * You may obtain a copy of the License at
646
+ *
647
+ * http://www.apache.org/licenses/LICENSE-2.0
648
+ *
649
+ * Unless required by applicable law or agreed to in writing, software
650
+ * distributed under the License is distributed on an "AS IS" BASIS,
651
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
652
+ * See the License for the specific language governing permissions and
653
+ * limitations under the License.
654
+ */const Sc=new Y(O.comparator);function $t(){return Sc}const qa=new Y(O.comparator);function nn(...r){let t=qa;for(const e of r)t=t.insert(e.key,e);return t}function ja(r){let t=qa;return r.forEach(((e,n)=>t=t.insert(e,n.overlayedDocument))),t}function he(){return un()}function Ba(){return un()}function un(){return new ge((r=>r.toString()),((r,t)=>r.isEqual(t)))}const Cc=new Y(O.comparator),bc=new st(O.comparator);function q(...r){let t=bc;for(const e of r)t=t.add(e);return t}const Dc=new st(U);function Nc(){return Dc}/**
655
+ * @license
656
+ * Copyright 2020 Google LLC
657
+ *
658
+ * Licensed under the Apache License, Version 2.0 (the "License");
659
+ * you may not use this file except in compliance with the License.
660
+ * You may obtain a copy of the License at
661
+ *
662
+ * http://www.apache.org/licenses/LICENSE-2.0
663
+ *
664
+ * Unless required by applicable law or agreed to in writing, software
665
+ * distributed under the License is distributed on an "AS IS" BASIS,
666
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
667
+ * See the License for the specific language governing permissions and
668
+ * limitations under the License.
669
+ */function Ds(r,t){if(r.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:nr(t)?"-0":t}}function za(r){return{integerValue:""+r}}function kc(r,t){return ic(t)?za(t):Ds(r,t)}/**
670
+ * @license
671
+ * Copyright 2018 Google LLC
672
+ *
673
+ * Licensed under the Apache License, Version 2.0 (the "License");
674
+ * you may not use this file except in compliance with the License.
675
+ * You may obtain a copy of the License at
676
+ *
677
+ * http://www.apache.org/licenses/LICENSE-2.0
678
+ *
679
+ * Unless required by applicable law or agreed to in writing, software
680
+ * distributed under the License is distributed on an "AS IS" BASIS,
681
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
682
+ * See the License for the specific language governing permissions and
683
+ * limitations under the License.
684
+ */class vr{constructor(){this._=void 0}}function xc(r,t,e){return r instanceof or?(function(i,o){const u={fields:{[Pa]:{stringValue:Ra},[Sa]:{timestampValue:{seconds:i.seconds,nanos:i.nanoseconds}}}};return o&&Vs(o)&&(o=gr(o)),o&&(u.fields[Va]=o),{mapValue:u}})(e,t):r instanceof gn?Ga(r,t):r instanceof _n?Ka(r,t):(function(i,o){const u=$a(i,o),c=So(u)+So(i.Ee);return us(u)&&us(i.Ee)?za(c):Ds(i.serializer,c)})(r,t)}function Oc(r,t,e){return r instanceof gn?Ga(r,t):r instanceof _n?Ka(r,t):e}function $a(r,t){return r instanceof ar?(function(n){return us(n)||(function(o){return!!o&&"doubleValue"in o})(n)})(t)?t:{integerValue:0}:null}class or extends vr{}class gn extends vr{constructor(t){super(),this.elements=t}}function Ga(r,t){const e=Qa(t);for(const n of r.elements)e.some((i=>xt(i,n)))||e.push(n);return{arrayValue:{values:e}}}class _n extends vr{constructor(t){super(),this.elements=t}}function Ka(r,t){let e=Qa(t);for(const n of r.elements)e=e.filter((i=>!xt(i,n)));return{arrayValue:{values:e}}}class ar extends vr{constructor(t,e){super(),this.serializer=t,this.Ee=e}}function So(r){return Z(r.integerValue||r.doubleValue)}function Qa(r){return Ss(r)&&r.arrayValue.values?r.arrayValue.values.slice():[]}function Mc(r,t){return r.field.isEqual(t.field)&&(function(n,i){return n instanceof gn&&i instanceof gn||n instanceof _n&&i instanceof _n?Ve(n.elements,i.elements,xt):n instanceof ar&&i instanceof ar?xt(n.Ee,i.Ee):n instanceof or&&i instanceof or})(r.transform,t.transform)}class Fc{constructor(t,e){this.version=t,this.transformResults=e}}class Vt{constructor(t,e){this.updateTime=t,this.exists=e}static none(){return new Vt}static exists(t){return new Vt(void 0,t)}static updateTime(t){return new Vt(t)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)}}function Zn(r,t){return r.updateTime!==void 0?t.isFoundDocument()&&t.version.isEqual(r.updateTime):r.exists===void 0||r.exists===t.isFoundDocument()}class Ir{}function Wa(r,t){if(!r.hasLocalMutations||t&&t.fields.length===0)return null;if(t===null)return r.isNoDocument()?new Ns(r.key,Vt.none()):new En(r.key,r.data,Vt.none());{const e=r.data,n=It.empty();let i=new st(ct.comparator);for(let o of t.fields)if(!i.has(o)){let u=e.field(o);u===null&&o.length>1&&(o=o.popLast(),u=e.field(o)),u===null?n.delete(o):n.set(o,u),i=i.add(o)}return new oe(r.key,n,new wt(i.toArray()),Vt.none())}}function Lc(r,t,e){r instanceof En?(function(i,o,u){const c=i.value.clone(),h=bo(i.fieldTransforms,o,u.transformResults);c.setAll(h),o.convertToFoundDocument(u.version,c).setHasCommittedMutations()})(r,t,e):r instanceof oe?(function(i,o,u){if(!Zn(i.precondition,o))return void o.convertToUnknownDocument(u.version);const c=bo(i.fieldTransforms,o,u.transformResults),h=o.data;h.setAll(Ha(i)),h.setAll(c),o.convertToFoundDocument(u.version,h).setHasCommittedMutations()})(r,t,e):(function(i,o,u){o.convertToNoDocument(u.version).setHasCommittedMutations()})(0,t,e)}function ln(r,t,e,n){return r instanceof En?(function(o,u,c,h){if(!Zn(o.precondition,u))return c;const f=o.value.clone(),p=Do(o.fieldTransforms,h,u);return f.setAll(p),u.convertToFoundDocument(u.version,f).setHasLocalMutations(),null})(r,t,e,n):r instanceof oe?(function(o,u,c,h){if(!Zn(o.precondition,u))return c;const f=Do(o.fieldTransforms,h,u),p=u.data;return p.setAll(Ha(o)),p.setAll(f),u.convertToFoundDocument(u.version,p).setHasLocalMutations(),c===null?null:c.unionWith(o.fieldMask.fields).unionWith(o.fieldTransforms.map((E=>E.field)))})(r,t,e,n):(function(o,u,c){return Zn(o.precondition,u)?(u.convertToNoDocument(u.version).setHasLocalMutations(),null):c})(r,t,e)}function Uc(r,t){let e=null;for(const n of r.fieldTransforms){const i=t.data.field(n.field),o=$a(n.transform,i||null);o!=null&&(e===null&&(e=It.empty()),e.set(n.field,o))}return e||null}function Co(r,t){return r.type===t.type&&!!r.key.isEqual(t.key)&&!!r.precondition.isEqual(t.precondition)&&!!(function(n,i){return n===void 0&&i===void 0||!(!n||!i)&&Ve(n,i,((o,u)=>Mc(o,u)))})(r.fieldTransforms,t.fieldTransforms)&&(r.type===0?r.value.isEqual(t.value):r.type!==1||r.data.isEqual(t.data)&&r.fieldMask.isEqual(t.fieldMask))}class En extends Ir{constructor(t,e,n,i=[]){super(),this.key=t,this.value=e,this.precondition=n,this.fieldTransforms=i,this.type=0}getFieldMask(){return null}}class oe extends Ir{constructor(t,e,n,i,o=[]){super(),this.key=t,this.data=e,this.fieldMask=n,this.precondition=i,this.fieldTransforms=o,this.type=1}getFieldMask(){return this.fieldMask}}function Ha(r){const t=new Map;return r.fieldMask.fields.forEach((e=>{if(!e.isEmpty()){const n=r.data.field(e);t.set(e,n)}})),t}function bo(r,t,e){const n=new Map;G(r.length===e.length,32656,{Ae:e.length,Re:r.length});for(let i=0;i<e.length;i++){const o=r[i],u=o.transform,c=t.data.field(o.field);n.set(o.field,Oc(u,c,e[i]))}return n}function Do(r,t,e){const n=new Map;for(const i of r){const o=i.transform,u=e.data.field(i.field);n.set(i.field,xc(o,u,t))}return n}class Ns extends Ir{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class qc extends Ir{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}/**
685
+ * @license
686
+ * Copyright 2017 Google LLC
687
+ *
688
+ * Licensed under the Apache License, Version 2.0 (the "License");
689
+ * you may not use this file except in compliance with the License.
690
+ * You may obtain a copy of the License at
691
+ *
692
+ * http://www.apache.org/licenses/LICENSE-2.0
693
+ *
694
+ * Unless required by applicable law or agreed to in writing, software
695
+ * distributed under the License is distributed on an "AS IS" BASIS,
696
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
697
+ * See the License for the specific language governing permissions and
698
+ * limitations under the License.
699
+ */class jc{constructor(t,e,n,i){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,this.mutations=i}applyToRemoteDocument(t,e){const n=e.mutationResults;for(let i=0;i<this.mutations.length;i++){const o=this.mutations[i];o.key.isEqual(t.key)&&Lc(o,t,n[i])}}applyToLocalView(t,e){for(const n of this.baseMutations)n.key.isEqual(t.key)&&(e=ln(n,t,e,this.localWriteTime));for(const n of this.mutations)n.key.isEqual(t.key)&&(e=ln(n,t,e,this.localWriteTime));return e}applyToLocalDocumentSet(t,e){const n=Ba();return this.mutations.forEach((i=>{const o=t.get(i.key),u=o.overlayedDocument;let c=this.applyToLocalView(u,o.mutatedFields);c=e.has(i.key)?null:c;const h=Wa(u,c);h!==null&&n.set(i.key,h),u.isValidDocument()||u.convertToNoDocument(F.min())})),n}keys(){return this.mutations.reduce(((t,e)=>t.add(e.key)),q())}isEqual(t){return this.batchId===t.batchId&&Ve(this.mutations,t.mutations,((e,n)=>Co(e,n)))&&Ve(this.baseMutations,t.baseMutations,((e,n)=>Co(e,n)))}}class ks{constructor(t,e,n,i){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.docVersions=i}static from(t,e,n){G(t.mutations.length===n.length,58842,{Ve:t.mutations.length,me:n.length});let i=(function(){return Cc})();const o=t.mutations;for(let u=0;u<o.length;u++)i=i.insert(o[u].key,n[u].version);return new ks(t,e,n,i)}}/**
700
+ * @license
701
+ * Copyright 2022 Google LLC
702
+ *
703
+ * Licensed under the Apache License, Version 2.0 (the "License");
704
+ * you may not use this file except in compliance with the License.
705
+ * You may obtain a copy of the License at
706
+ *
707
+ * http://www.apache.org/licenses/LICENSE-2.0
708
+ *
709
+ * Unless required by applicable law or agreed to in writing, software
710
+ * distributed under the License is distributed on an "AS IS" BASIS,
711
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
712
+ * See the License for the specific language governing permissions and
713
+ * limitations under the License.
714
+ */class Bc{constructor(t,e){this.largestBatchId=t,this.mutation=e}getKey(){return this.mutation.key}isEqual(t){return t!==null&&this.mutation===t.mutation}toString(){return`Overlay{
715
+ largestBatchId: ${this.largestBatchId},
716
+ mutation: ${this.mutation.toString()}
717
+ }`}}/**
718
+ * @license
719
+ * Copyright 2017 Google LLC
720
+ *
721
+ * Licensed under the Apache License, Version 2.0 (the "License");
722
+ * you may not use this file except in compliance with the License.
723
+ * You may obtain a copy of the License at
724
+ *
725
+ * http://www.apache.org/licenses/LICENSE-2.0
726
+ *
727
+ * Unless required by applicable law or agreed to in writing, software
728
+ * distributed under the License is distributed on an "AS IS" BASIS,
729
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
730
+ * See the License for the specific language governing permissions and
731
+ * limitations under the License.
732
+ */class zc{constructor(t,e){this.count=t,this.unchangedNames=e}}/**
733
+ * @license
734
+ * Copyright 2017 Google LLC
735
+ *
736
+ * Licensed under the Apache License, Version 2.0 (the "License");
737
+ * you may not use this file except in compliance with the License.
738
+ * You may obtain a copy of the License at
739
+ *
740
+ * http://www.apache.org/licenses/LICENSE-2.0
741
+ *
742
+ * Unless required by applicable law or agreed to in writing, software
743
+ * distributed under the License is distributed on an "AS IS" BASIS,
744
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
745
+ * See the License for the specific language governing permissions and
746
+ * limitations under the License.
747
+ */var tt,j;function $c(r){switch(r){case P.OK:return M(64938);case P.CANCELLED:case P.UNKNOWN:case P.DEADLINE_EXCEEDED:case P.RESOURCE_EXHAUSTED:case P.INTERNAL:case P.UNAVAILABLE:case P.UNAUTHENTICATED:return!1;case P.INVALID_ARGUMENT:case P.NOT_FOUND:case P.ALREADY_EXISTS:case P.PERMISSION_DENIED:case P.FAILED_PRECONDITION:case P.ABORTED:case P.OUT_OF_RANGE:case P.UNIMPLEMENTED:case P.DATA_LOSS:return!0;default:return M(15467,{code:r})}}function Xa(r){if(r===void 0)return zt("GRPC error has no .code"),P.UNKNOWN;switch(r){case tt.OK:return P.OK;case tt.CANCELLED:return P.CANCELLED;case tt.UNKNOWN:return P.UNKNOWN;case tt.DEADLINE_EXCEEDED:return P.DEADLINE_EXCEEDED;case tt.RESOURCE_EXHAUSTED:return P.RESOURCE_EXHAUSTED;case tt.INTERNAL:return P.INTERNAL;case tt.UNAVAILABLE:return P.UNAVAILABLE;case tt.UNAUTHENTICATED:return P.UNAUTHENTICATED;case tt.INVALID_ARGUMENT:return P.INVALID_ARGUMENT;case tt.NOT_FOUND:return P.NOT_FOUND;case tt.ALREADY_EXISTS:return P.ALREADY_EXISTS;case tt.PERMISSION_DENIED:return P.PERMISSION_DENIED;case tt.FAILED_PRECONDITION:return P.FAILED_PRECONDITION;case tt.ABORTED:return P.ABORTED;case tt.OUT_OF_RANGE:return P.OUT_OF_RANGE;case tt.UNIMPLEMENTED:return P.UNIMPLEMENTED;case tt.DATA_LOSS:return P.DATA_LOSS;default:return M(39323,{code:r})}}(j=tt||(tt={}))[j.OK=0]="OK",j[j.CANCELLED=1]="CANCELLED",j[j.UNKNOWN=2]="UNKNOWN",j[j.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",j[j.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",j[j.NOT_FOUND=5]="NOT_FOUND",j[j.ALREADY_EXISTS=6]="ALREADY_EXISTS",j[j.PERMISSION_DENIED=7]="PERMISSION_DENIED",j[j.UNAUTHENTICATED=16]="UNAUTHENTICATED",j[j.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",j[j.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",j[j.ABORTED=10]="ABORTED",j[j.OUT_OF_RANGE=11]="OUT_OF_RANGE",j[j.UNIMPLEMENTED=12]="UNIMPLEMENTED",j[j.INTERNAL=13]="INTERNAL",j[j.UNAVAILABLE=14]="UNAVAILABLE",j[j.DATA_LOSS=15]="DATA_LOSS";/**
748
+ * @license
749
+ * Copyright 2022 Google LLC
750
+ *
751
+ * Licensed under the Apache License, Version 2.0 (the "License");
752
+ * you may not use this file except in compliance with the License.
753
+ * You may obtain a copy of the License at
754
+ *
755
+ * http://www.apache.org/licenses/LICENSE-2.0
756
+ *
757
+ * Unless required by applicable law or agreed to in writing, software
758
+ * distributed under the License is distributed on an "AS IS" BASIS,
759
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
760
+ * See the License for the specific language governing permissions and
761
+ * limitations under the License.
762
+ */const Gc=new Xt([4294967295,4294967295],0);function No(r){const t=Ea().encode(r),e=new ha;return e.update(t),new Uint8Array(e.digest())}function ko(r){const t=new DataView(r.buffer),e=t.getUint32(0,!0),n=t.getUint32(4,!0),i=t.getUint32(8,!0),o=t.getUint32(12,!0);return[new Xt([e,n],0),new Xt([i,o],0)]}class xs{constructor(t,e,n){if(this.bitmap=t,this.padding=e,this.hashCount=n,e<0||e>=8)throw new rn(`Invalid padding: ${e}`);if(n<0)throw new rn(`Invalid hash count: ${n}`);if(t.length>0&&this.hashCount===0)throw new rn(`Invalid hash count: ${n}`);if(t.length===0&&e!==0)throw new rn(`Invalid padding when bitmap length is 0: ${e}`);this.fe=8*t.length-e,this.ge=Xt.fromNumber(this.fe)}pe(t,e,n){let i=t.add(e.multiply(Xt.fromNumber(n)));return i.compare(Gc)===1&&(i=new Xt([i.getBits(0),i.getBits(1)],0)),i.modulo(this.ge).toNumber()}ye(t){return!!(this.bitmap[Math.floor(t/8)]&1<<t%8)}mightContain(t){if(this.fe===0)return!1;const e=No(t),[n,i]=ko(e);for(let o=0;o<this.hashCount;o++){const u=this.pe(n,i,o);if(!this.ye(u))return!1}return!0}static create(t,e,n){const i=t%8==0?0:8-t%8,o=new Uint8Array(Math.ceil(t/8)),u=new xs(o,i,e);return n.forEach((c=>u.insert(c))),u}insert(t){if(this.fe===0)return;const e=No(t),[n,i]=ko(e);for(let o=0;o<this.hashCount;o++){const u=this.pe(n,i,o);this.we(u)}}we(t){const e=Math.floor(t/8),n=t%8;this.bitmap[e]|=1<<n}}class rn extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/**
763
+ * @license
764
+ * Copyright 2017 Google LLC
765
+ *
766
+ * Licensed under the Apache License, Version 2.0 (the "License");
767
+ * you may not use this file except in compliance with the License.
768
+ * You may obtain a copy of the License at
769
+ *
770
+ * http://www.apache.org/licenses/LICENSE-2.0
771
+ *
772
+ * Unless required by applicable law or agreed to in writing, software
773
+ * distributed under the License is distributed on an "AS IS" BASIS,
774
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
775
+ * See the License for the specific language governing permissions and
776
+ * limitations under the License.
777
+ */class Ar{constructor(t,e,n,i,o){this.snapshotVersion=t,this.targetChanges=e,this.targetMismatches=n,this.documentUpdates=i,this.resolvedLimboDocuments=o}static createSynthesizedRemoteEventForCurrentChange(t,e,n){const i=new Map;return i.set(t,Tn.createSynthesizedTargetChangeForCurrentChange(t,e,n)),new Ar(F.min(),i,new Y(U),$t(),q())}}class Tn{constructor(t,e,n,i,o){this.resumeToken=t,this.current=e,this.addedDocuments=n,this.modifiedDocuments=i,this.removedDocuments=o}static createSynthesizedTargetChangeForCurrentChange(t,e,n){return new Tn(n,e,q(),q(),q())}}/**
778
+ * @license
779
+ * Copyright 2017 Google LLC
780
+ *
781
+ * Licensed under the Apache License, Version 2.0 (the "License");
782
+ * you may not use this file except in compliance with the License.
783
+ * You may obtain a copy of the License at
784
+ *
785
+ * http://www.apache.org/licenses/LICENSE-2.0
786
+ *
787
+ * Unless required by applicable law or agreed to in writing, software
788
+ * distributed under the License is distributed on an "AS IS" BASIS,
789
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
790
+ * See the License for the specific language governing permissions and
791
+ * limitations under the License.
792
+ */class tr{constructor(t,e,n,i){this.Se=t,this.removedTargetIds=e,this.key=n,this.be=i}}class Ya{constructor(t,e){this.targetId=t,this.De=e}}class Ja{constructor(t,e,n=ht.EMPTY_BYTE_STRING,i=null){this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=i}}class xo{constructor(){this.ve=0,this.Ce=Oo(),this.Fe=ht.EMPTY_BYTE_STRING,this.Me=!1,this.xe=!0}get current(){return this.Me}get resumeToken(){return this.Fe}get Oe(){return this.ve!==0}get Ne(){return this.xe}Be(t){t.approximateByteSize()>0&&(this.xe=!0,this.Fe=t)}Le(){let t=q(),e=q(),n=q();return this.Ce.forEach(((i,o)=>{switch(o){case 0:t=t.add(i);break;case 2:e=e.add(i);break;case 1:n=n.add(i);break;default:M(38017,{changeType:o})}})),new Tn(this.Fe,this.Me,t,e,n)}ke(){this.xe=!1,this.Ce=Oo()}qe(t,e){this.xe=!0,this.Ce=this.Ce.insert(t,e)}Qe(t){this.xe=!0,this.Ce=this.Ce.remove(t)}$e(){this.ve+=1}Ue(){this.ve-=1,G(this.ve>=0,3241,{ve:this.ve})}Ke(){this.xe=!0,this.Me=!0}}class Kc{constructor(t){this.We=t,this.Ge=new Map,this.ze=$t(),this.je=Wn(),this.Je=Wn(),this.He=new Y(U)}Ye(t){for(const e of t.Se)t.be&&t.be.isFoundDocument()?this.Ze(e,t.be):this.Xe(e,t.key,t.be);for(const e of t.removedTargetIds)this.Xe(e,t.key,t.be)}et(t){this.forEachTarget(t,(e=>{const n=this.tt(e);switch(t.state){case 0:this.nt(e)&&n.Be(t.resumeToken);break;case 1:n.Ue(),n.Oe||n.ke(),n.Be(t.resumeToken);break;case 2:n.Ue(),n.Oe||this.removeTarget(e);break;case 3:this.nt(e)&&(n.Ke(),n.Be(t.resumeToken));break;case 4:this.nt(e)&&(this.rt(e),n.Be(t.resumeToken));break;default:M(56790,{state:t.state})}}))}forEachTarget(t,e){t.targetIds.length>0?t.targetIds.forEach(e):this.Ge.forEach(((n,i)=>{this.nt(i)&&e(i)}))}it(t){const e=t.targetId,n=t.De.count,i=this.st(e);if(i){const o=i.target;if(cs(o))if(n===0){const u=new O(o.path);this.Xe(e,u,yt.newNoDocument(u,F.min()))}else G(n===1,20013,{expectedCount:n});else{const u=this.ot(e);if(u!==n){const c=this._t(t),h=c?this.ut(c,t,u):1;if(h!==0){this.rt(e);const f=h===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.He=this.He.insert(e,f)}}}}}_t(t){const e=t.De.unchangedNames;if(!e||!e.bits)return null;const{bits:{bitmap:n="",padding:i=0},hashCount:o=0}=e;let u,c;try{u=ee(n).toUint8Array()}catch(h){if(h instanceof wa)return Jt("Decoding the base64 bloom filter in existence filter failed ("+h.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw h}try{c=new xs(u,i,o)}catch(h){return Jt(h instanceof rn?"BloomFilter error: ":"Applying bloom filter failed: ",h),null}return c.fe===0?null:c}ut(t,e,n){return e.De.count===n-this.ht(t,e.targetId)?0:2}ht(t,e){const n=this.We.getRemoteKeysForTarget(e);let i=0;return n.forEach((o=>{const u=this.We.lt(),c=`projects/${u.projectId}/databases/${u.database}/documents/${o.path.canonicalString()}`;t.mightContain(c)||(this.Xe(e,o,null),i++)})),i}Pt(t){const e=new Map;this.Ge.forEach(((o,u)=>{const c=this.st(u);if(c){if(o.current&&cs(c.target)){const h=new O(c.target.path);this.Tt(h).has(u)||this.It(u,h)||this.Xe(u,h,yt.newNoDocument(h,t))}o.Ne&&(e.set(u,o.Le()),o.ke())}}));let n=q();this.Je.forEach(((o,u)=>{let c=!0;u.forEachWhile((h=>{const f=this.st(h);return!f||f.purpose==="TargetPurposeLimboResolution"||(c=!1,!1)})),c&&(n=n.add(o))})),this.ze.forEach(((o,u)=>u.setReadTime(t)));const i=new Ar(t,e,this.He,this.ze,n);return this.ze=$t(),this.je=Wn(),this.Je=Wn(),this.He=new Y(U),i}Ze(t,e){if(!this.nt(t))return;const n=this.It(t,e.key)?2:0;this.tt(t).qe(e.key,n),this.ze=this.ze.insert(e.key,e),this.je=this.je.insert(e.key,this.Tt(e.key).add(t)),this.Je=this.Je.insert(e.key,this.dt(e.key).add(t))}Xe(t,e,n){if(!this.nt(t))return;const i=this.tt(t);this.It(t,e)?i.qe(e,1):i.Qe(e),this.Je=this.Je.insert(e,this.dt(e).delete(t)),this.Je=this.Je.insert(e,this.dt(e).add(t)),n&&(this.ze=this.ze.insert(e,n))}removeTarget(t){this.Ge.delete(t)}ot(t){const e=this.tt(t).Le();return this.We.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size}$e(t){this.tt(t).$e()}tt(t){let e=this.Ge.get(t);return e||(e=new xo,this.Ge.set(t,e)),e}dt(t){let e=this.Je.get(t);return e||(e=new st(U),this.Je=this.Je.insert(t,e)),e}Tt(t){let e=this.je.get(t);return e||(e=new st(U),this.je=this.je.insert(t,e)),e}nt(t){const e=this.st(t)!==null;return e||N("WatchChangeAggregator","Detected inactive target",t),e}st(t){const e=this.Ge.get(t);return e&&e.Oe?null:this.We.Et(t)}rt(t){this.Ge.set(t,new xo),this.We.getRemoteKeysForTarget(t).forEach((e=>{this.Xe(t,e,null)}))}It(t,e){return this.We.getRemoteKeysForTarget(t).has(e)}}function Wn(){return new Y(O.comparator)}function Oo(){return new Y(O.comparator)}const Qc={asc:"ASCENDING",desc:"DESCENDING"},Wc={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},Hc={and:"AND",or:"OR"};class Xc{constructor(t,e){this.databaseId=t,this.useProto3Json=e}}function ds(r,t){return r.useProto3Json||pr(t)?t:{value:t}}function ur(r,t){return r.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function Za(r,t){return r.useProto3Json?t.toBase64():t.toUint8Array()}function Yc(r,t){return ur(r,t.toTimestamp())}function bt(r){return G(!!r,49232),F.fromTimestamp((function(e){const n=te(e);return new W(n.seconds,n.nanos)})(r))}function Os(r,t){return fs(r,t).canonicalString()}function fs(r,t){const e=(function(i){return new X(["projects",i.projectId,"databases",i.database])})(r).child("documents");return t===void 0?e:e.child(t)}function tu(r){const t=X.fromString(r);return G(iu(t),10190,{key:t.toString()}),t}function ms(r,t){return Os(r.databaseId,t.path)}function ts(r,t){const e=tu(t);if(e.get(1)!==r.databaseId.projectId)throw new k(P.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+e.get(1)+" vs "+r.databaseId.projectId);if(e.get(3)!==r.databaseId.database)throw new k(P.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+e.get(3)+" vs "+r.databaseId.database);return new O(nu(e))}function eu(r,t){return Os(r.databaseId,t)}function Jc(r){const t=tu(r);return t.length===4?X.emptyPath():nu(t)}function ps(r){return new X(["projects",r.databaseId.projectId,"databases",r.databaseId.database]).canonicalString()}function nu(r){return G(r.length>4&&r.get(4)==="documents",29091,{key:r.toString()}),r.popFirst(5)}function Mo(r,t,e){return{name:ms(r,t),fields:e.value.mapValue.fields}}function Zc(r,t){let e;if("targetChange"in t){t.targetChange;const n=(function(f){return f==="NO_CHANGE"?0:f==="ADD"?1:f==="REMOVE"?2:f==="CURRENT"?3:f==="RESET"?4:M(39313,{state:f})})(t.targetChange.targetChangeType||"NO_CHANGE"),i=t.targetChange.targetIds||[],o=(function(f,p){return f.useProto3Json?(G(p===void 0||typeof p=="string",58123),ht.fromBase64String(p||"")):(G(p===void 0||p instanceof Buffer||p instanceof Uint8Array,16193),ht.fromUint8Array(p||new Uint8Array))})(r,t.targetChange.resumeToken),u=t.targetChange.cause,c=u&&(function(f){const p=f.code===void 0?P.UNKNOWN:Xa(f.code);return new k(p,f.message||"")})(u);e=new Ja(n,i,o,c||null)}else if("documentChange"in t){t.documentChange;const n=t.documentChange;n.document,n.document.name,n.document.updateTime;const i=ts(r,n.document.name),o=bt(n.document.updateTime),u=n.document.createTime?bt(n.document.createTime):F.min(),c=new It({mapValue:{fields:n.document.fields}}),h=yt.newFoundDocument(i,o,u,c),f=n.targetIds||[],p=n.removedTargetIds||[];e=new tr(f,p,h.key,h)}else if("documentDelete"in t){t.documentDelete;const n=t.documentDelete;n.document;const i=ts(r,n.document),o=n.readTime?bt(n.readTime):F.min(),u=yt.newNoDocument(i,o),c=n.removedTargetIds||[];e=new tr([],c,u.key,u)}else if("documentRemove"in t){t.documentRemove;const n=t.documentRemove;n.document;const i=ts(r,n.document),o=n.removedTargetIds||[];e=new tr([],o,i,null)}else{if(!("filter"in t))return M(11601,{At:t});{t.filter;const n=t.filter;n.targetId;const{count:i=0,unchangedNames:o}=n,u=new zc(i,o),c=n.targetId;e=new Ya(c,u)}}return e}function th(r,t){let e;if(t instanceof En)e={update:Mo(r,t.key,t.value)};else if(t instanceof Ns)e={delete:ms(r,t.key)};else if(t instanceof oe)e={update:Mo(r,t.key,t.data),updateMask:lh(t.fieldMask)};else{if(!(t instanceof qc))return M(16599,{Rt:t.type});e={verify:ms(r,t.key)}}return t.fieldTransforms.length>0&&(e.updateTransforms=t.fieldTransforms.map((n=>(function(o,u){const c=u.transform;if(c instanceof or)return{fieldPath:u.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(c instanceof gn)return{fieldPath:u.field.canonicalString(),appendMissingElements:{values:c.elements}};if(c instanceof _n)return{fieldPath:u.field.canonicalString(),removeAllFromArray:{values:c.elements}};if(c instanceof ar)return{fieldPath:u.field.canonicalString(),increment:c.Ee};throw M(20930,{transform:u.transform})})(0,n)))),t.precondition.isNone||(e.currentDocument=(function(i,o){return o.updateTime!==void 0?{updateTime:Yc(i,o.updateTime)}:o.exists!==void 0?{exists:o.exists}:M(27497)})(r,t.precondition)),e}function eh(r,t){return r&&r.length>0?(G(t!==void 0,14353),r.map((e=>(function(i,o){let u=i.updateTime?bt(i.updateTime):bt(o);return u.isEqual(F.min())&&(u=bt(o)),new Fc(u,i.transformResults||[])})(e,t)))):[]}function nh(r,t){return{documents:[eu(r,t.path)]}}function rh(r,t){const e={structuredQuery:{}},n=t.path;let i;t.collectionGroup!==null?(i=n,e.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=n.popLast(),e.structuredQuery.from=[{collectionId:n.lastSegment()}]),e.parent=eu(r,i);const o=(function(f){if(f.length!==0)return su(Ot.create(f,"and"))})(t.filters);o&&(e.structuredQuery.where=o);const u=(function(f){if(f.length!==0)return f.map((p=>(function(R){return{field:we(R.field),direction:oh(R.dir)}})(p)))})(t.orderBy);u&&(e.structuredQuery.orderBy=u);const c=ds(r,t.limit);return c!==null&&(e.structuredQuery.limit=c),t.startAt&&(e.structuredQuery.startAt=(function(f){return{before:f.inclusive,values:f.position}})(t.startAt)),t.endAt&&(e.structuredQuery.endAt=(function(f){return{before:!f.inclusive,values:f.position}})(t.endAt)),{Vt:e,parent:i}}function sh(r){let t=Jc(r.parent);const e=r.structuredQuery,n=e.from?e.from.length:0;let i=null;if(n>0){G(n===1,65062);const p=e.from[0];p.allDescendants?i=p.collectionId:t=t.child(p.collectionId)}let o=[];e.where&&(o=(function(E){const R=ru(E);return R instanceof Ot&&xa(R)?R.getFilters():[R]})(e.where));let u=[];e.orderBy&&(u=(function(E){return E.map((R=>(function(D){return new ir(Re(D.field),(function(b){switch(b){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}})(D.direction))})(R)))})(e.orderBy));let c=null;e.limit&&(c=(function(E){let R;return R=typeof E=="object"?E.value:E,pr(R)?null:R})(e.limit));let h=null;e.startAt&&(h=(function(E){const R=!!E.before,S=E.values||[];return new sr(S,R)})(e.startAt));let f=null;return e.endAt&&(f=(function(E){const R=!E.before,S=E.values||[];return new sr(S,R)})(e.endAt)),Ac(t,i,u,o,c,"F",h,f)}function ih(r,t){const e=(function(i){switch(i){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return M(28987,{purpose:i})}})(t.purpose);return e==null?null:{"goog-listen-tags":e}}function ru(r){return r.unaryFilter!==void 0?(function(e){switch(e.unaryFilter.op){case"IS_NAN":const n=Re(e.unaryFilter.field);return nt.create(n,"==",{doubleValue:NaN});case"IS_NULL":const i=Re(e.unaryFilter.field);return nt.create(i,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const o=Re(e.unaryFilter.field);return nt.create(o,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const u=Re(e.unaryFilter.field);return nt.create(u,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return M(61313);default:return M(60726)}})(r):r.fieldFilter!==void 0?(function(e){return nt.create(Re(e.fieldFilter.field),(function(i){switch(i){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":return M(58110);default:return M(50506)}})(e.fieldFilter.op),e.fieldFilter.value)})(r):r.compositeFilter!==void 0?(function(e){return Ot.create(e.compositeFilter.filters.map((n=>ru(n))),(function(i){switch(i){case"AND":return"and";case"OR":return"or";default:return M(1026)}})(e.compositeFilter.op))})(r):M(30097,{filter:r})}function oh(r){return Qc[r]}function ah(r){return Wc[r]}function uh(r){return Hc[r]}function we(r){return{fieldPath:r.canonicalString()}}function Re(r){return ct.fromServerFormat(r.fieldPath)}function su(r){return r instanceof nt?(function(e){if(e.op==="=="){if(Ao(e.value))return{unaryFilter:{field:we(e.field),op:"IS_NAN"}};if(Io(e.value))return{unaryFilter:{field:we(e.field),op:"IS_NULL"}}}else if(e.op==="!="){if(Ao(e.value))return{unaryFilter:{field:we(e.field),op:"IS_NOT_NAN"}};if(Io(e.value))return{unaryFilter:{field:we(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:we(e.field),op:ah(e.op),value:e.value}}})(r):r instanceof Ot?(function(e){const n=e.getFilters().map((i=>su(i)));return n.length===1?n[0]:{compositeFilter:{op:uh(e.op),filters:n}}})(r):M(54877,{filter:r})}function lh(r){const t=[];return r.fields.forEach((e=>t.push(e.canonicalString()))),{fieldPaths:t}}function iu(r){return r.length>=4&&r.get(0)==="projects"&&r.get(2)==="databases"}/**
793
+ * @license
794
+ * Copyright 2017 Google LLC
795
+ *
796
+ * Licensed under the Apache License, Version 2.0 (the "License");
797
+ * you may not use this file except in compliance with the License.
798
+ * You may obtain a copy of the License at
799
+ *
800
+ * http://www.apache.org/licenses/LICENSE-2.0
801
+ *
802
+ * Unless required by applicable law or agreed to in writing, software
803
+ * distributed under the License is distributed on an "AS IS" BASIS,
804
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
805
+ * See the License for the specific language governing permissions and
806
+ * limitations under the License.
807
+ */class Ht{constructor(t,e,n,i,o=F.min(),u=F.min(),c=ht.EMPTY_BYTE_STRING,h=null){this.target=t,this.targetId=e,this.purpose=n,this.sequenceNumber=i,this.snapshotVersion=o,this.lastLimboFreeSnapshotVersion=u,this.resumeToken=c,this.expectedCount=h}withSequenceNumber(t){return new Ht(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(t,e){return new Ht(this.target,this.targetId,this.purpose,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t,null)}withExpectedCount(t){return new Ht(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,t)}withLastLimboFreeSnapshotVersion(t){return new Ht(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken,this.expectedCount)}}/**
808
+ * @license
809
+ * Copyright 2017 Google LLC
810
+ *
811
+ * Licensed under the Apache License, Version 2.0 (the "License");
812
+ * you may not use this file except in compliance with the License.
813
+ * You may obtain a copy of the License at
814
+ *
815
+ * http://www.apache.org/licenses/LICENSE-2.0
816
+ *
817
+ * Unless required by applicable law or agreed to in writing, software
818
+ * distributed under the License is distributed on an "AS IS" BASIS,
819
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
820
+ * See the License for the specific language governing permissions and
821
+ * limitations under the License.
822
+ */class ch{constructor(t){this.gt=t}}function hh(r){const t=sh({parent:r.parent,structuredQuery:r.structuredQuery});return r.limitType==="LAST"?hs(t,t.limit,"L"):t}/**
823
+ * @license
824
+ * Copyright 2019 Google LLC
825
+ *
826
+ * Licensed under the Apache License, Version 2.0 (the "License");
827
+ * you may not use this file except in compliance with the License.
828
+ * You may obtain a copy of the License at
829
+ *
830
+ * http://www.apache.org/licenses/LICENSE-2.0
831
+ *
832
+ * Unless required by applicable law or agreed to in writing, software
833
+ * distributed under the License is distributed on an "AS IS" BASIS,
834
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
835
+ * See the License for the specific language governing permissions and
836
+ * limitations under the License.
837
+ */class dh{constructor(){this.Dn=new fh}addToCollectionParentIndex(t,e){return this.Dn.add(e),V.resolve()}getCollectionParents(t,e){return V.resolve(this.Dn.getEntries(e))}addFieldIndex(t,e){return V.resolve()}deleteFieldIndex(t,e){return V.resolve()}deleteAllFieldIndexes(t){return V.resolve()}createTargetIndexes(t,e){return V.resolve()}getDocumentsMatchingTarget(t,e){return V.resolve(null)}getIndexType(t,e){return V.resolve(0)}getFieldIndexes(t,e){return V.resolve([])}getNextCollectionGroupToUpdate(t){return V.resolve(null)}getMinOffset(t,e){return V.resolve(Zt.min())}getMinOffsetFromCollectionGroup(t,e){return V.resolve(Zt.min())}updateCollectionGroup(t,e,n){return V.resolve()}updateIndexEntries(t,e){return V.resolve()}}class fh{constructor(){this.index={}}add(t){const e=t.lastSegment(),n=t.popLast(),i=this.index[e]||new st(X.comparator),o=!i.has(n);return this.index[e]=i.add(n),o}has(t){const e=t.lastSegment(),n=t.popLast(),i=this.index[e];return i&&i.has(n)}getEntries(t){return(this.index[t]||new st(X.comparator)).toArray()}}/**
838
+ * @license
839
+ * Copyright 2018 Google LLC
840
+ *
841
+ * Licensed under the Apache License, Version 2.0 (the "License");
842
+ * you may not use this file except in compliance with the License.
843
+ * You may obtain a copy of the License at
844
+ *
845
+ * http://www.apache.org/licenses/LICENSE-2.0
846
+ *
847
+ * Unless required by applicable law or agreed to in writing, software
848
+ * distributed under the License is distributed on an "AS IS" BASIS,
849
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
850
+ * See the License for the specific language governing permissions and
851
+ * limitations under the License.
852
+ */const Fo={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},ou=41943040;class vt{static withCacheSize(t){return new vt(t,vt.DEFAULT_COLLECTION_PERCENTILE,vt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(t,e,n){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=e,this.maximumSequenceNumbersToCollect=n}}/**
853
+ * @license
854
+ * Copyright 2017 Google LLC
855
+ *
856
+ * Licensed under the Apache License, Version 2.0 (the "License");
857
+ * you may not use this file except in compliance with the License.
858
+ * You may obtain a copy of the License at
859
+ *
860
+ * http://www.apache.org/licenses/LICENSE-2.0
861
+ *
862
+ * Unless required by applicable law or agreed to in writing, software
863
+ * distributed under the License is distributed on an "AS IS" BASIS,
864
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
865
+ * See the License for the specific language governing permissions and
866
+ * limitations under the License.
867
+ */vt.DEFAULT_COLLECTION_PERCENTILE=10,vt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,vt.DEFAULT=new vt(ou,vt.DEFAULT_COLLECTION_PERCENTILE,vt.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),vt.DISABLED=new vt(-1,0,0);/**
868
+ * @license
869
+ * Copyright 2017 Google LLC
870
+ *
871
+ * Licensed under the Apache License, Version 2.0 (the "License");
872
+ * you may not use this file except in compliance with the License.
873
+ * You may obtain a copy of the License at
874
+ *
875
+ * http://www.apache.org/licenses/LICENSE-2.0
876
+ *
877
+ * Unless required by applicable law or agreed to in writing, software
878
+ * distributed under the License is distributed on an "AS IS" BASIS,
879
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
880
+ * See the License for the specific language governing permissions and
881
+ * limitations under the License.
882
+ */class be{constructor(t){this._r=t}next(){return this._r+=2,this._r}static ar(){return new be(0)}static ur(){return new be(-1)}}/**
883
+ * @license
884
+ * Copyright 2020 Google LLC
885
+ *
886
+ * Licensed under the Apache License, Version 2.0 (the "License");
887
+ * you may not use this file except in compliance with the License.
888
+ * You may obtain a copy of the License at
889
+ *
890
+ * http://www.apache.org/licenses/LICENSE-2.0
891
+ *
892
+ * Unless required by applicable law or agreed to in writing, software
893
+ * distributed under the License is distributed on an "AS IS" BASIS,
894
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
895
+ * See the License for the specific language governing permissions and
896
+ * limitations under the License.
897
+ */const Lo="LruGarbageCollector",au=1048576;function Uo([r,t],[e,n]){const i=U(r,e);return i===0?U(t,n):i}class mh{constructor(t){this.Tr=t,this.buffer=new st(Uo),this.Ir=0}dr(){return++this.Ir}Er(t){const e=[t,this.dr()];if(this.buffer.size<this.Tr)this.buffer=this.buffer.add(e);else{const n=this.buffer.last();Uo(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}}get maxValue(){return this.buffer.last()[0]}}class ph{constructor(t,e,n){this.garbageCollector=t,this.asyncQueue=e,this.localStore=n,this.Ar=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Rr(6e4)}stop(){this.Ar&&(this.Ar.cancel(),this.Ar=null)}get started(){return this.Ar!==null}Rr(t){N(Lo,`Garbage collection scheduled in ${t}ms`),this.Ar=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",t,(async()=>{this.Ar=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){Oe(e)?N(Lo,"Ignoring IndexedDB error during garbage collection: ",e):await xe(e)}await this.Rr(3e5)}))}}class gh{constructor(t,e){this.Vr=t,this.params=e}calculateTargetCount(t,e){return this.Vr.mr(t).next((n=>Math.floor(e/100*n)))}nthSequenceNumber(t,e){if(e===0)return V.resolve(mr.ue);const n=new mh(e);return this.Vr.forEachTarget(t,(i=>n.Er(i.sequenceNumber))).next((()=>this.Vr.gr(t,(i=>n.Er(i))))).next((()=>n.maxValue))}removeTargets(t,e,n){return this.Vr.removeTargets(t,e,n)}removeOrphanedDocuments(t,e){return this.Vr.removeOrphanedDocuments(t,e)}collect(t,e){return this.params.cacheSizeCollectionThreshold===-1?(N("LruGarbageCollector","Garbage collection skipped; disabled"),V.resolve(Fo)):this.getCacheSize(t).next((n=>n<this.params.cacheSizeCollectionThreshold?(N("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Fo):this.pr(t,e)))}getCacheSize(t){return this.Vr.getCacheSize(t)}pr(t,e){let n,i,o,u,c,h,f;const p=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next((E=>(E>this.params.maximumSequenceNumbersToCollect?(N("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${E}`),i=this.params.maximumSequenceNumbersToCollect):i=E,u=Date.now(),this.nthSequenceNumber(t,i)))).next((E=>(n=E,c=Date.now(),this.removeTargets(t,n,e)))).next((E=>(o=E,h=Date.now(),this.removeOrphanedDocuments(t,n)))).next((E=>(f=Date.now(),Ie()<=qt.DEBUG&&N("LruGarbageCollector",`LRU Garbage Collection
898
+ Counted targets in ${u-p}ms
899
+ Determined least recently used ${i} in `+(c-u)+`ms
900
+ Removed ${o} targets in `+(h-c)+`ms
901
+ Removed ${E} documents in `+(f-h)+`ms
902
+ Total Duration: ${f-p}ms`),V.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:o,documentsRemoved:E}))))}}function _h(r,t){return new gh(r,t)}/**
903
+ * @license
904
+ * Copyright 2017 Google LLC
905
+ *
906
+ * Licensed under the Apache License, Version 2.0 (the "License");
907
+ * you may not use this file except in compliance with the License.
908
+ * You may obtain a copy of the License at
909
+ *
910
+ * http://www.apache.org/licenses/LICENSE-2.0
911
+ *
912
+ * Unless required by applicable law or agreed to in writing, software
913
+ * distributed under the License is distributed on an "AS IS" BASIS,
914
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
915
+ * See the License for the specific language governing permissions and
916
+ * limitations under the License.
917
+ */class yh{constructor(){this.changes=new ge((t=>t.toString()),((t,e)=>t.isEqual(e))),this.changesApplied=!1}addEntry(t){this.assertNotApplied(),this.changes.set(t.key,t)}removeEntry(t,e){this.assertNotApplied(),this.changes.set(t,yt.newInvalidDocument(t).setReadTime(e))}getEntry(t,e){this.assertNotApplied();const n=this.changes.get(e);return n!==void 0?V.resolve(n):this.getFromCache(t,e)}getEntries(t,e){return this.getAllFromCache(t,e)}apply(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)}assertNotApplied(){}}/**
918
+ * @license
919
+ * Copyright 2017 Google LLC
920
+ *
921
+ * Licensed under the Apache License, Version 2.0 (the "License");
922
+ * you may not use this file except in compliance with the License.
923
+ * You may obtain a copy of the License at
924
+ *
925
+ * http://www.apache.org/licenses/LICENSE-2.0
926
+ *
927
+ * Unless required by applicable law or agreed to in writing, software
928
+ * distributed under the License is distributed on an "AS IS" BASIS,
929
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
930
+ * See the License for the specific language governing permissions and
931
+ * limitations under the License.
932
+ *//**
933
+ * @license
934
+ * Copyright 2022 Google LLC
935
+ *
936
+ * Licensed under the Apache License, Version 2.0 (the "License");
937
+ * you may not use this file except in compliance with the License.
938
+ * You may obtain a copy of the License at
939
+ *
940
+ * http://www.apache.org/licenses/LICENSE-2.0
941
+ *
942
+ * Unless required by applicable law or agreed to in writing, software
943
+ * distributed under the License is distributed on an "AS IS" BASIS,
944
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
945
+ * See the License for the specific language governing permissions and
946
+ * limitations under the License.
947
+ */class Eh{constructor(t,e){this.overlayedDocument=t,this.mutatedFields=e}}/**
948
+ * @license
949
+ * Copyright 2017 Google LLC
950
+ *
951
+ * Licensed under the Apache License, Version 2.0 (the "License");
952
+ * you may not use this file except in compliance with the License.
953
+ * You may obtain a copy of the License at
954
+ *
955
+ * http://www.apache.org/licenses/LICENSE-2.0
956
+ *
957
+ * Unless required by applicable law or agreed to in writing, software
958
+ * distributed under the License is distributed on an "AS IS" BASIS,
959
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
960
+ * See the License for the specific language governing permissions and
961
+ * limitations under the License.
962
+ */class Th{constructor(t,e,n,i){this.remoteDocumentCache=t,this.mutationQueue=e,this.documentOverlayCache=n,this.indexManager=i}getDocument(t,e){let n=null;return this.documentOverlayCache.getOverlay(t,e).next((i=>(n=i,this.remoteDocumentCache.getEntry(t,e)))).next((i=>(n!==null&&ln(n.mutation,i,wt.empty(),W.now()),i)))}getDocuments(t,e){return this.remoteDocumentCache.getEntries(t,e).next((n=>this.getLocalViewOfDocuments(t,n,q()).next((()=>n))))}getLocalViewOfDocuments(t,e,n=q()){const i=he();return this.populateOverlays(t,i,e).next((()=>this.computeViews(t,e,i,n).next((o=>{let u=nn();return o.forEach(((c,h)=>{u=u.insert(c,h.overlayedDocument)})),u}))))}getOverlayedDocuments(t,e){const n=he();return this.populateOverlays(t,n,e).next((()=>this.computeViews(t,e,n,q())))}populateOverlays(t,e,n){const i=[];return n.forEach((o=>{e.has(o)||i.push(o)})),this.documentOverlayCache.getOverlays(t,i).next((o=>{o.forEach(((u,c)=>{e.set(u,c)}))}))}computeViews(t,e,n,i){let o=$t();const u=un(),c=(function(){return un()})();return e.forEach(((h,f)=>{const p=n.get(f.key);i.has(f.key)&&(p===void 0||p.mutation instanceof oe)?o=o.insert(f.key,f):p!==void 0?(u.set(f.key,p.mutation.getFieldMask()),ln(p.mutation,f,p.mutation.getFieldMask(),W.now())):u.set(f.key,wt.empty())})),this.recalculateAndSaveOverlays(t,o).next((h=>(h.forEach(((f,p)=>u.set(f,p))),e.forEach(((f,p)=>{var E;return c.set(f,new Eh(p,(E=u.get(f))!==null&&E!==void 0?E:null))})),c)))}recalculateAndSaveOverlays(t,e){const n=un();let i=new Y(((u,c)=>u-c)),o=q();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(t,e).next((u=>{for(const c of u)c.keys().forEach((h=>{const f=e.get(h);if(f===null)return;let p=n.get(h)||wt.empty();p=c.applyToLocalView(f,p),n.set(h,p);const E=(i.get(c.batchId)||q()).add(h);i=i.insert(c.batchId,E)}))})).next((()=>{const u=[],c=i.getReverseIterator();for(;c.hasNext();){const h=c.getNext(),f=h.key,p=h.value,E=Ba();p.forEach((R=>{if(!o.has(R)){const S=Wa(e.get(R),n.get(R));S!==null&&E.set(R,S),o=o.add(R)}})),u.push(this.documentOverlayCache.saveOverlays(t,f,E))}return V.waitFor(u)})).next((()=>n))}recalculateAndSaveOverlaysForDocumentKeys(t,e){return this.remoteDocumentCache.getEntries(t,e).next((n=>this.recalculateAndSaveOverlays(t,n)))}getDocumentsMatchingQuery(t,e,n,i){return(function(u){return O.isDocumentKey(u.path)&&u.collectionGroup===null&&u.filters.length===0})(e)?this.getDocumentsMatchingDocumentQuery(t,e.path):wc(e)?this.getDocumentsMatchingCollectionGroupQuery(t,e,n,i):this.getDocumentsMatchingCollectionQuery(t,e,n,i)}getNextDocuments(t,e,n,i){return this.remoteDocumentCache.getAllFromCollectionGroup(t,e,n,i).next((o=>{const u=i-o.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(t,e,n.largestBatchId,i-o.size):V.resolve(he());let c=hn,h=o;return u.next((f=>V.forEach(f,((p,E)=>(c<E.largestBatchId&&(c=E.largestBatchId),o.get(p)?V.resolve():this.remoteDocumentCache.getEntry(t,p).next((R=>{h=h.insert(p,R)}))))).next((()=>this.populateOverlays(t,f,o))).next((()=>this.computeViews(t,h,f,q()))).next((p=>({batchId:c,changes:ja(p)})))))}))}getDocumentsMatchingDocumentQuery(t,e){return this.getDocument(t,new O(e)).next((n=>{let i=nn();return n.isFoundDocument()&&(i=i.insert(n.key,n)),i}))}getDocumentsMatchingCollectionGroupQuery(t,e,n,i){const o=e.collectionGroup;let u=nn();return this.indexManager.getCollectionParents(t,o).next((c=>V.forEach(c,(h=>{const f=(function(E,R){return new _r(R,null,E.explicitOrderBy.slice(),E.filters.slice(),E.limit,E.limitType,E.startAt,E.endAt)})(e,h.child(o));return this.getDocumentsMatchingCollectionQuery(t,f,n,i).next((p=>{p.forEach(((E,R)=>{u=u.insert(E,R)}))}))})).next((()=>u))))}getDocumentsMatchingCollectionQuery(t,e,n,i){let o;return this.documentOverlayCache.getOverlaysForCollection(t,e.path,n.largestBatchId).next((u=>(o=u,this.remoteDocumentCache.getDocumentsMatchingQuery(t,e,n,o,i)))).next((u=>{o.forEach(((h,f)=>{const p=f.getKey();u.get(p)===null&&(u=u.insert(p,yt.newInvalidDocument(p)))}));let c=nn();return u.forEach(((h,f)=>{const p=o.get(h);p!==void 0&&ln(p.mutation,f,wt.empty(),W.now()),Tr(e,f)&&(c=c.insert(h,f))})),c}))}}/**
963
+ * @license
964
+ * Copyright 2020 Google LLC
965
+ *
966
+ * Licensed under the Apache License, Version 2.0 (the "License");
967
+ * you may not use this file except in compliance with the License.
968
+ * You may obtain a copy of the License at
969
+ *
970
+ * http://www.apache.org/licenses/LICENSE-2.0
971
+ *
972
+ * Unless required by applicable law or agreed to in writing, software
973
+ * distributed under the License is distributed on an "AS IS" BASIS,
974
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
975
+ * See the License for the specific language governing permissions and
976
+ * limitations under the License.
977
+ */class vh{constructor(t){this.serializer=t,this.Br=new Map,this.Lr=new Map}getBundleMetadata(t,e){return V.resolve(this.Br.get(e))}saveBundleMetadata(t,e){return this.Br.set(e.id,(function(i){return{id:i.id,version:i.version,createTime:bt(i.createTime)}})(e)),V.resolve()}getNamedQuery(t,e){return V.resolve(this.Lr.get(e))}saveNamedQuery(t,e){return this.Lr.set(e.name,(function(i){return{name:i.name,query:hh(i.bundledQuery),readTime:bt(i.readTime)}})(e)),V.resolve()}}/**
978
+ * @license
979
+ * Copyright 2022 Google LLC
980
+ *
981
+ * Licensed under the Apache License, Version 2.0 (the "License");
982
+ * you may not use this file except in compliance with the License.
983
+ * You may obtain a copy of the License at
984
+ *
985
+ * http://www.apache.org/licenses/LICENSE-2.0
986
+ *
987
+ * Unless required by applicable law or agreed to in writing, software
988
+ * distributed under the License is distributed on an "AS IS" BASIS,
989
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
990
+ * See the License for the specific language governing permissions and
991
+ * limitations under the License.
992
+ */class Ih{constructor(){this.overlays=new Y(O.comparator),this.kr=new Map}getOverlay(t,e){return V.resolve(this.overlays.get(e))}getOverlays(t,e){const n=he();return V.forEach(e,(i=>this.getOverlay(t,i).next((o=>{o!==null&&n.set(i,o)})))).next((()=>n))}saveOverlays(t,e,n){return n.forEach(((i,o)=>{this.wt(t,e,o)})),V.resolve()}removeOverlaysForBatchId(t,e,n){const i=this.kr.get(n);return i!==void 0&&(i.forEach((o=>this.overlays=this.overlays.remove(o))),this.kr.delete(n)),V.resolve()}getOverlaysForCollection(t,e,n){const i=he(),o=e.length+1,u=new O(e.child("")),c=this.overlays.getIteratorFrom(u);for(;c.hasNext();){const h=c.getNext().value,f=h.getKey();if(!e.isPrefixOf(f.path))break;f.path.length===o&&h.largestBatchId>n&&i.set(h.getKey(),h)}return V.resolve(i)}getOverlaysForCollectionGroup(t,e,n,i){let o=new Y(((f,p)=>f-p));const u=this.overlays.getIterator();for(;u.hasNext();){const f=u.getNext().value;if(f.getKey().getCollectionGroup()===e&&f.largestBatchId>n){let p=o.get(f.largestBatchId);p===null&&(p=he(),o=o.insert(f.largestBatchId,p)),p.set(f.getKey(),f)}}const c=he(),h=o.getIterator();for(;h.hasNext()&&(h.getNext().value.forEach(((f,p)=>c.set(f,p))),!(c.size()>=i)););return V.resolve(c)}wt(t,e,n){const i=this.overlays.get(n.key);if(i!==null){const u=this.kr.get(i.largestBatchId).delete(n.key);this.kr.set(i.largestBatchId,u)}this.overlays=this.overlays.insert(n.key,new Bc(e,n));let o=this.kr.get(e);o===void 0&&(o=q(),this.kr.set(e,o)),this.kr.set(e,o.add(n.key))}}/**
993
+ * @license
994
+ * Copyright 2024 Google LLC
995
+ *
996
+ * Licensed under the Apache License, Version 2.0 (the "License");
997
+ * you may not use this file except in compliance with the License.
998
+ * You may obtain a copy of the License at
999
+ *
1000
+ * http://www.apache.org/licenses/LICENSE-2.0
1001
+ *
1002
+ * Unless required by applicable law or agreed to in writing, software
1003
+ * distributed under the License is distributed on an "AS IS" BASIS,
1004
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1005
+ * See the License for the specific language governing permissions and
1006
+ * limitations under the License.
1007
+ */class Ah{constructor(){this.sessionToken=ht.EMPTY_BYTE_STRING}getSessionToken(t){return V.resolve(this.sessionToken)}setSessionToken(t,e){return this.sessionToken=e,V.resolve()}}/**
1008
+ * @license
1009
+ * Copyright 2017 Google LLC
1010
+ *
1011
+ * Licensed under the Apache License, Version 2.0 (the "License");
1012
+ * you may not use this file except in compliance with the License.
1013
+ * You may obtain a copy of the License at
1014
+ *
1015
+ * http://www.apache.org/licenses/LICENSE-2.0
1016
+ *
1017
+ * Unless required by applicable law or agreed to in writing, software
1018
+ * distributed under the License is distributed on an "AS IS" BASIS,
1019
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1020
+ * See the License for the specific language governing permissions and
1021
+ * limitations under the License.
1022
+ */class Ms{constructor(){this.qr=new st(ot.Qr),this.$r=new st(ot.Ur)}isEmpty(){return this.qr.isEmpty()}addReference(t,e){const n=new ot(t,e);this.qr=this.qr.add(n),this.$r=this.$r.add(n)}Kr(t,e){t.forEach((n=>this.addReference(n,e)))}removeReference(t,e){this.Wr(new ot(t,e))}Gr(t,e){t.forEach((n=>this.removeReference(n,e)))}zr(t){const e=new O(new X([])),n=new ot(e,t),i=new ot(e,t+1),o=[];return this.$r.forEachInRange([n,i],(u=>{this.Wr(u),o.push(u.key)})),o}jr(){this.qr.forEach((t=>this.Wr(t)))}Wr(t){this.qr=this.qr.delete(t),this.$r=this.$r.delete(t)}Jr(t){const e=new O(new X([])),n=new ot(e,t),i=new ot(e,t+1);let o=q();return this.$r.forEachInRange([n,i],(u=>{o=o.add(u.key)})),o}containsKey(t){const e=new ot(t,0),n=this.qr.firstAfterOrEqual(e);return n!==null&&t.isEqual(n.key)}}class ot{constructor(t,e){this.key=t,this.Hr=e}static Qr(t,e){return O.comparator(t.key,e.key)||U(t.Hr,e.Hr)}static Ur(t,e){return U(t.Hr,e.Hr)||O.comparator(t.key,e.key)}}/**
1023
+ * @license
1024
+ * Copyright 2017 Google LLC
1025
+ *
1026
+ * Licensed under the Apache License, Version 2.0 (the "License");
1027
+ * you may not use this file except in compliance with the License.
1028
+ * You may obtain a copy of the License at
1029
+ *
1030
+ * http://www.apache.org/licenses/LICENSE-2.0
1031
+ *
1032
+ * Unless required by applicable law or agreed to in writing, software
1033
+ * distributed under the License is distributed on an "AS IS" BASIS,
1034
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1035
+ * See the License for the specific language governing permissions and
1036
+ * limitations under the License.
1037
+ */class wh{constructor(t,e){this.indexManager=t,this.referenceDelegate=e,this.mutationQueue=[],this.er=1,this.Yr=new st(ot.Qr)}checkEmpty(t){return V.resolve(this.mutationQueue.length===0)}addMutationBatch(t,e,n,i){const o=this.er;this.er++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const u=new jc(o,e,n,i);this.mutationQueue.push(u);for(const c of i)this.Yr=this.Yr.add(new ot(c.key,o)),this.indexManager.addToCollectionParentIndex(t,c.key.path.popLast());return V.resolve(u)}lookupMutationBatch(t,e){return V.resolve(this.Zr(e))}getNextMutationBatchAfterBatchId(t,e){const n=e+1,i=this.Xr(n),o=i<0?0:i;return V.resolve(this.mutationQueue.length>o?this.mutationQueue[o]:null)}getHighestUnacknowledgedBatchId(){return V.resolve(this.mutationQueue.length===0?Ps:this.er-1)}getAllMutationBatches(t){return V.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(t,e){const n=new ot(e,0),i=new ot(e,Number.POSITIVE_INFINITY),o=[];return this.Yr.forEachInRange([n,i],(u=>{const c=this.Zr(u.Hr);o.push(c)})),V.resolve(o)}getAllMutationBatchesAffectingDocumentKeys(t,e){let n=new st(U);return e.forEach((i=>{const o=new ot(i,0),u=new ot(i,Number.POSITIVE_INFINITY);this.Yr.forEachInRange([o,u],(c=>{n=n.add(c.Hr)}))})),V.resolve(this.ei(n))}getAllMutationBatchesAffectingQuery(t,e){const n=e.path,i=n.length+1;let o=n;O.isDocumentKey(o)||(o=o.child(""));const u=new ot(new O(o),0);let c=new st(U);return this.Yr.forEachWhile((h=>{const f=h.key.path;return!!n.isPrefixOf(f)&&(f.length===i&&(c=c.add(h.Hr)),!0)}),u),V.resolve(this.ei(c))}ei(t){const e=[];return t.forEach((n=>{const i=this.Zr(n);i!==null&&e.push(i)})),e}removeMutationBatch(t,e){G(this.ti(e.batchId,"removed")===0,55003),this.mutationQueue.shift();let n=this.Yr;return V.forEach(e.mutations,(i=>{const o=new ot(i.key,e.batchId);return n=n.delete(o),this.referenceDelegate.markPotentiallyOrphaned(t,i.key)})).next((()=>{this.Yr=n}))}rr(t){}containsKey(t,e){const n=new ot(e,0),i=this.Yr.firstAfterOrEqual(n);return V.resolve(e.isEqual(i&&i.key))}performConsistencyCheck(t){return this.mutationQueue.length,V.resolve()}ti(t,e){return this.Xr(t)}Xr(t){return this.mutationQueue.length===0?0:t-this.mutationQueue[0].batchId}Zr(t){const e=this.Xr(t);return e<0||e>=this.mutationQueue.length?null:this.mutationQueue[e]}}/**
1038
+ * @license
1039
+ * Copyright 2017 Google LLC
1040
+ *
1041
+ * Licensed under the Apache License, Version 2.0 (the "License");
1042
+ * you may not use this file except in compliance with the License.
1043
+ * You may obtain a copy of the License at
1044
+ *
1045
+ * http://www.apache.org/licenses/LICENSE-2.0
1046
+ *
1047
+ * Unless required by applicable law or agreed to in writing, software
1048
+ * distributed under the License is distributed on an "AS IS" BASIS,
1049
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1050
+ * See the License for the specific language governing permissions and
1051
+ * limitations under the License.
1052
+ */class Rh{constructor(t){this.ni=t,this.docs=(function(){return new Y(O.comparator)})(),this.size=0}setIndexManager(t){this.indexManager=t}addEntry(t,e){const n=e.key,i=this.docs.get(n),o=i?i.size:0,u=this.ni(e);return this.docs=this.docs.insert(n,{document:e.mutableCopy(),size:u}),this.size+=u-o,this.indexManager.addToCollectionParentIndex(t,n.path.popLast())}removeEntry(t){const e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)}getEntry(t,e){const n=this.docs.get(e);return V.resolve(n?n.document.mutableCopy():yt.newInvalidDocument(e))}getEntries(t,e){let n=$t();return e.forEach((i=>{const o=this.docs.get(i);n=n.insert(i,o?o.document.mutableCopy():yt.newInvalidDocument(i))})),V.resolve(n)}getDocumentsMatchingQuery(t,e,n,i){let o=$t();const u=e.path,c=new O(u.child("__id-9223372036854775808__")),h=this.docs.getIteratorFrom(c);for(;h.hasNext();){const{key:f,value:{document:p}}=h.getNext();if(!u.isPrefixOf(f.path))break;f.path.length>u.length+1||ec(tc(p),n)<=0||(i.has(p.key)||Tr(e,p))&&(o=o.insert(p.key,p.mutableCopy()))}return V.resolve(o)}getAllFromCollectionGroup(t,e,n,i){M(9500)}ri(t,e){return V.forEach(this.docs,(n=>e(n)))}newChangeBuffer(t){return new Ph(this)}getSize(t){return V.resolve(this.size)}}class Ph extends yh{constructor(t){super(),this.Or=t}applyChanges(t){const e=[];return this.changes.forEach(((n,i)=>{i.isValidDocument()?e.push(this.Or.addEntry(t,i)):this.Or.removeEntry(n)})),V.waitFor(e)}getFromCache(t,e){return this.Or.getEntry(t,e)}getAllFromCache(t,e){return this.Or.getEntries(t,e)}}/**
1053
+ * @license
1054
+ * Copyright 2017 Google LLC
1055
+ *
1056
+ * Licensed under the Apache License, Version 2.0 (the "License");
1057
+ * you may not use this file except in compliance with the License.
1058
+ * You may obtain a copy of the License at
1059
+ *
1060
+ * http://www.apache.org/licenses/LICENSE-2.0
1061
+ *
1062
+ * Unless required by applicable law or agreed to in writing, software
1063
+ * distributed under the License is distributed on an "AS IS" BASIS,
1064
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1065
+ * See the License for the specific language governing permissions and
1066
+ * limitations under the License.
1067
+ */class Vh{constructor(t){this.persistence=t,this.ii=new ge((e=>Cs(e)),bs),this.lastRemoteSnapshotVersion=F.min(),this.highestTargetId=0,this.si=0,this.oi=new Ms,this.targetCount=0,this._i=be.ar()}forEachTarget(t,e){return this.ii.forEach(((n,i)=>e(i))),V.resolve()}getLastRemoteSnapshotVersion(t){return V.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(t){return V.resolve(this.si)}allocateTargetId(t){return this.highestTargetId=this._i.next(),V.resolve(this.highestTargetId)}setTargetsMetadata(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.si&&(this.si=e),V.resolve()}hr(t){this.ii.set(t.target,t);const e=t.targetId;e>this.highestTargetId&&(this._i=new be(e),this.highestTargetId=e),t.sequenceNumber>this.si&&(this.si=t.sequenceNumber)}addTargetData(t,e){return this.hr(e),this.targetCount+=1,V.resolve()}updateTargetData(t,e){return this.hr(e),V.resolve()}removeTargetData(t,e){return this.ii.delete(e.target),this.oi.zr(e.targetId),this.targetCount-=1,V.resolve()}removeTargets(t,e,n){let i=0;const o=[];return this.ii.forEach(((u,c)=>{c.sequenceNumber<=e&&n.get(c.targetId)===null&&(this.ii.delete(u),o.push(this.removeMatchingKeysForTargetId(t,c.targetId)),i++)})),V.waitFor(o).next((()=>i))}getTargetCount(t){return V.resolve(this.targetCount)}getTargetData(t,e){const n=this.ii.get(e)||null;return V.resolve(n)}addMatchingKeys(t,e,n){return this.oi.Kr(e,n),V.resolve()}removeMatchingKeys(t,e,n){this.oi.Gr(e,n);const i=this.persistence.referenceDelegate,o=[];return i&&e.forEach((u=>{o.push(i.markPotentiallyOrphaned(t,u))})),V.waitFor(o)}removeMatchingKeysForTargetId(t,e){return this.oi.zr(e),V.resolve()}getMatchingKeysForTargetId(t,e){const n=this.oi.Jr(e);return V.resolve(n)}containsKey(t,e){return V.resolve(this.oi.containsKey(e))}}/**
1068
+ * @license
1069
+ * Copyright 2017 Google LLC
1070
+ *
1071
+ * Licensed under the Apache License, Version 2.0 (the "License");
1072
+ * you may not use this file except in compliance with the License.
1073
+ * You may obtain a copy of the License at
1074
+ *
1075
+ * http://www.apache.org/licenses/LICENSE-2.0
1076
+ *
1077
+ * Unless required by applicable law or agreed to in writing, software
1078
+ * distributed under the License is distributed on an "AS IS" BASIS,
1079
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1080
+ * See the License for the specific language governing permissions and
1081
+ * limitations under the License.
1082
+ */class uu{constructor(t,e){this.ai={},this.overlays={},this.ui=new mr(0),this.ci=!1,this.ci=!0,this.li=new Ah,this.referenceDelegate=t(this),this.hi=new Vh(this),this.indexManager=new dh,this.remoteDocumentCache=(function(i){return new Rh(i)})((n=>this.referenceDelegate.Pi(n))),this.serializer=new ch(e),this.Ti=new vh(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ci=!1,Promise.resolve()}get started(){return this.ci}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(t){return this.indexManager}getDocumentOverlayCache(t){let e=this.overlays[t.toKey()];return e||(e=new Ih,this.overlays[t.toKey()]=e),e}getMutationQueue(t,e){let n=this.ai[t.toKey()];return n||(n=new wh(e,this.referenceDelegate),this.ai[t.toKey()]=n),n}getGlobalsCache(){return this.li}getTargetCache(){return this.hi}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ti}runTransaction(t,e,n){N("MemoryPersistence","Starting transaction:",t);const i=new Sh(this.ui.next());return this.referenceDelegate.Ii(),n(i).next((o=>this.referenceDelegate.di(i).next((()=>o)))).toPromise().then((o=>(i.raiseOnCommittedEvent(),o)))}Ei(t,e){return V.or(Object.values(this.ai).map((n=>()=>n.containsKey(t,e))))}}class Sh extends rc{constructor(t){super(),this.currentSequenceNumber=t}}class Fs{constructor(t){this.persistence=t,this.Ai=new Ms,this.Ri=null}static Vi(t){return new Fs(t)}get mi(){if(this.Ri)return this.Ri;throw M(60996)}addReference(t,e,n){return this.Ai.addReference(n,e),this.mi.delete(n.toString()),V.resolve()}removeReference(t,e,n){return this.Ai.removeReference(n,e),this.mi.add(n.toString()),V.resolve()}markPotentiallyOrphaned(t,e){return this.mi.add(e.toString()),V.resolve()}removeTarget(t,e){this.Ai.zr(e.targetId).forEach((i=>this.mi.add(i.toString())));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(t,e.targetId).next((i=>{i.forEach((o=>this.mi.add(o.toString())))})).next((()=>n.removeTargetData(t,e)))}Ii(){this.Ri=new Set}di(t){const e=this.persistence.getRemoteDocumentCache().newChangeBuffer();return V.forEach(this.mi,(n=>{const i=O.fromPath(n);return this.fi(t,i).next((o=>{o||e.removeEntry(i,F.min())}))})).next((()=>(this.Ri=null,e.apply(t))))}updateLimboDocument(t,e){return this.fi(t,e).next((n=>{n?this.mi.delete(e.toString()):this.mi.add(e.toString())}))}Pi(t){return 0}fi(t,e){return V.or([()=>V.resolve(this.Ai.containsKey(e)),()=>this.persistence.getTargetCache().containsKey(t,e),()=>this.persistence.Ei(t,e)])}}class lr{constructor(t,e){this.persistence=t,this.gi=new ge((n=>oc(n.path)),((n,i)=>n.isEqual(i))),this.garbageCollector=_h(this,e)}static Vi(t,e){return new lr(t,e)}Ii(){}di(t){return V.resolve()}forEachTarget(t,e){return this.persistence.getTargetCache().forEachTarget(t,e)}mr(t){const e=this.yr(t);return this.persistence.getTargetCache().getTargetCount(t).next((n=>e.next((i=>n+i))))}yr(t){let e=0;return this.gr(t,(n=>{e++})).next((()=>e))}gr(t,e){return V.forEach(this.gi,((n,i)=>this.Sr(t,n,i).next((o=>o?V.resolve():e(i)))))}removeTargets(t,e,n){return this.persistence.getTargetCache().removeTargets(t,e,n)}removeOrphanedDocuments(t,e){let n=0;const i=this.persistence.getRemoteDocumentCache(),o=i.newChangeBuffer();return i.ri(t,(u=>this.Sr(t,u,e).next((c=>{c||(n++,o.removeEntry(u,F.min()))})))).next((()=>o.apply(t))).next((()=>n))}markPotentiallyOrphaned(t,e){return this.gi.set(e,t.currentSequenceNumber),V.resolve()}removeTarget(t,e){const n=e.withSequenceNumber(t.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(t,n)}addReference(t,e,n){return this.gi.set(n,t.currentSequenceNumber),V.resolve()}removeReference(t,e,n){return this.gi.set(n,t.currentSequenceNumber),V.resolve()}updateLimboDocument(t,e){return this.gi.set(e,t.currentSequenceNumber),V.resolve()}Pi(t){let e=t.key.toString().length;return t.isFoundDocument()&&(e+=Yn(t.data.value)),e}Sr(t,e,n){return V.or([()=>this.persistence.Ei(t,e),()=>this.persistence.getTargetCache().containsKey(t,e),()=>{const i=this.gi.get(e);return V.resolve(i!==void 0&&i>n)}])}getCacheSize(t){return this.persistence.getRemoteDocumentCache().getSize(t)}}/**
1083
+ * @license
1084
+ * Copyright 2017 Google LLC
1085
+ *
1086
+ * Licensed under the Apache License, Version 2.0 (the "License");
1087
+ * you may not use this file except in compliance with the License.
1088
+ * You may obtain a copy of the License at
1089
+ *
1090
+ * http://www.apache.org/licenses/LICENSE-2.0
1091
+ *
1092
+ * Unless required by applicable law or agreed to in writing, software
1093
+ * distributed under the License is distributed on an "AS IS" BASIS,
1094
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1095
+ * See the License for the specific language governing permissions and
1096
+ * limitations under the License.
1097
+ */class Ls{constructor(t,e,n,i){this.targetId=t,this.fromCache=e,this.Is=n,this.ds=i}static Es(t,e){let n=q(),i=q();for(const o of e.docChanges)switch(o.type){case 0:n=n.add(o.doc.key);break;case 1:i=i.add(o.doc.key)}return new Ls(t,e.fromCache,n,i)}}/**
1098
+ * @license
1099
+ * Copyright 2023 Google LLC
1100
+ *
1101
+ * Licensed under the Apache License, Version 2.0 (the "License");
1102
+ * you may not use this file except in compliance with the License.
1103
+ * You may obtain a copy of the License at
1104
+ *
1105
+ * http://www.apache.org/licenses/LICENSE-2.0
1106
+ *
1107
+ * Unless required by applicable law or agreed to in writing, software
1108
+ * distributed under the License is distributed on an "AS IS" BASIS,
1109
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1110
+ * See the License for the specific language governing permissions and
1111
+ * limitations under the License.
1112
+ */class Ch{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(t){this._documentReadCount+=t}}/**
1113
+ * @license
1114
+ * Copyright 2019 Google LLC
1115
+ *
1116
+ * Licensed under the Apache License, Version 2.0 (the "License");
1117
+ * you may not use this file except in compliance with the License.
1118
+ * You may obtain a copy of the License at
1119
+ *
1120
+ * http://www.apache.org/licenses/LICENSE-2.0
1121
+ *
1122
+ * Unless required by applicable law or agreed to in writing, software
1123
+ * distributed under the License is distributed on an "AS IS" BASIS,
1124
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1125
+ * See the License for the specific language governing permissions and
1126
+ * limitations under the License.
1127
+ */class bh{constructor(){this.As=!1,this.Rs=!1,this.Vs=100,this.fs=(function(){return xl()?8:sc(Ol())>0?6:4})()}initialize(t,e){this.gs=t,this.indexManager=e,this.As=!0}getDocumentsMatchingQuery(t,e,n,i){const o={result:null};return this.ps(t,e).next((u=>{o.result=u})).next((()=>{if(!o.result)return this.ys(t,e,i,n).next((u=>{o.result=u}))})).next((()=>{if(o.result)return;const u=new Ch;return this.ws(t,e,u).next((c=>{if(o.result=c,this.Rs)return this.Ss(t,e,u,c.size)}))})).next((()=>o.result))}Ss(t,e,n,i){return n.documentReadCount<this.Vs?(Ie()<=qt.DEBUG&&N("QueryEngine","SDK will not create cache indexes for query:",Ae(e),"since it only creates cache indexes for collection contains","more than or equal to",this.Vs,"documents"),V.resolve()):(Ie()<=qt.DEBUG&&N("QueryEngine","Query:",Ae(e),"scans",n.documentReadCount,"local documents and returns",i,"documents as results."),n.documentReadCount>this.fs*i?(Ie()<=qt.DEBUG&&N("QueryEngine","The SDK decides to create cache indexes for query:",Ae(e),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(t,Ct(e))):V.resolve())}ps(t,e){if(Vo(e))return V.resolve(null);let n=Ct(e);return this.indexManager.getIndexType(t,n).next((i=>i===0?null:(e.limit!==null&&i===1&&(e=hs(e,null,"F"),n=Ct(e)),this.indexManager.getDocumentsMatchingTarget(t,n).next((o=>{const u=q(...o);return this.gs.getDocuments(t,u).next((c=>this.indexManager.getMinOffset(t,n).next((h=>{const f=this.bs(e,c);return this.Ds(e,f,u,h.readTime)?this.ps(t,hs(e,null,"F")):this.vs(t,f,e,h)}))))})))))}ys(t,e,n,i){return Vo(e)||i.isEqual(F.min())?V.resolve(null):this.gs.getDocuments(t,n).next((o=>{const u=this.bs(e,o);return this.Ds(e,u,n,i)?V.resolve(null):(Ie()<=qt.DEBUG&&N("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),Ae(e)),this.vs(t,u,e,Zl(i,hn)).next((c=>c)))}))}bs(t,e){let n=new st(Ua(t));return e.forEach(((i,o)=>{Tr(t,o)&&(n=n.add(o))})),n}Ds(t,e,n,i){if(t.limit===null)return!1;if(n.size!==e.size)return!0;const o=t.limitType==="F"?e.last():e.first();return!!o&&(o.hasPendingWrites||o.version.compareTo(i)>0)}ws(t,e,n){return Ie()<=qt.DEBUG&&N("QueryEngine","Using full collection scan to execute query:",Ae(e)),this.gs.getDocumentsMatchingQuery(t,e,Zt.min(),n)}vs(t,e,n,i){return this.gs.getDocumentsMatchingQuery(t,n,i).next((o=>(e.forEach((u=>{o=o.insert(u.key,u)})),o)))}}/**
1128
+ * @license
1129
+ * Copyright 2020 Google LLC
1130
+ *
1131
+ * Licensed under the Apache License, Version 2.0 (the "License");
1132
+ * you may not use this file except in compliance with the License.
1133
+ * You may obtain a copy of the License at
1134
+ *
1135
+ * http://www.apache.org/licenses/LICENSE-2.0
1136
+ *
1137
+ * Unless required by applicable law or agreed to in writing, software
1138
+ * distributed under the License is distributed on an "AS IS" BASIS,
1139
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1140
+ * See the License for the specific language governing permissions and
1141
+ * limitations under the License.
1142
+ */const Us="LocalStore",Dh=3e8;class Nh{constructor(t,e,n,i){this.persistence=t,this.Cs=e,this.serializer=i,this.Fs=new Y(U),this.Ms=new ge((o=>Cs(o)),bs),this.xs=new Map,this.Os=t.getRemoteDocumentCache(),this.hi=t.getTargetCache(),this.Ti=t.getBundleCache(),this.Ns(n)}Ns(t){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(t),this.indexManager=this.persistence.getIndexManager(t),this.mutationQueue=this.persistence.getMutationQueue(t,this.indexManager),this.localDocuments=new Th(this.Os,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Os.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(e=>t.collect(e,this.Fs)))}}function kh(r,t,e,n){return new Nh(r,t,e,n)}async function lu(r,t){const e=L(r);return await e.persistence.runTransaction("Handle user change","readonly",(n=>{let i;return e.mutationQueue.getAllMutationBatches(n).next((o=>(i=o,e.Ns(t),e.mutationQueue.getAllMutationBatches(n)))).next((o=>{const u=[],c=[];let h=q();for(const f of i){u.push(f.batchId);for(const p of f.mutations)h=h.add(p.key)}for(const f of o){c.push(f.batchId);for(const p of f.mutations)h=h.add(p.key)}return e.localDocuments.getDocuments(n,h).next((f=>({Bs:f,removedBatchIds:u,addedBatchIds:c})))}))}))}function xh(r,t){const e=L(r);return e.persistence.runTransaction("Acknowledge batch","readwrite-primary",(n=>{const i=t.batch.keys(),o=e.Os.newChangeBuffer({trackRemovals:!0});return(function(c,h,f,p){const E=f.batch,R=E.keys();let S=V.resolve();return R.forEach((D=>{S=S.next((()=>p.getEntry(h,D))).next((x=>{const b=f.docVersions.get(D);G(b!==null,48541),x.version.compareTo(b)<0&&(E.applyToRemoteDocument(x,f),x.isValidDocument()&&(x.setReadTime(f.commitVersion),p.addEntry(x)))}))})),S.next((()=>c.mutationQueue.removeMutationBatch(h,E)))})(e,n,t,o).next((()=>o.apply(n))).next((()=>e.mutationQueue.performConsistencyCheck(n))).next((()=>e.documentOverlayCache.removeOverlaysForBatchId(n,i,t.batch.batchId))).next((()=>e.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(n,(function(c){let h=q();for(let f=0;f<c.mutationResults.length;++f)c.mutationResults[f].transformResults.length>0&&(h=h.add(c.batch.mutations[f].key));return h})(t)))).next((()=>e.localDocuments.getDocuments(n,i)))}))}function cu(r){const t=L(r);return t.persistence.runTransaction("Get last remote snapshot version","readonly",(e=>t.hi.getLastRemoteSnapshotVersion(e)))}function Oh(r,t){const e=L(r),n=t.snapshotVersion;let i=e.Fs;return e.persistence.runTransaction("Apply remote event","readwrite-primary",(o=>{const u=e.Os.newChangeBuffer({trackRemovals:!0});i=e.Fs;const c=[];t.targetChanges.forEach(((p,E)=>{const R=i.get(E);if(!R)return;c.push(e.hi.removeMatchingKeys(o,p.removedDocuments,E).next((()=>e.hi.addMatchingKeys(o,p.addedDocuments,E))));let S=R.withSequenceNumber(o.currentSequenceNumber);t.targetMismatches.get(E)!==null?S=S.withResumeToken(ht.EMPTY_BYTE_STRING,F.min()).withLastLimboFreeSnapshotVersion(F.min()):p.resumeToken.approximateByteSize()>0&&(S=S.withResumeToken(p.resumeToken,n)),i=i.insert(E,S),(function(x,b,$){return x.resumeToken.approximateByteSize()===0||b.snapshotVersion.toMicroseconds()-x.snapshotVersion.toMicroseconds()>=Dh?!0:$.addedDocuments.size+$.modifiedDocuments.size+$.removedDocuments.size>0})(R,S,p)&&c.push(e.hi.updateTargetData(o,S))}));let h=$t(),f=q();if(t.documentUpdates.forEach((p=>{t.resolvedLimboDocuments.has(p)&&c.push(e.persistence.referenceDelegate.updateLimboDocument(o,p))})),c.push(Mh(o,u,t.documentUpdates).next((p=>{h=p.Ls,f=p.ks}))),!n.isEqual(F.min())){const p=e.hi.getLastRemoteSnapshotVersion(o).next((E=>e.hi.setTargetsMetadata(o,o.currentSequenceNumber,n)));c.push(p)}return V.waitFor(c).next((()=>u.apply(o))).next((()=>e.localDocuments.getLocalViewOfDocuments(o,h,f))).next((()=>h))})).then((o=>(e.Fs=i,o)))}function Mh(r,t,e){let n=q(),i=q();return e.forEach((o=>n=n.add(o))),t.getEntries(r,n).next((o=>{let u=$t();return e.forEach(((c,h)=>{const f=o.get(c);h.isFoundDocument()!==f.isFoundDocument()&&(i=i.add(c)),h.isNoDocument()&&h.version.isEqual(F.min())?(t.removeEntry(c,h.readTime),u=u.insert(c,h)):!f.isValidDocument()||h.version.compareTo(f.version)>0||h.version.compareTo(f.version)===0&&f.hasPendingWrites?(t.addEntry(h),u=u.insert(c,h)):N(Us,"Ignoring outdated watch update for ",c,". Current version:",f.version," Watch version:",h.version)})),{Ls:u,ks:i}}))}function Fh(r,t){const e=L(r);return e.persistence.runTransaction("Get next mutation batch","readonly",(n=>(t===void 0&&(t=Ps),e.mutationQueue.getNextMutationBatchAfterBatchId(n,t))))}function Lh(r,t){const e=L(r);return e.persistence.runTransaction("Allocate target","readwrite",(n=>{let i;return e.hi.getTargetData(n,t).next((o=>o?(i=o,V.resolve(i)):e.hi.allocateTargetId(n).next((u=>(i=new Ht(t,u,"TargetPurposeListen",n.currentSequenceNumber),e.hi.addTargetData(n,i).next((()=>i)))))))})).then((n=>{const i=e.Fs.get(n.targetId);return(i===null||n.snapshotVersion.compareTo(i.snapshotVersion)>0)&&(e.Fs=e.Fs.insert(n.targetId,n),e.Ms.set(t,n.targetId)),n}))}async function gs(r,t,e){const n=L(r),i=n.Fs.get(t),o=e?"readwrite":"readwrite-primary";try{e||await n.persistence.runTransaction("Release target",o,(u=>n.persistence.referenceDelegate.removeTarget(u,i)))}catch(u){if(!Oe(u))throw u;N(Us,`Failed to update sequence numbers for target ${t}: ${u}`)}n.Fs=n.Fs.remove(t),n.Ms.delete(i.target)}function qo(r,t,e){const n=L(r);let i=F.min(),o=q();return n.persistence.runTransaction("Execute query","readwrite",(u=>(function(h,f,p){const E=L(h),R=E.Ms.get(p);return R!==void 0?V.resolve(E.Fs.get(R)):E.hi.getTargetData(f,p)})(n,u,Ct(t)).next((c=>{if(c)return i=c.lastLimboFreeSnapshotVersion,n.hi.getMatchingKeysForTargetId(u,c.targetId).next((h=>{o=h}))})).next((()=>n.Cs.getDocumentsMatchingQuery(u,t,e?i:F.min(),e?o:q()))).next((c=>(Uh(n,Pc(t),c),{documents:c,qs:o})))))}function Uh(r,t,e){let n=r.xs.get(t)||F.min();e.forEach(((i,o)=>{o.readTime.compareTo(n)>0&&(n=o.readTime)})),r.xs.set(t,n)}class jo{constructor(){this.activeTargetIds=Nc()}Gs(t){this.activeTargetIds=this.activeTargetIds.add(t)}zs(t){this.activeTargetIds=this.activeTargetIds.delete(t)}Ws(){const t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)}}class qh{constructor(){this.Fo=new jo,this.Mo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(t){}updateMutationState(t,e,n){}addLocalQueryTarget(t,e=!0){return e&&this.Fo.Gs(t),this.Mo[t]||"not-current"}updateQueryState(t,e,n){this.Mo[t]=e}removeLocalQueryTarget(t){this.Fo.zs(t)}isLocalQueryTarget(t){return this.Fo.activeTargetIds.has(t)}clearQueryState(t){delete this.Mo[t]}getAllActiveQueryTargets(){return this.Fo.activeTargetIds}isActiveQueryTarget(t){return this.Fo.activeTargetIds.has(t)}start(){return this.Fo=new jo,Promise.resolve()}handleUserChange(t,e,n){}setOnlineState(t){}shutdown(){}writeSequenceNumber(t){}notifyBundleLoaded(t){}}/**
1143
+ * @license
1144
+ * Copyright 2019 Google LLC
1145
+ *
1146
+ * Licensed under the Apache License, Version 2.0 (the "License");
1147
+ * you may not use this file except in compliance with the License.
1148
+ * You may obtain a copy of the License at
1149
+ *
1150
+ * http://www.apache.org/licenses/LICENSE-2.0
1151
+ *
1152
+ * Unless required by applicable law or agreed to in writing, software
1153
+ * distributed under the License is distributed on an "AS IS" BASIS,
1154
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1155
+ * See the License for the specific language governing permissions and
1156
+ * limitations under the License.
1157
+ */class jh{xo(t){}shutdown(){}}/**
1158
+ * @license
1159
+ * Copyright 2019 Google LLC
1160
+ *
1161
+ * Licensed under the Apache License, Version 2.0 (the "License");
1162
+ * you may not use this file except in compliance with the License.
1163
+ * You may obtain a copy of the License at
1164
+ *
1165
+ * http://www.apache.org/licenses/LICENSE-2.0
1166
+ *
1167
+ * Unless required by applicable law or agreed to in writing, software
1168
+ * distributed under the License is distributed on an "AS IS" BASIS,
1169
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1170
+ * See the License for the specific language governing permissions and
1171
+ * limitations under the License.
1172
+ */const Bo="ConnectivityMonitor";class zo{constructor(){this.Oo=()=>this.No(),this.Bo=()=>this.Lo(),this.ko=[],this.qo()}xo(t){this.ko.push(t)}shutdown(){window.removeEventListener("online",this.Oo),window.removeEventListener("offline",this.Bo)}qo(){window.addEventListener("online",this.Oo),window.addEventListener("offline",this.Bo)}No(){N(Bo,"Network connectivity changed: AVAILABLE");for(const t of this.ko)t(0)}Lo(){N(Bo,"Network connectivity changed: UNAVAILABLE");for(const t of this.ko)t(1)}static C(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/**
1173
+ * @license
1174
+ * Copyright 2023 Google LLC
1175
+ *
1176
+ * Licensed under the Apache License, Version 2.0 (the "License");
1177
+ * you may not use this file except in compliance with the License.
1178
+ * You may obtain a copy of the License at
1179
+ *
1180
+ * http://www.apache.org/licenses/LICENSE-2.0
1181
+ *
1182
+ * Unless required by applicable law or agreed to in writing, software
1183
+ * distributed under the License is distributed on an "AS IS" BASIS,
1184
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1185
+ * See the License for the specific language governing permissions and
1186
+ * limitations under the License.
1187
+ */let Hn=null;function _s(){return Hn===null?Hn=(function(){return 268435456+Math.round(2147483648*Math.random())})():Hn++,"0x"+Hn.toString(16)}/**
1188
+ * @license
1189
+ * Copyright 2020 Google LLC
1190
+ *
1191
+ * Licensed under the Apache License, Version 2.0 (the "License");
1192
+ * you may not use this file except in compliance with the License.
1193
+ * You may obtain a copy of the License at
1194
+ *
1195
+ * http://www.apache.org/licenses/LICENSE-2.0
1196
+ *
1197
+ * Unless required by applicable law or agreed to in writing, software
1198
+ * distributed under the License is distributed on an "AS IS" BASIS,
1199
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1200
+ * See the License for the specific language governing permissions and
1201
+ * limitations under the License.
1202
+ */const es="RestConnection",Bh={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};class zh{get Qo(){return!1}constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const e=t.ssl?"https":"http",n=encodeURIComponent(this.databaseId.projectId),i=encodeURIComponent(this.databaseId.database);this.$o=e+"://"+t.host,this.Uo=`projects/${n}/databases/${i}`,this.Ko=this.databaseId.database===fn?`project_id=${n}`:`project_id=${n}&database_id=${i}`}Wo(t,e,n,i,o){const u=_s(),c=this.Go(t,e.toUriEncodedString());N(es,`Sending RPC '${t}' ${u}:`,c,n);const h={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.Ko};this.zo(h,i,o);const{host:f}=new URL(c),p=Is(f);return this.jo(t,c,h,n,p).then((E=>(N(es,`Received RPC '${t}' ${u}: `,E),E)),(E=>{throw Jt(es,`RPC '${t}' ${u} failed with error: `,E,"url: ",c,"request:",n),E}))}Jo(t,e,n,i,o,u){return this.Wo(t,e,n,i,o)}zo(t,e,n){t["X-Goog-Api-Client"]=(function(){return"gl-js/ fire/"+ke})(),t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),e&&e.headers.forEach(((i,o)=>t[o]=i)),n&&n.headers.forEach(((i,o)=>t[o]=i))}Go(t,e){const n=Bh[t];return`${this.$o}/v1/${e}:${n}`}terminate(){}}/**
1203
+ * @license
1204
+ * Copyright 2017 Google LLC
1205
+ *
1206
+ * Licensed under the Apache License, Version 2.0 (the "License");
1207
+ * you may not use this file except in compliance with the License.
1208
+ * You may obtain a copy of the License at
1209
+ *
1210
+ * http://www.apache.org/licenses/LICENSE-2.0
1211
+ *
1212
+ * Unless required by applicable law or agreed to in writing, software
1213
+ * distributed under the License is distributed on an "AS IS" BASIS,
1214
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1215
+ * See the License for the specific language governing permissions and
1216
+ * limitations under the License.
1217
+ */class $h{constructor(t){this.Ho=t.Ho,this.Yo=t.Yo}Zo(t){this.Xo=t}e_(t){this.t_=t}n_(t){this.r_=t}onMessage(t){this.i_=t}close(){this.Yo()}send(t){this.Ho(t)}s_(){this.Xo()}o_(){this.t_()}__(t){this.r_(t)}a_(t){this.i_(t)}}/**
1218
+ * @license
1219
+ * Copyright 2017 Google LLC
1220
+ *
1221
+ * Licensed under the Apache License, Version 2.0 (the "License");
1222
+ * you may not use this file except in compliance with the License.
1223
+ * You may obtain a copy of the License at
1224
+ *
1225
+ * http://www.apache.org/licenses/LICENSE-2.0
1226
+ *
1227
+ * Unless required by applicable law or agreed to in writing, software
1228
+ * distributed under the License is distributed on an "AS IS" BASIS,
1229
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1230
+ * See the License for the specific language governing permissions and
1231
+ * limitations under the License.
1232
+ */const gt="WebChannelConnection";class Gh extends zh{constructor(t){super(t),this.u_=[],this.forceLongPolling=t.forceLongPolling,this.autoDetectLongPolling=t.autoDetectLongPolling,this.useFetchStreams=t.useFetchStreams,this.longPollingOptions=t.longPollingOptions}jo(t,e,n,i,o){const u=_s();return new Promise(((c,h)=>{const f=new da;f.setWithCredentials(!0),f.listenOnce(fa.COMPLETE,(()=>{try{switch(f.getLastErrorCode()){case Xn.NO_ERROR:const E=f.getResponseJson();N(gt,`XHR for RPC '${t}' ${u} received:`,JSON.stringify(E)),c(E);break;case Xn.TIMEOUT:N(gt,`RPC '${t}' ${u} timed out`),h(new k(P.DEADLINE_EXCEEDED,"Request time out"));break;case Xn.HTTP_ERROR:const R=f.getStatus();if(N(gt,`RPC '${t}' ${u} failed with status:`,R,"response text:",f.getResponseText()),R>0){let S=f.getResponseJson();Array.isArray(S)&&(S=S[0]);const D=S==null?void 0:S.error;if(D&&D.status&&D.message){const x=(function($){const B=$.toLowerCase().replace(/_/g,"-");return Object.values(P).indexOf(B)>=0?B:P.UNKNOWN})(D.status);h(new k(x,D.message))}else h(new k(P.UNKNOWN,"Server responded with status "+f.getStatus()))}else h(new k(P.UNAVAILABLE,"Connection failed."));break;default:M(9055,{c_:t,streamId:u,l_:f.getLastErrorCode(),h_:f.getLastError()})}}finally{N(gt,`RPC '${t}' ${u} completed.`)}}));const p=JSON.stringify(i);N(gt,`RPC '${t}' ${u} sending request:`,i),f.send(e,"POST",p,n,15)}))}P_(t,e,n){const i=_s(),o=[this.$o,"/","google.firestore.v1.Firestore","/",t,"/channel"],u=ga(),c=pa(),h={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},f=this.longPollingOptions.timeoutSeconds;f!==void 0&&(h.longPollingTimeout=Math.round(1e3*f)),this.useFetchStreams&&(h.useFetchStreams=!0),this.zo(h.initMessageHeaders,e,n),h.encodeInitMessageHeaders=!0;const p=o.join("");N(gt,`Creating RPC '${t}' stream ${i}: ${p}`,h);const E=u.createWebChannel(p,h);this.T_(E);let R=!1,S=!1;const D=new $h({Ho:b=>{S?N(gt,`Not sending because RPC '${t}' stream ${i} is closed:`,b):(R||(N(gt,`Opening RPC '${t}' stream ${i} transport.`),E.open(),R=!0),N(gt,`RPC '${t}' stream ${i} sending:`,b),E.send(b))},Yo:()=>E.close()}),x=(b,$,B)=>{b.listen($,(K=>{try{B(K)}catch(it){setTimeout((()=>{throw it}),0)}}))};return x(E,en.EventType.OPEN,(()=>{S||(N(gt,`RPC '${t}' stream ${i} transport opened.`),D.s_())})),x(E,en.EventType.CLOSE,(()=>{S||(S=!0,N(gt,`RPC '${t}' stream ${i} transport closed`),D.__(),this.I_(E))})),x(E,en.EventType.ERROR,(b=>{S||(S=!0,Jt(gt,`RPC '${t}' stream ${i} transport errored. Name:`,b.name,"Message:",b.message),D.__(new k(P.UNAVAILABLE,"The operation could not be completed")))})),x(E,en.EventType.MESSAGE,(b=>{var $;if(!S){const B=b.data[0];G(!!B,16349);const K=B,it=(K==null?void 0:K.error)||(($=K[0])===null||$===void 0?void 0:$.error);if(it){N(gt,`RPC '${t}' stream ${i} received error:`,it);const Mt=it.status;let at=(function(_){const y=tt[_];if(y!==void 0)return Xa(y)})(Mt),v=it.message;at===void 0&&(at=P.INTERNAL,v="Unknown error status: "+Mt+" with message "+it.message),S=!0,D.__(new k(at,v)),E.close()}else N(gt,`RPC '${t}' stream ${i} received:`,B),D.a_(B)}})),x(c,ma.STAT_EVENT,(b=>{b.stat===is.PROXY?N(gt,`RPC '${t}' stream ${i} detected buffering proxy`):b.stat===is.NOPROXY&&N(gt,`RPC '${t}' stream ${i} detected no buffering proxy`)})),setTimeout((()=>{D.o_()}),0),D}terminate(){this.u_.forEach((t=>t.close())),this.u_=[]}T_(t){this.u_.push(t)}I_(t){this.u_=this.u_.filter((e=>e===t))}}function ns(){return typeof document<"u"?document:null}/**
1233
+ * @license
1234
+ * Copyright 2020 Google LLC
1235
+ *
1236
+ * Licensed under the Apache License, Version 2.0 (the "License");
1237
+ * you may not use this file except in compliance with the License.
1238
+ * You may obtain a copy of the License at
1239
+ *
1240
+ * http://www.apache.org/licenses/LICENSE-2.0
1241
+ *
1242
+ * Unless required by applicable law or agreed to in writing, software
1243
+ * distributed under the License is distributed on an "AS IS" BASIS,
1244
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1245
+ * See the License for the specific language governing permissions and
1246
+ * limitations under the License.
1247
+ */function wr(r){return new Xc(r,!0)}/**
1248
+ * @license
1249
+ * Copyright 2017 Google LLC
1250
+ *
1251
+ * Licensed under the Apache License, Version 2.0 (the "License");
1252
+ * you may not use this file except in compliance with the License.
1253
+ * You may obtain a copy of the License at
1254
+ *
1255
+ * http://www.apache.org/licenses/LICENSE-2.0
1256
+ *
1257
+ * Unless required by applicable law or agreed to in writing, software
1258
+ * distributed under the License is distributed on an "AS IS" BASIS,
1259
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1260
+ * See the License for the specific language governing permissions and
1261
+ * limitations under the License.
1262
+ */class hu{constructor(t,e,n=1e3,i=1.5,o=6e4){this.Fi=t,this.timerId=e,this.d_=n,this.E_=i,this.A_=o,this.R_=0,this.V_=null,this.m_=Date.now(),this.reset()}reset(){this.R_=0}f_(){this.R_=this.A_}g_(t){this.cancel();const e=Math.floor(this.R_+this.p_()),n=Math.max(0,Date.now()-this.m_),i=Math.max(0,e-n);i>0&&N("ExponentialBackoff",`Backing off for ${i} ms (base delay: ${this.R_} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),this.V_=this.Fi.enqueueAfterDelay(this.timerId,i,(()=>(this.m_=Date.now(),t()))),this.R_*=this.E_,this.R_<this.d_&&(this.R_=this.d_),this.R_>this.A_&&(this.R_=this.A_)}y_(){this.V_!==null&&(this.V_.skipDelay(),this.V_=null)}cancel(){this.V_!==null&&(this.V_.cancel(),this.V_=null)}p_(){return(Math.random()-.5)*this.R_}}/**
1263
+ * @license
1264
+ * Copyright 2017 Google LLC
1265
+ *
1266
+ * Licensed under the Apache License, Version 2.0 (the "License");
1267
+ * you may not use this file except in compliance with the License.
1268
+ * You may obtain a copy of the License at
1269
+ *
1270
+ * http://www.apache.org/licenses/LICENSE-2.0
1271
+ *
1272
+ * Unless required by applicable law or agreed to in writing, software
1273
+ * distributed under the License is distributed on an "AS IS" BASIS,
1274
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1275
+ * See the License for the specific language governing permissions and
1276
+ * limitations under the License.
1277
+ */const $o="PersistentStream";class du{constructor(t,e,n,i,o,u,c,h){this.Fi=t,this.w_=n,this.S_=i,this.connection=o,this.authCredentialsProvider=u,this.appCheckCredentialsProvider=c,this.listener=h,this.state=0,this.b_=0,this.D_=null,this.v_=null,this.stream=null,this.C_=0,this.F_=new hu(t,e)}M_(){return this.state===1||this.state===5||this.x_()}x_(){return this.state===2||this.state===3}start(){this.C_=0,this.state!==4?this.auth():this.O_()}async stop(){this.M_()&&await this.close(0)}N_(){this.state=0,this.F_.reset()}B_(){this.x_()&&this.D_===null&&(this.D_=this.Fi.enqueueAfterDelay(this.w_,6e4,(()=>this.L_())))}k_(t){this.q_(),this.stream.send(t)}async L_(){if(this.x_())return this.close(0)}q_(){this.D_&&(this.D_.cancel(),this.D_=null)}Q_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(t,e){this.q_(),this.Q_(),this.F_.cancel(),this.b_++,t!==4?this.F_.reset():e&&e.code===P.RESOURCE_EXHAUSTED?(zt(e.toString()),zt("Using maximum backoff delay to prevent overloading the backend."),this.F_.f_()):e&&e.code===P.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.U_(),this.stream.close(),this.stream=null),this.state=t,await this.listener.n_(e)}U_(){}auth(){this.state=1;const t=this.K_(this.b_),e=this.b_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([n,i])=>{this.b_===e&&this.W_(n,i)}),(n=>{t((()=>{const i=new k(P.UNKNOWN,"Fetching auth token failed: "+n.message);return this.G_(i)}))}))}W_(t,e){const n=this.K_(this.b_);this.stream=this.z_(t,e),this.stream.Zo((()=>{n((()=>this.listener.Zo()))})),this.stream.e_((()=>{n((()=>(this.state=2,this.v_=this.Fi.enqueueAfterDelay(this.S_,1e4,(()=>(this.x_()&&(this.state=3),Promise.resolve()))),this.listener.e_())))})),this.stream.n_((i=>{n((()=>this.G_(i)))})),this.stream.onMessage((i=>{n((()=>++this.C_==1?this.j_(i):this.onNext(i)))}))}O_(){this.state=5,this.F_.g_((async()=>{this.state=0,this.start()}))}G_(t){return N($o,`close with error: ${t}`),this.stream=null,this.close(4,t)}K_(t){return e=>{this.Fi.enqueueAndForget((()=>this.b_===t?e():(N($o,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class Kh extends du{constructor(t,e,n,i,o,u){super(t,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",e,n,i,u),this.serializer=o}z_(t,e){return this.connection.P_("Listen",t,e)}j_(t){return this.onNext(t)}onNext(t){this.F_.reset();const e=Zc(this.serializer,t),n=(function(o){if(!("targetChange"in o))return F.min();const u=o.targetChange;return u.targetIds&&u.targetIds.length?F.min():u.readTime?bt(u.readTime):F.min()})(t);return this.listener.J_(e,n)}H_(t){const e={};e.database=ps(this.serializer),e.addTarget=(function(o,u){let c;const h=u.target;if(c=cs(h)?{documents:nh(o,h)}:{query:rh(o,h).Vt},c.targetId=u.targetId,u.resumeToken.approximateByteSize()>0){c.resumeToken=Za(o,u.resumeToken);const f=ds(o,u.expectedCount);f!==null&&(c.expectedCount=f)}else if(u.snapshotVersion.compareTo(F.min())>0){c.readTime=ur(o,u.snapshotVersion.toTimestamp());const f=ds(o,u.expectedCount);f!==null&&(c.expectedCount=f)}return c})(this.serializer,t);const n=ih(this.serializer,t);n&&(e.labels=n),this.k_(e)}Y_(t){const e={};e.database=ps(this.serializer),e.removeTarget=t,this.k_(e)}}class Qh extends du{constructor(t,e,n,i,o,u){super(t,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",e,n,i,u),this.serializer=o}get Z_(){return this.C_>0}start(){this.lastStreamToken=void 0,super.start()}U_(){this.Z_&&this.X_([])}z_(t,e){return this.connection.P_("Write",t,e)}j_(t){return G(!!t.streamToken,31322),this.lastStreamToken=t.streamToken,G(!t.writeResults||t.writeResults.length===0,55816),this.listener.ea()}onNext(t){G(!!t.streamToken,12678),this.lastStreamToken=t.streamToken,this.F_.reset();const e=eh(t.writeResults,t.commitTime),n=bt(t.commitTime);return this.listener.ta(n,e)}na(){const t={};t.database=ps(this.serializer),this.k_(t)}X_(t){const e={streamToken:this.lastStreamToken,writes:t.map((n=>th(this.serializer,n)))};this.k_(e)}}/**
1278
+ * @license
1279
+ * Copyright 2017 Google LLC
1280
+ *
1281
+ * Licensed under the Apache License, Version 2.0 (the "License");
1282
+ * you may not use this file except in compliance with the License.
1283
+ * You may obtain a copy of the License at
1284
+ *
1285
+ * http://www.apache.org/licenses/LICENSE-2.0
1286
+ *
1287
+ * Unless required by applicable law or agreed to in writing, software
1288
+ * distributed under the License is distributed on an "AS IS" BASIS,
1289
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1290
+ * See the License for the specific language governing permissions and
1291
+ * limitations under the License.
1292
+ */class Wh{}class Hh extends Wh{constructor(t,e,n,i){super(),this.authCredentials=t,this.appCheckCredentials=e,this.connection=n,this.serializer=i,this.ra=!1}ia(){if(this.ra)throw new k(P.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(t,e,n,i){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([o,u])=>this.connection.Wo(t,fs(e,n),i,o,u))).catch((o=>{throw o.name==="FirebaseError"?(o.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),o):new k(P.UNKNOWN,o.toString())}))}Jo(t,e,n,i,o){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([u,c])=>this.connection.Jo(t,fs(e,n),i,u,c,o))).catch((u=>{throw u.name==="FirebaseError"?(u.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),u):new k(P.UNKNOWN,u.toString())}))}terminate(){this.ra=!0,this.connection.terminate()}}class Xh{constructor(t,e){this.asyncQueue=t,this.onlineStateHandler=e,this.state="Unknown",this.sa=0,this.oa=null,this._a=!0}aa(){this.sa===0&&(this.ua("Unknown"),this.oa=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this.oa=null,this.ca("Backend didn't respond within 10 seconds."),this.ua("Offline"),Promise.resolve()))))}la(t){this.state==="Online"?this.ua("Unknown"):(this.sa++,this.sa>=1&&(this.ha(),this.ca(`Connection failed 1 times. Most recent error: ${t.toString()}`),this.ua("Offline")))}set(t){this.ha(),this.sa=0,t==="Online"&&(this._a=!1),this.ua(t)}ua(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))}ca(t){const e=`Could not reach Cloud Firestore backend. ${t}
1293
+ This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this._a?(zt(e),this._a=!1):N("OnlineStateTracker",e)}ha(){this.oa!==null&&(this.oa.cancel(),this.oa=null)}}/**
1294
+ * @license
1295
+ * Copyright 2017 Google LLC
1296
+ *
1297
+ * Licensed under the Apache License, Version 2.0 (the "License");
1298
+ * you may not use this file except in compliance with the License.
1299
+ * You may obtain a copy of the License at
1300
+ *
1301
+ * http://www.apache.org/licenses/LICENSE-2.0
1302
+ *
1303
+ * Unless required by applicable law or agreed to in writing, software
1304
+ * distributed under the License is distributed on an "AS IS" BASIS,
1305
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1306
+ * See the License for the specific language governing permissions and
1307
+ * limitations under the License.
1308
+ */const pe="RemoteStore";class Yh{constructor(t,e,n,i,o){this.localStore=t,this.datastore=e,this.asyncQueue=n,this.remoteSyncer={},this.Pa=[],this.Ta=new Map,this.Ia=new Set,this.da=[],this.Ea=o,this.Ea.xo((u=>{n.enqueueAndForget((async()=>{_e(this)&&(N(pe,"Restarting streams for network reachability change."),await(async function(h){const f=L(h);f.Ia.add(4),await vn(f),f.Aa.set("Unknown"),f.Ia.delete(4),await Rr(f)})(this))}))})),this.Aa=new Xh(n,i)}}async function Rr(r){if(_e(r))for(const t of r.da)await t(!0)}async function vn(r){for(const t of r.da)await t(!1)}function fu(r,t){const e=L(r);e.Ta.has(t.targetId)||(e.Ta.set(t.targetId,t),zs(e)?Bs(e):Me(e).x_()&&js(e,t))}function qs(r,t){const e=L(r),n=Me(e);e.Ta.delete(t),n.x_()&&mu(e,t),e.Ta.size===0&&(n.x_()?n.B_():_e(e)&&e.Aa.set("Unknown"))}function js(r,t){if(r.Ra.$e(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(F.min())>0){const e=r.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(e)}Me(r).H_(t)}function mu(r,t){r.Ra.$e(t),Me(r).Y_(t)}function Bs(r){r.Ra=new Kc({getRemoteKeysForTarget:t=>r.remoteSyncer.getRemoteKeysForTarget(t),Et:t=>r.Ta.get(t)||null,lt:()=>r.datastore.serializer.databaseId}),Me(r).start(),r.Aa.aa()}function zs(r){return _e(r)&&!Me(r).M_()&&r.Ta.size>0}function _e(r){return L(r).Ia.size===0}function pu(r){r.Ra=void 0}async function Jh(r){r.Aa.set("Online")}async function Zh(r){r.Ta.forEach(((t,e)=>{js(r,t)}))}async function td(r,t){pu(r),zs(r)?(r.Aa.la(t),Bs(r)):r.Aa.set("Unknown")}async function ed(r,t,e){if(r.Aa.set("Online"),t instanceof Ja&&t.state===2&&t.cause)try{await(async function(i,o){const u=o.cause;for(const c of o.targetIds)i.Ta.has(c)&&(await i.remoteSyncer.rejectListen(c,u),i.Ta.delete(c),i.Ra.removeTarget(c))})(r,t)}catch(n){N(pe,"Failed to remove targets %s: %s ",t.targetIds.join(","),n),await cr(r,n)}else if(t instanceof tr?r.Ra.Ye(t):t instanceof Ya?r.Ra.it(t):r.Ra.et(t),!e.isEqual(F.min()))try{const n=await cu(r.localStore);e.compareTo(n)>=0&&await(function(o,u){const c=o.Ra.Pt(u);return c.targetChanges.forEach(((h,f)=>{if(h.resumeToken.approximateByteSize()>0){const p=o.Ta.get(f);p&&o.Ta.set(f,p.withResumeToken(h.resumeToken,u))}})),c.targetMismatches.forEach(((h,f)=>{const p=o.Ta.get(h);if(!p)return;o.Ta.set(h,p.withResumeToken(ht.EMPTY_BYTE_STRING,p.snapshotVersion)),mu(o,h);const E=new Ht(p.target,h,f,p.sequenceNumber);js(o,E)})),o.remoteSyncer.applyRemoteEvent(c)})(r,e)}catch(n){N(pe,"Failed to raise snapshot:",n),await cr(r,n)}}async function cr(r,t,e){if(!Oe(t))throw t;r.Ia.add(1),await vn(r),r.Aa.set("Offline"),e||(e=()=>cu(r.localStore)),r.asyncQueue.enqueueRetryable((async()=>{N(pe,"Retrying IndexedDB access"),await e(),r.Ia.delete(1),await Rr(r)}))}function gu(r,t){return t().catch((e=>cr(r,e,t)))}async function Pr(r){const t=L(r),e=re(t);let n=t.Pa.length>0?t.Pa[t.Pa.length-1].batchId:Ps;for(;nd(t);)try{const i=await Fh(t.localStore,n);if(i===null){t.Pa.length===0&&e.B_();break}n=i.batchId,rd(t,i)}catch(i){await cr(t,i)}_u(t)&&yu(t)}function nd(r){return _e(r)&&r.Pa.length<10}function rd(r,t){r.Pa.push(t);const e=re(r);e.x_()&&e.Z_&&e.X_(t.mutations)}function _u(r){return _e(r)&&!re(r).M_()&&r.Pa.length>0}function yu(r){re(r).start()}async function sd(r){re(r).na()}async function id(r){const t=re(r);for(const e of r.Pa)t.X_(e.mutations)}async function od(r,t,e){const n=r.Pa.shift(),i=ks.from(n,t,e);await gu(r,(()=>r.remoteSyncer.applySuccessfulWrite(i))),await Pr(r)}async function ad(r,t){t&&re(r).Z_&&await(async function(n,i){if((function(u){return $c(u)&&u!==P.ABORTED})(i.code)){const o=n.Pa.shift();re(n).N_(),await gu(n,(()=>n.remoteSyncer.rejectFailedWrite(o.batchId,i))),await Pr(n)}})(r,t),_u(r)&&yu(r)}async function Go(r,t){const e=L(r);e.asyncQueue.verifyOperationInProgress(),N(pe,"RemoteStore received new credentials");const n=_e(e);e.Ia.add(3),await vn(e),n&&e.Aa.set("Unknown"),await e.remoteSyncer.handleCredentialChange(t),e.Ia.delete(3),await Rr(e)}async function ud(r,t){const e=L(r);t?(e.Ia.delete(2),await Rr(e)):t||(e.Ia.add(2),await vn(e),e.Aa.set("Unknown"))}function Me(r){return r.Va||(r.Va=(function(e,n,i){const o=L(e);return o.ia(),new Kh(n,o.connection,o.authCredentials,o.appCheckCredentials,o.serializer,i)})(r.datastore,r.asyncQueue,{Zo:Jh.bind(null,r),e_:Zh.bind(null,r),n_:td.bind(null,r),J_:ed.bind(null,r)}),r.da.push((async t=>{t?(r.Va.N_(),zs(r)?Bs(r):r.Aa.set("Unknown")):(await r.Va.stop(),pu(r))}))),r.Va}function re(r){return r.ma||(r.ma=(function(e,n,i){const o=L(e);return o.ia(),new Qh(n,o.connection,o.authCredentials,o.appCheckCredentials,o.serializer,i)})(r.datastore,r.asyncQueue,{Zo:()=>Promise.resolve(),e_:sd.bind(null,r),n_:ad.bind(null,r),ea:id.bind(null,r),ta:od.bind(null,r)}),r.da.push((async t=>{t?(r.ma.N_(),await Pr(r)):(await r.ma.stop(),r.Pa.length>0&&(N(pe,`Stopping write stream with ${r.Pa.length} pending writes`),r.Pa=[]))}))),r.ma}/**
1309
+ * @license
1310
+ * Copyright 2017 Google LLC
1311
+ *
1312
+ * Licensed under the Apache License, Version 2.0 (the "License");
1313
+ * you may not use this file except in compliance with the License.
1314
+ * You may obtain a copy of the License at
1315
+ *
1316
+ * http://www.apache.org/licenses/LICENSE-2.0
1317
+ *
1318
+ * Unless required by applicable law or agreed to in writing, software
1319
+ * distributed under the License is distributed on an "AS IS" BASIS,
1320
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1321
+ * See the License for the specific language governing permissions and
1322
+ * limitations under the License.
1323
+ */class $s{constructor(t,e,n,i,o){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=i,this.removalCallback=o,this.deferred=new jt,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((u=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(t,e,n,i,o){const u=Date.now()+n,c=new $s(t,e,u,i,o);return c.start(n),c}start(t){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),t)}skipDelay(){return this.handleDelayElapsed()}cancel(t){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new k(P.CANCELLED,"Operation cancelled"+(t?": "+t:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then((t=>this.deferred.resolve(t)))):Promise.resolve()))}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function Gs(r,t){if(zt("AsyncQueue",`${t}: ${r}`),Oe(r))return new k(P.UNAVAILABLE,`${t}: ${r}`);throw r}/**
1324
+ * @license
1325
+ * Copyright 2017 Google LLC
1326
+ *
1327
+ * Licensed under the Apache License, Version 2.0 (the "License");
1328
+ * you may not use this file except in compliance with the License.
1329
+ * You may obtain a copy of the License at
1330
+ *
1331
+ * http://www.apache.org/licenses/LICENSE-2.0
1332
+ *
1333
+ * Unless required by applicable law or agreed to in writing, software
1334
+ * distributed under the License is distributed on an "AS IS" BASIS,
1335
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1336
+ * See the License for the specific language governing permissions and
1337
+ * limitations under the License.
1338
+ */class Pe{static emptySet(t){return new Pe(t.comparator)}constructor(t){this.comparator=t?(e,n)=>t(e,n)||O.comparator(e.key,n.key):(e,n)=>O.comparator(e.key,n.key),this.keyedMap=nn(),this.sortedSet=new Y(this.comparator)}has(t){return this.keyedMap.get(t)!=null}get(t){return this.keyedMap.get(t)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(t){const e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1}get size(){return this.sortedSet.size}forEach(t){this.sortedSet.inorderTraversal(((e,n)=>(t(e),!1)))}add(t){const e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))}delete(t){const e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this}isEqual(t){if(!(t instanceof Pe)||this.size!==t.size)return!1;const e=this.sortedSet.getIterator(),n=t.sortedSet.getIterator();for(;e.hasNext();){const i=e.getNext().key,o=n.getNext().key;if(!i.isEqual(o))return!1}return!0}toString(){const t=[];return this.forEach((e=>{t.push(e.toString())})),t.length===0?"DocumentSet ()":`DocumentSet (
1339
+ `+t.join(`
1340
+ `)+`
1341
+ )`}copy(t,e){const n=new Pe;return n.comparator=this.comparator,n.keyedMap=t,n.sortedSet=e,n}}/**
1342
+ * @license
1343
+ * Copyright 2017 Google LLC
1344
+ *
1345
+ * Licensed under the Apache License, Version 2.0 (the "License");
1346
+ * you may not use this file except in compliance with the License.
1347
+ * You may obtain a copy of the License at
1348
+ *
1349
+ * http://www.apache.org/licenses/LICENSE-2.0
1350
+ *
1351
+ * Unless required by applicable law or agreed to in writing, software
1352
+ * distributed under the License is distributed on an "AS IS" BASIS,
1353
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1354
+ * See the License for the specific language governing permissions and
1355
+ * limitations under the License.
1356
+ */class Ko{constructor(){this.fa=new Y(O.comparator)}track(t){const e=t.doc.key,n=this.fa.get(e);n?t.type!==0&&n.type===3?this.fa=this.fa.insert(e,t):t.type===3&&n.type!==1?this.fa=this.fa.insert(e,{type:n.type,doc:t.doc}):t.type===2&&n.type===2?this.fa=this.fa.insert(e,{type:2,doc:t.doc}):t.type===2&&n.type===0?this.fa=this.fa.insert(e,{type:0,doc:t.doc}):t.type===1&&n.type===0?this.fa=this.fa.remove(e):t.type===1&&n.type===2?this.fa=this.fa.insert(e,{type:1,doc:n.doc}):t.type===0&&n.type===1?this.fa=this.fa.insert(e,{type:2,doc:t.doc}):M(63341,{At:t,ga:n}):this.fa=this.fa.insert(e,t)}pa(){const t=[];return this.fa.inorderTraversal(((e,n)=>{t.push(n)})),t}}class De{constructor(t,e,n,i,o,u,c,h,f){this.query=t,this.docs=e,this.oldDocs=n,this.docChanges=i,this.mutatedKeys=o,this.fromCache=u,this.syncStateChanged=c,this.excludesMetadataChanges=h,this.hasCachedResults=f}static fromInitialDocuments(t,e,n,i,o){const u=[];return e.forEach((c=>{u.push({type:0,doc:c})})),new De(t,e,Pe.emptySet(e),u,n,i,!0,!1,o)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(t){if(!(this.fromCache===t.fromCache&&this.hasCachedResults===t.hasCachedResults&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&Er(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;const e=this.docChanges,n=t.docChanges;if(e.length!==n.length)return!1;for(let i=0;i<e.length;i++)if(e[i].type!==n[i].type||!e[i].doc.isEqual(n[i].doc))return!1;return!0}}/**
1357
+ * @license
1358
+ * Copyright 2017 Google LLC
1359
+ *
1360
+ * Licensed under the Apache License, Version 2.0 (the "License");
1361
+ * you may not use this file except in compliance with the License.
1362
+ * You may obtain a copy of the License at
1363
+ *
1364
+ * http://www.apache.org/licenses/LICENSE-2.0
1365
+ *
1366
+ * Unless required by applicable law or agreed to in writing, software
1367
+ * distributed under the License is distributed on an "AS IS" BASIS,
1368
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1369
+ * See the License for the specific language governing permissions and
1370
+ * limitations under the License.
1371
+ */class ld{constructor(){this.ya=void 0,this.wa=[]}Sa(){return this.wa.some((t=>t.ba()))}}class cd{constructor(){this.queries=Qo(),this.onlineState="Unknown",this.Da=new Set}terminate(){(function(e,n){const i=L(e),o=i.queries;i.queries=Qo(),o.forEach(((u,c)=>{for(const h of c.wa)h.onError(n)}))})(this,new k(P.ABORTED,"Firestore shutting down"))}}function Qo(){return new ge((r=>La(r)),Er)}async function Ks(r,t){const e=L(r);let n=3;const i=t.query;let o=e.queries.get(i);o?!o.Sa()&&t.ba()&&(n=2):(o=new ld,n=t.ba()?0:1);try{switch(n){case 0:o.ya=await e.onListen(i,!0);break;case 1:o.ya=await e.onListen(i,!1);break;case 2:await e.onFirstRemoteStoreListen(i)}}catch(u){const c=Gs(u,`Initialization of query '${Ae(t.query)}' failed`);return void t.onError(c)}e.queries.set(i,o),o.wa.push(t),t.va(e.onlineState),o.ya&&t.Ca(o.ya)&&Ws(e)}async function Qs(r,t){const e=L(r),n=t.query;let i=3;const o=e.queries.get(n);if(o){const u=o.wa.indexOf(t);u>=0&&(o.wa.splice(u,1),o.wa.length===0?i=t.ba()?0:1:!o.Sa()&&t.ba()&&(i=2))}switch(i){case 0:return e.queries.delete(n),e.onUnlisten(n,!0);case 1:return e.queries.delete(n),e.onUnlisten(n,!1);case 2:return e.onLastRemoteStoreUnlisten(n);default:return}}function hd(r,t){const e=L(r);let n=!1;for(const i of t){const o=i.query,u=e.queries.get(o);if(u){for(const c of u.wa)c.Ca(i)&&(n=!0);u.ya=i}}n&&Ws(e)}function dd(r,t,e){const n=L(r),i=n.queries.get(t);if(i)for(const o of i.wa)o.onError(e);n.queries.delete(t)}function Ws(r){r.Da.forEach((t=>{t.next()}))}var ys,Wo;(Wo=ys||(ys={})).Fa="default",Wo.Cache="cache";class Hs{constructor(t,e,n){this.query=t,this.Ma=e,this.xa=!1,this.Oa=null,this.onlineState="Unknown",this.options=n||{}}Ca(t){if(!this.options.includeMetadataChanges){const n=[];for(const i of t.docChanges)i.type!==3&&n.push(i);t=new De(t.query,t.docs,t.oldDocs,n,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0,t.hasCachedResults)}let e=!1;return this.xa?this.Na(t)&&(this.Ma.next(t),e=!0):this.Ba(t,this.onlineState)&&(this.La(t),e=!0),this.Oa=t,e}onError(t){this.Ma.error(t)}va(t){this.onlineState=t;let e=!1;return this.Oa&&!this.xa&&this.Ba(this.Oa,t)&&(this.La(this.Oa),e=!0),e}Ba(t,e){if(!t.fromCache||!this.ba())return!0;const n=e!=="Offline";return(!this.options.ka||!n)&&(!t.docs.isEmpty()||t.hasCachedResults||e==="Offline")}Na(t){if(t.docChanges.length>0)return!0;const e=this.Oa&&this.Oa.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&this.options.includeMetadataChanges===!0}La(t){t=De.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache,t.hasCachedResults),this.xa=!0,this.Ma.next(t)}ba(){return this.options.source!==ys.Cache}}/**
1372
+ * @license
1373
+ * Copyright 2017 Google LLC
1374
+ *
1375
+ * Licensed under the Apache License, Version 2.0 (the "License");
1376
+ * you may not use this file except in compliance with the License.
1377
+ * You may obtain a copy of the License at
1378
+ *
1379
+ * http://www.apache.org/licenses/LICENSE-2.0
1380
+ *
1381
+ * Unless required by applicable law or agreed to in writing, software
1382
+ * distributed under the License is distributed on an "AS IS" BASIS,
1383
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1384
+ * See the License for the specific language governing permissions and
1385
+ * limitations under the License.
1386
+ */class Eu{constructor(t){this.key=t}}class Tu{constructor(t){this.key=t}}class fd{constructor(t,e){this.query=t,this.Ha=e,this.Ya=null,this.hasCachedResults=!1,this.current=!1,this.Za=q(),this.mutatedKeys=q(),this.Xa=Ua(t),this.eu=new Pe(this.Xa)}get tu(){return this.Ha}nu(t,e){const n=e?e.ru:new Ko,i=e?e.eu:this.eu;let o=e?e.mutatedKeys:this.mutatedKeys,u=i,c=!1;const h=this.query.limitType==="F"&&i.size===this.query.limit?i.last():null,f=this.query.limitType==="L"&&i.size===this.query.limit?i.first():null;if(t.inorderTraversal(((p,E)=>{const R=i.get(p),S=Tr(this.query,E)?E:null,D=!!R&&this.mutatedKeys.has(R.key),x=!!S&&(S.hasLocalMutations||this.mutatedKeys.has(S.key)&&S.hasCommittedMutations);let b=!1;R&&S?R.data.isEqual(S.data)?D!==x&&(n.track({type:3,doc:S}),b=!0):this.iu(R,S)||(n.track({type:2,doc:S}),b=!0,(h&&this.Xa(S,h)>0||f&&this.Xa(S,f)<0)&&(c=!0)):!R&&S?(n.track({type:0,doc:S}),b=!0):R&&!S&&(n.track({type:1,doc:R}),b=!0,(h||f)&&(c=!0)),b&&(S?(u=u.add(S),o=x?o.add(p):o.delete(p)):(u=u.delete(p),o=o.delete(p)))})),this.query.limit!==null)for(;u.size>this.query.limit;){const p=this.query.limitType==="F"?u.last():u.first();u=u.delete(p.key),o=o.delete(p.key),n.track({type:1,doc:p})}return{eu:u,ru:n,Ds:c,mutatedKeys:o}}iu(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations}applyChanges(t,e,n,i){const o=this.eu;this.eu=t.eu,this.mutatedKeys=t.mutatedKeys;const u=t.ru.pa();u.sort(((p,E)=>(function(S,D){const x=b=>{switch(b){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return M(20277,{At:b})}};return x(S)-x(D)})(p.type,E.type)||this.Xa(p.doc,E.doc))),this.su(n),i=i!=null&&i;const c=e&&!i?this.ou():[],h=this.Za.size===0&&this.current&&!i?1:0,f=h!==this.Ya;return this.Ya=h,u.length!==0||f?{snapshot:new De(this.query,t.eu,o,u,t.mutatedKeys,h===0,f,!1,!!n&&n.resumeToken.approximateByteSize()>0),_u:c}:{_u:c}}va(t){return this.current&&t==="Offline"?(this.current=!1,this.applyChanges({eu:this.eu,ru:new Ko,mutatedKeys:this.mutatedKeys,Ds:!1},!1)):{_u:[]}}au(t){return!this.Ha.has(t)&&!!this.eu.has(t)&&!this.eu.get(t).hasLocalMutations}su(t){t&&(t.addedDocuments.forEach((e=>this.Ha=this.Ha.add(e))),t.modifiedDocuments.forEach((e=>{})),t.removedDocuments.forEach((e=>this.Ha=this.Ha.delete(e))),this.current=t.current)}ou(){if(!this.current)return[];const t=this.Za;this.Za=q(),this.eu.forEach((n=>{this.au(n.key)&&(this.Za=this.Za.add(n.key))}));const e=[];return t.forEach((n=>{this.Za.has(n)||e.push(new Tu(n))})),this.Za.forEach((n=>{t.has(n)||e.push(new Eu(n))})),e}uu(t){this.Ha=t.qs,this.Za=q();const e=this.nu(t.documents);return this.applyChanges(e,!0)}cu(){return De.fromInitialDocuments(this.query,this.eu,this.mutatedKeys,this.Ya===0,this.hasCachedResults)}}const Xs="SyncEngine";class md{constructor(t,e,n){this.query=t,this.targetId=e,this.view=n}}class pd{constructor(t){this.key=t,this.lu=!1}}class gd{constructor(t,e,n,i,o,u){this.localStore=t,this.remoteStore=e,this.eventManager=n,this.sharedClientState=i,this.currentUser=o,this.maxConcurrentLimboResolutions=u,this.hu={},this.Pu=new ge((c=>La(c)),Er),this.Tu=new Map,this.Iu=new Set,this.du=new Y(O.comparator),this.Eu=new Map,this.Au=new Ms,this.Ru={},this.Vu=new Map,this.mu=be.ur(),this.onlineState="Unknown",this.fu=void 0}get isPrimaryClient(){return this.fu===!0}}async function _d(r,t,e=!0){const n=Pu(r);let i;const o=n.Pu.get(t);return o?(n.sharedClientState.addLocalQueryTarget(o.targetId),i=o.view.cu()):i=await vu(n,t,e,!0),i}async function yd(r,t){const e=Pu(r);await vu(e,t,!0,!1)}async function vu(r,t,e,n){const i=await Lh(r.localStore,Ct(t)),o=i.targetId,u=r.sharedClientState.addLocalQueryTarget(o,e);let c;return n&&(c=await Ed(r,t,o,u==="current",i.resumeToken)),r.isPrimaryClient&&e&&fu(r.remoteStore,i),c}async function Ed(r,t,e,n,i){r.gu=(E,R,S)=>(async function(x,b,$,B){let K=b.view.nu($);K.Ds&&(K=await qo(x.localStore,b.query,!1).then((({documents:v})=>b.view.nu(v,K))));const it=B&&B.targetChanges.get(b.targetId),Mt=B&&B.targetMismatches.get(b.targetId)!=null,at=b.view.applyChanges(K,x.isPrimaryClient,it,Mt);return Xo(x,b.targetId,at._u),at.snapshot})(r,E,R,S);const o=await qo(r.localStore,t,!0),u=new fd(t,o.qs),c=u.nu(o.documents),h=Tn.createSynthesizedTargetChangeForCurrentChange(e,n&&r.onlineState!=="Offline",i),f=u.applyChanges(c,r.isPrimaryClient,h);Xo(r,e,f._u);const p=new md(t,e,u);return r.Pu.set(t,p),r.Tu.has(e)?r.Tu.get(e).push(t):r.Tu.set(e,[t]),f.snapshot}async function Td(r,t,e){const n=L(r),i=n.Pu.get(t),o=n.Tu.get(i.targetId);if(o.length>1)return n.Tu.set(i.targetId,o.filter((u=>!Er(u,t)))),void n.Pu.delete(t);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(i.targetId),n.sharedClientState.isActiveQueryTarget(i.targetId)||await gs(n.localStore,i.targetId,!1).then((()=>{n.sharedClientState.clearQueryState(i.targetId),e&&qs(n.remoteStore,i.targetId),Es(n,i.targetId)})).catch(xe)):(Es(n,i.targetId),await gs(n.localStore,i.targetId,!0))}async function vd(r,t){const e=L(r),n=e.Pu.get(t),i=e.Tu.get(n.targetId);e.isPrimaryClient&&i.length===1&&(e.sharedClientState.removeLocalQueryTarget(n.targetId),qs(e.remoteStore,n.targetId))}async function Id(r,t,e){const n=Cd(r);try{const i=await(function(u,c){const h=L(u),f=W.now(),p=c.reduce(((S,D)=>S.add(D.key)),q());let E,R;return h.persistence.runTransaction("Locally write mutations","readwrite",(S=>{let D=$t(),x=q();return h.Os.getEntries(S,p).next((b=>{D=b,D.forEach((($,B)=>{B.isValidDocument()||(x=x.add($))}))})).next((()=>h.localDocuments.getOverlayedDocuments(S,D))).next((b=>{E=b;const $=[];for(const B of c){const K=Uc(B,E.get(B.key).overlayedDocument);K!=null&&$.push(new oe(B.key,K,Da(K.value.mapValue),Vt.exists(!0)))}return h.mutationQueue.addMutationBatch(S,f,$,c)})).next((b=>{R=b;const $=b.applyToLocalDocumentSet(E,x);return h.documentOverlayCache.saveOverlays(S,b.batchId,$)}))})).then((()=>({batchId:R.batchId,changes:ja(E)})))})(n.localStore,t);n.sharedClientState.addPendingMutation(i.batchId),(function(u,c,h){let f=u.Ru[u.currentUser.toKey()];f||(f=new Y(U)),f=f.insert(c,h),u.Ru[u.currentUser.toKey()]=f})(n,i.batchId,e),await In(n,i.changes),await Pr(n.remoteStore)}catch(i){const o=Gs(i,"Failed to persist write");e.reject(o)}}async function Iu(r,t){const e=L(r);try{const n=await Oh(e.localStore,t);t.targetChanges.forEach(((i,o)=>{const u=e.Eu.get(o);u&&(G(i.addedDocuments.size+i.modifiedDocuments.size+i.removedDocuments.size<=1,22616),i.addedDocuments.size>0?u.lu=!0:i.modifiedDocuments.size>0?G(u.lu,14607):i.removedDocuments.size>0&&(G(u.lu,42227),u.lu=!1))})),await In(e,n,t)}catch(n){await xe(n)}}function Ho(r,t,e){const n=L(r);if(n.isPrimaryClient&&e===0||!n.isPrimaryClient&&e===1){const i=[];n.Pu.forEach(((o,u)=>{const c=u.view.va(t);c.snapshot&&i.push(c.snapshot)})),(function(u,c){const h=L(u);h.onlineState=c;let f=!1;h.queries.forEach(((p,E)=>{for(const R of E.wa)R.va(c)&&(f=!0)})),f&&Ws(h)})(n.eventManager,t),i.length&&n.hu.J_(i),n.onlineState=t,n.isPrimaryClient&&n.sharedClientState.setOnlineState(t)}}async function Ad(r,t,e){const n=L(r);n.sharedClientState.updateQueryState(t,"rejected",e);const i=n.Eu.get(t),o=i&&i.key;if(o){let u=new Y(O.comparator);u=u.insert(o,yt.newNoDocument(o,F.min()));const c=q().add(o),h=new Ar(F.min(),new Map,new Y(U),u,c);await Iu(n,h),n.du=n.du.remove(o),n.Eu.delete(t),Ys(n)}else await gs(n.localStore,t,!1).then((()=>Es(n,t,e))).catch(xe)}async function wd(r,t){const e=L(r),n=t.batch.batchId;try{const i=await xh(e.localStore,t);wu(e,n,null),Au(e,n),e.sharedClientState.updateMutationState(n,"acknowledged"),await In(e,i)}catch(i){await xe(i)}}async function Rd(r,t,e){const n=L(r);try{const i=await(function(u,c){const h=L(u);return h.persistence.runTransaction("Reject batch","readwrite-primary",(f=>{let p;return h.mutationQueue.lookupMutationBatch(f,c).next((E=>(G(E!==null,37113),p=E.keys(),h.mutationQueue.removeMutationBatch(f,E)))).next((()=>h.mutationQueue.performConsistencyCheck(f))).next((()=>h.documentOverlayCache.removeOverlaysForBatchId(f,p,c))).next((()=>h.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(f,p))).next((()=>h.localDocuments.getDocuments(f,p)))}))})(n.localStore,t);wu(n,t,e),Au(n,t),n.sharedClientState.updateMutationState(t,"rejected",e),await In(n,i)}catch(i){await xe(i)}}function Au(r,t){(r.Vu.get(t)||[]).forEach((e=>{e.resolve()})),r.Vu.delete(t)}function wu(r,t,e){const n=L(r);let i=n.Ru[n.currentUser.toKey()];if(i){const o=i.get(t);o&&(e?o.reject(e):o.resolve(),i=i.remove(t)),n.Ru[n.currentUser.toKey()]=i}}function Es(r,t,e=null){r.sharedClientState.removeLocalQueryTarget(t);for(const n of r.Tu.get(t))r.Pu.delete(n),e&&r.hu.pu(n,e);r.Tu.delete(t),r.isPrimaryClient&&r.Au.zr(t).forEach((n=>{r.Au.containsKey(n)||Ru(r,n)}))}function Ru(r,t){r.Iu.delete(t.path.canonicalString());const e=r.du.get(t);e!==null&&(qs(r.remoteStore,e),r.du=r.du.remove(t),r.Eu.delete(e),Ys(r))}function Xo(r,t,e){for(const n of e)n instanceof Eu?(r.Au.addReference(n.key,t),Pd(r,n)):n instanceof Tu?(N(Xs,"Document no longer in limbo: "+n.key),r.Au.removeReference(n.key,t),r.Au.containsKey(n.key)||Ru(r,n.key)):M(19791,{yu:n})}function Pd(r,t){const e=t.key,n=e.path.canonicalString();r.du.get(e)||r.Iu.has(n)||(N(Xs,"New document in limbo: "+e),r.Iu.add(n),Ys(r))}function Ys(r){for(;r.Iu.size>0&&r.du.size<r.maxConcurrentLimboResolutions;){const t=r.Iu.values().next().value;r.Iu.delete(t);const e=new O(X.fromString(t)),n=r.mu.next();r.Eu.set(n,new pd(e)),r.du=r.du.insert(e,n),fu(r.remoteStore,new Ht(Ct(yr(e.path)),n,"TargetPurposeLimboResolution",mr.ue))}}async function In(r,t,e){const n=L(r),i=[],o=[],u=[];n.Pu.isEmpty()||(n.Pu.forEach(((c,h)=>{u.push(n.gu(h,t,e).then((f=>{var p;if((f||e)&&n.isPrimaryClient){const E=f?!f.fromCache:(p=e==null?void 0:e.targetChanges.get(h.targetId))===null||p===void 0?void 0:p.current;n.sharedClientState.updateQueryState(h.targetId,E?"current":"not-current")}if(f){i.push(f);const E=Ls.Es(h.targetId,f);o.push(E)}})))})),await Promise.all(u),n.hu.J_(i),await(async function(h,f){const p=L(h);try{await p.persistence.runTransaction("notifyLocalViewChanges","readwrite",(E=>V.forEach(f,(R=>V.forEach(R.Is,(S=>p.persistence.referenceDelegate.addReference(E,R.targetId,S))).next((()=>V.forEach(R.ds,(S=>p.persistence.referenceDelegate.removeReference(E,R.targetId,S)))))))))}catch(E){if(!Oe(E))throw E;N(Us,"Failed to update sequence numbers: "+E)}for(const E of f){const R=E.targetId;if(!E.fromCache){const S=p.Fs.get(R),D=S.snapshotVersion,x=S.withLastLimboFreeSnapshotVersion(D);p.Fs=p.Fs.insert(R,x)}}})(n.localStore,o))}async function Vd(r,t){const e=L(r);if(!e.currentUser.isEqual(t)){N(Xs,"User change. New user:",t.toKey());const n=await lu(e.localStore,t);e.currentUser=t,(function(o,u){o.Vu.forEach((c=>{c.forEach((h=>{h.reject(new k(P.CANCELLED,u))}))})),o.Vu.clear()})(e,"'waitForPendingWrites' promise is rejected due to a user change."),e.sharedClientState.handleUserChange(t,n.removedBatchIds,n.addedBatchIds),await In(e,n.Bs)}}function Sd(r,t){const e=L(r),n=e.Eu.get(t);if(n&&n.lu)return q().add(n.key);{let i=q();const o=e.Tu.get(t);if(!o)return i;for(const u of o){const c=e.Pu.get(u);i=i.unionWith(c.view.tu)}return i}}function Pu(r){const t=L(r);return t.remoteStore.remoteSyncer.applyRemoteEvent=Iu.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=Sd.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=Ad.bind(null,t),t.hu.J_=hd.bind(null,t.eventManager),t.hu.pu=dd.bind(null,t.eventManager),t}function Cd(r){const t=L(r);return t.remoteStore.remoteSyncer.applySuccessfulWrite=wd.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=Rd.bind(null,t),t}class hr{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(t){this.serializer=wr(t.databaseInfo.databaseId),this.sharedClientState=this.bu(t),this.persistence=this.Du(t),await this.persistence.start(),this.localStore=this.vu(t),this.gcScheduler=this.Cu(t,this.localStore),this.indexBackfillerScheduler=this.Fu(t,this.localStore)}Cu(t,e){return null}Fu(t,e){return null}vu(t){return kh(this.persistence,new bh,t.initialUser,this.serializer)}Du(t){return new uu(Fs.Vi,this.serializer)}bu(t){return new qh}async terminate(){var t,e;(t=this.gcScheduler)===null||t===void 0||t.stop(),(e=this.indexBackfillerScheduler)===null||e===void 0||e.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}hr.provider={build:()=>new hr};class bd extends hr{constructor(t){super(),this.cacheSizeBytes=t}Cu(t,e){G(this.persistence.referenceDelegate instanceof lr,46915);const n=this.persistence.referenceDelegate.garbageCollector;return new ph(n,t.asyncQueue,e)}Du(t){const e=this.cacheSizeBytes!==void 0?vt.withCacheSize(this.cacheSizeBytes):vt.DEFAULT;return new uu((n=>lr.Vi(n,e)),this.serializer)}}class Ts{async initialize(t,e){this.localStore||(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(e),this.remoteStore=this.createRemoteStore(e),this.eventManager=this.createEventManager(e),this.syncEngine=this.createSyncEngine(e,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=n=>Ho(this.syncEngine,n,1),this.remoteStore.remoteSyncer.handleCredentialChange=Vd.bind(null,this.syncEngine),await ud(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(t){return(function(){return new cd})()}createDatastore(t){const e=wr(t.databaseInfo.databaseId),n=(function(o){return new Gh(o)})(t.databaseInfo);return(function(o,u,c,h){return new Hh(o,u,c,h)})(t.authCredentials,t.appCheckCredentials,n,e)}createRemoteStore(t){return(function(n,i,o,u,c){return new Yh(n,i,o,u,c)})(this.localStore,this.datastore,t.asyncQueue,(e=>Ho(this.syncEngine,e,0)),(function(){return zo.C()?new zo:new jh})())}createSyncEngine(t,e){return(function(i,o,u,c,h,f,p){const E=new gd(i,o,u,c,h,f);return p&&(E.fu=!0),E})(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,e)}async terminate(){var t,e;await(async function(i){const o=L(i);N(pe,"RemoteStore shutting down."),o.Ia.add(5),await vn(o),o.Ea.shutdown(),o.Aa.set("Unknown")})(this.remoteStore),(t=this.datastore)===null||t===void 0||t.terminate(),(e=this.eventManager)===null||e===void 0||e.terminate()}}Ts.provider={build:()=>new Ts};/**
1387
+ * @license
1388
+ * Copyright 2020 Google LLC
1389
+ *
1390
+ * Licensed under the Apache License, Version 2.0 (the "License");
1391
+ * you may not use this file except in compliance with the License.
1392
+ * You may obtain a copy of the License at
1393
+ *
1394
+ * http://www.apache.org/licenses/LICENSE-2.0
1395
+ *
1396
+ * Unless required by applicable law or agreed to in writing, software
1397
+ * distributed under the License is distributed on an "AS IS" BASIS,
1398
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1399
+ * See the License for the specific language governing permissions and
1400
+ * limitations under the License.
1401
+ *//**
1402
+ * @license
1403
+ * Copyright 2017 Google LLC
1404
+ *
1405
+ * Licensed under the Apache License, Version 2.0 (the "License");
1406
+ * you may not use this file except in compliance with the License.
1407
+ * You may obtain a copy of the License at
1408
+ *
1409
+ * http://www.apache.org/licenses/LICENSE-2.0
1410
+ *
1411
+ * Unless required by applicable law or agreed to in writing, software
1412
+ * distributed under the License is distributed on an "AS IS" BASIS,
1413
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
+ * See the License for the specific language governing permissions and
1415
+ * limitations under the License.
1416
+ */class Js{constructor(t){this.observer=t,this.muted=!1}next(t){this.muted||this.observer.next&&this.xu(this.observer.next,t)}error(t){this.muted||(this.observer.error?this.xu(this.observer.error,t):zt("Uncaught Error in snapshot listener:",t.toString()))}Ou(){this.muted=!0}xu(t,e){setTimeout((()=>{this.muted||t(e)}),0)}}/**
1417
+ * @license
1418
+ * Copyright 2017 Google LLC
1419
+ *
1420
+ * Licensed under the Apache License, Version 2.0 (the "License");
1421
+ * you may not use this file except in compliance with the License.
1422
+ * You may obtain a copy of the License at
1423
+ *
1424
+ * http://www.apache.org/licenses/LICENSE-2.0
1425
+ *
1426
+ * Unless required by applicable law or agreed to in writing, software
1427
+ * distributed under the License is distributed on an "AS IS" BASIS,
1428
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1429
+ * See the License for the specific language governing permissions and
1430
+ * limitations under the License.
1431
+ */const se="FirestoreClient";class Dd{constructor(t,e,n,i,o){this.authCredentials=t,this.appCheckCredentials=e,this.asyncQueue=n,this.databaseInfo=i,this.user=_t.UNAUTHENTICATED,this.clientId=ws.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=o,this.authCredentials.start(n,(async u=>{N(se,"Received user=",u.uid),await this.authCredentialListener(u),this.user=u})),this.appCheckCredentials.start(n,(u=>(N(se,"Received new app check token=",u),this.appCheckCredentialListener(u,this.user))))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(t){this.authCredentialListener=t}setAppCheckTokenChangeListener(t){this.appCheckCredentialListener=t}terminate(){this.asyncQueue.enterRestrictedMode();const t=new jt;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),t.resolve()}catch(e){const n=Gs(e,"Failed to shutdown persistence");t.reject(n)}})),t.promise}}async function rs(r,t){r.asyncQueue.verifyOperationInProgress(),N(se,"Initializing OfflineComponentProvider");const e=r.configuration;await t.initialize(e);let n=e.initialUser;r.setCredentialChangeListener((async i=>{n.isEqual(i)||(await lu(t.localStore,i),n=i)})),t.persistence.setDatabaseDeletedListener((()=>{Jt("Terminating Firestore due to IndexedDb database deletion"),r.terminate().then((()=>{N("Terminating Firestore due to IndexedDb database deletion completed successfully")})).catch((i=>{Jt("Terminating Firestore due to IndexedDb database deletion failed",i)}))})),r._offlineComponents=t}async function Yo(r,t){r.asyncQueue.verifyOperationInProgress();const e=await Nd(r);N(se,"Initializing OnlineComponentProvider"),await t.initialize(e,r.configuration),r.setCredentialChangeListener((n=>Go(t.remoteStore,n))),r.setAppCheckTokenChangeListener(((n,i)=>Go(t.remoteStore,i))),r._onlineComponents=t}async function Nd(r){if(!r._offlineComponents)if(r._uninitializedComponentsProvider){N(se,"Using user provided OfflineComponentProvider");try{await rs(r,r._uninitializedComponentsProvider._offline)}catch(t){const e=t;if(!(function(i){return i.name==="FirebaseError"?i.code===P.FAILED_PRECONDITION||i.code===P.UNIMPLEMENTED:!(typeof DOMException<"u"&&i instanceof DOMException)||i.code===22||i.code===20||i.code===11})(e))throw e;Jt("Error using user provided cache. Falling back to memory cache: "+e),await rs(r,new hr)}}else N(se,"Using default OfflineComponentProvider"),await rs(r,new bd(void 0));return r._offlineComponents}async function Vu(r){return r._onlineComponents||(r._uninitializedComponentsProvider?(N(se,"Using user provided OnlineComponentProvider"),await Yo(r,r._uninitializedComponentsProvider._online)):(N(se,"Using default OnlineComponentProvider"),await Yo(r,new Ts))),r._onlineComponents}function kd(r){return Vu(r).then((t=>t.syncEngine))}async function dr(r){const t=await Vu(r),e=t.eventManager;return e.onListen=_d.bind(null,t.syncEngine),e.onUnlisten=Td.bind(null,t.syncEngine),e.onFirstRemoteStoreListen=yd.bind(null,t.syncEngine),e.onLastRemoteStoreUnlisten=vd.bind(null,t.syncEngine),e}function xd(r,t,e={}){const n=new jt;return r.asyncQueue.enqueueAndForget((async()=>(function(o,u,c,h,f){const p=new Js({next:R=>{p.Ou(),u.enqueueAndForget((()=>Qs(o,E)));const S=R.docs.has(c);!S&&R.fromCache?f.reject(new k(P.UNAVAILABLE,"Failed to get document because the client is offline.")):S&&R.fromCache&&h&&h.source==="server"?f.reject(new k(P.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):f.resolve(R)},error:R=>f.reject(R)}),E=new Hs(yr(c.path),p,{includeMetadataChanges:!0,ka:!0});return Ks(o,E)})(await dr(r),r.asyncQueue,t,e,n))),n.promise}function Od(r,t,e={}){const n=new jt;return r.asyncQueue.enqueueAndForget((async()=>(function(o,u,c,h,f){const p=new Js({next:R=>{p.Ou(),u.enqueueAndForget((()=>Qs(o,E))),R.fromCache&&h.source==="server"?f.reject(new k(P.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):f.resolve(R)},error:R=>f.reject(R)}),E=new Hs(c,p,{includeMetadataChanges:!0,ka:!0});return Ks(o,E)})(await dr(r),r.asyncQueue,t,e,n))),n.promise}/**
1432
+ * @license
1433
+ * Copyright 2023 Google LLC
1434
+ *
1435
+ * Licensed under the Apache License, Version 2.0 (the "License");
1436
+ * you may not use this file except in compliance with the License.
1437
+ * You may obtain a copy of the License at
1438
+ *
1439
+ * http://www.apache.org/licenses/LICENSE-2.0
1440
+ *
1441
+ * Unless required by applicable law or agreed to in writing, software
1442
+ * distributed under the License is distributed on an "AS IS" BASIS,
1443
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1444
+ * See the License for the specific language governing permissions and
1445
+ * limitations under the License.
1446
+ */function Su(r){const t={};return r.timeoutSeconds!==void 0&&(t.timeoutSeconds=r.timeoutSeconds),t}/**
1447
+ * @license
1448
+ * Copyright 2020 Google LLC
1449
+ *
1450
+ * Licensed under the Apache License, Version 2.0 (the "License");
1451
+ * you may not use this file except in compliance with the License.
1452
+ * You may obtain a copy of the License at
1453
+ *
1454
+ * http://www.apache.org/licenses/LICENSE-2.0
1455
+ *
1456
+ * Unless required by applicable law or agreed to in writing, software
1457
+ * distributed under the License is distributed on an "AS IS" BASIS,
1458
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1459
+ * See the License for the specific language governing permissions and
1460
+ * limitations under the License.
1461
+ */const Jo=new Map;/**
1462
+ * @license
1463
+ * Copyright 2020 Google LLC
1464
+ *
1465
+ * Licensed under the Apache License, Version 2.0 (the "License");
1466
+ * you may not use this file except in compliance with the License.
1467
+ * You may obtain a copy of the License at
1468
+ *
1469
+ * http://www.apache.org/licenses/LICENSE-2.0
1470
+ *
1471
+ * Unless required by applicable law or agreed to in writing, software
1472
+ * distributed under the License is distributed on an "AS IS" BASIS,
1473
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1474
+ * See the License for the specific language governing permissions and
1475
+ * limitations under the License.
1476
+ */const Cu="firestore.googleapis.com",Zo=!0;class ta{constructor(t){var e,n;if(t.host===void 0){if(t.ssl!==void 0)throw new k(P.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=Cu,this.ssl=Zo}else this.host=t.host,this.ssl=(e=t.ssl)!==null&&e!==void 0?e:Zo;if(this.isUsingEmulator=t.emulatorOptions!==void 0,this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,this.localCache=t.localCache,t.cacheSizeBytes===void 0)this.cacheSizeBytes=ou;else{if(t.cacheSizeBytes!==-1&&t.cacheSizeBytes<au)throw new k(P.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}Jl("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:t.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=Su((n=t.experimentalLongPollingOptions)!==null&&n!==void 0?n:{}),(function(o){if(o.timeoutSeconds!==void 0){if(isNaN(o.timeoutSeconds))throw new k(P.INVALID_ARGUMENT,`invalid long polling timeout: ${o.timeoutSeconds} (must not be NaN)`);if(o.timeoutSeconds<5)throw new k(P.INVALID_ARGUMENT,`invalid long polling timeout: ${o.timeoutSeconds} (minimum allowed value is 5)`);if(o.timeoutSeconds>30)throw new k(P.INVALID_ARGUMENT,`invalid long polling timeout: ${o.timeoutSeconds} (maximum allowed value is 30)`)}})(this.experimentalLongPollingOptions),this.useFetchStreams=!!t.useFetchStreams}isEqual(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&(function(n,i){return n.timeoutSeconds===i.timeoutSeconds})(this.experimentalLongPollingOptions,t.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties&&this.useFetchStreams===t.useFetchStreams}}class Vr{constructor(t,e,n,i){this._authCredentials=t,this._appCheckCredentials=e,this._databaseId=n,this._app=i,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new ta({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new k(P.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(t){if(this._settingsFrozen)throw new k(P.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new ta(t),this._emulatorOptions=t.emulatorOptions||{},t.credentials!==void 0&&(this._authCredentials=(function(n){if(!n)return new zl;switch(n.type){case"firstParty":return new Ql(n.sessionIndex||"0",n.iamToken||null,n.authTokenFactory||null);case"provider":return n.client;default:throw new k(P.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}})(t.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return(function(e){const n=Jo.get(e);n&&(N("ComponentProvider","Removing Datastore"),Jo.delete(e),n.terminate())})(this),Promise.resolve()}}function Md(r,t,e,n={}){var i;r=Bt(r,Vr);const o=Is(t),u=r._getSettings(),c=Object.assign(Object.assign({},u),{emulatorOptions:r._getEmulatorOptions()}),h=`${t}:${e}`;o&&(ca(`https://${h}`),Dl("Firestore",!0)),u.host!==Cu&&u.host!==h&&Jt("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const f=Object.assign(Object.assign({},u),{host:h,ssl:o,emulatorOptions:n});if(!la(f,c)&&(r._setSettings(f),n.mockUserToken)){let p,E;if(typeof n.mockUserToken=="string")p=n.mockUserToken,E=_t.MOCK_USER;else{p=Nl(n.mockUserToken,(i=r._app)===null||i===void 0?void 0:i.options.projectId);const R=n.mockUserToken.sub||n.mockUserToken.user_id;if(!R)throw new k(P.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");E=new _t(R)}r._authCredentials=new $l(new ya(p,E))}}/**
1477
+ * @license
1478
+ * Copyright 2020 Google LLC
1479
+ *
1480
+ * Licensed under the Apache License, Version 2.0 (the "License");
1481
+ * you may not use this file except in compliance with the License.
1482
+ * You may obtain a copy of the License at
1483
+ *
1484
+ * http://www.apache.org/licenses/LICENSE-2.0
1485
+ *
1486
+ * Unless required by applicable law or agreed to in writing, software
1487
+ * distributed under the License is distributed on an "AS IS" BASIS,
1488
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1489
+ * See the License for the specific language governing permissions and
1490
+ * limitations under the License.
1491
+ */class An{constructor(t,e,n){this.converter=e,this._query=n,this.type="query",this.firestore=t}withConverter(t){return new An(this.firestore,t,this._query)}}class rt{constructor(t,e,n){this.converter=e,this._key=n,this.type="document",this.firestore=t}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Yt(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new rt(this.firestore,t,this._key)}toJSON(){return{type:rt._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(t,e,n){if(yn(e,rt._jsonSchema))return new rt(t,n||null,new O(X.fromString(e.referencePath)))}}rt._jsonSchemaVersion="firestore/documentReference/1.0",rt._jsonSchema={type:et("string",rt._jsonSchemaVersion),referencePath:et("string")};class Yt extends An{constructor(t,e,n){super(t,e,yr(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const t=this._path.popLast();return t.isEmpty()?null:new rt(this.firestore,null,new O(t))}withConverter(t){return new Yt(this.firestore,t,this._path)}}function ea(r,t,...e){if(r=kt(r),Ta("collection","path",t),r instanceof Vr){const n=X.fromString(t,...e);return mo(n),new Yt(r,null,n)}{if(!(r instanceof rt||r instanceof Yt))throw new k(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const n=r._path.child(X.fromString(t,...e));return mo(n),new Yt(r.firestore,null,n)}}function na(r,t,...e){if(r=kt(r),arguments.length===1&&(t=ws.newId()),Ta("doc","path",t),r instanceof Vr){const n=X.fromString(t,...e);return fo(n),new rt(r,null,new O(n))}{if(!(r instanceof rt||r instanceof Yt))throw new k(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const n=r._path.child(X.fromString(t,...e));return fo(n),new rt(r.firestore,r instanceof Yt?r.converter:null,new O(n))}}/**
1492
+ * @license
1493
+ * Copyright 2020 Google LLC
1494
+ *
1495
+ * Licensed under the Apache License, Version 2.0 (the "License");
1496
+ * you may not use this file except in compliance with the License.
1497
+ * You may obtain a copy of the License at
1498
+ *
1499
+ * http://www.apache.org/licenses/LICENSE-2.0
1500
+ *
1501
+ * Unless required by applicable law or agreed to in writing, software
1502
+ * distributed under the License is distributed on an "AS IS" BASIS,
1503
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1504
+ * See the License for the specific language governing permissions and
1505
+ * limitations under the License.
1506
+ */const ra="AsyncQueue";class sa{constructor(t=Promise.resolve()){this.Zu=[],this.Xu=!1,this.ec=[],this.tc=null,this.nc=!1,this.rc=!1,this.sc=[],this.F_=new hu(this,"async_queue_retry"),this.oc=()=>{const n=ns();n&&N(ra,"Visibility state changed to "+n.visibilityState),this.F_.y_()},this._c=t;const e=ns();e&&typeof e.addEventListener=="function"&&e.addEventListener("visibilitychange",this.oc)}get isShuttingDown(){return this.Xu}enqueueAndForget(t){this.enqueue(t)}enqueueAndForgetEvenWhileRestricted(t){this.ac(),this.uc(t)}enterRestrictedMode(t){if(!this.Xu){this.Xu=!0,this.rc=t||!1;const e=ns();e&&typeof e.removeEventListener=="function"&&e.removeEventListener("visibilitychange",this.oc)}}enqueue(t){if(this.ac(),this.Xu)return new Promise((()=>{}));const e=new jt;return this.uc((()=>this.Xu&&this.rc?Promise.resolve():(t().then(e.resolve,e.reject),e.promise))).then((()=>e.promise))}enqueueRetryable(t){this.enqueueAndForget((()=>(this.Zu.push(t),this.cc())))}async cc(){if(this.Zu.length!==0){try{await this.Zu[0](),this.Zu.shift(),this.F_.reset()}catch(t){if(!Oe(t))throw t;N(ra,"Operation failed with retryable error: "+t)}this.Zu.length>0&&this.F_.g_((()=>this.cc()))}}uc(t){const e=this._c.then((()=>(this.nc=!0,t().catch((n=>{throw this.tc=n,this.nc=!1,zt("INTERNAL UNHANDLED ERROR: ",ia(n)),n})).then((n=>(this.nc=!1,n))))));return this._c=e,e}enqueueAfterDelay(t,e,n){this.ac(),this.sc.indexOf(t)>-1&&(e=0);const i=$s.createAndSchedule(this,t,e,n,(o=>this.lc(o)));return this.ec.push(i),i}ac(){this.tc&&M(47125,{hc:ia(this.tc)})}verifyOperationInProgress(){}async Pc(){let t;do t=this._c,await t;while(t!==this._c)}Tc(t){for(const e of this.ec)if(e.timerId===t)return!0;return!1}Ic(t){return this.Pc().then((()=>{this.ec.sort(((e,n)=>e.targetTimeMs-n.targetTimeMs));for(const e of this.ec)if(e.skipDelay(),t!=="all"&&e.timerId===t)break;return this.Pc()}))}dc(t){this.sc.push(t)}lc(t){const e=this.ec.indexOf(t);this.ec.splice(e,1)}}function ia(r){let t=r.message||"";return r.stack&&(t=r.stack.includes(r.message)?r.stack:r.message+`
1507
+ `+r.stack),t}/**
1508
+ * @license
1509
+ * Copyright 2017 Google LLC
1510
+ *
1511
+ * Licensed under the Apache License, Version 2.0 (the "License");
1512
+ * you may not use this file except in compliance with the License.
1513
+ * You may obtain a copy of the License at
1514
+ *
1515
+ * http://www.apache.org/licenses/LICENSE-2.0
1516
+ *
1517
+ * Unless required by applicable law or agreed to in writing, software
1518
+ * distributed under the License is distributed on an "AS IS" BASIS,
1519
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1520
+ * See the License for the specific language governing permissions and
1521
+ * limitations under the License.
1522
+ */function oa(r){return(function(e,n){if(typeof e!="object"||e===null)return!1;const i=e;for(const o of n)if(o in i&&typeof i[o]=="function")return!0;return!1})(r,["next","error","complete"])}class Ne extends Vr{constructor(t,e,n,i){super(t,e,n,i),this.type="firestore",this._queue=new sa,this._persistenceKey=(i==null?void 0:i.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const t=this._firestoreClient.terminate();this._queue=new sa(t),this._firestoreClient=void 0,await t}}}function Fd(r,t,e){e||(e=fn);const n=ua(r,"firestore");if(n.isInitialized(e)){const i=n.getImmediate({identifier:e}),o=n.getOptions(e);if(la(o,t))return i;throw new k(P.FAILED_PRECONDITION,"initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.")}if(t.cacheSizeBytes!==void 0&&t.localCache!==void 0)throw new k(P.INVALID_ARGUMENT,"cache and cacheSizeBytes cannot be specified at the same time as cacheSizeBytes willbe deprecated. Instead, specify the cache size in the cache object");if(t.cacheSizeBytes!==void 0&&t.cacheSizeBytes!==-1&&t.cacheSizeBytes<au)throw new k(P.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return t.host&&Is(t.host)&&ca(t.host),n.initialize({options:t,instanceIdentifier:e})}function Ld(r,t){const e=typeof r=="object"?r:Sl(),n=typeof r=="string"?r:fn,i=ua(e,"firestore").getImmediate({identifier:n});if(!i._initialized){const o=Cl("firestore");o&&Md(i,...o)}return i}function wn(r){if(r._terminated)throw new k(P.FAILED_PRECONDITION,"The client has already been terminated.");return r._firestoreClient||Ud(r),r._firestoreClient}function Ud(r){var t,e,n;const i=r._freezeSettings(),o=(function(c,h,f,p){return new lc(c,h,f,p.host,p.ssl,p.experimentalForceLongPolling,p.experimentalAutoDetectLongPolling,Su(p.experimentalLongPollingOptions),p.useFetchStreams,p.isUsingEmulator)})(r._databaseId,((t=r._app)===null||t===void 0?void 0:t.options.appId)||"",r._persistenceKey,i);r._componentsProvider||!((e=i.localCache)===null||e===void 0)&&e._offlineComponentProvider&&(!((n=i.localCache)===null||n===void 0)&&n._onlineComponentProvider)&&(r._componentsProvider={_offline:i.localCache._offlineComponentProvider,_online:i.localCache._onlineComponentProvider}),r._firestoreClient=new Dd(r._authCredentials,r._appCheckCredentials,r._queue,o,r._componentsProvider&&(function(c){const h=c==null?void 0:c._online.build();return{_offline:c==null?void 0:c._offline.build(h),_online:h}})(r._componentsProvider))}/**
1523
+ * @license
1524
+ * Copyright 2020 Google LLC
1525
+ *
1526
+ * Licensed under the Apache License, Version 2.0 (the "License");
1527
+ * you may not use this file except in compliance with the License.
1528
+ * You may obtain a copy of the License at
1529
+ *
1530
+ * http://www.apache.org/licenses/LICENSE-2.0
1531
+ *
1532
+ * Unless required by applicable law or agreed to in writing, software
1533
+ * distributed under the License is distributed on an "AS IS" BASIS,
1534
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1535
+ * See the License for the specific language governing permissions and
1536
+ * limitations under the License.
1537
+ */class Rt{constructor(t){this._byteString=t}static fromBase64String(t){try{return new Rt(ht.fromBase64String(t))}catch(e){throw new k(P.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(t){return new Rt(ht.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(t){return this._byteString.isEqual(t._byteString)}toJSON(){return{type:Rt._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(t){if(yn(t,Rt._jsonSchema))return Rt.fromBase64String(t.bytes)}}Rt._jsonSchemaVersion="firestore/bytes/1.0",Rt._jsonSchema={type:et("string",Rt._jsonSchemaVersion),bytes:et("string")};/**
1538
+ * @license
1539
+ * Copyright 2020 Google LLC
1540
+ *
1541
+ * Licensed under the Apache License, Version 2.0 (the "License");
1542
+ * you may not use this file except in compliance with the License.
1543
+ * You may obtain a copy of the License at
1544
+ *
1545
+ * http://www.apache.org/licenses/LICENSE-2.0
1546
+ *
1547
+ * Unless required by applicable law or agreed to in writing, software
1548
+ * distributed under the License is distributed on an "AS IS" BASIS,
1549
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1550
+ * See the License for the specific language governing permissions and
1551
+ * limitations under the License.
1552
+ */class Sr{constructor(...t){for(let e=0;e<t.length;++e)if(t[e].length===0)throw new k(P.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new ct(t)}isEqual(t){return this._internalPath.isEqual(t._internalPath)}}/**
1553
+ * @license
1554
+ * Copyright 2020 Google LLC
1555
+ *
1556
+ * Licensed under the Apache License, Version 2.0 (the "License");
1557
+ * you may not use this file except in compliance with the License.
1558
+ * You may obtain a copy of the License at
1559
+ *
1560
+ * http://www.apache.org/licenses/LICENSE-2.0
1561
+ *
1562
+ * Unless required by applicable law or agreed to in writing, software
1563
+ * distributed under the License is distributed on an "AS IS" BASIS,
1564
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1565
+ * See the License for the specific language governing permissions and
1566
+ * limitations under the License.
1567
+ */class Zs{constructor(t){this._methodName=t}}/**
1568
+ * @license
1569
+ * Copyright 2017 Google LLC
1570
+ *
1571
+ * Licensed under the Apache License, Version 2.0 (the "License");
1572
+ * you may not use this file except in compliance with the License.
1573
+ * You may obtain a copy of the License at
1574
+ *
1575
+ * http://www.apache.org/licenses/LICENSE-2.0
1576
+ *
1577
+ * Unless required by applicable law or agreed to in writing, software
1578
+ * distributed under the License is distributed on an "AS IS" BASIS,
1579
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1580
+ * See the License for the specific language governing permissions and
1581
+ * limitations under the License.
1582
+ */class Dt{constructor(t,e){if(!isFinite(t)||t<-90||t>90)throw new k(P.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new k(P.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}get latitude(){return this._lat}get longitude(){return this._long}isEqual(t){return this._lat===t._lat&&this._long===t._long}_compareTo(t){return U(this._lat,t._lat)||U(this._long,t._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:Dt._jsonSchemaVersion}}static fromJSON(t){if(yn(t,Dt._jsonSchema))return new Dt(t.latitude,t.longitude)}}Dt._jsonSchemaVersion="firestore/geoPoint/1.0",Dt._jsonSchema={type:et("string",Dt._jsonSchemaVersion),latitude:et("number"),longitude:et("number")};/**
1583
+ * @license
1584
+ * Copyright 2024 Google LLC
1585
+ *
1586
+ * Licensed under the Apache License, Version 2.0 (the "License");
1587
+ * you may not use this file except in compliance with the License.
1588
+ * You may obtain a copy of the License at
1589
+ *
1590
+ * http://www.apache.org/licenses/LICENSE-2.0
1591
+ *
1592
+ * Unless required by applicable law or agreed to in writing, software
1593
+ * distributed under the License is distributed on an "AS IS" BASIS,
1594
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1595
+ * See the License for the specific language governing permissions and
1596
+ * limitations under the License.
1597
+ */class Nt{constructor(t){this._values=(t||[]).map((e=>e))}toArray(){return this._values.map((t=>t))}isEqual(t){return(function(n,i){if(n.length!==i.length)return!1;for(let o=0;o<n.length;++o)if(n[o]!==i[o])return!1;return!0})(this._values,t._values)}toJSON(){return{type:Nt._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(t){if(yn(t,Nt._jsonSchema)){if(Array.isArray(t.vectorValues)&&t.vectorValues.every((e=>typeof e=="number")))return new Nt(t.vectorValues);throw new k(P.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}Nt._jsonSchemaVersion="firestore/vectorValue/1.0",Nt._jsonSchema={type:et("string",Nt._jsonSchemaVersion),vectorValues:et("object")};/**
1598
+ * @license
1599
+ * Copyright 2017 Google LLC
1600
+ *
1601
+ * Licensed under the Apache License, Version 2.0 (the "License");
1602
+ * you may not use this file except in compliance with the License.
1603
+ * You may obtain a copy of the License at
1604
+ *
1605
+ * http://www.apache.org/licenses/LICENSE-2.0
1606
+ *
1607
+ * Unless required by applicable law or agreed to in writing, software
1608
+ * distributed under the License is distributed on an "AS IS" BASIS,
1609
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1610
+ * See the License for the specific language governing permissions and
1611
+ * limitations under the License.
1612
+ */const qd=/^__.*__$/;class jd{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return this.fieldMask!==null?new oe(t,this.data,this.fieldMask,e,this.fieldTransforms):new En(t,this.data,e,this.fieldTransforms)}}class bu{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return new oe(t,this.data,this.fieldMask,e,this.fieldTransforms)}}function Du(r){switch(r){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw M(40011,{Ec:r})}}class ti{constructor(t,e,n,i,o,u){this.settings=t,this.databaseId=e,this.serializer=n,this.ignoreUndefinedProperties=i,o===void 0&&this.Ac(),this.fieldTransforms=o||[],this.fieldMask=u||[]}get path(){return this.settings.path}get Ec(){return this.settings.Ec}Rc(t){return new ti(Object.assign(Object.assign({},this.settings),t),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}Vc(t){var e;const n=(e=this.path)===null||e===void 0?void 0:e.child(t),i=this.Rc({path:n,mc:!1});return i.fc(t),i}gc(t){var e;const n=(e=this.path)===null||e===void 0?void 0:e.child(t),i=this.Rc({path:n,mc:!1});return i.Ac(),i}yc(t){return this.Rc({path:void 0,mc:!0})}wc(t){return fr(t,this.settings.methodName,this.settings.Sc||!1,this.path,this.settings.bc)}contains(t){return this.fieldMask.find((e=>t.isPrefixOf(e)))!==void 0||this.fieldTransforms.find((e=>t.isPrefixOf(e.field)))!==void 0}Ac(){if(this.path)for(let t=0;t<this.path.length;t++)this.fc(this.path.get(t))}fc(t){if(t.length===0)throw this.wc("Document fields must not be empty");if(Du(this.Ec)&&qd.test(t))throw this.wc('Document fields cannot begin and end with "__"')}}class Bd{constructor(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.serializer=n||wr(t)}Dc(t,e,n,i=!1){return new ti({Ec:t,methodName:e,bc:n,path:ct.emptyPath(),mc:!1,Sc:i},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function zd(r){const t=r._freezeSettings(),e=wr(r._databaseId);return new Bd(r._databaseId,!!t.ignoreUndefinedProperties,e)}function $d(r,t,e,n,i,o={}){const u=r.Dc(o.merge||o.mergeFields?2:0,t,e,i);ei("Data must be an object, but it was:",u,n);const c=Nu(n,u);let h,f;if(o.merge)h=new wt(u.fieldMask),f=u.fieldTransforms;else if(o.mergeFields){const p=[];for(const E of o.mergeFields){const R=vs(t,E,e);if(!u.contains(R))throw new k(P.INVALID_ARGUMENT,`Field '${R}' is specified in your field mask but missing from your input data.`);xu(p,R)||p.push(R)}h=new wt(p),f=u.fieldTransforms.filter((E=>h.covers(E.field)))}else h=null,f=u.fieldTransforms;return new jd(new It(c),h,f)}class Rn extends Zs{_toFieldTransform(t){if(t.Ec!==2)throw t.Ec===1?t.wc(`${this._methodName}() can only appear at the top level of your update data`):t.wc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return t.fieldMask.push(t.path),null}isEqual(t){return t instanceof Rn}}function Gd(r,t,e,n){const i=r.Dc(1,t,e);ei("Data must be an object, but it was:",i,n);const o=[],u=It.empty();ie(n,((h,f)=>{const p=ni(t,h,e);f=kt(f);const E=i.gc(p);if(f instanceof Rn)o.push(p);else{const R=Cr(f,E);R!=null&&(o.push(p),u.set(p,R))}}));const c=new wt(o);return new bu(u,c,i.fieldTransforms)}function Kd(r,t,e,n,i,o){const u=r.Dc(1,t,e),c=[vs(t,n,e)],h=[i];if(o.length%2!=0)throw new k(P.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let R=0;R<o.length;R+=2)c.push(vs(t,o[R])),h.push(o[R+1]);const f=[],p=It.empty();for(let R=c.length-1;R>=0;--R)if(!xu(f,c[R])){const S=c[R];let D=h[R];D=kt(D);const x=u.gc(S);if(D instanceof Rn)f.push(S);else{const b=Cr(D,x);b!=null&&(f.push(S),p.set(S,b))}}const E=new wt(f);return new bu(p,E,u.fieldTransforms)}function Cr(r,t){if(ku(r=kt(r)))return ei("Unsupported field value:",t,r),Nu(r,t);if(r instanceof Zs)return(function(n,i){if(!Du(i.Ec))throw i.wc(`${n._methodName}() can only be used with update() and set()`);if(!i.path)throw i.wc(`${n._methodName}() is not currently supported inside arrays`);const o=n._toFieldTransform(i);o&&i.fieldTransforms.push(o)})(r,t),null;if(r===void 0&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),r instanceof Array){if(t.settings.mc&&t.Ec!==4)throw t.wc("Nested arrays are not supported");return(function(n,i){const o=[];let u=0;for(const c of n){let h=Cr(c,i.yc(u));h==null&&(h={nullValue:"NULL_VALUE"}),o.push(h),u++}return{arrayValue:{values:o}}})(r,t)}return(function(n,i){if((n=kt(n))===null)return{nullValue:"NULL_VALUE"};if(typeof n=="number")return kc(i.serializer,n);if(typeof n=="boolean")return{booleanValue:n};if(typeof n=="string")return{stringValue:n};if(n instanceof Date){const o=W.fromDate(n);return{timestampValue:ur(i.serializer,o)}}if(n instanceof W){const o=new W(n.seconds,1e3*Math.floor(n.nanoseconds/1e3));return{timestampValue:ur(i.serializer,o)}}if(n instanceof Dt)return{geoPointValue:{latitude:n.latitude,longitude:n.longitude}};if(n instanceof Rt)return{bytesValue:Za(i.serializer,n._byteString)};if(n instanceof rt){const o=i.databaseId,u=n.firestore._databaseId;if(!u.isEqual(o))throw i.wc(`Document reference is for database ${u.projectId}/${u.database} but should be for database ${o.projectId}/${o.database}`);return{referenceValue:Os(n.firestore._databaseId||i.databaseId,n._key.path)}}if(n instanceof Nt)return(function(u,c){return{mapValue:{fields:{[Ca]:{stringValue:ba},[rr]:{arrayValue:{values:u.toArray().map((f=>{if(typeof f!="number")throw c.wc("VectorValues must only contain numeric values.");return Ds(c.serializer,f)}))}}}}}})(n,i);throw i.wc(`Unsupported field value: ${Rs(n)}`)})(r,t)}function Nu(r,t){const e={};return Aa(r)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):ie(r,((n,i)=>{const o=Cr(i,t.Vc(n));o!=null&&(e[n]=o)})),{mapValue:{fields:e}}}function ku(r){return!(typeof r!="object"||r===null||r instanceof Array||r instanceof Date||r instanceof W||r instanceof Dt||r instanceof Rt||r instanceof rt||r instanceof Zs||r instanceof Nt)}function ei(r,t,e){if(!ku(e)||!va(e)){const n=Rs(e);throw n==="an object"?t.wc(r+" a custom object"):t.wc(r+" "+n)}}function vs(r,t,e){if((t=kt(t))instanceof Sr)return t._internalPath;if(typeof t=="string")return ni(r,t);throw fr("Field path arguments must be of type string or ",r,!1,void 0,e)}const Qd=new RegExp("[~\\*/\\[\\]]");function ni(r,t,e){if(t.search(Qd)>=0)throw fr(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,r,!1,void 0,e);try{return new Sr(...t.split("."))._internalPath}catch{throw fr(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,r,!1,void 0,e)}}function fr(r,t,e,n,i){const o=n&&!n.isEmpty(),u=i!==void 0;let c=`Function ${t}() called with invalid data`;e&&(c+=" (via `toFirestore()`)"),c+=". ";let h="";return(o||u)&&(h+=" (found",o&&(h+=` in field ${n}`),u&&(h+=` in document ${i}`),h+=")"),new k(P.INVALID_ARGUMENT,c+r+h)}function xu(r,t){return r.some((e=>e.isEqual(t)))}/**
1613
+ * @license
1614
+ * Copyright 2020 Google LLC
1615
+ *
1616
+ * Licensed under the Apache License, Version 2.0 (the "License");
1617
+ * you may not use this file except in compliance with the License.
1618
+ * You may obtain a copy of the License at
1619
+ *
1620
+ * http://www.apache.org/licenses/LICENSE-2.0
1621
+ *
1622
+ * Unless required by applicable law or agreed to in writing, software
1623
+ * distributed under the License is distributed on an "AS IS" BASIS,
1624
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1625
+ * See the License for the specific language governing permissions and
1626
+ * limitations under the License.
1627
+ */class Ou{constructor(t,e,n,i,o){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=i,this._converter=o}get id(){return this._key.path.lastSegment()}get ref(){return new rt(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const t=new Wd(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}}get(t){if(this._document){const e=this._document.data.field(Mu("DocumentSnapshot.get",t));if(e!==null)return this._userDataWriter.convertValue(e)}}}class Wd extends Ou{data(){return super.data()}}function Mu(r,t){return typeof t=="string"?ni(r,t):t instanceof Sr?t._internalPath:t._delegate._internalPath}/**
1628
+ * @license
1629
+ * Copyright 2020 Google LLC
1630
+ *
1631
+ * Licensed under the Apache License, Version 2.0 (the "License");
1632
+ * you may not use this file except in compliance with the License.
1633
+ * You may obtain a copy of the License at
1634
+ *
1635
+ * http://www.apache.org/licenses/LICENSE-2.0
1636
+ *
1637
+ * Unless required by applicable law or agreed to in writing, software
1638
+ * distributed under the License is distributed on an "AS IS" BASIS,
1639
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1640
+ * See the License for the specific language governing permissions and
1641
+ * limitations under the License.
1642
+ */function Fu(r){if(r.limitType==="L"&&r.explicitOrderBy.length===0)throw new k(P.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Hd{convertValue(t,e="none"){switch(ne(t)){case 0:return null;case 1:return t.booleanValue;case 2:return Z(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(ee(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 11:return this.convertObject(t.mapValue,e);case 10:return this.convertVectorValue(t.mapValue);default:throw M(62114,{value:t})}}convertObject(t,e){return this.convertObjectMap(t.fields,e)}convertObjectMap(t,e="none"){const n={};return ie(t,((i,o)=>{n[i]=this.convertValue(o,e)})),n}convertVectorValue(t){var e,n,i;const o=(i=(n=(e=t.fields)===null||e===void 0?void 0:e[rr].arrayValue)===null||n===void 0?void 0:n.values)===null||i===void 0?void 0:i.map((u=>Z(u.doubleValue)));return new Nt(o)}convertGeoPoint(t){return new Dt(Z(t.latitude),Z(t.longitude))}convertArray(t,e){return(t.values||[]).map((n=>this.convertValue(n,e)))}convertServerTimestamp(t,e){switch(e){case"previous":const n=gr(t);return n==null?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(dn(t));default:return null}}convertTimestamp(t){const e=te(t);return new W(e.seconds,e.nanos)}convertDocumentKey(t,e){const n=X.fromString(t);G(iu(n),9688,{name:t});const i=new mn(n.get(1),n.get(3)),o=new O(n.popFirst(5));return i.isEqual(e)||zt(`Document ${o} contains a document reference within a different database (${i.projectId}/${i.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),o}}/**
1643
+ * @license
1644
+ * Copyright 2020 Google LLC
1645
+ *
1646
+ * Licensed under the Apache License, Version 2.0 (the "License");
1647
+ * you may not use this file except in compliance with the License.
1648
+ * You may obtain a copy of the License at
1649
+ *
1650
+ * http://www.apache.org/licenses/LICENSE-2.0
1651
+ *
1652
+ * Unless required by applicable law or agreed to in writing, software
1653
+ * distributed under the License is distributed on an "AS IS" BASIS,
1654
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1655
+ * See the License for the specific language governing permissions and
1656
+ * limitations under the License.
1657
+ */function Xd(r,t,e){let n;return n=r?e&&(e.merge||e.mergeFields)?r.toFirestore(t,e):r.toFirestore(t):t,n}class sn{constructor(t,e){this.hasPendingWrites=t,this.fromCache=e}isEqual(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache}}class de extends Ou{constructor(t,e,n,i,o,u){super(t,e,n,i,u),this._firestore=t,this._firestoreImpl=t,this.metadata=o}exists(){return super.exists()}data(t={}){if(this._document){if(this._converter){const e=new er(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(e,t)}return this._userDataWriter.convertValue(this._document.data.value,t.serverTimestamps)}}get(t,e={}){if(this._document){const n=this._document.data.field(Mu("DocumentSnapshot.get",t));if(n!==null)return this._userDataWriter.convertValue(n,e.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new k(P.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const t=this._document,e={};return e.type=de._jsonSchemaVersion,e.bundle="",e.bundleSource="DocumentSnapshot",e.bundleName=this._key.toString(),!t||!t.isValidDocument()||!t.isFoundDocument()?e:(this._userDataWriter.convertObjectMap(t.data.value.mapValue.fields,"previous"),e.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),e)}}de._jsonSchemaVersion="firestore/documentSnapshot/1.0",de._jsonSchema={type:et("string",de._jsonSchemaVersion),bundleSource:et("string","DocumentSnapshot"),bundleName:et("string"),bundle:et("string")};class er extends de{data(t={}){return super.data(t)}}class fe{constructor(t,e,n,i){this._firestore=t,this._userDataWriter=e,this._snapshot=i,this.metadata=new sn(i.hasPendingWrites,i.fromCache),this.query=n}get docs(){const t=[];return this.forEach((e=>t.push(e))),t}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(t,e){this._snapshot.docs.forEach((n=>{t.call(e,new er(this._firestore,this._userDataWriter,n.key,n,new sn(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(t={}){const e=!!t.includeMetadataChanges;if(e&&this._snapshot.excludesMetadataChanges)throw new k(P.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=(function(i,o){if(i._snapshot.oldDocs.isEmpty()){let u=0;return i._snapshot.docChanges.map((c=>{const h=new er(i._firestore,i._userDataWriter,c.doc.key,c.doc,new sn(i._snapshot.mutatedKeys.has(c.doc.key),i._snapshot.fromCache),i.query.converter);return c.doc,{type:"added",doc:h,oldIndex:-1,newIndex:u++}}))}{let u=i._snapshot.oldDocs;return i._snapshot.docChanges.filter((c=>o||c.type!==3)).map((c=>{const h=new er(i._firestore,i._userDataWriter,c.doc.key,c.doc,new sn(i._snapshot.mutatedKeys.has(c.doc.key),i._snapshot.fromCache),i.query.converter);let f=-1,p=-1;return c.type!==0&&(f=u.indexOf(c.doc.key),u=u.delete(c.doc.key)),c.type!==1&&(u=u.add(c.doc),p=u.indexOf(c.doc.key)),{type:Yd(c.type),doc:h,oldIndex:f,newIndex:p}}))}})(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new k(P.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const t={};t.type=fe._jsonSchemaVersion,t.bundleSource="QuerySnapshot",t.bundleName=ws.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const e=[],n=[],i=[];return this.docs.forEach((o=>{o._document!==null&&(e.push(o._document),n.push(this._userDataWriter.convertObjectMap(o._document.data.value.mapValue.fields,"previous")),i.push(o.ref.path))})),t.bundle=(this._firestore,this.query._query,t.bundleName,"NOT SUPPORTED"),t}}function Yd(r){switch(r){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return M(61501,{type:r})}}/**
1658
+ * @license
1659
+ * Copyright 2020 Google LLC
1660
+ *
1661
+ * Licensed under the Apache License, Version 2.0 (the "License");
1662
+ * you may not use this file except in compliance with the License.
1663
+ * You may obtain a copy of the License at
1664
+ *
1665
+ * http://www.apache.org/licenses/LICENSE-2.0
1666
+ *
1667
+ * Unless required by applicable law or agreed to in writing, software
1668
+ * distributed under the License is distributed on an "AS IS" BASIS,
1669
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1670
+ * See the License for the specific language governing permissions and
1671
+ * limitations under the License.
1672
+ */function Jd(r){r=Bt(r,rt);const t=Bt(r.firestore,Ne);return xd(wn(t),r._key).then((e=>Lu(t,r,e)))}fe._jsonSchemaVersion="firestore/querySnapshot/1.0",fe._jsonSchema={type:et("string",fe._jsonSchemaVersion),bundleSource:et("string","QuerySnapshot"),bundleName:et("string"),bundle:et("string")};class ri extends Hd{constructor(t){super(),this.firestore=t}convertBytes(t){return new Rt(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);return new rt(this.firestore,null,e)}}function Zd(r){r=Bt(r,An);const t=Bt(r.firestore,Ne),e=wn(t),n=new ri(t);return Fu(r._query),Od(e,r._query).then((i=>new fe(t,n,r,i)))}function tf(r,...t){var e,n,i;r=kt(r);let o={includeMetadataChanges:!1,source:"default"},u=0;typeof t[u]!="object"||oa(t[u])||(o=t[u++]);const c={includeMetadataChanges:o.includeMetadataChanges,source:o.source};if(oa(t[u])){const E=t[u];t[u]=(e=E.next)===null||e===void 0?void 0:e.bind(E),t[u+1]=(n=E.error)===null||n===void 0?void 0:n.bind(E),t[u+2]=(i=E.complete)===null||i===void 0?void 0:i.bind(E)}let h,f,p;if(r instanceof rt)f=Bt(r.firestore,Ne),p=yr(r._key.path),h={next:E=>{t[u]&&t[u](Lu(f,r,E))},error:t[u+1],complete:t[u+2]};else{const E=Bt(r,An);f=Bt(E.firestore,Ne),p=E._query;const R=new ri(f);h={next:S=>{t[u]&&t[u](new fe(f,R,E,S))},error:t[u+1],complete:t[u+2]},Fu(r._query)}return(function(R,S,D,x){const b=new Js(x),$=new Hs(S,b,D);return R.asyncQueue.enqueueAndForget((async()=>Ks(await dr(R),$))),()=>{b.Ou(),R.asyncQueue.enqueueAndForget((async()=>Qs(await dr(R),$)))}})(wn(f),p,c,h)}function ef(r,t){return(function(n,i){const o=new jt;return n.asyncQueue.enqueueAndForget((async()=>Id(await kd(n),i,o))),o.promise})(wn(r),t)}function Lu(r,t,e){const n=e.docs.get(t._key),i=new ri(r);return new de(r,i,t._key,n,new sn(e.hasPendingWrites,e.fromCache),t.converter)}/**
1673
+ * @license
1674
+ * Copyright 2020 Google LLC
1675
+ *
1676
+ * Licensed under the Apache License, Version 2.0 (the "License");
1677
+ * you may not use this file except in compliance with the License.
1678
+ * You may obtain a copy of the License at
1679
+ *
1680
+ * http://www.apache.org/licenses/LICENSE-2.0
1681
+ *
1682
+ * Unless required by applicable law or agreed to in writing, software
1683
+ * distributed under the License is distributed on an "AS IS" BASIS,
1684
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1685
+ * See the License for the specific language governing permissions and
1686
+ * limitations under the License.
1687
+ */class nf{constructor(t,e){this._firestore=t,this._commitHandler=e,this._mutations=[],this._committed=!1,this._dataReader=zd(t)}set(t,e,n){this._verifyNotCommitted();const i=ss(t,this._firestore),o=Xd(i.converter,e,n),u=$d(this._dataReader,"WriteBatch.set",i._key,o,i.converter!==null,n);return this._mutations.push(u.toMutation(i._key,Vt.none())),this}update(t,e,n,...i){this._verifyNotCommitted();const o=ss(t,this._firestore);let u;return u=typeof(e=kt(e))=="string"||e instanceof Sr?Kd(this._dataReader,"WriteBatch.update",o._key,e,n,i):Gd(this._dataReader,"WriteBatch.update",o._key,e),this._mutations.push(u.toMutation(o._key,Vt.exists(!0))),this}delete(t){this._verifyNotCommitted();const e=ss(t,this._firestore);return this._mutations=this._mutations.concat(new Ns(e._key,Vt.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new k(P.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function ss(r,t){if((r=kt(r)).firestore!==t)throw new k(P.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return r}/**
1688
+ * @license
1689
+ * Copyright 2020 Google LLC
1690
+ *
1691
+ * Licensed under the Apache License, Version 2.0 (the "License");
1692
+ * you may not use this file except in compliance with the License.
1693
+ * You may obtain a copy of the License at
1694
+ *
1695
+ * http://www.apache.org/licenses/LICENSE-2.0
1696
+ *
1697
+ * Unless required by applicable law or agreed to in writing, software
1698
+ * distributed under the License is distributed on an "AS IS" BASIS,
1699
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1700
+ * See the License for the specific language governing permissions and
1701
+ * limitations under the License.
1702
+ */function rf(){return new Rn("deleteField")}/**
1703
+ * @license
1704
+ * Copyright 2020 Google LLC
1705
+ *
1706
+ * Licensed under the Apache License, Version 2.0 (the "License");
1707
+ * you may not use this file except in compliance with the License.
1708
+ * You may obtain a copy of the License at
1709
+ *
1710
+ * http://www.apache.org/licenses/LICENSE-2.0
1711
+ *
1712
+ * Unless required by applicable law or agreed to in writing, software
1713
+ * distributed under the License is distributed on an "AS IS" BASIS,
1714
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1715
+ * See the License for the specific language governing permissions and
1716
+ * limitations under the License.
1717
+ */function sf(r){return wn(r=Bt(r,Ne)),new nf(r,(t=>ef(r,t)))}(function(t,e=!0){(function(i){ke=i})(Ml),Fl(new Ll("firestore",((n,{instanceIdentifier:i,options:o})=>{const u=n.getProvider("app").getImmediate(),c=new Ne(new Gl(n.getProvider("auth-internal")),new Wl(u,n.getProvider("app-check-internal")),(function(f,p){if(!Object.prototype.hasOwnProperty.apply(f.options,["projectId"]))throw new k(P.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new mn(f.options.projectId,p)})(u,i),u);return o=Object.assign({useFetchStreams:e},o),c._setSettings(o),c}),"PUBLIC").setMultipleInstances(!0)),io(ao,uo,t),io(ao,uo,"esm2017")})();function of(r){const t=()=>Tl(()=>import("./index.esm-BFc7vwnl.js"),__vite__mapDeps([0,1]),import.meta.url),e=n=>(n==null?void 0:n.code)??"";return{async put(n,i,o){const u=await t();await u.uploadBytes(u.ref(u.getStorage(r),n),i,o?{contentType:o}:void 0)},async get(n){const i=await t();try{return new Uint8Array(await i.getBytes(i.ref(i.getStorage(r),n)))}catch(o){if(e(o)==="storage/object-not-found")return null;throw o}},async delete(n){const i=await t();try{await i.deleteObject(i.ref(i.getStorage(r),n))}catch(o){if(e(o)!=="storage/object-not-found")throw o}}}}function af(r){return`agentcrm-${r.projectId??"default"}`}function uf(r){const t=af(r);return ql().find(e=>e.name===t)??jl(r,t)}const aa=new WeakMap;function lf(r){let t=aa.get(r);if(!t){try{t=Fd(r,{ignoreUndefinedProperties:!0})}catch{t=Ld(r)}aa.set(r,t)}return t}function cn(r){if(r instanceof W)return r.toMillis();if(Array.isArray(r))return r.map(cn);if(r&&typeof r=="object"&&Object.getPrototypeOf(r)===Object.prototype){const t={};for(const[e,n]of Object.entries(r))t[e]=cn(n);return t}return r}function tn(r){return r?{uid:r.uid,email:r.email,displayName:r.displayName,emailVerified:r.emailVerified,photoURL:r.photoURL}:null}function gf(r){const t=uf(r),e=lf(t),n=vl(t),i=new Promise(o=>{const u=so(n,()=>{u(),o()})});return{...r.storageBucket?{storage:of(t)}:{},async listCollection(o){return(await Zd(ea(e,o))).docs.map(c=>({id:c.id,data:cn(c.data())}))},watchCollection(o,u,c){return tf(ea(e,o),h=>u(h.docs.map(f=>({id:f.id,data:cn(f.data())}))),c)},async getDoc(o,u){const c=await Jd(na(e,o,u));return c.exists()?cn(c.data()):null},async commit(o){const u=sf(e);for(const c of o){const h=na(e,c.collection,c.id);if(c.type==="set")u.set(h,c.data);else if(c.type==="delete")u.delete(h);else{const f={};for(const[p,E]of Object.entries(c.data))f[p]=E===Bl?rf():E;u.update(h,f)}}await u.commit()},auth:{async currentUser(){return await i,tn(n.currentUser)},onChange(o){return so(n,u=>o(tn(u)))},async signInWithPassword(o,u){const c=await Vl(n,o.trim(),u);return tn(c.user)},async signInWithGoogle(){const o=new Rl;o.setCustomParameters({prompt:"select_account"});const u=await Pl(n,o);return tn(u.user)},async sendPasswordReset(o){await wl(n,o.trim())},async sendVerificationEmail(){n.currentUser&&await Al(n.currentUser,{url:`${window.location.origin}${window.location.pathname}`})},async reload(){const o=n.currentUser;return o?(await o.reload(),await o.getIdToken(!0),tn(n.currentUser)):null},async signOut(){await Il(n)}}}}export{gf as createSdkFirebaseApi,uf as getFirebaseApp};