@iebh/tera-fy 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugin.vue2.es2019.js +10 -10
- package/dist/terafy.es2019.js +1 -1
- package/dist/terafy.js +1 -1
- package/lib/projectFile.js +1 -1
- package/lib/syncro.js +46 -6
- package/lib/terafy.server.js +7 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var jP=Object.create;var Za=Object.defineProperty;var $P=Object.getOwnPropertyDescriptor;var qP=Object.getOwnPropertyNames;var zP=Object.getPrototypeOf,GP=Object.prototype.hasOwnProperty;var KP=(r,e,t)=>e in r?Za(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var WP=(r,e)=>()=>(r&&(e=r(r=0)),e);var cr=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),HP=(r,e)=>{for(var t in e)Za(r,t,{get:e[t],enumerable:!0})},zy=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of qP(e))!GP.call(r,s)&&s!==t&&Za(r,s,{get:()=>e[s],enumerable:!(n=$P(e,s))||n.enumerable});return r};var Dd=(r,e,t)=>(t=r!=null?jP(zP(r)):{},zy(e||!r||!r.__esModule?Za(t,"default",{value:r,enumerable:!0}):t,r)),QP=r=>zy(Za({},"__esModule",{value:!0}),r);var gt=(r,e,t)=>KP(r,typeof e!="symbol"?e+"":e,t);var gs={};HP(gs,{Headers:()=>Eg,Request:()=>LF,Response:()=>MF,default:()=>Tg,fetch:()=>VF});var NF,ta,VF,Tg,Eg,LF,MF,Ei=WP(()=>{"use strict";NF=function(){if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;throw new Error("unable to locate global object")},ta=NF(),VF=ta.fetch,Tg=ta.fetch.bind(ta),Eg=ta.Headers,LF=ta.Request,MF=ta.Response});var Ag=cr(xg=>{"use strict";Object.defineProperty(xg,"__esModule",{value:!0});var Ig=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};xg.default=Ig});var Rg=cr(Vu=>{"use strict";var sE=Vu&&Vu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Vu,"__esModule",{value:!0});var UF=sE((Ei(),QP(gs))),BF=sE(Ag()),Sg=class{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.isMaybeSingle=e.isMaybeSingle,e.fetch?this.fetch=e.fetch:typeof fetch=="undefined"?this.fetch=UF.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=Object.assign({},this.headers),this.headers[e]=t,this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");let n=this.fetch,s=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async a=>{var c,h,f;let m=null,_=null,E=null,I=a.status,k=a.statusText;if(a.ok){if(this.method!=="HEAD"){let J=await a.text();J===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?_=J:_=JSON.parse(J))}let G=(c=this.headers.Prefer)===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),j=(h=a.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");G&&j&&j.length>1&&(E=parseInt(j[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(_)&&(_.length>1?(m={code:"PGRST116",details:`Results contain ${_.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},_=null,E=null,I=406,k="Not Acceptable"):_.length===1?_=_[0]:_=null)}else{let G=await a.text();try{m=JSON.parse(G),Array.isArray(m)&&a.status===404&&(_=[],m=null,I=200,k="OK")}catch{a.status===404&&G===""?(I=204,k="No Content"):m={message:G}}if(m&&this.isMaybeSingle&&(!((f=m==null?void 0:m.details)===null||f===void 0)&&f.includes("0 rows"))&&(m=null,I=200,k="OK"),m&&this.shouldThrowOnError)throw new BF.default(m)}return{error:m,data:_,count:E,status:I,statusText:k}});return this.shouldThrowOnError||(s=s.catch(a=>{var c,h,f;return{error:{message:`${(c=a==null?void 0:a.name)!==null&&c!==void 0?c:"FetchError"}: ${a==null?void 0:a.message}`,details:`${(h=a==null?void 0:a.stack)!==null&&h!==void 0?h:""}`,hint:"",code:`${(f=a==null?void 0:a.code)!==null&&f!==void 0?f:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}};Vu.default=Sg});var Cg=cr(Lu=>{"use strict";var jF=Lu&&Lu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Lu,"__esModule",{value:!0});var $F=jF(Rg()),Pg=class extends $F.default{select(e){let t=!1,n=(e!=null?e:"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",n),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:t=!0,nullsFirst:n,foreignTable:s,referencedTable:a=s}={}){let c=a?`${a}.order`:"order",h=this.url.searchParams.get(c);return this.url.searchParams.set(c,`${h?`${h},`:""}${e}.${t?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:n=t}={}){let s=typeof n=="undefined"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:n,referencedTable:s=n}={}){let a=typeof s=="undefined"?"offset":`${s}.offset`,c=typeof s=="undefined"?"limit":`${s}.limit`;return this.url.searchParams.set(a,`${e}`),this.url.searchParams.set(c,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.method==="GET"?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:t=!1,settings:n=!1,buffers:s=!1,wal:a=!1,format:c="text"}={}){var h;let f=[e?"analyze":null,t?"verbose":null,n?"settings":null,s?"buffers":null,a?"wal":null].filter(Boolean).join("|"),m=(h=this.headers.Accept)!==null&&h!==void 0?h:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${c}; for="${m}"; options=${f};`,c==="json"?this:this}rollback(){var e;return((e=this.headers.Prefer)!==null&&e!==void 0?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}};Lu.default=Pg});var tf=cr(Mu=>{"use strict";var qF=Mu&&Mu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Mu,"__esModule",{value:!0});var zF=qF(Cg()),Dg=class extends zF.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let n=Array.from(new Set(t)).map(s=>typeof s=="string"&&new RegExp("[,()]").test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:n,type:s}={}){let a="";s==="plain"?a="pl":s==="phrase"?a="ph":s==="websearch"&&(a="w");let c=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${a}fts${c}.${t}`),this}match(e){return Object.entries(e).forEach(([t,n])=>{this.url.searchParams.append(t,`eq.${n}`)}),this}not(e,t,n){return this.url.searchParams.append(e,`not.${t}.${n}`),this}or(e,{foreignTable:t,referencedTable:n=t}={}){let s=n?`${n}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,n){return this.url.searchParams.append(e,`${t}.${n}`),this}};Mu.default=Dg});var kg=cr(Uu=>{"use strict";var GF=Uu&&Uu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Uu,"__esModule",{value:!0});var Fu=GF(tf()),Og=class{constructor(e,{headers:t={},schema:n,fetch:s}){this.url=e,this.headers=t,this.schema=n,this.fetch=s}select(e,{head:t=!1,count:n}={}){let s=t?"HEAD":"GET",a=!1,c=(e!=null?e:"*").split("").map(h=>/\s/.test(h)&&!a?"":(h==='"'&&(a=!a),h)).join("");return this.url.searchParams.set("select",c),n&&(this.headers.Prefer=`count=${n}`),new Fu.default({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:t,defaultToNull:n=!0}={}){let s="POST",a=[];if(this.headers.Prefer&&a.push(this.headers.Prefer),t&&a.push(`count=${t}`),n||a.push("missing=default"),this.headers.Prefer=a.join(","),Array.isArray(e)){let c=e.reduce((h,f)=>h.concat(Object.keys(f)),[]);if(c.length>0){let h=[...new Set(c)].map(f=>`"${f}"`);this.url.searchParams.set("columns",h.join(","))}}return new Fu.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:t,ignoreDuplicates:n=!1,count:s,defaultToNull:a=!0}={}){let c="POST",h=[`resolution=${n?"ignore":"merge"}-duplicates`];if(t!==void 0&&this.url.searchParams.set("on_conflict",t),this.headers.Prefer&&h.push(this.headers.Prefer),s&&h.push(`count=${s}`),a||h.push("missing=default"),this.headers.Prefer=h.join(","),Array.isArray(e)){let f=e.reduce((m,_)=>m.concat(Object.keys(_)),[]);if(f.length>0){let m=[...new Set(f)].map(_=>`"${_}"`);this.url.searchParams.set("columns",m.join(","))}}return new Fu.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:t}={}){let n="PATCH",s=[];return this.headers.Prefer&&s.push(this.headers.Prefer),t&&s.push(`count=${t}`),this.headers.Prefer=s.join(","),new Fu.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){let t="DELETE",n=[];return e&&n.push(`count=${e}`),this.headers.Prefer&&n.unshift(this.headers.Prefer),this.headers.Prefer=n.join(","),new Fu.default({method:t,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}};Uu.default=Og});var oE=cr(rf=>{"use strict";Object.defineProperty(rf,"__esModule",{value:!0});rf.version=void 0;rf.version="0.0.0-automated"});var aE=cr(nf=>{"use strict";Object.defineProperty(nf,"__esModule",{value:!0});nf.DEFAULT_HEADERS=void 0;var KF=oE();nf.DEFAULT_HEADERS={"X-Client-Info":`postgrest-js/${KF.version}`}});var cE=cr(Bu=>{"use strict";var uE=Bu&&Bu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Bu,"__esModule",{value:!0});var WF=uE(kg()),HF=uE(tf()),QF=aE(),Ng=class r{constructor(e,{headers:t={},schema:n,fetch:s}={}){this.url=e,this.headers=Object.assign(Object.assign({},QF.DEFAULT_HEADERS),t),this.schemaName=n,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new WF.default(t,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new r(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:n=!1,get:s=!1,count:a}={}){let c,h=new URL(`${this.url}/rpc/${e}`),f;n||s?(c=n?"HEAD":"GET",Object.entries(t).filter(([_,E])=>E!==void 0).map(([_,E])=>[_,Array.isArray(E)?`{${E.join(",")}}`:`${E}`]).forEach(([_,E])=>{h.searchParams.append(_,E)})):(c="POST",f=t);let m=Object.assign({},this.headers);return a&&(m.Prefer=`count=${a}`),new HF.default({method:c,url:h,headers:m,schema:this.schemaName,body:f,fetch:this.fetch,allowEmpty:!1})}};Bu.default=Ng});var gE=cr(bt=>{"use strict";var ra=bt&&bt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(bt,"__esModule",{value:!0});bt.PostgrestError=bt.PostgrestBuilder=bt.PostgrestTransformBuilder=bt.PostgrestFilterBuilder=bt.PostgrestQueryBuilder=bt.PostgrestClient=void 0;var lE=ra(cE());bt.PostgrestClient=lE.default;var hE=ra(kg());bt.PostgrestQueryBuilder=hE.default;var fE=ra(tf());bt.PostgrestFilterBuilder=fE.default;var dE=ra(Cg());bt.PostgrestTransformBuilder=dE.default;var pE=ra(Rg());bt.PostgrestBuilder=pE.default;var mE=ra(Ag());bt.PostgrestError=mE.default;bt.default={PostgrestClient:lE.default,PostgrestQueryBuilder:hE.default,PostgrestFilterBuilder:fE.default,PostgrestTransformBuilder:dE.default,PostgrestBuilder:pE.default,PostgrestError:mE.default}});var xE=cr((s3,IE)=>{"use strict";IE.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var uI=cr((fa,nc)=>{(function(){var r,e="4.17.21",t=200,n="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",a="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",h=500,f="__lodash_placeholder__",m=1,_=2,E=4,I=1,k=2,B=1,G=2,j=4,J=8,ee=16,re=32,le=64,de=128,ie=256,C=512,A=30,R="...",D=800,V=16,M=1,S=2,dr=3,Wt=1/0,Pr=9007199254740991,Ai=17976931348623157e292,Cr=NaN,Lt=4294967295,ac=Lt-1,vf=Lt>>>1,Dr=[["ary",de],["bind",B],["bindKey",G],["curry",J],["curryRight",ee],["flip",C],["partial",re],["partialRight",le],["rearg",ie]],Ke="[object Arguments]",Cs="[object Array]",Si="[object AsyncFunction]",Ri="[object Boolean]",pr="[object Date]",wf="[object DOMException]",Ds="[object Error]",rn="[object Function]",Pi="[object GeneratorFunction]",Pt="[object Map]",nn="[object Number]",pa="[object Null]",Ht="[object Object]",ma="[object Promise]",uc="[object Proxy]",Ci="[object RegExp]",Mt="[object Set]",Ln="[object String]",Mn="[object Symbol]",cc="[object Undefined]",Di="[object WeakMap]",ga="[object WeakSet]",sn="[object ArrayBuffer]",Or="[object DataView]",nt="[object Float32Array]",ut="[object Float64Array]",Fn="[object Int8Array]",Os="[object Int16Array]",ks="[object Int32Array]",_a="[object Uint8Array]",on="[object Uint8ClampedArray]",Ns="[object Uint16Array]",Vs="[object Uint32Array]",ya=/\b__p \+= '';/g,bf=/\b(__p \+=) '' \+/g,Tf=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ls=/&(?:amp|lt|gt|quot|#39);/g,va=/[&<>"']/g,lc=RegExp(Ls.source),Oi=RegExp(va.source),wa=/<%-([\s\S]+?)%>/g,ba=/<%([\s\S]+?)%>/g,kr=/<%=([\s\S]+?)%>/g,hc=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ms=/^\w*$/,fc=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,an=/[\\^$.*+?()[\]{}|]/g,dc=RegExp(an.source),ct=/^\s+/,pc=/\s/,ki=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ni=/\{\n\/\* \[wrapped with (.+)\] \*/,Ef=/,? & /,If=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Un=/[()=,{}\[\]\/\s]/,xf=/\\(\\)?/g,Af=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Vi=/\w*$/,mc=/^[-+]0x[0-9a-f]+$/i,Ta=/^0b[01]+$/i,Fs=/^\[object .+?Constructor\]$/,Nr=/^0o[0-7]+$/i,gc=/^(?:0|[1-9]\d*)$/,_c=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Bn=/($^)/,Ea=/['\n\r\u2028\u2029\\]/g,Li="\\ud800-\\udfff",yc="\\u0300-\\u036f",Sf="\\ufe20-\\ufe2f",Us="\\u20d0-\\u20ff",Ia=yc+Sf+Us,Bs="\\u2700-\\u27bf",jn="a-z\\xdf-\\xf6\\xf8-\\xff",un="\\xac\\xb1\\xd7\\xf7",xa="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Rf="\\u2000-\\u206f",vc=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Aa="A-Z\\xc0-\\xd6\\xd8-\\xde",Sa="\\ufe0e\\ufe0f",js=un+xa+Rf+vc,Mi="['\u2019]",wc="["+Li+"]",Ra="["+js+"]",$s="["+Ia+"]",bc="\\d+",Tc="["+Bs+"]",Pa="["+jn+"]",Ec="[^"+Li+js+bc+Bs+jn+Aa+"]",mr="\\ud83c[\\udffb-\\udfff]",gr="(?:"+$s+"|"+mr+")",Fi="[^"+Li+"]",$n="(?:\\ud83c[\\udde6-\\uddff]){2}",qs="[\\ud800-\\udbff][\\udc00-\\udfff]",Ce="["+Aa+"]",Ui="\\u200d",qn="(?:"+Pa+"|"+Ec+")",Bi="(?:"+Ce+"|"+Ec+")",Ic="(?:"+Mi+"(?:d|ll|m|re|s|t|ve))?",Ca="(?:"+Mi+"(?:D|LL|M|RE|S|T|VE))?",xc=gr+"?",Ac="["+Sa+"]?",Pf="(?:"+Ui+"(?:"+[Fi,$n,qs].join("|")+")"+Ac+xc+")*",Cf="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ji="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",_r=Ac+xc+Pf,Sc="(?:"+[Tc,$n,qs].join("|")+")"+_r,Rc="(?:"+[Fi+$s+"?",$s,$n,qs,wc].join("|")+")",Pc=RegExp(Mi,"g"),zn=RegExp($s,"g"),Da=RegExp(mr+"(?="+mr+")|"+Rc+_r,"g"),Df=RegExp([Ce+"?"+Pa+"+"+Ic+"(?="+[Ra,Ce,"$"].join("|")+")",Bi+"+"+Ca+"(?="+[Ra,Ce+qn,"$"].join("|")+")",Ce+"?"+qn+"+"+Ic,Ce+"+"+Ca,ji,Cf,bc,Sc].join("|"),"g"),Of=RegExp("["+Ui+Li+Ia+Sa+"]"),Vr=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,kf=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Nf=-1,Oe={};Oe[nt]=Oe[ut]=Oe[Fn]=Oe[Os]=Oe[ks]=Oe[_a]=Oe[on]=Oe[Ns]=Oe[Vs]=!0,Oe[Ke]=Oe[Cs]=Oe[sn]=Oe[Ri]=Oe[Or]=Oe[pr]=Oe[Ds]=Oe[rn]=Oe[Pt]=Oe[nn]=Oe[Ht]=Oe[Ci]=Oe[Mt]=Oe[Ln]=Oe[Di]=!1;var ke={};ke[Ke]=ke[Cs]=ke[sn]=ke[Or]=ke[Ri]=ke[pr]=ke[nt]=ke[ut]=ke[Fn]=ke[Os]=ke[ks]=ke[Pt]=ke[nn]=ke[Ht]=ke[Ci]=ke[Mt]=ke[Ln]=ke[Mn]=ke[_a]=ke[on]=ke[Ns]=ke[Vs]=!0,ke[Ds]=ke[rn]=ke[Di]=!1;var Cc={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},$i={"&":"&","<":"<",">":">",'"':""","'":"'"},qi={"&":"&","<":"<",">":">",""":'"',"'":"'"},Dc={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Oa=parseFloat,ze=parseInt,Oc=typeof global=="object"&&global&&global.Object===Object&&global,Vf=typeof self=="object"&&self&&self.Object===Object&&self,Xe=Oc||Vf||Function("return this")(),zs=typeof fa=="object"&&fa&&!fa.nodeType&&fa,Lr=zs&&typeof nc=="object"&&nc&&!nc.nodeType&&nc,zi=Lr&&Lr.exports===zs,Gs=zi&&Oc.process,He=function(){try{var O=Lr&&Lr.require&&Lr.require("util").types;return O||Gs&&Gs.binding&&Gs.binding("util")}catch{}}(),ka=He&&He.isArrayBuffer,kc=He&&He.isDate,Gn=He&&He.isMap,Na=He&&He.isRegExp,Ks=He&&He.isSet,Gi=He&&He.isTypedArray;function Et(O,$,U){switch(U.length){case 0:return O.call($);case 1:return O.call($,U[0]);case 2:return O.call($,U[0],U[1]);case 3:return O.call($,U[0],U[1],U[2])}return O.apply($,U)}function Ws(O,$,U,Z){for(var he=-1,Ne=O==null?0:O.length;++he<Ne;){var ft=O[he];$(Z,ft,U(ft),O)}return Z}function Ft(O,$){for(var U=-1,Z=O==null?0:O.length;++U<Z&&$(O[U],U,O)!==!1;);return O}function Nc(O,$){for(var U=O==null?0:O.length;U--&&$(O[U],U,O)!==!1;);return O}function Kn(O,$){for(var U=-1,Z=O==null?0:O.length;++U<Z;)if(!$(O[U],U,O))return!1;return!0}function yr(O,$){for(var U=-1,Z=O==null?0:O.length,he=0,Ne=[];++U<Z;){var ft=O[U];$(ft,U,O)&&(Ne[he++]=ft)}return Ne}function Ki(O,$){var U=O==null?0:O.length;return!!U&&wr(O,$,0)>-1}function Wi(O,$,U){for(var Z=-1,he=O==null?0:O.length;++Z<he;)if(U($,O[Z]))return!0;return!1}function Fe(O,$){for(var U=-1,Z=O==null?0:O.length,he=Array(Z);++U<Z;)he[U]=$(O[U],U,O);return he}function vr(O,$){for(var U=-1,Z=$.length,he=O.length;++U<Z;)O[he+U]=$[U];return O}function Wn(O,$,U,Z){var he=-1,Ne=O==null?0:O.length;for(Z&&Ne&&(U=O[++he]);++he<Ne;)U=$(U,O[he],he,O);return U}function Vc(O,$,U,Z){var he=O==null?0:O.length;for(Z&&he&&(U=O[--he]);he--;)U=$(U,O[he],he,O);return U}function Hs(O,$){for(var U=-1,Z=O==null?0:O.length;++U<Z;)if($(O[U],U,O))return!0;return!1}var cn=Mr("length");function Lc(O){return O.split("")}function Mc(O){return O.match(If)||[]}function Va(O,$,U){var Z;return U(O,function(he,Ne,ft){if($(he,Ne,ft))return Z=Ne,!1}),Z}function Hi(O,$,U,Z){for(var he=O.length,Ne=U+(Z?1:-1);Z?Ne--:++Ne<he;)if($(O[Ne],Ne,O))return Ne;return-1}function wr(O,$,U){return $===$?SI(O,$,U):Hi(O,La,U)}function Ct(O,$,U,Z){for(var he=U-1,Ne=O.length;++he<Ne;)if(Z(O[he],$))return he;return-1}function La(O){return O!==O}function Ma(O,$){var U=O==null?0:O.length;return U?b(O,$)/U:Cr}function Mr(O){return function($){return $==null?r:$[O]}}function u(O){return function($){return O==null?r:O[$]}}function d(O,$,U,Z,he){return he(O,function(Ne,ft,Ue){U=Z?(Z=!1,Ne):$(U,Ne,ft,Ue)}),U}function g(O,$){var U=O.length;for(O.sort($);U--;)O[U]=O[U].value;return O}function b(O,$){for(var U,Z=-1,he=O.length;++Z<he;){var Ne=$(O[Z]);Ne!==r&&(U=U===r?Ne:U+Ne)}return U}function L(O,$){for(var U=-1,Z=Array(O);++U<O;)Z[U]=$(U);return Z}function F(O,$){return Fe($,function(U){return[U,O[U]]})}function Q(O){return O&&O.slice(0,e_(O)+1).replace(ct,"")}function _e(O){return function($){return O($)}}function Ze(O,$){return Fe($,function(U){return O[U]})}function be(O,$){return O.has($)}function lt(O,$){for(var U=-1,Z=O.length;++U<Z&&wr($,O[U],0)>-1;);return U}function ht(O,$){for(var U=O.length;U--&&wr($,O[U],0)>-1;);return U}function Hn(O,$){for(var U=O.length,Z=0;U--;)O[U]===$&&++Z;return Z}var Qt=u(Cc),Qs=u($i);function Fa(O){return"\\"+Dc[O]}function EI(O,$){return O==null?r:O[$]}function Js(O){return Of.test(O)}function II(O){return Vr.test(O)}function xI(O){for(var $,U=[];!($=O.next()).done;)U.push($.value);return U}function Lf(O){var $=-1,U=Array(O.size);return O.forEach(function(Z,he){U[++$]=[he,Z]}),U}function Zg(O,$){return function(U){return O($(U))}}function Qn(O,$){for(var U=-1,Z=O.length,he=0,Ne=[];++U<Z;){var ft=O[U];(ft===$||ft===f)&&(O[U]=f,Ne[he++]=U)}return Ne}function Fc(O){var $=-1,U=Array(O.size);return O.forEach(function(Z){U[++$]=Z}),U}function AI(O){var $=-1,U=Array(O.size);return O.forEach(function(Z){U[++$]=[Z,Z]}),U}function SI(O,$,U){for(var Z=U-1,he=O.length;++Z<he;)if(O[Z]===$)return Z;return-1}function RI(O,$,U){for(var Z=U+1;Z--;)if(O[Z]===$)return Z;return Z}function Ys(O){return Js(O)?CI(O):cn(O)}function br(O){return Js(O)?DI(O):Lc(O)}function e_(O){for(var $=O.length;$--&&pc.test(O.charAt($)););return $}var PI=u(qi);function CI(O){for(var $=Da.lastIndex=0;Da.test(O);)++$;return $}function DI(O){return O.match(Da)||[]}function OI(O){return O.match(Df)||[]}var kI=function O($){$=$==null?Xe:Jn.defaults(Xe.Object(),$,Jn.pick(Xe,kf));var U=$.Array,Z=$.Date,he=$.Error,Ne=$.Function,ft=$.Math,Ue=$.Object,Mf=$.RegExp,NI=$.String,nr=$.TypeError,Uc=U.prototype,VI=Ne.prototype,Xs=Ue.prototype,Bc=$["__core-js_shared__"],jc=VI.toString,Me=Xs.hasOwnProperty,LI=0,t_=function(){var i=/[^.]+$/.exec(Bc&&Bc.keys&&Bc.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}(),$c=Xs.toString,MI=jc.call(Ue),FI=Xe._,UI=Mf("^"+jc.call(Me).replace(an,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),qc=zi?$.Buffer:r,Yn=$.Symbol,zc=$.Uint8Array,r_=qc?qc.allocUnsafe:r,Gc=Zg(Ue.getPrototypeOf,Ue),n_=Ue.create,i_=Xs.propertyIsEnumerable,Kc=Uc.splice,s_=Yn?Yn.isConcatSpreadable:r,Ua=Yn?Yn.iterator:r,Qi=Yn?Yn.toStringTag:r,Wc=function(){try{var i=es(Ue,"defineProperty");return i({},"",{}),i}catch{}}(),BI=$.clearTimeout!==Xe.clearTimeout&&$.clearTimeout,jI=Z&&Z.now!==Xe.Date.now&&Z.now,$I=$.setTimeout!==Xe.setTimeout&&$.setTimeout,Hc=ft.ceil,Qc=ft.floor,Ff=Ue.getOwnPropertySymbols,qI=qc?qc.isBuffer:r,o_=$.isFinite,zI=Uc.join,GI=Zg(Ue.keys,Ue),dt=ft.max,It=ft.min,KI=Z.now,WI=$.parseInt,a_=ft.random,HI=Uc.reverse,Uf=es($,"DataView"),Ba=es($,"Map"),Bf=es($,"Promise"),Zs=es($,"Set"),ja=es($,"WeakMap"),$a=es(Ue,"create"),Jc=ja&&new ja,eo={},QI=ts(Uf),JI=ts(Ba),YI=ts(Bf),XI=ts(Zs),ZI=ts(ja),Yc=Yn?Yn.prototype:r,qa=Yc?Yc.valueOf:r,u_=Yc?Yc.toString:r;function w(i){if(Qe(i)&&!pe(i)&&!(i instanceof Ie)){if(i instanceof ir)return i;if(Me.call(i,"__wrapped__"))return cy(i)}return new ir(i)}var to=function(){function i(){}return function(o){if(!We(o))return{};if(n_)return n_(o);i.prototype=o;var l=new i;return i.prototype=r,l}}();function Xc(){}function ir(i,o){this.__wrapped__=i,this.__actions__=[],this.__chain__=!!o,this.__index__=0,this.__values__=r}w.templateSettings={escape:wa,evaluate:ba,interpolate:kr,variable:"",imports:{_:w}},w.prototype=Xc.prototype,w.prototype.constructor=w,ir.prototype=to(Xc.prototype),ir.prototype.constructor=ir;function Ie(i){this.__wrapped__=i,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Lt,this.__views__=[]}function ex(){var i=new Ie(this.__wrapped__);return i.__actions__=Ut(this.__actions__),i.__dir__=this.__dir__,i.__filtered__=this.__filtered__,i.__iteratees__=Ut(this.__iteratees__),i.__takeCount__=this.__takeCount__,i.__views__=Ut(this.__views__),i}function tx(){if(this.__filtered__){var i=new Ie(this);i.__dir__=-1,i.__filtered__=!0}else i=this.clone(),i.__dir__*=-1;return i}function rx(){var i=this.__wrapped__.value(),o=this.__dir__,l=pe(i),p=o<0,y=l?i.length:0,T=pA(0,y,this.__views__),x=T.start,P=T.end,N=P-x,q=p?P:x-1,z=this.__iteratees__,K=z.length,Y=0,te=It(N,this.__takeCount__);if(!l||!p&&y==N&&te==N)return O_(i,this.__actions__);var oe=[];e:for(;N--&&Y<te;){q+=o;for(var ve=-1,ae=i[q];++ve<K;){var Te=z[ve],Ae=Te.iteratee,Xt=Te.type,kt=Ae(ae);if(Xt==S)ae=kt;else if(!kt){if(Xt==M)continue e;break e}}oe[Y++]=ae}return oe}Ie.prototype=to(Xc.prototype),Ie.prototype.constructor=Ie;function Ji(i){var o=-1,l=i==null?0:i.length;for(this.clear();++o<l;){var p=i[o];this.set(p[0],p[1])}}function nx(){this.__data__=$a?$a(null):{},this.size=0}function ix(i){var o=this.has(i)&&delete this.__data__[i];return this.size-=o?1:0,o}function sx(i){var o=this.__data__;if($a){var l=o[i];return l===c?r:l}return Me.call(o,i)?o[i]:r}function ox(i){var o=this.__data__;return $a?o[i]!==r:Me.call(o,i)}function ax(i,o){var l=this.__data__;return this.size+=this.has(i)?0:1,l[i]=$a&&o===r?c:o,this}Ji.prototype.clear=nx,Ji.prototype.delete=ix,Ji.prototype.get=sx,Ji.prototype.has=ox,Ji.prototype.set=ax;function ln(i){var o=-1,l=i==null?0:i.length;for(this.clear();++o<l;){var p=i[o];this.set(p[0],p[1])}}function ux(){this.__data__=[],this.size=0}function cx(i){var o=this.__data__,l=Zc(o,i);if(l<0)return!1;var p=o.length-1;return l==p?o.pop():Kc.call(o,l,1),--this.size,!0}function lx(i){var o=this.__data__,l=Zc(o,i);return l<0?r:o[l][1]}function hx(i){return Zc(this.__data__,i)>-1}function fx(i,o){var l=this.__data__,p=Zc(l,i);return p<0?(++this.size,l.push([i,o])):l[p][1]=o,this}ln.prototype.clear=ux,ln.prototype.delete=cx,ln.prototype.get=lx,ln.prototype.has=hx,ln.prototype.set=fx;function hn(i){var o=-1,l=i==null?0:i.length;for(this.clear();++o<l;){var p=i[o];this.set(p[0],p[1])}}function dx(){this.size=0,this.__data__={hash:new Ji,map:new(Ba||ln),string:new Ji}}function px(i){var o=hl(this,i).delete(i);return this.size-=o?1:0,o}function mx(i){return hl(this,i).get(i)}function gx(i){return hl(this,i).has(i)}function _x(i,o){var l=hl(this,i),p=l.size;return l.set(i,o),this.size+=l.size==p?0:1,this}hn.prototype.clear=dx,hn.prototype.delete=px,hn.prototype.get=mx,hn.prototype.has=gx,hn.prototype.set=_x;function Yi(i){var o=-1,l=i==null?0:i.length;for(this.__data__=new hn;++o<l;)this.add(i[o])}function yx(i){return this.__data__.set(i,c),this}function vx(i){return this.__data__.has(i)}Yi.prototype.add=Yi.prototype.push=yx,Yi.prototype.has=vx;function Tr(i){var o=this.__data__=new ln(i);this.size=o.size}function wx(){this.__data__=new ln,this.size=0}function bx(i){var o=this.__data__,l=o.delete(i);return this.size=o.size,l}function Tx(i){return this.__data__.get(i)}function Ex(i){return this.__data__.has(i)}function Ix(i,o){var l=this.__data__;if(l instanceof ln){var p=l.__data__;if(!Ba||p.length<t-1)return p.push([i,o]),this.size=++l.size,this;l=this.__data__=new hn(p)}return l.set(i,o),this.size=l.size,this}Tr.prototype.clear=wx,Tr.prototype.delete=bx,Tr.prototype.get=Tx,Tr.prototype.has=Ex,Tr.prototype.set=Ix;function c_(i,o){var l=pe(i),p=!l&&rs(i),y=!l&&!p&&ri(i),T=!l&&!p&&!y&&so(i),x=l||p||y||T,P=x?L(i.length,NI):[],N=P.length;for(var q in i)(o||Me.call(i,q))&&!(x&&(q=="length"||y&&(q=="offset"||q=="parent")||T&&(q=="buffer"||q=="byteLength"||q=="byteOffset")||mn(q,N)))&&P.push(q);return P}function l_(i){var o=i.length;return o?i[Yf(0,o-1)]:r}function xx(i,o){return fl(Ut(i),Xi(o,0,i.length))}function Ax(i){return fl(Ut(i))}function jf(i,o,l){(l!==r&&!Er(i[o],l)||l===r&&!(o in i))&&fn(i,o,l)}function za(i,o,l){var p=i[o];(!(Me.call(i,o)&&Er(p,l))||l===r&&!(o in i))&&fn(i,o,l)}function Zc(i,o){for(var l=i.length;l--;)if(Er(i[l][0],o))return l;return-1}function Sx(i,o,l,p){return Xn(i,function(y,T,x){o(p,y,l(y),x)}),p}function h_(i,o){return i&&Ur(o,mt(o),i)}function Rx(i,o){return i&&Ur(o,jt(o),i)}function fn(i,o,l){o=="__proto__"&&Wc?Wc(i,o,{configurable:!0,enumerable:!0,value:l,writable:!0}):i[o]=l}function $f(i,o){for(var l=-1,p=o.length,y=U(p),T=i==null;++l<p;)y[l]=T?r:Td(i,o[l]);return y}function Xi(i,o,l){return i===i&&(l!==r&&(i=i<=l?i:l),o!==r&&(i=i>=o?i:o)),i}function sr(i,o,l,p,y,T){var x,P=o&m,N=o&_,q=o&E;if(l&&(x=y?l(i,p,y,T):l(i)),x!==r)return x;if(!We(i))return i;var z=pe(i);if(z){if(x=gA(i),!P)return Ut(i,x)}else{var K=xt(i),Y=K==rn||K==Pi;if(ri(i))return V_(i,P);if(K==Ht||K==Ke||Y&&!y){if(x=N||Y?{}:ey(i),!P)return N?sA(i,Rx(x,i)):iA(i,h_(x,i))}else{if(!ke[K])return y?i:{};x=_A(i,K,P)}}T||(T=new Tr);var te=T.get(i);if(te)return te;T.set(i,x),Py(i)?i.forEach(function(ae){x.add(sr(ae,o,l,ae,i,T))}):Sy(i)&&i.forEach(function(ae,Te){x.set(Te,sr(ae,o,l,Te,i,T))});var oe=q?N?ud:ad:N?jt:mt,ve=z?r:oe(i);return Ft(ve||i,function(ae,Te){ve&&(Te=ae,ae=i[Te]),za(x,Te,sr(ae,o,l,Te,i,T))}),x}function Px(i){var o=mt(i);return function(l){return f_(l,i,o)}}function f_(i,o,l){var p=l.length;if(i==null)return!p;for(i=Ue(i);p--;){var y=l[p],T=o[y],x=i[y];if(x===r&&!(y in i)||!T(x))return!1}return!0}function d_(i,o,l){if(typeof i!="function")throw new nr(s);return Ya(function(){i.apply(r,l)},o)}function Ga(i,o,l,p){var y=-1,T=Ki,x=!0,P=i.length,N=[],q=o.length;if(!P)return N;l&&(o=Fe(o,_e(l))),p?(T=Wi,x=!1):o.length>=t&&(T=be,x=!1,o=new Yi(o));e:for(;++y<P;){var z=i[y],K=l==null?z:l(z);if(z=p||z!==0?z:0,x&&K===K){for(var Y=q;Y--;)if(o[Y]===K)continue e;N.push(z)}else T(o,K,p)||N.push(z)}return N}var Xn=B_(Fr),p_=B_(zf,!0);function Cx(i,o){var l=!0;return Xn(i,function(p,y,T){return l=!!o(p,y,T),l}),l}function el(i,o,l){for(var p=-1,y=i.length;++p<y;){var T=i[p],x=o(T);if(x!=null&&(P===r?x===x&&!Yt(x):l(x,P)))var P=x,N=T}return N}function Dx(i,o,l,p){var y=i.length;for(l=ye(l),l<0&&(l=-l>y?0:y+l),p=p===r||p>y?y:ye(p),p<0&&(p+=y),p=l>p?0:Dy(p);l<p;)i[l++]=o;return i}function m_(i,o){var l=[];return Xn(i,function(p,y,T){o(p,y,T)&&l.push(p)}),l}function vt(i,o,l,p,y){var T=-1,x=i.length;for(l||(l=vA),y||(y=[]);++T<x;){var P=i[T];o>0&&l(P)?o>1?vt(P,o-1,l,p,y):vr(y,P):p||(y[y.length]=P)}return y}var qf=j_(),g_=j_(!0);function Fr(i,o){return i&&qf(i,o,mt)}function zf(i,o){return i&&g_(i,o,mt)}function tl(i,o){return yr(o,function(l){return gn(i[l])})}function Zi(i,o){o=ei(o,i);for(var l=0,p=o.length;i!=null&&l<p;)i=i[Br(o[l++])];return l&&l==p?i:r}function __(i,o,l){var p=o(i);return pe(i)?p:vr(p,l(i))}function Dt(i){return i==null?i===r?cc:pa:Qi&&Qi in Ue(i)?dA(i):AA(i)}function Gf(i,o){return i>o}function Ox(i,o){return i!=null&&Me.call(i,o)}function kx(i,o){return i!=null&&o in Ue(i)}function Nx(i,o,l){return i>=It(o,l)&&i<dt(o,l)}function Kf(i,o,l){for(var p=l?Wi:Ki,y=i[0].length,T=i.length,x=T,P=U(T),N=1/0,q=[];x--;){var z=i[x];x&&o&&(z=Fe(z,_e(o))),N=It(z.length,N),P[x]=!l&&(o||y>=120&&z.length>=120)?new Yi(x&&z):r}z=i[0];var K=-1,Y=P[0];e:for(;++K<y&&q.length<N;){var te=z[K],oe=o?o(te):te;if(te=l||te!==0?te:0,!(Y?be(Y,oe):p(q,oe,l))){for(x=T;--x;){var ve=P[x];if(!(ve?be(ve,oe):p(i[x],oe,l)))continue e}Y&&Y.push(oe),q.push(te)}}return q}function Vx(i,o,l,p){return Fr(i,function(y,T,x){o(p,l(y),T,x)}),p}function Ka(i,o,l){o=ei(o,i),i=iy(i,o);var p=i==null?i:i[Br(ar(o))];return p==null?r:Et(p,i,l)}function y_(i){return Qe(i)&&Dt(i)==Ke}function Lx(i){return Qe(i)&&Dt(i)==sn}function Mx(i){return Qe(i)&&Dt(i)==pr}function Wa(i,o,l,p,y){return i===o?!0:i==null||o==null||!Qe(i)&&!Qe(o)?i!==i&&o!==o:Fx(i,o,l,p,Wa,y)}function Fx(i,o,l,p,y,T){var x=pe(i),P=pe(o),N=x?Cs:xt(i),q=P?Cs:xt(o);N=N==Ke?Ht:N,q=q==Ke?Ht:q;var z=N==Ht,K=q==Ht,Y=N==q;if(Y&&ri(i)){if(!ri(o))return!1;x=!0,z=!1}if(Y&&!z)return T||(T=new Tr),x||so(i)?Y_(i,o,l,p,y,T):hA(i,o,N,l,p,y,T);if(!(l&I)){var te=z&&Me.call(i,"__wrapped__"),oe=K&&Me.call(o,"__wrapped__");if(te||oe){var ve=te?i.value():i,ae=oe?o.value():o;return T||(T=new Tr),y(ve,ae,l,p,T)}}return Y?(T||(T=new Tr),fA(i,o,l,p,y,T)):!1}function Ux(i){return Qe(i)&&xt(i)==Pt}function Wf(i,o,l,p){var y=l.length,T=y,x=!p;if(i==null)return!T;for(i=Ue(i);y--;){var P=l[y];if(x&&P[2]?P[1]!==i[P[0]]:!(P[0]in i))return!1}for(;++y<T;){P=l[y];var N=P[0],q=i[N],z=P[1];if(x&&P[2]){if(q===r&&!(N in i))return!1}else{var K=new Tr;if(p)var Y=p(q,z,N,i,o,K);if(!(Y===r?Wa(z,q,I|k,p,K):Y))return!1}}return!0}function v_(i){if(!We(i)||bA(i))return!1;var o=gn(i)?UI:Fs;return o.test(ts(i))}function Bx(i){return Qe(i)&&Dt(i)==Ci}function jx(i){return Qe(i)&&xt(i)==Mt}function $x(i){return Qe(i)&&yl(i.length)&&!!Oe[Dt(i)]}function w_(i){return typeof i=="function"?i:i==null?$t:typeof i=="object"?pe(i)?E_(i[0],i[1]):T_(i):$y(i)}function Hf(i){if(!Ja(i))return GI(i);var o=[];for(var l in Ue(i))Me.call(i,l)&&l!="constructor"&&o.push(l);return o}function qx(i){if(!We(i))return xA(i);var o=Ja(i),l=[];for(var p in i)p=="constructor"&&(o||!Me.call(i,p))||l.push(p);return l}function Qf(i,o){return i<o}function b_(i,o){var l=-1,p=Bt(i)?U(i.length):[];return Xn(i,function(y,T,x){p[++l]=o(y,T,x)}),p}function T_(i){var o=ld(i);return o.length==1&&o[0][2]?ry(o[0][0],o[0][1]):function(l){return l===i||Wf(l,i,o)}}function E_(i,o){return fd(i)&&ty(o)?ry(Br(i),o):function(l){var p=Td(l,i);return p===r&&p===o?Ed(l,i):Wa(o,p,I|k)}}function rl(i,o,l,p,y){i!==o&&qf(o,function(T,x){if(y||(y=new Tr),We(T))zx(i,o,x,l,rl,p,y);else{var P=p?p(pd(i,x),T,x+"",i,o,y):r;P===r&&(P=T),jf(i,x,P)}},jt)}function zx(i,o,l,p,y,T,x){var P=pd(i,l),N=pd(o,l),q=x.get(N);if(q){jf(i,l,q);return}var z=T?T(P,N,l+"",i,o,x):r,K=z===r;if(K){var Y=pe(N),te=!Y&&ri(N),oe=!Y&&!te&&so(N);z=N,Y||te||oe?pe(P)?z=P:et(P)?z=Ut(P):te?(K=!1,z=V_(N,!0)):oe?(K=!1,z=L_(N,!0)):z=[]:Xa(N)||rs(N)?(z=P,rs(P)?z=Oy(P):(!We(P)||gn(P))&&(z=ey(N))):K=!1}K&&(x.set(N,z),y(z,N,p,T,x),x.delete(N)),jf(i,l,z)}function I_(i,o){var l=i.length;if(l)return o+=o<0?l:0,mn(o,l)?i[o]:r}function x_(i,o,l){o.length?o=Fe(o,function(T){return pe(T)?function(x){return Zi(x,T.length===1?T[0]:T)}:T}):o=[$t];var p=-1;o=Fe(o,_e(se()));var y=b_(i,function(T,x,P){var N=Fe(o,function(q){return q(T)});return{criteria:N,index:++p,value:T}});return g(y,function(T,x){return nA(T,x,l)})}function Gx(i,o){return A_(i,o,function(l,p){return Ed(i,p)})}function A_(i,o,l){for(var p=-1,y=o.length,T={};++p<y;){var x=o[p],P=Zi(i,x);l(P,x)&&Ha(T,ei(x,i),P)}return T}function Kx(i){return function(o){return Zi(o,i)}}function Jf(i,o,l,p){var y=p?Ct:wr,T=-1,x=o.length,P=i;for(i===o&&(o=Ut(o)),l&&(P=Fe(i,_e(l)));++T<x;)for(var N=0,q=o[T],z=l?l(q):q;(N=y(P,z,N,p))>-1;)P!==i&&Kc.call(P,N,1),Kc.call(i,N,1);return i}function S_(i,o){for(var l=i?o.length:0,p=l-1;l--;){var y=o[l];if(l==p||y!==T){var T=y;mn(y)?Kc.call(i,y,1):ed(i,y)}}return i}function Yf(i,o){return i+Qc(a_()*(o-i+1))}function Wx(i,o,l,p){for(var y=-1,T=dt(Hc((o-i)/(l||1)),0),x=U(T);T--;)x[p?T:++y]=i,i+=l;return x}function Xf(i,o){var l="";if(!i||o<1||o>Pr)return l;do o%2&&(l+=i),o=Qc(o/2),o&&(i+=i);while(o);return l}function we(i,o){return md(ny(i,o,$t),i+"")}function Hx(i){return l_(oo(i))}function Qx(i,o){var l=oo(i);return fl(l,Xi(o,0,l.length))}function Ha(i,o,l,p){if(!We(i))return i;o=ei(o,i);for(var y=-1,T=o.length,x=T-1,P=i;P!=null&&++y<T;){var N=Br(o[y]),q=l;if(N==="__proto__"||N==="constructor"||N==="prototype")return i;if(y!=x){var z=P[N];q=p?p(z,N,P):r,q===r&&(q=We(z)?z:mn(o[y+1])?[]:{})}za(P,N,q),P=P[N]}return i}var R_=Jc?function(i,o){return Jc.set(i,o),i}:$t,Jx=Wc?function(i,o){return Wc(i,"toString",{configurable:!0,enumerable:!1,value:xd(o),writable:!0})}:$t;function Yx(i){return fl(oo(i))}function or(i,o,l){var p=-1,y=i.length;o<0&&(o=-o>y?0:y+o),l=l>y?y:l,l<0&&(l+=y),y=o>l?0:l-o>>>0,o>>>=0;for(var T=U(y);++p<y;)T[p]=i[p+o];return T}function Xx(i,o){var l;return Xn(i,function(p,y,T){return l=o(p,y,T),!l}),!!l}function nl(i,o,l){var p=0,y=i==null?p:i.length;if(typeof o=="number"&&o===o&&y<=vf){for(;p<y;){var T=p+y>>>1,x=i[T];x!==null&&!Yt(x)&&(l?x<=o:x<o)?p=T+1:y=T}return y}return Zf(i,o,$t,l)}function Zf(i,o,l,p){var y=0,T=i==null?0:i.length;if(T===0)return 0;o=l(o);for(var x=o!==o,P=o===null,N=Yt(o),q=o===r;y<T;){var z=Qc((y+T)/2),K=l(i[z]),Y=K!==r,te=K===null,oe=K===K,ve=Yt(K);if(x)var ae=p||oe;else q?ae=oe&&(p||Y):P?ae=oe&&Y&&(p||!te):N?ae=oe&&Y&&!te&&(p||!ve):te||ve?ae=!1:ae=p?K<=o:K<o;ae?y=z+1:T=z}return It(T,ac)}function P_(i,o){for(var l=-1,p=i.length,y=0,T=[];++l<p;){var x=i[l],P=o?o(x):x;if(!l||!Er(P,N)){var N=P;T[y++]=x===0?0:x}}return T}function C_(i){return typeof i=="number"?i:Yt(i)?Cr:+i}function Jt(i){if(typeof i=="string")return i;if(pe(i))return Fe(i,Jt)+"";if(Yt(i))return u_?u_.call(i):"";var o=i+"";return o=="0"&&1/i==-Wt?"-0":o}function Zn(i,o,l){var p=-1,y=Ki,T=i.length,x=!0,P=[],N=P;if(l)x=!1,y=Wi;else if(T>=t){var q=o?null:cA(i);if(q)return Fc(q);x=!1,y=be,N=new Yi}else N=o?[]:P;e:for(;++p<T;){var z=i[p],K=o?o(z):z;if(z=l||z!==0?z:0,x&&K===K){for(var Y=N.length;Y--;)if(N[Y]===K)continue e;o&&N.push(K),P.push(z)}else y(N,K,l)||(N!==P&&N.push(K),P.push(z))}return P}function ed(i,o){return o=ei(o,i),i=iy(i,o),i==null||delete i[Br(ar(o))]}function D_(i,o,l,p){return Ha(i,o,l(Zi(i,o)),p)}function il(i,o,l,p){for(var y=i.length,T=p?y:-1;(p?T--:++T<y)&&o(i[T],T,i););return l?or(i,p?0:T,p?T+1:y):or(i,p?T+1:0,p?y:T)}function O_(i,o){var l=i;return l instanceof Ie&&(l=l.value()),Wn(o,function(p,y){return y.func.apply(y.thisArg,vr([p],y.args))},l)}function td(i,o,l){var p=i.length;if(p<2)return p?Zn(i[0]):[];for(var y=-1,T=U(p);++y<p;)for(var x=i[y],P=-1;++P<p;)P!=y&&(T[y]=Ga(T[y]||x,i[P],o,l));return Zn(vt(T,1),o,l)}function k_(i,o,l){for(var p=-1,y=i.length,T=o.length,x={};++p<y;){var P=p<T?o[p]:r;l(x,i[p],P)}return x}function rd(i){return et(i)?i:[]}function nd(i){return typeof i=="function"?i:$t}function ei(i,o){return pe(i)?i:fd(i,o)?[i]:uy(Ve(i))}var Zx=we;function ti(i,o,l){var p=i.length;return l=l===r?p:l,!o&&l>=p?i:or(i,o,l)}var N_=BI||function(i){return Xe.clearTimeout(i)};function V_(i,o){if(o)return i.slice();var l=i.length,p=r_?r_(l):new i.constructor(l);return i.copy(p),p}function id(i){var o=new i.constructor(i.byteLength);return new zc(o).set(new zc(i)),o}function eA(i,o){var l=o?id(i.buffer):i.buffer;return new i.constructor(l,i.byteOffset,i.byteLength)}function tA(i){var o=new i.constructor(i.source,Vi.exec(i));return o.lastIndex=i.lastIndex,o}function rA(i){return qa?Ue(qa.call(i)):{}}function L_(i,o){var l=o?id(i.buffer):i.buffer;return new i.constructor(l,i.byteOffset,i.length)}function M_(i,o){if(i!==o){var l=i!==r,p=i===null,y=i===i,T=Yt(i),x=o!==r,P=o===null,N=o===o,q=Yt(o);if(!P&&!q&&!T&&i>o||T&&x&&N&&!P&&!q||p&&x&&N||!l&&N||!y)return 1;if(!p&&!T&&!q&&i<o||q&&l&&y&&!p&&!T||P&&l&&y||!x&&y||!N)return-1}return 0}function nA(i,o,l){for(var p=-1,y=i.criteria,T=o.criteria,x=y.length,P=l.length;++p<x;){var N=M_(y[p],T[p]);if(N){if(p>=P)return N;var q=l[p];return N*(q=="desc"?-1:1)}}return i.index-o.index}function F_(i,o,l,p){for(var y=-1,T=i.length,x=l.length,P=-1,N=o.length,q=dt(T-x,0),z=U(N+q),K=!p;++P<N;)z[P]=o[P];for(;++y<x;)(K||y<T)&&(z[l[y]]=i[y]);for(;q--;)z[P++]=i[y++];return z}function U_(i,o,l,p){for(var y=-1,T=i.length,x=-1,P=l.length,N=-1,q=o.length,z=dt(T-P,0),K=U(z+q),Y=!p;++y<z;)K[y]=i[y];for(var te=y;++N<q;)K[te+N]=o[N];for(;++x<P;)(Y||y<T)&&(K[te+l[x]]=i[y++]);return K}function Ut(i,o){var l=-1,p=i.length;for(o||(o=U(p));++l<p;)o[l]=i[l];return o}function Ur(i,o,l,p){var y=!l;l||(l={});for(var T=-1,x=o.length;++T<x;){var P=o[T],N=p?p(l[P],i[P],P,l,i):r;N===r&&(N=i[P]),y?fn(l,P,N):za(l,P,N)}return l}function iA(i,o){return Ur(i,hd(i),o)}function sA(i,o){return Ur(i,X_(i),o)}function sl(i,o){return function(l,p){var y=pe(l)?Ws:Sx,T=o?o():{};return y(l,i,se(p,2),T)}}function ro(i){return we(function(o,l){var p=-1,y=l.length,T=y>1?l[y-1]:r,x=y>2?l[2]:r;for(T=i.length>3&&typeof T=="function"?(y--,T):r,x&&Ot(l[0],l[1],x)&&(T=y<3?r:T,y=1),o=Ue(o);++p<y;){var P=l[p];P&&i(o,P,p,T)}return o})}function B_(i,o){return function(l,p){if(l==null)return l;if(!Bt(l))return i(l,p);for(var y=l.length,T=o?y:-1,x=Ue(l);(o?T--:++T<y)&&p(x[T],T,x)!==!1;);return l}}function j_(i){return function(o,l,p){for(var y=-1,T=Ue(o),x=p(o),P=x.length;P--;){var N=x[i?P:++y];if(l(T[N],N,T)===!1)break}return o}}function oA(i,o,l){var p=o&B,y=Qa(i);function T(){var x=this&&this!==Xe&&this instanceof T?y:i;return x.apply(p?l:this,arguments)}return T}function $_(i){return function(o){o=Ve(o);var l=Js(o)?br(o):r,p=l?l[0]:o.charAt(0),y=l?ti(l,1).join(""):o.slice(1);return p[i]()+y}}function no(i){return function(o){return Wn(By(Uy(o).replace(Pc,"")),i,"")}}function Qa(i){return function(){var o=arguments;switch(o.length){case 0:return new i;case 1:return new i(o[0]);case 2:return new i(o[0],o[1]);case 3:return new i(o[0],o[1],o[2]);case 4:return new i(o[0],o[1],o[2],o[3]);case 5:return new i(o[0],o[1],o[2],o[3],o[4]);case 6:return new i(o[0],o[1],o[2],o[3],o[4],o[5]);case 7:return new i(o[0],o[1],o[2],o[3],o[4],o[5],o[6])}var l=to(i.prototype),p=i.apply(l,o);return We(p)?p:l}}function aA(i,o,l){var p=Qa(i);function y(){for(var T=arguments.length,x=U(T),P=T,N=io(y);P--;)x[P]=arguments[P];var q=T<3&&x[0]!==N&&x[T-1]!==N?[]:Qn(x,N);if(T-=q.length,T<l)return W_(i,o,ol,y.placeholder,r,x,q,r,r,l-T);var z=this&&this!==Xe&&this instanceof y?p:i;return Et(z,this,x)}return y}function q_(i){return function(o,l,p){var y=Ue(o);if(!Bt(o)){var T=se(l,3);o=mt(o),l=function(P){return T(y[P],P,y)}}var x=i(o,l,p);return x>-1?y[T?o[x]:x]:r}}function z_(i){return pn(function(o){var l=o.length,p=l,y=ir.prototype.thru;for(i&&o.reverse();p--;){var T=o[p];if(typeof T!="function")throw new nr(s);if(y&&!x&&ll(T)=="wrapper")var x=new ir([],!0)}for(p=x?p:l;++p<l;){T=o[p];var P=ll(T),N=P=="wrapper"?cd(T):r;N&&dd(N[0])&&N[1]==(de|J|re|ie)&&!N[4].length&&N[9]==1?x=x[ll(N[0])].apply(x,N[3]):x=T.length==1&&dd(T)?x[P]():x.thru(T)}return function(){var q=arguments,z=q[0];if(x&&q.length==1&&pe(z))return x.plant(z).value();for(var K=0,Y=l?o[K].apply(this,q):z;++K<l;)Y=o[K].call(this,Y);return Y}})}function ol(i,o,l,p,y,T,x,P,N,q){var z=o&de,K=o&B,Y=o&G,te=o&(J|ee),oe=o&C,ve=Y?r:Qa(i);function ae(){for(var Te=arguments.length,Ae=U(Te),Xt=Te;Xt--;)Ae[Xt]=arguments[Xt];if(te)var kt=io(ae),Zt=Hn(Ae,kt);if(p&&(Ae=F_(Ae,p,y,te)),T&&(Ae=U_(Ae,T,x,te)),Te-=Zt,te&&Te<q){var tt=Qn(Ae,kt);return W_(i,o,ol,ae.placeholder,l,Ae,tt,P,N,q-Te)}var Ir=K?l:this,yn=Y?Ir[i]:i;return Te=Ae.length,P?Ae=SA(Ae,P):oe&&Te>1&&Ae.reverse(),z&&N<Te&&(Ae.length=N),this&&this!==Xe&&this instanceof ae&&(yn=ve||Qa(yn)),yn.apply(Ir,Ae)}return ae}function G_(i,o){return function(l,p){return Vx(l,i,o(p),{})}}function al(i,o){return function(l,p){var y;if(l===r&&p===r)return o;if(l!==r&&(y=l),p!==r){if(y===r)return p;typeof l=="string"||typeof p=="string"?(l=Jt(l),p=Jt(p)):(l=C_(l),p=C_(p)),y=i(l,p)}return y}}function sd(i){return pn(function(o){return o=Fe(o,_e(se())),we(function(l){var p=this;return i(o,function(y){return Et(y,p,l)})})})}function ul(i,o){o=o===r?" ":Jt(o);var l=o.length;if(l<2)return l?Xf(o,i):o;var p=Xf(o,Hc(i/Ys(o)));return Js(o)?ti(br(p),0,i).join(""):p.slice(0,i)}function uA(i,o,l,p){var y=o&B,T=Qa(i);function x(){for(var P=-1,N=arguments.length,q=-1,z=p.length,K=U(z+N),Y=this&&this!==Xe&&this instanceof x?T:i;++q<z;)K[q]=p[q];for(;N--;)K[q++]=arguments[++P];return Et(Y,y?l:this,K)}return x}function K_(i){return function(o,l,p){return p&&typeof p!="number"&&Ot(o,l,p)&&(l=p=r),o=_n(o),l===r?(l=o,o=0):l=_n(l),p=p===r?o<l?1:-1:_n(p),Wx(o,l,p,i)}}function cl(i){return function(o,l){return typeof o=="string"&&typeof l=="string"||(o=ur(o),l=ur(l)),i(o,l)}}function W_(i,o,l,p,y,T,x,P,N,q){var z=o&J,K=z?x:r,Y=z?r:x,te=z?T:r,oe=z?r:T;o|=z?re:le,o&=~(z?le:re),o&j||(o&=~(B|G));var ve=[i,o,y,te,K,oe,Y,P,N,q],ae=l.apply(r,ve);return dd(i)&&sy(ae,ve),ae.placeholder=p,oy(ae,i,o)}function od(i){var o=ft[i];return function(l,p){if(l=ur(l),p=p==null?0:It(ye(p),292),p&&o_(l)){var y=(Ve(l)+"e").split("e"),T=o(y[0]+"e"+(+y[1]+p));return y=(Ve(T)+"e").split("e"),+(y[0]+"e"+(+y[1]-p))}return o(l)}}var cA=Zs&&1/Fc(new Zs([,-0]))[1]==Wt?function(i){return new Zs(i)}:Rd;function H_(i){return function(o){var l=xt(o);return l==Pt?Lf(o):l==Mt?AI(o):F(o,i(o))}}function dn(i,o,l,p,y,T,x,P){var N=o&G;if(!N&&typeof i!="function")throw new nr(s);var q=p?p.length:0;if(q||(o&=~(re|le),p=y=r),x=x===r?x:dt(ye(x),0),P=P===r?P:ye(P),q-=y?y.length:0,o&le){var z=p,K=y;p=y=r}var Y=N?r:cd(i),te=[i,o,l,p,y,z,K,T,x,P];if(Y&&IA(te,Y),i=te[0],o=te[1],l=te[2],p=te[3],y=te[4],P=te[9]=te[9]===r?N?0:i.length:dt(te[9]-q,0),!P&&o&(J|ee)&&(o&=~(J|ee)),!o||o==B)var oe=oA(i,o,l);else o==J||o==ee?oe=aA(i,o,P):(o==re||o==(B|re))&&!y.length?oe=uA(i,o,l,p):oe=ol.apply(r,te);var ve=Y?R_:sy;return oy(ve(oe,te),i,o)}function Q_(i,o,l,p){return i===r||Er(i,Xs[l])&&!Me.call(p,l)?o:i}function J_(i,o,l,p,y,T){return We(i)&&We(o)&&(T.set(o,i),rl(i,o,r,J_,T),T.delete(o)),i}function lA(i){return Xa(i)?r:i}function Y_(i,o,l,p,y,T){var x=l&I,P=i.length,N=o.length;if(P!=N&&!(x&&N>P))return!1;var q=T.get(i),z=T.get(o);if(q&&z)return q==o&&z==i;var K=-1,Y=!0,te=l&k?new Yi:r;for(T.set(i,o),T.set(o,i);++K<P;){var oe=i[K],ve=o[K];if(p)var ae=x?p(ve,oe,K,o,i,T):p(oe,ve,K,i,o,T);if(ae!==r){if(ae)continue;Y=!1;break}if(te){if(!Hs(o,function(Te,Ae){if(!be(te,Ae)&&(oe===Te||y(oe,Te,l,p,T)))return te.push(Ae)})){Y=!1;break}}else if(!(oe===ve||y(oe,ve,l,p,T))){Y=!1;break}}return T.delete(i),T.delete(o),Y}function hA(i,o,l,p,y,T,x){switch(l){case Or:if(i.byteLength!=o.byteLength||i.byteOffset!=o.byteOffset)return!1;i=i.buffer,o=o.buffer;case sn:return!(i.byteLength!=o.byteLength||!T(new zc(i),new zc(o)));case Ri:case pr:case nn:return Er(+i,+o);case Ds:return i.name==o.name&&i.message==o.message;case Ci:case Ln:return i==o+"";case Pt:var P=Lf;case Mt:var N=p&I;if(P||(P=Fc),i.size!=o.size&&!N)return!1;var q=x.get(i);if(q)return q==o;p|=k,x.set(i,o);var z=Y_(P(i),P(o),p,y,T,x);return x.delete(i),z;case Mn:if(qa)return qa.call(i)==qa.call(o)}return!1}function fA(i,o,l,p,y,T){var x=l&I,P=ad(i),N=P.length,q=ad(o),z=q.length;if(N!=z&&!x)return!1;for(var K=N;K--;){var Y=P[K];if(!(x?Y in o:Me.call(o,Y)))return!1}var te=T.get(i),oe=T.get(o);if(te&&oe)return te==o&&oe==i;var ve=!0;T.set(i,o),T.set(o,i);for(var ae=x;++K<N;){Y=P[K];var Te=i[Y],Ae=o[Y];if(p)var Xt=x?p(Ae,Te,Y,o,i,T):p(Te,Ae,Y,i,o,T);if(!(Xt===r?Te===Ae||y(Te,Ae,l,p,T):Xt)){ve=!1;break}ae||(ae=Y=="constructor")}if(ve&&!ae){var kt=i.constructor,Zt=o.constructor;kt!=Zt&&"constructor"in i&&"constructor"in o&&!(typeof kt=="function"&&kt instanceof kt&&typeof Zt=="function"&&Zt instanceof Zt)&&(ve=!1)}return T.delete(i),T.delete(o),ve}function pn(i){return md(ny(i,r,fy),i+"")}function ad(i){return __(i,mt,hd)}function ud(i){return __(i,jt,X_)}var cd=Jc?function(i){return Jc.get(i)}:Rd;function ll(i){for(var o=i.name+"",l=eo[o],p=Me.call(eo,o)?l.length:0;p--;){var y=l[p],T=y.func;if(T==null||T==i)return y.name}return o}function io(i){var o=Me.call(w,"placeholder")?w:i;return o.placeholder}function se(){var i=w.iteratee||Ad;return i=i===Ad?w_:i,arguments.length?i(arguments[0],arguments[1]):i}function hl(i,o){var l=i.__data__;return wA(o)?l[typeof o=="string"?"string":"hash"]:l.map}function ld(i){for(var o=mt(i),l=o.length;l--;){var p=o[l],y=i[p];o[l]=[p,y,ty(y)]}return o}function es(i,o){var l=EI(i,o);return v_(l)?l:r}function dA(i){var o=Me.call(i,Qi),l=i[Qi];try{i[Qi]=r;var p=!0}catch{}var y=$c.call(i);return p&&(o?i[Qi]=l:delete i[Qi]),y}var hd=Ff?function(i){return i==null?[]:(i=Ue(i),yr(Ff(i),function(o){return i_.call(i,o)}))}:Pd,X_=Ff?function(i){for(var o=[];i;)vr(o,hd(i)),i=Gc(i);return o}:Pd,xt=Dt;(Uf&&xt(new Uf(new ArrayBuffer(1)))!=Or||Ba&&xt(new Ba)!=Pt||Bf&&xt(Bf.resolve())!=ma||Zs&&xt(new Zs)!=Mt||ja&&xt(new ja)!=Di)&&(xt=function(i){var o=Dt(i),l=o==Ht?i.constructor:r,p=l?ts(l):"";if(p)switch(p){case QI:return Or;case JI:return Pt;case YI:return ma;case XI:return Mt;case ZI:return Di}return o});function pA(i,o,l){for(var p=-1,y=l.length;++p<y;){var T=l[p],x=T.size;switch(T.type){case"drop":i+=x;break;case"dropRight":o-=x;break;case"take":o=It(o,i+x);break;case"takeRight":i=dt(i,o-x);break}}return{start:i,end:o}}function mA(i){var o=i.match(Ni);return o?o[1].split(Ef):[]}function Z_(i,o,l){o=ei(o,i);for(var p=-1,y=o.length,T=!1;++p<y;){var x=Br(o[p]);if(!(T=i!=null&&l(i,x)))break;i=i[x]}return T||++p!=y?T:(y=i==null?0:i.length,!!y&&yl(y)&&mn(x,y)&&(pe(i)||rs(i)))}function gA(i){var o=i.length,l=new i.constructor(o);return o&&typeof i[0]=="string"&&Me.call(i,"index")&&(l.index=i.index,l.input=i.input),l}function ey(i){return typeof i.constructor=="function"&&!Ja(i)?to(Gc(i)):{}}function _A(i,o,l){var p=i.constructor;switch(o){case sn:return id(i);case Ri:case pr:return new p(+i);case Or:return eA(i,l);case nt:case ut:case Fn:case Os:case ks:case _a:case on:case Ns:case Vs:return L_(i,l);case Pt:return new p;case nn:case Ln:return new p(i);case Ci:return tA(i);case Mt:return new p;case Mn:return rA(i)}}function yA(i,o){var l=o.length;if(!l)return i;var p=l-1;return o[p]=(l>1?"& ":"")+o[p],o=o.join(l>2?", ":" "),i.replace(ki,`{
|
|
1
|
+
var jP=Object.create;var Za=Object.defineProperty;var $P=Object.getOwnPropertyDescriptor;var qP=Object.getOwnPropertyNames;var zP=Object.getPrototypeOf,GP=Object.prototype.hasOwnProperty;var KP=(r,e,t)=>e in r?Za(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var WP=(r,e)=>()=>(r&&(e=r(r=0)),e);var cr=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),HP=(r,e)=>{for(var t in e)Za(r,t,{get:e[t],enumerable:!0})},Gy=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of qP(e))!GP.call(r,s)&&s!==t&&Za(r,s,{get:()=>e[s],enumerable:!(n=$P(e,s))||n.enumerable});return r};var Dd=(r,e,t)=>(t=r!=null?jP(zP(r)):{},Gy(e||!r||!r.__esModule?Za(t,"default",{value:r,enumerable:!0}):t,r)),QP=r=>Gy(Za({},"__esModule",{value:!0}),r);var gt=(r,e,t)=>KP(r,typeof e!="symbol"?e+"":e,t);var gs={};HP(gs,{Headers:()=>Eg,Request:()=>LF,Response:()=>MF,default:()=>Tg,fetch:()=>VF});var NF,ta,VF,Tg,Eg,LF,MF,Ei=WP(()=>{"use strict";NF=function(){if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;throw new Error("unable to locate global object")},ta=NF(),VF=ta.fetch,Tg=ta.fetch.bind(ta),Eg=ta.Headers,LF=ta.Request,MF=ta.Response});var Ag=cr(xg=>{"use strict";Object.defineProperty(xg,"__esModule",{value:!0});var Ig=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};xg.default=Ig});var Rg=cr(Vu=>{"use strict";var oE=Vu&&Vu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Vu,"__esModule",{value:!0});var UF=oE((Ei(),QP(gs))),BF=oE(Ag()),Sg=class{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.isMaybeSingle=e.isMaybeSingle,e.fetch?this.fetch=e.fetch:typeof fetch=="undefined"?this.fetch=UF.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=Object.assign({},this.headers),this.headers[e]=t,this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");let n=this.fetch,s=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async a=>{var c,h,f;let m=null,_=null,E=null,I=a.status,k=a.statusText;if(a.ok){if(this.method!=="HEAD"){let J=await a.text();J===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?_=J:_=JSON.parse(J))}let G=(c=this.headers.Prefer)===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),j=(h=a.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");G&&j&&j.length>1&&(E=parseInt(j[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(_)&&(_.length>1?(m={code:"PGRST116",details:`Results contain ${_.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},_=null,E=null,I=406,k="Not Acceptable"):_.length===1?_=_[0]:_=null)}else{let G=await a.text();try{m=JSON.parse(G),Array.isArray(m)&&a.status===404&&(_=[],m=null,I=200,k="OK")}catch{a.status===404&&G===""?(I=204,k="No Content"):m={message:G}}if(m&&this.isMaybeSingle&&(!((f=m==null?void 0:m.details)===null||f===void 0)&&f.includes("0 rows"))&&(m=null,I=200,k="OK"),m&&this.shouldThrowOnError)throw new BF.default(m)}return{error:m,data:_,count:E,status:I,statusText:k}});return this.shouldThrowOnError||(s=s.catch(a=>{var c,h,f;return{error:{message:`${(c=a==null?void 0:a.name)!==null&&c!==void 0?c:"FetchError"}: ${a==null?void 0:a.message}`,details:`${(h=a==null?void 0:a.stack)!==null&&h!==void 0?h:""}`,hint:"",code:`${(f=a==null?void 0:a.code)!==null&&f!==void 0?f:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}};Vu.default=Sg});var Cg=cr(Lu=>{"use strict";var jF=Lu&&Lu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Lu,"__esModule",{value:!0});var $F=jF(Rg()),Pg=class extends $F.default{select(e){let t=!1,n=(e!=null?e:"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",n),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:t=!0,nullsFirst:n,foreignTable:s,referencedTable:a=s}={}){let c=a?`${a}.order`:"order",h=this.url.searchParams.get(c);return this.url.searchParams.set(c,`${h?`${h},`:""}${e}.${t?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:n=t}={}){let s=typeof n=="undefined"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,t,{foreignTable:n,referencedTable:s=n}={}){let a=typeof s=="undefined"?"offset":`${s}.offset`,c=typeof s=="undefined"?"limit":`${s}.limit`;return this.url.searchParams.set(a,`${e}`),this.url.searchParams.set(c,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.method==="GET"?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:t=!1,settings:n=!1,buffers:s=!1,wal:a=!1,format:c="text"}={}){var h;let f=[e?"analyze":null,t?"verbose":null,n?"settings":null,s?"buffers":null,a?"wal":null].filter(Boolean).join("|"),m=(h=this.headers.Accept)!==null&&h!==void 0?h:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${c}; for="${m}"; options=${f};`,c==="json"?this:this}rollback(){var e;return((e=this.headers.Prefer)!==null&&e!==void 0?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}};Lu.default=Pg});var tf=cr(Mu=>{"use strict";var qF=Mu&&Mu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Mu,"__esModule",{value:!0});var zF=qF(Cg()),Dg=class extends zF.default{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){let n=Array.from(new Set(t)).map(s=>typeof s=="string"&&new RegExp("[,()]").test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:n,type:s}={}){let a="";s==="plain"?a="pl":s==="phrase"?a="ph":s==="websearch"&&(a="w");let c=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${a}fts${c}.${t}`),this}match(e){return Object.entries(e).forEach(([t,n])=>{this.url.searchParams.append(t,`eq.${n}`)}),this}not(e,t,n){return this.url.searchParams.append(e,`not.${t}.${n}`),this}or(e,{foreignTable:t,referencedTable:n=t}={}){let s=n?`${n}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,t,n){return this.url.searchParams.append(e,`${t}.${n}`),this}};Mu.default=Dg});var kg=cr(Uu=>{"use strict";var GF=Uu&&Uu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Uu,"__esModule",{value:!0});var Fu=GF(tf()),Og=class{constructor(e,{headers:t={},schema:n,fetch:s}){this.url=e,this.headers=t,this.schema=n,this.fetch=s}select(e,{head:t=!1,count:n}={}){let s=t?"HEAD":"GET",a=!1,c=(e!=null?e:"*").split("").map(h=>/\s/.test(h)&&!a?"":(h==='"'&&(a=!a),h)).join("");return this.url.searchParams.set("select",c),n&&(this.headers.Prefer=`count=${n}`),new Fu.default({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:t,defaultToNull:n=!0}={}){let s="POST",a=[];if(this.headers.Prefer&&a.push(this.headers.Prefer),t&&a.push(`count=${t}`),n||a.push("missing=default"),this.headers.Prefer=a.join(","),Array.isArray(e)){let c=e.reduce((h,f)=>h.concat(Object.keys(f)),[]);if(c.length>0){let h=[...new Set(c)].map(f=>`"${f}"`);this.url.searchParams.set("columns",h.join(","))}}return new Fu.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:t,ignoreDuplicates:n=!1,count:s,defaultToNull:a=!0}={}){let c="POST",h=[`resolution=${n?"ignore":"merge"}-duplicates`];if(t!==void 0&&this.url.searchParams.set("on_conflict",t),this.headers.Prefer&&h.push(this.headers.Prefer),s&&h.push(`count=${s}`),a||h.push("missing=default"),this.headers.Prefer=h.join(","),Array.isArray(e)){let f=e.reduce((m,_)=>m.concat(Object.keys(_)),[]);if(f.length>0){let m=[...new Set(f)].map(_=>`"${_}"`);this.url.searchParams.set("columns",m.join(","))}}return new Fu.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:t}={}){let n="PATCH",s=[];return this.headers.Prefer&&s.push(this.headers.Prefer),t&&s.push(`count=${t}`),this.headers.Prefer=s.join(","),new Fu.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){let t="DELETE",n=[];return e&&n.push(`count=${e}`),this.headers.Prefer&&n.unshift(this.headers.Prefer),this.headers.Prefer=n.join(","),new Fu.default({method:t,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}};Uu.default=Og});var aE=cr(rf=>{"use strict";Object.defineProperty(rf,"__esModule",{value:!0});rf.version=void 0;rf.version="0.0.0-automated"});var uE=cr(nf=>{"use strict";Object.defineProperty(nf,"__esModule",{value:!0});nf.DEFAULT_HEADERS=void 0;var KF=aE();nf.DEFAULT_HEADERS={"X-Client-Info":`postgrest-js/${KF.version}`}});var lE=cr(Bu=>{"use strict";var cE=Bu&&Bu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Bu,"__esModule",{value:!0});var WF=cE(kg()),HF=cE(tf()),QF=uE(),Ng=class r{constructor(e,{headers:t={},schema:n,fetch:s}={}){this.url=e,this.headers=Object.assign(Object.assign({},QF.DEFAULT_HEADERS),t),this.schemaName=n,this.fetch=s}from(e){let t=new URL(`${this.url}/${e}`);return new WF.default(t,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new r(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,t={},{head:n=!1,get:s=!1,count:a}={}){let c,h=new URL(`${this.url}/rpc/${e}`),f;n||s?(c=n?"HEAD":"GET",Object.entries(t).filter(([_,E])=>E!==void 0).map(([_,E])=>[_,Array.isArray(E)?`{${E.join(",")}}`:`${E}`]).forEach(([_,E])=>{h.searchParams.append(_,E)})):(c="POST",f=t);let m=Object.assign({},this.headers);return a&&(m.Prefer=`count=${a}`),new HF.default({method:c,url:h,headers:m,schema:this.schemaName,body:f,fetch:this.fetch,allowEmpty:!1})}};Bu.default=Ng});var _E=cr(bt=>{"use strict";var ra=bt&&bt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(bt,"__esModule",{value:!0});bt.PostgrestError=bt.PostgrestBuilder=bt.PostgrestTransformBuilder=bt.PostgrestFilterBuilder=bt.PostgrestQueryBuilder=bt.PostgrestClient=void 0;var hE=ra(lE());bt.PostgrestClient=hE.default;var fE=ra(kg());bt.PostgrestQueryBuilder=fE.default;var dE=ra(tf());bt.PostgrestFilterBuilder=dE.default;var pE=ra(Cg());bt.PostgrestTransformBuilder=pE.default;var mE=ra(Rg());bt.PostgrestBuilder=mE.default;var gE=ra(Ag());bt.PostgrestError=gE.default;bt.default={PostgrestClient:hE.default,PostgrestQueryBuilder:fE.default,PostgrestFilterBuilder:dE.default,PostgrestTransformBuilder:pE.default,PostgrestBuilder:mE.default,PostgrestError:gE.default}});var AE=cr((s3,xE)=>{"use strict";xE.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var cI=cr((fa,nc)=>{(function(){var r,e="4.17.21",t=200,n="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",a="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",h=500,f="__lodash_placeholder__",m=1,_=2,E=4,I=1,k=2,B=1,G=2,j=4,J=8,ee=16,re=32,le=64,de=128,ie=256,C=512,A=30,R="...",D=800,V=16,M=1,S=2,dr=3,Wt=1/0,Pr=9007199254740991,Ai=17976931348623157e292,Cr=NaN,Lt=4294967295,ac=Lt-1,vf=Lt>>>1,Dr=[["ary",de],["bind",B],["bindKey",G],["curry",J],["curryRight",ee],["flip",C],["partial",re],["partialRight",le],["rearg",ie]],Ke="[object Arguments]",Cs="[object Array]",Si="[object AsyncFunction]",Ri="[object Boolean]",pr="[object Date]",wf="[object DOMException]",Ds="[object Error]",rn="[object Function]",Pi="[object GeneratorFunction]",Pt="[object Map]",nn="[object Number]",pa="[object Null]",Ht="[object Object]",ma="[object Promise]",uc="[object Proxy]",Ci="[object RegExp]",Mt="[object Set]",Ln="[object String]",Mn="[object Symbol]",cc="[object Undefined]",Di="[object WeakMap]",ga="[object WeakSet]",sn="[object ArrayBuffer]",Or="[object DataView]",nt="[object Float32Array]",ut="[object Float64Array]",Fn="[object Int8Array]",Os="[object Int16Array]",ks="[object Int32Array]",_a="[object Uint8Array]",on="[object Uint8ClampedArray]",Ns="[object Uint16Array]",Vs="[object Uint32Array]",ya=/\b__p \+= '';/g,bf=/\b(__p \+=) '' \+/g,Tf=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ls=/&(?:amp|lt|gt|quot|#39);/g,va=/[&<>"']/g,lc=RegExp(Ls.source),Oi=RegExp(va.source),wa=/<%-([\s\S]+?)%>/g,ba=/<%([\s\S]+?)%>/g,kr=/<%=([\s\S]+?)%>/g,hc=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ms=/^\w*$/,fc=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,an=/[\\^$.*+?()[\]{}|]/g,dc=RegExp(an.source),ct=/^\s+/,pc=/\s/,ki=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ni=/\{\n\/\* \[wrapped with (.+)\] \*/,Ef=/,? & /,If=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Un=/[()=,{}\[\]\/\s]/,xf=/\\(\\)?/g,Af=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Vi=/\w*$/,mc=/^[-+]0x[0-9a-f]+$/i,Ta=/^0b[01]+$/i,Fs=/^\[object .+?Constructor\]$/,Nr=/^0o[0-7]+$/i,gc=/^(?:0|[1-9]\d*)$/,_c=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Bn=/($^)/,Ea=/['\n\r\u2028\u2029\\]/g,Li="\\ud800-\\udfff",yc="\\u0300-\\u036f",Sf="\\ufe20-\\ufe2f",Us="\\u20d0-\\u20ff",Ia=yc+Sf+Us,Bs="\\u2700-\\u27bf",jn="a-z\\xdf-\\xf6\\xf8-\\xff",un="\\xac\\xb1\\xd7\\xf7",xa="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Rf="\\u2000-\\u206f",vc=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Aa="A-Z\\xc0-\\xd6\\xd8-\\xde",Sa="\\ufe0e\\ufe0f",js=un+xa+Rf+vc,Mi="['\u2019]",wc="["+Li+"]",Ra="["+js+"]",$s="["+Ia+"]",bc="\\d+",Tc="["+Bs+"]",Pa="["+jn+"]",Ec="[^"+Li+js+bc+Bs+jn+Aa+"]",mr="\\ud83c[\\udffb-\\udfff]",gr="(?:"+$s+"|"+mr+")",Fi="[^"+Li+"]",$n="(?:\\ud83c[\\udde6-\\uddff]){2}",qs="[\\ud800-\\udbff][\\udc00-\\udfff]",Ce="["+Aa+"]",Ui="\\u200d",qn="(?:"+Pa+"|"+Ec+")",Bi="(?:"+Ce+"|"+Ec+")",Ic="(?:"+Mi+"(?:d|ll|m|re|s|t|ve))?",Ca="(?:"+Mi+"(?:D|LL|M|RE|S|T|VE))?",xc=gr+"?",Ac="["+Sa+"]?",Pf="(?:"+Ui+"(?:"+[Fi,$n,qs].join("|")+")"+Ac+xc+")*",Cf="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ji="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",_r=Ac+xc+Pf,Sc="(?:"+[Tc,$n,qs].join("|")+")"+_r,Rc="(?:"+[Fi+$s+"?",$s,$n,qs,wc].join("|")+")",Pc=RegExp(Mi,"g"),zn=RegExp($s,"g"),Da=RegExp(mr+"(?="+mr+")|"+Rc+_r,"g"),Df=RegExp([Ce+"?"+Pa+"+"+Ic+"(?="+[Ra,Ce,"$"].join("|")+")",Bi+"+"+Ca+"(?="+[Ra,Ce+qn,"$"].join("|")+")",Ce+"?"+qn+"+"+Ic,Ce+"+"+Ca,ji,Cf,bc,Sc].join("|"),"g"),Of=RegExp("["+Ui+Li+Ia+Sa+"]"),Vr=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,kf=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Nf=-1,Oe={};Oe[nt]=Oe[ut]=Oe[Fn]=Oe[Os]=Oe[ks]=Oe[_a]=Oe[on]=Oe[Ns]=Oe[Vs]=!0,Oe[Ke]=Oe[Cs]=Oe[sn]=Oe[Ri]=Oe[Or]=Oe[pr]=Oe[Ds]=Oe[rn]=Oe[Pt]=Oe[nn]=Oe[Ht]=Oe[Ci]=Oe[Mt]=Oe[Ln]=Oe[Di]=!1;var ke={};ke[Ke]=ke[Cs]=ke[sn]=ke[Or]=ke[Ri]=ke[pr]=ke[nt]=ke[ut]=ke[Fn]=ke[Os]=ke[ks]=ke[Pt]=ke[nn]=ke[Ht]=ke[Ci]=ke[Mt]=ke[Ln]=ke[Mn]=ke[_a]=ke[on]=ke[Ns]=ke[Vs]=!0,ke[Ds]=ke[rn]=ke[Di]=!1;var Cc={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},$i={"&":"&","<":"<",">":">",'"':""","'":"'"},qi={"&":"&","<":"<",">":">",""":'"',"'":"'"},Dc={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Oa=parseFloat,ze=parseInt,Oc=typeof global=="object"&&global&&global.Object===Object&&global,Vf=typeof self=="object"&&self&&self.Object===Object&&self,Xe=Oc||Vf||Function("return this")(),zs=typeof fa=="object"&&fa&&!fa.nodeType&&fa,Lr=zs&&typeof nc=="object"&&nc&&!nc.nodeType&&nc,zi=Lr&&Lr.exports===zs,Gs=zi&&Oc.process,He=function(){try{var O=Lr&&Lr.require&&Lr.require("util").types;return O||Gs&&Gs.binding&&Gs.binding("util")}catch{}}(),ka=He&&He.isArrayBuffer,kc=He&&He.isDate,Gn=He&&He.isMap,Na=He&&He.isRegExp,Ks=He&&He.isSet,Gi=He&&He.isTypedArray;function Et(O,$,U){switch(U.length){case 0:return O.call($);case 1:return O.call($,U[0]);case 2:return O.call($,U[0],U[1]);case 3:return O.call($,U[0],U[1],U[2])}return O.apply($,U)}function Ws(O,$,U,Z){for(var he=-1,Ne=O==null?0:O.length;++he<Ne;){var ft=O[he];$(Z,ft,U(ft),O)}return Z}function Ft(O,$){for(var U=-1,Z=O==null?0:O.length;++U<Z&&$(O[U],U,O)!==!1;);return O}function Nc(O,$){for(var U=O==null?0:O.length;U--&&$(O[U],U,O)!==!1;);return O}function Kn(O,$){for(var U=-1,Z=O==null?0:O.length;++U<Z;)if(!$(O[U],U,O))return!1;return!0}function yr(O,$){for(var U=-1,Z=O==null?0:O.length,he=0,Ne=[];++U<Z;){var ft=O[U];$(ft,U,O)&&(Ne[he++]=ft)}return Ne}function Ki(O,$){var U=O==null?0:O.length;return!!U&&wr(O,$,0)>-1}function Wi(O,$,U){for(var Z=-1,he=O==null?0:O.length;++Z<he;)if(U($,O[Z]))return!0;return!1}function Fe(O,$){for(var U=-1,Z=O==null?0:O.length,he=Array(Z);++U<Z;)he[U]=$(O[U],U,O);return he}function vr(O,$){for(var U=-1,Z=$.length,he=O.length;++U<Z;)O[he+U]=$[U];return O}function Wn(O,$,U,Z){var he=-1,Ne=O==null?0:O.length;for(Z&&Ne&&(U=O[++he]);++he<Ne;)U=$(U,O[he],he,O);return U}function Vc(O,$,U,Z){var he=O==null?0:O.length;for(Z&&he&&(U=O[--he]);he--;)U=$(U,O[he],he,O);return U}function Hs(O,$){for(var U=-1,Z=O==null?0:O.length;++U<Z;)if($(O[U],U,O))return!0;return!1}var cn=Mr("length");function Lc(O){return O.split("")}function Mc(O){return O.match(If)||[]}function Va(O,$,U){var Z;return U(O,function(he,Ne,ft){if($(he,Ne,ft))return Z=Ne,!1}),Z}function Hi(O,$,U,Z){for(var he=O.length,Ne=U+(Z?1:-1);Z?Ne--:++Ne<he;)if($(O[Ne],Ne,O))return Ne;return-1}function wr(O,$,U){return $===$?SI(O,$,U):Hi(O,La,U)}function Ct(O,$,U,Z){for(var he=U-1,Ne=O.length;++he<Ne;)if(Z(O[he],$))return he;return-1}function La(O){return O!==O}function Ma(O,$){var U=O==null?0:O.length;return U?b(O,$)/U:Cr}function Mr(O){return function($){return $==null?r:$[O]}}function u(O){return function($){return O==null?r:O[$]}}function d(O,$,U,Z,he){return he(O,function(Ne,ft,Ue){U=Z?(Z=!1,Ne):$(U,Ne,ft,Ue)}),U}function g(O,$){var U=O.length;for(O.sort($);U--;)O[U]=O[U].value;return O}function b(O,$){for(var U,Z=-1,he=O.length;++Z<he;){var Ne=$(O[Z]);Ne!==r&&(U=U===r?Ne:U+Ne)}return U}function L(O,$){for(var U=-1,Z=Array(O);++U<O;)Z[U]=$(U);return Z}function F(O,$){return Fe($,function(U){return[U,O[U]]})}function Q(O){return O&&O.slice(0,t_(O)+1).replace(ct,"")}function _e(O){return function($){return O($)}}function Ze(O,$){return Fe($,function(U){return O[U]})}function be(O,$){return O.has($)}function lt(O,$){for(var U=-1,Z=O.length;++U<Z&&wr($,O[U],0)>-1;);return U}function ht(O,$){for(var U=O.length;U--&&wr($,O[U],0)>-1;);return U}function Hn(O,$){for(var U=O.length,Z=0;U--;)O[U]===$&&++Z;return Z}var Qt=u(Cc),Qs=u($i);function Fa(O){return"\\"+Dc[O]}function EI(O,$){return O==null?r:O[$]}function Js(O){return Of.test(O)}function II(O){return Vr.test(O)}function xI(O){for(var $,U=[];!($=O.next()).done;)U.push($.value);return U}function Lf(O){var $=-1,U=Array(O.size);return O.forEach(function(Z,he){U[++$]=[he,Z]}),U}function e_(O,$){return function(U){return O($(U))}}function Qn(O,$){for(var U=-1,Z=O.length,he=0,Ne=[];++U<Z;){var ft=O[U];(ft===$||ft===f)&&(O[U]=f,Ne[he++]=U)}return Ne}function Fc(O){var $=-1,U=Array(O.size);return O.forEach(function(Z){U[++$]=Z}),U}function AI(O){var $=-1,U=Array(O.size);return O.forEach(function(Z){U[++$]=[Z,Z]}),U}function SI(O,$,U){for(var Z=U-1,he=O.length;++Z<he;)if(O[Z]===$)return Z;return-1}function RI(O,$,U){for(var Z=U+1;Z--;)if(O[Z]===$)return Z;return Z}function Ys(O){return Js(O)?CI(O):cn(O)}function br(O){return Js(O)?DI(O):Lc(O)}function t_(O){for(var $=O.length;$--&&pc.test(O.charAt($)););return $}var PI=u(qi);function CI(O){for(var $=Da.lastIndex=0;Da.test(O);)++$;return $}function DI(O){return O.match(Da)||[]}function OI(O){return O.match(Df)||[]}var kI=function O($){$=$==null?Xe:Jn.defaults(Xe.Object(),$,Jn.pick(Xe,kf));var U=$.Array,Z=$.Date,he=$.Error,Ne=$.Function,ft=$.Math,Ue=$.Object,Mf=$.RegExp,NI=$.String,nr=$.TypeError,Uc=U.prototype,VI=Ne.prototype,Xs=Ue.prototype,Bc=$["__core-js_shared__"],jc=VI.toString,Me=Xs.hasOwnProperty,LI=0,r_=function(){var i=/[^.]+$/.exec(Bc&&Bc.keys&&Bc.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}(),$c=Xs.toString,MI=jc.call(Ue),FI=Xe._,UI=Mf("^"+jc.call(Me).replace(an,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),qc=zi?$.Buffer:r,Yn=$.Symbol,zc=$.Uint8Array,n_=qc?qc.allocUnsafe:r,Gc=e_(Ue.getPrototypeOf,Ue),i_=Ue.create,s_=Xs.propertyIsEnumerable,Kc=Uc.splice,o_=Yn?Yn.isConcatSpreadable:r,Ua=Yn?Yn.iterator:r,Qi=Yn?Yn.toStringTag:r,Wc=function(){try{var i=es(Ue,"defineProperty");return i({},"",{}),i}catch{}}(),BI=$.clearTimeout!==Xe.clearTimeout&&$.clearTimeout,jI=Z&&Z.now!==Xe.Date.now&&Z.now,$I=$.setTimeout!==Xe.setTimeout&&$.setTimeout,Hc=ft.ceil,Qc=ft.floor,Ff=Ue.getOwnPropertySymbols,qI=qc?qc.isBuffer:r,a_=$.isFinite,zI=Uc.join,GI=e_(Ue.keys,Ue),dt=ft.max,It=ft.min,KI=Z.now,WI=$.parseInt,u_=ft.random,HI=Uc.reverse,Uf=es($,"DataView"),Ba=es($,"Map"),Bf=es($,"Promise"),Zs=es($,"Set"),ja=es($,"WeakMap"),$a=es(Ue,"create"),Jc=ja&&new ja,eo={},QI=ts(Uf),JI=ts(Ba),YI=ts(Bf),XI=ts(Zs),ZI=ts(ja),Yc=Yn?Yn.prototype:r,qa=Yc?Yc.valueOf:r,c_=Yc?Yc.toString:r;function w(i){if(Qe(i)&&!pe(i)&&!(i instanceof Ie)){if(i instanceof ir)return i;if(Me.call(i,"__wrapped__"))return ly(i)}return new ir(i)}var to=function(){function i(){}return function(o){if(!We(o))return{};if(i_)return i_(o);i.prototype=o;var l=new i;return i.prototype=r,l}}();function Xc(){}function ir(i,o){this.__wrapped__=i,this.__actions__=[],this.__chain__=!!o,this.__index__=0,this.__values__=r}w.templateSettings={escape:wa,evaluate:ba,interpolate:kr,variable:"",imports:{_:w}},w.prototype=Xc.prototype,w.prototype.constructor=w,ir.prototype=to(Xc.prototype),ir.prototype.constructor=ir;function Ie(i){this.__wrapped__=i,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Lt,this.__views__=[]}function ex(){var i=new Ie(this.__wrapped__);return i.__actions__=Ut(this.__actions__),i.__dir__=this.__dir__,i.__filtered__=this.__filtered__,i.__iteratees__=Ut(this.__iteratees__),i.__takeCount__=this.__takeCount__,i.__views__=Ut(this.__views__),i}function tx(){if(this.__filtered__){var i=new Ie(this);i.__dir__=-1,i.__filtered__=!0}else i=this.clone(),i.__dir__*=-1;return i}function rx(){var i=this.__wrapped__.value(),o=this.__dir__,l=pe(i),p=o<0,y=l?i.length:0,T=pA(0,y,this.__views__),x=T.start,P=T.end,N=P-x,q=p?P:x-1,z=this.__iteratees__,K=z.length,Y=0,te=It(N,this.__takeCount__);if(!l||!p&&y==N&&te==N)return k_(i,this.__actions__);var oe=[];e:for(;N--&&Y<te;){q+=o;for(var ve=-1,ae=i[q];++ve<K;){var Te=z[ve],Ae=Te.iteratee,Xt=Te.type,kt=Ae(ae);if(Xt==S)ae=kt;else if(!kt){if(Xt==M)continue e;break e}}oe[Y++]=ae}return oe}Ie.prototype=to(Xc.prototype),Ie.prototype.constructor=Ie;function Ji(i){var o=-1,l=i==null?0:i.length;for(this.clear();++o<l;){var p=i[o];this.set(p[0],p[1])}}function nx(){this.__data__=$a?$a(null):{},this.size=0}function ix(i){var o=this.has(i)&&delete this.__data__[i];return this.size-=o?1:0,o}function sx(i){var o=this.__data__;if($a){var l=o[i];return l===c?r:l}return Me.call(o,i)?o[i]:r}function ox(i){var o=this.__data__;return $a?o[i]!==r:Me.call(o,i)}function ax(i,o){var l=this.__data__;return this.size+=this.has(i)?0:1,l[i]=$a&&o===r?c:o,this}Ji.prototype.clear=nx,Ji.prototype.delete=ix,Ji.prototype.get=sx,Ji.prototype.has=ox,Ji.prototype.set=ax;function ln(i){var o=-1,l=i==null?0:i.length;for(this.clear();++o<l;){var p=i[o];this.set(p[0],p[1])}}function ux(){this.__data__=[],this.size=0}function cx(i){var o=this.__data__,l=Zc(o,i);if(l<0)return!1;var p=o.length-1;return l==p?o.pop():Kc.call(o,l,1),--this.size,!0}function lx(i){var o=this.__data__,l=Zc(o,i);return l<0?r:o[l][1]}function hx(i){return Zc(this.__data__,i)>-1}function fx(i,o){var l=this.__data__,p=Zc(l,i);return p<0?(++this.size,l.push([i,o])):l[p][1]=o,this}ln.prototype.clear=ux,ln.prototype.delete=cx,ln.prototype.get=lx,ln.prototype.has=hx,ln.prototype.set=fx;function hn(i){var o=-1,l=i==null?0:i.length;for(this.clear();++o<l;){var p=i[o];this.set(p[0],p[1])}}function dx(){this.size=0,this.__data__={hash:new Ji,map:new(Ba||ln),string:new Ji}}function px(i){var o=hl(this,i).delete(i);return this.size-=o?1:0,o}function mx(i){return hl(this,i).get(i)}function gx(i){return hl(this,i).has(i)}function _x(i,o){var l=hl(this,i),p=l.size;return l.set(i,o),this.size+=l.size==p?0:1,this}hn.prototype.clear=dx,hn.prototype.delete=px,hn.prototype.get=mx,hn.prototype.has=gx,hn.prototype.set=_x;function Yi(i){var o=-1,l=i==null?0:i.length;for(this.__data__=new hn;++o<l;)this.add(i[o])}function yx(i){return this.__data__.set(i,c),this}function vx(i){return this.__data__.has(i)}Yi.prototype.add=Yi.prototype.push=yx,Yi.prototype.has=vx;function Tr(i){var o=this.__data__=new ln(i);this.size=o.size}function wx(){this.__data__=new ln,this.size=0}function bx(i){var o=this.__data__,l=o.delete(i);return this.size=o.size,l}function Tx(i){return this.__data__.get(i)}function Ex(i){return this.__data__.has(i)}function Ix(i,o){var l=this.__data__;if(l instanceof ln){var p=l.__data__;if(!Ba||p.length<t-1)return p.push([i,o]),this.size=++l.size,this;l=this.__data__=new hn(p)}return l.set(i,o),this.size=l.size,this}Tr.prototype.clear=wx,Tr.prototype.delete=bx,Tr.prototype.get=Tx,Tr.prototype.has=Ex,Tr.prototype.set=Ix;function l_(i,o){var l=pe(i),p=!l&&rs(i),y=!l&&!p&&ri(i),T=!l&&!p&&!y&&so(i),x=l||p||y||T,P=x?L(i.length,NI):[],N=P.length;for(var q in i)(o||Me.call(i,q))&&!(x&&(q=="length"||y&&(q=="offset"||q=="parent")||T&&(q=="buffer"||q=="byteLength"||q=="byteOffset")||mn(q,N)))&&P.push(q);return P}function h_(i){var o=i.length;return o?i[Yf(0,o-1)]:r}function xx(i,o){return fl(Ut(i),Xi(o,0,i.length))}function Ax(i){return fl(Ut(i))}function jf(i,o,l){(l!==r&&!Er(i[o],l)||l===r&&!(o in i))&&fn(i,o,l)}function za(i,o,l){var p=i[o];(!(Me.call(i,o)&&Er(p,l))||l===r&&!(o in i))&&fn(i,o,l)}function Zc(i,o){for(var l=i.length;l--;)if(Er(i[l][0],o))return l;return-1}function Sx(i,o,l,p){return Xn(i,function(y,T,x){o(p,y,l(y),x)}),p}function f_(i,o){return i&&Ur(o,mt(o),i)}function Rx(i,o){return i&&Ur(o,jt(o),i)}function fn(i,o,l){o=="__proto__"&&Wc?Wc(i,o,{configurable:!0,enumerable:!0,value:l,writable:!0}):i[o]=l}function $f(i,o){for(var l=-1,p=o.length,y=U(p),T=i==null;++l<p;)y[l]=T?r:Td(i,o[l]);return y}function Xi(i,o,l){return i===i&&(l!==r&&(i=i<=l?i:l),o!==r&&(i=i>=o?i:o)),i}function sr(i,o,l,p,y,T){var x,P=o&m,N=o&_,q=o&E;if(l&&(x=y?l(i,p,y,T):l(i)),x!==r)return x;if(!We(i))return i;var z=pe(i);if(z){if(x=gA(i),!P)return Ut(i,x)}else{var K=xt(i),Y=K==rn||K==Pi;if(ri(i))return L_(i,P);if(K==Ht||K==Ke||Y&&!y){if(x=N||Y?{}:ty(i),!P)return N?sA(i,Rx(x,i)):iA(i,f_(x,i))}else{if(!ke[K])return y?i:{};x=_A(i,K,P)}}T||(T=new Tr);var te=T.get(i);if(te)return te;T.set(i,x),Cy(i)?i.forEach(function(ae){x.add(sr(ae,o,l,ae,i,T))}):Ry(i)&&i.forEach(function(ae,Te){x.set(Te,sr(ae,o,l,Te,i,T))});var oe=q?N?ud:ad:N?jt:mt,ve=z?r:oe(i);return Ft(ve||i,function(ae,Te){ve&&(Te=ae,ae=i[Te]),za(x,Te,sr(ae,o,l,Te,i,T))}),x}function Px(i){var o=mt(i);return function(l){return d_(l,i,o)}}function d_(i,o,l){var p=l.length;if(i==null)return!p;for(i=Ue(i);p--;){var y=l[p],T=o[y],x=i[y];if(x===r&&!(y in i)||!T(x))return!1}return!0}function p_(i,o,l){if(typeof i!="function")throw new nr(s);return Ya(function(){i.apply(r,l)},o)}function Ga(i,o,l,p){var y=-1,T=Ki,x=!0,P=i.length,N=[],q=o.length;if(!P)return N;l&&(o=Fe(o,_e(l))),p?(T=Wi,x=!1):o.length>=t&&(T=be,x=!1,o=new Yi(o));e:for(;++y<P;){var z=i[y],K=l==null?z:l(z);if(z=p||z!==0?z:0,x&&K===K){for(var Y=q;Y--;)if(o[Y]===K)continue e;N.push(z)}else T(o,K,p)||N.push(z)}return N}var Xn=j_(Fr),m_=j_(zf,!0);function Cx(i,o){var l=!0;return Xn(i,function(p,y,T){return l=!!o(p,y,T),l}),l}function el(i,o,l){for(var p=-1,y=i.length;++p<y;){var T=i[p],x=o(T);if(x!=null&&(P===r?x===x&&!Yt(x):l(x,P)))var P=x,N=T}return N}function Dx(i,o,l,p){var y=i.length;for(l=ye(l),l<0&&(l=-l>y?0:y+l),p=p===r||p>y?y:ye(p),p<0&&(p+=y),p=l>p?0:Oy(p);l<p;)i[l++]=o;return i}function g_(i,o){var l=[];return Xn(i,function(p,y,T){o(p,y,T)&&l.push(p)}),l}function vt(i,o,l,p,y){var T=-1,x=i.length;for(l||(l=vA),y||(y=[]);++T<x;){var P=i[T];o>0&&l(P)?o>1?vt(P,o-1,l,p,y):vr(y,P):p||(y[y.length]=P)}return y}var qf=$_(),__=$_(!0);function Fr(i,o){return i&&qf(i,o,mt)}function zf(i,o){return i&&__(i,o,mt)}function tl(i,o){return yr(o,function(l){return gn(i[l])})}function Zi(i,o){o=ei(o,i);for(var l=0,p=o.length;i!=null&&l<p;)i=i[Br(o[l++])];return l&&l==p?i:r}function y_(i,o,l){var p=o(i);return pe(i)?p:vr(p,l(i))}function Dt(i){return i==null?i===r?cc:pa:Qi&&Qi in Ue(i)?dA(i):AA(i)}function Gf(i,o){return i>o}function Ox(i,o){return i!=null&&Me.call(i,o)}function kx(i,o){return i!=null&&o in Ue(i)}function Nx(i,o,l){return i>=It(o,l)&&i<dt(o,l)}function Kf(i,o,l){for(var p=l?Wi:Ki,y=i[0].length,T=i.length,x=T,P=U(T),N=1/0,q=[];x--;){var z=i[x];x&&o&&(z=Fe(z,_e(o))),N=It(z.length,N),P[x]=!l&&(o||y>=120&&z.length>=120)?new Yi(x&&z):r}z=i[0];var K=-1,Y=P[0];e:for(;++K<y&&q.length<N;){var te=z[K],oe=o?o(te):te;if(te=l||te!==0?te:0,!(Y?be(Y,oe):p(q,oe,l))){for(x=T;--x;){var ve=P[x];if(!(ve?be(ve,oe):p(i[x],oe,l)))continue e}Y&&Y.push(oe),q.push(te)}}return q}function Vx(i,o,l,p){return Fr(i,function(y,T,x){o(p,l(y),T,x)}),p}function Ka(i,o,l){o=ei(o,i),i=sy(i,o);var p=i==null?i:i[Br(ar(o))];return p==null?r:Et(p,i,l)}function v_(i){return Qe(i)&&Dt(i)==Ke}function Lx(i){return Qe(i)&&Dt(i)==sn}function Mx(i){return Qe(i)&&Dt(i)==pr}function Wa(i,o,l,p,y){return i===o?!0:i==null||o==null||!Qe(i)&&!Qe(o)?i!==i&&o!==o:Fx(i,o,l,p,Wa,y)}function Fx(i,o,l,p,y,T){var x=pe(i),P=pe(o),N=x?Cs:xt(i),q=P?Cs:xt(o);N=N==Ke?Ht:N,q=q==Ke?Ht:q;var z=N==Ht,K=q==Ht,Y=N==q;if(Y&&ri(i)){if(!ri(o))return!1;x=!0,z=!1}if(Y&&!z)return T||(T=new Tr),x||so(i)?X_(i,o,l,p,y,T):hA(i,o,N,l,p,y,T);if(!(l&I)){var te=z&&Me.call(i,"__wrapped__"),oe=K&&Me.call(o,"__wrapped__");if(te||oe){var ve=te?i.value():i,ae=oe?o.value():o;return T||(T=new Tr),y(ve,ae,l,p,T)}}return Y?(T||(T=new Tr),fA(i,o,l,p,y,T)):!1}function Ux(i){return Qe(i)&&xt(i)==Pt}function Wf(i,o,l,p){var y=l.length,T=y,x=!p;if(i==null)return!T;for(i=Ue(i);y--;){var P=l[y];if(x&&P[2]?P[1]!==i[P[0]]:!(P[0]in i))return!1}for(;++y<T;){P=l[y];var N=P[0],q=i[N],z=P[1];if(x&&P[2]){if(q===r&&!(N in i))return!1}else{var K=new Tr;if(p)var Y=p(q,z,N,i,o,K);if(!(Y===r?Wa(z,q,I|k,p,K):Y))return!1}}return!0}function w_(i){if(!We(i)||bA(i))return!1;var o=gn(i)?UI:Fs;return o.test(ts(i))}function Bx(i){return Qe(i)&&Dt(i)==Ci}function jx(i){return Qe(i)&&xt(i)==Mt}function $x(i){return Qe(i)&&yl(i.length)&&!!Oe[Dt(i)]}function b_(i){return typeof i=="function"?i:i==null?$t:typeof i=="object"?pe(i)?I_(i[0],i[1]):E_(i):qy(i)}function Hf(i){if(!Ja(i))return GI(i);var o=[];for(var l in Ue(i))Me.call(i,l)&&l!="constructor"&&o.push(l);return o}function qx(i){if(!We(i))return xA(i);var o=Ja(i),l=[];for(var p in i)p=="constructor"&&(o||!Me.call(i,p))||l.push(p);return l}function Qf(i,o){return i<o}function T_(i,o){var l=-1,p=Bt(i)?U(i.length):[];return Xn(i,function(y,T,x){p[++l]=o(y,T,x)}),p}function E_(i){var o=ld(i);return o.length==1&&o[0][2]?ny(o[0][0],o[0][1]):function(l){return l===i||Wf(l,i,o)}}function I_(i,o){return fd(i)&&ry(o)?ny(Br(i),o):function(l){var p=Td(l,i);return p===r&&p===o?Ed(l,i):Wa(o,p,I|k)}}function rl(i,o,l,p,y){i!==o&&qf(o,function(T,x){if(y||(y=new Tr),We(T))zx(i,o,x,l,rl,p,y);else{var P=p?p(pd(i,x),T,x+"",i,o,y):r;P===r&&(P=T),jf(i,x,P)}},jt)}function zx(i,o,l,p,y,T,x){var P=pd(i,l),N=pd(o,l),q=x.get(N);if(q){jf(i,l,q);return}var z=T?T(P,N,l+"",i,o,x):r,K=z===r;if(K){var Y=pe(N),te=!Y&&ri(N),oe=!Y&&!te&&so(N);z=N,Y||te||oe?pe(P)?z=P:et(P)?z=Ut(P):te?(K=!1,z=L_(N,!0)):oe?(K=!1,z=M_(N,!0)):z=[]:Xa(N)||rs(N)?(z=P,rs(P)?z=ky(P):(!We(P)||gn(P))&&(z=ty(N))):K=!1}K&&(x.set(N,z),y(z,N,p,T,x),x.delete(N)),jf(i,l,z)}function x_(i,o){var l=i.length;if(l)return o+=o<0?l:0,mn(o,l)?i[o]:r}function A_(i,o,l){o.length?o=Fe(o,function(T){return pe(T)?function(x){return Zi(x,T.length===1?T[0]:T)}:T}):o=[$t];var p=-1;o=Fe(o,_e(se()));var y=T_(i,function(T,x,P){var N=Fe(o,function(q){return q(T)});return{criteria:N,index:++p,value:T}});return g(y,function(T,x){return nA(T,x,l)})}function Gx(i,o){return S_(i,o,function(l,p){return Ed(i,p)})}function S_(i,o,l){for(var p=-1,y=o.length,T={};++p<y;){var x=o[p],P=Zi(i,x);l(P,x)&&Ha(T,ei(x,i),P)}return T}function Kx(i){return function(o){return Zi(o,i)}}function Jf(i,o,l,p){var y=p?Ct:wr,T=-1,x=o.length,P=i;for(i===o&&(o=Ut(o)),l&&(P=Fe(i,_e(l)));++T<x;)for(var N=0,q=o[T],z=l?l(q):q;(N=y(P,z,N,p))>-1;)P!==i&&Kc.call(P,N,1),Kc.call(i,N,1);return i}function R_(i,o){for(var l=i?o.length:0,p=l-1;l--;){var y=o[l];if(l==p||y!==T){var T=y;mn(y)?Kc.call(i,y,1):ed(i,y)}}return i}function Yf(i,o){return i+Qc(u_()*(o-i+1))}function Wx(i,o,l,p){for(var y=-1,T=dt(Hc((o-i)/(l||1)),0),x=U(T);T--;)x[p?T:++y]=i,i+=l;return x}function Xf(i,o){var l="";if(!i||o<1||o>Pr)return l;do o%2&&(l+=i),o=Qc(o/2),o&&(i+=i);while(o);return l}function we(i,o){return md(iy(i,o,$t),i+"")}function Hx(i){return h_(oo(i))}function Qx(i,o){var l=oo(i);return fl(l,Xi(o,0,l.length))}function Ha(i,o,l,p){if(!We(i))return i;o=ei(o,i);for(var y=-1,T=o.length,x=T-1,P=i;P!=null&&++y<T;){var N=Br(o[y]),q=l;if(N==="__proto__"||N==="constructor"||N==="prototype")return i;if(y!=x){var z=P[N];q=p?p(z,N,P):r,q===r&&(q=We(z)?z:mn(o[y+1])?[]:{})}za(P,N,q),P=P[N]}return i}var P_=Jc?function(i,o){return Jc.set(i,o),i}:$t,Jx=Wc?function(i,o){return Wc(i,"toString",{configurable:!0,enumerable:!1,value:xd(o),writable:!0})}:$t;function Yx(i){return fl(oo(i))}function or(i,o,l){var p=-1,y=i.length;o<0&&(o=-o>y?0:y+o),l=l>y?y:l,l<0&&(l+=y),y=o>l?0:l-o>>>0,o>>>=0;for(var T=U(y);++p<y;)T[p]=i[p+o];return T}function Xx(i,o){var l;return Xn(i,function(p,y,T){return l=o(p,y,T),!l}),!!l}function nl(i,o,l){var p=0,y=i==null?p:i.length;if(typeof o=="number"&&o===o&&y<=vf){for(;p<y;){var T=p+y>>>1,x=i[T];x!==null&&!Yt(x)&&(l?x<=o:x<o)?p=T+1:y=T}return y}return Zf(i,o,$t,l)}function Zf(i,o,l,p){var y=0,T=i==null?0:i.length;if(T===0)return 0;o=l(o);for(var x=o!==o,P=o===null,N=Yt(o),q=o===r;y<T;){var z=Qc((y+T)/2),K=l(i[z]),Y=K!==r,te=K===null,oe=K===K,ve=Yt(K);if(x)var ae=p||oe;else q?ae=oe&&(p||Y):P?ae=oe&&Y&&(p||!te):N?ae=oe&&Y&&!te&&(p||!ve):te||ve?ae=!1:ae=p?K<=o:K<o;ae?y=z+1:T=z}return It(T,ac)}function C_(i,o){for(var l=-1,p=i.length,y=0,T=[];++l<p;){var x=i[l],P=o?o(x):x;if(!l||!Er(P,N)){var N=P;T[y++]=x===0?0:x}}return T}function D_(i){return typeof i=="number"?i:Yt(i)?Cr:+i}function Jt(i){if(typeof i=="string")return i;if(pe(i))return Fe(i,Jt)+"";if(Yt(i))return c_?c_.call(i):"";var o=i+"";return o=="0"&&1/i==-Wt?"-0":o}function Zn(i,o,l){var p=-1,y=Ki,T=i.length,x=!0,P=[],N=P;if(l)x=!1,y=Wi;else if(T>=t){var q=o?null:cA(i);if(q)return Fc(q);x=!1,y=be,N=new Yi}else N=o?[]:P;e:for(;++p<T;){var z=i[p],K=o?o(z):z;if(z=l||z!==0?z:0,x&&K===K){for(var Y=N.length;Y--;)if(N[Y]===K)continue e;o&&N.push(K),P.push(z)}else y(N,K,l)||(N!==P&&N.push(K),P.push(z))}return P}function ed(i,o){return o=ei(o,i),i=sy(i,o),i==null||delete i[Br(ar(o))]}function O_(i,o,l,p){return Ha(i,o,l(Zi(i,o)),p)}function il(i,o,l,p){for(var y=i.length,T=p?y:-1;(p?T--:++T<y)&&o(i[T],T,i););return l?or(i,p?0:T,p?T+1:y):or(i,p?T+1:0,p?y:T)}function k_(i,o){var l=i;return l instanceof Ie&&(l=l.value()),Wn(o,function(p,y){return y.func.apply(y.thisArg,vr([p],y.args))},l)}function td(i,o,l){var p=i.length;if(p<2)return p?Zn(i[0]):[];for(var y=-1,T=U(p);++y<p;)for(var x=i[y],P=-1;++P<p;)P!=y&&(T[y]=Ga(T[y]||x,i[P],o,l));return Zn(vt(T,1),o,l)}function N_(i,o,l){for(var p=-1,y=i.length,T=o.length,x={};++p<y;){var P=p<T?o[p]:r;l(x,i[p],P)}return x}function rd(i){return et(i)?i:[]}function nd(i){return typeof i=="function"?i:$t}function ei(i,o){return pe(i)?i:fd(i,o)?[i]:cy(Ve(i))}var Zx=we;function ti(i,o,l){var p=i.length;return l=l===r?p:l,!o&&l>=p?i:or(i,o,l)}var V_=BI||function(i){return Xe.clearTimeout(i)};function L_(i,o){if(o)return i.slice();var l=i.length,p=n_?n_(l):new i.constructor(l);return i.copy(p),p}function id(i){var o=new i.constructor(i.byteLength);return new zc(o).set(new zc(i)),o}function eA(i,o){var l=o?id(i.buffer):i.buffer;return new i.constructor(l,i.byteOffset,i.byteLength)}function tA(i){var o=new i.constructor(i.source,Vi.exec(i));return o.lastIndex=i.lastIndex,o}function rA(i){return qa?Ue(qa.call(i)):{}}function M_(i,o){var l=o?id(i.buffer):i.buffer;return new i.constructor(l,i.byteOffset,i.length)}function F_(i,o){if(i!==o){var l=i!==r,p=i===null,y=i===i,T=Yt(i),x=o!==r,P=o===null,N=o===o,q=Yt(o);if(!P&&!q&&!T&&i>o||T&&x&&N&&!P&&!q||p&&x&&N||!l&&N||!y)return 1;if(!p&&!T&&!q&&i<o||q&&l&&y&&!p&&!T||P&&l&&y||!x&&y||!N)return-1}return 0}function nA(i,o,l){for(var p=-1,y=i.criteria,T=o.criteria,x=y.length,P=l.length;++p<x;){var N=F_(y[p],T[p]);if(N){if(p>=P)return N;var q=l[p];return N*(q=="desc"?-1:1)}}return i.index-o.index}function U_(i,o,l,p){for(var y=-1,T=i.length,x=l.length,P=-1,N=o.length,q=dt(T-x,0),z=U(N+q),K=!p;++P<N;)z[P]=o[P];for(;++y<x;)(K||y<T)&&(z[l[y]]=i[y]);for(;q--;)z[P++]=i[y++];return z}function B_(i,o,l,p){for(var y=-1,T=i.length,x=-1,P=l.length,N=-1,q=o.length,z=dt(T-P,0),K=U(z+q),Y=!p;++y<z;)K[y]=i[y];for(var te=y;++N<q;)K[te+N]=o[N];for(;++x<P;)(Y||y<T)&&(K[te+l[x]]=i[y++]);return K}function Ut(i,o){var l=-1,p=i.length;for(o||(o=U(p));++l<p;)o[l]=i[l];return o}function Ur(i,o,l,p){var y=!l;l||(l={});for(var T=-1,x=o.length;++T<x;){var P=o[T],N=p?p(l[P],i[P],P,l,i):r;N===r&&(N=i[P]),y?fn(l,P,N):za(l,P,N)}return l}function iA(i,o){return Ur(i,hd(i),o)}function sA(i,o){return Ur(i,Z_(i),o)}function sl(i,o){return function(l,p){var y=pe(l)?Ws:Sx,T=o?o():{};return y(l,i,se(p,2),T)}}function ro(i){return we(function(o,l){var p=-1,y=l.length,T=y>1?l[y-1]:r,x=y>2?l[2]:r;for(T=i.length>3&&typeof T=="function"?(y--,T):r,x&&Ot(l[0],l[1],x)&&(T=y<3?r:T,y=1),o=Ue(o);++p<y;){var P=l[p];P&&i(o,P,p,T)}return o})}function j_(i,o){return function(l,p){if(l==null)return l;if(!Bt(l))return i(l,p);for(var y=l.length,T=o?y:-1,x=Ue(l);(o?T--:++T<y)&&p(x[T],T,x)!==!1;);return l}}function $_(i){return function(o,l,p){for(var y=-1,T=Ue(o),x=p(o),P=x.length;P--;){var N=x[i?P:++y];if(l(T[N],N,T)===!1)break}return o}}function oA(i,o,l){var p=o&B,y=Qa(i);function T(){var x=this&&this!==Xe&&this instanceof T?y:i;return x.apply(p?l:this,arguments)}return T}function q_(i){return function(o){o=Ve(o);var l=Js(o)?br(o):r,p=l?l[0]:o.charAt(0),y=l?ti(l,1).join(""):o.slice(1);return p[i]()+y}}function no(i){return function(o){return Wn(jy(By(o).replace(Pc,"")),i,"")}}function Qa(i){return function(){var o=arguments;switch(o.length){case 0:return new i;case 1:return new i(o[0]);case 2:return new i(o[0],o[1]);case 3:return new i(o[0],o[1],o[2]);case 4:return new i(o[0],o[1],o[2],o[3]);case 5:return new i(o[0],o[1],o[2],o[3],o[4]);case 6:return new i(o[0],o[1],o[2],o[3],o[4],o[5]);case 7:return new i(o[0],o[1],o[2],o[3],o[4],o[5],o[6])}var l=to(i.prototype),p=i.apply(l,o);return We(p)?p:l}}function aA(i,o,l){var p=Qa(i);function y(){for(var T=arguments.length,x=U(T),P=T,N=io(y);P--;)x[P]=arguments[P];var q=T<3&&x[0]!==N&&x[T-1]!==N?[]:Qn(x,N);if(T-=q.length,T<l)return H_(i,o,ol,y.placeholder,r,x,q,r,r,l-T);var z=this&&this!==Xe&&this instanceof y?p:i;return Et(z,this,x)}return y}function z_(i){return function(o,l,p){var y=Ue(o);if(!Bt(o)){var T=se(l,3);o=mt(o),l=function(P){return T(y[P],P,y)}}var x=i(o,l,p);return x>-1?y[T?o[x]:x]:r}}function G_(i){return pn(function(o){var l=o.length,p=l,y=ir.prototype.thru;for(i&&o.reverse();p--;){var T=o[p];if(typeof T!="function")throw new nr(s);if(y&&!x&&ll(T)=="wrapper")var x=new ir([],!0)}for(p=x?p:l;++p<l;){T=o[p];var P=ll(T),N=P=="wrapper"?cd(T):r;N&&dd(N[0])&&N[1]==(de|J|re|ie)&&!N[4].length&&N[9]==1?x=x[ll(N[0])].apply(x,N[3]):x=T.length==1&&dd(T)?x[P]():x.thru(T)}return function(){var q=arguments,z=q[0];if(x&&q.length==1&&pe(z))return x.plant(z).value();for(var K=0,Y=l?o[K].apply(this,q):z;++K<l;)Y=o[K].call(this,Y);return Y}})}function ol(i,o,l,p,y,T,x,P,N,q){var z=o&de,K=o&B,Y=o&G,te=o&(J|ee),oe=o&C,ve=Y?r:Qa(i);function ae(){for(var Te=arguments.length,Ae=U(Te),Xt=Te;Xt--;)Ae[Xt]=arguments[Xt];if(te)var kt=io(ae),Zt=Hn(Ae,kt);if(p&&(Ae=U_(Ae,p,y,te)),T&&(Ae=B_(Ae,T,x,te)),Te-=Zt,te&&Te<q){var tt=Qn(Ae,kt);return H_(i,o,ol,ae.placeholder,l,Ae,tt,P,N,q-Te)}var Ir=K?l:this,yn=Y?Ir[i]:i;return Te=Ae.length,P?Ae=SA(Ae,P):oe&&Te>1&&Ae.reverse(),z&&N<Te&&(Ae.length=N),this&&this!==Xe&&this instanceof ae&&(yn=ve||Qa(yn)),yn.apply(Ir,Ae)}return ae}function K_(i,o){return function(l,p){return Vx(l,i,o(p),{})}}function al(i,o){return function(l,p){var y;if(l===r&&p===r)return o;if(l!==r&&(y=l),p!==r){if(y===r)return p;typeof l=="string"||typeof p=="string"?(l=Jt(l),p=Jt(p)):(l=D_(l),p=D_(p)),y=i(l,p)}return y}}function sd(i){return pn(function(o){return o=Fe(o,_e(se())),we(function(l){var p=this;return i(o,function(y){return Et(y,p,l)})})})}function ul(i,o){o=o===r?" ":Jt(o);var l=o.length;if(l<2)return l?Xf(o,i):o;var p=Xf(o,Hc(i/Ys(o)));return Js(o)?ti(br(p),0,i).join(""):p.slice(0,i)}function uA(i,o,l,p){var y=o&B,T=Qa(i);function x(){for(var P=-1,N=arguments.length,q=-1,z=p.length,K=U(z+N),Y=this&&this!==Xe&&this instanceof x?T:i;++q<z;)K[q]=p[q];for(;N--;)K[q++]=arguments[++P];return Et(Y,y?l:this,K)}return x}function W_(i){return function(o,l,p){return p&&typeof p!="number"&&Ot(o,l,p)&&(l=p=r),o=_n(o),l===r?(l=o,o=0):l=_n(l),p=p===r?o<l?1:-1:_n(p),Wx(o,l,p,i)}}function cl(i){return function(o,l){return typeof o=="string"&&typeof l=="string"||(o=ur(o),l=ur(l)),i(o,l)}}function H_(i,o,l,p,y,T,x,P,N,q){var z=o&J,K=z?x:r,Y=z?r:x,te=z?T:r,oe=z?r:T;o|=z?re:le,o&=~(z?le:re),o&j||(o&=~(B|G));var ve=[i,o,y,te,K,oe,Y,P,N,q],ae=l.apply(r,ve);return dd(i)&&oy(ae,ve),ae.placeholder=p,ay(ae,i,o)}function od(i){var o=ft[i];return function(l,p){if(l=ur(l),p=p==null?0:It(ye(p),292),p&&a_(l)){var y=(Ve(l)+"e").split("e"),T=o(y[0]+"e"+(+y[1]+p));return y=(Ve(T)+"e").split("e"),+(y[0]+"e"+(+y[1]-p))}return o(l)}}var cA=Zs&&1/Fc(new Zs([,-0]))[1]==Wt?function(i){return new Zs(i)}:Rd;function Q_(i){return function(o){var l=xt(o);return l==Pt?Lf(o):l==Mt?AI(o):F(o,i(o))}}function dn(i,o,l,p,y,T,x,P){var N=o&G;if(!N&&typeof i!="function")throw new nr(s);var q=p?p.length:0;if(q||(o&=~(re|le),p=y=r),x=x===r?x:dt(ye(x),0),P=P===r?P:ye(P),q-=y?y.length:0,o&le){var z=p,K=y;p=y=r}var Y=N?r:cd(i),te=[i,o,l,p,y,z,K,T,x,P];if(Y&&IA(te,Y),i=te[0],o=te[1],l=te[2],p=te[3],y=te[4],P=te[9]=te[9]===r?N?0:i.length:dt(te[9]-q,0),!P&&o&(J|ee)&&(o&=~(J|ee)),!o||o==B)var oe=oA(i,o,l);else o==J||o==ee?oe=aA(i,o,P):(o==re||o==(B|re))&&!y.length?oe=uA(i,o,l,p):oe=ol.apply(r,te);var ve=Y?P_:oy;return ay(ve(oe,te),i,o)}function J_(i,o,l,p){return i===r||Er(i,Xs[l])&&!Me.call(p,l)?o:i}function Y_(i,o,l,p,y,T){return We(i)&&We(o)&&(T.set(o,i),rl(i,o,r,Y_,T),T.delete(o)),i}function lA(i){return Xa(i)?r:i}function X_(i,o,l,p,y,T){var x=l&I,P=i.length,N=o.length;if(P!=N&&!(x&&N>P))return!1;var q=T.get(i),z=T.get(o);if(q&&z)return q==o&&z==i;var K=-1,Y=!0,te=l&k?new Yi:r;for(T.set(i,o),T.set(o,i);++K<P;){var oe=i[K],ve=o[K];if(p)var ae=x?p(ve,oe,K,o,i,T):p(oe,ve,K,i,o,T);if(ae!==r){if(ae)continue;Y=!1;break}if(te){if(!Hs(o,function(Te,Ae){if(!be(te,Ae)&&(oe===Te||y(oe,Te,l,p,T)))return te.push(Ae)})){Y=!1;break}}else if(!(oe===ve||y(oe,ve,l,p,T))){Y=!1;break}}return T.delete(i),T.delete(o),Y}function hA(i,o,l,p,y,T,x){switch(l){case Or:if(i.byteLength!=o.byteLength||i.byteOffset!=o.byteOffset)return!1;i=i.buffer,o=o.buffer;case sn:return!(i.byteLength!=o.byteLength||!T(new zc(i),new zc(o)));case Ri:case pr:case nn:return Er(+i,+o);case Ds:return i.name==o.name&&i.message==o.message;case Ci:case Ln:return i==o+"";case Pt:var P=Lf;case Mt:var N=p&I;if(P||(P=Fc),i.size!=o.size&&!N)return!1;var q=x.get(i);if(q)return q==o;p|=k,x.set(i,o);var z=X_(P(i),P(o),p,y,T,x);return x.delete(i),z;case Mn:if(qa)return qa.call(i)==qa.call(o)}return!1}function fA(i,o,l,p,y,T){var x=l&I,P=ad(i),N=P.length,q=ad(o),z=q.length;if(N!=z&&!x)return!1;for(var K=N;K--;){var Y=P[K];if(!(x?Y in o:Me.call(o,Y)))return!1}var te=T.get(i),oe=T.get(o);if(te&&oe)return te==o&&oe==i;var ve=!0;T.set(i,o),T.set(o,i);for(var ae=x;++K<N;){Y=P[K];var Te=i[Y],Ae=o[Y];if(p)var Xt=x?p(Ae,Te,Y,o,i,T):p(Te,Ae,Y,i,o,T);if(!(Xt===r?Te===Ae||y(Te,Ae,l,p,T):Xt)){ve=!1;break}ae||(ae=Y=="constructor")}if(ve&&!ae){var kt=i.constructor,Zt=o.constructor;kt!=Zt&&"constructor"in i&&"constructor"in o&&!(typeof kt=="function"&&kt instanceof kt&&typeof Zt=="function"&&Zt instanceof Zt)&&(ve=!1)}return T.delete(i),T.delete(o),ve}function pn(i){return md(iy(i,r,dy),i+"")}function ad(i){return y_(i,mt,hd)}function ud(i){return y_(i,jt,Z_)}var cd=Jc?function(i){return Jc.get(i)}:Rd;function ll(i){for(var o=i.name+"",l=eo[o],p=Me.call(eo,o)?l.length:0;p--;){var y=l[p],T=y.func;if(T==null||T==i)return y.name}return o}function io(i){var o=Me.call(w,"placeholder")?w:i;return o.placeholder}function se(){var i=w.iteratee||Ad;return i=i===Ad?b_:i,arguments.length?i(arguments[0],arguments[1]):i}function hl(i,o){var l=i.__data__;return wA(o)?l[typeof o=="string"?"string":"hash"]:l.map}function ld(i){for(var o=mt(i),l=o.length;l--;){var p=o[l],y=i[p];o[l]=[p,y,ry(y)]}return o}function es(i,o){var l=EI(i,o);return w_(l)?l:r}function dA(i){var o=Me.call(i,Qi),l=i[Qi];try{i[Qi]=r;var p=!0}catch{}var y=$c.call(i);return p&&(o?i[Qi]=l:delete i[Qi]),y}var hd=Ff?function(i){return i==null?[]:(i=Ue(i),yr(Ff(i),function(o){return s_.call(i,o)}))}:Pd,Z_=Ff?function(i){for(var o=[];i;)vr(o,hd(i)),i=Gc(i);return o}:Pd,xt=Dt;(Uf&&xt(new Uf(new ArrayBuffer(1)))!=Or||Ba&&xt(new Ba)!=Pt||Bf&&xt(Bf.resolve())!=ma||Zs&&xt(new Zs)!=Mt||ja&&xt(new ja)!=Di)&&(xt=function(i){var o=Dt(i),l=o==Ht?i.constructor:r,p=l?ts(l):"";if(p)switch(p){case QI:return Or;case JI:return Pt;case YI:return ma;case XI:return Mt;case ZI:return Di}return o});function pA(i,o,l){for(var p=-1,y=l.length;++p<y;){var T=l[p],x=T.size;switch(T.type){case"drop":i+=x;break;case"dropRight":o-=x;break;case"take":o=It(o,i+x);break;case"takeRight":i=dt(i,o-x);break}}return{start:i,end:o}}function mA(i){var o=i.match(Ni);return o?o[1].split(Ef):[]}function ey(i,o,l){o=ei(o,i);for(var p=-1,y=o.length,T=!1;++p<y;){var x=Br(o[p]);if(!(T=i!=null&&l(i,x)))break;i=i[x]}return T||++p!=y?T:(y=i==null?0:i.length,!!y&&yl(y)&&mn(x,y)&&(pe(i)||rs(i)))}function gA(i){var o=i.length,l=new i.constructor(o);return o&&typeof i[0]=="string"&&Me.call(i,"index")&&(l.index=i.index,l.input=i.input),l}function ty(i){return typeof i.constructor=="function"&&!Ja(i)?to(Gc(i)):{}}function _A(i,o,l){var p=i.constructor;switch(o){case sn:return id(i);case Ri:case pr:return new p(+i);case Or:return eA(i,l);case nt:case ut:case Fn:case Os:case ks:case _a:case on:case Ns:case Vs:return M_(i,l);case Pt:return new p;case nn:case Ln:return new p(i);case Ci:return tA(i);case Mt:return new p;case Mn:return rA(i)}}function yA(i,o){var l=o.length;if(!l)return i;var p=l-1;return o[p]=(l>1?"& ":"")+o[p],o=o.join(l>2?", ":" "),i.replace(ki,`{
|
|
2
2
|
/* [wrapped with `+o+`] */
|
|
3
|
-
`)}function vA(i){return pe(i)||rs(i)||!!(s_&&i&&i[s_])}function mn(i,o){var l=typeof i;return o=o==null?Pr:o,!!o&&(l=="number"||l!="symbol"&&gc.test(i))&&i>-1&&i%1==0&&i<o}function Ot(i,o,l){if(!We(l))return!1;var p=typeof o;return(p=="number"?Bt(l)&&mn(o,l.length):p=="string"&&o in l)?Er(l[o],i):!1}function fd(i,o){if(pe(i))return!1;var l=typeof i;return l=="number"||l=="symbol"||l=="boolean"||i==null||Yt(i)?!0:Ms.test(i)||!hc.test(i)||o!=null&&i in Ue(o)}function wA(i){var o=typeof i;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?i!=="__proto__":i===null}function dd(i){var o=ll(i),l=w[o];if(typeof l!="function"||!(o in Ie.prototype))return!1;if(i===l)return!0;var p=cd(l);return!!p&&i===p[0]}function bA(i){return!!t_&&t_ in i}var TA=Bc?gn:Cd;function Ja(i){var o=i&&i.constructor,l=typeof o=="function"&&o.prototype||Xs;return i===l}function ty(i){return i===i&&!We(i)}function ry(i,o){return function(l){return l==null?!1:l[i]===o&&(o!==r||i in Ue(l))}}function EA(i){var o=gl(i,function(p){return l.size===h&&l.clear(),p}),l=o.cache;return o}function IA(i,o){var l=i[1],p=o[1],y=l|p,T=y<(B|G|de),x=p==de&&l==J||p==de&&l==ie&&i[7].length<=o[8]||p==(de|ie)&&o[7].length<=o[8]&&l==J;if(!(T||x))return i;p&B&&(i[2]=o[2],y|=l&B?0:j);var P=o[3];if(P){var N=i[3];i[3]=N?F_(N,P,o[4]):P,i[4]=N?Qn(i[3],f):o[4]}return P=o[5],P&&(N=i[5],i[5]=N?U_(N,P,o[6]):P,i[6]=N?Qn(i[5],f):o[6]),P=o[7],P&&(i[7]=P),p&de&&(i[8]=i[8]==null?o[8]:It(i[8],o[8])),i[9]==null&&(i[9]=o[9]),i[0]=o[0],i[1]=y,i}function xA(i){var o=[];if(i!=null)for(var l in Ue(i))o.push(l);return o}function AA(i){return $c.call(i)}function ny(i,o,l){return o=dt(o===r?i.length-1:o,0),function(){for(var p=arguments,y=-1,T=dt(p.length-o,0),x=U(T);++y<T;)x[y]=p[o+y];y=-1;for(var P=U(o+1);++y<o;)P[y]=p[y];return P[o]=l(x),Et(i,this,P)}}function iy(i,o){return o.length<2?i:Zi(i,or(o,0,-1))}function SA(i,o){for(var l=i.length,p=It(o.length,l),y=Ut(i);p--;){var T=o[p];i[p]=mn(T,l)?y[T]:r}return i}function pd(i,o){if(!(o==="constructor"&&typeof i[o]=="function")&&o!="__proto__")return i[o]}var sy=ay(R_),Ya=$I||function(i,o){return Xe.setTimeout(i,o)},md=ay(Jx);function oy(i,o,l){var p=o+"";return md(i,yA(p,RA(mA(p),l)))}function ay(i){var o=0,l=0;return function(){var p=KI(),y=V-(p-l);if(l=p,y>0){if(++o>=D)return arguments[0]}else o=0;return i.apply(r,arguments)}}function fl(i,o){var l=-1,p=i.length,y=p-1;for(o=o===r?p:o;++l<o;){var T=Yf(l,y),x=i[T];i[T]=i[l],i[l]=x}return i.length=o,i}var uy=EA(function(i){var o=[];return i.charCodeAt(0)===46&&o.push(""),i.replace(fc,function(l,p,y,T){o.push(y?T.replace(xf,"$1"):p||l)}),o});function Br(i){if(typeof i=="string"||Yt(i))return i;var o=i+"";return o=="0"&&1/i==-Wt?"-0":o}function ts(i){if(i!=null){try{return jc.call(i)}catch{}try{return i+""}catch{}}return""}function RA(i,o){return Ft(Dr,function(l){var p="_."+l[0];o&l[1]&&!Ki(i,p)&&i.push(p)}),i.sort()}function cy(i){if(i instanceof Ie)return i.clone();var o=new ir(i.__wrapped__,i.__chain__);return o.__actions__=Ut(i.__actions__),o.__index__=i.__index__,o.__values__=i.__values__,o}function PA(i,o,l){(l?Ot(i,o,l):o===r)?o=1:o=dt(ye(o),0);var p=i==null?0:i.length;if(!p||o<1)return[];for(var y=0,T=0,x=U(Hc(p/o));y<p;)x[T++]=or(i,y,y+=o);return x}function CA(i){for(var o=-1,l=i==null?0:i.length,p=0,y=[];++o<l;){var T=i[o];T&&(y[p++]=T)}return y}function DA(){var i=arguments.length;if(!i)return[];for(var o=U(i-1),l=arguments[0],p=i;p--;)o[p-1]=arguments[p];return vr(pe(l)?Ut(l):[l],vt(o,1))}var OA=we(function(i,o){return et(i)?Ga(i,vt(o,1,et,!0)):[]}),kA=we(function(i,o){var l=ar(o);return et(l)&&(l=r),et(i)?Ga(i,vt(o,1,et,!0),se(l,2)):[]}),NA=we(function(i,o){var l=ar(o);return et(l)&&(l=r),et(i)?Ga(i,vt(o,1,et,!0),r,l):[]});function VA(i,o,l){var p=i==null?0:i.length;return p?(o=l||o===r?1:ye(o),or(i,o<0?0:o,p)):[]}function LA(i,o,l){var p=i==null?0:i.length;return p?(o=l||o===r?1:ye(o),o=p-o,or(i,0,o<0?0:o)):[]}function MA(i,o){return i&&i.length?il(i,se(o,3),!0,!0):[]}function FA(i,o){return i&&i.length?il(i,se(o,3),!0):[]}function UA(i,o,l,p){var y=i==null?0:i.length;return y?(l&&typeof l!="number"&&Ot(i,o,l)&&(l=0,p=y),Dx(i,o,l,p)):[]}function ly(i,o,l){var p=i==null?0:i.length;if(!p)return-1;var y=l==null?0:ye(l);return y<0&&(y=dt(p+y,0)),Hi(i,se(o,3),y)}function hy(i,o,l){var p=i==null?0:i.length;if(!p)return-1;var y=p-1;return l!==r&&(y=ye(l),y=l<0?dt(p+y,0):It(y,p-1)),Hi(i,se(o,3),y,!0)}function fy(i){var o=i==null?0:i.length;return o?vt(i,1):[]}function BA(i){var o=i==null?0:i.length;return o?vt(i,Wt):[]}function jA(i,o){var l=i==null?0:i.length;return l?(o=o===r?1:ye(o),vt(i,o)):[]}function $A(i){for(var o=-1,l=i==null?0:i.length,p={};++o<l;){var y=i[o];p[y[0]]=y[1]}return p}function dy(i){return i&&i.length?i[0]:r}function qA(i,o,l){var p=i==null?0:i.length;if(!p)return-1;var y=l==null?0:ye(l);return y<0&&(y=dt(p+y,0)),wr(i,o,y)}function zA(i){var o=i==null?0:i.length;return o?or(i,0,-1):[]}var GA=we(function(i){var o=Fe(i,rd);return o.length&&o[0]===i[0]?Kf(o):[]}),KA=we(function(i){var o=ar(i),l=Fe(i,rd);return o===ar(l)?o=r:l.pop(),l.length&&l[0]===i[0]?Kf(l,se(o,2)):[]}),WA=we(function(i){var o=ar(i),l=Fe(i,rd);return o=typeof o=="function"?o:r,o&&l.pop(),l.length&&l[0]===i[0]?Kf(l,r,o):[]});function HA(i,o){return i==null?"":zI.call(i,o)}function ar(i){var o=i==null?0:i.length;return o?i[o-1]:r}function QA(i,o,l){var p=i==null?0:i.length;if(!p)return-1;var y=p;return l!==r&&(y=ye(l),y=y<0?dt(p+y,0):It(y,p-1)),o===o?RI(i,o,y):Hi(i,La,y,!0)}function JA(i,o){return i&&i.length?I_(i,ye(o)):r}var YA=we(py);function py(i,o){return i&&i.length&&o&&o.length?Jf(i,o):i}function XA(i,o,l){return i&&i.length&&o&&o.length?Jf(i,o,se(l,2)):i}function ZA(i,o,l){return i&&i.length&&o&&o.length?Jf(i,o,r,l):i}var eS=pn(function(i,o){var l=i==null?0:i.length,p=$f(i,o);return S_(i,Fe(o,function(y){return mn(y,l)?+y:y}).sort(M_)),p});function tS(i,o){var l=[];if(!(i&&i.length))return l;var p=-1,y=[],T=i.length;for(o=se(o,3);++p<T;){var x=i[p];o(x,p,i)&&(l.push(x),y.push(p))}return S_(i,y),l}function gd(i){return i==null?i:HI.call(i)}function rS(i,o,l){var p=i==null?0:i.length;return p?(l&&typeof l!="number"&&Ot(i,o,l)?(o=0,l=p):(o=o==null?0:ye(o),l=l===r?p:ye(l)),or(i,o,l)):[]}function nS(i,o){return nl(i,o)}function iS(i,o,l){return Zf(i,o,se(l,2))}function sS(i,o){var l=i==null?0:i.length;if(l){var p=nl(i,o);if(p<l&&Er(i[p],o))return p}return-1}function oS(i,o){return nl(i,o,!0)}function aS(i,o,l){return Zf(i,o,se(l,2),!0)}function uS(i,o){var l=i==null?0:i.length;if(l){var p=nl(i,o,!0)-1;if(Er(i[p],o))return p}return-1}function cS(i){return i&&i.length?P_(i):[]}function lS(i,o){return i&&i.length?P_(i,se(o,2)):[]}function hS(i){var o=i==null?0:i.length;return o?or(i,1,o):[]}function fS(i,o,l){return i&&i.length?(o=l||o===r?1:ye(o),or(i,0,o<0?0:o)):[]}function dS(i,o,l){var p=i==null?0:i.length;return p?(o=l||o===r?1:ye(o),o=p-o,or(i,o<0?0:o,p)):[]}function pS(i,o){return i&&i.length?il(i,se(o,3),!1,!0):[]}function mS(i,o){return i&&i.length?il(i,se(o,3)):[]}var gS=we(function(i){return Zn(vt(i,1,et,!0))}),_S=we(function(i){var o=ar(i);return et(o)&&(o=r),Zn(vt(i,1,et,!0),se(o,2))}),yS=we(function(i){var o=ar(i);return o=typeof o=="function"?o:r,Zn(vt(i,1,et,!0),r,o)});function vS(i){return i&&i.length?Zn(i):[]}function wS(i,o){return i&&i.length?Zn(i,se(o,2)):[]}function bS(i,o){return o=typeof o=="function"?o:r,i&&i.length?Zn(i,r,o):[]}function _d(i){if(!(i&&i.length))return[];var o=0;return i=yr(i,function(l){if(et(l))return o=dt(l.length,o),!0}),L(o,function(l){return Fe(i,Mr(l))})}function my(i,o){if(!(i&&i.length))return[];var l=_d(i);return o==null?l:Fe(l,function(p){return Et(o,r,p)})}var TS=we(function(i,o){return et(i)?Ga(i,o):[]}),ES=we(function(i){return td(yr(i,et))}),IS=we(function(i){var o=ar(i);return et(o)&&(o=r),td(yr(i,et),se(o,2))}),xS=we(function(i){var o=ar(i);return o=typeof o=="function"?o:r,td(yr(i,et),r,o)}),AS=we(_d);function SS(i,o){return k_(i||[],o||[],za)}function RS(i,o){return k_(i||[],o||[],Ha)}var PS=we(function(i){var o=i.length,l=o>1?i[o-1]:r;return l=typeof l=="function"?(i.pop(),l):r,my(i,l)});function gy(i){var o=w(i);return o.__chain__=!0,o}function CS(i,o){return o(i),i}function dl(i,o){return o(i)}var DS=pn(function(i){var o=i.length,l=o?i[0]:0,p=this.__wrapped__,y=function(T){return $f(T,i)};return o>1||this.__actions__.length||!(p instanceof Ie)||!mn(l)?this.thru(y):(p=p.slice(l,+l+(o?1:0)),p.__actions__.push({func:dl,args:[y],thisArg:r}),new ir(p,this.__chain__).thru(function(T){return o&&!T.length&&T.push(r),T}))});function OS(){return gy(this)}function kS(){return new ir(this.value(),this.__chain__)}function NS(){this.__values__===r&&(this.__values__=Cy(this.value()));var i=this.__index__>=this.__values__.length,o=i?r:this.__values__[this.__index__++];return{done:i,value:o}}function VS(){return this}function LS(i){for(var o,l=this;l instanceof Xc;){var p=cy(l);p.__index__=0,p.__values__=r,o?y.__wrapped__=p:o=p;var y=p;l=l.__wrapped__}return y.__wrapped__=i,o}function MS(){var i=this.__wrapped__;if(i instanceof Ie){var o=i;return this.__actions__.length&&(o=new Ie(this)),o=o.reverse(),o.__actions__.push({func:dl,args:[gd],thisArg:r}),new ir(o,this.__chain__)}return this.thru(gd)}function FS(){return O_(this.__wrapped__,this.__actions__)}var US=sl(function(i,o,l){Me.call(i,l)?++i[l]:fn(i,l,1)});function BS(i,o,l){var p=pe(i)?Kn:Cx;return l&&Ot(i,o,l)&&(o=r),p(i,se(o,3))}function jS(i,o){var l=pe(i)?yr:m_;return l(i,se(o,3))}var $S=q_(ly),qS=q_(hy);function zS(i,o){return vt(pl(i,o),1)}function GS(i,o){return vt(pl(i,o),Wt)}function KS(i,o,l){return l=l===r?1:ye(l),vt(pl(i,o),l)}function _y(i,o){var l=pe(i)?Ft:Xn;return l(i,se(o,3))}function yy(i,o){var l=pe(i)?Nc:p_;return l(i,se(o,3))}var WS=sl(function(i,o,l){Me.call(i,l)?i[l].push(o):fn(i,l,[o])});function HS(i,o,l,p){i=Bt(i)?i:oo(i),l=l&&!p?ye(l):0;var y=i.length;return l<0&&(l=dt(y+l,0)),vl(i)?l<=y&&i.indexOf(o,l)>-1:!!y&&wr(i,o,l)>-1}var QS=we(function(i,o,l){var p=-1,y=typeof o=="function",T=Bt(i)?U(i.length):[];return Xn(i,function(x){T[++p]=y?Et(o,x,l):Ka(x,o,l)}),T}),JS=sl(function(i,o,l){fn(i,l,o)});function pl(i,o){var l=pe(i)?Fe:b_;return l(i,se(o,3))}function YS(i,o,l,p){return i==null?[]:(pe(o)||(o=o==null?[]:[o]),l=p?r:l,pe(l)||(l=l==null?[]:[l]),x_(i,o,l))}var XS=sl(function(i,o,l){i[l?0:1].push(o)},function(){return[[],[]]});function ZS(i,o,l){var p=pe(i)?Wn:d,y=arguments.length<3;return p(i,se(o,4),l,y,Xn)}function e1(i,o,l){var p=pe(i)?Vc:d,y=arguments.length<3;return p(i,se(o,4),l,y,p_)}function t1(i,o){var l=pe(i)?yr:m_;return l(i,_l(se(o,3)))}function r1(i){var o=pe(i)?l_:Hx;return o(i)}function n1(i,o,l){(l?Ot(i,o,l):o===r)?o=1:o=ye(o);var p=pe(i)?xx:Qx;return p(i,o)}function i1(i){var o=pe(i)?Ax:Yx;return o(i)}function s1(i){if(i==null)return 0;if(Bt(i))return vl(i)?Ys(i):i.length;var o=xt(i);return o==Pt||o==Mt?i.size:Hf(i).length}function o1(i,o,l){var p=pe(i)?Hs:Xx;return l&&Ot(i,o,l)&&(o=r),p(i,se(o,3))}var a1=we(function(i,o){if(i==null)return[];var l=o.length;return l>1&&Ot(i,o[0],o[1])?o=[]:l>2&&Ot(o[0],o[1],o[2])&&(o=[o[0]]),x_(i,vt(o,1),[])}),ml=jI||function(){return Xe.Date.now()};function u1(i,o){if(typeof o!="function")throw new nr(s);return i=ye(i),function(){if(--i<1)return o.apply(this,arguments)}}function vy(i,o,l){return o=l?r:o,o=i&&o==null?i.length:o,dn(i,de,r,r,r,r,o)}function wy(i,o){var l;if(typeof o!="function")throw new nr(s);return i=ye(i),function(){return--i>0&&(l=o.apply(this,arguments)),i<=1&&(o=r),l}}var yd=we(function(i,o,l){var p=B;if(l.length){var y=Qn(l,io(yd));p|=re}return dn(i,p,o,l,y)}),by=we(function(i,o,l){var p=B|G;if(l.length){var y=Qn(l,io(by));p|=re}return dn(o,p,i,l,y)});function Ty(i,o,l){o=l?r:o;var p=dn(i,J,r,r,r,r,r,o);return p.placeholder=Ty.placeholder,p}function Ey(i,o,l){o=l?r:o;var p=dn(i,ee,r,r,r,r,r,o);return p.placeholder=Ey.placeholder,p}function Iy(i,o,l){var p,y,T,x,P,N,q=0,z=!1,K=!1,Y=!0;if(typeof i!="function")throw new nr(s);o=ur(o)||0,We(l)&&(z=!!l.leading,K="maxWait"in l,T=K?dt(ur(l.maxWait)||0,o):T,Y="trailing"in l?!!l.trailing:Y);function te(tt){var Ir=p,yn=y;return p=y=r,q=tt,x=i.apply(yn,Ir),x}function oe(tt){return q=tt,P=Ya(Te,o),z?te(tt):x}function ve(tt){var Ir=tt-N,yn=tt-q,qy=o-Ir;return K?It(qy,T-yn):qy}function ae(tt){var Ir=tt-N,yn=tt-q;return N===r||Ir>=o||Ir<0||K&&yn>=T}function Te(){var tt=ml();if(ae(tt))return Ae(tt);P=Ya(Te,ve(tt))}function Ae(tt){return P=r,Y&&p?te(tt):(p=y=r,x)}function Xt(){P!==r&&N_(P),q=0,p=N=y=P=r}function kt(){return P===r?x:Ae(ml())}function Zt(){var tt=ml(),Ir=ae(tt);if(p=arguments,y=this,N=tt,Ir){if(P===r)return oe(N);if(K)return N_(P),P=Ya(Te,o),te(N)}return P===r&&(P=Ya(Te,o)),x}return Zt.cancel=Xt,Zt.flush=kt,Zt}var c1=we(function(i,o){return d_(i,1,o)}),l1=we(function(i,o,l){return d_(i,ur(o)||0,l)});function h1(i){return dn(i,C)}function gl(i,o){if(typeof i!="function"||o!=null&&typeof o!="function")throw new nr(s);var l=function(){var p=arguments,y=o?o.apply(this,p):p[0],T=l.cache;if(T.has(y))return T.get(y);var x=i.apply(this,p);return l.cache=T.set(y,x)||T,x};return l.cache=new(gl.Cache||hn),l}gl.Cache=hn;function _l(i){if(typeof i!="function")throw new nr(s);return function(){var o=arguments;switch(o.length){case 0:return!i.call(this);case 1:return!i.call(this,o[0]);case 2:return!i.call(this,o[0],o[1]);case 3:return!i.call(this,o[0],o[1],o[2])}return!i.apply(this,o)}}function f1(i){return wy(2,i)}var d1=Zx(function(i,o){o=o.length==1&&pe(o[0])?Fe(o[0],_e(se())):Fe(vt(o,1),_e(se()));var l=o.length;return we(function(p){for(var y=-1,T=It(p.length,l);++y<T;)p[y]=o[y].call(this,p[y]);return Et(i,this,p)})}),vd=we(function(i,o){var l=Qn(o,io(vd));return dn(i,re,r,o,l)}),xy=we(function(i,o){var l=Qn(o,io(xy));return dn(i,le,r,o,l)}),p1=pn(function(i,o){return dn(i,ie,r,r,r,o)});function m1(i,o){if(typeof i!="function")throw new nr(s);return o=o===r?o:ye(o),we(i,o)}function g1(i,o){if(typeof i!="function")throw new nr(s);return o=o==null?0:dt(ye(o),0),we(function(l){var p=l[o],y=ti(l,0,o);return p&&vr(y,p),Et(i,this,y)})}function _1(i,o,l){var p=!0,y=!0;if(typeof i!="function")throw new nr(s);return We(l)&&(p="leading"in l?!!l.leading:p,y="trailing"in l?!!l.trailing:y),Iy(i,o,{leading:p,maxWait:o,trailing:y})}function y1(i){return vy(i,1)}function v1(i,o){return vd(nd(o),i)}function w1(){if(!arguments.length)return[];var i=arguments[0];return pe(i)?i:[i]}function b1(i){return sr(i,E)}function T1(i,o){return o=typeof o=="function"?o:r,sr(i,E,o)}function E1(i){return sr(i,m|E)}function I1(i,o){return o=typeof o=="function"?o:r,sr(i,m|E,o)}function x1(i,o){return o==null||f_(i,o,mt(o))}function Er(i,o){return i===o||i!==i&&o!==o}var A1=cl(Gf),S1=cl(function(i,o){return i>=o}),rs=y_(function(){return arguments}())?y_:function(i){return Qe(i)&&Me.call(i,"callee")&&!i_.call(i,"callee")},pe=U.isArray,R1=ka?_e(ka):Lx;function Bt(i){return i!=null&&yl(i.length)&&!gn(i)}function et(i){return Qe(i)&&Bt(i)}function P1(i){return i===!0||i===!1||Qe(i)&&Dt(i)==Ri}var ri=qI||Cd,C1=kc?_e(kc):Mx;function D1(i){return Qe(i)&&i.nodeType===1&&!Xa(i)}function O1(i){if(i==null)return!0;if(Bt(i)&&(pe(i)||typeof i=="string"||typeof i.splice=="function"||ri(i)||so(i)||rs(i)))return!i.length;var o=xt(i);if(o==Pt||o==Mt)return!i.size;if(Ja(i))return!Hf(i).length;for(var l in i)if(Me.call(i,l))return!1;return!0}function k1(i,o){return Wa(i,o)}function N1(i,o,l){l=typeof l=="function"?l:r;var p=l?l(i,o):r;return p===r?Wa(i,o,r,l):!!p}function wd(i){if(!Qe(i))return!1;var o=Dt(i);return o==Ds||o==wf||typeof i.message=="string"&&typeof i.name=="string"&&!Xa(i)}function V1(i){return typeof i=="number"&&o_(i)}function gn(i){if(!We(i))return!1;var o=Dt(i);return o==rn||o==Pi||o==Si||o==uc}function Ay(i){return typeof i=="number"&&i==ye(i)}function yl(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=Pr}function We(i){var o=typeof i;return i!=null&&(o=="object"||o=="function")}function Qe(i){return i!=null&&typeof i=="object"}var Sy=Gn?_e(Gn):Ux;function L1(i,o){return i===o||Wf(i,o,ld(o))}function M1(i,o,l){return l=typeof l=="function"?l:r,Wf(i,o,ld(o),l)}function F1(i){return Ry(i)&&i!=+i}function U1(i){if(TA(i))throw new he(n);return v_(i)}function B1(i){return i===null}function j1(i){return i==null}function Ry(i){return typeof i=="number"||Qe(i)&&Dt(i)==nn}function Xa(i){if(!Qe(i)||Dt(i)!=Ht)return!1;var o=Gc(i);if(o===null)return!0;var l=Me.call(o,"constructor")&&o.constructor;return typeof l=="function"&&l instanceof l&&jc.call(l)==MI}var bd=Na?_e(Na):Bx;function $1(i){return Ay(i)&&i>=-Pr&&i<=Pr}var Py=Ks?_e(Ks):jx;function vl(i){return typeof i=="string"||!pe(i)&&Qe(i)&&Dt(i)==Ln}function Yt(i){return typeof i=="symbol"||Qe(i)&&Dt(i)==Mn}var so=Gi?_e(Gi):$x;function q1(i){return i===r}function z1(i){return Qe(i)&&xt(i)==Di}function G1(i){return Qe(i)&&Dt(i)==ga}var K1=cl(Qf),W1=cl(function(i,o){return i<=o});function Cy(i){if(!i)return[];if(Bt(i))return vl(i)?br(i):Ut(i);if(Ua&&i[Ua])return xI(i[Ua]());var o=xt(i),l=o==Pt?Lf:o==Mt?Fc:oo;return l(i)}function _n(i){if(!i)return i===0?i:0;if(i=ur(i),i===Wt||i===-Wt){var o=i<0?-1:1;return o*Ai}return i===i?i:0}function ye(i){var o=_n(i),l=o%1;return o===o?l?o-l:o:0}function Dy(i){return i?Xi(ye(i),0,Lt):0}function ur(i){if(typeof i=="number")return i;if(Yt(i))return Cr;if(We(i)){var o=typeof i.valueOf=="function"?i.valueOf():i;i=We(o)?o+"":o}if(typeof i!="string")return i===0?i:+i;i=Q(i);var l=Ta.test(i);return l||Nr.test(i)?ze(i.slice(2),l?2:8):mc.test(i)?Cr:+i}function Oy(i){return Ur(i,jt(i))}function H1(i){return i?Xi(ye(i),-Pr,Pr):i===0?i:0}function Ve(i){return i==null?"":Jt(i)}var Q1=ro(function(i,o){if(Ja(o)||Bt(o)){Ur(o,mt(o),i);return}for(var l in o)Me.call(o,l)&&za(i,l,o[l])}),ky=ro(function(i,o){Ur(o,jt(o),i)}),wl=ro(function(i,o,l,p){Ur(o,jt(o),i,p)}),J1=ro(function(i,o,l,p){Ur(o,mt(o),i,p)}),Y1=pn($f);function X1(i,o){var l=to(i);return o==null?l:h_(l,o)}var Z1=we(function(i,o){i=Ue(i);var l=-1,p=o.length,y=p>2?o[2]:r;for(y&&Ot(o[0],o[1],y)&&(p=1);++l<p;)for(var T=o[l],x=jt(T),P=-1,N=x.length;++P<N;){var q=x[P],z=i[q];(z===r||Er(z,Xs[q])&&!Me.call(i,q))&&(i[q]=T[q])}return i}),eR=we(function(i){return i.push(r,J_),Et(Ny,r,i)});function tR(i,o){return Va(i,se(o,3),Fr)}function rR(i,o){return Va(i,se(o,3),zf)}function nR(i,o){return i==null?i:qf(i,se(o,3),jt)}function iR(i,o){return i==null?i:g_(i,se(o,3),jt)}function sR(i,o){return i&&Fr(i,se(o,3))}function oR(i,o){return i&&zf(i,se(o,3))}function aR(i){return i==null?[]:tl(i,mt(i))}function uR(i){return i==null?[]:tl(i,jt(i))}function Td(i,o,l){var p=i==null?r:Zi(i,o);return p===r?l:p}function cR(i,o){return i!=null&&Z_(i,o,Ox)}function Ed(i,o){return i!=null&&Z_(i,o,kx)}var lR=G_(function(i,o,l){o!=null&&typeof o.toString!="function"&&(o=$c.call(o)),i[o]=l},xd($t)),hR=G_(function(i,o,l){o!=null&&typeof o.toString!="function"&&(o=$c.call(o)),Me.call(i,o)?i[o].push(l):i[o]=[l]},se),fR=we(Ka);function mt(i){return Bt(i)?c_(i):Hf(i)}function jt(i){return Bt(i)?c_(i,!0):qx(i)}function dR(i,o){var l={};return o=se(o,3),Fr(i,function(p,y,T){fn(l,o(p,y,T),p)}),l}function pR(i,o){var l={};return o=se(o,3),Fr(i,function(p,y,T){fn(l,y,o(p,y,T))}),l}var mR=ro(function(i,o,l){rl(i,o,l)}),Ny=ro(function(i,o,l,p){rl(i,o,l,p)}),gR=pn(function(i,o){var l={};if(i==null)return l;var p=!1;o=Fe(o,function(T){return T=ei(T,i),p||(p=T.length>1),T}),Ur(i,ud(i),l),p&&(l=sr(l,m|_|E,lA));for(var y=o.length;y--;)ed(l,o[y]);return l});function _R(i,o){return Vy(i,_l(se(o)))}var yR=pn(function(i,o){return i==null?{}:Gx(i,o)});function Vy(i,o){if(i==null)return{};var l=Fe(ud(i),function(p){return[p]});return o=se(o),A_(i,l,function(p,y){return o(p,y[0])})}function vR(i,o,l){o=ei(o,i);var p=-1,y=o.length;for(y||(y=1,i=r);++p<y;){var T=i==null?r:i[Br(o[p])];T===r&&(p=y,T=l),i=gn(T)?T.call(i):T}return i}function wR(i,o,l){return i==null?i:Ha(i,o,l)}function bR(i,o,l,p){return p=typeof p=="function"?p:r,i==null?i:Ha(i,o,l,p)}var Ly=H_(mt),My=H_(jt);function TR(i,o,l){var p=pe(i),y=p||ri(i)||so(i);if(o=se(o,4),l==null){var T=i&&i.constructor;y?l=p?new T:[]:We(i)?l=gn(T)?to(Gc(i)):{}:l={}}return(y?Ft:Fr)(i,function(x,P,N){return o(l,x,P,N)}),l}function ER(i,o){return i==null?!0:ed(i,o)}function IR(i,o,l){return i==null?i:D_(i,o,nd(l))}function xR(i,o,l,p){return p=typeof p=="function"?p:r,i==null?i:D_(i,o,nd(l),p)}function oo(i){return i==null?[]:Ze(i,mt(i))}function AR(i){return i==null?[]:Ze(i,jt(i))}function SR(i,o,l){return l===r&&(l=o,o=r),l!==r&&(l=ur(l),l=l===l?l:0),o!==r&&(o=ur(o),o=o===o?o:0),Xi(ur(i),o,l)}function RR(i,o,l){return o=_n(o),l===r?(l=o,o=0):l=_n(l),i=ur(i),Nx(i,o,l)}function PR(i,o,l){if(l&&typeof l!="boolean"&&Ot(i,o,l)&&(o=l=r),l===r&&(typeof o=="boolean"?(l=o,o=r):typeof i=="boolean"&&(l=i,i=r)),i===r&&o===r?(i=0,o=1):(i=_n(i),o===r?(o=i,i=0):o=_n(o)),i>o){var p=i;i=o,o=p}if(l||i%1||o%1){var y=a_();return It(i+y*(o-i+Oa("1e-"+((y+"").length-1))),o)}return Yf(i,o)}var CR=no(function(i,o,l){return o=o.toLowerCase(),i+(l?Fy(o):o)});function Fy(i){return Id(Ve(i).toLowerCase())}function Uy(i){return i=Ve(i),i&&i.replace(_c,Qt).replace(zn,"")}function DR(i,o,l){i=Ve(i),o=Jt(o);var p=i.length;l=l===r?p:Xi(ye(l),0,p);var y=l;return l-=o.length,l>=0&&i.slice(l,y)==o}function OR(i){return i=Ve(i),i&&Oi.test(i)?i.replace(va,Qs):i}function kR(i){return i=Ve(i),i&&dc.test(i)?i.replace(an,"\\$&"):i}var NR=no(function(i,o,l){return i+(l?"-":"")+o.toLowerCase()}),VR=no(function(i,o,l){return i+(l?" ":"")+o.toLowerCase()}),LR=$_("toLowerCase");function MR(i,o,l){i=Ve(i),o=ye(o);var p=o?Ys(i):0;if(!o||p>=o)return i;var y=(o-p)/2;return ul(Qc(y),l)+i+ul(Hc(y),l)}function FR(i,o,l){i=Ve(i),o=ye(o);var p=o?Ys(i):0;return o&&p<o?i+ul(o-p,l):i}function UR(i,o,l){i=Ve(i),o=ye(o);var p=o?Ys(i):0;return o&&p<o?ul(o-p,l)+i:i}function BR(i,o,l){return l||o==null?o=0:o&&(o=+o),WI(Ve(i).replace(ct,""),o||0)}function jR(i,o,l){return(l?Ot(i,o,l):o===r)?o=1:o=ye(o),Xf(Ve(i),o)}function $R(){var i=arguments,o=Ve(i[0]);return i.length<3?o:o.replace(i[1],i[2])}var qR=no(function(i,o,l){return i+(l?"_":"")+o.toLowerCase()});function zR(i,o,l){return l&&typeof l!="number"&&Ot(i,o,l)&&(o=l=r),l=l===r?Lt:l>>>0,l?(i=Ve(i),i&&(typeof o=="string"||o!=null&&!bd(o))&&(o=Jt(o),!o&&Js(i))?ti(br(i),0,l):i.split(o,l)):[]}var GR=no(function(i,o,l){return i+(l?" ":"")+Id(o)});function KR(i,o,l){return i=Ve(i),l=l==null?0:Xi(ye(l),0,i.length),o=Jt(o),i.slice(l,l+o.length)==o}function WR(i,o,l){var p=w.templateSettings;l&&Ot(i,o,l)&&(o=r),i=Ve(i),o=wl({},o,p,Q_);var y=wl({},o.imports,p.imports,Q_),T=mt(y),x=Ze(y,T),P,N,q=0,z=o.interpolate||Bn,K="__p += '",Y=Mf((o.escape||Bn).source+"|"+z.source+"|"+(z===kr?Af:Bn).source+"|"+(o.evaluate||Bn).source+"|$","g"),te="//# sourceURL="+(Me.call(o,"sourceURL")?(o.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Nf+"]")+`
|
|
3
|
+
`)}function vA(i){return pe(i)||rs(i)||!!(o_&&i&&i[o_])}function mn(i,o){var l=typeof i;return o=o==null?Pr:o,!!o&&(l=="number"||l!="symbol"&&gc.test(i))&&i>-1&&i%1==0&&i<o}function Ot(i,o,l){if(!We(l))return!1;var p=typeof o;return(p=="number"?Bt(l)&&mn(o,l.length):p=="string"&&o in l)?Er(l[o],i):!1}function fd(i,o){if(pe(i))return!1;var l=typeof i;return l=="number"||l=="symbol"||l=="boolean"||i==null||Yt(i)?!0:Ms.test(i)||!hc.test(i)||o!=null&&i in Ue(o)}function wA(i){var o=typeof i;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?i!=="__proto__":i===null}function dd(i){var o=ll(i),l=w[o];if(typeof l!="function"||!(o in Ie.prototype))return!1;if(i===l)return!0;var p=cd(l);return!!p&&i===p[0]}function bA(i){return!!r_&&r_ in i}var TA=Bc?gn:Cd;function Ja(i){var o=i&&i.constructor,l=typeof o=="function"&&o.prototype||Xs;return i===l}function ry(i){return i===i&&!We(i)}function ny(i,o){return function(l){return l==null?!1:l[i]===o&&(o!==r||i in Ue(l))}}function EA(i){var o=gl(i,function(p){return l.size===h&&l.clear(),p}),l=o.cache;return o}function IA(i,o){var l=i[1],p=o[1],y=l|p,T=y<(B|G|de),x=p==de&&l==J||p==de&&l==ie&&i[7].length<=o[8]||p==(de|ie)&&o[7].length<=o[8]&&l==J;if(!(T||x))return i;p&B&&(i[2]=o[2],y|=l&B?0:j);var P=o[3];if(P){var N=i[3];i[3]=N?U_(N,P,o[4]):P,i[4]=N?Qn(i[3],f):o[4]}return P=o[5],P&&(N=i[5],i[5]=N?B_(N,P,o[6]):P,i[6]=N?Qn(i[5],f):o[6]),P=o[7],P&&(i[7]=P),p&de&&(i[8]=i[8]==null?o[8]:It(i[8],o[8])),i[9]==null&&(i[9]=o[9]),i[0]=o[0],i[1]=y,i}function xA(i){var o=[];if(i!=null)for(var l in Ue(i))o.push(l);return o}function AA(i){return $c.call(i)}function iy(i,o,l){return o=dt(o===r?i.length-1:o,0),function(){for(var p=arguments,y=-1,T=dt(p.length-o,0),x=U(T);++y<T;)x[y]=p[o+y];y=-1;for(var P=U(o+1);++y<o;)P[y]=p[y];return P[o]=l(x),Et(i,this,P)}}function sy(i,o){return o.length<2?i:Zi(i,or(o,0,-1))}function SA(i,o){for(var l=i.length,p=It(o.length,l),y=Ut(i);p--;){var T=o[p];i[p]=mn(T,l)?y[T]:r}return i}function pd(i,o){if(!(o==="constructor"&&typeof i[o]=="function")&&o!="__proto__")return i[o]}var oy=uy(P_),Ya=$I||function(i,o){return Xe.setTimeout(i,o)},md=uy(Jx);function ay(i,o,l){var p=o+"";return md(i,yA(p,RA(mA(p),l)))}function uy(i){var o=0,l=0;return function(){var p=KI(),y=V-(p-l);if(l=p,y>0){if(++o>=D)return arguments[0]}else o=0;return i.apply(r,arguments)}}function fl(i,o){var l=-1,p=i.length,y=p-1;for(o=o===r?p:o;++l<o;){var T=Yf(l,y),x=i[T];i[T]=i[l],i[l]=x}return i.length=o,i}var cy=EA(function(i){var o=[];return i.charCodeAt(0)===46&&o.push(""),i.replace(fc,function(l,p,y,T){o.push(y?T.replace(xf,"$1"):p||l)}),o});function Br(i){if(typeof i=="string"||Yt(i))return i;var o=i+"";return o=="0"&&1/i==-Wt?"-0":o}function ts(i){if(i!=null){try{return jc.call(i)}catch{}try{return i+""}catch{}}return""}function RA(i,o){return Ft(Dr,function(l){var p="_."+l[0];o&l[1]&&!Ki(i,p)&&i.push(p)}),i.sort()}function ly(i){if(i instanceof Ie)return i.clone();var o=new ir(i.__wrapped__,i.__chain__);return o.__actions__=Ut(i.__actions__),o.__index__=i.__index__,o.__values__=i.__values__,o}function PA(i,o,l){(l?Ot(i,o,l):o===r)?o=1:o=dt(ye(o),0);var p=i==null?0:i.length;if(!p||o<1)return[];for(var y=0,T=0,x=U(Hc(p/o));y<p;)x[T++]=or(i,y,y+=o);return x}function CA(i){for(var o=-1,l=i==null?0:i.length,p=0,y=[];++o<l;){var T=i[o];T&&(y[p++]=T)}return y}function DA(){var i=arguments.length;if(!i)return[];for(var o=U(i-1),l=arguments[0],p=i;p--;)o[p-1]=arguments[p];return vr(pe(l)?Ut(l):[l],vt(o,1))}var OA=we(function(i,o){return et(i)?Ga(i,vt(o,1,et,!0)):[]}),kA=we(function(i,o){var l=ar(o);return et(l)&&(l=r),et(i)?Ga(i,vt(o,1,et,!0),se(l,2)):[]}),NA=we(function(i,o){var l=ar(o);return et(l)&&(l=r),et(i)?Ga(i,vt(o,1,et,!0),r,l):[]});function VA(i,o,l){var p=i==null?0:i.length;return p?(o=l||o===r?1:ye(o),or(i,o<0?0:o,p)):[]}function LA(i,o,l){var p=i==null?0:i.length;return p?(o=l||o===r?1:ye(o),o=p-o,or(i,0,o<0?0:o)):[]}function MA(i,o){return i&&i.length?il(i,se(o,3),!0,!0):[]}function FA(i,o){return i&&i.length?il(i,se(o,3),!0):[]}function UA(i,o,l,p){var y=i==null?0:i.length;return y?(l&&typeof l!="number"&&Ot(i,o,l)&&(l=0,p=y),Dx(i,o,l,p)):[]}function hy(i,o,l){var p=i==null?0:i.length;if(!p)return-1;var y=l==null?0:ye(l);return y<0&&(y=dt(p+y,0)),Hi(i,se(o,3),y)}function fy(i,o,l){var p=i==null?0:i.length;if(!p)return-1;var y=p-1;return l!==r&&(y=ye(l),y=l<0?dt(p+y,0):It(y,p-1)),Hi(i,se(o,3),y,!0)}function dy(i){var o=i==null?0:i.length;return o?vt(i,1):[]}function BA(i){var o=i==null?0:i.length;return o?vt(i,Wt):[]}function jA(i,o){var l=i==null?0:i.length;return l?(o=o===r?1:ye(o),vt(i,o)):[]}function $A(i){for(var o=-1,l=i==null?0:i.length,p={};++o<l;){var y=i[o];p[y[0]]=y[1]}return p}function py(i){return i&&i.length?i[0]:r}function qA(i,o,l){var p=i==null?0:i.length;if(!p)return-1;var y=l==null?0:ye(l);return y<0&&(y=dt(p+y,0)),wr(i,o,y)}function zA(i){var o=i==null?0:i.length;return o?or(i,0,-1):[]}var GA=we(function(i){var o=Fe(i,rd);return o.length&&o[0]===i[0]?Kf(o):[]}),KA=we(function(i){var o=ar(i),l=Fe(i,rd);return o===ar(l)?o=r:l.pop(),l.length&&l[0]===i[0]?Kf(l,se(o,2)):[]}),WA=we(function(i){var o=ar(i),l=Fe(i,rd);return o=typeof o=="function"?o:r,o&&l.pop(),l.length&&l[0]===i[0]?Kf(l,r,o):[]});function HA(i,o){return i==null?"":zI.call(i,o)}function ar(i){var o=i==null?0:i.length;return o?i[o-1]:r}function QA(i,o,l){var p=i==null?0:i.length;if(!p)return-1;var y=p;return l!==r&&(y=ye(l),y=y<0?dt(p+y,0):It(y,p-1)),o===o?RI(i,o,y):Hi(i,La,y,!0)}function JA(i,o){return i&&i.length?x_(i,ye(o)):r}var YA=we(my);function my(i,o){return i&&i.length&&o&&o.length?Jf(i,o):i}function XA(i,o,l){return i&&i.length&&o&&o.length?Jf(i,o,se(l,2)):i}function ZA(i,o,l){return i&&i.length&&o&&o.length?Jf(i,o,r,l):i}var eS=pn(function(i,o){var l=i==null?0:i.length,p=$f(i,o);return R_(i,Fe(o,function(y){return mn(y,l)?+y:y}).sort(F_)),p});function tS(i,o){var l=[];if(!(i&&i.length))return l;var p=-1,y=[],T=i.length;for(o=se(o,3);++p<T;){var x=i[p];o(x,p,i)&&(l.push(x),y.push(p))}return R_(i,y),l}function gd(i){return i==null?i:HI.call(i)}function rS(i,o,l){var p=i==null?0:i.length;return p?(l&&typeof l!="number"&&Ot(i,o,l)?(o=0,l=p):(o=o==null?0:ye(o),l=l===r?p:ye(l)),or(i,o,l)):[]}function nS(i,o){return nl(i,o)}function iS(i,o,l){return Zf(i,o,se(l,2))}function sS(i,o){var l=i==null?0:i.length;if(l){var p=nl(i,o);if(p<l&&Er(i[p],o))return p}return-1}function oS(i,o){return nl(i,o,!0)}function aS(i,o,l){return Zf(i,o,se(l,2),!0)}function uS(i,o){var l=i==null?0:i.length;if(l){var p=nl(i,o,!0)-1;if(Er(i[p],o))return p}return-1}function cS(i){return i&&i.length?C_(i):[]}function lS(i,o){return i&&i.length?C_(i,se(o,2)):[]}function hS(i){var o=i==null?0:i.length;return o?or(i,1,o):[]}function fS(i,o,l){return i&&i.length?(o=l||o===r?1:ye(o),or(i,0,o<0?0:o)):[]}function dS(i,o,l){var p=i==null?0:i.length;return p?(o=l||o===r?1:ye(o),o=p-o,or(i,o<0?0:o,p)):[]}function pS(i,o){return i&&i.length?il(i,se(o,3),!1,!0):[]}function mS(i,o){return i&&i.length?il(i,se(o,3)):[]}var gS=we(function(i){return Zn(vt(i,1,et,!0))}),_S=we(function(i){var o=ar(i);return et(o)&&(o=r),Zn(vt(i,1,et,!0),se(o,2))}),yS=we(function(i){var o=ar(i);return o=typeof o=="function"?o:r,Zn(vt(i,1,et,!0),r,o)});function vS(i){return i&&i.length?Zn(i):[]}function wS(i,o){return i&&i.length?Zn(i,se(o,2)):[]}function bS(i,o){return o=typeof o=="function"?o:r,i&&i.length?Zn(i,r,o):[]}function _d(i){if(!(i&&i.length))return[];var o=0;return i=yr(i,function(l){if(et(l))return o=dt(l.length,o),!0}),L(o,function(l){return Fe(i,Mr(l))})}function gy(i,o){if(!(i&&i.length))return[];var l=_d(i);return o==null?l:Fe(l,function(p){return Et(o,r,p)})}var TS=we(function(i,o){return et(i)?Ga(i,o):[]}),ES=we(function(i){return td(yr(i,et))}),IS=we(function(i){var o=ar(i);return et(o)&&(o=r),td(yr(i,et),se(o,2))}),xS=we(function(i){var o=ar(i);return o=typeof o=="function"?o:r,td(yr(i,et),r,o)}),AS=we(_d);function SS(i,o){return N_(i||[],o||[],za)}function RS(i,o){return N_(i||[],o||[],Ha)}var PS=we(function(i){var o=i.length,l=o>1?i[o-1]:r;return l=typeof l=="function"?(i.pop(),l):r,gy(i,l)});function _y(i){var o=w(i);return o.__chain__=!0,o}function CS(i,o){return o(i),i}function dl(i,o){return o(i)}var DS=pn(function(i){var o=i.length,l=o?i[0]:0,p=this.__wrapped__,y=function(T){return $f(T,i)};return o>1||this.__actions__.length||!(p instanceof Ie)||!mn(l)?this.thru(y):(p=p.slice(l,+l+(o?1:0)),p.__actions__.push({func:dl,args:[y],thisArg:r}),new ir(p,this.__chain__).thru(function(T){return o&&!T.length&&T.push(r),T}))});function OS(){return _y(this)}function kS(){return new ir(this.value(),this.__chain__)}function NS(){this.__values__===r&&(this.__values__=Dy(this.value()));var i=this.__index__>=this.__values__.length,o=i?r:this.__values__[this.__index__++];return{done:i,value:o}}function VS(){return this}function LS(i){for(var o,l=this;l instanceof Xc;){var p=ly(l);p.__index__=0,p.__values__=r,o?y.__wrapped__=p:o=p;var y=p;l=l.__wrapped__}return y.__wrapped__=i,o}function MS(){var i=this.__wrapped__;if(i instanceof Ie){var o=i;return this.__actions__.length&&(o=new Ie(this)),o=o.reverse(),o.__actions__.push({func:dl,args:[gd],thisArg:r}),new ir(o,this.__chain__)}return this.thru(gd)}function FS(){return k_(this.__wrapped__,this.__actions__)}var US=sl(function(i,o,l){Me.call(i,l)?++i[l]:fn(i,l,1)});function BS(i,o,l){var p=pe(i)?Kn:Cx;return l&&Ot(i,o,l)&&(o=r),p(i,se(o,3))}function jS(i,o){var l=pe(i)?yr:g_;return l(i,se(o,3))}var $S=z_(hy),qS=z_(fy);function zS(i,o){return vt(pl(i,o),1)}function GS(i,o){return vt(pl(i,o),Wt)}function KS(i,o,l){return l=l===r?1:ye(l),vt(pl(i,o),l)}function yy(i,o){var l=pe(i)?Ft:Xn;return l(i,se(o,3))}function vy(i,o){var l=pe(i)?Nc:m_;return l(i,se(o,3))}var WS=sl(function(i,o,l){Me.call(i,l)?i[l].push(o):fn(i,l,[o])});function HS(i,o,l,p){i=Bt(i)?i:oo(i),l=l&&!p?ye(l):0;var y=i.length;return l<0&&(l=dt(y+l,0)),vl(i)?l<=y&&i.indexOf(o,l)>-1:!!y&&wr(i,o,l)>-1}var QS=we(function(i,o,l){var p=-1,y=typeof o=="function",T=Bt(i)?U(i.length):[];return Xn(i,function(x){T[++p]=y?Et(o,x,l):Ka(x,o,l)}),T}),JS=sl(function(i,o,l){fn(i,l,o)});function pl(i,o){var l=pe(i)?Fe:T_;return l(i,se(o,3))}function YS(i,o,l,p){return i==null?[]:(pe(o)||(o=o==null?[]:[o]),l=p?r:l,pe(l)||(l=l==null?[]:[l]),A_(i,o,l))}var XS=sl(function(i,o,l){i[l?0:1].push(o)},function(){return[[],[]]});function ZS(i,o,l){var p=pe(i)?Wn:d,y=arguments.length<3;return p(i,se(o,4),l,y,Xn)}function eR(i,o,l){var p=pe(i)?Vc:d,y=arguments.length<3;return p(i,se(o,4),l,y,m_)}function tR(i,o){var l=pe(i)?yr:g_;return l(i,_l(se(o,3)))}function rR(i){var o=pe(i)?h_:Hx;return o(i)}function nR(i,o,l){(l?Ot(i,o,l):o===r)?o=1:o=ye(o);var p=pe(i)?xx:Qx;return p(i,o)}function iR(i){var o=pe(i)?Ax:Yx;return o(i)}function sR(i){if(i==null)return 0;if(Bt(i))return vl(i)?Ys(i):i.length;var o=xt(i);return o==Pt||o==Mt?i.size:Hf(i).length}function oR(i,o,l){var p=pe(i)?Hs:Xx;return l&&Ot(i,o,l)&&(o=r),p(i,se(o,3))}var aR=we(function(i,o){if(i==null)return[];var l=o.length;return l>1&&Ot(i,o[0],o[1])?o=[]:l>2&&Ot(o[0],o[1],o[2])&&(o=[o[0]]),A_(i,vt(o,1),[])}),ml=jI||function(){return Xe.Date.now()};function uR(i,o){if(typeof o!="function")throw new nr(s);return i=ye(i),function(){if(--i<1)return o.apply(this,arguments)}}function wy(i,o,l){return o=l?r:o,o=i&&o==null?i.length:o,dn(i,de,r,r,r,r,o)}function by(i,o){var l;if(typeof o!="function")throw new nr(s);return i=ye(i),function(){return--i>0&&(l=o.apply(this,arguments)),i<=1&&(o=r),l}}var yd=we(function(i,o,l){var p=B;if(l.length){var y=Qn(l,io(yd));p|=re}return dn(i,p,o,l,y)}),Ty=we(function(i,o,l){var p=B|G;if(l.length){var y=Qn(l,io(Ty));p|=re}return dn(o,p,i,l,y)});function Ey(i,o,l){o=l?r:o;var p=dn(i,J,r,r,r,r,r,o);return p.placeholder=Ey.placeholder,p}function Iy(i,o,l){o=l?r:o;var p=dn(i,ee,r,r,r,r,r,o);return p.placeholder=Iy.placeholder,p}function xy(i,o,l){var p,y,T,x,P,N,q=0,z=!1,K=!1,Y=!0;if(typeof i!="function")throw new nr(s);o=ur(o)||0,We(l)&&(z=!!l.leading,K="maxWait"in l,T=K?dt(ur(l.maxWait)||0,o):T,Y="trailing"in l?!!l.trailing:Y);function te(tt){var Ir=p,yn=y;return p=y=r,q=tt,x=i.apply(yn,Ir),x}function oe(tt){return q=tt,P=Ya(Te,o),z?te(tt):x}function ve(tt){var Ir=tt-N,yn=tt-q,zy=o-Ir;return K?It(zy,T-yn):zy}function ae(tt){var Ir=tt-N,yn=tt-q;return N===r||Ir>=o||Ir<0||K&&yn>=T}function Te(){var tt=ml();if(ae(tt))return Ae(tt);P=Ya(Te,ve(tt))}function Ae(tt){return P=r,Y&&p?te(tt):(p=y=r,x)}function Xt(){P!==r&&V_(P),q=0,p=N=y=P=r}function kt(){return P===r?x:Ae(ml())}function Zt(){var tt=ml(),Ir=ae(tt);if(p=arguments,y=this,N=tt,Ir){if(P===r)return oe(N);if(K)return V_(P),P=Ya(Te,o),te(N)}return P===r&&(P=Ya(Te,o)),x}return Zt.cancel=Xt,Zt.flush=kt,Zt}var cR=we(function(i,o){return p_(i,1,o)}),lR=we(function(i,o,l){return p_(i,ur(o)||0,l)});function hR(i){return dn(i,C)}function gl(i,o){if(typeof i!="function"||o!=null&&typeof o!="function")throw new nr(s);var l=function(){var p=arguments,y=o?o.apply(this,p):p[0],T=l.cache;if(T.has(y))return T.get(y);var x=i.apply(this,p);return l.cache=T.set(y,x)||T,x};return l.cache=new(gl.Cache||hn),l}gl.Cache=hn;function _l(i){if(typeof i!="function")throw new nr(s);return function(){var o=arguments;switch(o.length){case 0:return!i.call(this);case 1:return!i.call(this,o[0]);case 2:return!i.call(this,o[0],o[1]);case 3:return!i.call(this,o[0],o[1],o[2])}return!i.apply(this,o)}}function fR(i){return by(2,i)}var dR=Zx(function(i,o){o=o.length==1&&pe(o[0])?Fe(o[0],_e(se())):Fe(vt(o,1),_e(se()));var l=o.length;return we(function(p){for(var y=-1,T=It(p.length,l);++y<T;)p[y]=o[y].call(this,p[y]);return Et(i,this,p)})}),vd=we(function(i,o){var l=Qn(o,io(vd));return dn(i,re,r,o,l)}),Ay=we(function(i,o){var l=Qn(o,io(Ay));return dn(i,le,r,o,l)}),pR=pn(function(i,o){return dn(i,ie,r,r,r,o)});function mR(i,o){if(typeof i!="function")throw new nr(s);return o=o===r?o:ye(o),we(i,o)}function gR(i,o){if(typeof i!="function")throw new nr(s);return o=o==null?0:dt(ye(o),0),we(function(l){var p=l[o],y=ti(l,0,o);return p&&vr(y,p),Et(i,this,y)})}function _R(i,o,l){var p=!0,y=!0;if(typeof i!="function")throw new nr(s);return We(l)&&(p="leading"in l?!!l.leading:p,y="trailing"in l?!!l.trailing:y),xy(i,o,{leading:p,maxWait:o,trailing:y})}function yR(i){return wy(i,1)}function vR(i,o){return vd(nd(o),i)}function wR(){if(!arguments.length)return[];var i=arguments[0];return pe(i)?i:[i]}function bR(i){return sr(i,E)}function TR(i,o){return o=typeof o=="function"?o:r,sr(i,E,o)}function ER(i){return sr(i,m|E)}function IR(i,o){return o=typeof o=="function"?o:r,sr(i,m|E,o)}function xR(i,o){return o==null||d_(i,o,mt(o))}function Er(i,o){return i===o||i!==i&&o!==o}var AR=cl(Gf),SR=cl(function(i,o){return i>=o}),rs=v_(function(){return arguments}())?v_:function(i){return Qe(i)&&Me.call(i,"callee")&&!s_.call(i,"callee")},pe=U.isArray,RR=ka?_e(ka):Lx;function Bt(i){return i!=null&&yl(i.length)&&!gn(i)}function et(i){return Qe(i)&&Bt(i)}function PR(i){return i===!0||i===!1||Qe(i)&&Dt(i)==Ri}var ri=qI||Cd,CR=kc?_e(kc):Mx;function DR(i){return Qe(i)&&i.nodeType===1&&!Xa(i)}function OR(i){if(i==null)return!0;if(Bt(i)&&(pe(i)||typeof i=="string"||typeof i.splice=="function"||ri(i)||so(i)||rs(i)))return!i.length;var o=xt(i);if(o==Pt||o==Mt)return!i.size;if(Ja(i))return!Hf(i).length;for(var l in i)if(Me.call(i,l))return!1;return!0}function kR(i,o){return Wa(i,o)}function NR(i,o,l){l=typeof l=="function"?l:r;var p=l?l(i,o):r;return p===r?Wa(i,o,r,l):!!p}function wd(i){if(!Qe(i))return!1;var o=Dt(i);return o==Ds||o==wf||typeof i.message=="string"&&typeof i.name=="string"&&!Xa(i)}function VR(i){return typeof i=="number"&&a_(i)}function gn(i){if(!We(i))return!1;var o=Dt(i);return o==rn||o==Pi||o==Si||o==uc}function Sy(i){return typeof i=="number"&&i==ye(i)}function yl(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=Pr}function We(i){var o=typeof i;return i!=null&&(o=="object"||o=="function")}function Qe(i){return i!=null&&typeof i=="object"}var Ry=Gn?_e(Gn):Ux;function LR(i,o){return i===o||Wf(i,o,ld(o))}function MR(i,o,l){return l=typeof l=="function"?l:r,Wf(i,o,ld(o),l)}function FR(i){return Py(i)&&i!=+i}function UR(i){if(TA(i))throw new he(n);return w_(i)}function BR(i){return i===null}function jR(i){return i==null}function Py(i){return typeof i=="number"||Qe(i)&&Dt(i)==nn}function Xa(i){if(!Qe(i)||Dt(i)!=Ht)return!1;var o=Gc(i);if(o===null)return!0;var l=Me.call(o,"constructor")&&o.constructor;return typeof l=="function"&&l instanceof l&&jc.call(l)==MI}var bd=Na?_e(Na):Bx;function $R(i){return Sy(i)&&i>=-Pr&&i<=Pr}var Cy=Ks?_e(Ks):jx;function vl(i){return typeof i=="string"||!pe(i)&&Qe(i)&&Dt(i)==Ln}function Yt(i){return typeof i=="symbol"||Qe(i)&&Dt(i)==Mn}var so=Gi?_e(Gi):$x;function qR(i){return i===r}function zR(i){return Qe(i)&&xt(i)==Di}function GR(i){return Qe(i)&&Dt(i)==ga}var KR=cl(Qf),WR=cl(function(i,o){return i<=o});function Dy(i){if(!i)return[];if(Bt(i))return vl(i)?br(i):Ut(i);if(Ua&&i[Ua])return xI(i[Ua]());var o=xt(i),l=o==Pt?Lf:o==Mt?Fc:oo;return l(i)}function _n(i){if(!i)return i===0?i:0;if(i=ur(i),i===Wt||i===-Wt){var o=i<0?-1:1;return o*Ai}return i===i?i:0}function ye(i){var o=_n(i),l=o%1;return o===o?l?o-l:o:0}function Oy(i){return i?Xi(ye(i),0,Lt):0}function ur(i){if(typeof i=="number")return i;if(Yt(i))return Cr;if(We(i)){var o=typeof i.valueOf=="function"?i.valueOf():i;i=We(o)?o+"":o}if(typeof i!="string")return i===0?i:+i;i=Q(i);var l=Ta.test(i);return l||Nr.test(i)?ze(i.slice(2),l?2:8):mc.test(i)?Cr:+i}function ky(i){return Ur(i,jt(i))}function HR(i){return i?Xi(ye(i),-Pr,Pr):i===0?i:0}function Ve(i){return i==null?"":Jt(i)}var QR=ro(function(i,o){if(Ja(o)||Bt(o)){Ur(o,mt(o),i);return}for(var l in o)Me.call(o,l)&&za(i,l,o[l])}),Ny=ro(function(i,o){Ur(o,jt(o),i)}),wl=ro(function(i,o,l,p){Ur(o,jt(o),i,p)}),JR=ro(function(i,o,l,p){Ur(o,mt(o),i,p)}),YR=pn($f);function XR(i,o){var l=to(i);return o==null?l:f_(l,o)}var ZR=we(function(i,o){i=Ue(i);var l=-1,p=o.length,y=p>2?o[2]:r;for(y&&Ot(o[0],o[1],y)&&(p=1);++l<p;)for(var T=o[l],x=jt(T),P=-1,N=x.length;++P<N;){var q=x[P],z=i[q];(z===r||Er(z,Xs[q])&&!Me.call(i,q))&&(i[q]=T[q])}return i}),e1=we(function(i){return i.push(r,Y_),Et(Vy,r,i)});function t1(i,o){return Va(i,se(o,3),Fr)}function r1(i,o){return Va(i,se(o,3),zf)}function n1(i,o){return i==null?i:qf(i,se(o,3),jt)}function i1(i,o){return i==null?i:__(i,se(o,3),jt)}function s1(i,o){return i&&Fr(i,se(o,3))}function o1(i,o){return i&&zf(i,se(o,3))}function a1(i){return i==null?[]:tl(i,mt(i))}function u1(i){return i==null?[]:tl(i,jt(i))}function Td(i,o,l){var p=i==null?r:Zi(i,o);return p===r?l:p}function c1(i,o){return i!=null&&ey(i,o,Ox)}function Ed(i,o){return i!=null&&ey(i,o,kx)}var l1=K_(function(i,o,l){o!=null&&typeof o.toString!="function"&&(o=$c.call(o)),i[o]=l},xd($t)),h1=K_(function(i,o,l){o!=null&&typeof o.toString!="function"&&(o=$c.call(o)),Me.call(i,o)?i[o].push(l):i[o]=[l]},se),f1=we(Ka);function mt(i){return Bt(i)?l_(i):Hf(i)}function jt(i){return Bt(i)?l_(i,!0):qx(i)}function d1(i,o){var l={};return o=se(o,3),Fr(i,function(p,y,T){fn(l,o(p,y,T),p)}),l}function p1(i,o){var l={};return o=se(o,3),Fr(i,function(p,y,T){fn(l,y,o(p,y,T))}),l}var m1=ro(function(i,o,l){rl(i,o,l)}),Vy=ro(function(i,o,l,p){rl(i,o,l,p)}),g1=pn(function(i,o){var l={};if(i==null)return l;var p=!1;o=Fe(o,function(T){return T=ei(T,i),p||(p=T.length>1),T}),Ur(i,ud(i),l),p&&(l=sr(l,m|_|E,lA));for(var y=o.length;y--;)ed(l,o[y]);return l});function _1(i,o){return Ly(i,_l(se(o)))}var y1=pn(function(i,o){return i==null?{}:Gx(i,o)});function Ly(i,o){if(i==null)return{};var l=Fe(ud(i),function(p){return[p]});return o=se(o),S_(i,l,function(p,y){return o(p,y[0])})}function v1(i,o,l){o=ei(o,i);var p=-1,y=o.length;for(y||(y=1,i=r);++p<y;){var T=i==null?r:i[Br(o[p])];T===r&&(p=y,T=l),i=gn(T)?T.call(i):T}return i}function w1(i,o,l){return i==null?i:Ha(i,o,l)}function b1(i,o,l,p){return p=typeof p=="function"?p:r,i==null?i:Ha(i,o,l,p)}var My=Q_(mt),Fy=Q_(jt);function T1(i,o,l){var p=pe(i),y=p||ri(i)||so(i);if(o=se(o,4),l==null){var T=i&&i.constructor;y?l=p?new T:[]:We(i)?l=gn(T)?to(Gc(i)):{}:l={}}return(y?Ft:Fr)(i,function(x,P,N){return o(l,x,P,N)}),l}function E1(i,o){return i==null?!0:ed(i,o)}function I1(i,o,l){return i==null?i:O_(i,o,nd(l))}function x1(i,o,l,p){return p=typeof p=="function"?p:r,i==null?i:O_(i,o,nd(l),p)}function oo(i){return i==null?[]:Ze(i,mt(i))}function A1(i){return i==null?[]:Ze(i,jt(i))}function S1(i,o,l){return l===r&&(l=o,o=r),l!==r&&(l=ur(l),l=l===l?l:0),o!==r&&(o=ur(o),o=o===o?o:0),Xi(ur(i),o,l)}function R1(i,o,l){return o=_n(o),l===r?(l=o,o=0):l=_n(l),i=ur(i),Nx(i,o,l)}function P1(i,o,l){if(l&&typeof l!="boolean"&&Ot(i,o,l)&&(o=l=r),l===r&&(typeof o=="boolean"?(l=o,o=r):typeof i=="boolean"&&(l=i,i=r)),i===r&&o===r?(i=0,o=1):(i=_n(i),o===r?(o=i,i=0):o=_n(o)),i>o){var p=i;i=o,o=p}if(l||i%1||o%1){var y=u_();return It(i+y*(o-i+Oa("1e-"+((y+"").length-1))),o)}return Yf(i,o)}var C1=no(function(i,o,l){return o=o.toLowerCase(),i+(l?Uy(o):o)});function Uy(i){return Id(Ve(i).toLowerCase())}function By(i){return i=Ve(i),i&&i.replace(_c,Qt).replace(zn,"")}function D1(i,o,l){i=Ve(i),o=Jt(o);var p=i.length;l=l===r?p:Xi(ye(l),0,p);var y=l;return l-=o.length,l>=0&&i.slice(l,y)==o}function O1(i){return i=Ve(i),i&&Oi.test(i)?i.replace(va,Qs):i}function k1(i){return i=Ve(i),i&&dc.test(i)?i.replace(an,"\\$&"):i}var N1=no(function(i,o,l){return i+(l?"-":"")+o.toLowerCase()}),V1=no(function(i,o,l){return i+(l?" ":"")+o.toLowerCase()}),L1=q_("toLowerCase");function M1(i,o,l){i=Ve(i),o=ye(o);var p=o?Ys(i):0;if(!o||p>=o)return i;var y=(o-p)/2;return ul(Qc(y),l)+i+ul(Hc(y),l)}function F1(i,o,l){i=Ve(i),o=ye(o);var p=o?Ys(i):0;return o&&p<o?i+ul(o-p,l):i}function U1(i,o,l){i=Ve(i),o=ye(o);var p=o?Ys(i):0;return o&&p<o?ul(o-p,l)+i:i}function B1(i,o,l){return l||o==null?o=0:o&&(o=+o),WI(Ve(i).replace(ct,""),o||0)}function j1(i,o,l){return(l?Ot(i,o,l):o===r)?o=1:o=ye(o),Xf(Ve(i),o)}function $1(){var i=arguments,o=Ve(i[0]);return i.length<3?o:o.replace(i[1],i[2])}var q1=no(function(i,o,l){return i+(l?"_":"")+o.toLowerCase()});function z1(i,o,l){return l&&typeof l!="number"&&Ot(i,o,l)&&(o=l=r),l=l===r?Lt:l>>>0,l?(i=Ve(i),i&&(typeof o=="string"||o!=null&&!bd(o))&&(o=Jt(o),!o&&Js(i))?ti(br(i),0,l):i.split(o,l)):[]}var G1=no(function(i,o,l){return i+(l?" ":"")+Id(o)});function K1(i,o,l){return i=Ve(i),l=l==null?0:Xi(ye(l),0,i.length),o=Jt(o),i.slice(l,l+o.length)==o}function W1(i,o,l){var p=w.templateSettings;l&&Ot(i,o,l)&&(o=r),i=Ve(i),o=wl({},o,p,J_);var y=wl({},o.imports,p.imports,J_),T=mt(y),x=Ze(y,T),P,N,q=0,z=o.interpolate||Bn,K="__p += '",Y=Mf((o.escape||Bn).source+"|"+z.source+"|"+(z===kr?Af:Bn).source+"|"+(o.evaluate||Bn).source+"|$","g"),te="//# sourceURL="+(Me.call(o,"sourceURL")?(o.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Nf+"]")+`
|
|
4
4
|
`;i.replace(Y,function(ae,Te,Ae,Xt,kt,Zt){return Ae||(Ae=Xt),K+=i.slice(q,Zt).replace(Ea,Fa),Te&&(P=!0,K+=`' +
|
|
5
5
|
__e(`+Te+`) +
|
|
6
6
|
'`),kt&&(N=!0,K+=`';
|
|
@@ -17,7 +17,7 @@ __p += '`),Ae&&(K+=`' +
|
|
|
17
17
|
function print() { __p += __j.call(arguments, '') }
|
|
18
18
|
`:`;
|
|
19
19
|
`)+K+`return __p
|
|
20
|
-
}`;var ve=jy(function(){return Ne(T,te+"return "+K).apply(r,x)});if(ve.source=K,wd(ve))throw ve;return ve}function HR(i){return Ve(i).toLowerCase()}function QR(i){return Ve(i).toUpperCase()}function JR(i,o,l){if(i=Ve(i),i&&(l||o===r))return Q(i);if(!i||!(o=Jt(o)))return i;var p=br(i),y=br(o),T=lt(p,y),x=ht(p,y)+1;return ti(p,T,x).join("")}function YR(i,o,l){if(i=Ve(i),i&&(l||o===r))return i.slice(0,e_(i)+1);if(!i||!(o=Jt(o)))return i;var p=br(i),y=ht(p,br(o))+1;return ti(p,0,y).join("")}function XR(i,o,l){if(i=Ve(i),i&&(l||o===r))return i.replace(ct,"");if(!i||!(o=Jt(o)))return i;var p=br(i),y=lt(p,br(o));return ti(p,y).join("")}function ZR(i,o){var l=A,p=R;if(We(o)){var y="separator"in o?o.separator:y;l="length"in o?ye(o.length):l,p="omission"in o?Jt(o.omission):p}i=Ve(i);var T=i.length;if(Js(i)){var x=br(i);T=x.length}if(l>=T)return i;var P=l-Ys(p);if(P<1)return p;var N=x?ti(x,0,P).join(""):i.slice(0,P);if(y===r)return N+p;if(x&&(P+=N.length-P),bd(y)){if(i.slice(P).search(y)){var q,z=N;for(y.global||(y=Mf(y.source,Ve(Vi.exec(y))+"g")),y.lastIndex=0;q=y.exec(z);)var K=q.index;N=N.slice(0,K===r?P:K)}}else if(i.indexOf(Jt(y),P)!=P){var Y=N.lastIndexOf(y);Y>-1&&(N=N.slice(0,Y))}return N+p}function eP(i){return i=Ve(i),i&&lc.test(i)?i.replace(Ls,PI):i}var tP=no(function(i,o,l){return i+(l?" ":"")+o.toUpperCase()}),Id=$_("toUpperCase");function By(i,o,l){return i=Ve(i),o=l?r:o,o===r?II(i)?OI(i):Mc(i):i.match(o)||[]}var jy=we(function(i,o){try{return Et(i,r,o)}catch(l){return wd(l)?l:new he(l)}}),rP=pn(function(i,o){return Ft(o,function(l){l=Br(l),fn(i,l,yd(i[l],i))}),i});function nP(i){var o=i==null?0:i.length,l=se();return i=o?Fe(i,function(p){if(typeof p[1]!="function")throw new nr(s);return[l(p[0]),p[1]]}):[],we(function(p){for(var y=-1;++y<o;){var T=i[y];if(Et(T[0],this,p))return Et(T[1],this,p)}})}function iP(i){return Px(sr(i,m))}function xd(i){return function(){return i}}function sP(i,o){return i==null||i!==i?o:i}var oP=z_(),aP=z_(!0);function $t(i){return i}function Ad(i){return w_(typeof i=="function"?i:sr(i,m))}function uP(i){return T_(sr(i,m))}function cP(i,o){return E_(i,sr(o,m))}var lP=we(function(i,o){return function(l){return Ka(l,i,o)}}),hP=we(function(i,o){return function(l){return Ka(i,l,o)}});function Sd(i,o,l){var p=mt(o),y=tl(o,p);l==null&&!(We(o)&&(y.length||!p.length))&&(l=o,o=i,i=this,y=tl(o,mt(o)));var T=!(We(l)&&"chain"in l)||!!l.chain,x=gn(i);return Ft(y,function(P){var N=o[P];i[P]=N,x&&(i.prototype[P]=function(){var q=this.__chain__;if(T||q){var z=i(this.__wrapped__),K=z.__actions__=Ut(this.__actions__);return K.push({func:N,args:arguments,thisArg:i}),z.__chain__=q,z}return N.apply(i,vr([this.value()],arguments))})}),i}function fP(){return Xe._===this&&(Xe._=FI),this}function Rd(){}function dP(i){return i=ye(i),we(function(o){return I_(o,i)})}var pP=sd(Fe),mP=sd(Kn),gP=sd(Hs);function $y(i){return fd(i)?Mr(Br(i)):Kx(i)}function _P(i){return function(o){return i==null?r:Zi(i,o)}}var yP=K_(),vP=K_(!0);function Pd(){return[]}function Cd(){return!1}function wP(){return{}}function bP(){return""}function TP(){return!0}function EP(i,o){if(i=ye(i),i<1||i>Pr)return[];var l=Lt,p=It(i,Lt);o=se(o),i-=Lt;for(var y=L(p,o);++l<i;)o(l);return y}function IP(i){return pe(i)?Fe(i,Br):Yt(i)?[i]:Ut(uy(Ve(i)))}function xP(i){var o=++LI;return Ve(i)+o}var AP=al(function(i,o){return i+o},0),SP=od("ceil"),RP=al(function(i,o){return i/o},1),PP=od("floor");function CP(i){return i&&i.length?el(i,$t,Gf):r}function DP(i,o){return i&&i.length?el(i,se(o,2),Gf):r}function OP(i){return Ma(i,$t)}function kP(i,o){return Ma(i,se(o,2))}function NP(i){return i&&i.length?el(i,$t,Qf):r}function VP(i,o){return i&&i.length?el(i,se(o,2),Qf):r}var LP=al(function(i,o){return i*o},1),MP=od("round"),FP=al(function(i,o){return i-o},0);function UP(i){return i&&i.length?b(i,$t):0}function BP(i,o){return i&&i.length?b(i,se(o,2)):0}return w.after=u1,w.ary=vy,w.assign=Q1,w.assignIn=ky,w.assignInWith=wl,w.assignWith=J1,w.at=Y1,w.before=wy,w.bind=yd,w.bindAll=rP,w.bindKey=by,w.castArray=w1,w.chain=gy,w.chunk=PA,w.compact=CA,w.concat=DA,w.cond=nP,w.conforms=iP,w.constant=xd,w.countBy=US,w.create=X1,w.curry=Ty,w.curryRight=Ey,w.debounce=Iy,w.defaults=Z1,w.defaultsDeep=eR,w.defer=c1,w.delay=l1,w.difference=OA,w.differenceBy=kA,w.differenceWith=NA,w.drop=VA,w.dropRight=LA,w.dropRightWhile=MA,w.dropWhile=FA,w.fill=UA,w.filter=jS,w.flatMap=zS,w.flatMapDeep=GS,w.flatMapDepth=KS,w.flatten=fy,w.flattenDeep=BA,w.flattenDepth=jA,w.flip=h1,w.flow=oP,w.flowRight=aP,w.fromPairs=$A,w.functions=aR,w.functionsIn=uR,w.groupBy=WS,w.initial=zA,w.intersection=GA,w.intersectionBy=KA,w.intersectionWith=WA,w.invert=lR,w.invertBy=hR,w.invokeMap=QS,w.iteratee=Ad,w.keyBy=JS,w.keys=mt,w.keysIn=jt,w.map=pl,w.mapKeys=dR,w.mapValues=pR,w.matches=uP,w.matchesProperty=cP,w.memoize=gl,w.merge=mR,w.mergeWith=Ny,w.method=lP,w.methodOf=hP,w.mixin=Sd,w.negate=_l,w.nthArg=dP,w.omit=gR,w.omitBy=_R,w.once=f1,w.orderBy=YS,w.over=pP,w.overArgs=d1,w.overEvery=mP,w.overSome=gP,w.partial=vd,w.partialRight=xy,w.partition=XS,w.pick=yR,w.pickBy=Vy,w.property=$y,w.propertyOf=_P,w.pull=YA,w.pullAll=py,w.pullAllBy=XA,w.pullAllWith=ZA,w.pullAt=eS,w.range=yP,w.rangeRight=vP,w.rearg=p1,w.reject=t1,w.remove=tS,w.rest=m1,w.reverse=gd,w.sampleSize=n1,w.set=wR,w.setWith=bR,w.shuffle=i1,w.slice=rS,w.sortBy=a1,w.sortedUniq=cS,w.sortedUniqBy=lS,w.split=zR,w.spread=g1,w.tail=hS,w.take=fS,w.takeRight=dS,w.takeRightWhile=pS,w.takeWhile=mS,w.tap=CS,w.throttle=_1,w.thru=dl,w.toArray=Cy,w.toPairs=Ly,w.toPairsIn=My,w.toPath=IP,w.toPlainObject=Oy,w.transform=TR,w.unary=y1,w.union=gS,w.unionBy=_S,w.unionWith=yS,w.uniq=vS,w.uniqBy=wS,w.uniqWith=bS,w.unset=ER,w.unzip=_d,w.unzipWith=my,w.update=IR,w.updateWith=xR,w.values=oo,w.valuesIn=AR,w.without=TS,w.words=By,w.wrap=v1,w.xor=ES,w.xorBy=IS,w.xorWith=xS,w.zip=AS,w.zipObject=SS,w.zipObjectDeep=RS,w.zipWith=PS,w.entries=Ly,w.entriesIn=My,w.extend=ky,w.extendWith=wl,Sd(w,w),w.add=AP,w.attempt=jy,w.camelCase=CR,w.capitalize=Fy,w.ceil=SP,w.clamp=SR,w.clone=b1,w.cloneDeep=E1,w.cloneDeepWith=I1,w.cloneWith=T1,w.conformsTo=x1,w.deburr=Uy,w.defaultTo=sP,w.divide=RP,w.endsWith=DR,w.eq=Er,w.escape=OR,w.escapeRegExp=kR,w.every=BS,w.find=$S,w.findIndex=ly,w.findKey=tR,w.findLast=qS,w.findLastIndex=hy,w.findLastKey=rR,w.floor=PP,w.forEach=_y,w.forEachRight=yy,w.forIn=nR,w.forInRight=iR,w.forOwn=sR,w.forOwnRight=oR,w.get=Td,w.gt=A1,w.gte=S1,w.has=cR,w.hasIn=Ed,w.head=dy,w.identity=$t,w.includes=HS,w.indexOf=qA,w.inRange=RR,w.invoke=fR,w.isArguments=rs,w.isArray=pe,w.isArrayBuffer=R1,w.isArrayLike=Bt,w.isArrayLikeObject=et,w.isBoolean=P1,w.isBuffer=ri,w.isDate=C1,w.isElement=D1,w.isEmpty=O1,w.isEqual=k1,w.isEqualWith=N1,w.isError=wd,w.isFinite=V1,w.isFunction=gn,w.isInteger=Ay,w.isLength=yl,w.isMap=Sy,w.isMatch=L1,w.isMatchWith=M1,w.isNaN=F1,w.isNative=U1,w.isNil=j1,w.isNull=B1,w.isNumber=Ry,w.isObject=We,w.isObjectLike=Qe,w.isPlainObject=Xa,w.isRegExp=bd,w.isSafeInteger=$1,w.isSet=Py,w.isString=vl,w.isSymbol=Yt,w.isTypedArray=so,w.isUndefined=q1,w.isWeakMap=z1,w.isWeakSet=G1,w.join=HA,w.kebabCase=NR,w.last=ar,w.lastIndexOf=QA,w.lowerCase=VR,w.lowerFirst=LR,w.lt=K1,w.lte=W1,w.max=CP,w.maxBy=DP,w.mean=OP,w.meanBy=kP,w.min=NP,w.minBy=VP,w.stubArray=Pd,w.stubFalse=Cd,w.stubObject=wP,w.stubString=bP,w.stubTrue=TP,w.multiply=LP,w.nth=JA,w.noConflict=fP,w.noop=Rd,w.now=ml,w.pad=MR,w.padEnd=FR,w.padStart=UR,w.parseInt=BR,w.random=PR,w.reduce=ZS,w.reduceRight=e1,w.repeat=jR,w.replace=$R,w.result=vR,w.round=MP,w.runInContext=O,w.sample=r1,w.size=s1,w.snakeCase=qR,w.some=o1,w.sortedIndex=nS,w.sortedIndexBy=iS,w.sortedIndexOf=sS,w.sortedLastIndex=oS,w.sortedLastIndexBy=aS,w.sortedLastIndexOf=uS,w.startCase=GR,w.startsWith=KR,w.subtract=FP,w.sum=UP,w.sumBy=BP,w.template=WR,w.times=EP,w.toFinite=_n,w.toInteger=ye,w.toLength=Dy,w.toLower=HR,w.toNumber=ur,w.toSafeInteger=H1,w.toString=Ve,w.toUpper=QR,w.trim=JR,w.trimEnd=YR,w.trimStart=XR,w.truncate=ZR,w.unescape=eP,w.uniqueId=xP,w.upperCase=tP,w.upperFirst=Id,w.each=_y,w.eachRight=yy,w.first=dy,Sd(w,function(){var i={};return Fr(w,function(o,l){Me.call(w.prototype,l)||(i[l]=o)}),i}(),{chain:!1}),w.VERSION=e,Ft(["bind","bindKey","curry","curryRight","partial","partialRight"],function(i){w[i].placeholder=w}),Ft(["drop","take"],function(i,o){Ie.prototype[i]=function(l){l=l===r?1:dt(ye(l),0);var p=this.__filtered__&&!o?new Ie(this):this.clone();return p.__filtered__?p.__takeCount__=It(l,p.__takeCount__):p.__views__.push({size:It(l,Lt),type:i+(p.__dir__<0?"Right":"")}),p},Ie.prototype[i+"Right"]=function(l){return this.reverse()[i](l).reverse()}}),Ft(["filter","map","takeWhile"],function(i,o){var l=o+1,p=l==M||l==dr;Ie.prototype[i]=function(y){var T=this.clone();return T.__iteratees__.push({iteratee:se(y,3),type:l}),T.__filtered__=T.__filtered__||p,T}}),Ft(["head","last"],function(i,o){var l="take"+(o?"Right":"");Ie.prototype[i]=function(){return this[l](1).value()[0]}}),Ft(["initial","tail"],function(i,o){var l="drop"+(o?"":"Right");Ie.prototype[i]=function(){return this.__filtered__?new Ie(this):this[l](1)}}),Ie.prototype.compact=function(){return this.filter($t)},Ie.prototype.find=function(i){return this.filter(i).head()},Ie.prototype.findLast=function(i){return this.reverse().find(i)},Ie.prototype.invokeMap=we(function(i,o){return typeof i=="function"?new Ie(this):this.map(function(l){return Ka(l,i,o)})}),Ie.prototype.reject=function(i){return this.filter(_l(se(i)))},Ie.prototype.slice=function(i,o){i=ye(i);var l=this;return l.__filtered__&&(i>0||o<0)?new Ie(l):(i<0?l=l.takeRight(-i):i&&(l=l.drop(i)),o!==r&&(o=ye(o),l=o<0?l.dropRight(-o):l.take(o-i)),l)},Ie.prototype.takeRightWhile=function(i){return this.reverse().takeWhile(i).reverse()},Ie.prototype.toArray=function(){return this.take(Lt)},Fr(Ie.prototype,function(i,o){var l=/^(?:filter|find|map|reject)|While$/.test(o),p=/^(?:head|last)$/.test(o),y=w[p?"take"+(o=="last"?"Right":""):o],T=p||/^find/.test(o);y&&(w.prototype[o]=function(){var x=this.__wrapped__,P=p?[1]:arguments,N=x instanceof Ie,q=P[0],z=N||pe(x),K=function(Te){var Ae=y.apply(w,vr([Te],P));return p&&Y?Ae[0]:Ae};z&&l&&typeof q=="function"&&q.length!=1&&(N=z=!1);var Y=this.__chain__,te=!!this.__actions__.length,oe=T&&!Y,ve=N&&!te;if(!T&&z){x=ve?x:new Ie(this);var ae=i.apply(x,P);return ae.__actions__.push({func:dl,args:[K],thisArg:r}),new ir(ae,Y)}return oe&&ve?i.apply(this,P):(ae=this.thru(K),oe?p?ae.value()[0]:ae.value():ae)})}),Ft(["pop","push","shift","sort","splice","unshift"],function(i){var o=Uc[i],l=/^(?:push|sort|unshift)$/.test(i)?"tap":"thru",p=/^(?:pop|shift)$/.test(i);w.prototype[i]=function(){var y=arguments;if(p&&!this.__chain__){var T=this.value();return o.apply(pe(T)?T:[],y)}return this[l](function(x){return o.apply(pe(x)?x:[],y)})}}),Fr(Ie.prototype,function(i,o){var l=w[o];if(l){var p=l.name+"";Me.call(eo,p)||(eo[p]=[]),eo[p].push({name:o,func:l})}}),eo[ol(r,G).name]=[{name:"wrapper",func:r}],Ie.prototype.clone=ex,Ie.prototype.reverse=tx,Ie.prototype.value=rx,w.prototype.at=DS,w.prototype.chain=OS,w.prototype.commit=kS,w.prototype.next=NS,w.prototype.plant=LS,w.prototype.reverse=MS,w.prototype.toJSON=w.prototype.valueOf=w.prototype.value=FS,w.prototype.first=w.prototype.head,Ua&&(w.prototype[Ua]=VS),w},Jn=kI();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Xe._=Jn,define(function(){return Jn})):Lr?((Lr.exports=Jn)._=Jn,zs._=Jn):Xe._=Jn}).call(fa)});var hI=cr((YW,lI)=>{var yf=uI();function cI(r,e){var t={};return Object.keys(r).sort(e||void 0).forEach(function(n){t[n]=r[n]}),t}function Jg(r,e){if(yf.isArray(r))return yf.map(r,function(n){return Jg(n,e)});if(yf.isObject(r)){var t=cI(r,e);return yf.forEach(t,function(n,s){t[s]=Jg(n)}),t}else return r}lI.exports={keyArrange:cI,keyArrangeDeep:Jg}});var JP=typeof global=="object"&&global&&global.Object===Object&&global,bl=JP;var YP=typeof self=="object"&&self&&self.Object===Object&&self,XP=bl||YP||Function("return this")(),Je=XP;var ZP=Je.Symbol,Nt=ZP;var Gy=Object.prototype,eC=Gy.hasOwnProperty,tC=Gy.toString,eu=Nt?Nt.toStringTag:void 0;function rC(r){var e=eC.call(r,eu),t=r[eu];try{r[eu]=void 0;var n=!0}catch{}var s=tC.call(r);return n&&(e?r[eu]=t:delete r[eu]),s}var Ky=rC;var nC=Object.prototype,iC=nC.toString;function sC(r){return iC.call(r)}var Wy=sC;var oC="[object Null]",aC="[object Undefined]",Hy=Nt?Nt.toStringTag:void 0;function uC(r){return r==null?r===void 0?aC:oC:Hy&&Hy in Object(r)?Ky(r):Wy(r)}var xr=uC;function cC(r){return r!=null&&typeof r=="object"}var Vt=cC;var lC="[object Symbol]";function hC(r){return typeof r=="symbol"||Vt(r)&&xr(r)==lC}var ni=hC;function fC(r,e){for(var t=-1,n=r==null?0:r.length,s=Array(n);++t<n;)s[t]=e(r[t],t,r);return s}var Qy=fC;var dC=Array.isArray,rt=dC;var pC=1/0,Jy=Nt?Nt.prototype:void 0,Yy=Jy?Jy.toString:void 0;function Xy(r){if(typeof r=="string")return r;if(rt(r))return Qy(r,Xy)+"";if(ni(r))return Yy?Yy.call(r):"";var e=r+"";return e=="0"&&1/r==-pC?"-0":e}var Zy=Xy;var mC=/\s/;function gC(r){for(var e=r.length;e--&&mC.test(r.charAt(e)););return e}var ev=gC;var _C=/^\s+/;function yC(r){return r&&r.slice(0,ev(r)+1).replace(_C,"")}var tv=yC;function vC(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var De=vC;var rv=NaN,wC=/^[-+]0x[0-9a-f]+$/i,bC=/^0b[01]+$/i,TC=/^0o[0-7]+$/i,EC=parseInt;function IC(r){if(typeof r=="number")return r;if(ni(r))return rv;if(De(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=De(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=tv(r);var t=bC.test(r);return t||TC.test(r)?EC(r.slice(2),t?2:8):wC.test(r)?rv:+r}var Od=IC;function xC(r){return r}var ao=xC;var AC="[object AsyncFunction]",SC="[object Function]",RC="[object GeneratorFunction]",PC="[object Proxy]";function CC(r){if(!De(r))return!1;var e=xr(r);return e==SC||e==RC||e==AC||e==PC}var Tl=CC;var DC=Je["__core-js_shared__"],El=DC;var nv=function(){var r=/[^.]+$/.exec(El&&El.keys&&El.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function OC(r){return!!nv&&nv in r}var iv=OC;var kC=Function.prototype,NC=kC.toString;function VC(r){if(r!=null){try{return NC.call(r)}catch{}try{return r+""}catch{}}return""}var vn=VC;var LC=/[\\^$.*+?()[\]{}|]/g,MC=/^\[object .+?Constructor\]$/,FC=Function.prototype,UC=Object.prototype,BC=FC.toString,jC=UC.hasOwnProperty,$C=RegExp("^"+BC.call(jC).replace(LC,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function qC(r){if(!De(r)||iv(r))return!1;var e=Tl(r)?$C:MC;return e.test(vn(r))}var sv=qC;function zC(r,e){return r==null?void 0:r[e]}var ov=zC;function GC(r,e){var t=ov(r,e);return sv(t)?t:void 0}var qt=GC;var KC=qt(Je,"WeakMap"),Il=KC;var av=Object.create,WC=function(){function r(){}return function(e){if(!De(e))return{};if(av)return av(e);r.prototype=e;var t=new r;return r.prototype=void 0,t}}(),uv=WC;function HC(r,e,t){switch(t.length){case 0:return r.call(e);case 1:return r.call(e,t[0]);case 2:return r.call(e,t[0],t[1]);case 3:return r.call(e,t[0],t[1],t[2])}return r.apply(e,t)}var cv=HC;function QC(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}var lv=QC;var JC=800,YC=16,XC=Date.now;function ZC(r){var e=0,t=0;return function(){var n=XC(),s=YC-(n-t);if(t=n,s>0){if(++e>=JC)return arguments[0]}else e=0;return r.apply(void 0,arguments)}}var hv=ZC;function eD(r){return function(){return r}}var fv=eD;var tD=function(){try{var r=qt(Object,"defineProperty");return r({},"",{}),r}catch{}}(),uo=tD;var rD=uo?function(r,e){return uo(r,"toString",{configurable:!0,enumerable:!1,value:fv(e),writable:!0})}:ao,dv=rD;var nD=hv(dv),pv=nD;function iD(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var mv=iD;var sD=9007199254740991,oD=/^(?:0|[1-9]\d*)$/;function aD(r,e){var t=typeof r;return e=e==null?sD:e,!!e&&(t=="number"||t!="symbol"&&oD.test(r))&&r>-1&&r%1==0&&r<e}var ii=aD;function uD(r,e,t){e=="__proto__"&&uo?uo(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[e]=t}var co=uD;function cD(r,e){return r===e||r!==r&&e!==e}var jr=cD;var lD=Object.prototype,hD=lD.hasOwnProperty;function fD(r,e,t){var n=r[e];(!(hD.call(r,e)&&jr(n,t))||t===void 0&&!(e in r))&&co(r,e,t)}var lo=fD;function dD(r,e,t,n){var s=!t;t||(t={});for(var a=-1,c=e.length;++a<c;){var h=e[a],f=n?n(t[h],r[h],h,t,r):void 0;f===void 0&&(f=r[h]),s?co(t,h,f):lo(t,h,f)}return t}var si=dD;var gv=Math.max;function pD(r,e,t){return e=gv(e===void 0?r.length-1:e,0),function(){for(var n=arguments,s=-1,a=gv(n.length-e,0),c=Array(a);++s<a;)c[s]=n[e+s];s=-1;for(var h=Array(e+1);++s<e;)h[s]=n[s];return h[e]=t(c),cv(r,this,h)}}var _v=pD;function mD(r,e){return pv(_v(r,e,ao),r+"")}var yv=mD;var gD=9007199254740991;function _D(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=gD}var ho=_D;function yD(r){return r!=null&&ho(r.length)&&!Tl(r)}var oi=yD;function vD(r,e,t){if(!De(t))return!1;var n=typeof e;return(n=="number"?oi(t)&&ii(e,t.length):n=="string"&&e in t)?jr(t[e],r):!1}var vv=vD;var wD=Object.prototype;function bD(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||wD;return r===t}var ai=bD;function TD(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}var wv=TD;var ED="[object Arguments]";function ID(r){return Vt(r)&&xr(r)==ED}var kd=ID;var bv=Object.prototype,xD=bv.hasOwnProperty,AD=bv.propertyIsEnumerable,SD=kd(function(){return arguments}())?kd:function(r){return Vt(r)&&xD.call(r,"callee")&&!AD.call(r,"callee")},fo=SD;function RD(){return!1}var Tv=RD;var xv=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ev=xv&&typeof module=="object"&&module&&!module.nodeType&&module,PD=Ev&&Ev.exports===xv,Iv=PD?Je.Buffer:void 0,CD=Iv?Iv.isBuffer:void 0,DD=CD||Tv,wn=DD;var OD="[object Arguments]",kD="[object Array]",ND="[object Boolean]",VD="[object Date]",LD="[object Error]",MD="[object Function]",FD="[object Map]",UD="[object Number]",BD="[object Object]",jD="[object RegExp]",$D="[object Set]",qD="[object String]",zD="[object WeakMap]",GD="[object ArrayBuffer]",KD="[object DataView]",WD="[object Float32Array]",HD="[object Float64Array]",QD="[object Int8Array]",JD="[object Int16Array]",YD="[object Int32Array]",XD="[object Uint8Array]",ZD="[object Uint8ClampedArray]",eO="[object Uint16Array]",tO="[object Uint32Array]",qe={};qe[WD]=qe[HD]=qe[QD]=qe[JD]=qe[YD]=qe[XD]=qe[ZD]=qe[eO]=qe[tO]=!0;qe[OD]=qe[kD]=qe[GD]=qe[ND]=qe[KD]=qe[VD]=qe[LD]=qe[MD]=qe[FD]=qe[UD]=qe[BD]=qe[jD]=qe[$D]=qe[qD]=qe[zD]=!1;function rO(r){return Vt(r)&&ho(r.length)&&!!qe[xr(r)]}var Av=rO;function nO(r){return function(e){return r(e)}}var po=nO;var Sv=typeof exports=="object"&&exports&&!exports.nodeType&&exports,tu=Sv&&typeof module=="object"&&module&&!module.nodeType&&module,iO=tu&&tu.exports===Sv,Nd=iO&&bl.process,sO=function(){try{var r=tu&&tu.require&&tu.require("util").types;return r||Nd&&Nd.binding&&Nd.binding("util")}catch{}}(),bn=sO;var Rv=bn&&bn.isTypedArray,oO=Rv?po(Rv):Av,mo=oO;var aO=Object.prototype,uO=aO.hasOwnProperty;function cO(r,e){var t=rt(r),n=!t&&fo(r),s=!t&&!n&&wn(r),a=!t&&!n&&!s&&mo(r),c=t||n||s||a,h=c?wv(r.length,String):[],f=h.length;for(var m in r)(e||uO.call(r,m))&&!(c&&(m=="length"||s&&(m=="offset"||m=="parent")||a&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||ii(m,f)))&&h.push(m);return h}var xl=cO;function lO(r,e){return function(t){return r(e(t))}}var Al=lO;var hO=Al(Object.keys,Object),Pv=hO;var fO=Object.prototype,dO=fO.hasOwnProperty;function pO(r){if(!ai(r))return Pv(r);var e=[];for(var t in Object(r))dO.call(r,t)&&t!="constructor"&&e.push(t);return e}var Sl=pO;function mO(r){return oi(r)?xl(r):Sl(r)}var At=mO;function gO(r){var e=[];if(r!=null)for(var t in Object(r))e.push(t);return e}var Cv=gO;var _O=Object.prototype,yO=_O.hasOwnProperty;function vO(r){if(!De(r))return Cv(r);var e=ai(r),t=[];for(var n in r)n=="constructor"&&(e||!yO.call(r,n))||t.push(n);return t}var Dv=vO;function wO(r){return oi(r)?xl(r,!0):Dv(r)}var ui=wO;var bO=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,TO=/^\w*$/;function EO(r,e){if(rt(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||ni(r)?!0:TO.test(r)||!bO.test(r)||e!=null&&r in Object(e)}var go=EO;var IO=qt(Object,"create"),Tn=IO;function xO(){this.__data__=Tn?Tn(null):{},this.size=0}var Ov=xO;function AO(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var kv=AO;var SO="__lodash_hash_undefined__",RO=Object.prototype,PO=RO.hasOwnProperty;function CO(r){var e=this.__data__;if(Tn){var t=e[r];return t===SO?void 0:t}return PO.call(e,r)?e[r]:void 0}var Nv=CO;var DO=Object.prototype,OO=DO.hasOwnProperty;function kO(r){var e=this.__data__;return Tn?e[r]!==void 0:OO.call(e,r)}var Vv=kO;var NO="__lodash_hash_undefined__";function VO(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=Tn&&e===void 0?NO:e,this}var Lv=VO;function _o(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}_o.prototype.clear=Ov;_o.prototype.delete=kv;_o.prototype.get=Nv;_o.prototype.has=Vv;_o.prototype.set=Lv;var Vd=_o;function LO(){this.__data__=[],this.size=0}var Mv=LO;function MO(r,e){for(var t=r.length;t--;)if(jr(r[t][0],e))return t;return-1}var ci=MO;var FO=Array.prototype,UO=FO.splice;function BO(r){var e=this.__data__,t=ci(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():UO.call(e,t,1),--this.size,!0}var Fv=BO;function jO(r){var e=this.__data__,t=ci(e,r);return t<0?void 0:e[t][1]}var Uv=jO;function $O(r){return ci(this.__data__,r)>-1}var Bv=$O;function qO(r,e){var t=this.__data__,n=ci(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var jv=qO;function yo(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}yo.prototype.clear=Mv;yo.prototype.delete=Fv;yo.prototype.get=Uv;yo.prototype.has=Bv;yo.prototype.set=jv;var li=yo;var zO=qt(Je,"Map"),hi=zO;function GO(){this.size=0,this.__data__={hash:new Vd,map:new(hi||li),string:new Vd}}var $v=GO;function KO(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var qv=KO;function WO(r,e){var t=r.__data__;return qv(e)?t[typeof e=="string"?"string":"hash"]:t.map}var fi=WO;function HO(r){var e=fi(this,r).delete(r);return this.size-=e?1:0,e}var zv=HO;function QO(r){return fi(this,r).get(r)}var Gv=QO;function JO(r){return fi(this,r).has(r)}var Kv=JO;function YO(r,e){var t=fi(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var Wv=YO;function vo(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}vo.prototype.clear=$v;vo.prototype.delete=zv;vo.prototype.get=Gv;vo.prototype.has=Kv;vo.prototype.set=Wv;var ns=vo;var XO="Expected a function";function Ld(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(XO);var t=function(){var n=arguments,s=e?e.apply(this,n):n[0],a=t.cache;if(a.has(s))return a.get(s);var c=r.apply(this,n);return t.cache=a.set(s,c)||a,c};return t.cache=new(Ld.Cache||ns),t}Ld.Cache=ns;var Hv=Ld;var ZO=500;function ek(r){var e=Hv(r,function(n){return t.size===ZO&&t.clear(),n}),t=e.cache;return e}var Qv=ek;var tk=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rk=/\\(\\)?/g,nk=Qv(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(tk,function(t,n,s,a){e.push(s?a.replace(rk,"$1"):n||t)}),e}),Jv=nk;function ik(r){return r==null?"":Zy(r)}var Yv=ik;function sk(r,e){return rt(r)?r:go(r,e)?[r]:Jv(Yv(r))}var wo=sk;var ok=1/0;function ak(r){if(typeof r=="string"||ni(r))return r;var e=r+"";return e=="0"&&1/r==-ok?"-0":e}var $r=ak;function uk(r,e){e=wo(e,r);for(var t=0,n=e.length;r!=null&&t<n;)r=r[$r(e[t++])];return t&&t==n?r:void 0}var Rl=uk;function ck(r,e,t){var n=r==null?void 0:Rl(r,e);return n===void 0?t:n}var ru=ck;function lk(r,e){for(var t=-1,n=e.length,s=r.length;++t<n;)r[s+t]=e[t];return r}var Pl=lk;var hk=Al(Object.getPrototypeOf,Object),Cl=hk;function fk(){this.__data__=new li,this.size=0}var Xv=fk;function dk(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var Zv=dk;function pk(r){return this.__data__.get(r)}var ew=pk;function mk(r){return this.__data__.has(r)}var tw=mk;var gk=200;function _k(r,e){var t=this.__data__;if(t instanceof li){var n=t.__data__;if(!hi||n.length<gk-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new ns(n)}return t.set(r,e),this.size=t.size,this}var rw=_k;function bo(r){var e=this.__data__=new li(r);this.size=e.size}bo.prototype.clear=Xv;bo.prototype.delete=Zv;bo.prototype.get=ew;bo.prototype.has=tw;bo.prototype.set=rw;var di=bo;function yk(r,e){return r&&si(e,At(e),r)}var nw=yk;function vk(r,e){return r&&si(e,ui(e),r)}var iw=vk;var uw=typeof exports=="object"&&exports&&!exports.nodeType&&exports,sw=uw&&typeof module=="object"&&module&&!module.nodeType&&module,wk=sw&&sw.exports===uw,ow=wk?Je.Buffer:void 0,aw=ow?ow.allocUnsafe:void 0;function bk(r,e){if(e)return r.slice();var t=r.length,n=aw?aw(t):new r.constructor(t);return r.copy(n),n}var cw=bk;function Tk(r,e){for(var t=-1,n=r==null?0:r.length,s=0,a=[];++t<n;){var c=r[t];e(c,t,r)&&(a[s++]=c)}return a}var lw=Tk;function Ek(){return[]}var Dl=Ek;var Ik=Object.prototype,xk=Ik.propertyIsEnumerable,hw=Object.getOwnPropertySymbols,Ak=hw?function(r){return r==null?[]:(r=Object(r),lw(hw(r),function(e){return xk.call(r,e)}))}:Dl,To=Ak;function Sk(r,e){return si(r,To(r),e)}var fw=Sk;var Rk=Object.getOwnPropertySymbols,Pk=Rk?function(r){for(var e=[];r;)Pl(e,To(r)),r=Cl(r);return e}:Dl,Ol=Pk;function Ck(r,e){return si(r,Ol(r),e)}var dw=Ck;function Dk(r,e,t){var n=e(r);return rt(r)?n:Pl(n,t(r))}var kl=Dk;function Ok(r){return kl(r,At,To)}var nu=Ok;function kk(r){return kl(r,ui,Ol)}var pw=kk;var Nk=qt(Je,"DataView"),Nl=Nk;var Vk=qt(Je,"Promise"),Vl=Vk;var Lk=qt(Je,"Set"),Ll=Lk;var mw="[object Map]",Mk="[object Object]",gw="[object Promise]",_w="[object Set]",yw="[object WeakMap]",vw="[object DataView]",Fk=vn(Nl),Uk=vn(hi),Bk=vn(Vl),jk=vn(Ll),$k=vn(Il),is=xr;(Nl&&is(new Nl(new ArrayBuffer(1)))!=vw||hi&&is(new hi)!=mw||Vl&&is(Vl.resolve())!=gw||Ll&&is(new Ll)!=_w||Il&&is(new Il)!=yw)&&(is=function(r){var e=xr(r),t=e==Mk?r.constructor:void 0,n=t?vn(t):"";if(n)switch(n){case Fk:return vw;case Uk:return mw;case Bk:return gw;case jk:return _w;case $k:return yw}return e});var Ar=is;var qk=Object.prototype,zk=qk.hasOwnProperty;function Gk(r){var e=r.length,t=new r.constructor(e);return e&&typeof r[0]=="string"&&zk.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var ww=Gk;var Kk=Je.Uint8Array,Eo=Kk;function Wk(r){var e=new r.constructor(r.byteLength);return new Eo(e).set(new Eo(r)),e}var Io=Wk;function Hk(r,e){var t=e?Io(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var bw=Hk;var Qk=/\w*$/;function Jk(r){var e=new r.constructor(r.source,Qk.exec(r));return e.lastIndex=r.lastIndex,e}var Tw=Jk;var Ew=Nt?Nt.prototype:void 0,Iw=Ew?Ew.valueOf:void 0;function Yk(r){return Iw?Object(Iw.call(r)):{}}var xw=Yk;function Xk(r,e){var t=e?Io(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.length)}var Aw=Xk;var Zk="[object Boolean]",eN="[object Date]",tN="[object Map]",rN="[object Number]",nN="[object RegExp]",iN="[object Set]",sN="[object String]",oN="[object Symbol]",aN="[object ArrayBuffer]",uN="[object DataView]",cN="[object Float32Array]",lN="[object Float64Array]",hN="[object Int8Array]",fN="[object Int16Array]",dN="[object Int32Array]",pN="[object Uint8Array]",mN="[object Uint8ClampedArray]",gN="[object Uint16Array]",_N="[object Uint32Array]";function yN(r,e,t){var n=r.constructor;switch(e){case aN:return Io(r);case Zk:case eN:return new n(+r);case uN:return bw(r,t);case cN:case lN:case hN:case fN:case dN:case pN:case mN:case gN:case _N:return Aw(r,t);case tN:return new n;case rN:case sN:return new n(r);case nN:return Tw(r);case iN:return new n;case oN:return xw(r)}}var Sw=yN;function vN(r){return typeof r.constructor=="function"&&!ai(r)?uv(Cl(r)):{}}var Rw=vN;var wN="[object Map]";function bN(r){return Vt(r)&&Ar(r)==wN}var Pw=bN;var Cw=bn&&bn.isMap,TN=Cw?po(Cw):Pw,Dw=TN;var EN="[object Set]";function IN(r){return Vt(r)&&Ar(r)==EN}var Ow=IN;var kw=bn&&bn.isSet,xN=kw?po(kw):Ow,Nw=xN;var AN=1,SN=2,RN=4,Vw="[object Arguments]",PN="[object Array]",CN="[object Boolean]",DN="[object Date]",ON="[object Error]",Lw="[object Function]",kN="[object GeneratorFunction]",NN="[object Map]",VN="[object Number]",Mw="[object Object]",LN="[object RegExp]",MN="[object Set]",FN="[object String]",UN="[object Symbol]",BN="[object WeakMap]",jN="[object ArrayBuffer]",$N="[object DataView]",qN="[object Float32Array]",zN="[object Float64Array]",GN="[object Int8Array]",KN="[object Int16Array]",WN="[object Int32Array]",HN="[object Uint8Array]",QN="[object Uint8ClampedArray]",JN="[object Uint16Array]",YN="[object Uint32Array]",Be={};Be[Vw]=Be[PN]=Be[jN]=Be[$N]=Be[CN]=Be[DN]=Be[qN]=Be[zN]=Be[GN]=Be[KN]=Be[WN]=Be[NN]=Be[VN]=Be[Mw]=Be[LN]=Be[MN]=Be[FN]=Be[UN]=Be[HN]=Be[QN]=Be[JN]=Be[YN]=!0;Be[ON]=Be[Lw]=Be[BN]=!1;function Ml(r,e,t,n,s,a){var c,h=e&AN,f=e&SN,m=e&RN;if(t&&(c=s?t(r,n,s,a):t(r)),c!==void 0)return c;if(!De(r))return r;var _=rt(r);if(_){if(c=ww(r),!h)return lv(r,c)}else{var E=Ar(r),I=E==Lw||E==kN;if(wn(r))return cw(r,h);if(E==Mw||E==Vw||I&&!s){if(c=f||I?{}:Rw(r),!h)return f?dw(r,iw(c,r)):fw(r,nw(c,r))}else{if(!Be[E])return s?r:{};c=Sw(r,E,h)}}a||(a=new di);var k=a.get(r);if(k)return k;a.set(r,c),Nw(r)?r.forEach(function(j){c.add(Ml(j,e,t,j,r,a))}):Dw(r)&&r.forEach(function(j,J){c.set(J,Ml(j,e,t,J,r,a))});var B=m?f?pw:nu:f?ui:At,G=_?void 0:B(r);return mv(G||r,function(j,J){G&&(J=j,j=r[J]),lo(c,J,Ml(j,e,t,J,r,a))}),c}var Fw=Ml;var XN=1,ZN=4;function eV(r){return Fw(r,XN|ZN)}var qr=eV;var tV="__lodash_hash_undefined__";function rV(r){return this.__data__.set(r,tV),this}var Uw=rV;function nV(r){return this.__data__.has(r)}var Bw=nV;function Fl(r){var e=-1,t=r==null?0:r.length;for(this.__data__=new ns;++e<t;)this.add(r[e])}Fl.prototype.add=Fl.prototype.push=Uw;Fl.prototype.has=Bw;var jw=Fl;function iV(r,e){for(var t=-1,n=r==null?0:r.length;++t<n;)if(e(r[t],t,r))return!0;return!1}var $w=iV;function sV(r,e){return r.has(e)}var qw=sV;var oV=1,aV=2;function uV(r,e,t,n,s,a){var c=t&oV,h=r.length,f=e.length;if(h!=f&&!(c&&f>h))return!1;var m=a.get(r),_=a.get(e);if(m&&_)return m==e&&_==r;var E=-1,I=!0,k=t&aV?new jw:void 0;for(a.set(r,e),a.set(e,r);++E<h;){var B=r[E],G=e[E];if(n)var j=c?n(G,B,E,e,r,a):n(B,G,E,r,e,a);if(j!==void 0){if(j)continue;I=!1;break}if(k){if(!$w(e,function(J,ee){if(!qw(k,ee)&&(B===J||s(B,J,t,n,a)))return k.push(ee)})){I=!1;break}}else if(!(B===G||s(B,G,t,n,a))){I=!1;break}}return a.delete(r),a.delete(e),I}var Ul=uV;function cV(r){var e=-1,t=Array(r.size);return r.forEach(function(n,s){t[++e]=[s,n]}),t}var zw=cV;function lV(r){var e=-1,t=Array(r.size);return r.forEach(function(n){t[++e]=n}),t}var Gw=lV;var hV=1,fV=2,dV="[object Boolean]",pV="[object Date]",mV="[object Error]",gV="[object Map]",_V="[object Number]",yV="[object RegExp]",vV="[object Set]",wV="[object String]",bV="[object Symbol]",TV="[object ArrayBuffer]",EV="[object DataView]",Kw=Nt?Nt.prototype:void 0,Md=Kw?Kw.valueOf:void 0;function IV(r,e,t,n,s,a,c){switch(t){case EV:if(r.byteLength!=e.byteLength||r.byteOffset!=e.byteOffset)return!1;r=r.buffer,e=e.buffer;case TV:return!(r.byteLength!=e.byteLength||!a(new Eo(r),new Eo(e)));case dV:case pV:case _V:return jr(+r,+e);case mV:return r.name==e.name&&r.message==e.message;case yV:case wV:return r==e+"";case gV:var h=zw;case vV:var f=n&hV;if(h||(h=Gw),r.size!=e.size&&!f)return!1;var m=c.get(r);if(m)return m==e;n|=fV,c.set(r,e);var _=Ul(h(r),h(e),n,s,a,c);return c.delete(r),_;case bV:if(Md)return Md.call(r)==Md.call(e)}return!1}var Ww=IV;var xV=1,AV=Object.prototype,SV=AV.hasOwnProperty;function RV(r,e,t,n,s,a){var c=t&xV,h=nu(r),f=h.length,m=nu(e),_=m.length;if(f!=_&&!c)return!1;for(var E=f;E--;){var I=h[E];if(!(c?I in e:SV.call(e,I)))return!1}var k=a.get(r),B=a.get(e);if(k&&B)return k==e&&B==r;var G=!0;a.set(r,e),a.set(e,r);for(var j=c;++E<f;){I=h[E];var J=r[I],ee=e[I];if(n)var re=c?n(ee,J,I,e,r,a):n(J,ee,I,r,e,a);if(!(re===void 0?J===ee||s(J,ee,t,n,a):re)){G=!1;break}j||(j=I=="constructor")}if(G&&!j){var le=r.constructor,de=e.constructor;le!=de&&"constructor"in r&&"constructor"in e&&!(typeof le=="function"&&le instanceof le&&typeof de=="function"&&de instanceof de)&&(G=!1)}return a.delete(r),a.delete(e),G}var Hw=RV;var PV=1,Qw="[object Arguments]",Jw="[object Array]",Bl="[object Object]",CV=Object.prototype,Yw=CV.hasOwnProperty;function DV(r,e,t,n,s,a){var c=rt(r),h=rt(e),f=c?Jw:Ar(r),m=h?Jw:Ar(e);f=f==Qw?Bl:f,m=m==Qw?Bl:m;var _=f==Bl,E=m==Bl,I=f==m;if(I&&wn(r)){if(!wn(e))return!1;c=!0,_=!1}if(I&&!_)return a||(a=new di),c||mo(r)?Ul(r,e,t,n,s,a):Ww(r,e,f,t,n,s,a);if(!(t&PV)){var k=_&&Yw.call(r,"__wrapped__"),B=E&&Yw.call(e,"__wrapped__");if(k||B){var G=k?r.value():r,j=B?e.value():e;return a||(a=new di),s(G,j,t,n,a)}}return I?(a||(a=new di),Hw(r,e,t,n,s,a)):!1}var Xw=DV;function Zw(r,e,t,n,s){return r===e?!0:r==null||e==null||!Vt(r)&&!Vt(e)?r!==r&&e!==e:Xw(r,e,t,n,Zw,s)}var xo=Zw;var OV=1,kV=2;function NV(r,e,t,n){var s=t.length,a=s,c=!n;if(r==null)return!a;for(r=Object(r);s--;){var h=t[s];if(c&&h[2]?h[1]!==r[h[0]]:!(h[0]in r))return!1}for(;++s<a;){h=t[s];var f=h[0],m=r[f],_=h[1];if(c&&h[2]){if(m===void 0&&!(f in r))return!1}else{var E=new di;if(n)var I=n(m,_,f,r,e,E);if(!(I===void 0?xo(_,m,OV|kV,n,E):I))return!1}}return!0}var e0=NV;function VV(r){return r===r&&!De(r)}var jl=VV;function LV(r){for(var e=At(r),t=e.length;t--;){var n=e[t],s=r[n];e[t]=[n,s,jl(s)]}return e}var t0=LV;function MV(r,e){return function(t){return t==null?!1:t[r]===e&&(e!==void 0||r in Object(t))}}var $l=MV;function FV(r){var e=t0(r);return e.length==1&&e[0][2]?$l(e[0][0],e[0][1]):function(t){return t===r||e0(t,r,e)}}var r0=FV;function UV(r,e){return r!=null&&e in Object(r)}var n0=UV;function BV(r,e,t){e=wo(e,r);for(var n=-1,s=e.length,a=!1;++n<s;){var c=$r(e[n]);if(!(a=r!=null&&t(r,c)))break;r=r[c]}return a||++n!=s?a:(s=r==null?0:r.length,!!s&&ho(s)&&ii(c,s)&&(rt(r)||fo(r)))}var i0=BV;function jV(r,e){return r!=null&&i0(r,e,n0)}var s0=jV;var $V=1,qV=2;function zV(r,e){return go(r)&&jl(e)?$l($r(r),e):function(t){var n=ru(t,r);return n===void 0&&n===e?s0(t,r):xo(e,n,$V|qV)}}var o0=zV;function GV(r){return function(e){return e==null?void 0:e[r]}}var a0=GV;function KV(r){return function(e){return Rl(e,r)}}var u0=KV;function WV(r){return go(r)?a0($r(r)):u0(r)}var c0=WV;function HV(r){return typeof r=="function"?r:r==null?ao:typeof r=="object"?rt(r)?o0(r[0],r[1]):r0(r):c0(r)}var l0=HV;function QV(r){return function(e,t,n){for(var s=-1,a=Object(e),c=n(e),h=c.length;h--;){var f=c[r?h:++s];if(t(a[f],f,a)===!1)break}return e}}var h0=QV;var JV=h0(),f0=JV;function YV(r,e){return r&&f0(r,e,At)}var d0=YV;var XV=function(){return Je.Date.now()},ql=XV;var ZV="Expected a function",eL=Math.max,tL=Math.min;function rL(r,e,t){var n,s,a,c,h,f,m=0,_=!1,E=!1,I=!0;if(typeof r!="function")throw new TypeError(ZV);e=Od(e)||0,De(t)&&(_=!!t.leading,E="maxWait"in t,a=E?eL(Od(t.maxWait)||0,e):a,I="trailing"in t?!!t.trailing:I);function k(ie){var C=n,A=s;return n=s=void 0,m=ie,c=r.apply(A,C),c}function B(ie){return m=ie,h=setTimeout(J,e),_?k(ie):c}function G(ie){var C=ie-f,A=ie-m,R=e-C;return E?tL(R,a-A):R}function j(ie){var C=ie-f,A=ie-m;return f===void 0||C>=e||C<0||E&&A>=a}function J(){var ie=ql();if(j(ie))return ee(ie);h=setTimeout(J,G(ie))}function ee(ie){return h=void 0,I&&n?k(ie):(n=s=void 0,c)}function re(){h!==void 0&&clearTimeout(h),m=0,n=f=s=h=void 0}function le(){return h===void 0?c:ee(ql())}function de(){var ie=ql(),C=j(ie);if(n=arguments,s=this,f=ie,C){if(h===void 0)return B(f);if(E)return clearTimeout(h),h=setTimeout(J,e),k(f)}return h===void 0&&(h=setTimeout(J,e)),c}return de.cancel=re,de.flush=le,de}var p0=rL;var m0=Object.prototype,nL=m0.hasOwnProperty,iL=yv(function(r,e){r=Object(r);var t=-1,n=e.length,s=n>2?e[2]:void 0;for(s&&vv(e[0],e[1],s)&&(n=1);++t<n;)for(var a=e[t],c=ui(a),h=-1,f=c.length;++h<f;){var m=c[h],_=r[m];(_===void 0||jr(_,m0[m])&&!nL.call(r,m))&&(r[m]=a[m])}return r}),zl=iL;var sL="[object Map]",oL="[object Set]",aL=Object.prototype,uL=aL.hasOwnProperty;function cL(r){if(r==null)return!0;if(oi(r)&&(rt(r)||typeof r=="string"||typeof r.splice=="function"||wn(r)||mo(r)||fo(r)))return!r.length;var e=Ar(r);if(e==sL||e==oL)return!r.size;if(ai(r))return!Sl(r).length;for(var t in r)if(uL.call(r,t))return!1;return!0}var Fd=cL;function lL(r,e){return xo(r,e)}var Ud=lL;function hL(r,e){var t={};return e=l0(e,3),d0(r,function(n,s,a){co(t,e(n,s,a),n)}),t}var Bd=hL;function fL(r,e,t,n){if(!De(r))return r;e=wo(e,r);for(var s=-1,a=e.length,c=a-1,h=r;h!=null&&++s<a;){var f=$r(e[s]),m=t;if(f==="__proto__"||f==="constructor"||f==="prototype")return r;if(s!=c){var _=h[f];m=n?n(_,f,h):void 0,m===void 0&&(m=De(_)?_:ii(e[s+1])?[]:{})}lo(h,f,m),h=h[f]}return r}var g0=fL;function dL(r,e,t){return r==null?r:g0(r,e,t)}var pi=dL;var pL="Expected a function";function mL(r,e,t){var n=!0,s=!0;if(typeof r!="function")throw new TypeError(pL);return De(t)&&(n="leading"in t?!!t.leading:n,s="trailing"in t?!!t.trailing:s),p0(r,e,{leading:n,maxWait:e,trailing:s})}var jd=mL;var y0=function(r){let e=[],t=0;for(let n=0;n<r.length;n++){let s=r.charCodeAt(n);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},gL=function(r){let e=[],t=0,n=0;for(;t<r.length;){let s=r[t++];if(s<128)e[n++]=String.fromCharCode(s);else if(s>191&&s<224){let a=r[t++];e[n++]=String.fromCharCode((s&31)<<6|a&63)}else if(s>239&&s<365){let a=r[t++],c=r[t++],h=r[t++],f=((s&7)<<18|(a&63)<<12|(c&63)<<6|h&63)-65536;e[n++]=String.fromCharCode(55296+(f>>10)),e[n++]=String.fromCharCode(56320+(f&1023))}else{let a=r[t++],c=r[t++];e[n++]=String.fromCharCode((s&15)<<12|(a&63)<<6|c&63)}}return e.join("")},v0={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(r,e){if(!Array.isArray(r))throw Error("encodeByteArray takes an array as a parameter");this.init_();let t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,n=[];for(let s=0;s<r.length;s+=3){let a=r[s],c=s+1<r.length,h=c?r[s+1]:0,f=s+2<r.length,m=f?r[s+2]:0,_=a>>2,E=(a&3)<<4|h>>4,I=(h&15)<<2|m>>6,k=m&63;f||(k=64,c||(I=64)),n.push(t[_],t[E],t[I],t[k])}return n.join("")},encodeString(r,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(r):this.encodeByteArray(y0(r),e)},decodeString(r,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(r):gL(this.decodeStringToByteArray(r,e))},decodeStringToByteArray(r,e){this.init_();let t=e?this.charToByteMapWebSafe_:this.charToByteMap_,n=[];for(let s=0;s<r.length;){let a=t[r.charAt(s++)],h=s<r.length?t[r.charAt(s)]:0;++s;let m=s<r.length?t[r.charAt(s)]:64;++s;let E=s<r.length?t[r.charAt(s)]:64;if(++s,a==null||h==null||m==null||E==null)throw new $d;let I=a<<2|h>>4;if(n.push(I),m!==64){let k=h<<4&240|m>>2;if(n.push(k),E!==64){let B=m<<6&192|E;n.push(B)}}}return n},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let r=0;r<this.ENCODED_VALS.length;r++)this.byteToCharMap_[r]=this.ENCODED_VALS.charAt(r),this.charToByteMap_[this.byteToCharMap_[r]]=r,this.byteToCharMapWebSafe_[r]=this.ENCODED_VALS_WEBSAFE.charAt(r),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[r]]=r,r>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(r)]=r,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(r)]=r)}}},$d=class extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}},_L=function(r){let e=y0(r);return v0.encodeByteArray(e,!0)},iu=function(r){return _L(r).replace(/\./g,"")},w0=function(r){try{return v0.decodeString(r,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function yL(){if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;throw new Error("Unable to locate global object.")}var vL=()=>yL().__FIREBASE_DEFAULTS__,wL=()=>{if(typeof process=="undefined"||typeof process.env=="undefined")return;let r=process.env.__FIREBASE_DEFAULTS__;if(r)return JSON.parse(r)},bL=()=>{if(typeof document=="undefined")return;let r;try{r=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}let e=r&&w0(r[1]);return e&&JSON.parse(e)},qd=()=>{try{return vL()||wL()||bL()}catch(r){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${r}`);return}},TL=r=>{var e,t;return(t=(e=qd())===null||e===void 0?void 0:e.emulatorHosts)===null||t===void 0?void 0:t[r]},b0=r=>{let e=TL(r);if(!e)return;let t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);let n=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),n]:[e.substring(0,t),n]},zd=()=>{var r;return(r=qd())===null||r===void 0?void 0:r.config};var Gl=class{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,n)=>{t?this.reject(t):this.resolve(n),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,n))}}};function T0(r,e){if(r.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');let t={alg:"none",type:"JWT"},n=e||"demo-project",s=r.iat||0,a=r.sub||r.user_id;if(!a)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");let c=Object.assign({iss:`https://securetoken.google.com/${n}`,aud:n,iat:s,exp:s+3600,auth_time:s,sub:a,user_id:a,firebase:{sign_in_provider:"custom",identities:{}}},r);return[iu(JSON.stringify(t)),iu(JSON.stringify(c)),""].join(".")}function E0(){return typeof navigator!="undefined"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function EL(){var r;let e=(r=qd())===null||r===void 0?void 0:r.forceEnvironment;if(e==="node")return!0;if(e==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function I0(){return!EL()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function Gd(){try{return typeof indexedDB=="object"}catch{return!1}}function x0(){return new Promise((r,e)=>{try{let t=!0,n="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(n);s.onsuccess=()=>{s.result.close(),t||self.indexedDB.deleteDatabase(n),r(!0)},s.onupgradeneeded=()=>{t=!1},s.onerror=()=>{var a;e(((a=s.error)===null||a===void 0?void 0:a.message)||"")}}catch(t){e(t)}})}var IL="FirebaseError",En=class r extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name=IL,Object.setPrototypeOf(this,r.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,su.prototype.create)}},su=class{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){let n=t[0]||{},s=`${this.service}/${e}`,a=this.errors[e],c=a?xL(a,n):"Error",h=`${this.serviceName}: ${c} (${s}).`;return new En(s,h,n)}};function xL(r,e){return r.replace(AL,(t,n)=>{let s=e[n];return s!=null?String(s):`<${n}?>`})}var AL=/\{\$([^}]+)}/g;function ou(r,e){if(r===e)return!0;let t=Object.keys(r),n=Object.keys(e);for(let s of t){if(!n.includes(s))return!1;let a=r[s],c=e[s];if(_0(a)&&_0(c)){if(!ou(a,c))return!1}else if(a!==c)return!1}for(let s of n)if(!t.includes(s))return!1;return!0}function _0(r){return r!==null&&typeof r=="object"}var MG=4*60*60*1e3;function In(r){return r&&r._delegate?r._delegate:r}var xn=class{constructor(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}};var ss="[DEFAULT]";var Kd=class{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){let t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){let n=new Gl;if(this.instancesDeferred.set(t,n),this.isInitialized(t)||this.shouldAutoInitialize())try{let s=this.getOrInitializeService({instanceIdentifier:t});s&&n.resolve(s)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;let n=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),s=(t=e==null?void 0:e.optional)!==null&&t!==void 0?t:!1;if(this.isInitialized(n)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:n})}catch(a){if(s)return null;throw a}else{if(s)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(RL(e))try{this.getOrInitializeService({instanceIdentifier:ss})}catch{}for(let[t,n]of this.instancesDeferred.entries()){let s=this.normalizeInstanceIdentifier(t);try{let a=this.getOrInitializeService({instanceIdentifier:s});n.resolve(a)}catch{}}}}clearInstance(e=ss){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){let e=Array.from(this.instances.values());await Promise.all([...e.filter(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...e.filter(t=>"_delete"in t).map(t=>t._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=ss){return this.instances.has(e)}getOptions(e=ss){return this.instancesOptions.get(e)||{}}initialize(e={}){let{options:t={}}=e,n=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);let s=this.getOrInitializeService({instanceIdentifier:n,options:t});for(let[a,c]of this.instancesDeferred.entries()){let h=this.normalizeInstanceIdentifier(a);n===h&&c.resolve(s)}return s}onInit(e,t){var n;let s=this.normalizeInstanceIdentifier(t),a=(n=this.onInitCallbacks.get(s))!==null&&n!==void 0?n:new Set;a.add(e),this.onInitCallbacks.set(s,a);let c=this.instances.get(s);return c&&e(c,s),()=>{a.delete(e)}}invokeOnInitCallbacks(e,t){let n=this.onInitCallbacks.get(t);if(n)for(let s of n)try{s(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let n=this.instances.get(e);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:SL(e),options:t}),this.instances.set(e,n),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(n,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,n)}catch{}return n||null}normalizeInstanceIdentifier(e=ss){return this.component?this.component.multipleInstances?e:ss:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}};function SL(r){return r===ss?void 0:r}function RL(r){return r.instantiationMode==="EAGER"}var Kl=class{constructor(e){this.name=e,this.providers=new Map}addComponent(e){let t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);let t=new Kd(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}};var PL=[],Se;(function(r){r[r.DEBUG=0]="DEBUG",r[r.VERBOSE=1]="VERBOSE",r[r.INFO=2]="INFO",r[r.WARN=3]="WARN",r[r.ERROR=4]="ERROR",r[r.SILENT=5]="SILENT"})(Se||(Se={}));var CL={debug:Se.DEBUG,verbose:Se.VERBOSE,info:Se.INFO,warn:Se.WARN,error:Se.ERROR,silent:Se.SILENT},DL=Se.INFO,OL={[Se.DEBUG]:"log",[Se.VERBOSE]:"log",[Se.INFO]:"info",[Se.WARN]:"warn",[Se.ERROR]:"error"},kL=(r,e,...t)=>{if(e<r.logLevel)return;let n=new Date().toISOString(),s=OL[e];if(s)console[s](`[${n}] ${r.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)},Ao=class{constructor(e){this.name=e,this._logLevel=DL,this._logHandler=kL,this._userLogHandler=null,PL.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in Se))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?CL[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,Se.DEBUG,...e),this._logHandler(this,Se.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,Se.VERBOSE,...e),this._logHandler(this,Se.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,Se.INFO,...e),this._logHandler(this,Se.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,Se.WARN,...e),this._logHandler(this,Se.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,Se.ERROR,...e),this._logHandler(this,Se.ERROR,...e)}};var NL=(r,e)=>e.some(t=>r instanceof t),A0,S0;function VL(){return A0||(A0=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function LL(){return S0||(S0=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var R0=new WeakMap,Hd=new WeakMap,P0=new WeakMap,Wd=new WeakMap,Jd=new WeakMap;function ML(r){let e=new Promise((t,n)=>{let s=()=>{r.removeEventListener("success",a),r.removeEventListener("error",c)},a=()=>{t(zr(r.result)),s()},c=()=>{n(r.error),s()};r.addEventListener("success",a),r.addEventListener("error",c)});return e.then(t=>{t instanceof IDBCursor&&R0.set(t,r)}).catch(()=>{}),Jd.set(e,r),e}function FL(r){if(Hd.has(r))return;let e=new Promise((t,n)=>{let s=()=>{r.removeEventListener("complete",a),r.removeEventListener("error",c),r.removeEventListener("abort",c)},a=()=>{t(),s()},c=()=>{n(r.error||new DOMException("AbortError","AbortError")),s()};r.addEventListener("complete",a),r.addEventListener("error",c),r.addEventListener("abort",c)});Hd.set(r,e)}var Qd={get(r,e,t){if(r instanceof IDBTransaction){if(e==="done")return Hd.get(r);if(e==="objectStoreNames")return r.objectStoreNames||P0.get(r);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return zr(r[e])},set(r,e,t){return r[e]=t,!0},has(r,e){return r instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in r}};function C0(r){Qd=r(Qd)}function UL(r){return r===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){let n=r.call(Wl(this),e,...t);return P0.set(n,e.sort?e.sort():[e]),zr(n)}:LL().includes(r)?function(...e){return r.apply(Wl(this),e),zr(R0.get(this))}:function(...e){return zr(r.apply(Wl(this),e))}}function BL(r){return typeof r=="function"?UL(r):(r instanceof IDBTransaction&&FL(r),NL(r,VL())?new Proxy(r,Qd):r)}function zr(r){if(r instanceof IDBRequest)return ML(r);if(Wd.has(r))return Wd.get(r);let e=BL(r);return e!==r&&(Wd.set(r,e),Jd.set(e,r)),e}var Wl=r=>Jd.get(r);function O0(r,e,{blocked:t,upgrade:n,blocking:s,terminated:a}={}){let c=indexedDB.open(r,e),h=zr(c);return n&&c.addEventListener("upgradeneeded",f=>{n(zr(c.result),f.oldVersion,f.newVersion,zr(c.transaction),f)}),t&&c.addEventListener("blocked",f=>t(f.oldVersion,f.newVersion,f)),h.then(f=>{a&&f.addEventListener("close",()=>a()),s&&f.addEventListener("versionchange",m=>s(m.oldVersion,m.newVersion,m))}).catch(()=>{}),h}var jL=["get","getKey","getAll","getAllKeys","count"],$L=["put","add","delete","clear"],Yd=new Map;function D0(r,e){if(!(r instanceof IDBDatabase&&!(e in r)&&typeof e=="string"))return;if(Yd.get(e))return Yd.get(e);let t=e.replace(/FromIndex$/,""),n=e!==t,s=$L.includes(t);if(!(t in(n?IDBIndex:IDBObjectStore).prototype)||!(s||jL.includes(t)))return;let a=async function(c,...h){let f=this.transaction(c,s?"readwrite":"readonly"),m=f.store;return n&&(m=m.index(h.shift())),(await Promise.all([m[t](...h),s&&f.done]))[0]};return Yd.set(e,a),a}C0(r=>({...r,get:(e,t,n)=>D0(e,t)||r.get(e,t,n),has:(e,t)=>!!D0(e,t)||r.has(e,t)}));var Zd=class{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(qL(t)){let n=t.getImmediate();return`${n.library}/${n.version}`}else return null}).filter(t=>t).join(" ")}};function qL(r){let e=r.getComponent();return(e==null?void 0:e.type)==="VERSION"}var ep="@firebase/app",k0="0.11.1";var An=new Ao("@firebase/app"),zL="@firebase/app-compat",GL="@firebase/analytics-compat",KL="@firebase/analytics",WL="@firebase/app-check-compat",HL="@firebase/app-check",QL="@firebase/auth",JL="@firebase/auth-compat",YL="@firebase/database",XL="@firebase/data-connect",ZL="@firebase/database-compat",e2="@firebase/functions",t2="@firebase/functions-compat",r2="@firebase/installations",n2="@firebase/installations-compat",i2="@firebase/messaging",s2="@firebase/messaging-compat",o2="@firebase/performance",a2="@firebase/performance-compat",u2="@firebase/remote-config",c2="@firebase/remote-config-compat",l2="@firebase/storage",h2="@firebase/storage-compat",f2="@firebase/firestore",d2="@firebase/vertexai",p2="@firebase/firestore-compat",m2="firebase",g2="11.3.1";var tp="[DEFAULT]",_2={[ep]:"fire-core",[zL]:"fire-core-compat",[KL]:"fire-analytics",[GL]:"fire-analytics-compat",[HL]:"fire-app-check",[WL]:"fire-app-check-compat",[QL]:"fire-auth",[JL]:"fire-auth-compat",[YL]:"fire-rtdb",[XL]:"fire-data-connect",[ZL]:"fire-rtdb-compat",[e2]:"fire-fn",[t2]:"fire-fn-compat",[r2]:"fire-iid",[n2]:"fire-iid-compat",[i2]:"fire-fcm",[s2]:"fire-fcm-compat",[o2]:"fire-perf",[a2]:"fire-perf-compat",[u2]:"fire-rc",[c2]:"fire-rc-compat",[l2]:"fire-gcs",[h2]:"fire-gcs-compat",[f2]:"fire-fst",[p2]:"fire-fst-compat",[d2]:"fire-vertex","fire-js":"fire-js",[m2]:"fire-js-all"};var Hl=new Map,y2=new Map,rp=new Map;function N0(r,e){try{r.container.addComponent(e)}catch(t){An.debug(`Component ${e.name} failed to register with FirebaseApp ${r.name}`,t)}}function au(r){let e=r.name;if(rp.has(e))return An.debug(`There were multiple attempts to register component ${e}.`),!1;rp.set(e,r);for(let t of Hl.values())N0(t,r);for(let t of y2.values())N0(t,r);return!0}function F0(r,e){let t=r.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),r.container.getProvider(e)}function U0(r){return r==null?!1:r.settings!==void 0}var v2={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},mi=new su("app","Firebase",v2);var np=class{constructor(e,t,n){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new xn("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw mi.create("app-deleted",{appName:this._name})}};var B0=g2;function op(r,e={}){let t=r;typeof e!="object"&&(e={name:e});let n=Object.assign({name:tp,automaticDataCollectionEnabled:!1},e),s=n.name;if(typeof s!="string"||!s)throw mi.create("bad-app-name",{appName:String(s)});if(t||(t=zd()),!t)throw mi.create("no-options");let a=Hl.get(s);if(a){if(ou(t,a.options)&&ou(n,a.config))return a;throw mi.create("duplicate-app",{appName:s})}let c=new Kl(s);for(let f of rp.values())c.addComponent(f);let h=new np(t,n,c);return Hl.set(s,h),h}function j0(r=tp){let e=Hl.get(r);if(!e&&r===tp&&zd())return op();if(!e)throw mi.create("no-app",{appName:r});return e}function gi(r,e,t){var n;let s=(n=_2[r])!==null&&n!==void 0?n:r;t&&(s+=`-${t}`);let a=s.match(/\s|\//),c=e.match(/\s|\//);if(a||c){let h=[`Unable to register library "${s}" with version "${e}":`];a&&h.push(`library name "${s}" contains illegal characters (whitespace or "/")`),a&&c&&h.push("and"),c&&h.push(`version name "${e}" contains illegal characters (whitespace or "/")`),An.warn(h.join(" "));return}au(new xn(`${s}-version`,()=>({library:s,version:e}),"VERSION"))}var w2="firebase-heartbeat-database",b2=1,uu="firebase-heartbeat-store",Xd=null;function $0(){return Xd||(Xd=O0(w2,b2,{upgrade:(r,e)=>{switch(e){case 0:try{r.createObjectStore(uu)}catch(t){console.warn(t)}}}}).catch(r=>{throw mi.create("idb-open",{originalErrorMessage:r.message})})),Xd}async function T2(r){try{let t=(await $0()).transaction(uu),n=await t.objectStore(uu).get(q0(r));return await t.done,n}catch(e){if(e instanceof En)An.warn(e.message);else{let t=mi.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});An.warn(t.message)}}}async function V0(r,e){try{let n=(await $0()).transaction(uu,"readwrite");await n.objectStore(uu).put(e,q0(r)),await n.done}catch(t){if(t instanceof En)An.warn(t.message);else{let n=mi.create("idb-set",{originalErrorMessage:t==null?void 0:t.message});An.warn(n.message)}}}function q0(r){return`${r.name}!${r.options.appId}`}var E2=1024,I2=30,ip=class{constructor(e){this.container=e,this._heartbeatsCache=null;let t=this.container.getProvider("app").getImmediate();this._storage=new sp(t),this._heartbeatsCachePromise=this._storage.read().then(n=>(this._heartbeatsCache=n,n))}async triggerHeartbeat(){var e,t;try{let s=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),a=L0();if(((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((t=this._heartbeatsCache)===null||t===void 0?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===a||this._heartbeatsCache.heartbeats.some(c=>c.date===a))return;if(this._heartbeatsCache.heartbeats.push({date:a,agent:s}),this._heartbeatsCache.heartbeats.length>I2){let c=A2(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(c,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(n){An.warn(n)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";let t=L0(),{heartbeatsToSend:n,unsentEntries:s}=x2(this._heartbeatsCache.heartbeats),a=iu(JSON.stringify({version:2,heartbeats:n}));return this._heartbeatsCache.lastSentHeartbeatDate=t,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),a}catch(t){return An.warn(t),""}}};function L0(){return new Date().toISOString().substring(0,10)}function x2(r,e=E2){let t=[],n=r.slice();for(let s of r){let a=t.find(c=>c.agent===s.agent);if(a){if(a.dates.push(s.date),M0(t)>e){a.dates.pop();break}}else if(t.push({agent:s.agent,dates:[s.date]}),M0(t)>e){t.pop();break}n=n.slice(1)}return{heartbeatsToSend:t,unsentEntries:n}}var sp=class{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return Gd()?x0().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){let t=await T2(this.app);return t!=null&&t.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){let s=await this.read();return V0(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:s.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){var t;if(await this._canUseIndexedDBPromise){let s=await this.read();return V0(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:s.lastSentHeartbeatDate,heartbeats:[...s.heartbeats,...e.heartbeats]})}else return}};function M0(r){return iu(JSON.stringify({version:2,heartbeats:r})).length}function A2(r){if(r.length===0)return-1;let e=0,t=r[0].date;for(let n=1;n<r.length;n++)r[n].date<t&&(t=r[n].date,e=n);return e}function S2(r){au(new xn("platform-logger",e=>new Zd(e),"PRIVATE")),au(new xn("heartbeat",e=>new ip(e),"PRIVATE")),gi(ep,k0,r),gi(ep,k0,"esm2017"),gi("fire-js","")}S2("");var R2="firebase",P2="11.3.1";gi(R2,P2,"app");var z0=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},G0={};var Sn,ap;(function(){var r;function e(C,A){function R(){}R.prototype=A.prototype,C.D=A.prototype,C.prototype=new R,C.prototype.constructor=C,C.C=function(D,V,M){for(var S=Array(arguments.length-2),dr=2;dr<arguments.length;dr++)S[dr-2]=arguments[dr];return A.prototype[V].apply(D,S)}}function t(){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()}e(n,t),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 s(C,A,R){R||(R=0);var D=Array(16);if(typeof A=="string")for(var V=0;16>V;++V)D[V]=A.charCodeAt(R++)|A.charCodeAt(R++)<<8|A.charCodeAt(R++)<<16|A.charCodeAt(R++)<<24;else for(V=0;16>V;++V)D[V]=A[R++]|A[R++]<<8|A[R++]<<16|A[R++]<<24;A=C.g[0],R=C.g[1],V=C.g[2];var M=C.g[3],S=A+(M^R&(V^M))+D[0]+3614090360&4294967295;A=R+(S<<7&4294967295|S>>>25),S=M+(V^A&(R^V))+D[1]+3905402710&4294967295,M=A+(S<<12&4294967295|S>>>20),S=V+(R^M&(A^R))+D[2]+606105819&4294967295,V=M+(S<<17&4294967295|S>>>15),S=R+(A^V&(M^A))+D[3]+3250441966&4294967295,R=V+(S<<22&4294967295|S>>>10),S=A+(M^R&(V^M))+D[4]+4118548399&4294967295,A=R+(S<<7&4294967295|S>>>25),S=M+(V^A&(R^V))+D[5]+1200080426&4294967295,M=A+(S<<12&4294967295|S>>>20),S=V+(R^M&(A^R))+D[6]+2821735955&4294967295,V=M+(S<<17&4294967295|S>>>15),S=R+(A^V&(M^A))+D[7]+4249261313&4294967295,R=V+(S<<22&4294967295|S>>>10),S=A+(M^R&(V^M))+D[8]+1770035416&4294967295,A=R+(S<<7&4294967295|S>>>25),S=M+(V^A&(R^V))+D[9]+2336552879&4294967295,M=A+(S<<12&4294967295|S>>>20),S=V+(R^M&(A^R))+D[10]+4294925233&4294967295,V=M+(S<<17&4294967295|S>>>15),S=R+(A^V&(M^A))+D[11]+2304563134&4294967295,R=V+(S<<22&4294967295|S>>>10),S=A+(M^R&(V^M))+D[12]+1804603682&4294967295,A=R+(S<<7&4294967295|S>>>25),S=M+(V^A&(R^V))+D[13]+4254626195&4294967295,M=A+(S<<12&4294967295|S>>>20),S=V+(R^M&(A^R))+D[14]+2792965006&4294967295,V=M+(S<<17&4294967295|S>>>15),S=R+(A^V&(M^A))+D[15]+1236535329&4294967295,R=V+(S<<22&4294967295|S>>>10),S=A+(V^M&(R^V))+D[1]+4129170786&4294967295,A=R+(S<<5&4294967295|S>>>27),S=M+(R^V&(A^R))+D[6]+3225465664&4294967295,M=A+(S<<9&4294967295|S>>>23),S=V+(A^R&(M^A))+D[11]+643717713&4294967295,V=M+(S<<14&4294967295|S>>>18),S=R+(M^A&(V^M))+D[0]+3921069994&4294967295,R=V+(S<<20&4294967295|S>>>12),S=A+(V^M&(R^V))+D[5]+3593408605&4294967295,A=R+(S<<5&4294967295|S>>>27),S=M+(R^V&(A^R))+D[10]+38016083&4294967295,M=A+(S<<9&4294967295|S>>>23),S=V+(A^R&(M^A))+D[15]+3634488961&4294967295,V=M+(S<<14&4294967295|S>>>18),S=R+(M^A&(V^M))+D[4]+3889429448&4294967295,R=V+(S<<20&4294967295|S>>>12),S=A+(V^M&(R^V))+D[9]+568446438&4294967295,A=R+(S<<5&4294967295|S>>>27),S=M+(R^V&(A^R))+D[14]+3275163606&4294967295,M=A+(S<<9&4294967295|S>>>23),S=V+(A^R&(M^A))+D[3]+4107603335&4294967295,V=M+(S<<14&4294967295|S>>>18),S=R+(M^A&(V^M))+D[8]+1163531501&4294967295,R=V+(S<<20&4294967295|S>>>12),S=A+(V^M&(R^V))+D[13]+2850285829&4294967295,A=R+(S<<5&4294967295|S>>>27),S=M+(R^V&(A^R))+D[2]+4243563512&4294967295,M=A+(S<<9&4294967295|S>>>23),S=V+(A^R&(M^A))+D[7]+1735328473&4294967295,V=M+(S<<14&4294967295|S>>>18),S=R+(M^A&(V^M))+D[12]+2368359562&4294967295,R=V+(S<<20&4294967295|S>>>12),S=A+(R^V^M)+D[5]+4294588738&4294967295,A=R+(S<<4&4294967295|S>>>28),S=M+(A^R^V)+D[8]+2272392833&4294967295,M=A+(S<<11&4294967295|S>>>21),S=V+(M^A^R)+D[11]+1839030562&4294967295,V=M+(S<<16&4294967295|S>>>16),S=R+(V^M^A)+D[14]+4259657740&4294967295,R=V+(S<<23&4294967295|S>>>9),S=A+(R^V^M)+D[1]+2763975236&4294967295,A=R+(S<<4&4294967295|S>>>28),S=M+(A^R^V)+D[4]+1272893353&4294967295,M=A+(S<<11&4294967295|S>>>21),S=V+(M^A^R)+D[7]+4139469664&4294967295,V=M+(S<<16&4294967295|S>>>16),S=R+(V^M^A)+D[10]+3200236656&4294967295,R=V+(S<<23&4294967295|S>>>9),S=A+(R^V^M)+D[13]+681279174&4294967295,A=R+(S<<4&4294967295|S>>>28),S=M+(A^R^V)+D[0]+3936430074&4294967295,M=A+(S<<11&4294967295|S>>>21),S=V+(M^A^R)+D[3]+3572445317&4294967295,V=M+(S<<16&4294967295|S>>>16),S=R+(V^M^A)+D[6]+76029189&4294967295,R=V+(S<<23&4294967295|S>>>9),S=A+(R^V^M)+D[9]+3654602809&4294967295,A=R+(S<<4&4294967295|S>>>28),S=M+(A^R^V)+D[12]+3873151461&4294967295,M=A+(S<<11&4294967295|S>>>21),S=V+(M^A^R)+D[15]+530742520&4294967295,V=M+(S<<16&4294967295|S>>>16),S=R+(V^M^A)+D[2]+3299628645&4294967295,R=V+(S<<23&4294967295|S>>>9),S=A+(V^(R|~M))+D[0]+4096336452&4294967295,A=R+(S<<6&4294967295|S>>>26),S=M+(R^(A|~V))+D[7]+1126891415&4294967295,M=A+(S<<10&4294967295|S>>>22),S=V+(A^(M|~R))+D[14]+2878612391&4294967295,V=M+(S<<15&4294967295|S>>>17),S=R+(M^(V|~A))+D[5]+4237533241&4294967295,R=V+(S<<21&4294967295|S>>>11),S=A+(V^(R|~M))+D[12]+1700485571&4294967295,A=R+(S<<6&4294967295|S>>>26),S=M+(R^(A|~V))+D[3]+2399980690&4294967295,M=A+(S<<10&4294967295|S>>>22),S=V+(A^(M|~R))+D[10]+4293915773&4294967295,V=M+(S<<15&4294967295|S>>>17),S=R+(M^(V|~A))+D[1]+2240044497&4294967295,R=V+(S<<21&4294967295|S>>>11),S=A+(V^(R|~M))+D[8]+1873313359&4294967295,A=R+(S<<6&4294967295|S>>>26),S=M+(R^(A|~V))+D[15]+4264355552&4294967295,M=A+(S<<10&4294967295|S>>>22),S=V+(A^(M|~R))+D[6]+2734768916&4294967295,V=M+(S<<15&4294967295|S>>>17),S=R+(M^(V|~A))+D[13]+1309151649&4294967295,R=V+(S<<21&4294967295|S>>>11),S=A+(V^(R|~M))+D[4]+4149444226&4294967295,A=R+(S<<6&4294967295|S>>>26),S=M+(R^(A|~V))+D[11]+3174756917&4294967295,M=A+(S<<10&4294967295|S>>>22),S=V+(A^(M|~R))+D[2]+718787259&4294967295,V=M+(S<<15&4294967295|S>>>17),S=R+(M^(V|~A))+D[9]+3951481745&4294967295,C.g[0]=C.g[0]+A&4294967295,C.g[1]=C.g[1]+(V+(S<<21&4294967295|S>>>11))&4294967295,C.g[2]=C.g[2]+V&4294967295,C.g[3]=C.g[3]+M&4294967295}n.prototype.u=function(C,A){A===void 0&&(A=C.length);for(var R=A-this.blockSize,D=this.B,V=this.h,M=0;M<A;){if(V==0)for(;M<=R;)s(this,C,M),M+=this.blockSize;if(typeof C=="string"){for(;M<A;)if(D[V++]=C.charCodeAt(M++),V==this.blockSize){s(this,D),V=0;break}}else for(;M<A;)if(D[V++]=C[M++],V==this.blockSize){s(this,D),V=0;break}}this.h=V,this.o+=A},n.prototype.v=function(){var C=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);C[0]=128;for(var A=1;A<C.length-8;++A)C[A]=0;var R=8*this.o;for(A=C.length-8;A<C.length;++A)C[A]=R&255,R/=256;for(this.u(C),C=Array(16),A=R=0;4>A;++A)for(var D=0;32>D;D+=8)C[R++]=this.g[A]>>>D&255;return C};function a(C,A){var R=h;return Object.prototype.hasOwnProperty.call(R,C)?R[C]:R[C]=A(C)}function c(C,A){this.h=A;for(var R=[],D=!0,V=C.length-1;0<=V;V--){var M=C[V]|0;D&&M==A||(R[V]=M,D=!1)}this.g=R}var h={};function f(C){return-128<=C&&128>C?a(C,function(A){return new c([A|0],0>A?-1:0)}):new c([C|0],0>C?-1:0)}function m(C){if(isNaN(C)||!isFinite(C))return E;if(0>C)return j(m(-C));for(var A=[],R=1,D=0;C>=R;D++)A[D]=C/R|0,R*=4294967296;return new c(A,0)}function _(C,A){if(C.length==0)throw Error("number format error: empty string");if(A=A||10,2>A||36<A)throw Error("radix out of range: "+A);if(C.charAt(0)=="-")return j(_(C.substring(1),A));if(0<=C.indexOf("-"))throw Error('number format error: interior "-" character');for(var R=m(Math.pow(A,8)),D=E,V=0;V<C.length;V+=8){var M=Math.min(8,C.length-V),S=parseInt(C.substring(V,V+M),A);8>M?(M=m(Math.pow(A,M)),D=D.j(M).add(m(S))):(D=D.j(R),D=D.add(m(S)))}return D}var E=f(0),I=f(1),k=f(16777216);r=c.prototype,r.m=function(){if(G(this))return-j(this).m();for(var C=0,A=1,R=0;R<this.g.length;R++){var D=this.i(R);C+=(0<=D?D:4294967296+D)*A,A*=4294967296}return C},r.toString=function(C){if(C=C||10,2>C||36<C)throw Error("radix out of range: "+C);if(B(this))return"0";if(G(this))return"-"+j(this).toString(C);for(var A=m(Math.pow(C,6)),R=this,D="";;){var V=le(R,A).g;R=J(R,V.j(A));var M=((0<R.g.length?R.g[0]:R.h)>>>0).toString(C);if(R=V,B(R))return M+D;for(;6>M.length;)M="0"+M;D=M+D}},r.i=function(C){return 0>C?0:C<this.g.length?this.g[C]:this.h};function B(C){if(C.h!=0)return!1;for(var A=0;A<C.g.length;A++)if(C.g[A]!=0)return!1;return!0}function G(C){return C.h==-1}r.l=function(C){return C=J(this,C),G(C)?-1:B(C)?0:1};function j(C){for(var A=C.g.length,R=[],D=0;D<A;D++)R[D]=~C.g[D];return new c(R,~C.h).add(I)}r.abs=function(){return G(this)?j(this):this},r.add=function(C){for(var A=Math.max(this.g.length,C.g.length),R=[],D=0,V=0;V<=A;V++){var M=D+(this.i(V)&65535)+(C.i(V)&65535),S=(M>>>16)+(this.i(V)>>>16)+(C.i(V)>>>16);D=S>>>16,M&=65535,S&=65535,R[V]=S<<16|M}return new c(R,R[R.length-1]&-2147483648?-1:0)};function J(C,A){return C.add(j(A))}r.j=function(C){if(B(this)||B(C))return E;if(G(this))return G(C)?j(this).j(j(C)):j(j(this).j(C));if(G(C))return j(this.j(j(C)));if(0>this.l(k)&&0>C.l(k))return m(this.m()*C.m());for(var A=this.g.length+C.g.length,R=[],D=0;D<2*A;D++)R[D]=0;for(D=0;D<this.g.length;D++)for(var V=0;V<C.g.length;V++){var M=this.i(D)>>>16,S=this.i(D)&65535,dr=C.i(V)>>>16,Wt=C.i(V)&65535;R[2*D+2*V]+=S*Wt,ee(R,2*D+2*V),R[2*D+2*V+1]+=M*Wt,ee(R,2*D+2*V+1),R[2*D+2*V+1]+=S*dr,ee(R,2*D+2*V+1),R[2*D+2*V+2]+=M*dr,ee(R,2*D+2*V+2)}for(D=0;D<A;D++)R[D]=R[2*D+1]<<16|R[2*D];for(D=A;D<2*A;D++)R[D]=0;return new c(R,0)};function ee(C,A){for(;(C[A]&65535)!=C[A];)C[A+1]+=C[A]>>>16,C[A]&=65535,A++}function re(C,A){this.g=C,this.h=A}function le(C,A){if(B(A))throw Error("division by zero");if(B(C))return new re(E,E);if(G(C))return A=le(j(C),A),new re(j(A.g),j(A.h));if(G(A))return A=le(C,j(A)),new re(j(A.g),A.h);if(30<C.g.length){if(G(C)||G(A))throw Error("slowDivide_ only works with positive integers.");for(var R=I,D=A;0>=D.l(C);)R=de(R),D=de(D);var V=ie(R,1),M=ie(D,1);for(D=ie(D,2),R=ie(R,2);!B(D);){var S=M.add(D);0>=S.l(C)&&(V=V.add(R),M=S),D=ie(D,1),R=ie(R,1)}return A=J(C,V.j(A)),new re(V,A)}for(V=E;0<=C.l(A);){for(R=Math.max(1,Math.floor(C.m()/A.m())),D=Math.ceil(Math.log(R)/Math.LN2),D=48>=D?1:Math.pow(2,D-48),M=m(R),S=M.j(A);G(S)||0<S.l(C);)R-=D,M=m(R),S=M.j(A);B(M)&&(M=I),V=V.add(M),C=J(C,S)}return new re(V,C)}r.A=function(C){return le(this,C).h},r.and=function(C){for(var A=Math.max(this.g.length,C.g.length),R=[],D=0;D<A;D++)R[D]=this.i(D)&C.i(D);return new c(R,this.h&C.h)},r.or=function(C){for(var A=Math.max(this.g.length,C.g.length),R=[],D=0;D<A;D++)R[D]=this.i(D)|C.i(D);return new c(R,this.h|C.h)},r.xor=function(C){for(var A=Math.max(this.g.length,C.g.length),R=[],D=0;D<A;D++)R[D]=this.i(D)^C.i(D);return new c(R,this.h^C.h)};function de(C){for(var A=C.g.length+1,R=[],D=0;D<A;D++)R[D]=C.i(D)<<1|C.i(D-1)>>>31;return new c(R,C.h)}function ie(C,A){var R=A>>5;A%=32;for(var D=C.g.length-R,V=[],M=0;M<D;M++)V[M]=0<A?C.i(M+R)>>>A|C.i(M+R+1)<<32-A:C.i(M+R);return new c(V,C.h)}n.prototype.digest=n.prototype.v,n.prototype.reset=n.prototype.s,n.prototype.update=n.prototype.u,ap=G0.Md5=n,c.prototype.add=c.prototype.add,c.prototype.multiply=c.prototype.j,c.prototype.modulo=c.prototype.A,c.prototype.compare=c.prototype.l,c.prototype.toNumber=c.prototype.m,c.prototype.toString=c.prototype.toString,c.prototype.getBits=c.prototype.i,c.fromNumber=m,c.fromString=_,Sn=G0.Integer=c}).apply(typeof z0!="undefined"?z0:typeof self!="undefined"?self:typeof window!="undefined"?window:{});var Ql=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},Rn={};var up,C2,So,cp,cu,Jl,lp,hp,fp;(function(){var r,e=typeof Object.defineProperties=="function"?Object.defineProperty:function(u,d,g){return u==Array.prototype||u==Object.prototype||(u[d]=g.value),u};function t(u){u=[typeof globalThis=="object"&&globalThis,u,typeof window=="object"&&window,typeof self=="object"&&self,typeof Ql=="object"&&Ql];for(var d=0;d<u.length;++d){var g=u[d];if(g&&g.Math==Math)return g}throw Error("Cannot find global object")}var n=t(this);function s(u,d){if(d)e:{var g=n;u=u.split(".");for(var b=0;b<u.length-1;b++){var L=u[b];if(!(L in g))break e;g=g[L]}u=u[u.length-1],b=g[u],d=d(b),d!=b&&d!=null&&e(g,u,{configurable:!0,writable:!0,value:d})}}function a(u,d){u instanceof String&&(u+="");var g=0,b=!1,L={next:function(){if(!b&&g<u.length){var F=g++;return{value:d(F,u[F]),done:!1}}return b=!0,{done:!0,value:void 0}}};return L[Symbol.iterator]=function(){return L},L}s("Array.prototype.values",function(u){return u||function(){return a(this,function(d,g){return g})}});var c=c||{},h=this||self;function f(u){var d=typeof u;return d=d!="object"?d:u?Array.isArray(u)?"array":d:"null",d=="array"||d=="object"&&typeof u.length=="number"}function m(u){var d=typeof u;return d=="object"&&u!=null||d=="function"}function _(u,d,g){return u.call.apply(u.bind,arguments)}function E(u,d,g){if(!u)throw Error();if(2<arguments.length){var b=Array.prototype.slice.call(arguments,2);return function(){var L=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(L,b),u.apply(d,L)}}return function(){return u.apply(d,arguments)}}function I(u,d,g){return I=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?_:E,I.apply(null,arguments)}function k(u,d){var g=Array.prototype.slice.call(arguments,1);return function(){var b=g.slice();return b.push.apply(b,arguments),u.apply(this,b)}}function B(u,d){function g(){}g.prototype=d.prototype,u.aa=d.prototype,u.prototype=new g,u.prototype.constructor=u,u.Qb=function(b,L,F){for(var Q=Array(arguments.length-2),_e=2;_e<arguments.length;_e++)Q[_e-2]=arguments[_e];return d.prototype[L].apply(b,Q)}}function G(u){let d=u.length;if(0<d){let g=Array(d);for(let b=0;b<d;b++)g[b]=u[b];return g}return[]}function j(u,d){for(let g=1;g<arguments.length;g++){let b=arguments[g];if(f(b)){let L=u.length||0,F=b.length||0;u.length=L+F;for(let Q=0;Q<F;Q++)u[L+Q]=b[Q]}else u.push(b)}}class J{constructor(d,g){this.i=d,this.j=g,this.h=0,this.g=null}get(){let d;return 0<this.h?(this.h--,d=this.g,this.g=d.next,d.next=null):d=this.i(),d}}function ee(u){return/^[\s\xa0]*$/.test(u)}function re(){var u=h.navigator;return u&&(u=u.userAgent)?u:""}function le(u){return le[" "](u),u}le[" "]=function(){};var de=re().indexOf("Gecko")!=-1&&!(re().toLowerCase().indexOf("webkit")!=-1&&re().indexOf("Edge")==-1)&&!(re().indexOf("Trident")!=-1||re().indexOf("MSIE")!=-1)&&re().indexOf("Edge")==-1;function ie(u,d,g){for(let b in u)d.call(g,u[b],b,u)}function C(u,d){for(let g in u)d.call(void 0,u[g],g,u)}function A(u){let d={};for(let g in u)d[g]=u[g];return d}let R="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function D(u,d){let g,b;for(let L=1;L<arguments.length;L++){b=arguments[L];for(g in b)u[g]=b[g];for(let F=0;F<R.length;F++)g=R[F],Object.prototype.hasOwnProperty.call(b,g)&&(u[g]=b[g])}}function V(u){var d=1;u=u.split(":");let g=[];for(;0<d&&u.length;)g.push(u.shift()),d--;return u.length&&g.push(u.join(":")),g}function M(u){h.setTimeout(()=>{throw u},0)}function S(){var u=Lt;let d=null;return u.g&&(d=u.g,u.g=u.g.next,u.g||(u.h=null),d.next=null),d}class dr{constructor(){this.h=this.g=null}add(d,g){let b=Wt.get();b.set(d,g),this.h?this.h.next=b:this.g=b,this.h=b}}var Wt=new J(()=>new Pr,u=>u.reset());class Pr{constructor(){this.next=this.g=this.h=null}set(d,g){this.h=d,this.g=g,this.next=null}reset(){this.next=this.g=this.h=null}}let Ai,Cr=!1,Lt=new dr,ac=()=>{let u=h.Promise.resolve(void 0);Ai=()=>{u.then(vf)}};var vf=()=>{for(var u;u=S();){try{u.h.call(u.g)}catch(g){M(g)}var d=Wt;d.j(u),100>d.h&&(d.h++,u.next=d.g,d.g=u)}Cr=!1};function Dr(){this.s=this.s,this.C=this.C}Dr.prototype.s=!1,Dr.prototype.ma=function(){this.s||(this.s=!0,this.N())},Dr.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function Ke(u,d){this.type=u,this.g=this.target=d,this.defaultPrevented=!1}Ke.prototype.h=function(){this.defaultPrevented=!0};var Cs=function(){if(!h.addEventListener||!Object.defineProperty)return!1;var u=!1,d=Object.defineProperty({},"passive",{get:function(){u=!0}});try{let g=()=>{};h.addEventListener("test",g,d),h.removeEventListener("test",g,d)}catch{}return u}();function Si(u,d){if(Ke.call(this,u?u.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,u){var g=this.type=u.type,b=u.changedTouches&&u.changedTouches.length?u.changedTouches[0]:null;if(this.target=u.target||u.srcElement,this.g=d,d=u.relatedTarget){if(de){e:{try{le(d.nodeName);var L=!0;break e}catch{}L=!1}L||(d=null)}}else g=="mouseover"?d=u.fromElement:g=="mouseout"&&(d=u.toElement);this.relatedTarget=d,b?(this.clientX=b.clientX!==void 0?b.clientX:b.pageX,this.clientY=b.clientY!==void 0?b.clientY:b.pageY,this.screenX=b.screenX||0,this.screenY=b.screenY||0):(this.clientX=u.clientX!==void 0?u.clientX:u.pageX,this.clientY=u.clientY!==void 0?u.clientY:u.pageY,this.screenX=u.screenX||0,this.screenY=u.screenY||0),this.button=u.button,this.key=u.key||"",this.ctrlKey=u.ctrlKey,this.altKey=u.altKey,this.shiftKey=u.shiftKey,this.metaKey=u.metaKey,this.pointerId=u.pointerId||0,this.pointerType=typeof u.pointerType=="string"?u.pointerType:Ri[u.pointerType]||"",this.state=u.state,this.i=u,u.defaultPrevented&&Si.aa.h.call(this)}}B(Si,Ke);var Ri={2:"touch",3:"pen",4:"mouse"};Si.prototype.h=function(){Si.aa.h.call(this);var u=this.i;u.preventDefault?u.preventDefault():u.returnValue=!1};var pr="closure_listenable_"+(1e6*Math.random()|0),wf=0;function Ds(u,d,g,b,L){this.listener=u,this.proxy=null,this.src=d,this.type=g,this.capture=!!b,this.ha=L,this.key=++wf,this.da=this.fa=!1}function rn(u){u.da=!0,u.listener=null,u.proxy=null,u.src=null,u.ha=null}function Pi(u){this.src=u,this.g={},this.h=0}Pi.prototype.add=function(u,d,g,b,L){var F=u.toString();u=this.g[F],u||(u=this.g[F]=[],this.h++);var Q=nn(u,d,b,L);return-1<Q?(d=u[Q],g||(d.fa=!1)):(d=new Ds(d,this.src,F,!!b,L),d.fa=g,u.push(d)),d};function Pt(u,d){var g=d.type;if(g in u.g){var b=u.g[g],L=Array.prototype.indexOf.call(b,d,void 0),F;(F=0<=L)&&Array.prototype.splice.call(b,L,1),F&&(rn(d),u.g[g].length==0&&(delete u.g[g],u.h--))}}function nn(u,d,g,b){for(var L=0;L<u.length;++L){var F=u[L];if(!F.da&&F.listener==d&&F.capture==!!g&&F.ha==b)return L}return-1}var pa="closure_lm_"+(1e6*Math.random()|0),Ht={};function ma(u,d,g,b,L){if(b&&b.once)return Mt(u,d,g,b,L);if(Array.isArray(d)){for(var F=0;F<d.length;F++)ma(u,d[F],g,b,L);return null}return g=Or(g),u&&u[pr]?u.K(d,g,m(b)?!!b.capture:!!b,L):uc(u,d,g,!1,b,L)}function uc(u,d,g,b,L,F){if(!d)throw Error("Invalid event type");var Q=m(L)?!!L.capture:!!L,_e=ga(u);if(_e||(u[pa]=_e=new Pi(u)),g=_e.add(d,g,b,Q,F),g.proxy)return g;if(b=Ci(),g.proxy=b,b.src=u,b.listener=g,u.addEventListener)Cs||(L=Q),L===void 0&&(L=!1),u.addEventListener(d.toString(),b,L);else if(u.attachEvent)u.attachEvent(cc(d.toString()),b);else if(u.addListener&&u.removeListener)u.addListener(b);else throw Error("addEventListener and attachEvent are unavailable.");return g}function Ci(){function u(g){return d.call(u.src,u.listener,g)}let d=Di;return u}function Mt(u,d,g,b,L){if(Array.isArray(d)){for(var F=0;F<d.length;F++)Mt(u,d[F],g,b,L);return null}return g=Or(g),u&&u[pr]?u.L(d,g,m(b)?!!b.capture:!!b,L):uc(u,d,g,!0,b,L)}function Ln(u,d,g,b,L){if(Array.isArray(d))for(var F=0;F<d.length;F++)Ln(u,d[F],g,b,L);else b=m(b)?!!b.capture:!!b,g=Or(g),u&&u[pr]?(u=u.i,d=String(d).toString(),d in u.g&&(F=u.g[d],g=nn(F,g,b,L),-1<g&&(rn(F[g]),Array.prototype.splice.call(F,g,1),F.length==0&&(delete u.g[d],u.h--)))):u&&(u=ga(u))&&(d=u.g[d.toString()],u=-1,d&&(u=nn(d,g,b,L)),(g=-1<u?d[u]:null)&&Mn(g))}function Mn(u){if(typeof u!="number"&&u&&!u.da){var d=u.src;if(d&&d[pr])Pt(d.i,u);else{var g=u.type,b=u.proxy;d.removeEventListener?d.removeEventListener(g,b,u.capture):d.detachEvent?d.detachEvent(cc(g),b):d.addListener&&d.removeListener&&d.removeListener(b),(g=ga(d))?(Pt(g,u),g.h==0&&(g.src=null,d[pa]=null)):rn(u)}}}function cc(u){return u in Ht?Ht[u]:Ht[u]="on"+u}function Di(u,d){if(u.da)u=!0;else{d=new Si(d,this);var g=u.listener,b=u.ha||u.src;u.fa&&Mn(u),u=g.call(b,d)}return u}function ga(u){return u=u[pa],u instanceof Pi?u:null}var sn="__closure_events_fn_"+(1e9*Math.random()>>>0);function Or(u){return typeof u=="function"?u:(u[sn]||(u[sn]=function(d){return u.handleEvent(d)}),u[sn])}function nt(){Dr.call(this),this.i=new Pi(this),this.M=this,this.F=null}B(nt,Dr),nt.prototype[pr]=!0,nt.prototype.removeEventListener=function(u,d,g,b){Ln(this,u,d,g,b)};function ut(u,d){var g,b=u.F;if(b)for(g=[];b;b=b.F)g.push(b);if(u=u.M,b=d.type||d,typeof d=="string")d=new Ke(d,u);else if(d instanceof Ke)d.target=d.target||u;else{var L=d;d=new Ke(b,u),D(d,L)}if(L=!0,g)for(var F=g.length-1;0<=F;F--){var Q=d.g=g[F];L=Fn(Q,b,!0,d)&&L}if(Q=d.g=u,L=Fn(Q,b,!0,d)&&L,L=Fn(Q,b,!1,d)&&L,g)for(F=0;F<g.length;F++)Q=d.g=g[F],L=Fn(Q,b,!1,d)&&L}nt.prototype.N=function(){if(nt.aa.N.call(this),this.i){var u=this.i,d;for(d in u.g){for(var g=u.g[d],b=0;b<g.length;b++)rn(g[b]);delete u.g[d],u.h--}}this.F=null},nt.prototype.K=function(u,d,g,b){return this.i.add(String(u),d,!1,g,b)},nt.prototype.L=function(u,d,g,b){return this.i.add(String(u),d,!0,g,b)};function Fn(u,d,g,b){if(d=u.i.g[String(d)],!d)return!0;d=d.concat();for(var L=!0,F=0;F<d.length;++F){var Q=d[F];if(Q&&!Q.da&&Q.capture==g){var _e=Q.listener,Ze=Q.ha||Q.src;Q.fa&&Pt(u.i,Q),L=_e.call(Ze,b)!==!1&&L}}return L&&!b.defaultPrevented}function Os(u,d,g){if(typeof u=="function")g&&(u=I(u,g));else if(u&&typeof u.handleEvent=="function")u=I(u.handleEvent,u);else throw Error("Invalid listener argument");return 2147483647<Number(d)?-1:h.setTimeout(u,d||0)}function ks(u){u.g=Os(()=>{u.g=null,u.i&&(u.i=!1,ks(u))},u.l);let d=u.h;u.h=null,u.m.apply(null,d)}class _a extends Dr{constructor(d,g){super(),this.m=d,this.l=g,this.h=null,this.i=!1,this.g=null}j(d){this.h=arguments,this.g?this.i=!0:ks(this)}N(){super.N(),this.g&&(h.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function on(u){Dr.call(this),this.h=u,this.g={}}B(on,Dr);var Ns=[];function Vs(u){ie(u.g,function(d,g){this.g.hasOwnProperty(g)&&Mn(d)},u),u.g={}}on.prototype.N=function(){on.aa.N.call(this),Vs(this)},on.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var ya=h.JSON.stringify,bf=h.JSON.parse,Tf=class{stringify(u){return h.JSON.stringify(u,void 0)}parse(u){return h.JSON.parse(u,void 0)}};function Ls(){}Ls.prototype.h=null;function va(u){return u.h||(u.h=u.i())}function lc(){}var Oi={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function wa(){Ke.call(this,"d")}B(wa,Ke);function ba(){Ke.call(this,"c")}B(ba,Ke);var kr={},hc=null;function Ms(){return hc=hc||new nt}kr.La="serverreachability";function fc(u){Ke.call(this,kr.La,u)}B(fc,Ke);function an(u){let d=Ms();ut(d,new fc(d))}kr.STAT_EVENT="statevent";function dc(u,d){Ke.call(this,kr.STAT_EVENT,u),this.stat=d}B(dc,Ke);function ct(u){let d=Ms();ut(d,new dc(d,u))}kr.Ma="timingevent";function pc(u,d){Ke.call(this,kr.Ma,u),this.size=d}B(pc,Ke);function ki(u,d){if(typeof u!="function")throw Error("Fn must not be null and must be a function");return h.setTimeout(function(){u()},d)}function Ni(){this.g=!0}Ni.prototype.xa=function(){this.g=!1};function Ef(u,d,g,b,L,F){u.info(function(){if(u.g)if(F)for(var Q="",_e=F.split("&"),Ze=0;Ze<_e.length;Ze++){var be=_e[Ze].split("=");if(1<be.length){var lt=be[0];be=be[1];var ht=lt.split("_");Q=2<=ht.length&&ht[1]=="type"?Q+(lt+"="+be+"&"):Q+(lt+"=redacted&")}}else Q=null;else Q=F;return"XMLHTTP REQ ("+b+") [attempt "+L+"]: "+d+`
|
|
20
|
+
}`;var ve=$y(function(){return Ne(T,te+"return "+K).apply(r,x)});if(ve.source=K,wd(ve))throw ve;return ve}function H1(i){return Ve(i).toLowerCase()}function Q1(i){return Ve(i).toUpperCase()}function J1(i,o,l){if(i=Ve(i),i&&(l||o===r))return Q(i);if(!i||!(o=Jt(o)))return i;var p=br(i),y=br(o),T=lt(p,y),x=ht(p,y)+1;return ti(p,T,x).join("")}function Y1(i,o,l){if(i=Ve(i),i&&(l||o===r))return i.slice(0,t_(i)+1);if(!i||!(o=Jt(o)))return i;var p=br(i),y=ht(p,br(o))+1;return ti(p,0,y).join("")}function X1(i,o,l){if(i=Ve(i),i&&(l||o===r))return i.replace(ct,"");if(!i||!(o=Jt(o)))return i;var p=br(i),y=lt(p,br(o));return ti(p,y).join("")}function Z1(i,o){var l=A,p=R;if(We(o)){var y="separator"in o?o.separator:y;l="length"in o?ye(o.length):l,p="omission"in o?Jt(o.omission):p}i=Ve(i);var T=i.length;if(Js(i)){var x=br(i);T=x.length}if(l>=T)return i;var P=l-Ys(p);if(P<1)return p;var N=x?ti(x,0,P).join(""):i.slice(0,P);if(y===r)return N+p;if(x&&(P+=N.length-P),bd(y)){if(i.slice(P).search(y)){var q,z=N;for(y.global||(y=Mf(y.source,Ve(Vi.exec(y))+"g")),y.lastIndex=0;q=y.exec(z);)var K=q.index;N=N.slice(0,K===r?P:K)}}else if(i.indexOf(Jt(y),P)!=P){var Y=N.lastIndexOf(y);Y>-1&&(N=N.slice(0,Y))}return N+p}function eP(i){return i=Ve(i),i&&lc.test(i)?i.replace(Ls,PI):i}var tP=no(function(i,o,l){return i+(l?" ":"")+o.toUpperCase()}),Id=q_("toUpperCase");function jy(i,o,l){return i=Ve(i),o=l?r:o,o===r?II(i)?OI(i):Mc(i):i.match(o)||[]}var $y=we(function(i,o){try{return Et(i,r,o)}catch(l){return wd(l)?l:new he(l)}}),rP=pn(function(i,o){return Ft(o,function(l){l=Br(l),fn(i,l,yd(i[l],i))}),i});function nP(i){var o=i==null?0:i.length,l=se();return i=o?Fe(i,function(p){if(typeof p[1]!="function")throw new nr(s);return[l(p[0]),p[1]]}):[],we(function(p){for(var y=-1;++y<o;){var T=i[y];if(Et(T[0],this,p))return Et(T[1],this,p)}})}function iP(i){return Px(sr(i,m))}function xd(i){return function(){return i}}function sP(i,o){return i==null||i!==i?o:i}var oP=G_(),aP=G_(!0);function $t(i){return i}function Ad(i){return b_(typeof i=="function"?i:sr(i,m))}function uP(i){return E_(sr(i,m))}function cP(i,o){return I_(i,sr(o,m))}var lP=we(function(i,o){return function(l){return Ka(l,i,o)}}),hP=we(function(i,o){return function(l){return Ka(i,l,o)}});function Sd(i,o,l){var p=mt(o),y=tl(o,p);l==null&&!(We(o)&&(y.length||!p.length))&&(l=o,o=i,i=this,y=tl(o,mt(o)));var T=!(We(l)&&"chain"in l)||!!l.chain,x=gn(i);return Ft(y,function(P){var N=o[P];i[P]=N,x&&(i.prototype[P]=function(){var q=this.__chain__;if(T||q){var z=i(this.__wrapped__),K=z.__actions__=Ut(this.__actions__);return K.push({func:N,args:arguments,thisArg:i}),z.__chain__=q,z}return N.apply(i,vr([this.value()],arguments))})}),i}function fP(){return Xe._===this&&(Xe._=FI),this}function Rd(){}function dP(i){return i=ye(i),we(function(o){return x_(o,i)})}var pP=sd(Fe),mP=sd(Kn),gP=sd(Hs);function qy(i){return fd(i)?Mr(Br(i)):Kx(i)}function _P(i){return function(o){return i==null?r:Zi(i,o)}}var yP=W_(),vP=W_(!0);function Pd(){return[]}function Cd(){return!1}function wP(){return{}}function bP(){return""}function TP(){return!0}function EP(i,o){if(i=ye(i),i<1||i>Pr)return[];var l=Lt,p=It(i,Lt);o=se(o),i-=Lt;for(var y=L(p,o);++l<i;)o(l);return y}function IP(i){return pe(i)?Fe(i,Br):Yt(i)?[i]:Ut(cy(Ve(i)))}function xP(i){var o=++LI;return Ve(i)+o}var AP=al(function(i,o){return i+o},0),SP=od("ceil"),RP=al(function(i,o){return i/o},1),PP=od("floor");function CP(i){return i&&i.length?el(i,$t,Gf):r}function DP(i,o){return i&&i.length?el(i,se(o,2),Gf):r}function OP(i){return Ma(i,$t)}function kP(i,o){return Ma(i,se(o,2))}function NP(i){return i&&i.length?el(i,$t,Qf):r}function VP(i,o){return i&&i.length?el(i,se(o,2),Qf):r}var LP=al(function(i,o){return i*o},1),MP=od("round"),FP=al(function(i,o){return i-o},0);function UP(i){return i&&i.length?b(i,$t):0}function BP(i,o){return i&&i.length?b(i,se(o,2)):0}return w.after=uR,w.ary=wy,w.assign=QR,w.assignIn=Ny,w.assignInWith=wl,w.assignWith=JR,w.at=YR,w.before=by,w.bind=yd,w.bindAll=rP,w.bindKey=Ty,w.castArray=wR,w.chain=_y,w.chunk=PA,w.compact=CA,w.concat=DA,w.cond=nP,w.conforms=iP,w.constant=xd,w.countBy=US,w.create=XR,w.curry=Ey,w.curryRight=Iy,w.debounce=xy,w.defaults=ZR,w.defaultsDeep=e1,w.defer=cR,w.delay=lR,w.difference=OA,w.differenceBy=kA,w.differenceWith=NA,w.drop=VA,w.dropRight=LA,w.dropRightWhile=MA,w.dropWhile=FA,w.fill=UA,w.filter=jS,w.flatMap=zS,w.flatMapDeep=GS,w.flatMapDepth=KS,w.flatten=dy,w.flattenDeep=BA,w.flattenDepth=jA,w.flip=hR,w.flow=oP,w.flowRight=aP,w.fromPairs=$A,w.functions=a1,w.functionsIn=u1,w.groupBy=WS,w.initial=zA,w.intersection=GA,w.intersectionBy=KA,w.intersectionWith=WA,w.invert=l1,w.invertBy=h1,w.invokeMap=QS,w.iteratee=Ad,w.keyBy=JS,w.keys=mt,w.keysIn=jt,w.map=pl,w.mapKeys=d1,w.mapValues=p1,w.matches=uP,w.matchesProperty=cP,w.memoize=gl,w.merge=m1,w.mergeWith=Vy,w.method=lP,w.methodOf=hP,w.mixin=Sd,w.negate=_l,w.nthArg=dP,w.omit=g1,w.omitBy=_1,w.once=fR,w.orderBy=YS,w.over=pP,w.overArgs=dR,w.overEvery=mP,w.overSome=gP,w.partial=vd,w.partialRight=Ay,w.partition=XS,w.pick=y1,w.pickBy=Ly,w.property=qy,w.propertyOf=_P,w.pull=YA,w.pullAll=my,w.pullAllBy=XA,w.pullAllWith=ZA,w.pullAt=eS,w.range=yP,w.rangeRight=vP,w.rearg=pR,w.reject=tR,w.remove=tS,w.rest=mR,w.reverse=gd,w.sampleSize=nR,w.set=w1,w.setWith=b1,w.shuffle=iR,w.slice=rS,w.sortBy=aR,w.sortedUniq=cS,w.sortedUniqBy=lS,w.split=z1,w.spread=gR,w.tail=hS,w.take=fS,w.takeRight=dS,w.takeRightWhile=pS,w.takeWhile=mS,w.tap=CS,w.throttle=_R,w.thru=dl,w.toArray=Dy,w.toPairs=My,w.toPairsIn=Fy,w.toPath=IP,w.toPlainObject=ky,w.transform=T1,w.unary=yR,w.union=gS,w.unionBy=_S,w.unionWith=yS,w.uniq=vS,w.uniqBy=wS,w.uniqWith=bS,w.unset=E1,w.unzip=_d,w.unzipWith=gy,w.update=I1,w.updateWith=x1,w.values=oo,w.valuesIn=A1,w.without=TS,w.words=jy,w.wrap=vR,w.xor=ES,w.xorBy=IS,w.xorWith=xS,w.zip=AS,w.zipObject=SS,w.zipObjectDeep=RS,w.zipWith=PS,w.entries=My,w.entriesIn=Fy,w.extend=Ny,w.extendWith=wl,Sd(w,w),w.add=AP,w.attempt=$y,w.camelCase=C1,w.capitalize=Uy,w.ceil=SP,w.clamp=S1,w.clone=bR,w.cloneDeep=ER,w.cloneDeepWith=IR,w.cloneWith=TR,w.conformsTo=xR,w.deburr=By,w.defaultTo=sP,w.divide=RP,w.endsWith=D1,w.eq=Er,w.escape=O1,w.escapeRegExp=k1,w.every=BS,w.find=$S,w.findIndex=hy,w.findKey=t1,w.findLast=qS,w.findLastIndex=fy,w.findLastKey=r1,w.floor=PP,w.forEach=yy,w.forEachRight=vy,w.forIn=n1,w.forInRight=i1,w.forOwn=s1,w.forOwnRight=o1,w.get=Td,w.gt=AR,w.gte=SR,w.has=c1,w.hasIn=Ed,w.head=py,w.identity=$t,w.includes=HS,w.indexOf=qA,w.inRange=R1,w.invoke=f1,w.isArguments=rs,w.isArray=pe,w.isArrayBuffer=RR,w.isArrayLike=Bt,w.isArrayLikeObject=et,w.isBoolean=PR,w.isBuffer=ri,w.isDate=CR,w.isElement=DR,w.isEmpty=OR,w.isEqual=kR,w.isEqualWith=NR,w.isError=wd,w.isFinite=VR,w.isFunction=gn,w.isInteger=Sy,w.isLength=yl,w.isMap=Ry,w.isMatch=LR,w.isMatchWith=MR,w.isNaN=FR,w.isNative=UR,w.isNil=jR,w.isNull=BR,w.isNumber=Py,w.isObject=We,w.isObjectLike=Qe,w.isPlainObject=Xa,w.isRegExp=bd,w.isSafeInteger=$R,w.isSet=Cy,w.isString=vl,w.isSymbol=Yt,w.isTypedArray=so,w.isUndefined=qR,w.isWeakMap=zR,w.isWeakSet=GR,w.join=HA,w.kebabCase=N1,w.last=ar,w.lastIndexOf=QA,w.lowerCase=V1,w.lowerFirst=L1,w.lt=KR,w.lte=WR,w.max=CP,w.maxBy=DP,w.mean=OP,w.meanBy=kP,w.min=NP,w.minBy=VP,w.stubArray=Pd,w.stubFalse=Cd,w.stubObject=wP,w.stubString=bP,w.stubTrue=TP,w.multiply=LP,w.nth=JA,w.noConflict=fP,w.noop=Rd,w.now=ml,w.pad=M1,w.padEnd=F1,w.padStart=U1,w.parseInt=B1,w.random=P1,w.reduce=ZS,w.reduceRight=eR,w.repeat=j1,w.replace=$1,w.result=v1,w.round=MP,w.runInContext=O,w.sample=rR,w.size=sR,w.snakeCase=q1,w.some=oR,w.sortedIndex=nS,w.sortedIndexBy=iS,w.sortedIndexOf=sS,w.sortedLastIndex=oS,w.sortedLastIndexBy=aS,w.sortedLastIndexOf=uS,w.startCase=G1,w.startsWith=K1,w.subtract=FP,w.sum=UP,w.sumBy=BP,w.template=W1,w.times=EP,w.toFinite=_n,w.toInteger=ye,w.toLength=Oy,w.toLower=H1,w.toNumber=ur,w.toSafeInteger=HR,w.toString=Ve,w.toUpper=Q1,w.trim=J1,w.trimEnd=Y1,w.trimStart=X1,w.truncate=Z1,w.unescape=eP,w.uniqueId=xP,w.upperCase=tP,w.upperFirst=Id,w.each=yy,w.eachRight=vy,w.first=py,Sd(w,function(){var i={};return Fr(w,function(o,l){Me.call(w.prototype,l)||(i[l]=o)}),i}(),{chain:!1}),w.VERSION=e,Ft(["bind","bindKey","curry","curryRight","partial","partialRight"],function(i){w[i].placeholder=w}),Ft(["drop","take"],function(i,o){Ie.prototype[i]=function(l){l=l===r?1:dt(ye(l),0);var p=this.__filtered__&&!o?new Ie(this):this.clone();return p.__filtered__?p.__takeCount__=It(l,p.__takeCount__):p.__views__.push({size:It(l,Lt),type:i+(p.__dir__<0?"Right":"")}),p},Ie.prototype[i+"Right"]=function(l){return this.reverse()[i](l).reverse()}}),Ft(["filter","map","takeWhile"],function(i,o){var l=o+1,p=l==M||l==dr;Ie.prototype[i]=function(y){var T=this.clone();return T.__iteratees__.push({iteratee:se(y,3),type:l}),T.__filtered__=T.__filtered__||p,T}}),Ft(["head","last"],function(i,o){var l="take"+(o?"Right":"");Ie.prototype[i]=function(){return this[l](1).value()[0]}}),Ft(["initial","tail"],function(i,o){var l="drop"+(o?"":"Right");Ie.prototype[i]=function(){return this.__filtered__?new Ie(this):this[l](1)}}),Ie.prototype.compact=function(){return this.filter($t)},Ie.prototype.find=function(i){return this.filter(i).head()},Ie.prototype.findLast=function(i){return this.reverse().find(i)},Ie.prototype.invokeMap=we(function(i,o){return typeof i=="function"?new Ie(this):this.map(function(l){return Ka(l,i,o)})}),Ie.prototype.reject=function(i){return this.filter(_l(se(i)))},Ie.prototype.slice=function(i,o){i=ye(i);var l=this;return l.__filtered__&&(i>0||o<0)?new Ie(l):(i<0?l=l.takeRight(-i):i&&(l=l.drop(i)),o!==r&&(o=ye(o),l=o<0?l.dropRight(-o):l.take(o-i)),l)},Ie.prototype.takeRightWhile=function(i){return this.reverse().takeWhile(i).reverse()},Ie.prototype.toArray=function(){return this.take(Lt)},Fr(Ie.prototype,function(i,o){var l=/^(?:filter|find|map|reject)|While$/.test(o),p=/^(?:head|last)$/.test(o),y=w[p?"take"+(o=="last"?"Right":""):o],T=p||/^find/.test(o);y&&(w.prototype[o]=function(){var x=this.__wrapped__,P=p?[1]:arguments,N=x instanceof Ie,q=P[0],z=N||pe(x),K=function(Te){var Ae=y.apply(w,vr([Te],P));return p&&Y?Ae[0]:Ae};z&&l&&typeof q=="function"&&q.length!=1&&(N=z=!1);var Y=this.__chain__,te=!!this.__actions__.length,oe=T&&!Y,ve=N&&!te;if(!T&&z){x=ve?x:new Ie(this);var ae=i.apply(x,P);return ae.__actions__.push({func:dl,args:[K],thisArg:r}),new ir(ae,Y)}return oe&&ve?i.apply(this,P):(ae=this.thru(K),oe?p?ae.value()[0]:ae.value():ae)})}),Ft(["pop","push","shift","sort","splice","unshift"],function(i){var o=Uc[i],l=/^(?:push|sort|unshift)$/.test(i)?"tap":"thru",p=/^(?:pop|shift)$/.test(i);w.prototype[i]=function(){var y=arguments;if(p&&!this.__chain__){var T=this.value();return o.apply(pe(T)?T:[],y)}return this[l](function(x){return o.apply(pe(x)?x:[],y)})}}),Fr(Ie.prototype,function(i,o){var l=w[o];if(l){var p=l.name+"";Me.call(eo,p)||(eo[p]=[]),eo[p].push({name:o,func:l})}}),eo[ol(r,G).name]=[{name:"wrapper",func:r}],Ie.prototype.clone=ex,Ie.prototype.reverse=tx,Ie.prototype.value=rx,w.prototype.at=DS,w.prototype.chain=OS,w.prototype.commit=kS,w.prototype.next=NS,w.prototype.plant=LS,w.prototype.reverse=MS,w.prototype.toJSON=w.prototype.valueOf=w.prototype.value=FS,w.prototype.first=w.prototype.head,Ua&&(w.prototype[Ua]=VS),w},Jn=kI();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Xe._=Jn,define(function(){return Jn})):Lr?((Lr.exports=Jn)._=Jn,zs._=Jn):Xe._=Jn}).call(fa)});var fI=cr((YW,hI)=>{var yf=cI();function lI(r,e){var t={};return Object.keys(r).sort(e||void 0).forEach(function(n){t[n]=r[n]}),t}function Jg(r,e){if(yf.isArray(r))return yf.map(r,function(n){return Jg(n,e)});if(yf.isObject(r)){var t=lI(r,e);return yf.forEach(t,function(n,s){t[s]=Jg(n)}),t}else return r}hI.exports={keyArrange:lI,keyArrangeDeep:Jg}});var JP=typeof global=="object"&&global&&global.Object===Object&&global,bl=JP;var YP=typeof self=="object"&&self&&self.Object===Object&&self,XP=bl||YP||Function("return this")(),Je=XP;var ZP=Je.Symbol,Nt=ZP;var Ky=Object.prototype,eC=Ky.hasOwnProperty,tC=Ky.toString,eu=Nt?Nt.toStringTag:void 0;function rC(r){var e=eC.call(r,eu),t=r[eu];try{r[eu]=void 0;var n=!0}catch{}var s=tC.call(r);return n&&(e?r[eu]=t:delete r[eu]),s}var Wy=rC;var nC=Object.prototype,iC=nC.toString;function sC(r){return iC.call(r)}var Hy=sC;var oC="[object Null]",aC="[object Undefined]",Qy=Nt?Nt.toStringTag:void 0;function uC(r){return r==null?r===void 0?aC:oC:Qy&&Qy in Object(r)?Wy(r):Hy(r)}var xr=uC;function cC(r){return r!=null&&typeof r=="object"}var Vt=cC;var lC="[object Symbol]";function hC(r){return typeof r=="symbol"||Vt(r)&&xr(r)==lC}var ni=hC;function fC(r,e){for(var t=-1,n=r==null?0:r.length,s=Array(n);++t<n;)s[t]=e(r[t],t,r);return s}var Jy=fC;var dC=Array.isArray,rt=dC;var pC=1/0,Yy=Nt?Nt.prototype:void 0,Xy=Yy?Yy.toString:void 0;function Zy(r){if(typeof r=="string")return r;if(rt(r))return Jy(r,Zy)+"";if(ni(r))return Xy?Xy.call(r):"";var e=r+"";return e=="0"&&1/r==-pC?"-0":e}var ev=Zy;var mC=/\s/;function gC(r){for(var e=r.length;e--&&mC.test(r.charAt(e)););return e}var tv=gC;var _C=/^\s+/;function yC(r){return r&&r.slice(0,tv(r)+1).replace(_C,"")}var rv=yC;function vC(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var De=vC;var nv=NaN,wC=/^[-+]0x[0-9a-f]+$/i,bC=/^0b[01]+$/i,TC=/^0o[0-7]+$/i,EC=parseInt;function IC(r){if(typeof r=="number")return r;if(ni(r))return nv;if(De(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=De(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=rv(r);var t=bC.test(r);return t||TC.test(r)?EC(r.slice(2),t?2:8):wC.test(r)?nv:+r}var Od=IC;function xC(r){return r}var ao=xC;var AC="[object AsyncFunction]",SC="[object Function]",RC="[object GeneratorFunction]",PC="[object Proxy]";function CC(r){if(!De(r))return!1;var e=xr(r);return e==SC||e==RC||e==AC||e==PC}var Tl=CC;var DC=Je["__core-js_shared__"],El=DC;var iv=function(){var r=/[^.]+$/.exec(El&&El.keys&&El.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function OC(r){return!!iv&&iv in r}var sv=OC;var kC=Function.prototype,NC=kC.toString;function VC(r){if(r!=null){try{return NC.call(r)}catch{}try{return r+""}catch{}}return""}var vn=VC;var LC=/[\\^$.*+?()[\]{}|]/g,MC=/^\[object .+?Constructor\]$/,FC=Function.prototype,UC=Object.prototype,BC=FC.toString,jC=UC.hasOwnProperty,$C=RegExp("^"+BC.call(jC).replace(LC,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function qC(r){if(!De(r)||sv(r))return!1;var e=Tl(r)?$C:MC;return e.test(vn(r))}var ov=qC;function zC(r,e){return r==null?void 0:r[e]}var av=zC;function GC(r,e){var t=av(r,e);return ov(t)?t:void 0}var qt=GC;var KC=qt(Je,"WeakMap"),Il=KC;var uv=Object.create,WC=function(){function r(){}return function(e){if(!De(e))return{};if(uv)return uv(e);r.prototype=e;var t=new r;return r.prototype=void 0,t}}(),cv=WC;function HC(r,e,t){switch(t.length){case 0:return r.call(e);case 1:return r.call(e,t[0]);case 2:return r.call(e,t[0],t[1]);case 3:return r.call(e,t[0],t[1],t[2])}return r.apply(e,t)}var lv=HC;function QC(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}var hv=QC;var JC=800,YC=16,XC=Date.now;function ZC(r){var e=0,t=0;return function(){var n=XC(),s=YC-(n-t);if(t=n,s>0){if(++e>=JC)return arguments[0]}else e=0;return r.apply(void 0,arguments)}}var fv=ZC;function eD(r){return function(){return r}}var dv=eD;var tD=function(){try{var r=qt(Object,"defineProperty");return r({},"",{}),r}catch{}}(),uo=tD;var rD=uo?function(r,e){return uo(r,"toString",{configurable:!0,enumerable:!1,value:dv(e),writable:!0})}:ao,pv=rD;var nD=fv(pv),mv=nD;function iD(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var gv=iD;var sD=9007199254740991,oD=/^(?:0|[1-9]\d*)$/;function aD(r,e){var t=typeof r;return e=e==null?sD:e,!!e&&(t=="number"||t!="symbol"&&oD.test(r))&&r>-1&&r%1==0&&r<e}var ii=aD;function uD(r,e,t){e=="__proto__"&&uo?uo(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[e]=t}var co=uD;function cD(r,e){return r===e||r!==r&&e!==e}var jr=cD;var lD=Object.prototype,hD=lD.hasOwnProperty;function fD(r,e,t){var n=r[e];(!(hD.call(r,e)&&jr(n,t))||t===void 0&&!(e in r))&&co(r,e,t)}var lo=fD;function dD(r,e,t,n){var s=!t;t||(t={});for(var a=-1,c=e.length;++a<c;){var h=e[a],f=n?n(t[h],r[h],h,t,r):void 0;f===void 0&&(f=r[h]),s?co(t,h,f):lo(t,h,f)}return t}var si=dD;var _v=Math.max;function pD(r,e,t){return e=_v(e===void 0?r.length-1:e,0),function(){for(var n=arguments,s=-1,a=_v(n.length-e,0),c=Array(a);++s<a;)c[s]=n[e+s];s=-1;for(var h=Array(e+1);++s<e;)h[s]=n[s];return h[e]=t(c),lv(r,this,h)}}var yv=pD;function mD(r,e){return mv(yv(r,e,ao),r+"")}var vv=mD;var gD=9007199254740991;function _D(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=gD}var ho=_D;function yD(r){return r!=null&&ho(r.length)&&!Tl(r)}var oi=yD;function vD(r,e,t){if(!De(t))return!1;var n=typeof e;return(n=="number"?oi(t)&&ii(e,t.length):n=="string"&&e in t)?jr(t[e],r):!1}var wv=vD;var wD=Object.prototype;function bD(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||wD;return r===t}var ai=bD;function TD(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}var bv=TD;var ED="[object Arguments]";function ID(r){return Vt(r)&&xr(r)==ED}var kd=ID;var Tv=Object.prototype,xD=Tv.hasOwnProperty,AD=Tv.propertyIsEnumerable,SD=kd(function(){return arguments}())?kd:function(r){return Vt(r)&&xD.call(r,"callee")&&!AD.call(r,"callee")},fo=SD;function RD(){return!1}var Ev=RD;var Av=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Iv=Av&&typeof module=="object"&&module&&!module.nodeType&&module,PD=Iv&&Iv.exports===Av,xv=PD?Je.Buffer:void 0,CD=xv?xv.isBuffer:void 0,DD=CD||Ev,wn=DD;var OD="[object Arguments]",kD="[object Array]",ND="[object Boolean]",VD="[object Date]",LD="[object Error]",MD="[object Function]",FD="[object Map]",UD="[object Number]",BD="[object Object]",jD="[object RegExp]",$D="[object Set]",qD="[object String]",zD="[object WeakMap]",GD="[object ArrayBuffer]",KD="[object DataView]",WD="[object Float32Array]",HD="[object Float64Array]",QD="[object Int8Array]",JD="[object Int16Array]",YD="[object Int32Array]",XD="[object Uint8Array]",ZD="[object Uint8ClampedArray]",eO="[object Uint16Array]",tO="[object Uint32Array]",qe={};qe[WD]=qe[HD]=qe[QD]=qe[JD]=qe[YD]=qe[XD]=qe[ZD]=qe[eO]=qe[tO]=!0;qe[OD]=qe[kD]=qe[GD]=qe[ND]=qe[KD]=qe[VD]=qe[LD]=qe[MD]=qe[FD]=qe[UD]=qe[BD]=qe[jD]=qe[$D]=qe[qD]=qe[zD]=!1;function rO(r){return Vt(r)&&ho(r.length)&&!!qe[xr(r)]}var Sv=rO;function nO(r){return function(e){return r(e)}}var po=nO;var Rv=typeof exports=="object"&&exports&&!exports.nodeType&&exports,tu=Rv&&typeof module=="object"&&module&&!module.nodeType&&module,iO=tu&&tu.exports===Rv,Nd=iO&&bl.process,sO=function(){try{var r=tu&&tu.require&&tu.require("util").types;return r||Nd&&Nd.binding&&Nd.binding("util")}catch{}}(),bn=sO;var Pv=bn&&bn.isTypedArray,oO=Pv?po(Pv):Sv,mo=oO;var aO=Object.prototype,uO=aO.hasOwnProperty;function cO(r,e){var t=rt(r),n=!t&&fo(r),s=!t&&!n&&wn(r),a=!t&&!n&&!s&&mo(r),c=t||n||s||a,h=c?bv(r.length,String):[],f=h.length;for(var m in r)(e||uO.call(r,m))&&!(c&&(m=="length"||s&&(m=="offset"||m=="parent")||a&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||ii(m,f)))&&h.push(m);return h}var xl=cO;function lO(r,e){return function(t){return r(e(t))}}var Al=lO;var hO=Al(Object.keys,Object),Cv=hO;var fO=Object.prototype,dO=fO.hasOwnProperty;function pO(r){if(!ai(r))return Cv(r);var e=[];for(var t in Object(r))dO.call(r,t)&&t!="constructor"&&e.push(t);return e}var Sl=pO;function mO(r){return oi(r)?xl(r):Sl(r)}var At=mO;function gO(r){var e=[];if(r!=null)for(var t in Object(r))e.push(t);return e}var Dv=gO;var _O=Object.prototype,yO=_O.hasOwnProperty;function vO(r){if(!De(r))return Dv(r);var e=ai(r),t=[];for(var n in r)n=="constructor"&&(e||!yO.call(r,n))||t.push(n);return t}var Ov=vO;function wO(r){return oi(r)?xl(r,!0):Ov(r)}var ui=wO;var bO=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,TO=/^\w*$/;function EO(r,e){if(rt(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||ni(r)?!0:TO.test(r)||!bO.test(r)||e!=null&&r in Object(e)}var go=EO;var IO=qt(Object,"create"),Tn=IO;function xO(){this.__data__=Tn?Tn(null):{},this.size=0}var kv=xO;function AO(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var Nv=AO;var SO="__lodash_hash_undefined__",RO=Object.prototype,PO=RO.hasOwnProperty;function CO(r){var e=this.__data__;if(Tn){var t=e[r];return t===SO?void 0:t}return PO.call(e,r)?e[r]:void 0}var Vv=CO;var DO=Object.prototype,OO=DO.hasOwnProperty;function kO(r){var e=this.__data__;return Tn?e[r]!==void 0:OO.call(e,r)}var Lv=kO;var NO="__lodash_hash_undefined__";function VO(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=Tn&&e===void 0?NO:e,this}var Mv=VO;function _o(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}_o.prototype.clear=kv;_o.prototype.delete=Nv;_o.prototype.get=Vv;_o.prototype.has=Lv;_o.prototype.set=Mv;var Vd=_o;function LO(){this.__data__=[],this.size=0}var Fv=LO;function MO(r,e){for(var t=r.length;t--;)if(jr(r[t][0],e))return t;return-1}var ci=MO;var FO=Array.prototype,UO=FO.splice;function BO(r){var e=this.__data__,t=ci(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():UO.call(e,t,1),--this.size,!0}var Uv=BO;function jO(r){var e=this.__data__,t=ci(e,r);return t<0?void 0:e[t][1]}var Bv=jO;function $O(r){return ci(this.__data__,r)>-1}var jv=$O;function qO(r,e){var t=this.__data__,n=ci(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var $v=qO;function yo(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}yo.prototype.clear=Fv;yo.prototype.delete=Uv;yo.prototype.get=Bv;yo.prototype.has=jv;yo.prototype.set=$v;var li=yo;var zO=qt(Je,"Map"),hi=zO;function GO(){this.size=0,this.__data__={hash:new Vd,map:new(hi||li),string:new Vd}}var qv=GO;function KO(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var zv=KO;function WO(r,e){var t=r.__data__;return zv(e)?t[typeof e=="string"?"string":"hash"]:t.map}var fi=WO;function HO(r){var e=fi(this,r).delete(r);return this.size-=e?1:0,e}var Gv=HO;function QO(r){return fi(this,r).get(r)}var Kv=QO;function JO(r){return fi(this,r).has(r)}var Wv=JO;function YO(r,e){var t=fi(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var Hv=YO;function vo(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}vo.prototype.clear=qv;vo.prototype.delete=Gv;vo.prototype.get=Kv;vo.prototype.has=Wv;vo.prototype.set=Hv;var ns=vo;var XO="Expected a function";function Ld(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(XO);var t=function(){var n=arguments,s=e?e.apply(this,n):n[0],a=t.cache;if(a.has(s))return a.get(s);var c=r.apply(this,n);return t.cache=a.set(s,c)||a,c};return t.cache=new(Ld.Cache||ns),t}Ld.Cache=ns;var Qv=Ld;var ZO=500;function ek(r){var e=Qv(r,function(n){return t.size===ZO&&t.clear(),n}),t=e.cache;return e}var Jv=ek;var tk=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rk=/\\(\\)?/g,nk=Jv(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(tk,function(t,n,s,a){e.push(s?a.replace(rk,"$1"):n||t)}),e}),Yv=nk;function ik(r){return r==null?"":ev(r)}var Xv=ik;function sk(r,e){return rt(r)?r:go(r,e)?[r]:Yv(Xv(r))}var wo=sk;var ok=1/0;function ak(r){if(typeof r=="string"||ni(r))return r;var e=r+"";return e=="0"&&1/r==-ok?"-0":e}var $r=ak;function uk(r,e){e=wo(e,r);for(var t=0,n=e.length;r!=null&&t<n;)r=r[$r(e[t++])];return t&&t==n?r:void 0}var Rl=uk;function ck(r,e,t){var n=r==null?void 0:Rl(r,e);return n===void 0?t:n}var ru=ck;function lk(r,e){for(var t=-1,n=e.length,s=r.length;++t<n;)r[s+t]=e[t];return r}var Pl=lk;var hk=Al(Object.getPrototypeOf,Object),Cl=hk;function fk(){this.__data__=new li,this.size=0}var Zv=fk;function dk(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var ew=dk;function pk(r){return this.__data__.get(r)}var tw=pk;function mk(r){return this.__data__.has(r)}var rw=mk;var gk=200;function _k(r,e){var t=this.__data__;if(t instanceof li){var n=t.__data__;if(!hi||n.length<gk-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new ns(n)}return t.set(r,e),this.size=t.size,this}var nw=_k;function bo(r){var e=this.__data__=new li(r);this.size=e.size}bo.prototype.clear=Zv;bo.prototype.delete=ew;bo.prototype.get=tw;bo.prototype.has=rw;bo.prototype.set=nw;var di=bo;function yk(r,e){return r&&si(e,At(e),r)}var iw=yk;function vk(r,e){return r&&si(e,ui(e),r)}var sw=vk;var cw=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ow=cw&&typeof module=="object"&&module&&!module.nodeType&&module,wk=ow&&ow.exports===cw,aw=wk?Je.Buffer:void 0,uw=aw?aw.allocUnsafe:void 0;function bk(r,e){if(e)return r.slice();var t=r.length,n=uw?uw(t):new r.constructor(t);return r.copy(n),n}var lw=bk;function Tk(r,e){for(var t=-1,n=r==null?0:r.length,s=0,a=[];++t<n;){var c=r[t];e(c,t,r)&&(a[s++]=c)}return a}var hw=Tk;function Ek(){return[]}var Dl=Ek;var Ik=Object.prototype,xk=Ik.propertyIsEnumerable,fw=Object.getOwnPropertySymbols,Ak=fw?function(r){return r==null?[]:(r=Object(r),hw(fw(r),function(e){return xk.call(r,e)}))}:Dl,To=Ak;function Sk(r,e){return si(r,To(r),e)}var dw=Sk;var Rk=Object.getOwnPropertySymbols,Pk=Rk?function(r){for(var e=[];r;)Pl(e,To(r)),r=Cl(r);return e}:Dl,Ol=Pk;function Ck(r,e){return si(r,Ol(r),e)}var pw=Ck;function Dk(r,e,t){var n=e(r);return rt(r)?n:Pl(n,t(r))}var kl=Dk;function Ok(r){return kl(r,At,To)}var nu=Ok;function kk(r){return kl(r,ui,Ol)}var mw=kk;var Nk=qt(Je,"DataView"),Nl=Nk;var Vk=qt(Je,"Promise"),Vl=Vk;var Lk=qt(Je,"Set"),Ll=Lk;var gw="[object Map]",Mk="[object Object]",_w="[object Promise]",yw="[object Set]",vw="[object WeakMap]",ww="[object DataView]",Fk=vn(Nl),Uk=vn(hi),Bk=vn(Vl),jk=vn(Ll),$k=vn(Il),is=xr;(Nl&&is(new Nl(new ArrayBuffer(1)))!=ww||hi&&is(new hi)!=gw||Vl&&is(Vl.resolve())!=_w||Ll&&is(new Ll)!=yw||Il&&is(new Il)!=vw)&&(is=function(r){var e=xr(r),t=e==Mk?r.constructor:void 0,n=t?vn(t):"";if(n)switch(n){case Fk:return ww;case Uk:return gw;case Bk:return _w;case jk:return yw;case $k:return vw}return e});var Ar=is;var qk=Object.prototype,zk=qk.hasOwnProperty;function Gk(r){var e=r.length,t=new r.constructor(e);return e&&typeof r[0]=="string"&&zk.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var bw=Gk;var Kk=Je.Uint8Array,Eo=Kk;function Wk(r){var e=new r.constructor(r.byteLength);return new Eo(e).set(new Eo(r)),e}var Io=Wk;function Hk(r,e){var t=e?Io(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var Tw=Hk;var Qk=/\w*$/;function Jk(r){var e=new r.constructor(r.source,Qk.exec(r));return e.lastIndex=r.lastIndex,e}var Ew=Jk;var Iw=Nt?Nt.prototype:void 0,xw=Iw?Iw.valueOf:void 0;function Yk(r){return xw?Object(xw.call(r)):{}}var Aw=Yk;function Xk(r,e){var t=e?Io(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.length)}var Sw=Xk;var Zk="[object Boolean]",eN="[object Date]",tN="[object Map]",rN="[object Number]",nN="[object RegExp]",iN="[object Set]",sN="[object String]",oN="[object Symbol]",aN="[object ArrayBuffer]",uN="[object DataView]",cN="[object Float32Array]",lN="[object Float64Array]",hN="[object Int8Array]",fN="[object Int16Array]",dN="[object Int32Array]",pN="[object Uint8Array]",mN="[object Uint8ClampedArray]",gN="[object Uint16Array]",_N="[object Uint32Array]";function yN(r,e,t){var n=r.constructor;switch(e){case aN:return Io(r);case Zk:case eN:return new n(+r);case uN:return Tw(r,t);case cN:case lN:case hN:case fN:case dN:case pN:case mN:case gN:case _N:return Sw(r,t);case tN:return new n;case rN:case sN:return new n(r);case nN:return Ew(r);case iN:return new n;case oN:return Aw(r)}}var Rw=yN;function vN(r){return typeof r.constructor=="function"&&!ai(r)?cv(Cl(r)):{}}var Pw=vN;var wN="[object Map]";function bN(r){return Vt(r)&&Ar(r)==wN}var Cw=bN;var Dw=bn&&bn.isMap,TN=Dw?po(Dw):Cw,Ow=TN;var EN="[object Set]";function IN(r){return Vt(r)&&Ar(r)==EN}var kw=IN;var Nw=bn&&bn.isSet,xN=Nw?po(Nw):kw,Vw=xN;var AN=1,SN=2,RN=4,Lw="[object Arguments]",PN="[object Array]",CN="[object Boolean]",DN="[object Date]",ON="[object Error]",Mw="[object Function]",kN="[object GeneratorFunction]",NN="[object Map]",VN="[object Number]",Fw="[object Object]",LN="[object RegExp]",MN="[object Set]",FN="[object String]",UN="[object Symbol]",BN="[object WeakMap]",jN="[object ArrayBuffer]",$N="[object DataView]",qN="[object Float32Array]",zN="[object Float64Array]",GN="[object Int8Array]",KN="[object Int16Array]",WN="[object Int32Array]",HN="[object Uint8Array]",QN="[object Uint8ClampedArray]",JN="[object Uint16Array]",YN="[object Uint32Array]",Be={};Be[Lw]=Be[PN]=Be[jN]=Be[$N]=Be[CN]=Be[DN]=Be[qN]=Be[zN]=Be[GN]=Be[KN]=Be[WN]=Be[NN]=Be[VN]=Be[Fw]=Be[LN]=Be[MN]=Be[FN]=Be[UN]=Be[HN]=Be[QN]=Be[JN]=Be[YN]=!0;Be[ON]=Be[Mw]=Be[BN]=!1;function Ml(r,e,t,n,s,a){var c,h=e&AN,f=e&SN,m=e&RN;if(t&&(c=s?t(r,n,s,a):t(r)),c!==void 0)return c;if(!De(r))return r;var _=rt(r);if(_){if(c=bw(r),!h)return hv(r,c)}else{var E=Ar(r),I=E==Mw||E==kN;if(wn(r))return lw(r,h);if(E==Fw||E==Lw||I&&!s){if(c=f||I?{}:Pw(r),!h)return f?pw(r,sw(c,r)):dw(r,iw(c,r))}else{if(!Be[E])return s?r:{};c=Rw(r,E,h)}}a||(a=new di);var k=a.get(r);if(k)return k;a.set(r,c),Vw(r)?r.forEach(function(j){c.add(Ml(j,e,t,j,r,a))}):Ow(r)&&r.forEach(function(j,J){c.set(J,Ml(j,e,t,J,r,a))});var B=m?f?mw:nu:f?ui:At,G=_?void 0:B(r);return gv(G||r,function(j,J){G&&(J=j,j=r[J]),lo(c,J,Ml(j,e,t,J,r,a))}),c}var Uw=Ml;var XN=1,ZN=4;function eV(r){return Uw(r,XN|ZN)}var qr=eV;var tV="__lodash_hash_undefined__";function rV(r){return this.__data__.set(r,tV),this}var Bw=rV;function nV(r){return this.__data__.has(r)}var jw=nV;function Fl(r){var e=-1,t=r==null?0:r.length;for(this.__data__=new ns;++e<t;)this.add(r[e])}Fl.prototype.add=Fl.prototype.push=Bw;Fl.prototype.has=jw;var $w=Fl;function iV(r,e){for(var t=-1,n=r==null?0:r.length;++t<n;)if(e(r[t],t,r))return!0;return!1}var qw=iV;function sV(r,e){return r.has(e)}var zw=sV;var oV=1,aV=2;function uV(r,e,t,n,s,a){var c=t&oV,h=r.length,f=e.length;if(h!=f&&!(c&&f>h))return!1;var m=a.get(r),_=a.get(e);if(m&&_)return m==e&&_==r;var E=-1,I=!0,k=t&aV?new $w:void 0;for(a.set(r,e),a.set(e,r);++E<h;){var B=r[E],G=e[E];if(n)var j=c?n(G,B,E,e,r,a):n(B,G,E,r,e,a);if(j!==void 0){if(j)continue;I=!1;break}if(k){if(!qw(e,function(J,ee){if(!zw(k,ee)&&(B===J||s(B,J,t,n,a)))return k.push(ee)})){I=!1;break}}else if(!(B===G||s(B,G,t,n,a))){I=!1;break}}return a.delete(r),a.delete(e),I}var Ul=uV;function cV(r){var e=-1,t=Array(r.size);return r.forEach(function(n,s){t[++e]=[s,n]}),t}var Gw=cV;function lV(r){var e=-1,t=Array(r.size);return r.forEach(function(n){t[++e]=n}),t}var Kw=lV;var hV=1,fV=2,dV="[object Boolean]",pV="[object Date]",mV="[object Error]",gV="[object Map]",_V="[object Number]",yV="[object RegExp]",vV="[object Set]",wV="[object String]",bV="[object Symbol]",TV="[object ArrayBuffer]",EV="[object DataView]",Ww=Nt?Nt.prototype:void 0,Md=Ww?Ww.valueOf:void 0;function IV(r,e,t,n,s,a,c){switch(t){case EV:if(r.byteLength!=e.byteLength||r.byteOffset!=e.byteOffset)return!1;r=r.buffer,e=e.buffer;case TV:return!(r.byteLength!=e.byteLength||!a(new Eo(r),new Eo(e)));case dV:case pV:case _V:return jr(+r,+e);case mV:return r.name==e.name&&r.message==e.message;case yV:case wV:return r==e+"";case gV:var h=Gw;case vV:var f=n&hV;if(h||(h=Kw),r.size!=e.size&&!f)return!1;var m=c.get(r);if(m)return m==e;n|=fV,c.set(r,e);var _=Ul(h(r),h(e),n,s,a,c);return c.delete(r),_;case bV:if(Md)return Md.call(r)==Md.call(e)}return!1}var Hw=IV;var xV=1,AV=Object.prototype,SV=AV.hasOwnProperty;function RV(r,e,t,n,s,a){var c=t&xV,h=nu(r),f=h.length,m=nu(e),_=m.length;if(f!=_&&!c)return!1;for(var E=f;E--;){var I=h[E];if(!(c?I in e:SV.call(e,I)))return!1}var k=a.get(r),B=a.get(e);if(k&&B)return k==e&&B==r;var G=!0;a.set(r,e),a.set(e,r);for(var j=c;++E<f;){I=h[E];var J=r[I],ee=e[I];if(n)var re=c?n(ee,J,I,e,r,a):n(J,ee,I,r,e,a);if(!(re===void 0?J===ee||s(J,ee,t,n,a):re)){G=!1;break}j||(j=I=="constructor")}if(G&&!j){var le=r.constructor,de=e.constructor;le!=de&&"constructor"in r&&"constructor"in e&&!(typeof le=="function"&&le instanceof le&&typeof de=="function"&&de instanceof de)&&(G=!1)}return a.delete(r),a.delete(e),G}var Qw=RV;var PV=1,Jw="[object Arguments]",Yw="[object Array]",Bl="[object Object]",CV=Object.prototype,Xw=CV.hasOwnProperty;function DV(r,e,t,n,s,a){var c=rt(r),h=rt(e),f=c?Yw:Ar(r),m=h?Yw:Ar(e);f=f==Jw?Bl:f,m=m==Jw?Bl:m;var _=f==Bl,E=m==Bl,I=f==m;if(I&&wn(r)){if(!wn(e))return!1;c=!0,_=!1}if(I&&!_)return a||(a=new di),c||mo(r)?Ul(r,e,t,n,s,a):Hw(r,e,f,t,n,s,a);if(!(t&PV)){var k=_&&Xw.call(r,"__wrapped__"),B=E&&Xw.call(e,"__wrapped__");if(k||B){var G=k?r.value():r,j=B?e.value():e;return a||(a=new di),s(G,j,t,n,a)}}return I?(a||(a=new di),Qw(r,e,t,n,s,a)):!1}var Zw=DV;function e0(r,e,t,n,s){return r===e?!0:r==null||e==null||!Vt(r)&&!Vt(e)?r!==r&&e!==e:Zw(r,e,t,n,e0,s)}var xo=e0;var OV=1,kV=2;function NV(r,e,t,n){var s=t.length,a=s,c=!n;if(r==null)return!a;for(r=Object(r);s--;){var h=t[s];if(c&&h[2]?h[1]!==r[h[0]]:!(h[0]in r))return!1}for(;++s<a;){h=t[s];var f=h[0],m=r[f],_=h[1];if(c&&h[2]){if(m===void 0&&!(f in r))return!1}else{var E=new di;if(n)var I=n(m,_,f,r,e,E);if(!(I===void 0?xo(_,m,OV|kV,n,E):I))return!1}}return!0}var t0=NV;function VV(r){return r===r&&!De(r)}var jl=VV;function LV(r){for(var e=At(r),t=e.length;t--;){var n=e[t],s=r[n];e[t]=[n,s,jl(s)]}return e}var r0=LV;function MV(r,e){return function(t){return t==null?!1:t[r]===e&&(e!==void 0||r in Object(t))}}var $l=MV;function FV(r){var e=r0(r);return e.length==1&&e[0][2]?$l(e[0][0],e[0][1]):function(t){return t===r||t0(t,r,e)}}var n0=FV;function UV(r,e){return r!=null&&e in Object(r)}var i0=UV;function BV(r,e,t){e=wo(e,r);for(var n=-1,s=e.length,a=!1;++n<s;){var c=$r(e[n]);if(!(a=r!=null&&t(r,c)))break;r=r[c]}return a||++n!=s?a:(s=r==null?0:r.length,!!s&&ho(s)&&ii(c,s)&&(rt(r)||fo(r)))}var s0=BV;function jV(r,e){return r!=null&&s0(r,e,i0)}var o0=jV;var $V=1,qV=2;function zV(r,e){return go(r)&&jl(e)?$l($r(r),e):function(t){var n=ru(t,r);return n===void 0&&n===e?o0(t,r):xo(e,n,$V|qV)}}var a0=zV;function GV(r){return function(e){return e==null?void 0:e[r]}}var u0=GV;function KV(r){return function(e){return Rl(e,r)}}var c0=KV;function WV(r){return go(r)?u0($r(r)):c0(r)}var l0=WV;function HV(r){return typeof r=="function"?r:r==null?ao:typeof r=="object"?rt(r)?a0(r[0],r[1]):n0(r):l0(r)}var h0=HV;function QV(r){return function(e,t,n){for(var s=-1,a=Object(e),c=n(e),h=c.length;h--;){var f=c[r?h:++s];if(t(a[f],f,a)===!1)break}return e}}var f0=QV;var JV=f0(),d0=JV;function YV(r,e){return r&&d0(r,e,At)}var p0=YV;var XV=function(){return Je.Date.now()},ql=XV;var ZV="Expected a function",eL=Math.max,tL=Math.min;function rL(r,e,t){var n,s,a,c,h,f,m=0,_=!1,E=!1,I=!0;if(typeof r!="function")throw new TypeError(ZV);e=Od(e)||0,De(t)&&(_=!!t.leading,E="maxWait"in t,a=E?eL(Od(t.maxWait)||0,e):a,I="trailing"in t?!!t.trailing:I);function k(ie){var C=n,A=s;return n=s=void 0,m=ie,c=r.apply(A,C),c}function B(ie){return m=ie,h=setTimeout(J,e),_?k(ie):c}function G(ie){var C=ie-f,A=ie-m,R=e-C;return E?tL(R,a-A):R}function j(ie){var C=ie-f,A=ie-m;return f===void 0||C>=e||C<0||E&&A>=a}function J(){var ie=ql();if(j(ie))return ee(ie);h=setTimeout(J,G(ie))}function ee(ie){return h=void 0,I&&n?k(ie):(n=s=void 0,c)}function re(){h!==void 0&&clearTimeout(h),m=0,n=f=s=h=void 0}function le(){return h===void 0?c:ee(ql())}function de(){var ie=ql(),C=j(ie);if(n=arguments,s=this,f=ie,C){if(h===void 0)return B(f);if(E)return clearTimeout(h),h=setTimeout(J,e),k(f)}return h===void 0&&(h=setTimeout(J,e)),c}return de.cancel=re,de.flush=le,de}var m0=rL;var g0=Object.prototype,nL=g0.hasOwnProperty,iL=vv(function(r,e){r=Object(r);var t=-1,n=e.length,s=n>2?e[2]:void 0;for(s&&wv(e[0],e[1],s)&&(n=1);++t<n;)for(var a=e[t],c=ui(a),h=-1,f=c.length;++h<f;){var m=c[h],_=r[m];(_===void 0||jr(_,g0[m])&&!nL.call(r,m))&&(r[m]=a[m])}return r}),zl=iL;var sL="[object Map]",oL="[object Set]",aL=Object.prototype,uL=aL.hasOwnProperty;function cL(r){if(r==null)return!0;if(oi(r)&&(rt(r)||typeof r=="string"||typeof r.splice=="function"||wn(r)||mo(r)||fo(r)))return!r.length;var e=Ar(r);if(e==sL||e==oL)return!r.size;if(ai(r))return!Sl(r).length;for(var t in r)if(uL.call(r,t))return!1;return!0}var Fd=cL;function lL(r,e){return xo(r,e)}var Ud=lL;function hL(r,e){var t={};return e=h0(e,3),p0(r,function(n,s,a){co(t,e(n,s,a),n)}),t}var Bd=hL;function fL(r,e,t,n){if(!De(r))return r;e=wo(e,r);for(var s=-1,a=e.length,c=a-1,h=r;h!=null&&++s<a;){var f=$r(e[s]),m=t;if(f==="__proto__"||f==="constructor"||f==="prototype")return r;if(s!=c){var _=h[f];m=n?n(_,f,h):void 0,m===void 0&&(m=De(_)?_:ii(e[s+1])?[]:{})}lo(h,f,m),h=h[f]}return r}var _0=fL;function dL(r,e,t){return r==null?r:_0(r,e,t)}var pi=dL;var pL="Expected a function";function mL(r,e,t){var n=!0,s=!0;if(typeof r!="function")throw new TypeError(pL);return De(t)&&(n="leading"in t?!!t.leading:n,s="trailing"in t?!!t.trailing:s),m0(r,e,{leading:n,maxWait:e,trailing:s})}var jd=mL;var v0=function(r){let e=[],t=0;for(let n=0;n<r.length;n++){let s=r.charCodeAt(n);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},gL=function(r){let e=[],t=0,n=0;for(;t<r.length;){let s=r[t++];if(s<128)e[n++]=String.fromCharCode(s);else if(s>191&&s<224){let a=r[t++];e[n++]=String.fromCharCode((s&31)<<6|a&63)}else if(s>239&&s<365){let a=r[t++],c=r[t++],h=r[t++],f=((s&7)<<18|(a&63)<<12|(c&63)<<6|h&63)-65536;e[n++]=String.fromCharCode(55296+(f>>10)),e[n++]=String.fromCharCode(56320+(f&1023))}else{let a=r[t++],c=r[t++];e[n++]=String.fromCharCode((s&15)<<12|(a&63)<<6|c&63)}}return e.join("")},w0={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(r,e){if(!Array.isArray(r))throw Error("encodeByteArray takes an array as a parameter");this.init_();let t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,n=[];for(let s=0;s<r.length;s+=3){let a=r[s],c=s+1<r.length,h=c?r[s+1]:0,f=s+2<r.length,m=f?r[s+2]:0,_=a>>2,E=(a&3)<<4|h>>4,I=(h&15)<<2|m>>6,k=m&63;f||(k=64,c||(I=64)),n.push(t[_],t[E],t[I],t[k])}return n.join("")},encodeString(r,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(r):this.encodeByteArray(v0(r),e)},decodeString(r,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(r):gL(this.decodeStringToByteArray(r,e))},decodeStringToByteArray(r,e){this.init_();let t=e?this.charToByteMapWebSafe_:this.charToByteMap_,n=[];for(let s=0;s<r.length;){let a=t[r.charAt(s++)],h=s<r.length?t[r.charAt(s)]:0;++s;let m=s<r.length?t[r.charAt(s)]:64;++s;let E=s<r.length?t[r.charAt(s)]:64;if(++s,a==null||h==null||m==null||E==null)throw new $d;let I=a<<2|h>>4;if(n.push(I),m!==64){let k=h<<4&240|m>>2;if(n.push(k),E!==64){let B=m<<6&192|E;n.push(B)}}}return n},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let r=0;r<this.ENCODED_VALS.length;r++)this.byteToCharMap_[r]=this.ENCODED_VALS.charAt(r),this.charToByteMap_[this.byteToCharMap_[r]]=r,this.byteToCharMapWebSafe_[r]=this.ENCODED_VALS_WEBSAFE.charAt(r),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[r]]=r,r>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(r)]=r,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(r)]=r)}}},$d=class extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}},_L=function(r){let e=v0(r);return w0.encodeByteArray(e,!0)},iu=function(r){return _L(r).replace(/\./g,"")},b0=function(r){try{return w0.decodeString(r,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function yL(){if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;throw new Error("Unable to locate global object.")}var vL=()=>yL().__FIREBASE_DEFAULTS__,wL=()=>{if(typeof process=="undefined"||typeof process.env=="undefined")return;let r=process.env.__FIREBASE_DEFAULTS__;if(r)return JSON.parse(r)},bL=()=>{if(typeof document=="undefined")return;let r;try{r=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}let e=r&&b0(r[1]);return e&&JSON.parse(e)},qd=()=>{try{return vL()||wL()||bL()}catch(r){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${r}`);return}},TL=r=>{var e,t;return(t=(e=qd())===null||e===void 0?void 0:e.emulatorHosts)===null||t===void 0?void 0:t[r]},T0=r=>{let e=TL(r);if(!e)return;let t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);let n=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),n]:[e.substring(0,t),n]},zd=()=>{var r;return(r=qd())===null||r===void 0?void 0:r.config};var Gl=class{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,n)=>{t?this.reject(t):this.resolve(n),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,n))}}};function E0(r,e){if(r.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');let t={alg:"none",type:"JWT"},n=e||"demo-project",s=r.iat||0,a=r.sub||r.user_id;if(!a)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");let c=Object.assign({iss:`https://securetoken.google.com/${n}`,aud:n,iat:s,exp:s+3600,auth_time:s,sub:a,user_id:a,firebase:{sign_in_provider:"custom",identities:{}}},r);return[iu(JSON.stringify(t)),iu(JSON.stringify(c)),""].join(".")}function I0(){return typeof navigator!="undefined"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function EL(){var r;let e=(r=qd())===null||r===void 0?void 0:r.forceEnvironment;if(e==="node")return!0;if(e==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function x0(){return!EL()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function Gd(){try{return typeof indexedDB=="object"}catch{return!1}}function A0(){return new Promise((r,e)=>{try{let t=!0,n="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(n);s.onsuccess=()=>{s.result.close(),t||self.indexedDB.deleteDatabase(n),r(!0)},s.onupgradeneeded=()=>{t=!1},s.onerror=()=>{var a;e(((a=s.error)===null||a===void 0?void 0:a.message)||"")}}catch(t){e(t)}})}var IL="FirebaseError",En=class r extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name=IL,Object.setPrototypeOf(this,r.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,su.prototype.create)}},su=class{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){let n=t[0]||{},s=`${this.service}/${e}`,a=this.errors[e],c=a?xL(a,n):"Error",h=`${this.serviceName}: ${c} (${s}).`;return new En(s,h,n)}};function xL(r,e){return r.replace(AL,(t,n)=>{let s=e[n];return s!=null?String(s):`<${n}?>`})}var AL=/\{\$([^}]+)}/g;function ou(r,e){if(r===e)return!0;let t=Object.keys(r),n=Object.keys(e);for(let s of t){if(!n.includes(s))return!1;let a=r[s],c=e[s];if(y0(a)&&y0(c)){if(!ou(a,c))return!1}else if(a!==c)return!1}for(let s of n)if(!t.includes(s))return!1;return!0}function y0(r){return r!==null&&typeof r=="object"}var M6=4*60*60*1e3;function In(r){return r&&r._delegate?r._delegate:r}var xn=class{constructor(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}};var ss="[DEFAULT]";var Kd=class{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){let t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){let n=new Gl;if(this.instancesDeferred.set(t,n),this.isInitialized(t)||this.shouldAutoInitialize())try{let s=this.getOrInitializeService({instanceIdentifier:t});s&&n.resolve(s)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;let n=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),s=(t=e==null?void 0:e.optional)!==null&&t!==void 0?t:!1;if(this.isInitialized(n)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:n})}catch(a){if(s)return null;throw a}else{if(s)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(RL(e))try{this.getOrInitializeService({instanceIdentifier:ss})}catch{}for(let[t,n]of this.instancesDeferred.entries()){let s=this.normalizeInstanceIdentifier(t);try{let a=this.getOrInitializeService({instanceIdentifier:s});n.resolve(a)}catch{}}}}clearInstance(e=ss){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){let e=Array.from(this.instances.values());await Promise.all([...e.filter(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...e.filter(t=>"_delete"in t).map(t=>t._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=ss){return this.instances.has(e)}getOptions(e=ss){return this.instancesOptions.get(e)||{}}initialize(e={}){let{options:t={}}=e,n=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);let s=this.getOrInitializeService({instanceIdentifier:n,options:t});for(let[a,c]of this.instancesDeferred.entries()){let h=this.normalizeInstanceIdentifier(a);n===h&&c.resolve(s)}return s}onInit(e,t){var n;let s=this.normalizeInstanceIdentifier(t),a=(n=this.onInitCallbacks.get(s))!==null&&n!==void 0?n:new Set;a.add(e),this.onInitCallbacks.set(s,a);let c=this.instances.get(s);return c&&e(c,s),()=>{a.delete(e)}}invokeOnInitCallbacks(e,t){let n=this.onInitCallbacks.get(t);if(n)for(let s of n)try{s(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let n=this.instances.get(e);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:SL(e),options:t}),this.instances.set(e,n),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(n,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,n)}catch{}return n||null}normalizeInstanceIdentifier(e=ss){return this.component?this.component.multipleInstances?e:ss:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}};function SL(r){return r===ss?void 0:r}function RL(r){return r.instantiationMode==="EAGER"}var Kl=class{constructor(e){this.name=e,this.providers=new Map}addComponent(e){let t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);let t=new Kd(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}};var PL=[],Se;(function(r){r[r.DEBUG=0]="DEBUG",r[r.VERBOSE=1]="VERBOSE",r[r.INFO=2]="INFO",r[r.WARN=3]="WARN",r[r.ERROR=4]="ERROR",r[r.SILENT=5]="SILENT"})(Se||(Se={}));var CL={debug:Se.DEBUG,verbose:Se.VERBOSE,info:Se.INFO,warn:Se.WARN,error:Se.ERROR,silent:Se.SILENT},DL=Se.INFO,OL={[Se.DEBUG]:"log",[Se.VERBOSE]:"log",[Se.INFO]:"info",[Se.WARN]:"warn",[Se.ERROR]:"error"},kL=(r,e,...t)=>{if(e<r.logLevel)return;let n=new Date().toISOString(),s=OL[e];if(s)console[s](`[${n}] ${r.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)},Ao=class{constructor(e){this.name=e,this._logLevel=DL,this._logHandler=kL,this._userLogHandler=null,PL.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in Se))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?CL[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,Se.DEBUG,...e),this._logHandler(this,Se.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,Se.VERBOSE,...e),this._logHandler(this,Se.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,Se.INFO,...e),this._logHandler(this,Se.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,Se.WARN,...e),this._logHandler(this,Se.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,Se.ERROR,...e),this._logHandler(this,Se.ERROR,...e)}};var NL=(r,e)=>e.some(t=>r instanceof t),S0,R0;function VL(){return S0||(S0=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function LL(){return R0||(R0=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var P0=new WeakMap,Hd=new WeakMap,C0=new WeakMap,Wd=new WeakMap,Jd=new WeakMap;function ML(r){let e=new Promise((t,n)=>{let s=()=>{r.removeEventListener("success",a),r.removeEventListener("error",c)},a=()=>{t(zr(r.result)),s()},c=()=>{n(r.error),s()};r.addEventListener("success",a),r.addEventListener("error",c)});return e.then(t=>{t instanceof IDBCursor&&P0.set(t,r)}).catch(()=>{}),Jd.set(e,r),e}function FL(r){if(Hd.has(r))return;let e=new Promise((t,n)=>{let s=()=>{r.removeEventListener("complete",a),r.removeEventListener("error",c),r.removeEventListener("abort",c)},a=()=>{t(),s()},c=()=>{n(r.error||new DOMException("AbortError","AbortError")),s()};r.addEventListener("complete",a),r.addEventListener("error",c),r.addEventListener("abort",c)});Hd.set(r,e)}var Qd={get(r,e,t){if(r instanceof IDBTransaction){if(e==="done")return Hd.get(r);if(e==="objectStoreNames")return r.objectStoreNames||C0.get(r);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return zr(r[e])},set(r,e,t){return r[e]=t,!0},has(r,e){return r instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in r}};function D0(r){Qd=r(Qd)}function UL(r){return r===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){let n=r.call(Wl(this),e,...t);return C0.set(n,e.sort?e.sort():[e]),zr(n)}:LL().includes(r)?function(...e){return r.apply(Wl(this),e),zr(P0.get(this))}:function(...e){return zr(r.apply(Wl(this),e))}}function BL(r){return typeof r=="function"?UL(r):(r instanceof IDBTransaction&&FL(r),NL(r,VL())?new Proxy(r,Qd):r)}function zr(r){if(r instanceof IDBRequest)return ML(r);if(Wd.has(r))return Wd.get(r);let e=BL(r);return e!==r&&(Wd.set(r,e),Jd.set(e,r)),e}var Wl=r=>Jd.get(r);function k0(r,e,{blocked:t,upgrade:n,blocking:s,terminated:a}={}){let c=indexedDB.open(r,e),h=zr(c);return n&&c.addEventListener("upgradeneeded",f=>{n(zr(c.result),f.oldVersion,f.newVersion,zr(c.transaction),f)}),t&&c.addEventListener("blocked",f=>t(f.oldVersion,f.newVersion,f)),h.then(f=>{a&&f.addEventListener("close",()=>a()),s&&f.addEventListener("versionchange",m=>s(m.oldVersion,m.newVersion,m))}).catch(()=>{}),h}var jL=["get","getKey","getAll","getAllKeys","count"],$L=["put","add","delete","clear"],Yd=new Map;function O0(r,e){if(!(r instanceof IDBDatabase&&!(e in r)&&typeof e=="string"))return;if(Yd.get(e))return Yd.get(e);let t=e.replace(/FromIndex$/,""),n=e!==t,s=$L.includes(t);if(!(t in(n?IDBIndex:IDBObjectStore).prototype)||!(s||jL.includes(t)))return;let a=async function(c,...h){let f=this.transaction(c,s?"readwrite":"readonly"),m=f.store;return n&&(m=m.index(h.shift())),(await Promise.all([m[t](...h),s&&f.done]))[0]};return Yd.set(e,a),a}D0(r=>({...r,get:(e,t,n)=>O0(e,t)||r.get(e,t,n),has:(e,t)=>!!O0(e,t)||r.has(e,t)}));var Zd=class{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(qL(t)){let n=t.getImmediate();return`${n.library}/${n.version}`}else return null}).filter(t=>t).join(" ")}};function qL(r){let e=r.getComponent();return(e==null?void 0:e.type)==="VERSION"}var ep="@firebase/app",N0="0.11.1";var An=new Ao("@firebase/app"),zL="@firebase/app-compat",GL="@firebase/analytics-compat",KL="@firebase/analytics",WL="@firebase/app-check-compat",HL="@firebase/app-check",QL="@firebase/auth",JL="@firebase/auth-compat",YL="@firebase/database",XL="@firebase/data-connect",ZL="@firebase/database-compat",e2="@firebase/functions",t2="@firebase/functions-compat",r2="@firebase/installations",n2="@firebase/installations-compat",i2="@firebase/messaging",s2="@firebase/messaging-compat",o2="@firebase/performance",a2="@firebase/performance-compat",u2="@firebase/remote-config",c2="@firebase/remote-config-compat",l2="@firebase/storage",h2="@firebase/storage-compat",f2="@firebase/firestore",d2="@firebase/vertexai",p2="@firebase/firestore-compat",m2="firebase",g2="11.3.1";var tp="[DEFAULT]",_2={[ep]:"fire-core",[zL]:"fire-core-compat",[KL]:"fire-analytics",[GL]:"fire-analytics-compat",[HL]:"fire-app-check",[WL]:"fire-app-check-compat",[QL]:"fire-auth",[JL]:"fire-auth-compat",[YL]:"fire-rtdb",[XL]:"fire-data-connect",[ZL]:"fire-rtdb-compat",[e2]:"fire-fn",[t2]:"fire-fn-compat",[r2]:"fire-iid",[n2]:"fire-iid-compat",[i2]:"fire-fcm",[s2]:"fire-fcm-compat",[o2]:"fire-perf",[a2]:"fire-perf-compat",[u2]:"fire-rc",[c2]:"fire-rc-compat",[l2]:"fire-gcs",[h2]:"fire-gcs-compat",[f2]:"fire-fst",[p2]:"fire-fst-compat",[d2]:"fire-vertex","fire-js":"fire-js",[m2]:"fire-js-all"};var Hl=new Map,y2=new Map,rp=new Map;function V0(r,e){try{r.container.addComponent(e)}catch(t){An.debug(`Component ${e.name} failed to register with FirebaseApp ${r.name}`,t)}}function au(r){let e=r.name;if(rp.has(e))return An.debug(`There were multiple attempts to register component ${e}.`),!1;rp.set(e,r);for(let t of Hl.values())V0(t,r);for(let t of y2.values())V0(t,r);return!0}function U0(r,e){let t=r.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),r.container.getProvider(e)}function B0(r){return r==null?!1:r.settings!==void 0}var v2={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},mi=new su("app","Firebase",v2);var np=class{constructor(e,t,n){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new xn("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw mi.create("app-deleted",{appName:this._name})}};var j0=g2;function op(r,e={}){let t=r;typeof e!="object"&&(e={name:e});let n=Object.assign({name:tp,automaticDataCollectionEnabled:!1},e),s=n.name;if(typeof s!="string"||!s)throw mi.create("bad-app-name",{appName:String(s)});if(t||(t=zd()),!t)throw mi.create("no-options");let a=Hl.get(s);if(a){if(ou(t,a.options)&&ou(n,a.config))return a;throw mi.create("duplicate-app",{appName:s})}let c=new Kl(s);for(let f of rp.values())c.addComponent(f);let h=new np(t,n,c);return Hl.set(s,h),h}function $0(r=tp){let e=Hl.get(r);if(!e&&r===tp&&zd())return op();if(!e)throw mi.create("no-app",{appName:r});return e}function gi(r,e,t){var n;let s=(n=_2[r])!==null&&n!==void 0?n:r;t&&(s+=`-${t}`);let a=s.match(/\s|\//),c=e.match(/\s|\//);if(a||c){let h=[`Unable to register library "${s}" with version "${e}":`];a&&h.push(`library name "${s}" contains illegal characters (whitespace or "/")`),a&&c&&h.push("and"),c&&h.push(`version name "${e}" contains illegal characters (whitespace or "/")`),An.warn(h.join(" "));return}au(new xn(`${s}-version`,()=>({library:s,version:e}),"VERSION"))}var w2="firebase-heartbeat-database",b2=1,uu="firebase-heartbeat-store",Xd=null;function q0(){return Xd||(Xd=k0(w2,b2,{upgrade:(r,e)=>{switch(e){case 0:try{r.createObjectStore(uu)}catch(t){console.warn(t)}}}}).catch(r=>{throw mi.create("idb-open",{originalErrorMessage:r.message})})),Xd}async function T2(r){try{let t=(await q0()).transaction(uu),n=await t.objectStore(uu).get(z0(r));return await t.done,n}catch(e){if(e instanceof En)An.warn(e.message);else{let t=mi.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});An.warn(t.message)}}}async function L0(r,e){try{let n=(await q0()).transaction(uu,"readwrite");await n.objectStore(uu).put(e,z0(r)),await n.done}catch(t){if(t instanceof En)An.warn(t.message);else{let n=mi.create("idb-set",{originalErrorMessage:t==null?void 0:t.message});An.warn(n.message)}}}function z0(r){return`${r.name}!${r.options.appId}`}var E2=1024,I2=30,ip=class{constructor(e){this.container=e,this._heartbeatsCache=null;let t=this.container.getProvider("app").getImmediate();this._storage=new sp(t),this._heartbeatsCachePromise=this._storage.read().then(n=>(this._heartbeatsCache=n,n))}async triggerHeartbeat(){var e,t;try{let s=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),a=M0();if(((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((t=this._heartbeatsCache)===null||t===void 0?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===a||this._heartbeatsCache.heartbeats.some(c=>c.date===a))return;if(this._heartbeatsCache.heartbeats.push({date:a,agent:s}),this._heartbeatsCache.heartbeats.length>I2){let c=A2(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(c,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(n){An.warn(n)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";let t=M0(),{heartbeatsToSend:n,unsentEntries:s}=x2(this._heartbeatsCache.heartbeats),a=iu(JSON.stringify({version:2,heartbeats:n}));return this._heartbeatsCache.lastSentHeartbeatDate=t,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),a}catch(t){return An.warn(t),""}}};function M0(){return new Date().toISOString().substring(0,10)}function x2(r,e=E2){let t=[],n=r.slice();for(let s of r){let a=t.find(c=>c.agent===s.agent);if(a){if(a.dates.push(s.date),F0(t)>e){a.dates.pop();break}}else if(t.push({agent:s.agent,dates:[s.date]}),F0(t)>e){t.pop();break}n=n.slice(1)}return{heartbeatsToSend:t,unsentEntries:n}}var sp=class{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return Gd()?A0().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){let t=await T2(this.app);return t!=null&&t.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){let s=await this.read();return L0(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:s.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){var t;if(await this._canUseIndexedDBPromise){let s=await this.read();return L0(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:s.lastSentHeartbeatDate,heartbeats:[...s.heartbeats,...e.heartbeats]})}else return}};function F0(r){return iu(JSON.stringify({version:2,heartbeats:r})).length}function A2(r){if(r.length===0)return-1;let e=0,t=r[0].date;for(let n=1;n<r.length;n++)r[n].date<t&&(t=r[n].date,e=n);return e}function S2(r){au(new xn("platform-logger",e=>new Zd(e),"PRIVATE")),au(new xn("heartbeat",e=>new ip(e),"PRIVATE")),gi(ep,N0,r),gi(ep,N0,"esm2017"),gi("fire-js","")}S2("");var R2="firebase",P2="11.3.1";gi(R2,P2,"app");var G0=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},K0={};var Sn,ap;(function(){var r;function e(C,A){function R(){}R.prototype=A.prototype,C.D=A.prototype,C.prototype=new R,C.prototype.constructor=C,C.C=function(D,V,M){for(var S=Array(arguments.length-2),dr=2;dr<arguments.length;dr++)S[dr-2]=arguments[dr];return A.prototype[V].apply(D,S)}}function t(){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()}e(n,t),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 s(C,A,R){R||(R=0);var D=Array(16);if(typeof A=="string")for(var V=0;16>V;++V)D[V]=A.charCodeAt(R++)|A.charCodeAt(R++)<<8|A.charCodeAt(R++)<<16|A.charCodeAt(R++)<<24;else for(V=0;16>V;++V)D[V]=A[R++]|A[R++]<<8|A[R++]<<16|A[R++]<<24;A=C.g[0],R=C.g[1],V=C.g[2];var M=C.g[3],S=A+(M^R&(V^M))+D[0]+3614090360&4294967295;A=R+(S<<7&4294967295|S>>>25),S=M+(V^A&(R^V))+D[1]+3905402710&4294967295,M=A+(S<<12&4294967295|S>>>20),S=V+(R^M&(A^R))+D[2]+606105819&4294967295,V=M+(S<<17&4294967295|S>>>15),S=R+(A^V&(M^A))+D[3]+3250441966&4294967295,R=V+(S<<22&4294967295|S>>>10),S=A+(M^R&(V^M))+D[4]+4118548399&4294967295,A=R+(S<<7&4294967295|S>>>25),S=M+(V^A&(R^V))+D[5]+1200080426&4294967295,M=A+(S<<12&4294967295|S>>>20),S=V+(R^M&(A^R))+D[6]+2821735955&4294967295,V=M+(S<<17&4294967295|S>>>15),S=R+(A^V&(M^A))+D[7]+4249261313&4294967295,R=V+(S<<22&4294967295|S>>>10),S=A+(M^R&(V^M))+D[8]+1770035416&4294967295,A=R+(S<<7&4294967295|S>>>25),S=M+(V^A&(R^V))+D[9]+2336552879&4294967295,M=A+(S<<12&4294967295|S>>>20),S=V+(R^M&(A^R))+D[10]+4294925233&4294967295,V=M+(S<<17&4294967295|S>>>15),S=R+(A^V&(M^A))+D[11]+2304563134&4294967295,R=V+(S<<22&4294967295|S>>>10),S=A+(M^R&(V^M))+D[12]+1804603682&4294967295,A=R+(S<<7&4294967295|S>>>25),S=M+(V^A&(R^V))+D[13]+4254626195&4294967295,M=A+(S<<12&4294967295|S>>>20),S=V+(R^M&(A^R))+D[14]+2792965006&4294967295,V=M+(S<<17&4294967295|S>>>15),S=R+(A^V&(M^A))+D[15]+1236535329&4294967295,R=V+(S<<22&4294967295|S>>>10),S=A+(V^M&(R^V))+D[1]+4129170786&4294967295,A=R+(S<<5&4294967295|S>>>27),S=M+(R^V&(A^R))+D[6]+3225465664&4294967295,M=A+(S<<9&4294967295|S>>>23),S=V+(A^R&(M^A))+D[11]+643717713&4294967295,V=M+(S<<14&4294967295|S>>>18),S=R+(M^A&(V^M))+D[0]+3921069994&4294967295,R=V+(S<<20&4294967295|S>>>12),S=A+(V^M&(R^V))+D[5]+3593408605&4294967295,A=R+(S<<5&4294967295|S>>>27),S=M+(R^V&(A^R))+D[10]+38016083&4294967295,M=A+(S<<9&4294967295|S>>>23),S=V+(A^R&(M^A))+D[15]+3634488961&4294967295,V=M+(S<<14&4294967295|S>>>18),S=R+(M^A&(V^M))+D[4]+3889429448&4294967295,R=V+(S<<20&4294967295|S>>>12),S=A+(V^M&(R^V))+D[9]+568446438&4294967295,A=R+(S<<5&4294967295|S>>>27),S=M+(R^V&(A^R))+D[14]+3275163606&4294967295,M=A+(S<<9&4294967295|S>>>23),S=V+(A^R&(M^A))+D[3]+4107603335&4294967295,V=M+(S<<14&4294967295|S>>>18),S=R+(M^A&(V^M))+D[8]+1163531501&4294967295,R=V+(S<<20&4294967295|S>>>12),S=A+(V^M&(R^V))+D[13]+2850285829&4294967295,A=R+(S<<5&4294967295|S>>>27),S=M+(R^V&(A^R))+D[2]+4243563512&4294967295,M=A+(S<<9&4294967295|S>>>23),S=V+(A^R&(M^A))+D[7]+1735328473&4294967295,V=M+(S<<14&4294967295|S>>>18),S=R+(M^A&(V^M))+D[12]+2368359562&4294967295,R=V+(S<<20&4294967295|S>>>12),S=A+(R^V^M)+D[5]+4294588738&4294967295,A=R+(S<<4&4294967295|S>>>28),S=M+(A^R^V)+D[8]+2272392833&4294967295,M=A+(S<<11&4294967295|S>>>21),S=V+(M^A^R)+D[11]+1839030562&4294967295,V=M+(S<<16&4294967295|S>>>16),S=R+(V^M^A)+D[14]+4259657740&4294967295,R=V+(S<<23&4294967295|S>>>9),S=A+(R^V^M)+D[1]+2763975236&4294967295,A=R+(S<<4&4294967295|S>>>28),S=M+(A^R^V)+D[4]+1272893353&4294967295,M=A+(S<<11&4294967295|S>>>21),S=V+(M^A^R)+D[7]+4139469664&4294967295,V=M+(S<<16&4294967295|S>>>16),S=R+(V^M^A)+D[10]+3200236656&4294967295,R=V+(S<<23&4294967295|S>>>9),S=A+(R^V^M)+D[13]+681279174&4294967295,A=R+(S<<4&4294967295|S>>>28),S=M+(A^R^V)+D[0]+3936430074&4294967295,M=A+(S<<11&4294967295|S>>>21),S=V+(M^A^R)+D[3]+3572445317&4294967295,V=M+(S<<16&4294967295|S>>>16),S=R+(V^M^A)+D[6]+76029189&4294967295,R=V+(S<<23&4294967295|S>>>9),S=A+(R^V^M)+D[9]+3654602809&4294967295,A=R+(S<<4&4294967295|S>>>28),S=M+(A^R^V)+D[12]+3873151461&4294967295,M=A+(S<<11&4294967295|S>>>21),S=V+(M^A^R)+D[15]+530742520&4294967295,V=M+(S<<16&4294967295|S>>>16),S=R+(V^M^A)+D[2]+3299628645&4294967295,R=V+(S<<23&4294967295|S>>>9),S=A+(V^(R|~M))+D[0]+4096336452&4294967295,A=R+(S<<6&4294967295|S>>>26),S=M+(R^(A|~V))+D[7]+1126891415&4294967295,M=A+(S<<10&4294967295|S>>>22),S=V+(A^(M|~R))+D[14]+2878612391&4294967295,V=M+(S<<15&4294967295|S>>>17),S=R+(M^(V|~A))+D[5]+4237533241&4294967295,R=V+(S<<21&4294967295|S>>>11),S=A+(V^(R|~M))+D[12]+1700485571&4294967295,A=R+(S<<6&4294967295|S>>>26),S=M+(R^(A|~V))+D[3]+2399980690&4294967295,M=A+(S<<10&4294967295|S>>>22),S=V+(A^(M|~R))+D[10]+4293915773&4294967295,V=M+(S<<15&4294967295|S>>>17),S=R+(M^(V|~A))+D[1]+2240044497&4294967295,R=V+(S<<21&4294967295|S>>>11),S=A+(V^(R|~M))+D[8]+1873313359&4294967295,A=R+(S<<6&4294967295|S>>>26),S=M+(R^(A|~V))+D[15]+4264355552&4294967295,M=A+(S<<10&4294967295|S>>>22),S=V+(A^(M|~R))+D[6]+2734768916&4294967295,V=M+(S<<15&4294967295|S>>>17),S=R+(M^(V|~A))+D[13]+1309151649&4294967295,R=V+(S<<21&4294967295|S>>>11),S=A+(V^(R|~M))+D[4]+4149444226&4294967295,A=R+(S<<6&4294967295|S>>>26),S=M+(R^(A|~V))+D[11]+3174756917&4294967295,M=A+(S<<10&4294967295|S>>>22),S=V+(A^(M|~R))+D[2]+718787259&4294967295,V=M+(S<<15&4294967295|S>>>17),S=R+(M^(V|~A))+D[9]+3951481745&4294967295,C.g[0]=C.g[0]+A&4294967295,C.g[1]=C.g[1]+(V+(S<<21&4294967295|S>>>11))&4294967295,C.g[2]=C.g[2]+V&4294967295,C.g[3]=C.g[3]+M&4294967295}n.prototype.u=function(C,A){A===void 0&&(A=C.length);for(var R=A-this.blockSize,D=this.B,V=this.h,M=0;M<A;){if(V==0)for(;M<=R;)s(this,C,M),M+=this.blockSize;if(typeof C=="string"){for(;M<A;)if(D[V++]=C.charCodeAt(M++),V==this.blockSize){s(this,D),V=0;break}}else for(;M<A;)if(D[V++]=C[M++],V==this.blockSize){s(this,D),V=0;break}}this.h=V,this.o+=A},n.prototype.v=function(){var C=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);C[0]=128;for(var A=1;A<C.length-8;++A)C[A]=0;var R=8*this.o;for(A=C.length-8;A<C.length;++A)C[A]=R&255,R/=256;for(this.u(C),C=Array(16),A=R=0;4>A;++A)for(var D=0;32>D;D+=8)C[R++]=this.g[A]>>>D&255;return C};function a(C,A){var R=h;return Object.prototype.hasOwnProperty.call(R,C)?R[C]:R[C]=A(C)}function c(C,A){this.h=A;for(var R=[],D=!0,V=C.length-1;0<=V;V--){var M=C[V]|0;D&&M==A||(R[V]=M,D=!1)}this.g=R}var h={};function f(C){return-128<=C&&128>C?a(C,function(A){return new c([A|0],0>A?-1:0)}):new c([C|0],0>C?-1:0)}function m(C){if(isNaN(C)||!isFinite(C))return E;if(0>C)return j(m(-C));for(var A=[],R=1,D=0;C>=R;D++)A[D]=C/R|0,R*=4294967296;return new c(A,0)}function _(C,A){if(C.length==0)throw Error("number format error: empty string");if(A=A||10,2>A||36<A)throw Error("radix out of range: "+A);if(C.charAt(0)=="-")return j(_(C.substring(1),A));if(0<=C.indexOf("-"))throw Error('number format error: interior "-" character');for(var R=m(Math.pow(A,8)),D=E,V=0;V<C.length;V+=8){var M=Math.min(8,C.length-V),S=parseInt(C.substring(V,V+M),A);8>M?(M=m(Math.pow(A,M)),D=D.j(M).add(m(S))):(D=D.j(R),D=D.add(m(S)))}return D}var E=f(0),I=f(1),k=f(16777216);r=c.prototype,r.m=function(){if(G(this))return-j(this).m();for(var C=0,A=1,R=0;R<this.g.length;R++){var D=this.i(R);C+=(0<=D?D:4294967296+D)*A,A*=4294967296}return C},r.toString=function(C){if(C=C||10,2>C||36<C)throw Error("radix out of range: "+C);if(B(this))return"0";if(G(this))return"-"+j(this).toString(C);for(var A=m(Math.pow(C,6)),R=this,D="";;){var V=le(R,A).g;R=J(R,V.j(A));var M=((0<R.g.length?R.g[0]:R.h)>>>0).toString(C);if(R=V,B(R))return M+D;for(;6>M.length;)M="0"+M;D=M+D}},r.i=function(C){return 0>C?0:C<this.g.length?this.g[C]:this.h};function B(C){if(C.h!=0)return!1;for(var A=0;A<C.g.length;A++)if(C.g[A]!=0)return!1;return!0}function G(C){return C.h==-1}r.l=function(C){return C=J(this,C),G(C)?-1:B(C)?0:1};function j(C){for(var A=C.g.length,R=[],D=0;D<A;D++)R[D]=~C.g[D];return new c(R,~C.h).add(I)}r.abs=function(){return G(this)?j(this):this},r.add=function(C){for(var A=Math.max(this.g.length,C.g.length),R=[],D=0,V=0;V<=A;V++){var M=D+(this.i(V)&65535)+(C.i(V)&65535),S=(M>>>16)+(this.i(V)>>>16)+(C.i(V)>>>16);D=S>>>16,M&=65535,S&=65535,R[V]=S<<16|M}return new c(R,R[R.length-1]&-2147483648?-1:0)};function J(C,A){return C.add(j(A))}r.j=function(C){if(B(this)||B(C))return E;if(G(this))return G(C)?j(this).j(j(C)):j(j(this).j(C));if(G(C))return j(this.j(j(C)));if(0>this.l(k)&&0>C.l(k))return m(this.m()*C.m());for(var A=this.g.length+C.g.length,R=[],D=0;D<2*A;D++)R[D]=0;for(D=0;D<this.g.length;D++)for(var V=0;V<C.g.length;V++){var M=this.i(D)>>>16,S=this.i(D)&65535,dr=C.i(V)>>>16,Wt=C.i(V)&65535;R[2*D+2*V]+=S*Wt,ee(R,2*D+2*V),R[2*D+2*V+1]+=M*Wt,ee(R,2*D+2*V+1),R[2*D+2*V+1]+=S*dr,ee(R,2*D+2*V+1),R[2*D+2*V+2]+=M*dr,ee(R,2*D+2*V+2)}for(D=0;D<A;D++)R[D]=R[2*D+1]<<16|R[2*D];for(D=A;D<2*A;D++)R[D]=0;return new c(R,0)};function ee(C,A){for(;(C[A]&65535)!=C[A];)C[A+1]+=C[A]>>>16,C[A]&=65535,A++}function re(C,A){this.g=C,this.h=A}function le(C,A){if(B(A))throw Error("division by zero");if(B(C))return new re(E,E);if(G(C))return A=le(j(C),A),new re(j(A.g),j(A.h));if(G(A))return A=le(C,j(A)),new re(j(A.g),A.h);if(30<C.g.length){if(G(C)||G(A))throw Error("slowDivide_ only works with positive integers.");for(var R=I,D=A;0>=D.l(C);)R=de(R),D=de(D);var V=ie(R,1),M=ie(D,1);for(D=ie(D,2),R=ie(R,2);!B(D);){var S=M.add(D);0>=S.l(C)&&(V=V.add(R),M=S),D=ie(D,1),R=ie(R,1)}return A=J(C,V.j(A)),new re(V,A)}for(V=E;0<=C.l(A);){for(R=Math.max(1,Math.floor(C.m()/A.m())),D=Math.ceil(Math.log(R)/Math.LN2),D=48>=D?1:Math.pow(2,D-48),M=m(R),S=M.j(A);G(S)||0<S.l(C);)R-=D,M=m(R),S=M.j(A);B(M)&&(M=I),V=V.add(M),C=J(C,S)}return new re(V,C)}r.A=function(C){return le(this,C).h},r.and=function(C){for(var A=Math.max(this.g.length,C.g.length),R=[],D=0;D<A;D++)R[D]=this.i(D)&C.i(D);return new c(R,this.h&C.h)},r.or=function(C){for(var A=Math.max(this.g.length,C.g.length),R=[],D=0;D<A;D++)R[D]=this.i(D)|C.i(D);return new c(R,this.h|C.h)},r.xor=function(C){for(var A=Math.max(this.g.length,C.g.length),R=[],D=0;D<A;D++)R[D]=this.i(D)^C.i(D);return new c(R,this.h^C.h)};function de(C){for(var A=C.g.length+1,R=[],D=0;D<A;D++)R[D]=C.i(D)<<1|C.i(D-1)>>>31;return new c(R,C.h)}function ie(C,A){var R=A>>5;A%=32;for(var D=C.g.length-R,V=[],M=0;M<D;M++)V[M]=0<A?C.i(M+R)>>>A|C.i(M+R+1)<<32-A:C.i(M+R);return new c(V,C.h)}n.prototype.digest=n.prototype.v,n.prototype.reset=n.prototype.s,n.prototype.update=n.prototype.u,ap=K0.Md5=n,c.prototype.add=c.prototype.add,c.prototype.multiply=c.prototype.j,c.prototype.modulo=c.prototype.A,c.prototype.compare=c.prototype.l,c.prototype.toNumber=c.prototype.m,c.prototype.toString=c.prototype.toString,c.prototype.getBits=c.prototype.i,c.fromNumber=m,c.fromString=_,Sn=K0.Integer=c}).apply(typeof G0!="undefined"?G0:typeof self!="undefined"?self:typeof window!="undefined"?window:{});var Ql=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},Rn={};var up,C2,So,cp,cu,Jl,lp,hp,fp;(function(){var r,e=typeof Object.defineProperties=="function"?Object.defineProperty:function(u,d,g){return u==Array.prototype||u==Object.prototype||(u[d]=g.value),u};function t(u){u=[typeof globalThis=="object"&&globalThis,u,typeof window=="object"&&window,typeof self=="object"&&self,typeof Ql=="object"&&Ql];for(var d=0;d<u.length;++d){var g=u[d];if(g&&g.Math==Math)return g}throw Error("Cannot find global object")}var n=t(this);function s(u,d){if(d)e:{var g=n;u=u.split(".");for(var b=0;b<u.length-1;b++){var L=u[b];if(!(L in g))break e;g=g[L]}u=u[u.length-1],b=g[u],d=d(b),d!=b&&d!=null&&e(g,u,{configurable:!0,writable:!0,value:d})}}function a(u,d){u instanceof String&&(u+="");var g=0,b=!1,L={next:function(){if(!b&&g<u.length){var F=g++;return{value:d(F,u[F]),done:!1}}return b=!0,{done:!0,value:void 0}}};return L[Symbol.iterator]=function(){return L},L}s("Array.prototype.values",function(u){return u||function(){return a(this,function(d,g){return g})}});var c=c||{},h=this||self;function f(u){var d=typeof u;return d=d!="object"?d:u?Array.isArray(u)?"array":d:"null",d=="array"||d=="object"&&typeof u.length=="number"}function m(u){var d=typeof u;return d=="object"&&u!=null||d=="function"}function _(u,d,g){return u.call.apply(u.bind,arguments)}function E(u,d,g){if(!u)throw Error();if(2<arguments.length){var b=Array.prototype.slice.call(arguments,2);return function(){var L=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(L,b),u.apply(d,L)}}return function(){return u.apply(d,arguments)}}function I(u,d,g){return I=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?_:E,I.apply(null,arguments)}function k(u,d){var g=Array.prototype.slice.call(arguments,1);return function(){var b=g.slice();return b.push.apply(b,arguments),u.apply(this,b)}}function B(u,d){function g(){}g.prototype=d.prototype,u.aa=d.prototype,u.prototype=new g,u.prototype.constructor=u,u.Qb=function(b,L,F){for(var Q=Array(arguments.length-2),_e=2;_e<arguments.length;_e++)Q[_e-2]=arguments[_e];return d.prototype[L].apply(b,Q)}}function G(u){let d=u.length;if(0<d){let g=Array(d);for(let b=0;b<d;b++)g[b]=u[b];return g}return[]}function j(u,d){for(let g=1;g<arguments.length;g++){let b=arguments[g];if(f(b)){let L=u.length||0,F=b.length||0;u.length=L+F;for(let Q=0;Q<F;Q++)u[L+Q]=b[Q]}else u.push(b)}}class J{constructor(d,g){this.i=d,this.j=g,this.h=0,this.g=null}get(){let d;return 0<this.h?(this.h--,d=this.g,this.g=d.next,d.next=null):d=this.i(),d}}function ee(u){return/^[\s\xa0]*$/.test(u)}function re(){var u=h.navigator;return u&&(u=u.userAgent)?u:""}function le(u){return le[" "](u),u}le[" "]=function(){};var de=re().indexOf("Gecko")!=-1&&!(re().toLowerCase().indexOf("webkit")!=-1&&re().indexOf("Edge")==-1)&&!(re().indexOf("Trident")!=-1||re().indexOf("MSIE")!=-1)&&re().indexOf("Edge")==-1;function ie(u,d,g){for(let b in u)d.call(g,u[b],b,u)}function C(u,d){for(let g in u)d.call(void 0,u[g],g,u)}function A(u){let d={};for(let g in u)d[g]=u[g];return d}let R="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function D(u,d){let g,b;for(let L=1;L<arguments.length;L++){b=arguments[L];for(g in b)u[g]=b[g];for(let F=0;F<R.length;F++)g=R[F],Object.prototype.hasOwnProperty.call(b,g)&&(u[g]=b[g])}}function V(u){var d=1;u=u.split(":");let g=[];for(;0<d&&u.length;)g.push(u.shift()),d--;return u.length&&g.push(u.join(":")),g}function M(u){h.setTimeout(()=>{throw u},0)}function S(){var u=Lt;let d=null;return u.g&&(d=u.g,u.g=u.g.next,u.g||(u.h=null),d.next=null),d}class dr{constructor(){this.h=this.g=null}add(d,g){let b=Wt.get();b.set(d,g),this.h?this.h.next=b:this.g=b,this.h=b}}var Wt=new J(()=>new Pr,u=>u.reset());class Pr{constructor(){this.next=this.g=this.h=null}set(d,g){this.h=d,this.g=g,this.next=null}reset(){this.next=this.g=this.h=null}}let Ai,Cr=!1,Lt=new dr,ac=()=>{let u=h.Promise.resolve(void 0);Ai=()=>{u.then(vf)}};var vf=()=>{for(var u;u=S();){try{u.h.call(u.g)}catch(g){M(g)}var d=Wt;d.j(u),100>d.h&&(d.h++,u.next=d.g,d.g=u)}Cr=!1};function Dr(){this.s=this.s,this.C=this.C}Dr.prototype.s=!1,Dr.prototype.ma=function(){this.s||(this.s=!0,this.N())},Dr.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function Ke(u,d){this.type=u,this.g=this.target=d,this.defaultPrevented=!1}Ke.prototype.h=function(){this.defaultPrevented=!0};var Cs=function(){if(!h.addEventListener||!Object.defineProperty)return!1;var u=!1,d=Object.defineProperty({},"passive",{get:function(){u=!0}});try{let g=()=>{};h.addEventListener("test",g,d),h.removeEventListener("test",g,d)}catch{}return u}();function Si(u,d){if(Ke.call(this,u?u.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,u){var g=this.type=u.type,b=u.changedTouches&&u.changedTouches.length?u.changedTouches[0]:null;if(this.target=u.target||u.srcElement,this.g=d,d=u.relatedTarget){if(de){e:{try{le(d.nodeName);var L=!0;break e}catch{}L=!1}L||(d=null)}}else g=="mouseover"?d=u.fromElement:g=="mouseout"&&(d=u.toElement);this.relatedTarget=d,b?(this.clientX=b.clientX!==void 0?b.clientX:b.pageX,this.clientY=b.clientY!==void 0?b.clientY:b.pageY,this.screenX=b.screenX||0,this.screenY=b.screenY||0):(this.clientX=u.clientX!==void 0?u.clientX:u.pageX,this.clientY=u.clientY!==void 0?u.clientY:u.pageY,this.screenX=u.screenX||0,this.screenY=u.screenY||0),this.button=u.button,this.key=u.key||"",this.ctrlKey=u.ctrlKey,this.altKey=u.altKey,this.shiftKey=u.shiftKey,this.metaKey=u.metaKey,this.pointerId=u.pointerId||0,this.pointerType=typeof u.pointerType=="string"?u.pointerType:Ri[u.pointerType]||"",this.state=u.state,this.i=u,u.defaultPrevented&&Si.aa.h.call(this)}}B(Si,Ke);var Ri={2:"touch",3:"pen",4:"mouse"};Si.prototype.h=function(){Si.aa.h.call(this);var u=this.i;u.preventDefault?u.preventDefault():u.returnValue=!1};var pr="closure_listenable_"+(1e6*Math.random()|0),wf=0;function Ds(u,d,g,b,L){this.listener=u,this.proxy=null,this.src=d,this.type=g,this.capture=!!b,this.ha=L,this.key=++wf,this.da=this.fa=!1}function rn(u){u.da=!0,u.listener=null,u.proxy=null,u.src=null,u.ha=null}function Pi(u){this.src=u,this.g={},this.h=0}Pi.prototype.add=function(u,d,g,b,L){var F=u.toString();u=this.g[F],u||(u=this.g[F]=[],this.h++);var Q=nn(u,d,b,L);return-1<Q?(d=u[Q],g||(d.fa=!1)):(d=new Ds(d,this.src,F,!!b,L),d.fa=g,u.push(d)),d};function Pt(u,d){var g=d.type;if(g in u.g){var b=u.g[g],L=Array.prototype.indexOf.call(b,d,void 0),F;(F=0<=L)&&Array.prototype.splice.call(b,L,1),F&&(rn(d),u.g[g].length==0&&(delete u.g[g],u.h--))}}function nn(u,d,g,b){for(var L=0;L<u.length;++L){var F=u[L];if(!F.da&&F.listener==d&&F.capture==!!g&&F.ha==b)return L}return-1}var pa="closure_lm_"+(1e6*Math.random()|0),Ht={};function ma(u,d,g,b,L){if(b&&b.once)return Mt(u,d,g,b,L);if(Array.isArray(d)){for(var F=0;F<d.length;F++)ma(u,d[F],g,b,L);return null}return g=Or(g),u&&u[pr]?u.K(d,g,m(b)?!!b.capture:!!b,L):uc(u,d,g,!1,b,L)}function uc(u,d,g,b,L,F){if(!d)throw Error("Invalid event type");var Q=m(L)?!!L.capture:!!L,_e=ga(u);if(_e||(u[pa]=_e=new Pi(u)),g=_e.add(d,g,b,Q,F),g.proxy)return g;if(b=Ci(),g.proxy=b,b.src=u,b.listener=g,u.addEventListener)Cs||(L=Q),L===void 0&&(L=!1),u.addEventListener(d.toString(),b,L);else if(u.attachEvent)u.attachEvent(cc(d.toString()),b);else if(u.addListener&&u.removeListener)u.addListener(b);else throw Error("addEventListener and attachEvent are unavailable.");return g}function Ci(){function u(g){return d.call(u.src,u.listener,g)}let d=Di;return u}function Mt(u,d,g,b,L){if(Array.isArray(d)){for(var F=0;F<d.length;F++)Mt(u,d[F],g,b,L);return null}return g=Or(g),u&&u[pr]?u.L(d,g,m(b)?!!b.capture:!!b,L):uc(u,d,g,!0,b,L)}function Ln(u,d,g,b,L){if(Array.isArray(d))for(var F=0;F<d.length;F++)Ln(u,d[F],g,b,L);else b=m(b)?!!b.capture:!!b,g=Or(g),u&&u[pr]?(u=u.i,d=String(d).toString(),d in u.g&&(F=u.g[d],g=nn(F,g,b,L),-1<g&&(rn(F[g]),Array.prototype.splice.call(F,g,1),F.length==0&&(delete u.g[d],u.h--)))):u&&(u=ga(u))&&(d=u.g[d.toString()],u=-1,d&&(u=nn(d,g,b,L)),(g=-1<u?d[u]:null)&&Mn(g))}function Mn(u){if(typeof u!="number"&&u&&!u.da){var d=u.src;if(d&&d[pr])Pt(d.i,u);else{var g=u.type,b=u.proxy;d.removeEventListener?d.removeEventListener(g,b,u.capture):d.detachEvent?d.detachEvent(cc(g),b):d.addListener&&d.removeListener&&d.removeListener(b),(g=ga(d))?(Pt(g,u),g.h==0&&(g.src=null,d[pa]=null)):rn(u)}}}function cc(u){return u in Ht?Ht[u]:Ht[u]="on"+u}function Di(u,d){if(u.da)u=!0;else{d=new Si(d,this);var g=u.listener,b=u.ha||u.src;u.fa&&Mn(u),u=g.call(b,d)}return u}function ga(u){return u=u[pa],u instanceof Pi?u:null}var sn="__closure_events_fn_"+(1e9*Math.random()>>>0);function Or(u){return typeof u=="function"?u:(u[sn]||(u[sn]=function(d){return u.handleEvent(d)}),u[sn])}function nt(){Dr.call(this),this.i=new Pi(this),this.M=this,this.F=null}B(nt,Dr),nt.prototype[pr]=!0,nt.prototype.removeEventListener=function(u,d,g,b){Ln(this,u,d,g,b)};function ut(u,d){var g,b=u.F;if(b)for(g=[];b;b=b.F)g.push(b);if(u=u.M,b=d.type||d,typeof d=="string")d=new Ke(d,u);else if(d instanceof Ke)d.target=d.target||u;else{var L=d;d=new Ke(b,u),D(d,L)}if(L=!0,g)for(var F=g.length-1;0<=F;F--){var Q=d.g=g[F];L=Fn(Q,b,!0,d)&&L}if(Q=d.g=u,L=Fn(Q,b,!0,d)&&L,L=Fn(Q,b,!1,d)&&L,g)for(F=0;F<g.length;F++)Q=d.g=g[F],L=Fn(Q,b,!1,d)&&L}nt.prototype.N=function(){if(nt.aa.N.call(this),this.i){var u=this.i,d;for(d in u.g){for(var g=u.g[d],b=0;b<g.length;b++)rn(g[b]);delete u.g[d],u.h--}}this.F=null},nt.prototype.K=function(u,d,g,b){return this.i.add(String(u),d,!1,g,b)},nt.prototype.L=function(u,d,g,b){return this.i.add(String(u),d,!0,g,b)};function Fn(u,d,g,b){if(d=u.i.g[String(d)],!d)return!0;d=d.concat();for(var L=!0,F=0;F<d.length;++F){var Q=d[F];if(Q&&!Q.da&&Q.capture==g){var _e=Q.listener,Ze=Q.ha||Q.src;Q.fa&&Pt(u.i,Q),L=_e.call(Ze,b)!==!1&&L}}return L&&!b.defaultPrevented}function Os(u,d,g){if(typeof u=="function")g&&(u=I(u,g));else if(u&&typeof u.handleEvent=="function")u=I(u.handleEvent,u);else throw Error("Invalid listener argument");return 2147483647<Number(d)?-1:h.setTimeout(u,d||0)}function ks(u){u.g=Os(()=>{u.g=null,u.i&&(u.i=!1,ks(u))},u.l);let d=u.h;u.h=null,u.m.apply(null,d)}class _a extends Dr{constructor(d,g){super(),this.m=d,this.l=g,this.h=null,this.i=!1,this.g=null}j(d){this.h=arguments,this.g?this.i=!0:ks(this)}N(){super.N(),this.g&&(h.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function on(u){Dr.call(this),this.h=u,this.g={}}B(on,Dr);var Ns=[];function Vs(u){ie(u.g,function(d,g){this.g.hasOwnProperty(g)&&Mn(d)},u),u.g={}}on.prototype.N=function(){on.aa.N.call(this),Vs(this)},on.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var ya=h.JSON.stringify,bf=h.JSON.parse,Tf=class{stringify(u){return h.JSON.stringify(u,void 0)}parse(u){return h.JSON.parse(u,void 0)}};function Ls(){}Ls.prototype.h=null;function va(u){return u.h||(u.h=u.i())}function lc(){}var Oi={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function wa(){Ke.call(this,"d")}B(wa,Ke);function ba(){Ke.call(this,"c")}B(ba,Ke);var kr={},hc=null;function Ms(){return hc=hc||new nt}kr.La="serverreachability";function fc(u){Ke.call(this,kr.La,u)}B(fc,Ke);function an(u){let d=Ms();ut(d,new fc(d))}kr.STAT_EVENT="statevent";function dc(u,d){Ke.call(this,kr.STAT_EVENT,u),this.stat=d}B(dc,Ke);function ct(u){let d=Ms();ut(d,new dc(d,u))}kr.Ma="timingevent";function pc(u,d){Ke.call(this,kr.Ma,u),this.size=d}B(pc,Ke);function ki(u,d){if(typeof u!="function")throw Error("Fn must not be null and must be a function");return h.setTimeout(function(){u()},d)}function Ni(){this.g=!0}Ni.prototype.xa=function(){this.g=!1};function Ef(u,d,g,b,L,F){u.info(function(){if(u.g)if(F)for(var Q="",_e=F.split("&"),Ze=0;Ze<_e.length;Ze++){var be=_e[Ze].split("=");if(1<be.length){var lt=be[0];be=be[1];var ht=lt.split("_");Q=2<=ht.length&&ht[1]=="type"?Q+(lt+"="+be+"&"):Q+(lt+"=redacted&")}}else Q=null;else Q=F;return"XMLHTTP REQ ("+b+") [attempt "+L+"]: "+d+`
|
|
21
21
|
`+g+`
|
|
22
22
|
`+Q})}function If(u,d,g,b,L,F,Q){u.info(function(){return"XMLHTTP RESP ("+b+") [ attempt "+L+"]: "+d+`
|
|
23
23
|
`+g+`
|
|
@@ -25,25 +25,25 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
25
25
|
`,g);return b==-1?Bn:(g=Number(d.substring(g,b)),isNaN(g)?_c:(b+=1,b+g>d.length?Bn:(d=d.slice(b,b+g),u.C=b+g,d)))}Nr.prototype.cancel=function(){this.J=!0,un(this)};function Us(u){u.S=Date.now()+u.I,Ia(u,u.I)}function Ia(u,d){if(u.B!=null)throw Error("WatchDog timer not null");u.B=ki(I(u.ba,u),d)}function Bs(u){u.B&&(h.clearTimeout(u.B),u.B=null)}Nr.prototype.ba=function(){this.B=null;let u=Date.now();0<=u-this.S?(xf(this.i,this.A),this.L!=2&&(an(),ct(17)),un(this),this.s=2,jn(this)):Ia(this,this.S-u)};function jn(u){u.j.G==0||u.J||Vc(u.j,u)}function un(u){Bs(u);var d=u.M;d&&typeof d.ma=="function"&&d.ma(),u.M=null,Vs(u.U),u.g&&(d=u.g,u.g=null,d.abort(),d.ma())}function xa(u,d){try{var g=u.j;if(g.G!=0&&(g.g==u||js(g.h,u))){if(!u.K&&js(g.h,u)&&g.G==3){try{var b=g.Da.g.parse(d)}catch{b=null}if(Array.isArray(b)&&b.length==3){var L=b;if(L[0]==0){e:if(!g.u){if(g.g)if(g.g.F+3e3<u.F)Wn(g),Gi(g);else break e;Wi(g),ct(18)}}else g.za=L[1],0<g.za-g.T&&37500>L[2]&&g.F&&g.v==0&&!g.C&&(g.C=ki(I(g.Za,g),6e3));if(1>=Sa(g.h)&&g.ca){try{g.ca()}catch{}g.ca=void 0}}else cn(g,11)}else if((u.K||g.g==u)&&Wn(g),!ee(d))for(L=g.Da.g.parse(d),d=0;d<L.length;d++){let be=L[d];if(g.T=be[0],be=be[1],g.G==2)if(be[0]=="c"){g.K=be[1],g.ia=be[2];let lt=be[3];lt!=null&&(g.la=lt,g.j.info("VER="+g.la));let ht=be[4];ht!=null&&(g.Aa=ht,g.j.info("SVER="+g.Aa));let Hn=be[5];Hn!=null&&typeof Hn=="number"&&0<Hn&&(b=1.5*Hn,g.L=b,g.j.info("backChannelRequestTimeoutMs_="+b)),b=g;let Qt=u.g;if(Qt){let Qs=Qt.g?Qt.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(Qs){var F=b.h;F.g||Qs.indexOf("spdy")==-1&&Qs.indexOf("quic")==-1&&Qs.indexOf("h2")==-1||(F.j=F.l,F.g=new Set,F.h&&(Mi(F,F.h),F.h=null))}if(b.D){let Fa=Qt.g?Qt.g.getResponseHeader("X-HTTP-Session-Id"):null;Fa&&(b.ya=Fa,Ce(b.I,b.D,Fa))}}g.G=3,g.l&&g.l.ua(),g.ba&&(g.R=Date.now()-u.F,g.j.info("Handshake RTT: "+g.R+"ms")),b=g;var Q=u;if(b.qa=Mc(b,b.J?b.ia:null,b.W),Q.K){wc(b.h,Q);var _e=Q,Ze=b.L;Ze&&(_e.I=Ze),_e.B&&(Bs(_e),Us(_e)),b.g=Q}else Ki(b);0<g.i.length&&Ws(g)}else be[0]!="stop"&&be[0]!="close"||cn(g,7);else g.G==3&&(be[0]=="stop"||be[0]=="close"?be[0]=="stop"?cn(g,7):Ks(g):be[0]!="noop"&&g.l&&g.l.ta(be),g.v=0)}}an(4)}catch{}}var Rf=class{constructor(u,d){this.g=u,this.map=d}};function vc(u){this.l=u||10,h.PerformanceNavigationTiming?(u=h.performance.getEntriesByType("navigation"),u=0<u.length&&(u[0].nextHopProtocol=="hq"||u[0].nextHopProtocol=="h2")):u=!!(h.chrome&&h.chrome.loadTimes&&h.chrome.loadTimes()&&h.chrome.loadTimes().wasFetchedViaSpdy),this.j=u?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function Aa(u){return u.h?!0:u.g?u.g.size>=u.j:!1}function Sa(u){return u.h?1:u.g?u.g.size:0}function js(u,d){return u.h?u.h==d:u.g?u.g.has(d):!1}function Mi(u,d){u.g?u.g.add(d):u.h=d}function wc(u,d){u.h&&u.h==d?u.h=null:u.g&&u.g.has(d)&&u.g.delete(d)}vc.prototype.cancel=function(){if(this.i=Ra(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(let u of this.g.values())u.cancel();this.g.clear()}};function Ra(u){if(u.h!=null)return u.i.concat(u.h.D);if(u.g!=null&&u.g.size!==0){let d=u.i;for(let g of u.g.values())d=d.concat(g.D);return d}return G(u.i)}function $s(u){if(u.V&&typeof u.V=="function")return u.V();if(typeof Map!="undefined"&&u instanceof Map||typeof Set!="undefined"&&u instanceof Set)return Array.from(u.values());if(typeof u=="string")return u.split("");if(f(u)){for(var d=[],g=u.length,b=0;b<g;b++)d.push(u[b]);return d}d=[],g=0;for(b in u)d[g++]=u[b];return d}function bc(u){if(u.na&&typeof u.na=="function")return u.na();if(!u.V||typeof u.V!="function"){if(typeof Map!="undefined"&&u instanceof Map)return Array.from(u.keys());if(!(typeof Set!="undefined"&&u instanceof Set)){if(f(u)||typeof u=="string"){var d=[];u=u.length;for(var g=0;g<u;g++)d.push(g);return d}d=[],g=0;for(let b in u)d[g++]=b;return d}}}function Tc(u,d){if(u.forEach&&typeof u.forEach=="function")u.forEach(d,void 0);else if(f(u)||typeof u=="string")Array.prototype.forEach.call(u,d,void 0);else for(var g=bc(u),b=$s(u),L=b.length,F=0;F<L;F++)d.call(void 0,b[F],g&&g[F],u)}var Pa=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function Ec(u,d){if(u){u=u.split("&");for(var g=0;g<u.length;g++){var b=u[g].indexOf("="),L=null;if(0<=b){var F=u[g].substring(0,b);L=u[g].substring(b+1)}else F=u[g];d(F,L?decodeURIComponent(L.replace(/\+/g," ")):"")}}}function mr(u){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,u instanceof mr){this.h=u.h,Fi(this,u.j),this.o=u.o,this.g=u.g,$n(this,u.s),this.l=u.l;var d=u.i,g=new ji;g.i=d.i,d.g&&(g.g=new Map(d.g),g.h=d.h),qs(this,g),this.m=u.m}else u&&(d=String(u).match(Pa))?(this.h=!1,Fi(this,d[1]||"",!0),this.o=qn(d[2]||""),this.g=qn(d[3]||"",!0),$n(this,d[4]),this.l=qn(d[5]||"",!0),qs(this,d[6]||"",!0),this.m=qn(d[7]||"")):(this.h=!1,this.i=new ji(null,this.h))}mr.prototype.toString=function(){var u=[],d=this.j;d&&u.push(Bi(d,Ca,!0),":");var g=this.g;return(g||d=="file")&&(u.push("//"),(d=this.o)&&u.push(Bi(d,Ca,!0),"@"),u.push(encodeURIComponent(String(g)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),g=this.s,g!=null&&u.push(":",String(g))),(g=this.l)&&(this.g&&g.charAt(0)!="/"&&u.push("/"),u.push(Bi(g,g.charAt(0)=="/"?Ac:xc,!0))),(g=this.i.toString())&&u.push("?",g),(g=this.m)&&u.push("#",Bi(g,Cf)),u.join("")};function gr(u){return new mr(u)}function Fi(u,d,g){u.j=g?qn(d,!0):d,u.j&&(u.j=u.j.replace(/:$/,""))}function $n(u,d){if(d){if(d=Number(d),isNaN(d)||0>d)throw Error("Bad port number "+d);u.s=d}else u.s=null}function qs(u,d,g){d instanceof ji?(u.i=d,Da(u.i,u.h)):(g||(d=Bi(d,Pf)),u.i=new ji(d,u.h))}function Ce(u,d,g){u.i.set(d,g)}function Ui(u){return Ce(u,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),u}function qn(u,d){return u?d?decodeURI(u.replace(/%25/g,"%2525")):decodeURIComponent(u):""}function Bi(u,d,g){return typeof u=="string"?(u=encodeURI(u).replace(d,Ic),g&&(u=u.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),u):null}function Ic(u){return u=u.charCodeAt(0),"%"+(u>>4&15).toString(16)+(u&15).toString(16)}var Ca=/[#\/\?@]/g,xc=/[#\?:]/g,Ac=/[#\?]/g,Pf=/[#\?@]/g,Cf=/#/g;function ji(u,d){this.h=this.g=null,this.i=u||null,this.j=!!d}function _r(u){u.g||(u.g=new Map,u.h=0,u.i&&Ec(u.i,function(d,g){u.add(decodeURIComponent(d.replace(/\+/g," ")),g)}))}r=ji.prototype,r.add=function(u,d){_r(this),this.i=null,u=zn(this,u);var g=this.g.get(u);return g||this.g.set(u,g=[]),g.push(d),this.h+=1,this};function Sc(u,d){_r(u),d=zn(u,d),u.g.has(d)&&(u.i=null,u.h-=u.g.get(d).length,u.g.delete(d))}function Rc(u,d){return _r(u),d=zn(u,d),u.g.has(d)}r.forEach=function(u,d){_r(this),this.g.forEach(function(g,b){g.forEach(function(L){u.call(d,L,b,this)},this)},this)},r.na=function(){_r(this);let u=Array.from(this.g.values()),d=Array.from(this.g.keys()),g=[];for(let b=0;b<d.length;b++){let L=u[b];for(let F=0;F<L.length;F++)g.push(d[b])}return g},r.V=function(u){_r(this);let d=[];if(typeof u=="string")Rc(this,u)&&(d=d.concat(this.g.get(zn(this,u))));else{u=Array.from(this.g.values());for(let g=0;g<u.length;g++)d=d.concat(u[g])}return d},r.set=function(u,d){return _r(this),this.i=null,u=zn(this,u),Rc(this,u)&&(this.h-=this.g.get(u).length),this.g.set(u,[d]),this.h+=1,this},r.get=function(u,d){return u?(u=this.V(u),0<u.length?String(u[0]):d):d};function Pc(u,d,g){Sc(u,d),0<g.length&&(u.i=null,u.g.set(zn(u,d),G(g)),u.h+=g.length)}r.toString=function(){if(this.i)return this.i;if(!this.g)return"";let u=[],d=Array.from(this.g.keys());for(var g=0;g<d.length;g++){var b=d[g];let F=encodeURIComponent(String(b)),Q=this.V(b);for(b=0;b<Q.length;b++){var L=F;Q[b]!==""&&(L+="="+encodeURIComponent(String(Q[b]))),u.push(L)}}return this.i=u.join("&")};function zn(u,d){return d=String(d),u.j&&(d=d.toLowerCase()),d}function Da(u,d){d&&!u.j&&(_r(u),u.i=null,u.g.forEach(function(g,b){var L=b.toLowerCase();b!=L&&(Sc(this,b),Pc(this,L,g))},u)),u.j=d}function Df(u,d){let g=new Ni;if(h.Image){let b=new Image;b.onload=k(Vr,g,"TestLoadImage: loaded",!0,d,b),b.onerror=k(Vr,g,"TestLoadImage: error",!1,d,b),b.onabort=k(Vr,g,"TestLoadImage: abort",!1,d,b),b.ontimeout=k(Vr,g,"TestLoadImage: timeout",!1,d,b),h.setTimeout(function(){b.ontimeout&&b.ontimeout()},1e4),b.src=u}else d(!1)}function Of(u,d){let g=new Ni,b=new AbortController,L=setTimeout(()=>{b.abort(),Vr(g,"TestPingServer: timeout",!1,d)},1e4);fetch(u,{signal:b.signal}).then(F=>{clearTimeout(L),F.ok?Vr(g,"TestPingServer: ok",!0,d):Vr(g,"TestPingServer: server error",!1,d)}).catch(()=>{clearTimeout(L),Vr(g,"TestPingServer: error",!1,d)})}function Vr(u,d,g,b,L){try{L&&(L.onload=null,L.onerror=null,L.onabort=null,L.ontimeout=null),b(g)}catch{}}function kf(){this.g=new Tf}function Nf(u,d,g){let b=g||"";try{Tc(u,function(L,F){let Q=L;m(L)&&(Q=ya(L)),d.push(b+F+"="+encodeURIComponent(Q))})}catch(L){throw d.push(b+"type="+encodeURIComponent("_badmap")),L}}function Oe(u){this.l=u.Ub||null,this.j=u.eb||!1}B(Oe,Ls),Oe.prototype.g=function(){return new ke(this.l,this.j)},Oe.prototype.i=function(u){return function(){return u}}({});function ke(u,d){nt.call(this),this.D=u,this.o=d,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}B(ke,nt),r=ke.prototype,r.open=function(u,d){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=u,this.A=d,this.readyState=1,qi(this)},r.send=function(u){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;let d={headers:this.u,method:this.B,credentials:this.m,cache:void 0};u&&(d.body=u),(this.D||h).fetch(new Request(this.A,d)).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,$i(this)),this.readyState=0},r.Sa=function(u){if(this.g&&(this.l=u,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=u.headers,this.readyState=2,qi(this)),this.g&&(this.readyState=3,qi(this),this.g)))if(this.responseType==="arraybuffer")u.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof h.ReadableStream!="undefined"&&"body"in u){if(this.j=u.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;Cc(this)}else u.text().then(this.Ra.bind(this),this.ga.bind(this))};function Cc(u){u.j.read().then(u.Pa.bind(u)).catch(u.ga.bind(u))}r.Pa=function(u){if(this.g){if(this.o&&u.value)this.response.push(u.value);else if(!this.o){var d=u.value?u.value:new Uint8Array(0);(d=this.v.decode(d,{stream:!u.done}))&&(this.response=this.responseText+=d)}u.done?$i(this):qi(this),this.readyState==3&&Cc(this)}},r.Ra=function(u){this.g&&(this.response=this.responseText=u,$i(this))},r.Qa=function(u){this.g&&(this.response=u,$i(this))},r.ga=function(){this.g&&$i(this)};function $i(u){u.readyState=4,u.l=null,u.j=null,u.v=null,qi(u)}r.setRequestHeader=function(u,d){this.u.append(u,d)},r.getResponseHeader=function(u){return this.h&&this.h.get(u.toLowerCase())||""},r.getAllResponseHeaders=function(){if(!this.h)return"";let u=[],d=this.h.entries();for(var g=d.next();!g.done;)g=g.value,u.push(g[0]+": "+g[1]),g=d.next();return u.join(`\r
|
|
26
26
|
`)};function qi(u){u.onreadystatechange&&u.onreadystatechange.call(u)}Object.defineProperty(ke.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(u){this.m=u?"include":"same-origin"}});function Dc(u){let d="";return ie(u,function(g,b){d+=b,d+=":",d+=g,d+=`\r
|
|
27
27
|
`}),d}function Oa(u,d,g){e:{for(b in g){var b=!1;break e}b=!0}b||(g=Dc(g),typeof u=="string"?g!=null&&encodeURIComponent(String(g)):Ce(u,d,g))}function ze(u){nt.call(this),this.headers=new Map,this.o=u||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}B(ze,nt);var Oc=/^https?$/i,Vf=["POST","PUT"];r=ze.prototype,r.Ha=function(u){this.J=u},r.ea=function(u,d,g,b){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+u);d=d?d.toUpperCase():"GET",this.D=u,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():Ta.g(),this.v=this.o?va(this.o):va(Ta),this.g.onreadystatechange=I(this.Ea,this);try{this.B=!0,this.g.open(d,String(u),!0),this.B=!1}catch(F){Xe(this,F);return}if(u=g||"",g=new Map(this.headers),b)if(Object.getPrototypeOf(b)===Object.prototype)for(var L in b)g.set(L,b[L]);else if(typeof b.keys=="function"&&typeof b.get=="function")for(let F of b.keys())g.set(F,b.get(F));else throw Error("Unknown input type for opt_headers: "+String(b));b=Array.from(g.keys()).find(F=>F.toLowerCase()=="content-type"),L=h.FormData&&u instanceof h.FormData,!(0<=Array.prototype.indexOf.call(Vf,d,void 0))||b||L||g.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(let[F,Q]of g)this.g.setRequestHeader(F,Q);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{Gs(this),this.u=!0,this.g.send(u),this.u=!1}catch(F){Xe(this,F)}};function Xe(u,d){u.h=!1,u.g&&(u.j=!0,u.g.abort(),u.j=!1),u.l=d,u.m=5,zs(u),zi(u)}function zs(u){u.A||(u.A=!0,ut(u,"complete"),ut(u,"error"))}r.abort=function(u){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=u||7,ut(this,"complete"),ut(this,"abort"),zi(this))},r.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),zi(this,!0)),ze.aa.N.call(this)},r.Ea=function(){this.s||(this.B||this.u||this.j?Lr(this):this.bb())},r.bb=function(){Lr(this)};function Lr(u){if(u.h&&typeof c!="undefined"&&(!u.v[1]||He(u)!=4||u.Z()!=2)){if(u.u&&He(u)==4)Os(u.Ea,0,u);else if(ut(u,"readystatechange"),He(u)==4){u.h=!1;try{let Q=u.Z();e:switch(Q){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var d=!0;break e;default:d=!1}var g;if(!(g=d)){var b;if(b=Q===0){var L=String(u.D).match(Pa)[1]||null;!L&&h.self&&h.self.location&&(L=h.self.location.protocol.slice(0,-1)),b=!Oc.test(L?L.toLowerCase():"")}g=b}if(g)ut(u,"complete"),ut(u,"success");else{u.m=6;try{var F=2<He(u)?u.g.statusText:""}catch{F=""}u.l=F+" ["+u.Z()+"]",zs(u)}}finally{zi(u)}}}}function zi(u,d){if(u.g){Gs(u);let g=u.g,b=u.v[0]?()=>{}:null;u.g=null,u.v=null,d||ut(u,"ready");try{g.onreadystatechange=b}catch{}}}function Gs(u){u.I&&(h.clearTimeout(u.I),u.I=null)}r.isActive=function(){return!!this.g};function He(u){return u.g?u.g.readyState:0}r.Z=function(){try{return 2<He(this)?this.g.status:-1}catch{return-1}},r.oa=function(){try{return this.g?this.g.responseText:""}catch{return""}},r.Oa=function(u){if(this.g){var d=this.g.responseText;return u&&d.indexOf(u)==0&&(d=d.substring(u.length)),bf(d)}};function ka(u){try{if(!u.g)return null;if("response"in u.g)return u.g.response;switch(u.H){case"":case"text":return u.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in u.g)return u.g.mozResponseArrayBuffer}return null}catch{return null}}function kc(u){let d={};u=(u.g&&2<=He(u)&&u.g.getAllResponseHeaders()||"").split(`\r
|
|
28
|
-
`);for(let b=0;b<u.length;b++){if(ee(u[b]))continue;var g=V(u[b]);let L=g[0];if(g=g[1],typeof g!="string")continue;g=g.trim();let F=d[L]||[];d[L]=F,F.push(g)}C(d,function(b){return b.join(", ")})}r.Ba=function(){return this.m},r.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function Gn(u,d,g){return g&&g.internalChannelParams&&g.internalChannelParams[u]||d}function Na(u){this.Aa=0,this.i=[],this.j=new Ni,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=Gn("failFast",!1,u),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=Gn("baseRetryDelayMs",5e3,u),this.cb=Gn("retryDelaySeedMs",1e4,u),this.Wa=Gn("forwardChannelMaxRetries",2,u),this.wa=Gn("forwardChannelRequestTimeoutMs",2e4,u),this.pa=u&&u.xmlHttpFactory||void 0,this.Xa=u&&u.Tb||void 0,this.Ca=u&&u.useFetchStreams||!1,this.L=void 0,this.J=u&&u.supportsCrossDomainXhr||!1,this.K="",this.h=new vc(u&&u.concurrentRequestLimit),this.Da=new kf,this.P=u&&u.fastHandshake||!1,this.O=u&&u.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=u&&u.Rb||!1,u&&u.xa&&this.j.xa(),u&&u.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&u&&u.detectBufferingProxy||!1,this.ja=void 0,u&&u.longPollingTimeout&&0<u.longPollingTimeout&&(this.ja=u.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}r=Na.prototype,r.la=8,r.G=1,r.connect=function(u,d,g,b){ct(0),this.W=u,this.H=d||{},g&&b!==void 0&&(this.H.OSID=g,this.H.OAID=b),this.F=this.X,this.I=Mc(this,null,this.W),Ws(this)};function Ks(u){if(Et(u),u.G==3){var d=u.U++,g=gr(u.I);if(Ce(g,"SID",u.K),Ce(g,"RID",d),Ce(g,"TYPE","terminate"),Kn(u,g),d=new Nr(u,u.j,d),d.L=2,d.v=Ui(gr(g)),g=!1,h.navigator&&h.navigator.sendBeacon)try{g=h.navigator.sendBeacon(d.v.toString(),"")}catch{}!g&&h.Image&&(new Image().src=d.v,g=!0),g||(d.g=Va(d.j,null),d.g.ea(d.v)),d.F=Date.now(),Us(d)}Lc(u)}function Gi(u){u.g&&(Fe(u),u.g.cancel(),u.g=null)}function Et(u){Gi(u),u.u&&(h.clearTimeout(u.u),u.u=null),Wn(u),u.h.cancel(),u.s&&(typeof u.s=="number"&&h.clearTimeout(u.s),u.s=null)}function Ws(u){if(!Aa(u.h)&&!u.s){u.s=!0;var d=u.Ga;Ai||ac(),Cr||(Ai(),Cr=!0),Lt.add(d,u),u.B=0}}function Ft(u,d){return Sa(u.h)>=u.h.j-(u.s?1:0)?!1:u.s?(u.i=d.D.concat(u.i),!0):u.G==1||u.G==2||u.B>=(u.Va?0:u.Wa)?!1:(u.s=ki(I(u.Ga,u,d),Hs(u,u.B)),u.B++,!0)}r.Ga=function(u){if(this.s)if(this.s=null,this.G==1){if(!u){this.U=Math.floor(1e5*Math.random()),u=this.U++;let L=new Nr(this,this.j,u),F=this.o;if(this.S&&(F?(F=A(F),D(F,this.S)):F=this.S),this.m!==null||this.O||(L.H=F,F=null),this.P)e:{for(var d=0,g=0;g<this.i.length;g++){t:{var b=this.i[g];if("__data__"in b.map&&(b=b.map.__data__,typeof b=="string")){b=b.length;break t}b=void 0}if(b===void 0)break;if(d+=b,4096<d){d=g;break e}if(d===4096||g===this.i.length-1){d=g+1;break e}}d=1e3}else d=1e3;d=yr(this,L,d),g=gr(this.I),Ce(g,"RID",u),Ce(g,"CVER",22),this.D&&Ce(g,"X-HTTP-Session-Id",this.D),Kn(this,g),F&&(this.O?d="headers="+encodeURIComponent(String(Dc(F)))+"&"+d:this.m&&Oa(g,this.m,F)),Mi(this.h,L),this.Ua&&Ce(g,"TYPE","init"),this.P?(Ce(g,"$req",d),Ce(g,"SID","null"),L.T=!0,Ea(L,g,null)):Ea(L,g,d),this.G=2}}else this.G==3&&(u?Nc(this,u):this.i.length==0||Aa(this.h)||Nc(this))};function Nc(u,d){var g;d?g=d.l:g=u.U++;let b=gr(u.I);Ce(b,"SID",u.K),Ce(b,"RID",g),Ce(b,"AID",u.T),Kn(u,b),u.m&&u.o&&Oa(b,u.m,u.o),g=new Nr(u,u.j,g,u.B+1),u.m===null&&(g.H=u.o),d&&(u.i=d.D.concat(u.i)),d=yr(u,g,1e3),g.I=Math.round(.5*u.wa)+Math.round(.5*u.wa*Math.random()),Mi(u.h,g),Ea(g,b,d)}function Kn(u,d){u.H&&ie(u.H,function(g,b){Ce(d,b,g)}),u.l&&Tc({},function(g,b){Ce(d,b,g)})}function yr(u,d,g){g=Math.min(u.i.length,g);var b=u.l?I(u.l.Na,u.l,u):null;e:{var L=u.i;let F=-1;for(;;){let Q=["count="+g];F==-1?0<g?(F=L[0].g,Q.push("ofs="+F)):F=0:Q.push("ofs="+F);let _e=!0;for(let Ze=0;Ze<g;Ze++){let be=L[Ze].g,lt=L[Ze].map;if(be-=F,0>be)F=Math.max(0,L[Ze].g-100),_e=!1;else try{Nf(lt,Q,"req"+be+"_")}catch{b&&b(lt)}}if(_e){b=Q.join("&");break e}}}return u=u.i.splice(0,g),d.D=u,b}function Ki(u){if(!u.g&&!u.u){u.Y=1;var d=u.Fa;Ai||ac(),Cr||(Ai(),Cr=!0),Lt.add(d,u),u.v=0}}function Wi(u){return u.g||u.u||3<=u.v?!1:(u.Y++,u.u=ki(I(u.Fa,u),Hs(u,u.v)),u.v++,!0)}r.Fa=function(){if(this.u=null,vr(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var u=2*this.R;this.j.info("BP detection timer enabled: "+u),this.A=ki(I(this.ab,this),u)}},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,ct(10),Gi(this),vr(this))};function Fe(u){u.A!=null&&(h.clearTimeout(u.A),u.A=null)}function vr(u){u.g=new Nr(u,u.j,"rpc",u.Y),u.m===null&&(u.g.H=u.o),u.g.O=0;var d=gr(u.qa);Ce(d,"RID","rpc"),Ce(d,"SID",u.K),Ce(d,"AID",u.T),Ce(d,"CI",u.F?"0":"1"),!u.F&&u.ja&&Ce(d,"TO",u.ja),Ce(d,"TYPE","xmlhttp"),Kn(u,d),u.m&&u.o&&Oa(d,u.m,u.o),u.L&&(u.g.I=u.L);var g=u.g;u=u.ia,g.L=1,g.v=Ui(gr(d)),g.m=null,g.P=!0,Li(g,u)}r.Za=function(){this.C!=null&&(this.C=null,Gi(this),Wi(this),ct(19))};function Wn(u){u.C!=null&&(h.clearTimeout(u.C),u.C=null)}function Vc(u,d){var g=null;if(u.g==d){Wn(u),Fe(u),u.g=null;var b=2}else if(js(u.h,d))g=d.D,wc(u.h,d),b=1;else return;if(u.G!=0){if(d.o)if(b==1){g=d.m?d.m.length:0,d=Date.now()-d.F;var L=u.B;b=Ms(),ut(b,new pc(b,g)),Ws(u)}else Ki(u);else if(L=d.s,L==3||L==0&&0<d.X||!(b==1&&Ft(u,d)||b==2&&Wi(u)))switch(g&&0<g.length&&(d=u.h,d.i=d.i.concat(g)),L){case 1:cn(u,5);break;case 4:cn(u,10);break;case 3:cn(u,6);break;default:cn(u,2)}}}function Hs(u,d){let g=u.Ta+Math.floor(Math.random()*u.cb);return u.isActive()||(g*=2),g*d}function cn(u,d){if(u.j.info("Error code "+d),d==2){var g=I(u.fb,u),b=u.Xa;let L=!b;b=new mr(b||"//www.google.com/images/cleardot.gif"),h.location&&h.location.protocol=="http"||Fi(b,"https"),Ui(b),L?Df(b.toString(),g):Of(b.toString(),g)}else ct(2);u.G=0,u.l&&u.l.sa(d),Lc(u),Et(u)}r.fb=function(u){u?(this.j.info("Successfully pinged google.com"),ct(2)):(this.j.info("Failed to ping google.com"),ct(1))};function Lc(u){if(u.G=0,u.ka=[],u.l){let d=Ra(u.h);(d.length!=0||u.i.length!=0)&&(j(u.ka,d),j(u.ka,u.i),u.h.i.length=0,G(u.i),u.i.length=0),u.l.ra()}}function Mc(u,d,g){var b=g instanceof mr?gr(g):new mr(g);if(b.g!="")d&&(b.g=d+"."+b.g),$n(b,b.s);else{var L=h.location;b=L.protocol,d=d?d+"."+L.hostname:L.hostname,L=+L.port;var F=new mr(null);b&&Fi(F,b),d&&(F.g=d),L&&$n(F,L),g&&(F.l=g),b=F}return g=u.D,d=u.ya,g&&d&&Ce(b,g,d),Ce(b,"VER",u.la),Kn(u,b),b}function Va(u,d,g){if(d&&!u.J)throw Error("Can't create secondary domain capable XhrIo object.");return d=u.Ca&&!u.pa?new ze(new Oe({eb:g})):new ze(u.pa),d.Ha(u.J),d}r.isActive=function(){return!!this.l&&this.l.isActive(this)};function Hi(){}r=Hi.prototype,r.ua=function(){},r.ta=function(){},r.sa=function(){},r.ra=function(){},r.isActive=function(){return!0},r.Na=function(){};function wr(){}wr.prototype.g=function(u,d){return new Ct(u,d)};function Ct(u,d){nt.call(this),this.g=new Na(d),this.l=u,this.h=d&&d.messageUrlParams||null,u=d&&d.messageHeaders||null,d&&d.clientProtocolHeaderRequired&&(u?u["X-Client-Protocol"]="webchannel":u={"X-Client-Protocol":"webchannel"}),this.g.o=u,u=d&&d.initMessageHeaders||null,d&&d.messageContentType&&(u?u["X-WebChannel-Content-Type"]=d.messageContentType:u={"X-WebChannel-Content-Type":d.messageContentType}),d&&d.va&&(u?u["X-WebChannel-Client-Profile"]=d.va:u={"X-WebChannel-Client-Profile":d.va}),this.g.S=u,(u=d&&d.Sb)&&!ee(u)&&(this.g.m=u),this.v=d&&d.supportsCrossDomainXhr||!1,this.u=d&&d.sendRawJson||!1,(d=d&&d.httpSessionIdParam)&&!ee(d)&&(this.g.D=d,u=this.h,u!==null&&d in u&&(u=this.h,d in u&&delete u[d])),this.j=new Mr(this)}B(Ct,nt),Ct.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},Ct.prototype.close=function(){Ks(this.g)},Ct.prototype.o=function(u){var d=this.g;if(typeof u=="string"){var g={};g.__data__=u,u=g}else this.u&&(g={},g.__data__=ya(u),u=g);d.i.push(new Rf(d.Ya++,u)),d.G==3&&Ws(d)},Ct.prototype.N=function(){this.g.l=null,delete this.j,Ks(this.g),delete this.g,Ct.aa.N.call(this)};function La(u){wa.call(this),u.__headers__&&(this.headers=u.__headers__,this.statusCode=u.__status__,delete u.__headers__,delete u.__status__);var d=u.__sm__;if(d){e:{for(let g in d){u=g;break e}u=void 0}(this.i=u)&&(u=this.i,d=d!==null&&u in d?d[u]:void 0),this.data=d}else this.data=u}B(La,wa);function Ma(){ba.call(this),this.status=1}B(Ma,ba);function Mr(u){this.g=u}B(Mr,Hi),Mr.prototype.ua=function(){ut(this.g,"a")},Mr.prototype.ta=function(u){ut(this.g,new La(u))},Mr.prototype.sa=function(u){ut(this.g,new Ma)},Mr.prototype.ra=function(){ut(this.g,"b")},wr.prototype.createWebChannel=wr.prototype.g,Ct.prototype.send=Ct.prototype.o,Ct.prototype.open=Ct.prototype.m,Ct.prototype.close=Ct.prototype.close,fp=Rn.createWebChannelTransport=function(){return new wr},hp=Rn.getStatEventTarget=function(){return Ms()},lp=Rn.Event=kr,Jl=Rn.Stat={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},Vi.NO_ERROR=0,Vi.TIMEOUT=8,Vi.HTTP_ERROR=6,cu=Rn.ErrorCode=Vi,mc.COMPLETE="complete",cp=Rn.EventType=mc,lc.EventType=Oi,Oi.OPEN="a",Oi.CLOSE="b",Oi.ERROR="c",Oi.MESSAGE="d",nt.prototype.listen=nt.prototype.K,So=Rn.WebChannel=lc,C2=Rn.FetchXmlHttpFactory=Oe,ze.prototype.listenOnce=ze.prototype.L,ze.prototype.getLastError=ze.prototype.Ka,ze.prototype.getLastErrorCode=ze.prototype.Ba,ze.prototype.getStatus=ze.prototype.Z,ze.prototype.getResponseJson=ze.prototype.Oa,ze.prototype.getResponseText=ze.prototype.oa,ze.prototype.send=ze.prototype.ea,ze.prototype.setWithCredentials=ze.prototype.Ha,up=Rn.XhrIo=ze}).apply(typeof Ql!="undefined"?Ql:typeof self!="undefined"?self:typeof window!="undefined"?window:{});var K0="@firebase/firestore",W0="4.7.8";var _t=class{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.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");var Yo="11.3.1";var cs=new Ao("@firebase/firestore");function Ro(){return cs.logLevel}function X(r,...e){if(cs.logLevel<=Se.DEBUG){let t=e.map(Xm);cs.debug(`Firestore (${Yo}): ${r}`,...t)}}function Pn(r,...e){if(cs.logLevel<=Se.ERROR){let t=e.map(Xm);cs.error(`Firestore (${Yo}): ${r}`,...t)}}function Vo(r,...e){if(cs.logLevel<=Se.WARN){let t=e.map(Xm);cs.warn(`Firestore (${Yo}): ${r}`,...t)}}function Xm(r){if(typeof r=="string")return r;try{return function(t){return JSON.stringify(t)}(r)}catch{return r}}function ue(r="Unexpected state"){let e=`FIRESTORE (${Yo}) INTERNAL ASSERTION FAILED: `+r;throw Pn(e),new Error(e)}function Le(r,e){r||ue()}function fe(r,e){return r}var H={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"},ne=class extends En{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}};var Gr=class{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}};var nh=class{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}},_p=class{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(_t.UNAUTHENTICATED))}shutdown(){}},yp=class{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable(()=>t(this.token.user))}shutdown(){this.changeListener=null}},vp=class{constructor(e){this.t=e,this.currentUser=_t.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){Le(this.o===void 0);let n=this.i,s=f=>this.i!==n?(n=this.i,t(f)):Promise.resolve(),a=new Gr;this.o=()=>{this.i++,this.currentUser=this.u(),a.resolve(),a=new Gr,e.enqueueRetryable(()=>s(this.currentUser))};let c=()=>{let f=a;e.enqueueRetryable(async()=>{await f.promise,await s(this.currentUser)})},h=f=>{X("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=f,this.o&&(this.auth.addAuthTokenListener(this.o),c())};this.t.onInit(f=>h(f)),setTimeout(()=>{if(!this.auth){let f=this.t.getImmediate({optional:!0});f?h(f):(X("FirebaseAuthCredentialsProvider","Auth not yet detected"),a.resolve(),a=new Gr)}},0),c()}getToken(){let e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(n=>this.i!==e?(X("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):n?(Le(typeof n.accessToken=="string"),new nh(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(){let e=this.auth&&this.auth.getUid();return Le(e===null||typeof e=="string"),new _t(e)}},wp=class{constructor(e,t,n){this.l=e,this.h=t,this.P=n,this.type="FirstParty",this.user=_t.FIRST_PARTY,this.T=new Map}I(){return this.P?this.P():null}get headers(){this.T.set("X-Goog-AuthUser",this.l);let e=this.I();return e&&this.T.set("Authorization",e),this.h&&this.T.set("X-Goog-Iam-Authorization-Token",this.h),this.T}},bp=class{constructor(e,t,n){this.l=e,this.h=t,this.P=n}getToken(){return Promise.resolve(new wp(this.l,this.h,this.P))}start(e,t){e.enqueueRetryable(()=>t(_t.FIRST_PARTY))}shutdown(){}invalidateToken(){}},ih=class{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}},Tp=class{constructor(e,t){this.A=t,this.forceRefresh=!1,this.appCheck=null,this.R=null,this.V=null,U0(e)&&e.settings.appCheckToken&&(this.V=e.settings.appCheckToken)}start(e,t){Le(this.o===void 0);let n=a=>{a.error!=null&&X("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${a.error.message}`);let c=a.token!==this.R;return this.R=a.token,X("FirebaseAppCheckTokenProvider",`Received ${c?"new":"existing"} token.`),c?t(a.token):Promise.resolve()};this.o=a=>{e.enqueueRetryable(()=>n(a))};let s=a=>{X("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=a,this.o&&this.appCheck.addTokenListener(this.o)};this.A.onInit(a=>s(a)),setTimeout(()=>{if(!this.appCheck){let a=this.A.getImmediate({optional:!0});a?s(a):X("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.V)return Promise.resolve(new ih(this.V));let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(t=>t?(Le(typeof t.token=="string"),this.R=t.token,new ih(t.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}};function D2(r){let e=typeof self!="undefined"&&(self.crypto||self.msCrypto),t=new Uint8Array(r);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let n=0;n<r;n++)t[n]=Math.floor(256*Math.random());return t}var sh=class{static newId(){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=62*Math.floor(4.129032258064516),n="";for(;n.length<20;){let s=D2(40);for(let a=0;a<s.length;++a)n.length<20&&s[a]<t&&(n+=e.charAt(s[a]%62))}return n}};function Re(r,e){return r<e?-1:r>e?1:0}function Lo(r,e,t){return r.length===e.length&&r.every((n,s)=>t(n,e[s]))}var H0=-62135596800,Q0=1e6,wt=class r{static now(){return r.fromMillis(Date.now())}static fromDate(e){return r.fromMillis(e.getTime())}static fromMillis(e){let t=Math.floor(e/1e3),n=Math.floor((e-1e3*t)*Q0);return new r(t,n)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new ne(H.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new ne(H.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<H0)throw new ne(H.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new ne(H.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/Q0}_compareTo(e){return this.seconds===e.seconds?Re(this.nanoseconds,e.nanoseconds):Re(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){let e=this.seconds-H0;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}};var me=class r{static fromTimestamp(e){return new r(e)}static min(){return new r(new wt(0,0))}static max(){return new r(new wt(253402300799,999999999))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}};var J0="__name__",oh=class r{constructor(e,t,n){t===void 0?t=0:t>e.length&&ue(),n===void 0?n=e.length-t:n>e.length-t&&ue(),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(e){return r.comparator(this,e)===0}child(e){let t=this.segments.slice(this.offset,this.limit());return e instanceof r?e.forEach(n=>{t.push(n)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}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(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,n=this.limit();t<n;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){let n=Math.min(e.length,t.length);for(let s=0;s<n;s++){let a=r.compareSegments(e.get(s),t.get(s));if(a!==0)return a}return Math.sign(e.length-t.length)}static compareSegments(e,t){let n=r.isNumericId(e),s=r.isNumericId(t);return n&&!s?-1:!n&&s?1:n&&s?r.extractNumericId(e).compare(r.extractNumericId(t)):e<t?-1:e>t?1:0}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return Sn.fromString(e.substring(4,e.length-2))}},ot=class r extends oh{construct(e,t,n){return new r(e,t,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){let t=[];for(let n of e){if(n.indexOf("//")>=0)throw new ne(H.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);t.push(...n.split("/").filter(s=>s.length>0))}return new r(t)}static emptyPath(){return new r([])}},O2=/^[_a-zA-Z][_a-zA-Z0-9]*$/,tr=class r extends oh{construct(e,t,n){return new r(e,t,n)}static isValidIdentifier(e){return O2.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),r.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===J0}static keyField(){return new r([J0])}static fromServerFormat(e){let t=[],n="",s=0,a=()=>{if(n.length===0)throw new ne(H.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(n),n=""},c=!1;for(;s<e.length;){let h=e[s];if(h==="\\"){if(s+1===e.length)throw new ne(H.INVALID_ARGUMENT,"Path has trailing escape character: "+e);let f=e[s+1];if(f!=="\\"&&f!=="."&&f!=="`")throw new ne(H.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);n+=f,s+=2}else h==="`"?(c=!c,s++):h!=="."||c?(n+=h,s++):(a(),s++)}if(a(),c)throw new ne(H.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new r(t)}static emptyPath(){return new r([])}};var ce=class r{constructor(e){this.path=e}static fromPath(e){return new r(ot.fromString(e))}static fromName(e){return new r(ot.fromString(e).popFirst(5))}static empty(){return new r(ot.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&ot.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return ot.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new r(new ot(e.slice()))}};var mu=-1,Ep=class{constructor(e,t,n,s){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=s}};Ep.UNKNOWN_ID=-1;function k2(r,e){let t=r.toTimestamp().seconds,n=r.toTimestamp().nanoseconds+1,s=me.fromTimestamp(n===1e9?new wt(t+1,0):new wt(t,n));return new ls(s,ce.empty(),e)}function N2(r){return new ls(r.readTime,r.key,mu)}var ls=class r{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new r(me.min(),ce.empty(),mu)}static max(){return new r(me.max(),ce.empty(),mu)}};function V2(r,e){let t=r.readTime.compareTo(e.readTime);return t!==0?t:(t=ce.comparator(r.documentKey,e.documentKey),t!==0?t:Re(r.largestBatchId,e.largestBatchId))}var L2="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",Ip=class{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}};async function Xo(r){if(r.code!==H.FAILED_PRECONDITION||r.message!==L2)throw r;X("LocalStore","Unexpectedly lost primary lease")}var W=class r{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)},t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&ue(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new r((n,s)=>{this.nextCallback=a=>{this.wrapSuccess(e,a).next(n,s)},this.catchCallback=a=>{this.wrapFailure(t,a).next(n,s)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{let t=e();return t instanceof r?t:r.resolve(t)}catch(t){return r.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):r.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):r.reject(t)}static resolve(e){return new r((t,n)=>{t(e)})}static reject(e){return new r((t,n)=>{n(e)})}static waitFor(e){return new r((t,n)=>{let s=0,a=0,c=!1;e.forEach(h=>{++s,h.next(()=>{++a,c&&a===s&&t()},f=>n(f))}),c=!0,a===s&&t()})}static or(e){let t=r.resolve(!1);for(let n of e)t=t.next(s=>s?r.resolve(s):n());return t}static forEach(e,t){let n=[];return e.forEach((s,a)=>{n.push(t.call(this,s,a))}),this.waitFor(n)}static mapArray(e,t){return new r((n,s)=>{let a=e.length,c=new Array(a),h=0;for(let f=0;f<a;f++){let m=f;t(e[m]).next(_=>{c[m]=_,++h,h===a&&n(c)},_=>s(_))}})}static doWhile(e,t){return new r((n,s)=>{let a=()=>{e()===!0?t().next(()=>{a()},s):n()};a()})}};function M2(r){let e=r.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function Zo(r){return r.name==="IndexedDbTransactionError"}var Mo=class{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=n=>this.oe(n),this._e=n=>t.writeSequenceNumber(n))}oe(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){let e=++this.previousValue;return this._e&&this._e(e),e}};Mo.ae=-1;var Zm=-1;function jh(r){return r==null}function gu(r){return r===0&&1/r==-1/0}function F2(r){return typeof r=="number"&&Number.isInteger(r)&&!gu(r)&&r<=Number.MAX_SAFE_INTEGER&&r>=Number.MIN_SAFE_INTEGER}var kb="";function U2(r){let e="";for(let t=0;t<r.length;t++)e.length>0&&(e=Y0(e)),e=B2(r.get(t),e);return Y0(e)}function B2(r,e){let t=e,n=r.length;for(let s=0;s<n;s++){let a=r.charAt(s);switch(a){case"\0":t+="";break;case kb:t+="";break;default:t+=a}}return t}function Y0(r){return r+kb+""}var j2="remoteDocuments",Nb="owner";var Vb="mutationQueues";var Lb="mutations";var Mb="documentMutations",$2="remoteDocumentsV14";var Fb="remoteDocumentGlobal";var Ub="targets";var Bb="targetDocuments";var jb="targetGlobal",$b="collectionParents";var qb="clientMetadata";var zb="bundles";var Gb="namedQueries";var q2="indexConfiguration";var z2="indexState";var G2="indexEntries";var Kb="documentOverlays";var K2="globals";var W2=[Vb,Lb,Mb,j2,Ub,Nb,jb,Bb,qb,Fb,$b,zb,Gb],gK=[...W2,Kb],H2=[Vb,Lb,Mb,$2,Ub,Nb,jb,Bb,qb,Fb,$b,zb,Gb,Kb],Q2=H2,J2=[...Q2,q2,z2,G2];var _K=[...J2,K2];function X0(r){let e=0;for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&e++;return e}function Ti(r,e){for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&e(t,r[t])}function Wb(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(r,e))return!1;return!0}var Ye=class r{constructor(e,t){this.comparator=e,this.root=t||Kr.EMPTY}insert(e,t){return new r(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,Kr.BLACK,null,null))}remove(e){return new r(this.comparator,this.root.remove(e,this.comparator).copy(null,null,Kr.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){let n=this.comparator(e,t.key);if(n===0)return t.value;n<0?t=t.left:n>0&&(t=t.right)}return null}indexOf(e){let t=0,n=this.root;for(;!n.isEmpty();){let s=this.comparator(e,n.key);if(s===0)return t+n.left.size;s<0?n=n.left:(t+=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(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,n)=>(e(t,n),!1))}toString(){let e=[];return this.inorderTraversal((t,n)=>(e.push(`${t}:${n}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Oo(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Oo(this.root,e,this.comparator,!1)}getReverseIterator(){return new Oo(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Oo(this.root,e,this.comparator,!0)}},Oo=class{constructor(e,t,n,s){this.isReverse=s,this.nodeStack=[];let a=1;for(;!e.isEmpty();)if(a=t?n(e.key,t):1,t&&s&&(a*=-1),a<0)e=this.isReverse?e.left:e.right;else{if(a===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop(),t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;let e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}},Kr=class r{constructor(e,t,n,s,a){this.key=e,this.value=t,this.color=n!=null?n:r.RED,this.left=s!=null?s:r.EMPTY,this.right=a!=null?a:r.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,n,s,a){return new r(e!=null?e:this.key,t!=null?t:this.value,n!=null?n:this.color,s!=null?s:this.left,a!=null?a:this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,n){let s=this,a=n(e,s.key);return s=a<0?s.copy(null,null,null,s.left.insert(e,t,n),null):a===0?s.copy(null,t,null,null,null):s.copy(null,null,null,null,s.right.insert(e,t,n)),s.fixUp()}removeMin(){if(this.left.isEmpty())return r.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let n,s=this;if(t(e,s.key)<0)s.left.isEmpty()||s.left.isRed()||s.left.left.isRed()||(s=s.moveRedLeft()),s=s.copy(null,null,null,s.left.remove(e,t),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),t(e,s.key)===0){if(s.right.isEmpty())return r.EMPTY;n=s.right.min(),s=s.copy(n.key,n.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(e,t))}return s.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){let e=this.copy(null,null,r.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){let e=this.copy(null,null,r.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){let e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){let e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw ue();let e=this.left.check();if(e!==this.right.check())throw ue();return e+(this.isRed()?0:1)}};Kr.EMPTY=null,Kr.RED=!0,Kr.BLACK=!1;Kr.EMPTY=new class{constructor(){this.size=0}get key(){throw ue()}get value(){throw ue()}get color(){throw ue()}get left(){throw ue()}get right(){throw ue()}copy(e,t,n,s,a){return this}insert(e,t,n){return new Kr(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};var yt=class r{constructor(e){this.comparator=e,this.data=new Ye(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,n)=>(e(t),!1))}forEachInRange(e,t){let n=this.data.getIteratorFrom(e[0]);for(;n.hasNext();){let s=n.getNext();if(this.comparator(s.key,e[1])>=0)return;t(s.key)}}forEachWhile(e,t){let n;for(n=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();n.hasNext();)if(!e(n.getNext().key))return}firstAfterOrEqual(e){let t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new ah(this.data.getIterator())}getIteratorFrom(e){return new ah(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach(n=>{t=t.add(n)}),t}isEqual(e){if(!(e instanceof r)||this.size!==e.size)return!1;let t=this.data.getIterator(),n=e.data.getIterator();for(;t.hasNext();){let s=t.getNext().key,a=n.getNext().key;if(this.comparator(s,a)!==0)return!1}return!0}toArray(){let e=[];return this.forEach(t=>{e.push(t)}),e}toString(){let e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){let t=new r(this.comparator);return t.data=e,t}},ah=class{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}};var hr=class r{constructor(e){this.fields=e,e.sort(tr.comparator)}static empty(){return new r([])}unionWith(e){let t=new yt(tr.comparator);for(let n of this.fields)t=t.add(n);for(let n of e)t=t.add(n);return new r(t.toArray())}covers(e){for(let t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return Lo(this.fields,e.fields,(t,n)=>t.isEqual(n))}};var uh=class extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}};var Rt=class r{constructor(e){this.binaryString=e}static fromBase64String(e){let t=function(s){try{return atob(s)}catch(a){throw typeof DOMException!="undefined"&&a instanceof DOMException?new uh("Invalid base64 string: "+a):a}}(e);return new r(t)}static fromUint8Array(e){let t=function(s){let a="";for(let c=0;c<s.length;++c)a+=String.fromCharCode(s[c]);return a}(e);return new r(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function(t){return btoa(t)}(this.binaryString)}toUint8Array(){return function(t){let n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return Re(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}};Rt.EMPTY_BYTE_STRING=new Rt("");var Y2=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Cn(r){if(Le(!!r),typeof r=="string"){let e=0,t=Y2.exec(r);if(Le(!!t),t[1]){let s=t[1];s=(s+"000000000").substr(0,9),e=Number(s)}let n=new Date(r);return{seconds:Math.floor(n.getTime()/1e3),nanos:e}}return{seconds:Ge(r.seconds),nanos:Ge(r.nanos)}}function Ge(r){return typeof r=="number"?r:typeof r=="string"?Number(r):0}function Dn(r){return typeof r=="string"?Rt.fromBase64String(r):Rt.fromUint8Array(r)}var Hb="server_timestamp",Qb="__type__",Jb="__previous_value__",Yb="__local_write_time__";function eg(r){var e,t;return((t=(((e=r==null?void 0:r.mapValue)===null||e===void 0?void 0:e.fields)||{})[Qb])===null||t===void 0?void 0:t.stringValue)===Hb}function $h(r){let e=r.mapValue.fields[Jb];return eg(e)?$h(e):e}function _u(r){let e=Cn(r.mapValue.fields[Yb].timestampValue);return new wt(e.seconds,e.nanos)}var xp=class{constructor(e,t,n,s,a,c,h,f,m){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=s,this.ssl=a,this.forceLongPolling=c,this.autoDetectLongPolling=h,this.longPollingOptions=f,this.useFetchStreams=m}},ch="(default)",lh=class r{constructor(e,t){this.projectId=e,this.database=t||ch}static empty(){return new r("","")}get isDefaultDatabase(){return this.database===ch}isEqual(e){return e instanceof r&&e.projectId===this.projectId&&e.database===this.database}};var tg="__type__",Xb="__max__",Yl={mapValue:{fields:{__type__:{stringValue:Xb}}}},rg="__vector__",Fo="value";function yi(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?eg(r)?4:eT(r)?9007199254740991:Zb(r)?10:11:ue()}function Jr(r,e){if(r===e)return!0;let t=yi(r);if(t!==yi(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return r.booleanValue===e.booleanValue;case 4:return _u(r).isEqual(_u(e));case 3:return function(s,a){if(typeof s.timestampValue=="string"&&typeof a.timestampValue=="string"&&s.timestampValue.length===a.timestampValue.length)return s.timestampValue===a.timestampValue;let c=Cn(s.timestampValue),h=Cn(a.timestampValue);return c.seconds===h.seconds&&c.nanos===h.nanos}(r,e);case 5:return r.stringValue===e.stringValue;case 6:return function(s,a){return Dn(s.bytesValue).isEqual(Dn(a.bytesValue))}(r,e);case 7:return r.referenceValue===e.referenceValue;case 8:return function(s,a){return Ge(s.geoPointValue.latitude)===Ge(a.geoPointValue.latitude)&&Ge(s.geoPointValue.longitude)===Ge(a.geoPointValue.longitude)}(r,e);case 2:return function(s,a){if("integerValue"in s&&"integerValue"in a)return Ge(s.integerValue)===Ge(a.integerValue);if("doubleValue"in s&&"doubleValue"in a){let c=Ge(s.doubleValue),h=Ge(a.doubleValue);return c===h?gu(c)===gu(h):isNaN(c)&&isNaN(h)}return!1}(r,e);case 9:return Lo(r.arrayValue.values||[],e.arrayValue.values||[],Jr);case 10:case 11:return function(s,a){let c=s.mapValue.fields||{},h=a.mapValue.fields||{};if(X0(c)!==X0(h))return!1;for(let f in c)if(c.hasOwnProperty(f)&&(h[f]===void 0||!Jr(c[f],h[f])))return!1;return!0}(r,e);default:return ue()}}function yu(r,e){return(r.values||[]).find(t=>Jr(t,e))!==void 0}function Uo(r,e){if(r===e)return 0;let t=yi(r),n=yi(e);if(t!==n)return Re(t,n);switch(t){case 0:case 9007199254740991:return 0;case 1:return Re(r.booleanValue,e.booleanValue);case 2:return function(a,c){let h=Ge(a.integerValue||a.doubleValue),f=Ge(c.integerValue||c.doubleValue);return h<f?-1:h>f?1:h===f?0:isNaN(h)?isNaN(f)?0:-1:1}(r,e);case 3:return Z0(r.timestampValue,e.timestampValue);case 4:return Z0(_u(r),_u(e));case 5:return Re(r.stringValue,e.stringValue);case 6:return function(a,c){let h=Dn(a),f=Dn(c);return h.compareTo(f)}(r.bytesValue,e.bytesValue);case 7:return function(a,c){let h=a.split("/"),f=c.split("/");for(let m=0;m<h.length&&m<f.length;m++){let _=Re(h[m],f[m]);if(_!==0)return _}return Re(h.length,f.length)}(r.referenceValue,e.referenceValue);case 8:return function(a,c){let h=Re(Ge(a.latitude),Ge(c.latitude));return h!==0?h:Re(Ge(a.longitude),Ge(c.longitude))}(r.geoPointValue,e.geoPointValue);case 9:return eb(r.arrayValue,e.arrayValue);case 10:return function(a,c){var h,f,m,_;let E=a.fields||{},I=c.fields||{},k=(h=E[Fo])===null||h===void 0?void 0:h.arrayValue,B=(f=I[Fo])===null||f===void 0?void 0:f.arrayValue,G=Re(((m=k==null?void 0:k.values)===null||m===void 0?void 0:m.length)||0,((_=B==null?void 0:B.values)===null||_===void 0?void 0:_.length)||0);return G!==0?G:eb(k,B)}(r.mapValue,e.mapValue);case 11:return function(a,c){if(a===Yl.mapValue&&c===Yl.mapValue)return 0;if(a===Yl.mapValue)return 1;if(c===Yl.mapValue)return-1;let h=a.fields||{},f=Object.keys(h),m=c.fields||{},_=Object.keys(m);f.sort(),_.sort();for(let E=0;E<f.length&&E<_.length;++E){let I=Re(f[E],_[E]);if(I!==0)return I;let k=Uo(h[f[E]],m[_[E]]);if(k!==0)return k}return Re(f.length,_.length)}(r.mapValue,e.mapValue);default:throw ue()}}function Z0(r,e){if(typeof r=="string"&&typeof e=="string"&&r.length===e.length)return Re(r,e);let t=Cn(r),n=Cn(e),s=Re(t.seconds,n.seconds);return s!==0?s:Re(t.nanos,n.nanos)}function eb(r,e){let t=r.values||[],n=e.values||[];for(let s=0;s<t.length&&s<n.length;++s){let a=Uo(t[s],n[s]);if(a)return a}return Re(t.length,n.length)}function Bo(r){return Ap(r)}function Ap(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(t){let n=Cn(t);return`time(${n.seconds},${n.nanos})`}(r.timestampValue):"stringValue"in r?r.stringValue:"bytesValue"in r?function(t){return Dn(t).toBase64()}(r.bytesValue):"referenceValue"in r?function(t){return ce.fromName(t).toString()}(r.referenceValue):"geoPointValue"in r?function(t){return`geo(${t.latitude},${t.longitude})`}(r.geoPointValue):"arrayValue"in r?function(t){let n="[",s=!0;for(let a of t.values||[])s?s=!1:n+=",",n+=Ap(a);return n+"]"}(r.arrayValue):"mapValue"in r?function(t){let n=Object.keys(t.fields||{}).sort(),s="{",a=!0;for(let c of n)a?a=!1:s+=",",s+=`${c}:${Ap(t.fields[c])}`;return s+"}"}(r.mapValue):ue()}function eh(r){switch(yi(r)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let e=$h(r);return e?16+eh(e):16;case 5:return 2*r.stringValue.length;case 6:return Dn(r.bytesValue).approximateByteSize();case 7:return r.referenceValue.length;case 9:return function(n){return(n.values||[]).reduce((s,a)=>s+eh(a),0)}(r.arrayValue);case 10:case 11:return function(n){let s=0;return Ti(n.fields,(a,c)=>{s+=a.length+eh(c)}),s}(r.mapValue);default:throw ue()}}function Sp(r){return!!r&&"integerValue"in r}function ng(r){return!!r&&"arrayValue"in r}function tb(r){return!!r&&"nullValue"in r}function rb(r){return!!r&&"doubleValue"in r&&isNaN(Number(r.doubleValue))}function th(r){return!!r&&"mapValue"in r}function Zb(r){var e,t;return((t=(((e=r==null?void 0:r.mapValue)===null||e===void 0?void 0:e.fields)||{})[tg])===null||t===void 0?void 0:t.stringValue)===rg}function hu(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){let e={mapValue:{fields:{}}};return Ti(r.mapValue.fields,(t,n)=>e.mapValue.fields[t]=hu(n)),e}if(r.arrayValue){let e={arrayValue:{values:[]}};for(let t=0;t<(r.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=hu(r.arrayValue.values[t]);return e}return Object.assign({},r)}function eT(r){return(((r.mapValue||{}).fields||{}).__type__||{}).stringValue===Xb}var vK={mapValue:{fields:{[tg]:{stringValue:rg},[Fo]:{arrayValue:{}}}}};var er=class r{constructor(e){this.value=e}static empty(){return new r({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let n=0;n<e.length-1;++n)if(t=(t.mapValue.fields||{})[e.get(n)],!th(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=hu(t)}setAll(e){let t=tr.emptyPath(),n={},s=[];e.forEach((c,h)=>{if(!t.isImmediateParentOf(h)){let f=this.getFieldsMap(t);this.applyChanges(f,n,s),n={},s=[],t=h.popLast()}c?n[h.lastSegment()]=hu(c):s.push(h.lastSegment())});let a=this.getFieldsMap(t);this.applyChanges(a,n,s)}delete(e){let t=this.field(e.popLast());th(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Jr(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let n=0;n<e.length;++n){let s=t.mapValue.fields[e.get(n)];th(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=s),t=s}return t.mapValue.fields}applyChanges(e,t,n){Ti(t,(s,a)=>e[s]=a);for(let s of n)delete e[s]}clone(){return new r(hu(this.value))}};function tT(r){let e=[];return Ti(r.fields,(t,n)=>{let s=new tr([t]);if(th(n)){let a=tT(n.mapValue).fields;if(a.length===0)e.push(s);else for(let c of a)e.push(s.child(c))}else e.push(s)}),new hr(e)}var Sr=class r{constructor(e,t,n,s,a,c,h){this.key=e,this.documentType=t,this.version=n,this.readTime=s,this.createTime=a,this.data=c,this.documentState=h}static newInvalidDocument(e){return new r(e,0,me.min(),me.min(),me.min(),er.empty(),0)}static newFoundDocument(e,t,n,s){return new r(e,1,t,me.min(),n,s,0)}static newNoDocument(e,t){return new r(e,2,t,me.min(),me.min(),er.empty(),0)}static newUnknownDocument(e,t){return new r(e,3,t,me.min(),me.min(),er.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(me.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=er.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=er.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=me.min(),this}setReadTime(e){return this.readTime=e,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(e){return e instanceof r&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new r(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}})`}};var jo=class{constructor(e,t){this.position=e,this.inclusive=t}};function nb(r,e,t){let n=0;for(let s=0;s<r.position.length;s++){let a=e[s],c=r.position[s];if(a.field.isKeyField()?n=ce.comparator(ce.fromName(c.referenceValue),t.key):n=Uo(c,t.data.field(a.field)),a.dir==="desc"&&(n*=-1),n!==0)break}return n}function ib(r,e){if(r===null)return e===null;if(e===null||r.inclusive!==e.inclusive||r.position.length!==e.position.length)return!1;for(let t=0;t<r.position.length;t++)if(!Jr(r.position[t],e.position[t]))return!1;return!0}var $o=class{constructor(e,t="asc"){this.field=e,this.dir=t}};function X2(r,e){return r.dir===e.dir&&r.field.isEqual(e.field)}var hh=class{},pt=class r extends hh{constructor(e,t,n){super(),this.field=e,this.op=t,this.value=n}static create(e,t,n){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,n):new Pp(e,t,n):t==="array-contains"?new Op(e,n):t==="in"?new kp(e,n):t==="not-in"?new Np(e,n):t==="array-contains-any"?new Vp(e,n):new r(e,t,n)}static createKeyFieldInFilter(e,t,n){return t==="in"?new Cp(e,n):new Dp(e,n)}matches(e){let t=e.data.field(this.field);return this.op==="!="?t!==null&&this.matchesComparison(Uo(t,this.value)):t!==null&&yi(this.value)===yi(t)&&this.matchesComparison(Uo(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return ue()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}},Yr=class r extends hh{constructor(e,t){super(),this.filters=e,this.op=t,this.ce=null}static create(e,t){return new r(e,t)}matches(e){return rT(this)?this.filters.find(t=>!t.matches(e))===void 0:this.filters.find(t=>t.matches(e))!==void 0}getFlattenedFilters(){return this.ce!==null||(this.ce=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.ce}getFilters(){return Object.assign([],this.filters)}};function rT(r){return r.op==="and"}function nT(r){return Z2(r)&&rT(r)}function Z2(r){for(let e of r.filters)if(e instanceof Yr)return!1;return!0}function Rp(r){if(r instanceof pt)return r.field.canonicalString()+r.op.toString()+Bo(r.value);if(nT(r))return r.filters.map(e=>Rp(e)).join(",");{let e=r.filters.map(t=>Rp(t)).join(",");return`${r.op}(${e})`}}function iT(r,e){return r instanceof pt?function(n,s){return s instanceof pt&&n.op===s.op&&n.field.isEqual(s.field)&&Jr(n.value,s.value)}(r,e):r instanceof Yr?function(n,s){return s instanceof Yr&&n.op===s.op&&n.filters.length===s.filters.length?n.filters.reduce((a,c,h)=>a&&iT(c,s.filters[h]),!0):!1}(r,e):void ue()}function sT(r){return r instanceof pt?function(t){return`${t.field.canonicalString()} ${t.op} ${Bo(t.value)}`}(r):r instanceof Yr?function(t){return t.op.toString()+" {"+t.getFilters().map(sT).join(" ,")+"}"}(r):"Filter"}var Pp=class extends pt{constructor(e,t,n){super(e,t,n),this.key=ce.fromName(n.referenceValue)}matches(e){let t=ce.comparator(e.key,this.key);return this.matchesComparison(t)}},Cp=class extends pt{constructor(e,t){super(e,"in",t),this.keys=oT("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}},Dp=class extends pt{constructor(e,t){super(e,"not-in",t),this.keys=oT("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}};function oT(r,e){var t;return(((t=e.arrayValue)===null||t===void 0?void 0:t.values)||[]).map(n=>ce.fromName(n.referenceValue))}var Op=class extends pt{constructor(e,t){super(e,"array-contains",t)}matches(e){let t=e.data.field(this.field);return ng(t)&&yu(t.arrayValue,this.value)}},kp=class extends pt{constructor(e,t){super(e,"in",t)}matches(e){let t=e.data.field(this.field);return t!==null&&yu(this.value.arrayValue,t)}},Np=class extends pt{constructor(e,t){super(e,"not-in",t)}matches(e){if(yu(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;let t=e.data.field(this.field);return t!==null&&!yu(this.value.arrayValue,t)}},Vp=class extends pt{constructor(e,t){super(e,"array-contains-any",t)}matches(e){let t=e.data.field(this.field);return!(!ng(t)||!t.arrayValue.values)&&t.arrayValue.values.some(n=>yu(this.value.arrayValue,n))}};var Lp=class{constructor(e,t=null,n=[],s=[],a=null,c=null,h=null){this.path=e,this.collectionGroup=t,this.orderBy=n,this.filters=s,this.limit=a,this.startAt=c,this.endAt=h,this.le=null}};function sb(r,e=null,t=[],n=[],s=null,a=null,c=null){return new Lp(r,e,t,n,s,a,c)}function ig(r){let e=fe(r);if(e.le===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(n=>Rp(n)).join(","),t+="|ob:",t+=e.orderBy.map(n=>function(a){return a.field.canonicalString()+a.dir}(n)).join(","),jh(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(n=>Bo(n)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(n=>Bo(n)).join(",")),e.le=t}return e.le}function sg(r,e){if(r.limit!==e.limit||r.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<r.orderBy.length;t++)if(!X2(r.orderBy[t],e.orderBy[t]))return!1;if(r.filters.length!==e.filters.length)return!1;for(let t=0;t<r.filters.length;t++)if(!iT(r.filters[t],e.filters[t]))return!1;return r.collectionGroup===e.collectionGroup&&!!r.path.isEqual(e.path)&&!!ib(r.startAt,e.startAt)&&ib(r.endAt,e.endAt)}function Mp(r){return ce.isDocumentKey(r.path)&&r.collectionGroup===null&&r.filters.length===0}var qo=class{constructor(e,t=null,n=[],s=[],a=null,c="F",h=null,f=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=s,this.limit=a,this.limitType=c,this.startAt=h,this.endAt=f,this.he=null,this.Pe=null,this.Te=null,this.startAt,this.endAt}};function eM(r,e,t,n,s,a,c,h){return new qo(r,e,t,n,s,a,c,h)}function qh(r){return new qo(r)}function ob(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 tM(r){return r.collectionGroup!==null}function fu(r){let e=fe(r);if(e.he===null){e.he=[];let t=new Set;for(let a of e.explicitOrderBy)e.he.push(a),t.add(a.field.canonicalString());let n=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(c){let h=new yt(tr.comparator);return c.filters.forEach(f=>{f.getFlattenedFilters().forEach(m=>{m.isInequality()&&(h=h.add(m.field))})}),h})(e).forEach(a=>{t.has(a.canonicalString())||a.isKeyField()||e.he.push(new $o(a,n))}),t.has(tr.keyField().canonicalString())||e.he.push(new $o(tr.keyField(),n))}return e.he}function Wr(r){let e=fe(r);return e.Pe||(e.Pe=rM(e,fu(r))),e.Pe}function rM(r,e){if(r.limitType==="F")return sb(r.path,r.collectionGroup,e,r.filters,r.limit,r.startAt,r.endAt);{e=e.map(s=>{let a=s.dir==="desc"?"asc":"desc";return new $o(s.field,a)});let t=r.endAt?new jo(r.endAt.position,r.endAt.inclusive):null,n=r.startAt?new jo(r.startAt.position,r.startAt.inclusive):null;return sb(r.path,r.collectionGroup,e,r.filters,r.limit,t,n)}}function Fp(r,e,t){return new qo(r.path,r.collectionGroup,r.explicitOrderBy.slice(),r.filters.slice(),e,t,r.startAt,r.endAt)}function zh(r,e){return sg(Wr(r),Wr(e))&&r.limitType===e.limitType}function aT(r){return`${ig(Wr(r))}|lt:${r.limitType}`}function Po(r){return`Query(target=${function(t){let n=t.path.canonicalString();return t.collectionGroup!==null&&(n+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(n+=`, filters: [${t.filters.map(s=>sT(s)).join(", ")}]`),jh(t.limit)||(n+=", limit: "+t.limit),t.orderBy.length>0&&(n+=`, orderBy: [${t.orderBy.map(s=>function(c){return`${c.field.canonicalString()} (${c.dir})`}(s)).join(", ")}]`),t.startAt&&(n+=", startAt: ",n+=t.startAt.inclusive?"b:":"a:",n+=t.startAt.position.map(s=>Bo(s)).join(",")),t.endAt&&(n+=", endAt: ",n+=t.endAt.inclusive?"a:":"b:",n+=t.endAt.position.map(s=>Bo(s)).join(",")),`Target(${n})`}(Wr(r))}; limitType=${r.limitType})`}function Gh(r,e){return e.isFoundDocument()&&function(n,s){let a=s.key.path;return n.collectionGroup!==null?s.key.hasCollectionId(n.collectionGroup)&&n.path.isPrefixOf(a):ce.isDocumentKey(n.path)?n.path.isEqual(a):n.path.isImmediateParentOf(a)}(r,e)&&function(n,s){for(let a of fu(n))if(!a.field.isKeyField()&&s.data.field(a.field)===null)return!1;return!0}(r,e)&&function(n,s){for(let a of n.filters)if(!a.matches(s))return!1;return!0}(r,e)&&function(n,s){return!(n.startAt&&!function(c,h,f){let m=nb(c,h,f);return c.inclusive?m<=0:m<0}(n.startAt,fu(n),s)||n.endAt&&!function(c,h,f){let m=nb(c,h,f);return c.inclusive?m>=0:m>0}(n.endAt,fu(n),s))}(r,e)}function nM(r){return r.collectionGroup||(r.path.length%2==1?r.path.lastSegment():r.path.get(r.path.length-2))}function uT(r){return(e,t)=>{let n=!1;for(let s of fu(r)){let a=iM(s,e,t);if(a!==0)return a;n=n||s.field.isKeyField()}return 0}}function iM(r,e,t){let n=r.field.isKeyField()?ce.comparator(e.key,t.key):function(a,c,h){let f=c.data.field(a),m=h.data.field(a);return f!==null&&m!==null?Uo(f,m):ue()}(r.field,e,t);switch(r.dir){case"asc":return n;case"desc":return-1*n;default:return ue()}}var On=class{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){let t=this.mapKeyFn(e),n=this.inner[t];if(n!==void 0){for(let[s,a]of n)if(this.equalsFn(s,e))return a}}has(e){return this.get(e)!==void 0}set(e,t){let n=this.mapKeyFn(e),s=this.inner[n];if(s===void 0)return this.inner[n]=[[e,t]],void this.innerSize++;for(let a=0;a<s.length;a++)if(this.equalsFn(s[a][0],e))return void(s[a]=[e,t]);s.push([e,t]),this.innerSize++}delete(e){let t=this.mapKeyFn(e),n=this.inner[t];if(n===void 0)return!1;for(let s=0;s<n.length;s++)if(this.equalsFn(n[s][0],e))return n.length===1?delete this.inner[t]:n.splice(s,1),this.innerSize--,!0;return!1}forEach(e){Ti(this.inner,(t,n)=>{for(let[s,a]of n)e(s,a)})}isEmpty(){return Wb(this.inner)}size(){return this.innerSize}};var sM=new Ye(ce.comparator);function kn(){return sM}var cT=new Ye(ce.comparator);function lu(...r){let e=cT;for(let t of r)e=e.insert(t.key,t);return e}function lT(r){let e=cT;return r.forEach((t,n)=>e=e.insert(t,n.overlayedDocument)),e}function os(){return du()}function hT(){return du()}function du(){return new On(r=>r.toString(),(r,e)=>r.isEqual(e))}var oM=new Ye(ce.comparator),aM=new yt(ce.comparator);function xe(...r){let e=aM;for(let t of r)e=e.add(t);return e}var uM=new yt(Re);function cM(){return uM}function og(r,e){if(r.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:gu(e)?"-0":e}}function fT(r){return{integerValue:""+r}}function lM(r,e){return F2(e)?fT(e):og(r,e)}var zo=class{constructor(){this._=void 0}};function hM(r,e,t){return r instanceof Go?function(s,a){let c={fields:{[Qb]:{stringValue:Hb},[Yb]:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return a&&eg(a)&&(a=$h(a)),a&&(c.fields[Jb]=a),{mapValue:c}}(t,e):r instanceof hs?pT(r,e):r instanceof fs?mT(r,e):function(s,a){let c=dT(s,a),h=ab(c)+ab(s.Ie);return Sp(c)&&Sp(s.Ie)?fT(h):og(s.serializer,h)}(r,e)}function fM(r,e,t){return r instanceof hs?pT(r,e):r instanceof fs?mT(r,e):t}function dT(r,e){return r instanceof Ko?function(n){return Sp(n)||function(a){return!!a&&"doubleValue"in a}(n)}(e)?e:{integerValue:0}:null}var Go=class extends zo{},hs=class extends zo{constructor(e){super(),this.elements=e}};function pT(r,e){let t=gT(e);for(let n of r.elements)t.some(s=>Jr(s,n))||t.push(n);return{arrayValue:{values:t}}}var fs=class extends zo{constructor(e){super(),this.elements=e}};function mT(r,e){let t=gT(e);for(let n of r.elements)t=t.filter(s=>!Jr(s,n));return{arrayValue:{values:t}}}var Ko=class extends zo{constructor(e,t){super(),this.serializer=e,this.Ie=t}};function ab(r){return Ge(r.integerValue||r.doubleValue)}function gT(r){return ng(r)&&r.arrayValue.values?r.arrayValue.values.slice():[]}function dM(r,e){return r.field.isEqual(e.field)&&function(n,s){return n instanceof hs&&s instanceof hs||n instanceof fs&&s instanceof fs?Lo(n.elements,s.elements,Jr):n instanceof Ko&&s instanceof Ko?Jr(n.Ie,s.Ie):n instanceof Go&&s instanceof Go}(r.transform,e.transform)}var Up=class{constructor(e,t){this.version=e,this.transformResults=t}},_i=class r{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new r}static exists(e){return new r(void 0,e)}static updateTime(e){return new r(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}};function rh(r,e){return r.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(r.updateTime):r.exists===void 0||r.exists===e.isFoundDocument()}var Wo=class{};function _T(r,e){if(!r.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return r.isNoDocument()?new fh(r.key,_i.none()):new ds(r.key,r.data,_i.none());{let t=r.data,n=er.empty(),s=new yt(tr.comparator);for(let a of e.fields)if(!s.has(a)){let c=t.field(a);c===null&&a.length>1&&(a=a.popLast(),c=t.field(a)),c===null?n.delete(a):n.set(a,c),s=s.add(a)}return new Xr(r.key,n,new hr(s.toArray()),_i.none())}}function pM(r,e,t){r instanceof ds?function(s,a,c){let h=s.value.clone(),f=cb(s.fieldTransforms,a,c.transformResults);h.setAll(f),a.convertToFoundDocument(c.version,h).setHasCommittedMutations()}(r,e,t):r instanceof Xr?function(s,a,c){if(!rh(s.precondition,a))return void a.convertToUnknownDocument(c.version);let h=cb(s.fieldTransforms,a,c.transformResults),f=a.data;f.setAll(yT(s)),f.setAll(h),a.convertToFoundDocument(c.version,f).setHasCommittedMutations()}(r,e,t):function(s,a,c){a.convertToNoDocument(c.version).setHasCommittedMutations()}(0,e,t)}function pu(r,e,t,n){return r instanceof ds?function(a,c,h,f){if(!rh(a.precondition,c))return h;let m=a.value.clone(),_=lb(a.fieldTransforms,f,c);return m.setAll(_),c.convertToFoundDocument(c.version,m).setHasLocalMutations(),null}(r,e,t,n):r instanceof Xr?function(a,c,h,f){if(!rh(a.precondition,c))return h;let m=lb(a.fieldTransforms,f,c),_=c.data;return _.setAll(yT(a)),_.setAll(m),c.convertToFoundDocument(c.version,_).setHasLocalMutations(),h===null?null:h.unionWith(a.fieldMask.fields).unionWith(a.fieldTransforms.map(E=>E.field))}(r,e,t,n):function(a,c,h){return rh(a.precondition,c)?(c.convertToNoDocument(c.version).setHasLocalMutations(),null):h}(r,e,t)}function mM(r,e){let t=null;for(let n of r.fieldTransforms){let s=e.data.field(n.field),a=dT(n.transform,s||null);a!=null&&(t===null&&(t=er.empty()),t.set(n.field,a))}return t||null}function ub(r,e){return r.type===e.type&&!!r.key.isEqual(e.key)&&!!r.precondition.isEqual(e.precondition)&&!!function(n,s){return n===void 0&&s===void 0||!(!n||!s)&&Lo(n,s,(a,c)=>dM(a,c))}(r.fieldTransforms,e.fieldTransforms)&&(r.type===0?r.value.isEqual(e.value):r.type!==1||r.data.isEqual(e.data)&&r.fieldMask.isEqual(e.fieldMask))}var ds=class extends Wo{constructor(e,t,n,s=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}},Xr=class extends Wo{constructor(e,t,n,s,a=[]){super(),this.key=e,this.data=t,this.fieldMask=n,this.precondition=s,this.fieldTransforms=a,this.type=1}getFieldMask(){return this.fieldMask}};function yT(r){let e=new Map;return r.fieldMask.fields.forEach(t=>{if(!t.isEmpty()){let n=r.data.field(t);e.set(t,n)}}),e}function cb(r,e,t){let n=new Map;Le(r.length===t.length);for(let s=0;s<t.length;s++){let a=r[s],c=a.transform,h=e.data.field(a.field);n.set(a.field,fM(c,h,t[s]))}return n}function lb(r,e,t){let n=new Map;for(let s of r){let a=s.transform,c=t.data.field(s.field);n.set(s.field,hM(a,c,e))}return n}var fh=class extends Wo{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}},Bp=class extends Wo{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}};var jp=class{constructor(e,t,n,s){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=s}applyToRemoteDocument(e,t){let n=t.mutationResults;for(let s=0;s<this.mutations.length;s++){let a=this.mutations[s];a.key.isEqual(e.key)&&pM(a,e,n[s])}}applyToLocalView(e,t){for(let n of this.baseMutations)n.key.isEqual(e.key)&&(t=pu(n,e,t,this.localWriteTime));for(let n of this.mutations)n.key.isEqual(e.key)&&(t=pu(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let n=hT();return this.mutations.forEach(s=>{let a=e.get(s.key),c=a.overlayedDocument,h=this.applyToLocalView(c,a.mutatedFields);h=t.has(s.key)?null:h;let f=_T(c,h);f!==null&&n.set(s.key,f),c.isValidDocument()||c.convertToNoDocument(me.min())}),n}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),xe())}isEqual(e){return this.batchId===e.batchId&&Lo(this.mutations,e.mutations,(t,n)=>ub(t,n))&&Lo(this.baseMutations,e.baseMutations,(t,n)=>ub(t,n))}},$p=class r{constructor(e,t,n,s){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=s}static from(e,t,n){Le(e.mutations.length===n.length);let s=function(){return oM}(),a=e.mutations;for(let c=0;c<a.length;c++)s=s.insert(a[c].key,n[c].version);return new r(e,t,n,s)}};var qp=class{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{
|
|
28
|
+
`);for(let b=0;b<u.length;b++){if(ee(u[b]))continue;var g=V(u[b]);let L=g[0];if(g=g[1],typeof g!="string")continue;g=g.trim();let F=d[L]||[];d[L]=F,F.push(g)}C(d,function(b){return b.join(", ")})}r.Ba=function(){return this.m},r.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function Gn(u,d,g){return g&&g.internalChannelParams&&g.internalChannelParams[u]||d}function Na(u){this.Aa=0,this.i=[],this.j=new Ni,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=Gn("failFast",!1,u),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=Gn("baseRetryDelayMs",5e3,u),this.cb=Gn("retryDelaySeedMs",1e4,u),this.Wa=Gn("forwardChannelMaxRetries",2,u),this.wa=Gn("forwardChannelRequestTimeoutMs",2e4,u),this.pa=u&&u.xmlHttpFactory||void 0,this.Xa=u&&u.Tb||void 0,this.Ca=u&&u.useFetchStreams||!1,this.L=void 0,this.J=u&&u.supportsCrossDomainXhr||!1,this.K="",this.h=new vc(u&&u.concurrentRequestLimit),this.Da=new kf,this.P=u&&u.fastHandshake||!1,this.O=u&&u.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=u&&u.Rb||!1,u&&u.xa&&this.j.xa(),u&&u.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&u&&u.detectBufferingProxy||!1,this.ja=void 0,u&&u.longPollingTimeout&&0<u.longPollingTimeout&&(this.ja=u.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}r=Na.prototype,r.la=8,r.G=1,r.connect=function(u,d,g,b){ct(0),this.W=u,this.H=d||{},g&&b!==void 0&&(this.H.OSID=g,this.H.OAID=b),this.F=this.X,this.I=Mc(this,null,this.W),Ws(this)};function Ks(u){if(Et(u),u.G==3){var d=u.U++,g=gr(u.I);if(Ce(g,"SID",u.K),Ce(g,"RID",d),Ce(g,"TYPE","terminate"),Kn(u,g),d=new Nr(u,u.j,d),d.L=2,d.v=Ui(gr(g)),g=!1,h.navigator&&h.navigator.sendBeacon)try{g=h.navigator.sendBeacon(d.v.toString(),"")}catch{}!g&&h.Image&&(new Image().src=d.v,g=!0),g||(d.g=Va(d.j,null),d.g.ea(d.v)),d.F=Date.now(),Us(d)}Lc(u)}function Gi(u){u.g&&(Fe(u),u.g.cancel(),u.g=null)}function Et(u){Gi(u),u.u&&(h.clearTimeout(u.u),u.u=null),Wn(u),u.h.cancel(),u.s&&(typeof u.s=="number"&&h.clearTimeout(u.s),u.s=null)}function Ws(u){if(!Aa(u.h)&&!u.s){u.s=!0;var d=u.Ga;Ai||ac(),Cr||(Ai(),Cr=!0),Lt.add(d,u),u.B=0}}function Ft(u,d){return Sa(u.h)>=u.h.j-(u.s?1:0)?!1:u.s?(u.i=d.D.concat(u.i),!0):u.G==1||u.G==2||u.B>=(u.Va?0:u.Wa)?!1:(u.s=ki(I(u.Ga,u,d),Hs(u,u.B)),u.B++,!0)}r.Ga=function(u){if(this.s)if(this.s=null,this.G==1){if(!u){this.U=Math.floor(1e5*Math.random()),u=this.U++;let L=new Nr(this,this.j,u),F=this.o;if(this.S&&(F?(F=A(F),D(F,this.S)):F=this.S),this.m!==null||this.O||(L.H=F,F=null),this.P)e:{for(var d=0,g=0;g<this.i.length;g++){t:{var b=this.i[g];if("__data__"in b.map&&(b=b.map.__data__,typeof b=="string")){b=b.length;break t}b=void 0}if(b===void 0)break;if(d+=b,4096<d){d=g;break e}if(d===4096||g===this.i.length-1){d=g+1;break e}}d=1e3}else d=1e3;d=yr(this,L,d),g=gr(this.I),Ce(g,"RID",u),Ce(g,"CVER",22),this.D&&Ce(g,"X-HTTP-Session-Id",this.D),Kn(this,g),F&&(this.O?d="headers="+encodeURIComponent(String(Dc(F)))+"&"+d:this.m&&Oa(g,this.m,F)),Mi(this.h,L),this.Ua&&Ce(g,"TYPE","init"),this.P?(Ce(g,"$req",d),Ce(g,"SID","null"),L.T=!0,Ea(L,g,null)):Ea(L,g,d),this.G=2}}else this.G==3&&(u?Nc(this,u):this.i.length==0||Aa(this.h)||Nc(this))};function Nc(u,d){var g;d?g=d.l:g=u.U++;let b=gr(u.I);Ce(b,"SID",u.K),Ce(b,"RID",g),Ce(b,"AID",u.T),Kn(u,b),u.m&&u.o&&Oa(b,u.m,u.o),g=new Nr(u,u.j,g,u.B+1),u.m===null&&(g.H=u.o),d&&(u.i=d.D.concat(u.i)),d=yr(u,g,1e3),g.I=Math.round(.5*u.wa)+Math.round(.5*u.wa*Math.random()),Mi(u.h,g),Ea(g,b,d)}function Kn(u,d){u.H&&ie(u.H,function(g,b){Ce(d,b,g)}),u.l&&Tc({},function(g,b){Ce(d,b,g)})}function yr(u,d,g){g=Math.min(u.i.length,g);var b=u.l?I(u.l.Na,u.l,u):null;e:{var L=u.i;let F=-1;for(;;){let Q=["count="+g];F==-1?0<g?(F=L[0].g,Q.push("ofs="+F)):F=0:Q.push("ofs="+F);let _e=!0;for(let Ze=0;Ze<g;Ze++){let be=L[Ze].g,lt=L[Ze].map;if(be-=F,0>be)F=Math.max(0,L[Ze].g-100),_e=!1;else try{Nf(lt,Q,"req"+be+"_")}catch{b&&b(lt)}}if(_e){b=Q.join("&");break e}}}return u=u.i.splice(0,g),d.D=u,b}function Ki(u){if(!u.g&&!u.u){u.Y=1;var d=u.Fa;Ai||ac(),Cr||(Ai(),Cr=!0),Lt.add(d,u),u.v=0}}function Wi(u){return u.g||u.u||3<=u.v?!1:(u.Y++,u.u=ki(I(u.Fa,u),Hs(u,u.v)),u.v++,!0)}r.Fa=function(){if(this.u=null,vr(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var u=2*this.R;this.j.info("BP detection timer enabled: "+u),this.A=ki(I(this.ab,this),u)}},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,ct(10),Gi(this),vr(this))};function Fe(u){u.A!=null&&(h.clearTimeout(u.A),u.A=null)}function vr(u){u.g=new Nr(u,u.j,"rpc",u.Y),u.m===null&&(u.g.H=u.o),u.g.O=0;var d=gr(u.qa);Ce(d,"RID","rpc"),Ce(d,"SID",u.K),Ce(d,"AID",u.T),Ce(d,"CI",u.F?"0":"1"),!u.F&&u.ja&&Ce(d,"TO",u.ja),Ce(d,"TYPE","xmlhttp"),Kn(u,d),u.m&&u.o&&Oa(d,u.m,u.o),u.L&&(u.g.I=u.L);var g=u.g;u=u.ia,g.L=1,g.v=Ui(gr(d)),g.m=null,g.P=!0,Li(g,u)}r.Za=function(){this.C!=null&&(this.C=null,Gi(this),Wi(this),ct(19))};function Wn(u){u.C!=null&&(h.clearTimeout(u.C),u.C=null)}function Vc(u,d){var g=null;if(u.g==d){Wn(u),Fe(u),u.g=null;var b=2}else if(js(u.h,d))g=d.D,wc(u.h,d),b=1;else return;if(u.G!=0){if(d.o)if(b==1){g=d.m?d.m.length:0,d=Date.now()-d.F;var L=u.B;b=Ms(),ut(b,new pc(b,g)),Ws(u)}else Ki(u);else if(L=d.s,L==3||L==0&&0<d.X||!(b==1&&Ft(u,d)||b==2&&Wi(u)))switch(g&&0<g.length&&(d=u.h,d.i=d.i.concat(g)),L){case 1:cn(u,5);break;case 4:cn(u,10);break;case 3:cn(u,6);break;default:cn(u,2)}}}function Hs(u,d){let g=u.Ta+Math.floor(Math.random()*u.cb);return u.isActive()||(g*=2),g*d}function cn(u,d){if(u.j.info("Error code "+d),d==2){var g=I(u.fb,u),b=u.Xa;let L=!b;b=new mr(b||"//www.google.com/images/cleardot.gif"),h.location&&h.location.protocol=="http"||Fi(b,"https"),Ui(b),L?Df(b.toString(),g):Of(b.toString(),g)}else ct(2);u.G=0,u.l&&u.l.sa(d),Lc(u),Et(u)}r.fb=function(u){u?(this.j.info("Successfully pinged google.com"),ct(2)):(this.j.info("Failed to ping google.com"),ct(1))};function Lc(u){if(u.G=0,u.ka=[],u.l){let d=Ra(u.h);(d.length!=0||u.i.length!=0)&&(j(u.ka,d),j(u.ka,u.i),u.h.i.length=0,G(u.i),u.i.length=0),u.l.ra()}}function Mc(u,d,g){var b=g instanceof mr?gr(g):new mr(g);if(b.g!="")d&&(b.g=d+"."+b.g),$n(b,b.s);else{var L=h.location;b=L.protocol,d=d?d+"."+L.hostname:L.hostname,L=+L.port;var F=new mr(null);b&&Fi(F,b),d&&(F.g=d),L&&$n(F,L),g&&(F.l=g),b=F}return g=u.D,d=u.ya,g&&d&&Ce(b,g,d),Ce(b,"VER",u.la),Kn(u,b),b}function Va(u,d,g){if(d&&!u.J)throw Error("Can't create secondary domain capable XhrIo object.");return d=u.Ca&&!u.pa?new ze(new Oe({eb:g})):new ze(u.pa),d.Ha(u.J),d}r.isActive=function(){return!!this.l&&this.l.isActive(this)};function Hi(){}r=Hi.prototype,r.ua=function(){},r.ta=function(){},r.sa=function(){},r.ra=function(){},r.isActive=function(){return!0},r.Na=function(){};function wr(){}wr.prototype.g=function(u,d){return new Ct(u,d)};function Ct(u,d){nt.call(this),this.g=new Na(d),this.l=u,this.h=d&&d.messageUrlParams||null,u=d&&d.messageHeaders||null,d&&d.clientProtocolHeaderRequired&&(u?u["X-Client-Protocol"]="webchannel":u={"X-Client-Protocol":"webchannel"}),this.g.o=u,u=d&&d.initMessageHeaders||null,d&&d.messageContentType&&(u?u["X-WebChannel-Content-Type"]=d.messageContentType:u={"X-WebChannel-Content-Type":d.messageContentType}),d&&d.va&&(u?u["X-WebChannel-Client-Profile"]=d.va:u={"X-WebChannel-Client-Profile":d.va}),this.g.S=u,(u=d&&d.Sb)&&!ee(u)&&(this.g.m=u),this.v=d&&d.supportsCrossDomainXhr||!1,this.u=d&&d.sendRawJson||!1,(d=d&&d.httpSessionIdParam)&&!ee(d)&&(this.g.D=d,u=this.h,u!==null&&d in u&&(u=this.h,d in u&&delete u[d])),this.j=new Mr(this)}B(Ct,nt),Ct.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},Ct.prototype.close=function(){Ks(this.g)},Ct.prototype.o=function(u){var d=this.g;if(typeof u=="string"){var g={};g.__data__=u,u=g}else this.u&&(g={},g.__data__=ya(u),u=g);d.i.push(new Rf(d.Ya++,u)),d.G==3&&Ws(d)},Ct.prototype.N=function(){this.g.l=null,delete this.j,Ks(this.g),delete this.g,Ct.aa.N.call(this)};function La(u){wa.call(this),u.__headers__&&(this.headers=u.__headers__,this.statusCode=u.__status__,delete u.__headers__,delete u.__status__);var d=u.__sm__;if(d){e:{for(let g in d){u=g;break e}u=void 0}(this.i=u)&&(u=this.i,d=d!==null&&u in d?d[u]:void 0),this.data=d}else this.data=u}B(La,wa);function Ma(){ba.call(this),this.status=1}B(Ma,ba);function Mr(u){this.g=u}B(Mr,Hi),Mr.prototype.ua=function(){ut(this.g,"a")},Mr.prototype.ta=function(u){ut(this.g,new La(u))},Mr.prototype.sa=function(u){ut(this.g,new Ma)},Mr.prototype.ra=function(){ut(this.g,"b")},wr.prototype.createWebChannel=wr.prototype.g,Ct.prototype.send=Ct.prototype.o,Ct.prototype.open=Ct.prototype.m,Ct.prototype.close=Ct.prototype.close,fp=Rn.createWebChannelTransport=function(){return new wr},hp=Rn.getStatEventTarget=function(){return Ms()},lp=Rn.Event=kr,Jl=Rn.Stat={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},Vi.NO_ERROR=0,Vi.TIMEOUT=8,Vi.HTTP_ERROR=6,cu=Rn.ErrorCode=Vi,mc.COMPLETE="complete",cp=Rn.EventType=mc,lc.EventType=Oi,Oi.OPEN="a",Oi.CLOSE="b",Oi.ERROR="c",Oi.MESSAGE="d",nt.prototype.listen=nt.prototype.K,So=Rn.WebChannel=lc,C2=Rn.FetchXmlHttpFactory=Oe,ze.prototype.listenOnce=ze.prototype.L,ze.prototype.getLastError=ze.prototype.Ka,ze.prototype.getLastErrorCode=ze.prototype.Ba,ze.prototype.getStatus=ze.prototype.Z,ze.prototype.getResponseJson=ze.prototype.Oa,ze.prototype.getResponseText=ze.prototype.oa,ze.prototype.send=ze.prototype.ea,ze.prototype.setWithCredentials=ze.prototype.Ha,up=Rn.XhrIo=ze}).apply(typeof Ql!="undefined"?Ql:typeof self!="undefined"?self:typeof window!="undefined"?window:{});var W0="@firebase/firestore",H0="4.7.8";var _t=class{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.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");var Yo="11.3.1";var cs=new Ao("@firebase/firestore");function Ro(){return cs.logLevel}function X(r,...e){if(cs.logLevel<=Se.DEBUG){let t=e.map(Xm);cs.debug(`Firestore (${Yo}): ${r}`,...t)}}function Pn(r,...e){if(cs.logLevel<=Se.ERROR){let t=e.map(Xm);cs.error(`Firestore (${Yo}): ${r}`,...t)}}function Vo(r,...e){if(cs.logLevel<=Se.WARN){let t=e.map(Xm);cs.warn(`Firestore (${Yo}): ${r}`,...t)}}function Xm(r){if(typeof r=="string")return r;try{return function(t){return JSON.stringify(t)}(r)}catch{return r}}function ue(r="Unexpected state"){let e=`FIRESTORE (${Yo}) INTERNAL ASSERTION FAILED: `+r;throw Pn(e),new Error(e)}function Le(r,e){r||ue()}function fe(r,e){return r}var H={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"},ne=class extends En{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}};var Gr=class{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}};var nh=class{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}},_p=class{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(_t.UNAUTHENTICATED))}shutdown(){}},yp=class{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable(()=>t(this.token.user))}shutdown(){this.changeListener=null}},vp=class{constructor(e){this.t=e,this.currentUser=_t.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){Le(this.o===void 0);let n=this.i,s=f=>this.i!==n?(n=this.i,t(f)):Promise.resolve(),a=new Gr;this.o=()=>{this.i++,this.currentUser=this.u(),a.resolve(),a=new Gr,e.enqueueRetryable(()=>s(this.currentUser))};let c=()=>{let f=a;e.enqueueRetryable(async()=>{await f.promise,await s(this.currentUser)})},h=f=>{X("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=f,this.o&&(this.auth.addAuthTokenListener(this.o),c())};this.t.onInit(f=>h(f)),setTimeout(()=>{if(!this.auth){let f=this.t.getImmediate({optional:!0});f?h(f):(X("FirebaseAuthCredentialsProvider","Auth not yet detected"),a.resolve(),a=new Gr)}},0),c()}getToken(){let e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(n=>this.i!==e?(X("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):n?(Le(typeof n.accessToken=="string"),new nh(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(){let e=this.auth&&this.auth.getUid();return Le(e===null||typeof e=="string"),new _t(e)}},wp=class{constructor(e,t,n){this.l=e,this.h=t,this.P=n,this.type="FirstParty",this.user=_t.FIRST_PARTY,this.T=new Map}I(){return this.P?this.P():null}get headers(){this.T.set("X-Goog-AuthUser",this.l);let e=this.I();return e&&this.T.set("Authorization",e),this.h&&this.T.set("X-Goog-Iam-Authorization-Token",this.h),this.T}},bp=class{constructor(e,t,n){this.l=e,this.h=t,this.P=n}getToken(){return Promise.resolve(new wp(this.l,this.h,this.P))}start(e,t){e.enqueueRetryable(()=>t(_t.FIRST_PARTY))}shutdown(){}invalidateToken(){}},ih=class{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}},Tp=class{constructor(e,t){this.A=t,this.forceRefresh=!1,this.appCheck=null,this.R=null,this.V=null,B0(e)&&e.settings.appCheckToken&&(this.V=e.settings.appCheckToken)}start(e,t){Le(this.o===void 0);let n=a=>{a.error!=null&&X("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${a.error.message}`);let c=a.token!==this.R;return this.R=a.token,X("FirebaseAppCheckTokenProvider",`Received ${c?"new":"existing"} token.`),c?t(a.token):Promise.resolve()};this.o=a=>{e.enqueueRetryable(()=>n(a))};let s=a=>{X("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=a,this.o&&this.appCheck.addTokenListener(this.o)};this.A.onInit(a=>s(a)),setTimeout(()=>{if(!this.appCheck){let a=this.A.getImmediate({optional:!0});a?s(a):X("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.V)return Promise.resolve(new ih(this.V));let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(t=>t?(Le(typeof t.token=="string"),this.R=t.token,new ih(t.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}};function D2(r){let e=typeof self!="undefined"&&(self.crypto||self.msCrypto),t=new Uint8Array(r);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let n=0;n<r;n++)t[n]=Math.floor(256*Math.random());return t}var sh=class{static newId(){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=62*Math.floor(4.129032258064516),n="";for(;n.length<20;){let s=D2(40);for(let a=0;a<s.length;++a)n.length<20&&s[a]<t&&(n+=e.charAt(s[a]%62))}return n}};function Re(r,e){return r<e?-1:r>e?1:0}function Lo(r,e,t){return r.length===e.length&&r.every((n,s)=>t(n,e[s]))}var Q0=-62135596800,J0=1e6,wt=class r{static now(){return r.fromMillis(Date.now())}static fromDate(e){return r.fromMillis(e.getTime())}static fromMillis(e){let t=Math.floor(e/1e3),n=Math.floor((e-1e3*t)*J0);return new r(t,n)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new ne(H.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new ne(H.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<Q0)throw new ne(H.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new ne(H.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/J0}_compareTo(e){return this.seconds===e.seconds?Re(this.nanoseconds,e.nanoseconds):Re(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){let e=this.seconds-Q0;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}};var me=class r{static fromTimestamp(e){return new r(e)}static min(){return new r(new wt(0,0))}static max(){return new r(new wt(253402300799,999999999))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}};var Y0="__name__",oh=class r{constructor(e,t,n){t===void 0?t=0:t>e.length&&ue(),n===void 0?n=e.length-t:n>e.length-t&&ue(),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(e){return r.comparator(this,e)===0}child(e){let t=this.segments.slice(this.offset,this.limit());return e instanceof r?e.forEach(n=>{t.push(n)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}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(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,n=this.limit();t<n;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){let n=Math.min(e.length,t.length);for(let s=0;s<n;s++){let a=r.compareSegments(e.get(s),t.get(s));if(a!==0)return a}return Math.sign(e.length-t.length)}static compareSegments(e,t){let n=r.isNumericId(e),s=r.isNumericId(t);return n&&!s?-1:!n&&s?1:n&&s?r.extractNumericId(e).compare(r.extractNumericId(t)):e<t?-1:e>t?1:0}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return Sn.fromString(e.substring(4,e.length-2))}},ot=class r extends oh{construct(e,t,n){return new r(e,t,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){let t=[];for(let n of e){if(n.indexOf("//")>=0)throw new ne(H.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);t.push(...n.split("/").filter(s=>s.length>0))}return new r(t)}static emptyPath(){return new r([])}},O2=/^[_a-zA-Z][_a-zA-Z0-9]*$/,tr=class r extends oh{construct(e,t,n){return new r(e,t,n)}static isValidIdentifier(e){return O2.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),r.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===Y0}static keyField(){return new r([Y0])}static fromServerFormat(e){let t=[],n="",s=0,a=()=>{if(n.length===0)throw new ne(H.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(n),n=""},c=!1;for(;s<e.length;){let h=e[s];if(h==="\\"){if(s+1===e.length)throw new ne(H.INVALID_ARGUMENT,"Path has trailing escape character: "+e);let f=e[s+1];if(f!=="\\"&&f!=="."&&f!=="`")throw new ne(H.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);n+=f,s+=2}else h==="`"?(c=!c,s++):h!=="."||c?(n+=h,s++):(a(),s++)}if(a(),c)throw new ne(H.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new r(t)}static emptyPath(){return new r([])}};var ce=class r{constructor(e){this.path=e}static fromPath(e){return new r(ot.fromString(e))}static fromName(e){return new r(ot.fromString(e).popFirst(5))}static empty(){return new r(ot.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&ot.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return ot.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new r(new ot(e.slice()))}};var mu=-1,Ep=class{constructor(e,t,n,s){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=s}};Ep.UNKNOWN_ID=-1;function k2(r,e){let t=r.toTimestamp().seconds,n=r.toTimestamp().nanoseconds+1,s=me.fromTimestamp(n===1e9?new wt(t+1,0):new wt(t,n));return new ls(s,ce.empty(),e)}function N2(r){return new ls(r.readTime,r.key,mu)}var ls=class r{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new r(me.min(),ce.empty(),mu)}static max(){return new r(me.max(),ce.empty(),mu)}};function V2(r,e){let t=r.readTime.compareTo(e.readTime);return t!==0?t:(t=ce.comparator(r.documentKey,e.documentKey),t!==0?t:Re(r.largestBatchId,e.largestBatchId))}var L2="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",Ip=class{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}};async function Xo(r){if(r.code!==H.FAILED_PRECONDITION||r.message!==L2)throw r;X("LocalStore","Unexpectedly lost primary lease")}var W=class r{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)},t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&ue(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new r((n,s)=>{this.nextCallback=a=>{this.wrapSuccess(e,a).next(n,s)},this.catchCallback=a=>{this.wrapFailure(t,a).next(n,s)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{let t=e();return t instanceof r?t:r.resolve(t)}catch(t){return r.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):r.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):r.reject(t)}static resolve(e){return new r((t,n)=>{t(e)})}static reject(e){return new r((t,n)=>{n(e)})}static waitFor(e){return new r((t,n)=>{let s=0,a=0,c=!1;e.forEach(h=>{++s,h.next(()=>{++a,c&&a===s&&t()},f=>n(f))}),c=!0,a===s&&t()})}static or(e){let t=r.resolve(!1);for(let n of e)t=t.next(s=>s?r.resolve(s):n());return t}static forEach(e,t){let n=[];return e.forEach((s,a)=>{n.push(t.call(this,s,a))}),this.waitFor(n)}static mapArray(e,t){return new r((n,s)=>{let a=e.length,c=new Array(a),h=0;for(let f=0;f<a;f++){let m=f;t(e[m]).next(_=>{c[m]=_,++h,h===a&&n(c)},_=>s(_))}})}static doWhile(e,t){return new r((n,s)=>{let a=()=>{e()===!0?t().next(()=>{a()},s):n()};a()})}};function M2(r){let e=r.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function Zo(r){return r.name==="IndexedDbTransactionError"}var Mo=class{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=n=>this.oe(n),this._e=n=>t.writeSequenceNumber(n))}oe(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){let e=++this.previousValue;return this._e&&this._e(e),e}};Mo.ae=-1;var Zm=-1;function jh(r){return r==null}function gu(r){return r===0&&1/r==-1/0}function F2(r){return typeof r=="number"&&Number.isInteger(r)&&!gu(r)&&r<=Number.MAX_SAFE_INTEGER&&r>=Number.MIN_SAFE_INTEGER}var Nb="";function U2(r){let e="";for(let t=0;t<r.length;t++)e.length>0&&(e=X0(e)),e=B2(r.get(t),e);return X0(e)}function B2(r,e){let t=e,n=r.length;for(let s=0;s<n;s++){let a=r.charAt(s);switch(a){case"\0":t+="";break;case Nb:t+="";break;default:t+=a}}return t}function X0(r){return r+Nb+""}var j2="remoteDocuments",Vb="owner";var Lb="mutationQueues";var Mb="mutations";var Fb="documentMutations",$2="remoteDocumentsV14";var Ub="remoteDocumentGlobal";var Bb="targets";var jb="targetDocuments";var $b="targetGlobal",qb="collectionParents";var zb="clientMetadata";var Gb="bundles";var Kb="namedQueries";var q2="indexConfiguration";var z2="indexState";var G2="indexEntries";var Wb="documentOverlays";var K2="globals";var W2=[Lb,Mb,Fb,j2,Bb,Vb,$b,jb,zb,Ub,qb,Gb,Kb],gK=[...W2,Wb],H2=[Lb,Mb,Fb,$2,Bb,Vb,$b,jb,zb,Ub,qb,Gb,Kb,Wb],Q2=H2,J2=[...Q2,q2,z2,G2];var _K=[...J2,K2];function Z0(r){let e=0;for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&e++;return e}function Ti(r,e){for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&e(t,r[t])}function Hb(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(r,e))return!1;return!0}var Ye=class r{constructor(e,t){this.comparator=e,this.root=t||Kr.EMPTY}insert(e,t){return new r(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,Kr.BLACK,null,null))}remove(e){return new r(this.comparator,this.root.remove(e,this.comparator).copy(null,null,Kr.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){let n=this.comparator(e,t.key);if(n===0)return t.value;n<0?t=t.left:n>0&&(t=t.right)}return null}indexOf(e){let t=0,n=this.root;for(;!n.isEmpty();){let s=this.comparator(e,n.key);if(s===0)return t+n.left.size;s<0?n=n.left:(t+=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(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,n)=>(e(t,n),!1))}toString(){let e=[];return this.inorderTraversal((t,n)=>(e.push(`${t}:${n}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Oo(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Oo(this.root,e,this.comparator,!1)}getReverseIterator(){return new Oo(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Oo(this.root,e,this.comparator,!0)}},Oo=class{constructor(e,t,n,s){this.isReverse=s,this.nodeStack=[];let a=1;for(;!e.isEmpty();)if(a=t?n(e.key,t):1,t&&s&&(a*=-1),a<0)e=this.isReverse?e.left:e.right;else{if(a===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop(),t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;let e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}},Kr=class r{constructor(e,t,n,s,a){this.key=e,this.value=t,this.color=n!=null?n:r.RED,this.left=s!=null?s:r.EMPTY,this.right=a!=null?a:r.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,n,s,a){return new r(e!=null?e:this.key,t!=null?t:this.value,n!=null?n:this.color,s!=null?s:this.left,a!=null?a:this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,n){let s=this,a=n(e,s.key);return s=a<0?s.copy(null,null,null,s.left.insert(e,t,n),null):a===0?s.copy(null,t,null,null,null):s.copy(null,null,null,null,s.right.insert(e,t,n)),s.fixUp()}removeMin(){if(this.left.isEmpty())return r.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let n,s=this;if(t(e,s.key)<0)s.left.isEmpty()||s.left.isRed()||s.left.left.isRed()||(s=s.moveRedLeft()),s=s.copy(null,null,null,s.left.remove(e,t),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),t(e,s.key)===0){if(s.right.isEmpty())return r.EMPTY;n=s.right.min(),s=s.copy(n.key,n.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(e,t))}return s.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){let e=this.copy(null,null,r.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){let e=this.copy(null,null,r.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){let e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){let e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw ue();let e=this.left.check();if(e!==this.right.check())throw ue();return e+(this.isRed()?0:1)}};Kr.EMPTY=null,Kr.RED=!0,Kr.BLACK=!1;Kr.EMPTY=new class{constructor(){this.size=0}get key(){throw ue()}get value(){throw ue()}get color(){throw ue()}get left(){throw ue()}get right(){throw ue()}copy(e,t,n,s,a){return this}insert(e,t,n){return new Kr(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};var yt=class r{constructor(e){this.comparator=e,this.data=new Ye(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,n)=>(e(t),!1))}forEachInRange(e,t){let n=this.data.getIteratorFrom(e[0]);for(;n.hasNext();){let s=n.getNext();if(this.comparator(s.key,e[1])>=0)return;t(s.key)}}forEachWhile(e,t){let n;for(n=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();n.hasNext();)if(!e(n.getNext().key))return}firstAfterOrEqual(e){let t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new ah(this.data.getIterator())}getIteratorFrom(e){return new ah(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach(n=>{t=t.add(n)}),t}isEqual(e){if(!(e instanceof r)||this.size!==e.size)return!1;let t=this.data.getIterator(),n=e.data.getIterator();for(;t.hasNext();){let s=t.getNext().key,a=n.getNext().key;if(this.comparator(s,a)!==0)return!1}return!0}toArray(){let e=[];return this.forEach(t=>{e.push(t)}),e}toString(){let e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){let t=new r(this.comparator);return t.data=e,t}},ah=class{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}};var hr=class r{constructor(e){this.fields=e,e.sort(tr.comparator)}static empty(){return new r([])}unionWith(e){let t=new yt(tr.comparator);for(let n of this.fields)t=t.add(n);for(let n of e)t=t.add(n);return new r(t.toArray())}covers(e){for(let t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return Lo(this.fields,e.fields,(t,n)=>t.isEqual(n))}};var uh=class extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}};var Rt=class r{constructor(e){this.binaryString=e}static fromBase64String(e){let t=function(s){try{return atob(s)}catch(a){throw typeof DOMException!="undefined"&&a instanceof DOMException?new uh("Invalid base64 string: "+a):a}}(e);return new r(t)}static fromUint8Array(e){let t=function(s){let a="";for(let c=0;c<s.length;++c)a+=String.fromCharCode(s[c]);return a}(e);return new r(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function(t){return btoa(t)}(this.binaryString)}toUint8Array(){return function(t){let n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return Re(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}};Rt.EMPTY_BYTE_STRING=new Rt("");var Y2=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Cn(r){if(Le(!!r),typeof r=="string"){let e=0,t=Y2.exec(r);if(Le(!!t),t[1]){let s=t[1];s=(s+"000000000").substr(0,9),e=Number(s)}let n=new Date(r);return{seconds:Math.floor(n.getTime()/1e3),nanos:e}}return{seconds:Ge(r.seconds),nanos:Ge(r.nanos)}}function Ge(r){return typeof r=="number"?r:typeof r=="string"?Number(r):0}function Dn(r){return typeof r=="string"?Rt.fromBase64String(r):Rt.fromUint8Array(r)}var Qb="server_timestamp",Jb="__type__",Yb="__previous_value__",Xb="__local_write_time__";function eg(r){var e,t;return((t=(((e=r==null?void 0:r.mapValue)===null||e===void 0?void 0:e.fields)||{})[Jb])===null||t===void 0?void 0:t.stringValue)===Qb}function $h(r){let e=r.mapValue.fields[Yb];return eg(e)?$h(e):e}function _u(r){let e=Cn(r.mapValue.fields[Xb].timestampValue);return new wt(e.seconds,e.nanos)}var xp=class{constructor(e,t,n,s,a,c,h,f,m){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=s,this.ssl=a,this.forceLongPolling=c,this.autoDetectLongPolling=h,this.longPollingOptions=f,this.useFetchStreams=m}},ch="(default)",lh=class r{constructor(e,t){this.projectId=e,this.database=t||ch}static empty(){return new r("","")}get isDefaultDatabase(){return this.database===ch}isEqual(e){return e instanceof r&&e.projectId===this.projectId&&e.database===this.database}};var tg="__type__",Zb="__max__",Yl={mapValue:{fields:{__type__:{stringValue:Zb}}}},rg="__vector__",Fo="value";function yi(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?eg(r)?4:tT(r)?9007199254740991:eT(r)?10:11:ue()}function Jr(r,e){if(r===e)return!0;let t=yi(r);if(t!==yi(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return r.booleanValue===e.booleanValue;case 4:return _u(r).isEqual(_u(e));case 3:return function(s,a){if(typeof s.timestampValue=="string"&&typeof a.timestampValue=="string"&&s.timestampValue.length===a.timestampValue.length)return s.timestampValue===a.timestampValue;let c=Cn(s.timestampValue),h=Cn(a.timestampValue);return c.seconds===h.seconds&&c.nanos===h.nanos}(r,e);case 5:return r.stringValue===e.stringValue;case 6:return function(s,a){return Dn(s.bytesValue).isEqual(Dn(a.bytesValue))}(r,e);case 7:return r.referenceValue===e.referenceValue;case 8:return function(s,a){return Ge(s.geoPointValue.latitude)===Ge(a.geoPointValue.latitude)&&Ge(s.geoPointValue.longitude)===Ge(a.geoPointValue.longitude)}(r,e);case 2:return function(s,a){if("integerValue"in s&&"integerValue"in a)return Ge(s.integerValue)===Ge(a.integerValue);if("doubleValue"in s&&"doubleValue"in a){let c=Ge(s.doubleValue),h=Ge(a.doubleValue);return c===h?gu(c)===gu(h):isNaN(c)&&isNaN(h)}return!1}(r,e);case 9:return Lo(r.arrayValue.values||[],e.arrayValue.values||[],Jr);case 10:case 11:return function(s,a){let c=s.mapValue.fields||{},h=a.mapValue.fields||{};if(Z0(c)!==Z0(h))return!1;for(let f in c)if(c.hasOwnProperty(f)&&(h[f]===void 0||!Jr(c[f],h[f])))return!1;return!0}(r,e);default:return ue()}}function yu(r,e){return(r.values||[]).find(t=>Jr(t,e))!==void 0}function Uo(r,e){if(r===e)return 0;let t=yi(r),n=yi(e);if(t!==n)return Re(t,n);switch(t){case 0:case 9007199254740991:return 0;case 1:return Re(r.booleanValue,e.booleanValue);case 2:return function(a,c){let h=Ge(a.integerValue||a.doubleValue),f=Ge(c.integerValue||c.doubleValue);return h<f?-1:h>f?1:h===f?0:isNaN(h)?isNaN(f)?0:-1:1}(r,e);case 3:return eb(r.timestampValue,e.timestampValue);case 4:return eb(_u(r),_u(e));case 5:return Re(r.stringValue,e.stringValue);case 6:return function(a,c){let h=Dn(a),f=Dn(c);return h.compareTo(f)}(r.bytesValue,e.bytesValue);case 7:return function(a,c){let h=a.split("/"),f=c.split("/");for(let m=0;m<h.length&&m<f.length;m++){let _=Re(h[m],f[m]);if(_!==0)return _}return Re(h.length,f.length)}(r.referenceValue,e.referenceValue);case 8:return function(a,c){let h=Re(Ge(a.latitude),Ge(c.latitude));return h!==0?h:Re(Ge(a.longitude),Ge(c.longitude))}(r.geoPointValue,e.geoPointValue);case 9:return tb(r.arrayValue,e.arrayValue);case 10:return function(a,c){var h,f,m,_;let E=a.fields||{},I=c.fields||{},k=(h=E[Fo])===null||h===void 0?void 0:h.arrayValue,B=(f=I[Fo])===null||f===void 0?void 0:f.arrayValue,G=Re(((m=k==null?void 0:k.values)===null||m===void 0?void 0:m.length)||0,((_=B==null?void 0:B.values)===null||_===void 0?void 0:_.length)||0);return G!==0?G:tb(k,B)}(r.mapValue,e.mapValue);case 11:return function(a,c){if(a===Yl.mapValue&&c===Yl.mapValue)return 0;if(a===Yl.mapValue)return 1;if(c===Yl.mapValue)return-1;let h=a.fields||{},f=Object.keys(h),m=c.fields||{},_=Object.keys(m);f.sort(),_.sort();for(let E=0;E<f.length&&E<_.length;++E){let I=Re(f[E],_[E]);if(I!==0)return I;let k=Uo(h[f[E]],m[_[E]]);if(k!==0)return k}return Re(f.length,_.length)}(r.mapValue,e.mapValue);default:throw ue()}}function eb(r,e){if(typeof r=="string"&&typeof e=="string"&&r.length===e.length)return Re(r,e);let t=Cn(r),n=Cn(e),s=Re(t.seconds,n.seconds);return s!==0?s:Re(t.nanos,n.nanos)}function tb(r,e){let t=r.values||[],n=e.values||[];for(let s=0;s<t.length&&s<n.length;++s){let a=Uo(t[s],n[s]);if(a)return a}return Re(t.length,n.length)}function Bo(r){return Ap(r)}function Ap(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(t){let n=Cn(t);return`time(${n.seconds},${n.nanos})`}(r.timestampValue):"stringValue"in r?r.stringValue:"bytesValue"in r?function(t){return Dn(t).toBase64()}(r.bytesValue):"referenceValue"in r?function(t){return ce.fromName(t).toString()}(r.referenceValue):"geoPointValue"in r?function(t){return`geo(${t.latitude},${t.longitude})`}(r.geoPointValue):"arrayValue"in r?function(t){let n="[",s=!0;for(let a of t.values||[])s?s=!1:n+=",",n+=Ap(a);return n+"]"}(r.arrayValue):"mapValue"in r?function(t){let n=Object.keys(t.fields||{}).sort(),s="{",a=!0;for(let c of n)a?a=!1:s+=",",s+=`${c}:${Ap(t.fields[c])}`;return s+"}"}(r.mapValue):ue()}function eh(r){switch(yi(r)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let e=$h(r);return e?16+eh(e):16;case 5:return 2*r.stringValue.length;case 6:return Dn(r.bytesValue).approximateByteSize();case 7:return r.referenceValue.length;case 9:return function(n){return(n.values||[]).reduce((s,a)=>s+eh(a),0)}(r.arrayValue);case 10:case 11:return function(n){let s=0;return Ti(n.fields,(a,c)=>{s+=a.length+eh(c)}),s}(r.mapValue);default:throw ue()}}function Sp(r){return!!r&&"integerValue"in r}function ng(r){return!!r&&"arrayValue"in r}function rb(r){return!!r&&"nullValue"in r}function nb(r){return!!r&&"doubleValue"in r&&isNaN(Number(r.doubleValue))}function th(r){return!!r&&"mapValue"in r}function eT(r){var e,t;return((t=(((e=r==null?void 0:r.mapValue)===null||e===void 0?void 0:e.fields)||{})[tg])===null||t===void 0?void 0:t.stringValue)===rg}function hu(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){let e={mapValue:{fields:{}}};return Ti(r.mapValue.fields,(t,n)=>e.mapValue.fields[t]=hu(n)),e}if(r.arrayValue){let e={arrayValue:{values:[]}};for(let t=0;t<(r.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=hu(r.arrayValue.values[t]);return e}return Object.assign({},r)}function tT(r){return(((r.mapValue||{}).fields||{}).__type__||{}).stringValue===Zb}var vK={mapValue:{fields:{[tg]:{stringValue:rg},[Fo]:{arrayValue:{}}}}};var er=class r{constructor(e){this.value=e}static empty(){return new r({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let n=0;n<e.length-1;++n)if(t=(t.mapValue.fields||{})[e.get(n)],!th(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=hu(t)}setAll(e){let t=tr.emptyPath(),n={},s=[];e.forEach((c,h)=>{if(!t.isImmediateParentOf(h)){let f=this.getFieldsMap(t);this.applyChanges(f,n,s),n={},s=[],t=h.popLast()}c?n[h.lastSegment()]=hu(c):s.push(h.lastSegment())});let a=this.getFieldsMap(t);this.applyChanges(a,n,s)}delete(e){let t=this.field(e.popLast());th(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Jr(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let n=0;n<e.length;++n){let s=t.mapValue.fields[e.get(n)];th(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=s),t=s}return t.mapValue.fields}applyChanges(e,t,n){Ti(t,(s,a)=>e[s]=a);for(let s of n)delete e[s]}clone(){return new r(hu(this.value))}};function rT(r){let e=[];return Ti(r.fields,(t,n)=>{let s=new tr([t]);if(th(n)){let a=rT(n.mapValue).fields;if(a.length===0)e.push(s);else for(let c of a)e.push(s.child(c))}else e.push(s)}),new hr(e)}var Sr=class r{constructor(e,t,n,s,a,c,h){this.key=e,this.documentType=t,this.version=n,this.readTime=s,this.createTime=a,this.data=c,this.documentState=h}static newInvalidDocument(e){return new r(e,0,me.min(),me.min(),me.min(),er.empty(),0)}static newFoundDocument(e,t,n,s){return new r(e,1,t,me.min(),n,s,0)}static newNoDocument(e,t){return new r(e,2,t,me.min(),me.min(),er.empty(),0)}static newUnknownDocument(e,t){return new r(e,3,t,me.min(),me.min(),er.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(me.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=er.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=er.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=me.min(),this}setReadTime(e){return this.readTime=e,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(e){return e instanceof r&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new r(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}})`}};var jo=class{constructor(e,t){this.position=e,this.inclusive=t}};function ib(r,e,t){let n=0;for(let s=0;s<r.position.length;s++){let a=e[s],c=r.position[s];if(a.field.isKeyField()?n=ce.comparator(ce.fromName(c.referenceValue),t.key):n=Uo(c,t.data.field(a.field)),a.dir==="desc"&&(n*=-1),n!==0)break}return n}function sb(r,e){if(r===null)return e===null;if(e===null||r.inclusive!==e.inclusive||r.position.length!==e.position.length)return!1;for(let t=0;t<r.position.length;t++)if(!Jr(r.position[t],e.position[t]))return!1;return!0}var $o=class{constructor(e,t="asc"){this.field=e,this.dir=t}};function X2(r,e){return r.dir===e.dir&&r.field.isEqual(e.field)}var hh=class{},pt=class r extends hh{constructor(e,t,n){super(),this.field=e,this.op=t,this.value=n}static create(e,t,n){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,n):new Pp(e,t,n):t==="array-contains"?new Op(e,n):t==="in"?new kp(e,n):t==="not-in"?new Np(e,n):t==="array-contains-any"?new Vp(e,n):new r(e,t,n)}static createKeyFieldInFilter(e,t,n){return t==="in"?new Cp(e,n):new Dp(e,n)}matches(e){let t=e.data.field(this.field);return this.op==="!="?t!==null&&this.matchesComparison(Uo(t,this.value)):t!==null&&yi(this.value)===yi(t)&&this.matchesComparison(Uo(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return ue()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}},Yr=class r extends hh{constructor(e,t){super(),this.filters=e,this.op=t,this.ce=null}static create(e,t){return new r(e,t)}matches(e){return nT(this)?this.filters.find(t=>!t.matches(e))===void 0:this.filters.find(t=>t.matches(e))!==void 0}getFlattenedFilters(){return this.ce!==null||(this.ce=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.ce}getFilters(){return Object.assign([],this.filters)}};function nT(r){return r.op==="and"}function iT(r){return Z2(r)&&nT(r)}function Z2(r){for(let e of r.filters)if(e instanceof Yr)return!1;return!0}function Rp(r){if(r instanceof pt)return r.field.canonicalString()+r.op.toString()+Bo(r.value);if(iT(r))return r.filters.map(e=>Rp(e)).join(",");{let e=r.filters.map(t=>Rp(t)).join(",");return`${r.op}(${e})`}}function sT(r,e){return r instanceof pt?function(n,s){return s instanceof pt&&n.op===s.op&&n.field.isEqual(s.field)&&Jr(n.value,s.value)}(r,e):r instanceof Yr?function(n,s){return s instanceof Yr&&n.op===s.op&&n.filters.length===s.filters.length?n.filters.reduce((a,c,h)=>a&&sT(c,s.filters[h]),!0):!1}(r,e):void ue()}function oT(r){return r instanceof pt?function(t){return`${t.field.canonicalString()} ${t.op} ${Bo(t.value)}`}(r):r instanceof Yr?function(t){return t.op.toString()+" {"+t.getFilters().map(oT).join(" ,")+"}"}(r):"Filter"}var Pp=class extends pt{constructor(e,t,n){super(e,t,n),this.key=ce.fromName(n.referenceValue)}matches(e){let t=ce.comparator(e.key,this.key);return this.matchesComparison(t)}},Cp=class extends pt{constructor(e,t){super(e,"in",t),this.keys=aT("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}},Dp=class extends pt{constructor(e,t){super(e,"not-in",t),this.keys=aT("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}};function aT(r,e){var t;return(((t=e.arrayValue)===null||t===void 0?void 0:t.values)||[]).map(n=>ce.fromName(n.referenceValue))}var Op=class extends pt{constructor(e,t){super(e,"array-contains",t)}matches(e){let t=e.data.field(this.field);return ng(t)&&yu(t.arrayValue,this.value)}},kp=class extends pt{constructor(e,t){super(e,"in",t)}matches(e){let t=e.data.field(this.field);return t!==null&&yu(this.value.arrayValue,t)}},Np=class extends pt{constructor(e,t){super(e,"not-in",t)}matches(e){if(yu(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;let t=e.data.field(this.field);return t!==null&&!yu(this.value.arrayValue,t)}},Vp=class extends pt{constructor(e,t){super(e,"array-contains-any",t)}matches(e){let t=e.data.field(this.field);return!(!ng(t)||!t.arrayValue.values)&&t.arrayValue.values.some(n=>yu(this.value.arrayValue,n))}};var Lp=class{constructor(e,t=null,n=[],s=[],a=null,c=null,h=null){this.path=e,this.collectionGroup=t,this.orderBy=n,this.filters=s,this.limit=a,this.startAt=c,this.endAt=h,this.le=null}};function ob(r,e=null,t=[],n=[],s=null,a=null,c=null){return new Lp(r,e,t,n,s,a,c)}function ig(r){let e=fe(r);if(e.le===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(n=>Rp(n)).join(","),t+="|ob:",t+=e.orderBy.map(n=>function(a){return a.field.canonicalString()+a.dir}(n)).join(","),jh(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(n=>Bo(n)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(n=>Bo(n)).join(",")),e.le=t}return e.le}function sg(r,e){if(r.limit!==e.limit||r.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<r.orderBy.length;t++)if(!X2(r.orderBy[t],e.orderBy[t]))return!1;if(r.filters.length!==e.filters.length)return!1;for(let t=0;t<r.filters.length;t++)if(!sT(r.filters[t],e.filters[t]))return!1;return r.collectionGroup===e.collectionGroup&&!!r.path.isEqual(e.path)&&!!sb(r.startAt,e.startAt)&&sb(r.endAt,e.endAt)}function Mp(r){return ce.isDocumentKey(r.path)&&r.collectionGroup===null&&r.filters.length===0}var qo=class{constructor(e,t=null,n=[],s=[],a=null,c="F",h=null,f=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=s,this.limit=a,this.limitType=c,this.startAt=h,this.endAt=f,this.he=null,this.Pe=null,this.Te=null,this.startAt,this.endAt}};function eM(r,e,t,n,s,a,c,h){return new qo(r,e,t,n,s,a,c,h)}function qh(r){return new qo(r)}function ab(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 tM(r){return r.collectionGroup!==null}function fu(r){let e=fe(r);if(e.he===null){e.he=[];let t=new Set;for(let a of e.explicitOrderBy)e.he.push(a),t.add(a.field.canonicalString());let n=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(c){let h=new yt(tr.comparator);return c.filters.forEach(f=>{f.getFlattenedFilters().forEach(m=>{m.isInequality()&&(h=h.add(m.field))})}),h})(e).forEach(a=>{t.has(a.canonicalString())||a.isKeyField()||e.he.push(new $o(a,n))}),t.has(tr.keyField().canonicalString())||e.he.push(new $o(tr.keyField(),n))}return e.he}function Wr(r){let e=fe(r);return e.Pe||(e.Pe=rM(e,fu(r))),e.Pe}function rM(r,e){if(r.limitType==="F")return ob(r.path,r.collectionGroup,e,r.filters,r.limit,r.startAt,r.endAt);{e=e.map(s=>{let a=s.dir==="desc"?"asc":"desc";return new $o(s.field,a)});let t=r.endAt?new jo(r.endAt.position,r.endAt.inclusive):null,n=r.startAt?new jo(r.startAt.position,r.startAt.inclusive):null;return ob(r.path,r.collectionGroup,e,r.filters,r.limit,t,n)}}function Fp(r,e,t){return new qo(r.path,r.collectionGroup,r.explicitOrderBy.slice(),r.filters.slice(),e,t,r.startAt,r.endAt)}function zh(r,e){return sg(Wr(r),Wr(e))&&r.limitType===e.limitType}function uT(r){return`${ig(Wr(r))}|lt:${r.limitType}`}function Po(r){return`Query(target=${function(t){let n=t.path.canonicalString();return t.collectionGroup!==null&&(n+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(n+=`, filters: [${t.filters.map(s=>oT(s)).join(", ")}]`),jh(t.limit)||(n+=", limit: "+t.limit),t.orderBy.length>0&&(n+=`, orderBy: [${t.orderBy.map(s=>function(c){return`${c.field.canonicalString()} (${c.dir})`}(s)).join(", ")}]`),t.startAt&&(n+=", startAt: ",n+=t.startAt.inclusive?"b:":"a:",n+=t.startAt.position.map(s=>Bo(s)).join(",")),t.endAt&&(n+=", endAt: ",n+=t.endAt.inclusive?"a:":"b:",n+=t.endAt.position.map(s=>Bo(s)).join(",")),`Target(${n})`}(Wr(r))}; limitType=${r.limitType})`}function Gh(r,e){return e.isFoundDocument()&&function(n,s){let a=s.key.path;return n.collectionGroup!==null?s.key.hasCollectionId(n.collectionGroup)&&n.path.isPrefixOf(a):ce.isDocumentKey(n.path)?n.path.isEqual(a):n.path.isImmediateParentOf(a)}(r,e)&&function(n,s){for(let a of fu(n))if(!a.field.isKeyField()&&s.data.field(a.field)===null)return!1;return!0}(r,e)&&function(n,s){for(let a of n.filters)if(!a.matches(s))return!1;return!0}(r,e)&&function(n,s){return!(n.startAt&&!function(c,h,f){let m=ib(c,h,f);return c.inclusive?m<=0:m<0}(n.startAt,fu(n),s)||n.endAt&&!function(c,h,f){let m=ib(c,h,f);return c.inclusive?m>=0:m>0}(n.endAt,fu(n),s))}(r,e)}function nM(r){return r.collectionGroup||(r.path.length%2==1?r.path.lastSegment():r.path.get(r.path.length-2))}function cT(r){return(e,t)=>{let n=!1;for(let s of fu(r)){let a=iM(s,e,t);if(a!==0)return a;n=n||s.field.isKeyField()}return 0}}function iM(r,e,t){let n=r.field.isKeyField()?ce.comparator(e.key,t.key):function(a,c,h){let f=c.data.field(a),m=h.data.field(a);return f!==null&&m!==null?Uo(f,m):ue()}(r.field,e,t);switch(r.dir){case"asc":return n;case"desc":return-1*n;default:return ue()}}var On=class{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){let t=this.mapKeyFn(e),n=this.inner[t];if(n!==void 0){for(let[s,a]of n)if(this.equalsFn(s,e))return a}}has(e){return this.get(e)!==void 0}set(e,t){let n=this.mapKeyFn(e),s=this.inner[n];if(s===void 0)return this.inner[n]=[[e,t]],void this.innerSize++;for(let a=0;a<s.length;a++)if(this.equalsFn(s[a][0],e))return void(s[a]=[e,t]);s.push([e,t]),this.innerSize++}delete(e){let t=this.mapKeyFn(e),n=this.inner[t];if(n===void 0)return!1;for(let s=0;s<n.length;s++)if(this.equalsFn(n[s][0],e))return n.length===1?delete this.inner[t]:n.splice(s,1),this.innerSize--,!0;return!1}forEach(e){Ti(this.inner,(t,n)=>{for(let[s,a]of n)e(s,a)})}isEmpty(){return Hb(this.inner)}size(){return this.innerSize}};var sM=new Ye(ce.comparator);function kn(){return sM}var lT=new Ye(ce.comparator);function lu(...r){let e=lT;for(let t of r)e=e.insert(t.key,t);return e}function hT(r){let e=lT;return r.forEach((t,n)=>e=e.insert(t,n.overlayedDocument)),e}function os(){return du()}function fT(){return du()}function du(){return new On(r=>r.toString(),(r,e)=>r.isEqual(e))}var oM=new Ye(ce.comparator),aM=new yt(ce.comparator);function xe(...r){let e=aM;for(let t of r)e=e.add(t);return e}var uM=new yt(Re);function cM(){return uM}function og(r,e){if(r.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:gu(e)?"-0":e}}function dT(r){return{integerValue:""+r}}function lM(r,e){return F2(e)?dT(e):og(r,e)}var zo=class{constructor(){this._=void 0}};function hM(r,e,t){return r instanceof Go?function(s,a){let c={fields:{[Jb]:{stringValue:Qb},[Xb]:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return a&&eg(a)&&(a=$h(a)),a&&(c.fields[Yb]=a),{mapValue:c}}(t,e):r instanceof hs?mT(r,e):r instanceof fs?gT(r,e):function(s,a){let c=pT(s,a),h=ub(c)+ub(s.Ie);return Sp(c)&&Sp(s.Ie)?dT(h):og(s.serializer,h)}(r,e)}function fM(r,e,t){return r instanceof hs?mT(r,e):r instanceof fs?gT(r,e):t}function pT(r,e){return r instanceof Ko?function(n){return Sp(n)||function(a){return!!a&&"doubleValue"in a}(n)}(e)?e:{integerValue:0}:null}var Go=class extends zo{},hs=class extends zo{constructor(e){super(),this.elements=e}};function mT(r,e){let t=_T(e);for(let n of r.elements)t.some(s=>Jr(s,n))||t.push(n);return{arrayValue:{values:t}}}var fs=class extends zo{constructor(e){super(),this.elements=e}};function gT(r,e){let t=_T(e);for(let n of r.elements)t=t.filter(s=>!Jr(s,n));return{arrayValue:{values:t}}}var Ko=class extends zo{constructor(e,t){super(),this.serializer=e,this.Ie=t}};function ub(r){return Ge(r.integerValue||r.doubleValue)}function _T(r){return ng(r)&&r.arrayValue.values?r.arrayValue.values.slice():[]}function dM(r,e){return r.field.isEqual(e.field)&&function(n,s){return n instanceof hs&&s instanceof hs||n instanceof fs&&s instanceof fs?Lo(n.elements,s.elements,Jr):n instanceof Ko&&s instanceof Ko?Jr(n.Ie,s.Ie):n instanceof Go&&s instanceof Go}(r.transform,e.transform)}var Up=class{constructor(e,t){this.version=e,this.transformResults=t}},_i=class r{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new r}static exists(e){return new r(void 0,e)}static updateTime(e){return new r(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}};function rh(r,e){return r.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(r.updateTime):r.exists===void 0||r.exists===e.isFoundDocument()}var Wo=class{};function yT(r,e){if(!r.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return r.isNoDocument()?new fh(r.key,_i.none()):new ds(r.key,r.data,_i.none());{let t=r.data,n=er.empty(),s=new yt(tr.comparator);for(let a of e.fields)if(!s.has(a)){let c=t.field(a);c===null&&a.length>1&&(a=a.popLast(),c=t.field(a)),c===null?n.delete(a):n.set(a,c),s=s.add(a)}return new Xr(r.key,n,new hr(s.toArray()),_i.none())}}function pM(r,e,t){r instanceof ds?function(s,a,c){let h=s.value.clone(),f=lb(s.fieldTransforms,a,c.transformResults);h.setAll(f),a.convertToFoundDocument(c.version,h).setHasCommittedMutations()}(r,e,t):r instanceof Xr?function(s,a,c){if(!rh(s.precondition,a))return void a.convertToUnknownDocument(c.version);let h=lb(s.fieldTransforms,a,c.transformResults),f=a.data;f.setAll(vT(s)),f.setAll(h),a.convertToFoundDocument(c.version,f).setHasCommittedMutations()}(r,e,t):function(s,a,c){a.convertToNoDocument(c.version).setHasCommittedMutations()}(0,e,t)}function pu(r,e,t,n){return r instanceof ds?function(a,c,h,f){if(!rh(a.precondition,c))return h;let m=a.value.clone(),_=hb(a.fieldTransforms,f,c);return m.setAll(_),c.convertToFoundDocument(c.version,m).setHasLocalMutations(),null}(r,e,t,n):r instanceof Xr?function(a,c,h,f){if(!rh(a.precondition,c))return h;let m=hb(a.fieldTransforms,f,c),_=c.data;return _.setAll(vT(a)),_.setAll(m),c.convertToFoundDocument(c.version,_).setHasLocalMutations(),h===null?null:h.unionWith(a.fieldMask.fields).unionWith(a.fieldTransforms.map(E=>E.field))}(r,e,t,n):function(a,c,h){return rh(a.precondition,c)?(c.convertToNoDocument(c.version).setHasLocalMutations(),null):h}(r,e,t)}function mM(r,e){let t=null;for(let n of r.fieldTransforms){let s=e.data.field(n.field),a=pT(n.transform,s||null);a!=null&&(t===null&&(t=er.empty()),t.set(n.field,a))}return t||null}function cb(r,e){return r.type===e.type&&!!r.key.isEqual(e.key)&&!!r.precondition.isEqual(e.precondition)&&!!function(n,s){return n===void 0&&s===void 0||!(!n||!s)&&Lo(n,s,(a,c)=>dM(a,c))}(r.fieldTransforms,e.fieldTransforms)&&(r.type===0?r.value.isEqual(e.value):r.type!==1||r.data.isEqual(e.data)&&r.fieldMask.isEqual(e.fieldMask))}var ds=class extends Wo{constructor(e,t,n,s=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}},Xr=class extends Wo{constructor(e,t,n,s,a=[]){super(),this.key=e,this.data=t,this.fieldMask=n,this.precondition=s,this.fieldTransforms=a,this.type=1}getFieldMask(){return this.fieldMask}};function vT(r){let e=new Map;return r.fieldMask.fields.forEach(t=>{if(!t.isEmpty()){let n=r.data.field(t);e.set(t,n)}}),e}function lb(r,e,t){let n=new Map;Le(r.length===t.length);for(let s=0;s<t.length;s++){let a=r[s],c=a.transform,h=e.data.field(a.field);n.set(a.field,fM(c,h,t[s]))}return n}function hb(r,e,t){let n=new Map;for(let s of r){let a=s.transform,c=t.data.field(s.field);n.set(s.field,hM(a,c,e))}return n}var fh=class extends Wo{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}},Bp=class extends Wo{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}};var jp=class{constructor(e,t,n,s){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=s}applyToRemoteDocument(e,t){let n=t.mutationResults;for(let s=0;s<this.mutations.length;s++){let a=this.mutations[s];a.key.isEqual(e.key)&&pM(a,e,n[s])}}applyToLocalView(e,t){for(let n of this.baseMutations)n.key.isEqual(e.key)&&(t=pu(n,e,t,this.localWriteTime));for(let n of this.mutations)n.key.isEqual(e.key)&&(t=pu(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let n=fT();return this.mutations.forEach(s=>{let a=e.get(s.key),c=a.overlayedDocument,h=this.applyToLocalView(c,a.mutatedFields);h=t.has(s.key)?null:h;let f=yT(c,h);f!==null&&n.set(s.key,f),c.isValidDocument()||c.convertToNoDocument(me.min())}),n}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),xe())}isEqual(e){return this.batchId===e.batchId&&Lo(this.mutations,e.mutations,(t,n)=>cb(t,n))&&Lo(this.baseMutations,e.baseMutations,(t,n)=>cb(t,n))}},$p=class r{constructor(e,t,n,s){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=s}static from(e,t,n){Le(e.mutations.length===n.length);let s=function(){return oM}(),a=e.mutations;for(let c=0;c<a.length;c++)s=s.insert(a[c].key,n[c].version);return new r(e,t,n,s)}};var qp=class{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{
|
|
29
29
|
largestBatchId: ${this.largestBatchId},
|
|
30
30
|
mutation: ${this.mutation.toString()}
|
|
31
|
-
}`}};var zp=class{constructor(e,t){this.count=e,this.unchangedNames=t}};var it,Pe;function gM(r){switch(r){case H.OK:return ue();case H.CANCELLED:case H.UNKNOWN:case H.DEADLINE_EXCEEDED:case H.RESOURCE_EXHAUSTED:case H.INTERNAL:case H.UNAVAILABLE:case H.UNAUTHENTICATED:return!1;case H.INVALID_ARGUMENT:case H.NOT_FOUND:case H.ALREADY_EXISTS:case H.PERMISSION_DENIED:case H.FAILED_PRECONDITION:case H.ABORTED:case H.OUT_OF_RANGE:case H.UNIMPLEMENTED:case H.DATA_LOSS:return!0;default:return ue()}}function vT(r){if(r===void 0)return Pn("GRPC error has no .code"),H.UNKNOWN;switch(r){case it.OK:return H.OK;case it.CANCELLED:return H.CANCELLED;case it.UNKNOWN:return H.UNKNOWN;case it.DEADLINE_EXCEEDED:return H.DEADLINE_EXCEEDED;case it.RESOURCE_EXHAUSTED:return H.RESOURCE_EXHAUSTED;case it.INTERNAL:return H.INTERNAL;case it.UNAVAILABLE:return H.UNAVAILABLE;case it.UNAUTHENTICATED:return H.UNAUTHENTICATED;case it.INVALID_ARGUMENT:return H.INVALID_ARGUMENT;case it.NOT_FOUND:return H.NOT_FOUND;case it.ALREADY_EXISTS:return H.ALREADY_EXISTS;case it.PERMISSION_DENIED:return H.PERMISSION_DENIED;case it.FAILED_PRECONDITION:return H.FAILED_PRECONDITION;case it.ABORTED:return H.ABORTED;case it.OUT_OF_RANGE:return H.OUT_OF_RANGE;case it.UNIMPLEMENTED:return H.UNIMPLEMENTED;case it.DATA_LOSS:return H.DATA_LOSS;default:return ue()}}(Pe=it||(it={}))[Pe.OK=0]="OK",Pe[Pe.CANCELLED=1]="CANCELLED",Pe[Pe.UNKNOWN=2]="UNKNOWN",Pe[Pe.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Pe[Pe.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Pe[Pe.NOT_FOUND=5]="NOT_FOUND",Pe[Pe.ALREADY_EXISTS=6]="ALREADY_EXISTS",Pe[Pe.PERMISSION_DENIED=7]="PERMISSION_DENIED",Pe[Pe.UNAUTHENTICATED=16]="UNAUTHENTICATED",Pe[Pe.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Pe[Pe.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Pe[Pe.ABORTED=10]="ABORTED",Pe[Pe.OUT_OF_RANGE=11]="OUT_OF_RANGE",Pe[Pe.UNIMPLEMENTED=12]="UNIMPLEMENTED",Pe[Pe.INTERNAL=13]="INTERNAL",Pe[Pe.UNAVAILABLE=14]="UNAVAILABLE",Pe[Pe.DATA_LOSS=15]="DATA_LOSS";var hb=null;function _M(){return new TextEncoder}var yM=new Sn([4294967295,4294967295],0);function fb(r){let e=_M().encode(r),t=new ap;return t.update(e),new Uint8Array(t.digest())}function db(r){let e=new DataView(r.buffer),t=e.getUint32(0,!0),n=e.getUint32(4,!0),s=e.getUint32(8,!0),a=e.getUint32(12,!0);return[new Sn([t,n],0),new Sn([s,a],0)]}var Gp=class r{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new as(`Invalid padding: ${t}`);if(n<0)throw new as(`Invalid hash count: ${n}`);if(e.length>0&&this.hashCount===0)throw new as(`Invalid hash count: ${n}`);if(e.length===0&&t!==0)throw new as(`Invalid padding when bitmap length is 0: ${t}`);this.Ee=8*e.length-t,this.de=Sn.fromNumber(this.Ee)}Ae(e,t,n){let s=e.add(t.multiply(Sn.fromNumber(n)));return s.compare(yM)===1&&(s=new Sn([s.getBits(0),s.getBits(1)],0)),s.modulo(this.de).toNumber()}Re(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.Ee===0)return!1;let t=fb(e),[n,s]=db(t);for(let a=0;a<this.hashCount;a++){let c=this.Ae(n,s,a);if(!this.Re(c))return!1}return!0}static create(e,t,n){let s=e%8==0?0:8-e%8,a=new Uint8Array(Math.ceil(e/8)),c=new r(a,s,t);return n.forEach(h=>c.insert(h)),c}insert(e){if(this.Ee===0)return;let t=fb(e),[n,s]=db(t);for(let a=0;a<this.hashCount;a++){let c=this.Ae(n,s,a);this.Ve(c)}}Ve(e){let t=Math.floor(e/8),n=e%8;this.bitmap[t]|=1<<n}},as=class extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}};var dh=class r{constructor(e,t,n,s,a){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=s,this.resolvedLimboDocuments=a}static createSynthesizedRemoteEventForCurrentChange(e,t,n){let s=new Map;return s.set(e,vu.createSynthesizedTargetChangeForCurrentChange(e,t,n)),new r(me.min(),s,new Ye(Re),kn(),xe())}},vu=class r{constructor(e,t,n,s,a){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=s,this.removedDocuments=a}static createSynthesizedTargetChangeForCurrentChange(e,t,n){return new r(n,t,xe(),xe(),xe())}};var ko=class{constructor(e,t,n,s){this.me=e,this.removedTargetIds=t,this.key=n,this.fe=s}},ph=class{constructor(e,t){this.targetId=e,this.ge=t}},mh=class{constructor(e,t,n=Rt.EMPTY_BYTE_STRING,s=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=s}},gh=class{constructor(){this.pe=0,this.ye=pb(),this.we=Rt.EMPTY_BYTE_STRING,this.Se=!1,this.be=!0}get current(){return this.Se}get resumeToken(){return this.we}get De(){return this.pe!==0}get ve(){return this.be}Ce(e){e.approximateByteSize()>0&&(this.be=!0,this.we=e)}Fe(){let e=xe(),t=xe(),n=xe();return this.ye.forEach((s,a)=>{switch(a){case 0:e=e.add(s);break;case 2:t=t.add(s);break;case 1:n=n.add(s);break;default:ue()}}),new vu(this.we,this.Se,e,t,n)}Me(){this.be=!1,this.ye=pb()}xe(e,t){this.be=!0,this.ye=this.ye.insert(e,t)}Oe(e){this.be=!0,this.ye=this.ye.remove(e)}Ne(){this.pe+=1}Be(){this.pe-=1,Le(this.pe>=0)}Le(){this.be=!0,this.Se=!0}},Kp=class{constructor(e){this.ke=e,this.qe=new Map,this.Qe=kn(),this.$e=Xl(),this.Ke=Xl(),this.Ue=new Ye(Re)}We(e){for(let t of e.me)e.fe&&e.fe.isFoundDocument()?this.Ge(t,e.fe):this.ze(t,e.key,e.fe);for(let t of e.removedTargetIds)this.ze(t,e.key,e.fe)}je(e){this.forEachTarget(e,t=>{let n=this.He(t);switch(e.state){case 0:this.Je(t)&&n.Ce(e.resumeToken);break;case 1:n.Be(),n.De||n.Me(),n.Ce(e.resumeToken);break;case 2:n.Be(),n.De||this.removeTarget(t);break;case 3:this.Je(t)&&(n.Le(),n.Ce(e.resumeToken));break;case 4:this.Je(t)&&(this.Ye(t),n.Ce(e.resumeToken));break;default:ue()}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.qe.forEach((n,s)=>{this.Je(s)&&t(s)})}Ze(e){let t=e.targetId,n=e.ge.count,s=this.Xe(t);if(s){let a=s.target;if(Mp(a))if(n===0){let c=new ce(a.path);this.ze(t,c,Sr.newNoDocument(c,me.min()))}else Le(n===1);else{let c=this.et(t);if(c!==n){let h=this.tt(e),f=h?this.nt(h,e,c):1;if(f!==0){this.Ye(t);let m=f===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ue=this.Ue.insert(t,m)}hb==null||hb.rt(function(_,E,I,k,B){var G,j,J,ee,re,le;let de={localCacheCount:_,existenceFilterCount:E.count,databaseId:I.database,projectId:I.projectId},ie=E.unchangedNames;return ie&&(de.bloomFilter={applied:B===0,hashCount:(G=ie==null?void 0:ie.hashCount)!==null&&G!==void 0?G:0,bitmapLength:(ee=(J=(j=ie==null?void 0:ie.bits)===null||j===void 0?void 0:j.bitmap)===null||J===void 0?void 0:J.length)!==null&&ee!==void 0?ee:0,padding:(le=(re=ie==null?void 0:ie.bits)===null||re===void 0?void 0:re.padding)!==null&&le!==void 0?le:0,mightContain:C=>{var A;return(A=k==null?void 0:k.mightContain(C))!==null&&A!==void 0&&A}}),de}(c,e.ge,this.ke.it(),h,f))}}}}tt(e){let t=e.ge.unchangedNames;if(!t||!t.bits)return null;let{bits:{bitmap:n="",padding:s=0},hashCount:a=0}=t,c,h;try{c=Dn(n).toUint8Array()}catch(f){if(f instanceof uh)return Vo("Decoding the base64 bloom filter in existence filter failed ("+f.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw f}try{h=new Gp(c,s,a)}catch(f){return Vo(f instanceof as?"BloomFilter error: ":"Applying bloom filter failed: ",f),null}return h.Ee===0?null:h}nt(e,t,n){return t.ge.count===n-this.st(e,t.targetId)?0:2}st(e,t){let n=this.ke.getRemoteKeysForTarget(t),s=0;return n.forEach(a=>{let c=this.ke.it(),h=`projects/${c.projectId}/databases/${c.database}/documents/${a.path.canonicalString()}`;e.mightContain(h)||(this.ze(t,a,null),s++)}),s}ot(e){let t=new Map;this.qe.forEach((a,c)=>{let h=this.Xe(c);if(h){if(a.current&&Mp(h.target)){let f=new ce(h.target.path);this._t(f).has(c)||this.ut(c,f)||this.ze(c,f,Sr.newNoDocument(f,e))}a.ve&&(t.set(c,a.Fe()),a.Me())}});let n=xe();this.Ke.forEach((a,c)=>{let h=!0;c.forEachWhile(f=>{let m=this.Xe(f);return!m||m.purpose==="TargetPurposeLimboResolution"||(h=!1,!1)}),h&&(n=n.add(a))}),this.Qe.forEach((a,c)=>c.setReadTime(e));let s=new dh(e,t,this.Ue,this.Qe,n);return this.Qe=kn(),this.$e=Xl(),this.Ke=Xl(),this.Ue=new Ye(Re),s}Ge(e,t){if(!this.Je(e))return;let n=this.ut(e,t.key)?2:0;this.He(e).xe(t.key,n),this.Qe=this.Qe.insert(t.key,t),this.$e=this.$e.insert(t.key,this._t(t.key).add(e)),this.Ke=this.Ke.insert(t.key,this.ct(t.key).add(e))}ze(e,t,n){if(!this.Je(e))return;let s=this.He(e);this.ut(e,t)?s.xe(t,1):s.Oe(t),this.Ke=this.Ke.insert(t,this.ct(t).delete(e)),this.Ke=this.Ke.insert(t,this.ct(t).add(e)),n&&(this.Qe=this.Qe.insert(t,n))}removeTarget(e){this.qe.delete(e)}et(e){let t=this.He(e).Fe();return this.ke.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}Ne(e){this.He(e).Ne()}He(e){let t=this.qe.get(e);return t||(t=new gh,this.qe.set(e,t)),t}ct(e){let t=this.Ke.get(e);return t||(t=new yt(Re),this.Ke=this.Ke.insert(e,t)),t}_t(e){let t=this.$e.get(e);return t||(t=new yt(Re),this.$e=this.$e.insert(e,t)),t}Je(e){let t=this.Xe(e)!==null;return t||X("WatchChangeAggregator","Detected inactive target",e),t}Xe(e){let t=this.qe.get(e);return t&&t.De?null:this.ke.lt(e)}Ye(e){this.qe.set(e,new gh),this.ke.getRemoteKeysForTarget(e).forEach(t=>{this.ze(e,t,null)})}ut(e,t){return this.ke.getRemoteKeysForTarget(e).has(t)}};function Xl(){return new Ye(ce.comparator)}function pb(){return new Ye(ce.comparator)}var vM={asc:"ASCENDING",desc:"DESCENDING"},wM={"<":"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"},bM={and:"AND",or:"OR"},Wp=class{constructor(e,t){this.databaseId=e,this.useProto3Json=t}};function Hp(r,e){return r.useProto3Json||jh(e)?e:{value:e}}function _h(r,e){return r.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function wT(r,e){return r.useProto3Json?e.toBase64():e.toUint8Array()}function TM(r,e){return _h(r,e.toTimestamp())}function Hr(r){return Le(!!r),me.fromTimestamp(function(t){let n=Cn(t);return new wt(n.seconds,n.nanos)}(r))}function ag(r,e){return Qp(r,e).canonicalString()}function Qp(r,e){let t=function(s){return new ot(["projects",s.projectId,"databases",s.database])}(r).child("documents");return e===void 0?t:t.child(e)}function bT(r){let e=ot.fromString(r);return Le(AT(e)),e}function Jp(r,e){return ag(r.databaseId,e.path)}function dp(r,e){let t=bT(e);if(t.get(1)!==r.databaseId.projectId)throw new ne(H.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+r.databaseId.projectId);if(t.get(3)!==r.databaseId.database)throw new ne(H.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+r.databaseId.database);return new ce(ET(t))}function TT(r,e){return ag(r.databaseId,e)}function EM(r){let e=bT(r);return e.length===4?ot.emptyPath():ET(e)}function Yp(r){return new ot(["projects",r.databaseId.projectId,"databases",r.databaseId.database]).canonicalString()}function ET(r){return Le(r.length>4&&r.get(4)==="documents"),r.popFirst(5)}function mb(r,e,t){return{name:Jp(r,e),fields:t.value.mapValue.fields}}function IM(r,e){let t;if("targetChange"in e){e.targetChange;let n=function(m){return m==="NO_CHANGE"?0:m==="ADD"?1:m==="REMOVE"?2:m==="CURRENT"?3:m==="RESET"?4:ue()}(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],a=function(m,_){return m.useProto3Json?(Le(_===void 0||typeof _=="string"),Rt.fromBase64String(_||"")):(Le(_===void 0||_ instanceof Buffer||_ instanceof Uint8Array),Rt.fromUint8Array(_||new Uint8Array))}(r,e.targetChange.resumeToken),c=e.targetChange.cause,h=c&&function(m){let _=m.code===void 0?H.UNKNOWN:vT(m.code);return new ne(_,m.message||"")}(c);t=new mh(n,s,a,h||null)}else if("documentChange"in e){e.documentChange;let n=e.documentChange;n.document,n.document.name,n.document.updateTime;let s=dp(r,n.document.name),a=Hr(n.document.updateTime),c=n.document.createTime?Hr(n.document.createTime):me.min(),h=new er({mapValue:{fields:n.document.fields}}),f=Sr.newFoundDocument(s,a,c,h),m=n.targetIds||[],_=n.removedTargetIds||[];t=new ko(m,_,f.key,f)}else if("documentDelete"in e){e.documentDelete;let n=e.documentDelete;n.document;let s=dp(r,n.document),a=n.readTime?Hr(n.readTime):me.min(),c=Sr.newNoDocument(s,a),h=n.removedTargetIds||[];t=new ko([],h,c.key,c)}else if("documentRemove"in e){e.documentRemove;let n=e.documentRemove;n.document;let s=dp(r,n.document),a=n.removedTargetIds||[];t=new ko([],a,s,null)}else{if(!("filter"in e))return ue();{e.filter;let n=e.filter;n.targetId;let{count:s=0,unchangedNames:a}=n,c=new zp(s,a),h=n.targetId;t=new ph(h,c)}}return t}function xM(r,e){let t;if(e instanceof ds)t={update:mb(r,e.key,e.value)};else if(e instanceof fh)t={delete:Jp(r,e.key)};else if(e instanceof Xr)t={update:mb(r,e.key,e.data),updateMask:NM(e.fieldMask)};else{if(!(e instanceof Bp))return ue();t={verify:Jp(r,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map(n=>function(a,c){let h=c.transform;if(h instanceof Go)return{fieldPath:c.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(h instanceof hs)return{fieldPath:c.field.canonicalString(),appendMissingElements:{values:h.elements}};if(h instanceof fs)return{fieldPath:c.field.canonicalString(),removeAllFromArray:{values:h.elements}};if(h instanceof Ko)return{fieldPath:c.field.canonicalString(),increment:h.Ie};throw ue()}(0,n))),e.precondition.isNone||(t.currentDocument=function(s,a){return a.updateTime!==void 0?{updateTime:TM(s,a.updateTime)}:a.exists!==void 0?{exists:a.exists}:ue()}(r,e.precondition)),t}function AM(r,e){return r&&r.length>0?(Le(e!==void 0),r.map(t=>function(s,a){let c=s.updateTime?Hr(s.updateTime):Hr(a);return c.isEqual(me.min())&&(c=Hr(a)),new Up(c,s.transformResults||[])}(t,e))):[]}function SM(r,e){return{documents:[TT(r,e.path)]}}function RM(r,e){let t={structuredQuery:{}},n=e.path,s;e.collectionGroup!==null?(s=n,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(s=n.popLast(),t.structuredQuery.from=[{collectionId:n.lastSegment()}]),t.parent=TT(r,s);let a=function(m){if(m.length!==0)return xT(Yr.create(m,"and"))}(e.filters);a&&(t.structuredQuery.where=a);let c=function(m){if(m.length!==0)return m.map(_=>function(I){return{field:Co(I.field),direction:DM(I.dir)}}(_))}(e.orderBy);c&&(t.structuredQuery.orderBy=c);let h=Hp(r,e.limit);return h!==null&&(t.structuredQuery.limit=h),e.startAt&&(t.structuredQuery.startAt=function(m){return{before:m.inclusive,values:m.position}}(e.startAt)),e.endAt&&(t.structuredQuery.endAt=function(m){return{before:!m.inclusive,values:m.position}}(e.endAt)),{ht:t,parent:s}}function PM(r){let e=EM(r.parent),t=r.structuredQuery,n=t.from?t.from.length:0,s=null;if(n>0){Le(n===1);let _=t.from[0];_.allDescendants?s=_.collectionId:e=e.child(_.collectionId)}let a=[];t.where&&(a=function(E){let I=IT(E);return I instanceof Yr&&nT(I)?I.getFilters():[I]}(t.where));let c=[];t.orderBy&&(c=function(E){return E.map(I=>function(B){return new $o(Do(B.field),function(j){switch(j){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(B.direction))}(I))}(t.orderBy));let h=null;t.limit&&(h=function(E){let I;return I=typeof E=="object"?E.value:E,jh(I)?null:I}(t.limit));let f=null;t.startAt&&(f=function(E){let I=!!E.before,k=E.values||[];return new jo(k,I)}(t.startAt));let m=null;return t.endAt&&(m=function(E){let I=!E.before,k=E.values||[];return new jo(k,I)}(t.endAt)),eM(e,s,c,a,h,"F",f,m)}function CM(r,e){let t=function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return ue()}}(e.purpose);return t==null?null:{"goog-listen-tags":t}}function IT(r){return r.unaryFilter!==void 0?function(t){switch(t.unaryFilter.op){case"IS_NAN":let n=Do(t.unaryFilter.field);return pt.create(n,"==",{doubleValue:NaN});case"IS_NULL":let s=Do(t.unaryFilter.field);return pt.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":let a=Do(t.unaryFilter.field);return pt.create(a,"!=",{doubleValue:NaN});case"IS_NOT_NULL":let c=Do(t.unaryFilter.field);return pt.create(c,"!=",{nullValue:"NULL_VALUE"});default:return ue()}}(r):r.fieldFilter!==void 0?function(t){return pt.create(Do(t.fieldFilter.field),function(s){switch(s){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return ue()}}(t.fieldFilter.op),t.fieldFilter.value)}(r):r.compositeFilter!==void 0?function(t){return Yr.create(t.compositeFilter.filters.map(n=>IT(n)),function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return ue()}}(t.compositeFilter.op))}(r):ue()}function DM(r){return vM[r]}function OM(r){return wM[r]}function kM(r){return bM[r]}function Co(r){return{fieldPath:r.canonicalString()}}function Do(r){return tr.fromServerFormat(r.fieldPath)}function xT(r){return r instanceof pt?function(t){if(t.op==="=="){if(rb(t.value))return{unaryFilter:{field:Co(t.field),op:"IS_NAN"}};if(tb(t.value))return{unaryFilter:{field:Co(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(rb(t.value))return{unaryFilter:{field:Co(t.field),op:"IS_NOT_NAN"}};if(tb(t.value))return{unaryFilter:{field:Co(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Co(t.field),op:OM(t.op),value:t.value}}}(r):r instanceof Yr?function(t){let n=t.getFilters().map(s=>xT(s));return n.length===1?n[0]:{compositeFilter:{op:kM(t.op),filters:n}}}(r):ue()}function NM(r){let e=[];return r.fields.forEach(t=>e.push(t.canonicalString())),{fieldPaths:e}}function AT(r){return r.length>=4&&r.get(0)==="projects"&&r.get(2)==="databases"}var wu=class r{constructor(e,t,n,s,a=me.min(),c=me.min(),h=Rt.EMPTY_BYTE_STRING,f=null){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=s,this.snapshotVersion=a,this.lastLimboFreeSnapshotVersion=c,this.resumeToken=h,this.expectedCount=f}withSequenceNumber(e){return new r(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new r(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new r(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new r(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}};var Xp=class{constructor(e){this.Tt=e}};function VM(r){let e=PM({parent:r.parent,structuredQuery:r.structuredQuery});return r.limitType==="LAST"?Fp(e,e.limit,"L"):e}var yh=class{constructor(){}At(e,t){this.Rt(e,t),t.Vt()}Rt(e,t){if("nullValue"in e)this.ft(t,5);else if("booleanValue"in e)this.ft(t,10),t.gt(e.booleanValue?1:0);else if("integerValue"in e)this.ft(t,15),t.gt(Ge(e.integerValue));else if("doubleValue"in e){let n=Ge(e.doubleValue);isNaN(n)?this.ft(t,13):(this.ft(t,15),gu(n)?t.gt(0):t.gt(n))}else if("timestampValue"in e){let n=e.timestampValue;this.ft(t,20),typeof n=="string"&&(n=Cn(n)),t.yt(`${n.seconds||""}`),t.gt(n.nanos||0)}else if("stringValue"in e)this.wt(e.stringValue,t),this.St(t);else if("bytesValue"in e)this.ft(t,30),t.bt(Dn(e.bytesValue)),this.St(t);else if("referenceValue"in e)this.Dt(e.referenceValue,t);else if("geoPointValue"in e){let n=e.geoPointValue;this.ft(t,45),t.gt(n.latitude||0),t.gt(n.longitude||0)}else"mapValue"in e?eT(e)?this.ft(t,Number.MAX_SAFE_INTEGER):Zb(e)?this.vt(e.mapValue,t):(this.Ct(e.mapValue,t),this.St(t)):"arrayValue"in e?(this.Ft(e.arrayValue,t),this.St(t)):ue()}wt(e,t){this.ft(t,25),this.Mt(e,t)}Mt(e,t){t.yt(e)}Ct(e,t){let n=e.fields||{};this.ft(t,55);for(let s of Object.keys(n))this.wt(s,t),this.Rt(n[s],t)}vt(e,t){var n,s;let a=e.fields||{};this.ft(t,53);let c=Fo,h=((s=(n=a[c].arrayValue)===null||n===void 0?void 0:n.values)===null||s===void 0?void 0:s.length)||0;this.ft(t,15),t.gt(Ge(h)),this.wt(c,t),this.Rt(a[c],t)}Ft(e,t){let n=e.values||[];this.ft(t,50);for(let s of n)this.Rt(s,t)}Dt(e,t){this.ft(t,37),ce.fromName(e).path.forEach(n=>{this.ft(t,60),this.Mt(n,t)})}ft(e,t){e.gt(t)}St(e){e.gt(2)}};yh.xt=new yh;var Zp=class{constructor(){this.Tn=new em}addToCollectionParentIndex(e,t){return this.Tn.add(t),W.resolve()}getCollectionParents(e,t){return W.resolve(this.Tn.getEntries(t))}addFieldIndex(e,t){return W.resolve()}deleteFieldIndex(e,t){return W.resolve()}deleteAllFieldIndexes(e){return W.resolve()}createTargetIndexes(e,t){return W.resolve()}getDocumentsMatchingTarget(e,t){return W.resolve(null)}getIndexType(e,t){return W.resolve(0)}getFieldIndexes(e,t){return W.resolve([])}getNextCollectionGroupToUpdate(e){return W.resolve(null)}getMinOffset(e,t){return W.resolve(ls.min())}getMinOffsetFromCollectionGroup(e,t){return W.resolve(ls.min())}updateCollectionGroup(e,t,n){return W.resolve()}updateIndexEntries(e,t){return W.resolve()}},em=class{constructor(){this.index={}}add(e){let t=e.lastSegment(),n=e.popLast(),s=this.index[t]||new yt(ot.comparator),a=!s.has(n);return this.index[t]=s.add(n),a}has(e){let t=e.lastSegment(),n=e.popLast(),s=this.index[t];return s&&s.has(n)}getEntries(e){return(this.index[e]||new yt(ot.comparator)).toArray()}};var wK=new Uint8Array(0);var gb={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},ST=41943040,lr=class r{static withCacheSize(e){return new r(e,r.DEFAULT_COLLECTION_PERCENTILE,r.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}};lr.DEFAULT_COLLECTION_PERCENTILE=10,lr.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,lr.DEFAULT=new lr(ST,lr.DEFAULT_COLLECTION_PERCENTILE,lr.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),lr.DISABLED=new lr(-1,0,0);var bu=class r{constructor(e){this.$n=e}next(){return this.$n+=2,this.$n}static Kn(){return new r(0)}static Un(){return new r(-1)}};var _b="LruGarbageCollector",LM=1048576;function yb([r,e],[t,n]){let s=Re(r,t);return s===0?Re(e,n):s}var tm=class{constructor(e){this.Hn=e,this.buffer=new yt(yb),this.Jn=0}Yn(){return++this.Jn}Zn(e){let t=[e,this.Yn()];if(this.buffer.size<this.Hn)this.buffer=this.buffer.add(t);else{let n=this.buffer.last();yb(t,n)<0&&(this.buffer=this.buffer.delete(n).add(t))}}get maxValue(){return this.buffer.last()[0]}},rm=class{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,this.localStore=n,this.Xn=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.er(6e4)}stop(){this.Xn&&(this.Xn.cancel(),this.Xn=null)}get started(){return this.Xn!==null}er(e){X(_b,`Garbage collection scheduled in ${e}ms`),this.Xn=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Xn=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){Zo(t)?X(_b,"Ignoring IndexedDB error during garbage collection: ",t):await Xo(t)}await this.er(3e5)})}},nm=class{constructor(e,t){this.tr=e,this.params=t}calculateTargetCount(e,t){return this.tr.nr(e).next(n=>Math.floor(t/100*n))}nthSequenceNumber(e,t){if(t===0)return W.resolve(Mo.ae);let n=new tm(t);return this.tr.forEachTarget(e,s=>n.Zn(s.sequenceNumber)).next(()=>this.tr.rr(e,s=>n.Zn(s))).next(()=>n.maxValue)}removeTargets(e,t,n){return this.tr.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.tr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(X("LruGarbageCollector","Garbage collection skipped; disabled"),W.resolve(gb)):this.getCacheSize(e).next(n=>n<this.params.cacheSizeCollectionThreshold?(X("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),gb):this.ir(e,t))}getCacheSize(e){return this.tr.getCacheSize(e)}ir(e,t){let n,s,a,c,h,f,m,_=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(E=>(E>this.params.maximumSequenceNumbersToCollect?(X("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${E}`),s=this.params.maximumSequenceNumbersToCollect):s=E,c=Date.now(),this.nthSequenceNumber(e,s))).next(E=>(n=E,h=Date.now(),this.removeTargets(e,n,t))).next(E=>(a=E,f=Date.now(),this.removeOrphanedDocuments(e,n))).next(E=>(m=Date.now(),Ro()<=Se.DEBUG&&X("LruGarbageCollector",`LRU Garbage Collection
|
|
31
|
+
}`}};var zp=class{constructor(e,t){this.count=e,this.unchangedNames=t}};var it,Pe;function gM(r){switch(r){case H.OK:return ue();case H.CANCELLED:case H.UNKNOWN:case H.DEADLINE_EXCEEDED:case H.RESOURCE_EXHAUSTED:case H.INTERNAL:case H.UNAVAILABLE:case H.UNAUTHENTICATED:return!1;case H.INVALID_ARGUMENT:case H.NOT_FOUND:case H.ALREADY_EXISTS:case H.PERMISSION_DENIED:case H.FAILED_PRECONDITION:case H.ABORTED:case H.OUT_OF_RANGE:case H.UNIMPLEMENTED:case H.DATA_LOSS:return!0;default:return ue()}}function wT(r){if(r===void 0)return Pn("GRPC error has no .code"),H.UNKNOWN;switch(r){case it.OK:return H.OK;case it.CANCELLED:return H.CANCELLED;case it.UNKNOWN:return H.UNKNOWN;case it.DEADLINE_EXCEEDED:return H.DEADLINE_EXCEEDED;case it.RESOURCE_EXHAUSTED:return H.RESOURCE_EXHAUSTED;case it.INTERNAL:return H.INTERNAL;case it.UNAVAILABLE:return H.UNAVAILABLE;case it.UNAUTHENTICATED:return H.UNAUTHENTICATED;case it.INVALID_ARGUMENT:return H.INVALID_ARGUMENT;case it.NOT_FOUND:return H.NOT_FOUND;case it.ALREADY_EXISTS:return H.ALREADY_EXISTS;case it.PERMISSION_DENIED:return H.PERMISSION_DENIED;case it.FAILED_PRECONDITION:return H.FAILED_PRECONDITION;case it.ABORTED:return H.ABORTED;case it.OUT_OF_RANGE:return H.OUT_OF_RANGE;case it.UNIMPLEMENTED:return H.UNIMPLEMENTED;case it.DATA_LOSS:return H.DATA_LOSS;default:return ue()}}(Pe=it||(it={}))[Pe.OK=0]="OK",Pe[Pe.CANCELLED=1]="CANCELLED",Pe[Pe.UNKNOWN=2]="UNKNOWN",Pe[Pe.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Pe[Pe.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Pe[Pe.NOT_FOUND=5]="NOT_FOUND",Pe[Pe.ALREADY_EXISTS=6]="ALREADY_EXISTS",Pe[Pe.PERMISSION_DENIED=7]="PERMISSION_DENIED",Pe[Pe.UNAUTHENTICATED=16]="UNAUTHENTICATED",Pe[Pe.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Pe[Pe.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Pe[Pe.ABORTED=10]="ABORTED",Pe[Pe.OUT_OF_RANGE=11]="OUT_OF_RANGE",Pe[Pe.UNIMPLEMENTED=12]="UNIMPLEMENTED",Pe[Pe.INTERNAL=13]="INTERNAL",Pe[Pe.UNAVAILABLE=14]="UNAVAILABLE",Pe[Pe.DATA_LOSS=15]="DATA_LOSS";var fb=null;function _M(){return new TextEncoder}var yM=new Sn([4294967295,4294967295],0);function db(r){let e=_M().encode(r),t=new ap;return t.update(e),new Uint8Array(t.digest())}function pb(r){let e=new DataView(r.buffer),t=e.getUint32(0,!0),n=e.getUint32(4,!0),s=e.getUint32(8,!0),a=e.getUint32(12,!0);return[new Sn([t,n],0),new Sn([s,a],0)]}var Gp=class r{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new as(`Invalid padding: ${t}`);if(n<0)throw new as(`Invalid hash count: ${n}`);if(e.length>0&&this.hashCount===0)throw new as(`Invalid hash count: ${n}`);if(e.length===0&&t!==0)throw new as(`Invalid padding when bitmap length is 0: ${t}`);this.Ee=8*e.length-t,this.de=Sn.fromNumber(this.Ee)}Ae(e,t,n){let s=e.add(t.multiply(Sn.fromNumber(n)));return s.compare(yM)===1&&(s=new Sn([s.getBits(0),s.getBits(1)],0)),s.modulo(this.de).toNumber()}Re(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.Ee===0)return!1;let t=db(e),[n,s]=pb(t);for(let a=0;a<this.hashCount;a++){let c=this.Ae(n,s,a);if(!this.Re(c))return!1}return!0}static create(e,t,n){let s=e%8==0?0:8-e%8,a=new Uint8Array(Math.ceil(e/8)),c=new r(a,s,t);return n.forEach(h=>c.insert(h)),c}insert(e){if(this.Ee===0)return;let t=db(e),[n,s]=pb(t);for(let a=0;a<this.hashCount;a++){let c=this.Ae(n,s,a);this.Ve(c)}}Ve(e){let t=Math.floor(e/8),n=e%8;this.bitmap[t]|=1<<n}},as=class extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}};var dh=class r{constructor(e,t,n,s,a){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=s,this.resolvedLimboDocuments=a}static createSynthesizedRemoteEventForCurrentChange(e,t,n){let s=new Map;return s.set(e,vu.createSynthesizedTargetChangeForCurrentChange(e,t,n)),new r(me.min(),s,new Ye(Re),kn(),xe())}},vu=class r{constructor(e,t,n,s,a){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=s,this.removedDocuments=a}static createSynthesizedTargetChangeForCurrentChange(e,t,n){return new r(n,t,xe(),xe(),xe())}};var ko=class{constructor(e,t,n,s){this.me=e,this.removedTargetIds=t,this.key=n,this.fe=s}},ph=class{constructor(e,t){this.targetId=e,this.ge=t}},mh=class{constructor(e,t,n=Rt.EMPTY_BYTE_STRING,s=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=s}},gh=class{constructor(){this.pe=0,this.ye=mb(),this.we=Rt.EMPTY_BYTE_STRING,this.Se=!1,this.be=!0}get current(){return this.Se}get resumeToken(){return this.we}get De(){return this.pe!==0}get ve(){return this.be}Ce(e){e.approximateByteSize()>0&&(this.be=!0,this.we=e)}Fe(){let e=xe(),t=xe(),n=xe();return this.ye.forEach((s,a)=>{switch(a){case 0:e=e.add(s);break;case 2:t=t.add(s);break;case 1:n=n.add(s);break;default:ue()}}),new vu(this.we,this.Se,e,t,n)}Me(){this.be=!1,this.ye=mb()}xe(e,t){this.be=!0,this.ye=this.ye.insert(e,t)}Oe(e){this.be=!0,this.ye=this.ye.remove(e)}Ne(){this.pe+=1}Be(){this.pe-=1,Le(this.pe>=0)}Le(){this.be=!0,this.Se=!0}},Kp=class{constructor(e){this.ke=e,this.qe=new Map,this.Qe=kn(),this.$e=Xl(),this.Ke=Xl(),this.Ue=new Ye(Re)}We(e){for(let t of e.me)e.fe&&e.fe.isFoundDocument()?this.Ge(t,e.fe):this.ze(t,e.key,e.fe);for(let t of e.removedTargetIds)this.ze(t,e.key,e.fe)}je(e){this.forEachTarget(e,t=>{let n=this.He(t);switch(e.state){case 0:this.Je(t)&&n.Ce(e.resumeToken);break;case 1:n.Be(),n.De||n.Me(),n.Ce(e.resumeToken);break;case 2:n.Be(),n.De||this.removeTarget(t);break;case 3:this.Je(t)&&(n.Le(),n.Ce(e.resumeToken));break;case 4:this.Je(t)&&(this.Ye(t),n.Ce(e.resumeToken));break;default:ue()}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.qe.forEach((n,s)=>{this.Je(s)&&t(s)})}Ze(e){let t=e.targetId,n=e.ge.count,s=this.Xe(t);if(s){let a=s.target;if(Mp(a))if(n===0){let c=new ce(a.path);this.ze(t,c,Sr.newNoDocument(c,me.min()))}else Le(n===1);else{let c=this.et(t);if(c!==n){let h=this.tt(e),f=h?this.nt(h,e,c):1;if(f!==0){this.Ye(t);let m=f===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ue=this.Ue.insert(t,m)}fb==null||fb.rt(function(_,E,I,k,B){var G,j,J,ee,re,le;let de={localCacheCount:_,existenceFilterCount:E.count,databaseId:I.database,projectId:I.projectId},ie=E.unchangedNames;return ie&&(de.bloomFilter={applied:B===0,hashCount:(G=ie==null?void 0:ie.hashCount)!==null&&G!==void 0?G:0,bitmapLength:(ee=(J=(j=ie==null?void 0:ie.bits)===null||j===void 0?void 0:j.bitmap)===null||J===void 0?void 0:J.length)!==null&&ee!==void 0?ee:0,padding:(le=(re=ie==null?void 0:ie.bits)===null||re===void 0?void 0:re.padding)!==null&&le!==void 0?le:0,mightContain:C=>{var A;return(A=k==null?void 0:k.mightContain(C))!==null&&A!==void 0&&A}}),de}(c,e.ge,this.ke.it(),h,f))}}}}tt(e){let t=e.ge.unchangedNames;if(!t||!t.bits)return null;let{bits:{bitmap:n="",padding:s=0},hashCount:a=0}=t,c,h;try{c=Dn(n).toUint8Array()}catch(f){if(f instanceof uh)return Vo("Decoding the base64 bloom filter in existence filter failed ("+f.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw f}try{h=new Gp(c,s,a)}catch(f){return Vo(f instanceof as?"BloomFilter error: ":"Applying bloom filter failed: ",f),null}return h.Ee===0?null:h}nt(e,t,n){return t.ge.count===n-this.st(e,t.targetId)?0:2}st(e,t){let n=this.ke.getRemoteKeysForTarget(t),s=0;return n.forEach(a=>{let c=this.ke.it(),h=`projects/${c.projectId}/databases/${c.database}/documents/${a.path.canonicalString()}`;e.mightContain(h)||(this.ze(t,a,null),s++)}),s}ot(e){let t=new Map;this.qe.forEach((a,c)=>{let h=this.Xe(c);if(h){if(a.current&&Mp(h.target)){let f=new ce(h.target.path);this._t(f).has(c)||this.ut(c,f)||this.ze(c,f,Sr.newNoDocument(f,e))}a.ve&&(t.set(c,a.Fe()),a.Me())}});let n=xe();this.Ke.forEach((a,c)=>{let h=!0;c.forEachWhile(f=>{let m=this.Xe(f);return!m||m.purpose==="TargetPurposeLimboResolution"||(h=!1,!1)}),h&&(n=n.add(a))}),this.Qe.forEach((a,c)=>c.setReadTime(e));let s=new dh(e,t,this.Ue,this.Qe,n);return this.Qe=kn(),this.$e=Xl(),this.Ke=Xl(),this.Ue=new Ye(Re),s}Ge(e,t){if(!this.Je(e))return;let n=this.ut(e,t.key)?2:0;this.He(e).xe(t.key,n),this.Qe=this.Qe.insert(t.key,t),this.$e=this.$e.insert(t.key,this._t(t.key).add(e)),this.Ke=this.Ke.insert(t.key,this.ct(t.key).add(e))}ze(e,t,n){if(!this.Je(e))return;let s=this.He(e);this.ut(e,t)?s.xe(t,1):s.Oe(t),this.Ke=this.Ke.insert(t,this.ct(t).delete(e)),this.Ke=this.Ke.insert(t,this.ct(t).add(e)),n&&(this.Qe=this.Qe.insert(t,n))}removeTarget(e){this.qe.delete(e)}et(e){let t=this.He(e).Fe();return this.ke.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}Ne(e){this.He(e).Ne()}He(e){let t=this.qe.get(e);return t||(t=new gh,this.qe.set(e,t)),t}ct(e){let t=this.Ke.get(e);return t||(t=new yt(Re),this.Ke=this.Ke.insert(e,t)),t}_t(e){let t=this.$e.get(e);return t||(t=new yt(Re),this.$e=this.$e.insert(e,t)),t}Je(e){let t=this.Xe(e)!==null;return t||X("WatchChangeAggregator","Detected inactive target",e),t}Xe(e){let t=this.qe.get(e);return t&&t.De?null:this.ke.lt(e)}Ye(e){this.qe.set(e,new gh),this.ke.getRemoteKeysForTarget(e).forEach(t=>{this.ze(e,t,null)})}ut(e,t){return this.ke.getRemoteKeysForTarget(e).has(t)}};function Xl(){return new Ye(ce.comparator)}function mb(){return new Ye(ce.comparator)}var vM={asc:"ASCENDING",desc:"DESCENDING"},wM={"<":"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"},bM={and:"AND",or:"OR"},Wp=class{constructor(e,t){this.databaseId=e,this.useProto3Json=t}};function Hp(r,e){return r.useProto3Json||jh(e)?e:{value:e}}function _h(r,e){return r.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function bT(r,e){return r.useProto3Json?e.toBase64():e.toUint8Array()}function TM(r,e){return _h(r,e.toTimestamp())}function Hr(r){return Le(!!r),me.fromTimestamp(function(t){let n=Cn(t);return new wt(n.seconds,n.nanos)}(r))}function ag(r,e){return Qp(r,e).canonicalString()}function Qp(r,e){let t=function(s){return new ot(["projects",s.projectId,"databases",s.database])}(r).child("documents");return e===void 0?t:t.child(e)}function TT(r){let e=ot.fromString(r);return Le(ST(e)),e}function Jp(r,e){return ag(r.databaseId,e.path)}function dp(r,e){let t=TT(e);if(t.get(1)!==r.databaseId.projectId)throw new ne(H.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+r.databaseId.projectId);if(t.get(3)!==r.databaseId.database)throw new ne(H.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+r.databaseId.database);return new ce(IT(t))}function ET(r,e){return ag(r.databaseId,e)}function EM(r){let e=TT(r);return e.length===4?ot.emptyPath():IT(e)}function Yp(r){return new ot(["projects",r.databaseId.projectId,"databases",r.databaseId.database]).canonicalString()}function IT(r){return Le(r.length>4&&r.get(4)==="documents"),r.popFirst(5)}function gb(r,e,t){return{name:Jp(r,e),fields:t.value.mapValue.fields}}function IM(r,e){let t;if("targetChange"in e){e.targetChange;let n=function(m){return m==="NO_CHANGE"?0:m==="ADD"?1:m==="REMOVE"?2:m==="CURRENT"?3:m==="RESET"?4:ue()}(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],a=function(m,_){return m.useProto3Json?(Le(_===void 0||typeof _=="string"),Rt.fromBase64String(_||"")):(Le(_===void 0||_ instanceof Buffer||_ instanceof Uint8Array),Rt.fromUint8Array(_||new Uint8Array))}(r,e.targetChange.resumeToken),c=e.targetChange.cause,h=c&&function(m){let _=m.code===void 0?H.UNKNOWN:wT(m.code);return new ne(_,m.message||"")}(c);t=new mh(n,s,a,h||null)}else if("documentChange"in e){e.documentChange;let n=e.documentChange;n.document,n.document.name,n.document.updateTime;let s=dp(r,n.document.name),a=Hr(n.document.updateTime),c=n.document.createTime?Hr(n.document.createTime):me.min(),h=new er({mapValue:{fields:n.document.fields}}),f=Sr.newFoundDocument(s,a,c,h),m=n.targetIds||[],_=n.removedTargetIds||[];t=new ko(m,_,f.key,f)}else if("documentDelete"in e){e.documentDelete;let n=e.documentDelete;n.document;let s=dp(r,n.document),a=n.readTime?Hr(n.readTime):me.min(),c=Sr.newNoDocument(s,a),h=n.removedTargetIds||[];t=new ko([],h,c.key,c)}else if("documentRemove"in e){e.documentRemove;let n=e.documentRemove;n.document;let s=dp(r,n.document),a=n.removedTargetIds||[];t=new ko([],a,s,null)}else{if(!("filter"in e))return ue();{e.filter;let n=e.filter;n.targetId;let{count:s=0,unchangedNames:a}=n,c=new zp(s,a),h=n.targetId;t=new ph(h,c)}}return t}function xM(r,e){let t;if(e instanceof ds)t={update:gb(r,e.key,e.value)};else if(e instanceof fh)t={delete:Jp(r,e.key)};else if(e instanceof Xr)t={update:gb(r,e.key,e.data),updateMask:NM(e.fieldMask)};else{if(!(e instanceof Bp))return ue();t={verify:Jp(r,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map(n=>function(a,c){let h=c.transform;if(h instanceof Go)return{fieldPath:c.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(h instanceof hs)return{fieldPath:c.field.canonicalString(),appendMissingElements:{values:h.elements}};if(h instanceof fs)return{fieldPath:c.field.canonicalString(),removeAllFromArray:{values:h.elements}};if(h instanceof Ko)return{fieldPath:c.field.canonicalString(),increment:h.Ie};throw ue()}(0,n))),e.precondition.isNone||(t.currentDocument=function(s,a){return a.updateTime!==void 0?{updateTime:TM(s,a.updateTime)}:a.exists!==void 0?{exists:a.exists}:ue()}(r,e.precondition)),t}function AM(r,e){return r&&r.length>0?(Le(e!==void 0),r.map(t=>function(s,a){let c=s.updateTime?Hr(s.updateTime):Hr(a);return c.isEqual(me.min())&&(c=Hr(a)),new Up(c,s.transformResults||[])}(t,e))):[]}function SM(r,e){return{documents:[ET(r,e.path)]}}function RM(r,e){let t={structuredQuery:{}},n=e.path,s;e.collectionGroup!==null?(s=n,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(s=n.popLast(),t.structuredQuery.from=[{collectionId:n.lastSegment()}]),t.parent=ET(r,s);let a=function(m){if(m.length!==0)return AT(Yr.create(m,"and"))}(e.filters);a&&(t.structuredQuery.where=a);let c=function(m){if(m.length!==0)return m.map(_=>function(I){return{field:Co(I.field),direction:DM(I.dir)}}(_))}(e.orderBy);c&&(t.structuredQuery.orderBy=c);let h=Hp(r,e.limit);return h!==null&&(t.structuredQuery.limit=h),e.startAt&&(t.structuredQuery.startAt=function(m){return{before:m.inclusive,values:m.position}}(e.startAt)),e.endAt&&(t.structuredQuery.endAt=function(m){return{before:!m.inclusive,values:m.position}}(e.endAt)),{ht:t,parent:s}}function PM(r){let e=EM(r.parent),t=r.structuredQuery,n=t.from?t.from.length:0,s=null;if(n>0){Le(n===1);let _=t.from[0];_.allDescendants?s=_.collectionId:e=e.child(_.collectionId)}let a=[];t.where&&(a=function(E){let I=xT(E);return I instanceof Yr&&iT(I)?I.getFilters():[I]}(t.where));let c=[];t.orderBy&&(c=function(E){return E.map(I=>function(B){return new $o(Do(B.field),function(j){switch(j){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(B.direction))}(I))}(t.orderBy));let h=null;t.limit&&(h=function(E){let I;return I=typeof E=="object"?E.value:E,jh(I)?null:I}(t.limit));let f=null;t.startAt&&(f=function(E){let I=!!E.before,k=E.values||[];return new jo(k,I)}(t.startAt));let m=null;return t.endAt&&(m=function(E){let I=!E.before,k=E.values||[];return new jo(k,I)}(t.endAt)),eM(e,s,c,a,h,"F",f,m)}function CM(r,e){let t=function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return ue()}}(e.purpose);return t==null?null:{"goog-listen-tags":t}}function xT(r){return r.unaryFilter!==void 0?function(t){switch(t.unaryFilter.op){case"IS_NAN":let n=Do(t.unaryFilter.field);return pt.create(n,"==",{doubleValue:NaN});case"IS_NULL":let s=Do(t.unaryFilter.field);return pt.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":let a=Do(t.unaryFilter.field);return pt.create(a,"!=",{doubleValue:NaN});case"IS_NOT_NULL":let c=Do(t.unaryFilter.field);return pt.create(c,"!=",{nullValue:"NULL_VALUE"});default:return ue()}}(r):r.fieldFilter!==void 0?function(t){return pt.create(Do(t.fieldFilter.field),function(s){switch(s){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return ue()}}(t.fieldFilter.op),t.fieldFilter.value)}(r):r.compositeFilter!==void 0?function(t){return Yr.create(t.compositeFilter.filters.map(n=>xT(n)),function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return ue()}}(t.compositeFilter.op))}(r):ue()}function DM(r){return vM[r]}function OM(r){return wM[r]}function kM(r){return bM[r]}function Co(r){return{fieldPath:r.canonicalString()}}function Do(r){return tr.fromServerFormat(r.fieldPath)}function AT(r){return r instanceof pt?function(t){if(t.op==="=="){if(nb(t.value))return{unaryFilter:{field:Co(t.field),op:"IS_NAN"}};if(rb(t.value))return{unaryFilter:{field:Co(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(nb(t.value))return{unaryFilter:{field:Co(t.field),op:"IS_NOT_NAN"}};if(rb(t.value))return{unaryFilter:{field:Co(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Co(t.field),op:OM(t.op),value:t.value}}}(r):r instanceof Yr?function(t){let n=t.getFilters().map(s=>AT(s));return n.length===1?n[0]:{compositeFilter:{op:kM(t.op),filters:n}}}(r):ue()}function NM(r){let e=[];return r.fields.forEach(t=>e.push(t.canonicalString())),{fieldPaths:e}}function ST(r){return r.length>=4&&r.get(0)==="projects"&&r.get(2)==="databases"}var wu=class r{constructor(e,t,n,s,a=me.min(),c=me.min(),h=Rt.EMPTY_BYTE_STRING,f=null){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=s,this.snapshotVersion=a,this.lastLimboFreeSnapshotVersion=c,this.resumeToken=h,this.expectedCount=f}withSequenceNumber(e){return new r(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new r(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new r(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new r(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}};var Xp=class{constructor(e){this.Tt=e}};function VM(r){let e=PM({parent:r.parent,structuredQuery:r.structuredQuery});return r.limitType==="LAST"?Fp(e,e.limit,"L"):e}var yh=class{constructor(){}At(e,t){this.Rt(e,t),t.Vt()}Rt(e,t){if("nullValue"in e)this.ft(t,5);else if("booleanValue"in e)this.ft(t,10),t.gt(e.booleanValue?1:0);else if("integerValue"in e)this.ft(t,15),t.gt(Ge(e.integerValue));else if("doubleValue"in e){let n=Ge(e.doubleValue);isNaN(n)?this.ft(t,13):(this.ft(t,15),gu(n)?t.gt(0):t.gt(n))}else if("timestampValue"in e){let n=e.timestampValue;this.ft(t,20),typeof n=="string"&&(n=Cn(n)),t.yt(`${n.seconds||""}`),t.gt(n.nanos||0)}else if("stringValue"in e)this.wt(e.stringValue,t),this.St(t);else if("bytesValue"in e)this.ft(t,30),t.bt(Dn(e.bytesValue)),this.St(t);else if("referenceValue"in e)this.Dt(e.referenceValue,t);else if("geoPointValue"in e){let n=e.geoPointValue;this.ft(t,45),t.gt(n.latitude||0),t.gt(n.longitude||0)}else"mapValue"in e?tT(e)?this.ft(t,Number.MAX_SAFE_INTEGER):eT(e)?this.vt(e.mapValue,t):(this.Ct(e.mapValue,t),this.St(t)):"arrayValue"in e?(this.Ft(e.arrayValue,t),this.St(t)):ue()}wt(e,t){this.ft(t,25),this.Mt(e,t)}Mt(e,t){t.yt(e)}Ct(e,t){let n=e.fields||{};this.ft(t,55);for(let s of Object.keys(n))this.wt(s,t),this.Rt(n[s],t)}vt(e,t){var n,s;let a=e.fields||{};this.ft(t,53);let c=Fo,h=((s=(n=a[c].arrayValue)===null||n===void 0?void 0:n.values)===null||s===void 0?void 0:s.length)||0;this.ft(t,15),t.gt(Ge(h)),this.wt(c,t),this.Rt(a[c],t)}Ft(e,t){let n=e.values||[];this.ft(t,50);for(let s of n)this.Rt(s,t)}Dt(e,t){this.ft(t,37),ce.fromName(e).path.forEach(n=>{this.ft(t,60),this.Mt(n,t)})}ft(e,t){e.gt(t)}St(e){e.gt(2)}};yh.xt=new yh;var Zp=class{constructor(){this.Tn=new em}addToCollectionParentIndex(e,t){return this.Tn.add(t),W.resolve()}getCollectionParents(e,t){return W.resolve(this.Tn.getEntries(t))}addFieldIndex(e,t){return W.resolve()}deleteFieldIndex(e,t){return W.resolve()}deleteAllFieldIndexes(e){return W.resolve()}createTargetIndexes(e,t){return W.resolve()}getDocumentsMatchingTarget(e,t){return W.resolve(null)}getIndexType(e,t){return W.resolve(0)}getFieldIndexes(e,t){return W.resolve([])}getNextCollectionGroupToUpdate(e){return W.resolve(null)}getMinOffset(e,t){return W.resolve(ls.min())}getMinOffsetFromCollectionGroup(e,t){return W.resolve(ls.min())}updateCollectionGroup(e,t,n){return W.resolve()}updateIndexEntries(e,t){return W.resolve()}},em=class{constructor(){this.index={}}add(e){let t=e.lastSegment(),n=e.popLast(),s=this.index[t]||new yt(ot.comparator),a=!s.has(n);return this.index[t]=s.add(n),a}has(e){let t=e.lastSegment(),n=e.popLast(),s=this.index[t];return s&&s.has(n)}getEntries(e){return(this.index[e]||new yt(ot.comparator)).toArray()}};var wK=new Uint8Array(0);var _b={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},RT=41943040,lr=class r{static withCacheSize(e){return new r(e,r.DEFAULT_COLLECTION_PERCENTILE,r.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}};lr.DEFAULT_COLLECTION_PERCENTILE=10,lr.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,lr.DEFAULT=new lr(RT,lr.DEFAULT_COLLECTION_PERCENTILE,lr.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),lr.DISABLED=new lr(-1,0,0);var bu=class r{constructor(e){this.$n=e}next(){return this.$n+=2,this.$n}static Kn(){return new r(0)}static Un(){return new r(-1)}};var yb="LruGarbageCollector",LM=1048576;function vb([r,e],[t,n]){let s=Re(r,t);return s===0?Re(e,n):s}var tm=class{constructor(e){this.Hn=e,this.buffer=new yt(vb),this.Jn=0}Yn(){return++this.Jn}Zn(e){let t=[e,this.Yn()];if(this.buffer.size<this.Hn)this.buffer=this.buffer.add(t);else{let n=this.buffer.last();vb(t,n)<0&&(this.buffer=this.buffer.delete(n).add(t))}}get maxValue(){return this.buffer.last()[0]}},rm=class{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,this.localStore=n,this.Xn=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.er(6e4)}stop(){this.Xn&&(this.Xn.cancel(),this.Xn=null)}get started(){return this.Xn!==null}er(e){X(yb,`Garbage collection scheduled in ${e}ms`),this.Xn=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Xn=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){Zo(t)?X(yb,"Ignoring IndexedDB error during garbage collection: ",t):await Xo(t)}await this.er(3e5)})}},nm=class{constructor(e,t){this.tr=e,this.params=t}calculateTargetCount(e,t){return this.tr.nr(e).next(n=>Math.floor(t/100*n))}nthSequenceNumber(e,t){if(t===0)return W.resolve(Mo.ae);let n=new tm(t);return this.tr.forEachTarget(e,s=>n.Zn(s.sequenceNumber)).next(()=>this.tr.rr(e,s=>n.Zn(s))).next(()=>n.maxValue)}removeTargets(e,t,n){return this.tr.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.tr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(X("LruGarbageCollector","Garbage collection skipped; disabled"),W.resolve(_b)):this.getCacheSize(e).next(n=>n<this.params.cacheSizeCollectionThreshold?(X("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),_b):this.ir(e,t))}getCacheSize(e){return this.tr.getCacheSize(e)}ir(e,t){let n,s,a,c,h,f,m,_=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(E=>(E>this.params.maximumSequenceNumbersToCollect?(X("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${E}`),s=this.params.maximumSequenceNumbersToCollect):s=E,c=Date.now(),this.nthSequenceNumber(e,s))).next(E=>(n=E,h=Date.now(),this.removeTargets(e,n,t))).next(E=>(a=E,f=Date.now(),this.removeOrphanedDocuments(e,n))).next(E=>(m=Date.now(),Ro()<=Se.DEBUG&&X("LruGarbageCollector",`LRU Garbage Collection
|
|
32
32
|
Counted targets in ${c-_}ms
|
|
33
33
|
Determined least recently used ${s} in `+(h-c)+`ms
|
|
34
34
|
Removed ${a} targets in `+(f-h)+`ms
|
|
35
35
|
Removed ${E} documents in `+(m-f)+`ms
|
|
36
|
-
Total Duration: ${m-_}ms`),W.resolve({didRun:!0,sequenceNumbersCollected:s,targetsRemoved:a,documentsRemoved:E})))}};function MM(r,e){return new nm(r,e)}var im=class{constructor(){this.changes=new On(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,Sr.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let n=this.changes.get(t);return n!==void 0?W.resolve(n):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}};var sm=class{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}};var om=class{constructor(e,t,n,s){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=n,this.indexManager=s}getDocument(e,t){let n=null;return this.documentOverlayCache.getOverlay(e,t).next(s=>(n=s,this.remoteDocumentCache.getEntry(e,t))).next(s=>(n!==null&&pu(n.mutation,s,hr.empty(),wt.now()),s))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(n=>this.getLocalViewOfDocuments(e,n,xe()).next(()=>n))}getLocalViewOfDocuments(e,t,n=xe()){let s=os();return this.populateOverlays(e,s,t).next(()=>this.computeViews(e,t,s,n).next(a=>{let c=lu();return a.forEach((h,f)=>{c=c.insert(h,f.overlayedDocument)}),c}))}getOverlayedDocuments(e,t){let n=os();return this.populateOverlays(e,n,t).next(()=>this.computeViews(e,t,n,xe()))}populateOverlays(e,t,n){let s=[];return n.forEach(a=>{t.has(a)||s.push(a)}),this.documentOverlayCache.getOverlays(e,s).next(a=>{a.forEach((c,h)=>{t.set(c,h)})})}computeViews(e,t,n,s){let a=kn(),c=du(),h=function(){return du()}();return t.forEach((f,m)=>{let _=n.get(m.key);s.has(m.key)&&(_===void 0||_.mutation instanceof Xr)?a=a.insert(m.key,m):_!==void 0?(c.set(m.key,_.mutation.getFieldMask()),pu(_.mutation,m,_.mutation.getFieldMask(),wt.now())):c.set(m.key,hr.empty())}),this.recalculateAndSaveOverlays(e,a).next(f=>(f.forEach((m,_)=>c.set(m,_)),t.forEach((m,_)=>{var E;return h.set(m,new sm(_,(E=c.get(m))!==null&&E!==void 0?E:null))}),h))}recalculateAndSaveOverlays(e,t){let n=du(),s=new Ye((c,h)=>c-h),a=xe();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(c=>{for(let h of c)h.keys().forEach(f=>{let m=t.get(f);if(m===null)return;let _=n.get(f)||hr.empty();_=h.applyToLocalView(m,_),n.set(f,_);let E=(s.get(h.batchId)||xe()).add(f);s=s.insert(h.batchId,E)})}).next(()=>{let c=[],h=s.getReverseIterator();for(;h.hasNext();){let f=h.getNext(),m=f.key,_=f.value,E=hT();_.forEach(I=>{if(!a.has(I)){let k=_T(t.get(I),n.get(I));k!==null&&E.set(I,k),a=a.add(I)}}),c.push(this.documentOverlayCache.saveOverlays(e,m,E))}return W.waitFor(c)}).next(()=>n)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(n=>this.recalculateAndSaveOverlays(e,n))}getDocumentsMatchingQuery(e,t,n,s){return function(c){return ce.isDocumentKey(c.path)&&c.collectionGroup===null&&c.filters.length===0}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):tM(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n,s):this.getDocumentsMatchingCollectionQuery(e,t,n,s)}getNextDocuments(e,t,n,s){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,s).next(a=>{let c=s-a.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,s-a.size):W.resolve(os()),h=mu,f=a;return c.next(m=>W.forEach(m,(_,E)=>(h<E.largestBatchId&&(h=E.largestBatchId),a.get(_)?W.resolve():this.remoteDocumentCache.getEntry(e,_).next(I=>{f=f.insert(_,I)}))).next(()=>this.populateOverlays(e,m,a)).next(()=>this.computeViews(e,f,m,xe())).next(_=>({batchId:h,changes:lT(_)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new ce(t)).next(n=>{let s=lu();return n.isFoundDocument()&&(s=s.insert(n.key,n)),s})}getDocumentsMatchingCollectionGroupQuery(e,t,n,s){let a=t.collectionGroup,c=lu();return this.indexManager.getCollectionParents(e,a).next(h=>W.forEach(h,f=>{let m=function(E,I){return new qo(I,null,E.explicitOrderBy.slice(),E.filters.slice(),E.limit,E.limitType,E.startAt,E.endAt)}(t,f.child(a));return this.getDocumentsMatchingCollectionQuery(e,m,n,s).next(_=>{_.forEach((E,I)=>{c=c.insert(E,I)})})}).next(()=>c))}getDocumentsMatchingCollectionQuery(e,t,n,s){let a;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next(c=>(a=c,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,a,s))).next(c=>{a.forEach((f,m)=>{let _=m.getKey();c.get(_)===null&&(c=c.insert(_,Sr.newInvalidDocument(_)))});let h=lu();return c.forEach((f,m)=>{let _=a.get(f);_!==void 0&&pu(_.mutation,m,hr.empty(),wt.now()),Gh(t,m)&&(h=h.insert(f,m))}),h})}};var am=class{constructor(e){this.serializer=e,this.dr=new Map,this.Ar=new Map}getBundleMetadata(e,t){return W.resolve(this.dr.get(t))}saveBundleMetadata(e,t){return this.dr.set(t.id,function(s){return{id:s.id,version:s.version,createTime:Hr(s.createTime)}}(t)),W.resolve()}getNamedQuery(e,t){return W.resolve(this.Ar.get(t))}saveNamedQuery(e,t){return this.Ar.set(t.name,function(s){return{name:s.name,query:VM(s.bundledQuery),readTime:Hr(s.readTime)}}(t)),W.resolve()}};var um=class{constructor(){this.overlays=new Ye(ce.comparator),this.Rr=new Map}getOverlay(e,t){return W.resolve(this.overlays.get(t))}getOverlays(e,t){let n=os();return W.forEach(t,s=>this.getOverlay(e,s).next(a=>{a!==null&&n.set(s,a)})).next(()=>n)}saveOverlays(e,t,n){return n.forEach((s,a)=>{this.Et(e,t,a)}),W.resolve()}removeOverlaysForBatchId(e,t,n){let s=this.Rr.get(n);return s!==void 0&&(s.forEach(a=>this.overlays=this.overlays.remove(a)),this.Rr.delete(n)),W.resolve()}getOverlaysForCollection(e,t,n){let s=os(),a=t.length+1,c=new ce(t.child("")),h=this.overlays.getIteratorFrom(c);for(;h.hasNext();){let f=h.getNext().value,m=f.getKey();if(!t.isPrefixOf(m.path))break;m.path.length===a&&f.largestBatchId>n&&s.set(f.getKey(),f)}return W.resolve(s)}getOverlaysForCollectionGroup(e,t,n,s){let a=new Ye((m,_)=>m-_),c=this.overlays.getIterator();for(;c.hasNext();){let m=c.getNext().value;if(m.getKey().getCollectionGroup()===t&&m.largestBatchId>n){let _=a.get(m.largestBatchId);_===null&&(_=os(),a=a.insert(m.largestBatchId,_)),_.set(m.getKey(),m)}}let h=os(),f=a.getIterator();for(;f.hasNext()&&(f.getNext().value.forEach((m,_)=>h.set(m,_)),!(h.size()>=s)););return W.resolve(h)}Et(e,t,n){let s=this.overlays.get(n.key);if(s!==null){let c=this.Rr.get(s.largestBatchId).delete(n.key);this.Rr.set(s.largestBatchId,c)}this.overlays=this.overlays.insert(n.key,new qp(t,n));let a=this.Rr.get(t);a===void 0&&(a=xe(),this.Rr.set(t,a)),this.Rr.set(t,a.add(n.key))}};var cm=class{constructor(){this.sessionToken=Rt.EMPTY_BYTE_STRING}getSessionToken(e){return W.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,W.resolve()}};var Tu=class{constructor(){this.Vr=new yt(st.mr),this.gr=new yt(st.pr)}isEmpty(){return this.Vr.isEmpty()}addReference(e,t){let n=new st(e,t);this.Vr=this.Vr.add(n),this.gr=this.gr.add(n)}yr(e,t){e.forEach(n=>this.addReference(n,t))}removeReference(e,t){this.wr(new st(e,t))}Sr(e,t){e.forEach(n=>this.removeReference(n,t))}br(e){let t=new ce(new ot([])),n=new st(t,e),s=new st(t,e+1),a=[];return this.gr.forEachInRange([n,s],c=>{this.wr(c),a.push(c.key)}),a}Dr(){this.Vr.forEach(e=>this.wr(e))}wr(e){this.Vr=this.Vr.delete(e),this.gr=this.gr.delete(e)}vr(e){let t=new ce(new ot([])),n=new st(t,e),s=new st(t,e+1),a=xe();return this.gr.forEachInRange([n,s],c=>{a=a.add(c.key)}),a}containsKey(e){let t=new st(e,0),n=this.Vr.firstAfterOrEqual(t);return n!==null&&e.isEqual(n.key)}},st=class{constructor(e,t){this.key=e,this.Cr=t}static mr(e,t){return ce.comparator(e.key,t.key)||Re(e.Cr,t.Cr)}static pr(e,t){return Re(e.Cr,t.Cr)||ce.comparator(e.key,t.key)}};var lm=class{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Fr=1,this.Mr=new yt(st.mr)}checkEmpty(e){return W.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,n,s){let a=this.Fr;this.Fr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let c=new jp(a,t,n,s);this.mutationQueue.push(c);for(let h of s)this.Mr=this.Mr.add(new st(h.key,a)),this.indexManager.addToCollectionParentIndex(e,h.key.path.popLast());return W.resolve(c)}lookupMutationBatch(e,t){return W.resolve(this.Or(t))}getNextMutationBatchAfterBatchId(e,t){let n=t+1,s=this.Nr(n),a=s<0?0:s;return W.resolve(this.mutationQueue.length>a?this.mutationQueue[a]:null)}getHighestUnacknowledgedBatchId(){return W.resolve(this.mutationQueue.length===0?Zm:this.Fr-1)}getAllMutationBatches(e){return W.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let n=new st(t,0),s=new st(t,Number.POSITIVE_INFINITY),a=[];return this.Mr.forEachInRange([n,s],c=>{let h=this.Or(c.Cr);a.push(h)}),W.resolve(a)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new yt(Re);return t.forEach(s=>{let a=new st(s,0),c=new st(s,Number.POSITIVE_INFINITY);this.Mr.forEachInRange([a,c],h=>{n=n.add(h.Cr)})}),W.resolve(this.Br(n))}getAllMutationBatchesAffectingQuery(e,t){let n=t.path,s=n.length+1,a=n;ce.isDocumentKey(a)||(a=a.child(""));let c=new st(new ce(a),0),h=new yt(Re);return this.Mr.forEachWhile(f=>{let m=f.key.path;return!!n.isPrefixOf(m)&&(m.length===s&&(h=h.add(f.Cr)),!0)},c),W.resolve(this.Br(h))}Br(e){let t=[];return e.forEach(n=>{let s=this.Or(n);s!==null&&t.push(s)}),t}removeMutationBatch(e,t){Le(this.Lr(t.batchId,"removed")===0),this.mutationQueue.shift();let n=this.Mr;return W.forEach(t.mutations,s=>{let a=new st(s.key,t.batchId);return n=n.delete(a),this.referenceDelegate.markPotentiallyOrphaned(e,s.key)}).next(()=>{this.Mr=n})}qn(e){}containsKey(e,t){let n=new st(t,0),s=this.Mr.firstAfterOrEqual(n);return W.resolve(t.isEqual(s&&s.key))}performConsistencyCheck(e){return this.mutationQueue.length,W.resolve()}Lr(e,t){return this.Nr(e)}Nr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Or(e){let t=this.Nr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}};var hm=class{constructor(e){this.kr=e,this.docs=function(){return new Ye(ce.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){let n=t.key,s=this.docs.get(n),a=s?s.size:0,c=this.kr(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:c}),this.size+=c-a,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}removeEntry(e){let t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){let n=this.docs.get(t);return W.resolve(n?n.document.mutableCopy():Sr.newInvalidDocument(t))}getEntries(e,t){let n=kn();return t.forEach(s=>{let a=this.docs.get(s);n=n.insert(s,a?a.document.mutableCopy():Sr.newInvalidDocument(s))}),W.resolve(n)}getDocumentsMatchingQuery(e,t,n,s){let a=kn(),c=t.path,h=new ce(c.child("__id-9223372036854775808__")),f=this.docs.getIteratorFrom(h);for(;f.hasNext();){let{key:m,value:{document:_}}=f.getNext();if(!c.isPrefixOf(m.path))break;m.path.length>c.length+1||V2(N2(_),n)<=0||(s.has(_.key)||Gh(t,_))&&(a=a.insert(_.key,_.mutableCopy()))}return W.resolve(a)}getAllFromCollectionGroup(e,t,n,s){ue()}qr(e,t){return W.forEach(this.docs,n=>t(n))}newChangeBuffer(e){return new fm(this)}getSize(e){return W.resolve(this.size)}},fm=class extends im{constructor(e){super(),this.Ir=e}applyChanges(e){let t=[];return this.changes.forEach((n,s)=>{s.isValidDocument()?t.push(this.Ir.addEntry(e,s)):this.Ir.removeEntry(n)}),W.waitFor(t)}getFromCache(e,t){return this.Ir.getEntry(e,t)}getAllFromCache(e,t){return this.Ir.getEntries(e,t)}};var dm=class{constructor(e){this.persistence=e,this.Qr=new On(t=>ig(t),sg),this.lastRemoteSnapshotVersion=me.min(),this.highestTargetId=0,this.$r=0,this.Kr=new Tu,this.targetCount=0,this.Ur=bu.Kn()}forEachTarget(e,t){return this.Qr.forEach((n,s)=>t(s)),W.resolve()}getLastRemoteSnapshotVersion(e){return W.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return W.resolve(this.$r)}allocateTargetId(e){return this.highestTargetId=this.Ur.next(),W.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.$r&&(this.$r=t),W.resolve()}zn(e){this.Qr.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.Ur=new bu(t),this.highestTargetId=t),e.sequenceNumber>this.$r&&(this.$r=e.sequenceNumber)}addTargetData(e,t){return this.zn(t),this.targetCount+=1,W.resolve()}updateTargetData(e,t){return this.zn(t),W.resolve()}removeTargetData(e,t){return this.Qr.delete(t.target),this.Kr.br(t.targetId),this.targetCount-=1,W.resolve()}removeTargets(e,t,n){let s=0,a=[];return this.Qr.forEach((c,h)=>{h.sequenceNumber<=t&&n.get(h.targetId)===null&&(this.Qr.delete(c),a.push(this.removeMatchingKeysForTargetId(e,h.targetId)),s++)}),W.waitFor(a).next(()=>s)}getTargetCount(e){return W.resolve(this.targetCount)}getTargetData(e,t){let n=this.Qr.get(t)||null;return W.resolve(n)}addMatchingKeys(e,t,n){return this.Kr.yr(t,n),W.resolve()}removeMatchingKeys(e,t,n){this.Kr.Sr(t,n);let s=this.persistence.referenceDelegate,a=[];return s&&t.forEach(c=>{a.push(s.markPotentiallyOrphaned(e,c))}),W.waitFor(a)}removeMatchingKeysForTargetId(e,t){return this.Kr.br(t),W.resolve()}getMatchingKeysForTargetId(e,t){let n=this.Kr.vr(t);return W.resolve(n)}containsKey(e,t){return W.resolve(this.Kr.containsKey(t))}};var vh=class{constructor(e,t){this.Wr={},this.overlays={},this.Gr=new Mo(0),this.zr=!1,this.zr=!0,this.jr=new cm,this.referenceDelegate=e(this),this.Hr=new dm(this),this.indexManager=new Zp,this.remoteDocumentCache=function(s){return new hm(s)}(n=>this.referenceDelegate.Jr(n)),this.serializer=new Xp(t),this.Yr=new am(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.zr=!1,Promise.resolve()}get started(){return this.zr}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new um,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.Wr[e.toKey()];return n||(n=new lm(t,this.referenceDelegate),this.Wr[e.toKey()]=n),n}getGlobalsCache(){return this.jr}getTargetCache(){return this.Hr}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Yr}runTransaction(e,t,n){X("MemoryPersistence","Starting transaction:",e);let s=new pm(this.Gr.next());return this.referenceDelegate.Zr(),n(s).next(a=>this.referenceDelegate.Xr(s).next(()=>a)).toPromise().then(a=>(s.raiseOnCommittedEvent(),a))}ei(e,t){return W.or(Object.values(this.Wr).map(n=>()=>n.containsKey(e,t)))}},pm=class extends Ip{constructor(e){super(),this.currentSequenceNumber=e}},mm=class r{constructor(e){this.persistence=e,this.ti=new Tu,this.ni=null}static ri(e){return new r(e)}get ii(){if(this.ni)return this.ni;throw ue()}addReference(e,t,n){return this.ti.addReference(n,t),this.ii.delete(n.toString()),W.resolve()}removeReference(e,t,n){return this.ti.removeReference(n,t),this.ii.add(n.toString()),W.resolve()}markPotentiallyOrphaned(e,t){return this.ii.add(t.toString()),W.resolve()}removeTarget(e,t){this.ti.br(t.targetId).forEach(s=>this.ii.add(s.toString()));let n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next(s=>{s.forEach(a=>this.ii.add(a.toString()))}).next(()=>n.removeTargetData(e,t))}Zr(){this.ni=new Set}Xr(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return W.forEach(this.ii,n=>{let s=ce.fromPath(n);return this.si(e,s).next(a=>{a||t.removeEntry(s,me.min())})}).next(()=>(this.ni=null,t.apply(e)))}updateLimboDocument(e,t){return this.si(e,t).next(n=>{n?this.ii.delete(t.toString()):this.ii.add(t.toString())})}Jr(e){return 0}si(e,t){return W.or([()=>W.resolve(this.ti.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.ei(e,t)])}},wh=class r{constructor(e,t){this.persistence=e,this.oi=new On(n=>U2(n.path),(n,s)=>n.isEqual(s)),this.garbageCollector=MM(this,t)}static ri(e,t){return new r(e,t)}Zr(){}Xr(e){return W.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}nr(e){let t=this.sr(e);return this.persistence.getTargetCache().getTargetCount(e).next(n=>t.next(s=>n+s))}sr(e){let t=0;return this.rr(e,n=>{t++}).next(()=>t)}rr(e,t){return W.forEach(this.oi,(n,s)=>this.ar(e,n,s).next(a=>a?W.resolve():t(s)))}removeTargets(e,t,n){return this.persistence.getTargetCache().removeTargets(e,t,n)}removeOrphanedDocuments(e,t){let n=0,s=this.persistence.getRemoteDocumentCache(),a=s.newChangeBuffer();return s.qr(e,c=>this.ar(e,c,t).next(h=>{h||(n++,a.removeEntry(c,me.min()))})).next(()=>a.apply(e)).next(()=>n)}markPotentiallyOrphaned(e,t){return this.oi.set(t,e.currentSequenceNumber),W.resolve()}removeTarget(e,t){let n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}addReference(e,t,n){return this.oi.set(n,e.currentSequenceNumber),W.resolve()}removeReference(e,t,n){return this.oi.set(n,e.currentSequenceNumber),W.resolve()}updateLimboDocument(e,t){return this.oi.set(t,e.currentSequenceNumber),W.resolve()}Jr(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=eh(e.data.value)),t}ar(e,t,n){return W.or([()=>this.persistence.ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let s=this.oi.get(t);return W.resolve(s!==void 0&&s>n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}};var gm=class r{constructor(e,t,n,s){this.targetId=e,this.fromCache=t,this.Hi=n,this.Ji=s}static Yi(e,t){let n=xe(),s=xe();for(let a of t.docChanges)switch(a.type){case 0:n=n.add(a.doc.key);break;case 1:s=s.add(a.doc.key)}return new r(e,t.fromCache,n,s)}};var _m=class{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}};var ym=class{constructor(){this.Zi=!1,this.Xi=!1,this.es=100,this.ts=function(){return I0()?8:M2(E0())>0?6:4}()}initialize(e,t){this.ns=e,this.indexManager=t,this.Zi=!0}getDocumentsMatchingQuery(e,t,n,s){let a={result:null};return this.rs(e,t).next(c=>{a.result=c}).next(()=>{if(!a.result)return this.ss(e,t,s,n).next(c=>{a.result=c})}).next(()=>{if(a.result)return;let c=new _m;return this._s(e,t,c).next(h=>{if(a.result=h,this.Xi)return this.us(e,t,c,h.size)})}).next(()=>a.result)}us(e,t,n,s){return n.documentReadCount<this.es?(Ro()<=Se.DEBUG&&X("QueryEngine","SDK will not create cache indexes for query:",Po(t),"since it only creates cache indexes for collection contains","more than or equal to",this.es,"documents"),W.resolve()):(Ro()<=Se.DEBUG&&X("QueryEngine","Query:",Po(t),"scans",n.documentReadCount,"local documents and returns",s,"documents as results."),n.documentReadCount>this.ts*s?(Ro()<=Se.DEBUG&&X("QueryEngine","The SDK decides to create cache indexes for query:",Po(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,Wr(t))):W.resolve())}rs(e,t){if(ob(t))return W.resolve(null);let n=Wr(t);return this.indexManager.getIndexType(e,n).next(s=>s===0?null:(t.limit!==null&&s===1&&(t=Fp(t,null,"F"),n=Wr(t)),this.indexManager.getDocumentsMatchingTarget(e,n).next(a=>{let c=xe(...a);return this.ns.getDocuments(e,c).next(h=>this.indexManager.getMinOffset(e,n).next(f=>{let m=this.cs(t,h);return this.ls(t,m,c,f.readTime)?this.rs(e,Fp(t,null,"F")):this.hs(e,m,t,f)}))})))}ss(e,t,n,s){return ob(t)||s.isEqual(me.min())?W.resolve(null):this.ns.getDocuments(e,n).next(a=>{let c=this.cs(t,a);return this.ls(t,c,n,s)?W.resolve(null):(Ro()<=Se.DEBUG&&X("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),Po(t)),this.hs(e,c,t,k2(s,mu)).next(h=>h))})}cs(e,t){let n=new yt(uT(e));return t.forEach((s,a)=>{Gh(e,a)&&(n=n.add(a))}),n}ls(e,t,n,s){if(e.limit===null)return!1;if(n.size!==t.size)return!0;let a=e.limitType==="F"?t.last():t.first();return!!a&&(a.hasPendingWrites||a.version.compareTo(s)>0)}_s(e,t,n){return Ro()<=Se.DEBUG&&X("QueryEngine","Using full collection scan to execute query:",Po(t)),this.ns.getDocumentsMatchingQuery(e,t,ls.min(),n)}hs(e,t,n,s){return this.ns.getDocumentsMatchingQuery(e,n,s).next(a=>(t.forEach(c=>{a=a.insert(c.key,c)}),a))}};var ug="LocalStore",FM=3e8,vm=class{constructor(e,t,n,s){this.persistence=e,this.Ps=t,this.serializer=s,this.Ts=new Ye(Re),this.Is=new On(a=>ig(a),sg),this.Es=new Map,this.ds=e.getRemoteDocumentCache(),this.Hr=e.getTargetCache(),this.Yr=e.getBundleCache(),this.As(n)}As(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new om(this.ds,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.ds.setIndexManager(this.indexManager),this.Ps.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.Ts))}};function UM(r,e,t,n){return new vm(r,e,t,n)}async function RT(r,e){let t=fe(r);return await t.persistence.runTransaction("Handle user change","readonly",n=>{let s;return t.mutationQueue.getAllMutationBatches(n).next(a=>(s=a,t.As(e),t.mutationQueue.getAllMutationBatches(n))).next(a=>{let c=[],h=[],f=xe();for(let m of s){c.push(m.batchId);for(let _ of m.mutations)f=f.add(_.key)}for(let m of a){h.push(m.batchId);for(let _ of m.mutations)f=f.add(_.key)}return t.localDocuments.getDocuments(n,f).next(m=>({Rs:m,removedBatchIds:c,addedBatchIds:h}))})})}function BM(r,e){let t=fe(r);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",n=>{let s=e.batch.keys(),a=t.ds.newChangeBuffer({trackRemovals:!0});return function(h,f,m,_){let E=m.batch,I=E.keys(),k=W.resolve();return I.forEach(B=>{k=k.next(()=>_.getEntry(f,B)).next(G=>{let j=m.docVersions.get(B);Le(j!==null),G.version.compareTo(j)<0&&(E.applyToRemoteDocument(G,m),G.isValidDocument()&&(G.setReadTime(m.commitVersion),_.addEntry(G)))})}),k.next(()=>h.mutationQueue.removeMutationBatch(f,E))}(t,n,e,a).next(()=>a.apply(n)).next(()=>t.mutationQueue.performConsistencyCheck(n)).next(()=>t.documentOverlayCache.removeOverlaysForBatchId(n,s,e.batch.batchId)).next(()=>t.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(n,function(h){let f=xe();for(let m=0;m<h.mutationResults.length;++m)h.mutationResults[m].transformResults.length>0&&(f=f.add(h.batch.mutations[m].key));return f}(e))).next(()=>t.localDocuments.getDocuments(n,s))})}function PT(r){let e=fe(r);return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.Hr.getLastRemoteSnapshotVersion(t))}function jM(r,e){let t=fe(r),n=e.snapshotVersion,s=t.Ts;return t.persistence.runTransaction("Apply remote event","readwrite-primary",a=>{let c=t.ds.newChangeBuffer({trackRemovals:!0});s=t.Ts;let h=[];e.targetChanges.forEach((_,E)=>{let I=s.get(E);if(!I)return;h.push(t.Hr.removeMatchingKeys(a,_.removedDocuments,E).next(()=>t.Hr.addMatchingKeys(a,_.addedDocuments,E)));let k=I.withSequenceNumber(a.currentSequenceNumber);e.targetMismatches.get(E)!==null?k=k.withResumeToken(Rt.EMPTY_BYTE_STRING,me.min()).withLastLimboFreeSnapshotVersion(me.min()):_.resumeToken.approximateByteSize()>0&&(k=k.withResumeToken(_.resumeToken,n)),s=s.insert(E,k),function(G,j,J){return G.resumeToken.approximateByteSize()===0||j.snapshotVersion.toMicroseconds()-G.snapshotVersion.toMicroseconds()>=FM?!0:J.addedDocuments.size+J.modifiedDocuments.size+J.removedDocuments.size>0}(I,k,_)&&h.push(t.Hr.updateTargetData(a,k))});let f=kn(),m=xe();if(e.documentUpdates.forEach(_=>{e.resolvedLimboDocuments.has(_)&&h.push(t.persistence.referenceDelegate.updateLimboDocument(a,_))}),h.push($M(a,c,e.documentUpdates).next(_=>{f=_.Vs,m=_.fs})),!n.isEqual(me.min())){let _=t.Hr.getLastRemoteSnapshotVersion(a).next(E=>t.Hr.setTargetsMetadata(a,a.currentSequenceNumber,n));h.push(_)}return W.waitFor(h).next(()=>c.apply(a)).next(()=>t.localDocuments.getLocalViewOfDocuments(a,f,m)).next(()=>f)}).then(a=>(t.Ts=s,a))}function $M(r,e,t){let n=xe(),s=xe();return t.forEach(a=>n=n.add(a)),e.getEntries(r,n).next(a=>{let c=kn();return t.forEach((h,f)=>{let m=a.get(h);f.isFoundDocument()!==m.isFoundDocument()&&(s=s.add(h)),f.isNoDocument()&&f.version.isEqual(me.min())?(e.removeEntry(h,f.readTime),c=c.insert(h,f)):!m.isValidDocument()||f.version.compareTo(m.version)>0||f.version.compareTo(m.version)===0&&m.hasPendingWrites?(e.addEntry(f),c=c.insert(h,f)):X(ug,"Ignoring outdated watch update for ",h,". Current version:",m.version," Watch version:",f.version)}),{Vs:c,fs:s}})}function qM(r,e){let t=fe(r);return t.persistence.runTransaction("Get next mutation batch","readonly",n=>(e===void 0&&(e=Zm),t.mutationQueue.getNextMutationBatchAfterBatchId(n,e)))}function zM(r,e){let t=fe(r);return t.persistence.runTransaction("Allocate target","readwrite",n=>{let s;return t.Hr.getTargetData(n,e).next(a=>a?(s=a,W.resolve(s)):t.Hr.allocateTargetId(n).next(c=>(s=new wu(e,c,"TargetPurposeListen",n.currentSequenceNumber),t.Hr.addTargetData(n,s).next(()=>s))))}).then(n=>{let s=t.Ts.get(n.targetId);return(s===null||n.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(t.Ts=t.Ts.insert(n.targetId,n),t.Is.set(e,n.targetId)),n})}async function wm(r,e,t){let n=fe(r),s=n.Ts.get(e),a=t?"readwrite":"readwrite-primary";try{t||await n.persistence.runTransaction("Release target",a,c=>n.persistence.referenceDelegate.removeTarget(c,s))}catch(c){if(!Zo(c))throw c;X(ug,`Failed to update sequence numbers for target ${e}: ${c}`)}n.Ts=n.Ts.remove(e),n.Is.delete(s.target)}function vb(r,e,t){let n=fe(r),s=me.min(),a=xe();return n.persistence.runTransaction("Execute query","readwrite",c=>function(f,m,_){let E=fe(f),I=E.Is.get(_);return I!==void 0?W.resolve(E.Ts.get(I)):E.Hr.getTargetData(m,_)}(n,c,Wr(e)).next(h=>{if(h)return s=h.lastLimboFreeSnapshotVersion,n.Hr.getMatchingKeysForTargetId(c,h.targetId).next(f=>{a=f})}).next(()=>n.Ps.getDocumentsMatchingQuery(c,e,t?s:me.min(),t?a:xe())).next(h=>(GM(n,nM(e),h),{documents:h,gs:a})))}function GM(r,e,t){let n=r.Es.get(e)||me.min();t.forEach((s,a)=>{a.readTime.compareTo(n)>0&&(n=a.readTime)}),r.Es.set(e,n)}var bh=class{constructor(){this.activeTargetIds=cM()}Ds(e){this.activeTargetIds=this.activeTargetIds.add(e)}vs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}bs(){let e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}};var bm=class{constructor(){this.ho=new bh,this.Po={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e,t=!0){return t&&this.ho.Ds(e),this.Po[e]||"not-current"}updateQueryState(e,t,n){this.Po[e]=t}removeLocalQueryTarget(e){this.ho.vs(e)}isLocalQueryTarget(e){return this.ho.activeTargetIds.has(e)}clearQueryState(e){delete this.Po[e]}getAllActiveQueryTargets(){return this.ho.activeTargetIds}isActiveQueryTarget(e){return this.ho.activeTargetIds.has(e)}start(){return this.ho=new bh,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}};var Tm=class{To(e){}shutdown(){}};var wb="ConnectivityMonitor",Th=class{constructor(){this.Io=()=>this.Eo(),this.Ao=()=>this.Ro(),this.Vo=[],this.mo()}To(e){this.Vo.push(e)}shutdown(){window.removeEventListener("online",this.Io),window.removeEventListener("offline",this.Ao)}mo(){window.addEventListener("online",this.Io),window.addEventListener("offline",this.Ao)}Eo(){X(wb,"Network connectivity changed: AVAILABLE");for(let e of this.Vo)e(0)}Ro(){X(wb,"Network connectivity changed: UNAVAILABLE");for(let e of this.Vo)e(1)}static D(){return typeof window!="undefined"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}};var Zl=null;function Em(){return Zl===null?Zl=function(){return 268435456+Math.round(2147483648*Math.random())}():Zl++,"0x"+Zl.toString(16)}var pp="RestConnection",KM={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"},Im=class{get fo(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;let t=e.ssl?"https":"http",n=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.po=t+"://"+e.host,this.yo=`projects/${n}/databases/${s}`,this.wo=this.databaseId.database===ch?`project_id=${n}`:`project_id=${n}&database_id=${s}`}So(e,t,n,s,a){let c=Em(),h=this.bo(e,t.toUriEncodedString());X(pp,`Sending RPC '${e}' ${c}:`,h,n);let f={"google-cloud-resource-prefix":this.yo,"x-goog-request-params":this.wo};return this.Do(f,s,a),this.vo(e,h,f,n).then(m=>(X(pp,`Received RPC '${e}' ${c}: `,m),m),m=>{throw Vo(pp,`RPC '${e}' ${c} failed with error: `,m,"url: ",h,"request:",n),m})}Co(e,t,n,s,a,c){return this.So(e,t,n,s,a)}Do(e,t,n){e["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+Yo}(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach((s,a)=>e[a]=s),n&&n.headers.forEach((s,a)=>e[a]=s)}bo(e,t){let n=KM[e];return`${this.po}/v1/${t}:${n}`}terminate(){}};var xm=class{constructor(e){this.Fo=e.Fo,this.Mo=e.Mo}xo(e){this.Oo=e}No(e){this.Bo=e}Lo(e){this.ko=e}onMessage(e){this.qo=e}close(){this.Mo()}send(e){this.Fo(e)}Qo(){this.Oo()}$o(){this.Bo()}Ko(e){this.ko(e)}Uo(e){this.qo(e)}};var St="WebChannelConnection",Am=class extends Im{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}vo(e,t,n,s){let a=Em();return new Promise((c,h)=>{let f=new up;f.setWithCredentials(!0),f.listenOnce(cp.COMPLETE,()=>{try{switch(f.getLastErrorCode()){case cu.NO_ERROR:let _=f.getResponseJson();X(St,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(_)),c(_);break;case cu.TIMEOUT:X(St,`RPC '${e}' ${a} timed out`),h(new ne(H.DEADLINE_EXCEEDED,"Request time out"));break;case cu.HTTP_ERROR:let E=f.getStatus();if(X(St,`RPC '${e}' ${a} failed with status:`,E,"response text:",f.getResponseText()),E>0){let I=f.getResponseJson();Array.isArray(I)&&(I=I[0]);let k=I==null?void 0:I.error;if(k&&k.status&&k.message){let B=function(j){let J=j.toLowerCase().replace(/_/g,"-");return Object.values(H).indexOf(J)>=0?J:H.UNKNOWN}(k.status);h(new ne(B,k.message))}else h(new ne(H.UNKNOWN,"Server responded with status "+f.getStatus()))}else h(new ne(H.UNAVAILABLE,"Connection failed."));break;default:ue()}}finally{X(St,`RPC '${e}' ${a} completed.`)}});let m=JSON.stringify(s);X(St,`RPC '${e}' ${a} sending request:`,s),f.send(t,"POST",m,n,15)})}Wo(e,t,n){let s=Em(),a=[this.po,"/","google.firestore.v1.Firestore","/",e,"/channel"],c=fp(),h=hp(),f={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},m=this.longPollingOptions.timeoutSeconds;m!==void 0&&(f.longPollingTimeout=Math.round(1e3*m)),this.useFetchStreams&&(f.useFetchStreams=!0),this.Do(f.initMessageHeaders,t,n),f.encodeInitMessageHeaders=!0;let _=a.join("");X(St,`Creating RPC '${e}' stream ${s}: ${_}`,f);let E=c.createWebChannel(_,f),I=!1,k=!1,B=new xm({Fo:j=>{k?X(St,`Not sending because RPC '${e}' stream ${s} is closed:`,j):(I||(X(St,`Opening RPC '${e}' stream ${s} transport.`),E.open(),I=!0),X(St,`RPC '${e}' stream ${s} sending:`,j),E.send(j))},Mo:()=>E.close()}),G=(j,J,ee)=>{j.listen(J,re=>{try{ee(re)}catch(le){setTimeout(()=>{throw le},0)}})};return G(E,So.EventType.OPEN,()=>{k||(X(St,`RPC '${e}' stream ${s} transport opened.`),B.Qo())}),G(E,So.EventType.CLOSE,()=>{k||(k=!0,X(St,`RPC '${e}' stream ${s} transport closed`),B.Ko())}),G(E,So.EventType.ERROR,j=>{k||(k=!0,Vo(St,`RPC '${e}' stream ${s} transport errored:`,j),B.Ko(new ne(H.UNAVAILABLE,"The operation could not be completed")))}),G(E,So.EventType.MESSAGE,j=>{var J;if(!k){let ee=j.data[0];Le(!!ee);let re=ee,le=(re==null?void 0:re.error)||((J=re[0])===null||J===void 0?void 0:J.error);if(le){X(St,`RPC '${e}' stream ${s} received error:`,le);let de=le.status,ie=function(R){let D=it[R];if(D!==void 0)return vT(D)}(de),C=le.message;ie===void 0&&(ie=H.INTERNAL,C="Unknown error status: "+de+" with message "+le.message),k=!0,B.Ko(new ne(ie,C)),E.close()}else X(St,`RPC '${e}' stream ${s} received:`,ee),B.Uo(ee)}}),G(h,lp.STAT_EVENT,j=>{j.stat===Jl.PROXY?X(St,`RPC '${e}' stream ${s} detected buffering proxy`):j.stat===Jl.NOPROXY&&X(St,`RPC '${e}' stream ${s} detected no buffering proxy`)}),setTimeout(()=>{B.$o()},0),B}};function mp(){return typeof document!="undefined"?document:null}function Kh(r){return new Wp(r,!0)}var Eh=class{constructor(e,t,n=1e3,s=1.5,a=6e4){this.Ti=e,this.timerId=t,this.Go=n,this.zo=s,this.jo=a,this.Ho=0,this.Jo=null,this.Yo=Date.now(),this.reset()}reset(){this.Ho=0}Zo(){this.Ho=this.jo}Xo(e){this.cancel();let t=Math.floor(this.Ho+this.e_()),n=Math.max(0,Date.now()-this.Yo),s=Math.max(0,t-n);s>0&&X("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.Ho} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.Jo=this.Ti.enqueueAfterDelay(this.timerId,s,()=>(this.Yo=Date.now(),e())),this.Ho*=this.zo,this.Ho<this.Go&&(this.Ho=this.Go),this.Ho>this.jo&&(this.Ho=this.jo)}t_(){this.Jo!==null&&(this.Jo.skipDelay(),this.Jo=null)}cancel(){this.Jo!==null&&(this.Jo.cancel(),this.Jo=null)}e_(){return(Math.random()-.5)*this.Ho}};var bb="PersistentStream",Ih=class{constructor(e,t,n,s,a,c,h,f){this.Ti=e,this.n_=n,this.r_=s,this.connection=a,this.authCredentialsProvider=c,this.appCheckCredentialsProvider=h,this.listener=f,this.state=0,this.i_=0,this.s_=null,this.o_=null,this.stream=null,this.__=0,this.a_=new Eh(e,t)}u_(){return this.state===1||this.state===5||this.c_()}c_(){return this.state===2||this.state===3}start(){this.__=0,this.state!==4?this.auth():this.l_()}async stop(){this.u_()&&await this.close(0)}h_(){this.state=0,this.a_.reset()}P_(){this.c_()&&this.s_===null&&(this.s_=this.Ti.enqueueAfterDelay(this.n_,6e4,()=>this.T_()))}I_(e){this.E_(),this.stream.send(e)}async T_(){if(this.c_())return this.close(0)}E_(){this.s_&&(this.s_.cancel(),this.s_=null)}d_(){this.o_&&(this.o_.cancel(),this.o_=null)}async close(e,t){this.E_(),this.d_(),this.a_.cancel(),this.i_++,e!==4?this.a_.reset():t&&t.code===H.RESOURCE_EXHAUSTED?(Pn(t.toString()),Pn("Using maximum backoff delay to prevent overloading the backend."),this.a_.Zo()):t&&t.code===H.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.A_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.Lo(t)}A_(){}auth(){this.state=1;let e=this.R_(this.i_),t=this.i_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([n,s])=>{this.i_===t&&this.V_(n,s)},n=>{e(()=>{let s=new ne(H.UNKNOWN,"Fetching auth token failed: "+n.message);return this.m_(s)})})}V_(e,t){let n=this.R_(this.i_);this.stream=this.f_(e,t),this.stream.xo(()=>{n(()=>this.listener.xo())}),this.stream.No(()=>{n(()=>(this.state=2,this.o_=this.Ti.enqueueAfterDelay(this.r_,1e4,()=>(this.c_()&&(this.state=3),Promise.resolve())),this.listener.No()))}),this.stream.Lo(s=>{n(()=>this.m_(s))}),this.stream.onMessage(s=>{n(()=>++this.__==1?this.g_(s):this.onNext(s))})}l_(){this.state=5,this.a_.Xo(async()=>{this.state=0,this.start()})}m_(e){return X(bb,`close with error: ${e}`),this.stream=null,this.close(4,e)}R_(e){return t=>{this.Ti.enqueueAndForget(()=>this.i_===e?t():(X(bb,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}},Sm=class extends Ih{constructor(e,t,n,s,a,c){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,n,s,c),this.serializer=a}f_(e,t){return this.connection.Wo("Listen",e,t)}g_(e){return this.onNext(e)}onNext(e){this.a_.reset();let t=IM(this.serializer,e),n=function(a){if(!("targetChange"in a))return me.min();let c=a.targetChange;return c.targetIds&&c.targetIds.length?me.min():c.readTime?Hr(c.readTime):me.min()}(e);return this.listener.p_(t,n)}y_(e){let t={};t.database=Yp(this.serializer),t.addTarget=function(a,c){let h,f=c.target;if(h=Mp(f)?{documents:SM(a,f)}:{query:RM(a,f).ht},h.targetId=c.targetId,c.resumeToken.approximateByteSize()>0){h.resumeToken=wT(a,c.resumeToken);let m=Hp(a,c.expectedCount);m!==null&&(h.expectedCount=m)}else if(c.snapshotVersion.compareTo(me.min())>0){h.readTime=_h(a,c.snapshotVersion.toTimestamp());let m=Hp(a,c.expectedCount);m!==null&&(h.expectedCount=m)}return h}(this.serializer,e);let n=CM(this.serializer,e);n&&(t.labels=n),this.I_(t)}w_(e){let t={};t.database=Yp(this.serializer),t.removeTarget=e,this.I_(t)}},Rm=class extends Ih{constructor(e,t,n,s,a,c){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,n,s,c),this.serializer=a}get S_(){return this.__>0}start(){this.lastStreamToken=void 0,super.start()}A_(){this.S_&&this.b_([])}f_(e,t){return this.connection.Wo("Write",e,t)}g_(e){return Le(!!e.streamToken),this.lastStreamToken=e.streamToken,Le(!e.writeResults||e.writeResults.length===0),this.listener.D_()}onNext(e){Le(!!e.streamToken),this.lastStreamToken=e.streamToken,this.a_.reset();let t=AM(e.writeResults,e.commitTime),n=Hr(e.commitTime);return this.listener.v_(n,t)}C_(){let e={};e.database=Yp(this.serializer),this.I_(e)}b_(e){let t={streamToken:this.lastStreamToken,writes:e.map(n=>xM(this.serializer,n))};this.I_(t)}};var Pm=class{},Cm=class extends Pm{constructor(e,t,n,s){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer=s,this.F_=!1}M_(){if(this.F_)throw new ne(H.FAILED_PRECONDITION,"The client has already been terminated.")}So(e,t,n,s){return this.M_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([a,c])=>this.connection.So(e,Qp(t,n),s,a,c)).catch(a=>{throw a.name==="FirebaseError"?(a.code===H.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new ne(H.UNKNOWN,a.toString())})}Co(e,t,n,s,a){return this.M_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([c,h])=>this.connection.Co(e,Qp(t,n),s,c,h,a)).catch(c=>{throw c.name==="FirebaseError"?(c.code===H.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),c):new ne(H.UNKNOWN,c.toString())})}terminate(){this.F_=!0,this.connection.terminate()}},Dm=class{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.x_=0,this.O_=null,this.N_=!0}B_(){this.x_===0&&(this.L_("Unknown"),this.O_=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.O_=null,this.k_("Backend didn't respond within 10 seconds."),this.L_("Offline"),Promise.resolve())))}q_(e){this.state==="Online"?this.L_("Unknown"):(this.x_++,this.x_>=1&&(this.Q_(),this.k_(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.L_("Offline")))}set(e){this.Q_(),this.x_=0,e==="Online"&&(this.N_=!1),this.L_(e)}L_(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}k_(e){let t=`Could not reach Cloud Firestore backend. ${e}
|
|
37
|
-
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.N_?(Pn(t),this.N_=!1):X("OnlineStateTracker",t)}Q_(){this.O_!==null&&(this.O_.cancel(),this.O_=null)}};var ps="RemoteStore",Om=class{constructor(e,t,n,s,a){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.K_=[],this.U_=new Map,this.W_=new Set,this.G_=[],this.z_=a,this.z_.To(c=>{n.enqueueAndForget(async()=>{ms(this)&&(X(ps,"Restarting streams for network reachability change."),await async function(f){let m=fe(f);m.W_.add(4),await Cu(m),m.j_.set("Unknown"),m.W_.delete(4),await Wh(m)}(this))})}),this.j_=new Dm(n,s)}};async function Wh(r){if(ms(r))for(let e of r.G_)await e(!0)}async function Cu(r){for(let e of r.G_)await e(!1)}function
|
|
36
|
+
Total Duration: ${m-_}ms`),W.resolve({didRun:!0,sequenceNumbersCollected:s,targetsRemoved:a,documentsRemoved:E})))}};function MM(r,e){return new nm(r,e)}var im=class{constructor(){this.changes=new On(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,Sr.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let n=this.changes.get(t);return n!==void 0?W.resolve(n):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}};var sm=class{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}};var om=class{constructor(e,t,n,s){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=n,this.indexManager=s}getDocument(e,t){let n=null;return this.documentOverlayCache.getOverlay(e,t).next(s=>(n=s,this.remoteDocumentCache.getEntry(e,t))).next(s=>(n!==null&&pu(n.mutation,s,hr.empty(),wt.now()),s))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(n=>this.getLocalViewOfDocuments(e,n,xe()).next(()=>n))}getLocalViewOfDocuments(e,t,n=xe()){let s=os();return this.populateOverlays(e,s,t).next(()=>this.computeViews(e,t,s,n).next(a=>{let c=lu();return a.forEach((h,f)=>{c=c.insert(h,f.overlayedDocument)}),c}))}getOverlayedDocuments(e,t){let n=os();return this.populateOverlays(e,n,t).next(()=>this.computeViews(e,t,n,xe()))}populateOverlays(e,t,n){let s=[];return n.forEach(a=>{t.has(a)||s.push(a)}),this.documentOverlayCache.getOverlays(e,s).next(a=>{a.forEach((c,h)=>{t.set(c,h)})})}computeViews(e,t,n,s){let a=kn(),c=du(),h=function(){return du()}();return t.forEach((f,m)=>{let _=n.get(m.key);s.has(m.key)&&(_===void 0||_.mutation instanceof Xr)?a=a.insert(m.key,m):_!==void 0?(c.set(m.key,_.mutation.getFieldMask()),pu(_.mutation,m,_.mutation.getFieldMask(),wt.now())):c.set(m.key,hr.empty())}),this.recalculateAndSaveOverlays(e,a).next(f=>(f.forEach((m,_)=>c.set(m,_)),t.forEach((m,_)=>{var E;return h.set(m,new sm(_,(E=c.get(m))!==null&&E!==void 0?E:null))}),h))}recalculateAndSaveOverlays(e,t){let n=du(),s=new Ye((c,h)=>c-h),a=xe();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(c=>{for(let h of c)h.keys().forEach(f=>{let m=t.get(f);if(m===null)return;let _=n.get(f)||hr.empty();_=h.applyToLocalView(m,_),n.set(f,_);let E=(s.get(h.batchId)||xe()).add(f);s=s.insert(h.batchId,E)})}).next(()=>{let c=[],h=s.getReverseIterator();for(;h.hasNext();){let f=h.getNext(),m=f.key,_=f.value,E=fT();_.forEach(I=>{if(!a.has(I)){let k=yT(t.get(I),n.get(I));k!==null&&E.set(I,k),a=a.add(I)}}),c.push(this.documentOverlayCache.saveOverlays(e,m,E))}return W.waitFor(c)}).next(()=>n)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(n=>this.recalculateAndSaveOverlays(e,n))}getDocumentsMatchingQuery(e,t,n,s){return function(c){return ce.isDocumentKey(c.path)&&c.collectionGroup===null&&c.filters.length===0}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):tM(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n,s):this.getDocumentsMatchingCollectionQuery(e,t,n,s)}getNextDocuments(e,t,n,s){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,s).next(a=>{let c=s-a.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,s-a.size):W.resolve(os()),h=mu,f=a;return c.next(m=>W.forEach(m,(_,E)=>(h<E.largestBatchId&&(h=E.largestBatchId),a.get(_)?W.resolve():this.remoteDocumentCache.getEntry(e,_).next(I=>{f=f.insert(_,I)}))).next(()=>this.populateOverlays(e,m,a)).next(()=>this.computeViews(e,f,m,xe())).next(_=>({batchId:h,changes:hT(_)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new ce(t)).next(n=>{let s=lu();return n.isFoundDocument()&&(s=s.insert(n.key,n)),s})}getDocumentsMatchingCollectionGroupQuery(e,t,n,s){let a=t.collectionGroup,c=lu();return this.indexManager.getCollectionParents(e,a).next(h=>W.forEach(h,f=>{let m=function(E,I){return new qo(I,null,E.explicitOrderBy.slice(),E.filters.slice(),E.limit,E.limitType,E.startAt,E.endAt)}(t,f.child(a));return this.getDocumentsMatchingCollectionQuery(e,m,n,s).next(_=>{_.forEach((E,I)=>{c=c.insert(E,I)})})}).next(()=>c))}getDocumentsMatchingCollectionQuery(e,t,n,s){let a;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next(c=>(a=c,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,a,s))).next(c=>{a.forEach((f,m)=>{let _=m.getKey();c.get(_)===null&&(c=c.insert(_,Sr.newInvalidDocument(_)))});let h=lu();return c.forEach((f,m)=>{let _=a.get(f);_!==void 0&&pu(_.mutation,m,hr.empty(),wt.now()),Gh(t,m)&&(h=h.insert(f,m))}),h})}};var am=class{constructor(e){this.serializer=e,this.dr=new Map,this.Ar=new Map}getBundleMetadata(e,t){return W.resolve(this.dr.get(t))}saveBundleMetadata(e,t){return this.dr.set(t.id,function(s){return{id:s.id,version:s.version,createTime:Hr(s.createTime)}}(t)),W.resolve()}getNamedQuery(e,t){return W.resolve(this.Ar.get(t))}saveNamedQuery(e,t){return this.Ar.set(t.name,function(s){return{name:s.name,query:VM(s.bundledQuery),readTime:Hr(s.readTime)}}(t)),W.resolve()}};var um=class{constructor(){this.overlays=new Ye(ce.comparator),this.Rr=new Map}getOverlay(e,t){return W.resolve(this.overlays.get(t))}getOverlays(e,t){let n=os();return W.forEach(t,s=>this.getOverlay(e,s).next(a=>{a!==null&&n.set(s,a)})).next(()=>n)}saveOverlays(e,t,n){return n.forEach((s,a)=>{this.Et(e,t,a)}),W.resolve()}removeOverlaysForBatchId(e,t,n){let s=this.Rr.get(n);return s!==void 0&&(s.forEach(a=>this.overlays=this.overlays.remove(a)),this.Rr.delete(n)),W.resolve()}getOverlaysForCollection(e,t,n){let s=os(),a=t.length+1,c=new ce(t.child("")),h=this.overlays.getIteratorFrom(c);for(;h.hasNext();){let f=h.getNext().value,m=f.getKey();if(!t.isPrefixOf(m.path))break;m.path.length===a&&f.largestBatchId>n&&s.set(f.getKey(),f)}return W.resolve(s)}getOverlaysForCollectionGroup(e,t,n,s){let a=new Ye((m,_)=>m-_),c=this.overlays.getIterator();for(;c.hasNext();){let m=c.getNext().value;if(m.getKey().getCollectionGroup()===t&&m.largestBatchId>n){let _=a.get(m.largestBatchId);_===null&&(_=os(),a=a.insert(m.largestBatchId,_)),_.set(m.getKey(),m)}}let h=os(),f=a.getIterator();for(;f.hasNext()&&(f.getNext().value.forEach((m,_)=>h.set(m,_)),!(h.size()>=s)););return W.resolve(h)}Et(e,t,n){let s=this.overlays.get(n.key);if(s!==null){let c=this.Rr.get(s.largestBatchId).delete(n.key);this.Rr.set(s.largestBatchId,c)}this.overlays=this.overlays.insert(n.key,new qp(t,n));let a=this.Rr.get(t);a===void 0&&(a=xe(),this.Rr.set(t,a)),this.Rr.set(t,a.add(n.key))}};var cm=class{constructor(){this.sessionToken=Rt.EMPTY_BYTE_STRING}getSessionToken(e){return W.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,W.resolve()}};var Tu=class{constructor(){this.Vr=new yt(st.mr),this.gr=new yt(st.pr)}isEmpty(){return this.Vr.isEmpty()}addReference(e,t){let n=new st(e,t);this.Vr=this.Vr.add(n),this.gr=this.gr.add(n)}yr(e,t){e.forEach(n=>this.addReference(n,t))}removeReference(e,t){this.wr(new st(e,t))}Sr(e,t){e.forEach(n=>this.removeReference(n,t))}br(e){let t=new ce(new ot([])),n=new st(t,e),s=new st(t,e+1),a=[];return this.gr.forEachInRange([n,s],c=>{this.wr(c),a.push(c.key)}),a}Dr(){this.Vr.forEach(e=>this.wr(e))}wr(e){this.Vr=this.Vr.delete(e),this.gr=this.gr.delete(e)}vr(e){let t=new ce(new ot([])),n=new st(t,e),s=new st(t,e+1),a=xe();return this.gr.forEachInRange([n,s],c=>{a=a.add(c.key)}),a}containsKey(e){let t=new st(e,0),n=this.Vr.firstAfterOrEqual(t);return n!==null&&e.isEqual(n.key)}},st=class{constructor(e,t){this.key=e,this.Cr=t}static mr(e,t){return ce.comparator(e.key,t.key)||Re(e.Cr,t.Cr)}static pr(e,t){return Re(e.Cr,t.Cr)||ce.comparator(e.key,t.key)}};var lm=class{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Fr=1,this.Mr=new yt(st.mr)}checkEmpty(e){return W.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,n,s){let a=this.Fr;this.Fr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let c=new jp(a,t,n,s);this.mutationQueue.push(c);for(let h of s)this.Mr=this.Mr.add(new st(h.key,a)),this.indexManager.addToCollectionParentIndex(e,h.key.path.popLast());return W.resolve(c)}lookupMutationBatch(e,t){return W.resolve(this.Or(t))}getNextMutationBatchAfterBatchId(e,t){let n=t+1,s=this.Nr(n),a=s<0?0:s;return W.resolve(this.mutationQueue.length>a?this.mutationQueue[a]:null)}getHighestUnacknowledgedBatchId(){return W.resolve(this.mutationQueue.length===0?Zm:this.Fr-1)}getAllMutationBatches(e){return W.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let n=new st(t,0),s=new st(t,Number.POSITIVE_INFINITY),a=[];return this.Mr.forEachInRange([n,s],c=>{let h=this.Or(c.Cr);a.push(h)}),W.resolve(a)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new yt(Re);return t.forEach(s=>{let a=new st(s,0),c=new st(s,Number.POSITIVE_INFINITY);this.Mr.forEachInRange([a,c],h=>{n=n.add(h.Cr)})}),W.resolve(this.Br(n))}getAllMutationBatchesAffectingQuery(e,t){let n=t.path,s=n.length+1,a=n;ce.isDocumentKey(a)||(a=a.child(""));let c=new st(new ce(a),0),h=new yt(Re);return this.Mr.forEachWhile(f=>{let m=f.key.path;return!!n.isPrefixOf(m)&&(m.length===s&&(h=h.add(f.Cr)),!0)},c),W.resolve(this.Br(h))}Br(e){let t=[];return e.forEach(n=>{let s=this.Or(n);s!==null&&t.push(s)}),t}removeMutationBatch(e,t){Le(this.Lr(t.batchId,"removed")===0),this.mutationQueue.shift();let n=this.Mr;return W.forEach(t.mutations,s=>{let a=new st(s.key,t.batchId);return n=n.delete(a),this.referenceDelegate.markPotentiallyOrphaned(e,s.key)}).next(()=>{this.Mr=n})}qn(e){}containsKey(e,t){let n=new st(t,0),s=this.Mr.firstAfterOrEqual(n);return W.resolve(t.isEqual(s&&s.key))}performConsistencyCheck(e){return this.mutationQueue.length,W.resolve()}Lr(e,t){return this.Nr(e)}Nr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Or(e){let t=this.Nr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}};var hm=class{constructor(e){this.kr=e,this.docs=function(){return new Ye(ce.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){let n=t.key,s=this.docs.get(n),a=s?s.size:0,c=this.kr(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:c}),this.size+=c-a,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}removeEntry(e){let t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){let n=this.docs.get(t);return W.resolve(n?n.document.mutableCopy():Sr.newInvalidDocument(t))}getEntries(e,t){let n=kn();return t.forEach(s=>{let a=this.docs.get(s);n=n.insert(s,a?a.document.mutableCopy():Sr.newInvalidDocument(s))}),W.resolve(n)}getDocumentsMatchingQuery(e,t,n,s){let a=kn(),c=t.path,h=new ce(c.child("__id-9223372036854775808__")),f=this.docs.getIteratorFrom(h);for(;f.hasNext();){let{key:m,value:{document:_}}=f.getNext();if(!c.isPrefixOf(m.path))break;m.path.length>c.length+1||V2(N2(_),n)<=0||(s.has(_.key)||Gh(t,_))&&(a=a.insert(_.key,_.mutableCopy()))}return W.resolve(a)}getAllFromCollectionGroup(e,t,n,s){ue()}qr(e,t){return W.forEach(this.docs,n=>t(n))}newChangeBuffer(e){return new fm(this)}getSize(e){return W.resolve(this.size)}},fm=class extends im{constructor(e){super(),this.Ir=e}applyChanges(e){let t=[];return this.changes.forEach((n,s)=>{s.isValidDocument()?t.push(this.Ir.addEntry(e,s)):this.Ir.removeEntry(n)}),W.waitFor(t)}getFromCache(e,t){return this.Ir.getEntry(e,t)}getAllFromCache(e,t){return this.Ir.getEntries(e,t)}};var dm=class{constructor(e){this.persistence=e,this.Qr=new On(t=>ig(t),sg),this.lastRemoteSnapshotVersion=me.min(),this.highestTargetId=0,this.$r=0,this.Kr=new Tu,this.targetCount=0,this.Ur=bu.Kn()}forEachTarget(e,t){return this.Qr.forEach((n,s)=>t(s)),W.resolve()}getLastRemoteSnapshotVersion(e){return W.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return W.resolve(this.$r)}allocateTargetId(e){return this.highestTargetId=this.Ur.next(),W.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.$r&&(this.$r=t),W.resolve()}zn(e){this.Qr.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.Ur=new bu(t),this.highestTargetId=t),e.sequenceNumber>this.$r&&(this.$r=e.sequenceNumber)}addTargetData(e,t){return this.zn(t),this.targetCount+=1,W.resolve()}updateTargetData(e,t){return this.zn(t),W.resolve()}removeTargetData(e,t){return this.Qr.delete(t.target),this.Kr.br(t.targetId),this.targetCount-=1,W.resolve()}removeTargets(e,t,n){let s=0,a=[];return this.Qr.forEach((c,h)=>{h.sequenceNumber<=t&&n.get(h.targetId)===null&&(this.Qr.delete(c),a.push(this.removeMatchingKeysForTargetId(e,h.targetId)),s++)}),W.waitFor(a).next(()=>s)}getTargetCount(e){return W.resolve(this.targetCount)}getTargetData(e,t){let n=this.Qr.get(t)||null;return W.resolve(n)}addMatchingKeys(e,t,n){return this.Kr.yr(t,n),W.resolve()}removeMatchingKeys(e,t,n){this.Kr.Sr(t,n);let s=this.persistence.referenceDelegate,a=[];return s&&t.forEach(c=>{a.push(s.markPotentiallyOrphaned(e,c))}),W.waitFor(a)}removeMatchingKeysForTargetId(e,t){return this.Kr.br(t),W.resolve()}getMatchingKeysForTargetId(e,t){let n=this.Kr.vr(t);return W.resolve(n)}containsKey(e,t){return W.resolve(this.Kr.containsKey(t))}};var vh=class{constructor(e,t){this.Wr={},this.overlays={},this.Gr=new Mo(0),this.zr=!1,this.zr=!0,this.jr=new cm,this.referenceDelegate=e(this),this.Hr=new dm(this),this.indexManager=new Zp,this.remoteDocumentCache=function(s){return new hm(s)}(n=>this.referenceDelegate.Jr(n)),this.serializer=new Xp(t),this.Yr=new am(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.zr=!1,Promise.resolve()}get started(){return this.zr}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new um,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.Wr[e.toKey()];return n||(n=new lm(t,this.referenceDelegate),this.Wr[e.toKey()]=n),n}getGlobalsCache(){return this.jr}getTargetCache(){return this.Hr}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Yr}runTransaction(e,t,n){X("MemoryPersistence","Starting transaction:",e);let s=new pm(this.Gr.next());return this.referenceDelegate.Zr(),n(s).next(a=>this.referenceDelegate.Xr(s).next(()=>a)).toPromise().then(a=>(s.raiseOnCommittedEvent(),a))}ei(e,t){return W.or(Object.values(this.Wr).map(n=>()=>n.containsKey(e,t)))}},pm=class extends Ip{constructor(e){super(),this.currentSequenceNumber=e}},mm=class r{constructor(e){this.persistence=e,this.ti=new Tu,this.ni=null}static ri(e){return new r(e)}get ii(){if(this.ni)return this.ni;throw ue()}addReference(e,t,n){return this.ti.addReference(n,t),this.ii.delete(n.toString()),W.resolve()}removeReference(e,t,n){return this.ti.removeReference(n,t),this.ii.add(n.toString()),W.resolve()}markPotentiallyOrphaned(e,t){return this.ii.add(t.toString()),W.resolve()}removeTarget(e,t){this.ti.br(t.targetId).forEach(s=>this.ii.add(s.toString()));let n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next(s=>{s.forEach(a=>this.ii.add(a.toString()))}).next(()=>n.removeTargetData(e,t))}Zr(){this.ni=new Set}Xr(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return W.forEach(this.ii,n=>{let s=ce.fromPath(n);return this.si(e,s).next(a=>{a||t.removeEntry(s,me.min())})}).next(()=>(this.ni=null,t.apply(e)))}updateLimboDocument(e,t){return this.si(e,t).next(n=>{n?this.ii.delete(t.toString()):this.ii.add(t.toString())})}Jr(e){return 0}si(e,t){return W.or([()=>W.resolve(this.ti.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.ei(e,t)])}},wh=class r{constructor(e,t){this.persistence=e,this.oi=new On(n=>U2(n.path),(n,s)=>n.isEqual(s)),this.garbageCollector=MM(this,t)}static ri(e,t){return new r(e,t)}Zr(){}Xr(e){return W.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}nr(e){let t=this.sr(e);return this.persistence.getTargetCache().getTargetCount(e).next(n=>t.next(s=>n+s))}sr(e){let t=0;return this.rr(e,n=>{t++}).next(()=>t)}rr(e,t){return W.forEach(this.oi,(n,s)=>this.ar(e,n,s).next(a=>a?W.resolve():t(s)))}removeTargets(e,t,n){return this.persistence.getTargetCache().removeTargets(e,t,n)}removeOrphanedDocuments(e,t){let n=0,s=this.persistence.getRemoteDocumentCache(),a=s.newChangeBuffer();return s.qr(e,c=>this.ar(e,c,t).next(h=>{h||(n++,a.removeEntry(c,me.min()))})).next(()=>a.apply(e)).next(()=>n)}markPotentiallyOrphaned(e,t){return this.oi.set(t,e.currentSequenceNumber),W.resolve()}removeTarget(e,t){let n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}addReference(e,t,n){return this.oi.set(n,e.currentSequenceNumber),W.resolve()}removeReference(e,t,n){return this.oi.set(n,e.currentSequenceNumber),W.resolve()}updateLimboDocument(e,t){return this.oi.set(t,e.currentSequenceNumber),W.resolve()}Jr(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=eh(e.data.value)),t}ar(e,t,n){return W.or([()=>this.persistence.ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let s=this.oi.get(t);return W.resolve(s!==void 0&&s>n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}};var gm=class r{constructor(e,t,n,s){this.targetId=e,this.fromCache=t,this.Hi=n,this.Ji=s}static Yi(e,t){let n=xe(),s=xe();for(let a of t.docChanges)switch(a.type){case 0:n=n.add(a.doc.key);break;case 1:s=s.add(a.doc.key)}return new r(e,t.fromCache,n,s)}};var _m=class{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}};var ym=class{constructor(){this.Zi=!1,this.Xi=!1,this.es=100,this.ts=function(){return x0()?8:M2(I0())>0?6:4}()}initialize(e,t){this.ns=e,this.indexManager=t,this.Zi=!0}getDocumentsMatchingQuery(e,t,n,s){let a={result:null};return this.rs(e,t).next(c=>{a.result=c}).next(()=>{if(!a.result)return this.ss(e,t,s,n).next(c=>{a.result=c})}).next(()=>{if(a.result)return;let c=new _m;return this._s(e,t,c).next(h=>{if(a.result=h,this.Xi)return this.us(e,t,c,h.size)})}).next(()=>a.result)}us(e,t,n,s){return n.documentReadCount<this.es?(Ro()<=Se.DEBUG&&X("QueryEngine","SDK will not create cache indexes for query:",Po(t),"since it only creates cache indexes for collection contains","more than or equal to",this.es,"documents"),W.resolve()):(Ro()<=Se.DEBUG&&X("QueryEngine","Query:",Po(t),"scans",n.documentReadCount,"local documents and returns",s,"documents as results."),n.documentReadCount>this.ts*s?(Ro()<=Se.DEBUG&&X("QueryEngine","The SDK decides to create cache indexes for query:",Po(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,Wr(t))):W.resolve())}rs(e,t){if(ab(t))return W.resolve(null);let n=Wr(t);return this.indexManager.getIndexType(e,n).next(s=>s===0?null:(t.limit!==null&&s===1&&(t=Fp(t,null,"F"),n=Wr(t)),this.indexManager.getDocumentsMatchingTarget(e,n).next(a=>{let c=xe(...a);return this.ns.getDocuments(e,c).next(h=>this.indexManager.getMinOffset(e,n).next(f=>{let m=this.cs(t,h);return this.ls(t,m,c,f.readTime)?this.rs(e,Fp(t,null,"F")):this.hs(e,m,t,f)}))})))}ss(e,t,n,s){return ab(t)||s.isEqual(me.min())?W.resolve(null):this.ns.getDocuments(e,n).next(a=>{let c=this.cs(t,a);return this.ls(t,c,n,s)?W.resolve(null):(Ro()<=Se.DEBUG&&X("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),Po(t)),this.hs(e,c,t,k2(s,mu)).next(h=>h))})}cs(e,t){let n=new yt(cT(e));return t.forEach((s,a)=>{Gh(e,a)&&(n=n.add(a))}),n}ls(e,t,n,s){if(e.limit===null)return!1;if(n.size!==t.size)return!0;let a=e.limitType==="F"?t.last():t.first();return!!a&&(a.hasPendingWrites||a.version.compareTo(s)>0)}_s(e,t,n){return Ro()<=Se.DEBUG&&X("QueryEngine","Using full collection scan to execute query:",Po(t)),this.ns.getDocumentsMatchingQuery(e,t,ls.min(),n)}hs(e,t,n,s){return this.ns.getDocumentsMatchingQuery(e,n,s).next(a=>(t.forEach(c=>{a=a.insert(c.key,c)}),a))}};var ug="LocalStore",FM=3e8,vm=class{constructor(e,t,n,s){this.persistence=e,this.Ps=t,this.serializer=s,this.Ts=new Ye(Re),this.Is=new On(a=>ig(a),sg),this.Es=new Map,this.ds=e.getRemoteDocumentCache(),this.Hr=e.getTargetCache(),this.Yr=e.getBundleCache(),this.As(n)}As(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new om(this.ds,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.ds.setIndexManager(this.indexManager),this.Ps.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.Ts))}};function UM(r,e,t,n){return new vm(r,e,t,n)}async function PT(r,e){let t=fe(r);return await t.persistence.runTransaction("Handle user change","readonly",n=>{let s;return t.mutationQueue.getAllMutationBatches(n).next(a=>(s=a,t.As(e),t.mutationQueue.getAllMutationBatches(n))).next(a=>{let c=[],h=[],f=xe();for(let m of s){c.push(m.batchId);for(let _ of m.mutations)f=f.add(_.key)}for(let m of a){h.push(m.batchId);for(let _ of m.mutations)f=f.add(_.key)}return t.localDocuments.getDocuments(n,f).next(m=>({Rs:m,removedBatchIds:c,addedBatchIds:h}))})})}function BM(r,e){let t=fe(r);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",n=>{let s=e.batch.keys(),a=t.ds.newChangeBuffer({trackRemovals:!0});return function(h,f,m,_){let E=m.batch,I=E.keys(),k=W.resolve();return I.forEach(B=>{k=k.next(()=>_.getEntry(f,B)).next(G=>{let j=m.docVersions.get(B);Le(j!==null),G.version.compareTo(j)<0&&(E.applyToRemoteDocument(G,m),G.isValidDocument()&&(G.setReadTime(m.commitVersion),_.addEntry(G)))})}),k.next(()=>h.mutationQueue.removeMutationBatch(f,E))}(t,n,e,a).next(()=>a.apply(n)).next(()=>t.mutationQueue.performConsistencyCheck(n)).next(()=>t.documentOverlayCache.removeOverlaysForBatchId(n,s,e.batch.batchId)).next(()=>t.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(n,function(h){let f=xe();for(let m=0;m<h.mutationResults.length;++m)h.mutationResults[m].transformResults.length>0&&(f=f.add(h.batch.mutations[m].key));return f}(e))).next(()=>t.localDocuments.getDocuments(n,s))})}function CT(r){let e=fe(r);return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.Hr.getLastRemoteSnapshotVersion(t))}function jM(r,e){let t=fe(r),n=e.snapshotVersion,s=t.Ts;return t.persistence.runTransaction("Apply remote event","readwrite-primary",a=>{let c=t.ds.newChangeBuffer({trackRemovals:!0});s=t.Ts;let h=[];e.targetChanges.forEach((_,E)=>{let I=s.get(E);if(!I)return;h.push(t.Hr.removeMatchingKeys(a,_.removedDocuments,E).next(()=>t.Hr.addMatchingKeys(a,_.addedDocuments,E)));let k=I.withSequenceNumber(a.currentSequenceNumber);e.targetMismatches.get(E)!==null?k=k.withResumeToken(Rt.EMPTY_BYTE_STRING,me.min()).withLastLimboFreeSnapshotVersion(me.min()):_.resumeToken.approximateByteSize()>0&&(k=k.withResumeToken(_.resumeToken,n)),s=s.insert(E,k),function(G,j,J){return G.resumeToken.approximateByteSize()===0||j.snapshotVersion.toMicroseconds()-G.snapshotVersion.toMicroseconds()>=FM?!0:J.addedDocuments.size+J.modifiedDocuments.size+J.removedDocuments.size>0}(I,k,_)&&h.push(t.Hr.updateTargetData(a,k))});let f=kn(),m=xe();if(e.documentUpdates.forEach(_=>{e.resolvedLimboDocuments.has(_)&&h.push(t.persistence.referenceDelegate.updateLimboDocument(a,_))}),h.push($M(a,c,e.documentUpdates).next(_=>{f=_.Vs,m=_.fs})),!n.isEqual(me.min())){let _=t.Hr.getLastRemoteSnapshotVersion(a).next(E=>t.Hr.setTargetsMetadata(a,a.currentSequenceNumber,n));h.push(_)}return W.waitFor(h).next(()=>c.apply(a)).next(()=>t.localDocuments.getLocalViewOfDocuments(a,f,m)).next(()=>f)}).then(a=>(t.Ts=s,a))}function $M(r,e,t){let n=xe(),s=xe();return t.forEach(a=>n=n.add(a)),e.getEntries(r,n).next(a=>{let c=kn();return t.forEach((h,f)=>{let m=a.get(h);f.isFoundDocument()!==m.isFoundDocument()&&(s=s.add(h)),f.isNoDocument()&&f.version.isEqual(me.min())?(e.removeEntry(h,f.readTime),c=c.insert(h,f)):!m.isValidDocument()||f.version.compareTo(m.version)>0||f.version.compareTo(m.version)===0&&m.hasPendingWrites?(e.addEntry(f),c=c.insert(h,f)):X(ug,"Ignoring outdated watch update for ",h,". Current version:",m.version," Watch version:",f.version)}),{Vs:c,fs:s}})}function qM(r,e){let t=fe(r);return t.persistence.runTransaction("Get next mutation batch","readonly",n=>(e===void 0&&(e=Zm),t.mutationQueue.getNextMutationBatchAfterBatchId(n,e)))}function zM(r,e){let t=fe(r);return t.persistence.runTransaction("Allocate target","readwrite",n=>{let s;return t.Hr.getTargetData(n,e).next(a=>a?(s=a,W.resolve(s)):t.Hr.allocateTargetId(n).next(c=>(s=new wu(e,c,"TargetPurposeListen",n.currentSequenceNumber),t.Hr.addTargetData(n,s).next(()=>s))))}).then(n=>{let s=t.Ts.get(n.targetId);return(s===null||n.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(t.Ts=t.Ts.insert(n.targetId,n),t.Is.set(e,n.targetId)),n})}async function wm(r,e,t){let n=fe(r),s=n.Ts.get(e),a=t?"readwrite":"readwrite-primary";try{t||await n.persistence.runTransaction("Release target",a,c=>n.persistence.referenceDelegate.removeTarget(c,s))}catch(c){if(!Zo(c))throw c;X(ug,`Failed to update sequence numbers for target ${e}: ${c}`)}n.Ts=n.Ts.remove(e),n.Is.delete(s.target)}function wb(r,e,t){let n=fe(r),s=me.min(),a=xe();return n.persistence.runTransaction("Execute query","readwrite",c=>function(f,m,_){let E=fe(f),I=E.Is.get(_);return I!==void 0?W.resolve(E.Ts.get(I)):E.Hr.getTargetData(m,_)}(n,c,Wr(e)).next(h=>{if(h)return s=h.lastLimboFreeSnapshotVersion,n.Hr.getMatchingKeysForTargetId(c,h.targetId).next(f=>{a=f})}).next(()=>n.Ps.getDocumentsMatchingQuery(c,e,t?s:me.min(),t?a:xe())).next(h=>(GM(n,nM(e),h),{documents:h,gs:a})))}function GM(r,e,t){let n=r.Es.get(e)||me.min();t.forEach((s,a)=>{a.readTime.compareTo(n)>0&&(n=a.readTime)}),r.Es.set(e,n)}var bh=class{constructor(){this.activeTargetIds=cM()}Ds(e){this.activeTargetIds=this.activeTargetIds.add(e)}vs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}bs(){let e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}};var bm=class{constructor(){this.ho=new bh,this.Po={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e,t=!0){return t&&this.ho.Ds(e),this.Po[e]||"not-current"}updateQueryState(e,t,n){this.Po[e]=t}removeLocalQueryTarget(e){this.ho.vs(e)}isLocalQueryTarget(e){return this.ho.activeTargetIds.has(e)}clearQueryState(e){delete this.Po[e]}getAllActiveQueryTargets(){return this.ho.activeTargetIds}isActiveQueryTarget(e){return this.ho.activeTargetIds.has(e)}start(){return this.ho=new bh,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}};var Tm=class{To(e){}shutdown(){}};var bb="ConnectivityMonitor",Th=class{constructor(){this.Io=()=>this.Eo(),this.Ao=()=>this.Ro(),this.Vo=[],this.mo()}To(e){this.Vo.push(e)}shutdown(){window.removeEventListener("online",this.Io),window.removeEventListener("offline",this.Ao)}mo(){window.addEventListener("online",this.Io),window.addEventListener("offline",this.Ao)}Eo(){X(bb,"Network connectivity changed: AVAILABLE");for(let e of this.Vo)e(0)}Ro(){X(bb,"Network connectivity changed: UNAVAILABLE");for(let e of this.Vo)e(1)}static D(){return typeof window!="undefined"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}};var Zl=null;function Em(){return Zl===null?Zl=function(){return 268435456+Math.round(2147483648*Math.random())}():Zl++,"0x"+Zl.toString(16)}var pp="RestConnection",KM={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"},Im=class{get fo(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;let t=e.ssl?"https":"http",n=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.po=t+"://"+e.host,this.yo=`projects/${n}/databases/${s}`,this.wo=this.databaseId.database===ch?`project_id=${n}`:`project_id=${n}&database_id=${s}`}So(e,t,n,s,a){let c=Em(),h=this.bo(e,t.toUriEncodedString());X(pp,`Sending RPC '${e}' ${c}:`,h,n);let f={"google-cloud-resource-prefix":this.yo,"x-goog-request-params":this.wo};return this.Do(f,s,a),this.vo(e,h,f,n).then(m=>(X(pp,`Received RPC '${e}' ${c}: `,m),m),m=>{throw Vo(pp,`RPC '${e}' ${c} failed with error: `,m,"url: ",h,"request:",n),m})}Co(e,t,n,s,a,c){return this.So(e,t,n,s,a)}Do(e,t,n){e["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+Yo}(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach((s,a)=>e[a]=s),n&&n.headers.forEach((s,a)=>e[a]=s)}bo(e,t){let n=KM[e];return`${this.po}/v1/${t}:${n}`}terminate(){}};var xm=class{constructor(e){this.Fo=e.Fo,this.Mo=e.Mo}xo(e){this.Oo=e}No(e){this.Bo=e}Lo(e){this.ko=e}onMessage(e){this.qo=e}close(){this.Mo()}send(e){this.Fo(e)}Qo(){this.Oo()}$o(){this.Bo()}Ko(e){this.ko(e)}Uo(e){this.qo(e)}};var St="WebChannelConnection",Am=class extends Im{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}vo(e,t,n,s){let a=Em();return new Promise((c,h)=>{let f=new up;f.setWithCredentials(!0),f.listenOnce(cp.COMPLETE,()=>{try{switch(f.getLastErrorCode()){case cu.NO_ERROR:let _=f.getResponseJson();X(St,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(_)),c(_);break;case cu.TIMEOUT:X(St,`RPC '${e}' ${a} timed out`),h(new ne(H.DEADLINE_EXCEEDED,"Request time out"));break;case cu.HTTP_ERROR:let E=f.getStatus();if(X(St,`RPC '${e}' ${a} failed with status:`,E,"response text:",f.getResponseText()),E>0){let I=f.getResponseJson();Array.isArray(I)&&(I=I[0]);let k=I==null?void 0:I.error;if(k&&k.status&&k.message){let B=function(j){let J=j.toLowerCase().replace(/_/g,"-");return Object.values(H).indexOf(J)>=0?J:H.UNKNOWN}(k.status);h(new ne(B,k.message))}else h(new ne(H.UNKNOWN,"Server responded with status "+f.getStatus()))}else h(new ne(H.UNAVAILABLE,"Connection failed."));break;default:ue()}}finally{X(St,`RPC '${e}' ${a} completed.`)}});let m=JSON.stringify(s);X(St,`RPC '${e}' ${a} sending request:`,s),f.send(t,"POST",m,n,15)})}Wo(e,t,n){let s=Em(),a=[this.po,"/","google.firestore.v1.Firestore","/",e,"/channel"],c=fp(),h=hp(),f={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},m=this.longPollingOptions.timeoutSeconds;m!==void 0&&(f.longPollingTimeout=Math.round(1e3*m)),this.useFetchStreams&&(f.useFetchStreams=!0),this.Do(f.initMessageHeaders,t,n),f.encodeInitMessageHeaders=!0;let _=a.join("");X(St,`Creating RPC '${e}' stream ${s}: ${_}`,f);let E=c.createWebChannel(_,f),I=!1,k=!1,B=new xm({Fo:j=>{k?X(St,`Not sending because RPC '${e}' stream ${s} is closed:`,j):(I||(X(St,`Opening RPC '${e}' stream ${s} transport.`),E.open(),I=!0),X(St,`RPC '${e}' stream ${s} sending:`,j),E.send(j))},Mo:()=>E.close()}),G=(j,J,ee)=>{j.listen(J,re=>{try{ee(re)}catch(le){setTimeout(()=>{throw le},0)}})};return G(E,So.EventType.OPEN,()=>{k||(X(St,`RPC '${e}' stream ${s} transport opened.`),B.Qo())}),G(E,So.EventType.CLOSE,()=>{k||(k=!0,X(St,`RPC '${e}' stream ${s} transport closed`),B.Ko())}),G(E,So.EventType.ERROR,j=>{k||(k=!0,Vo(St,`RPC '${e}' stream ${s} transport errored:`,j),B.Ko(new ne(H.UNAVAILABLE,"The operation could not be completed")))}),G(E,So.EventType.MESSAGE,j=>{var J;if(!k){let ee=j.data[0];Le(!!ee);let re=ee,le=(re==null?void 0:re.error)||((J=re[0])===null||J===void 0?void 0:J.error);if(le){X(St,`RPC '${e}' stream ${s} received error:`,le);let de=le.status,ie=function(R){let D=it[R];if(D!==void 0)return wT(D)}(de),C=le.message;ie===void 0&&(ie=H.INTERNAL,C="Unknown error status: "+de+" with message "+le.message),k=!0,B.Ko(new ne(ie,C)),E.close()}else X(St,`RPC '${e}' stream ${s} received:`,ee),B.Uo(ee)}}),G(h,lp.STAT_EVENT,j=>{j.stat===Jl.PROXY?X(St,`RPC '${e}' stream ${s} detected buffering proxy`):j.stat===Jl.NOPROXY&&X(St,`RPC '${e}' stream ${s} detected no buffering proxy`)}),setTimeout(()=>{B.$o()},0),B}};function mp(){return typeof document!="undefined"?document:null}function Kh(r){return new Wp(r,!0)}var Eh=class{constructor(e,t,n=1e3,s=1.5,a=6e4){this.Ti=e,this.timerId=t,this.Go=n,this.zo=s,this.jo=a,this.Ho=0,this.Jo=null,this.Yo=Date.now(),this.reset()}reset(){this.Ho=0}Zo(){this.Ho=this.jo}Xo(e){this.cancel();let t=Math.floor(this.Ho+this.e_()),n=Math.max(0,Date.now()-this.Yo),s=Math.max(0,t-n);s>0&&X("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.Ho} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.Jo=this.Ti.enqueueAfterDelay(this.timerId,s,()=>(this.Yo=Date.now(),e())),this.Ho*=this.zo,this.Ho<this.Go&&(this.Ho=this.Go),this.Ho>this.jo&&(this.Ho=this.jo)}t_(){this.Jo!==null&&(this.Jo.skipDelay(),this.Jo=null)}cancel(){this.Jo!==null&&(this.Jo.cancel(),this.Jo=null)}e_(){return(Math.random()-.5)*this.Ho}};var Tb="PersistentStream",Ih=class{constructor(e,t,n,s,a,c,h,f){this.Ti=e,this.n_=n,this.r_=s,this.connection=a,this.authCredentialsProvider=c,this.appCheckCredentialsProvider=h,this.listener=f,this.state=0,this.i_=0,this.s_=null,this.o_=null,this.stream=null,this.__=0,this.a_=new Eh(e,t)}u_(){return this.state===1||this.state===5||this.c_()}c_(){return this.state===2||this.state===3}start(){this.__=0,this.state!==4?this.auth():this.l_()}async stop(){this.u_()&&await this.close(0)}h_(){this.state=0,this.a_.reset()}P_(){this.c_()&&this.s_===null&&(this.s_=this.Ti.enqueueAfterDelay(this.n_,6e4,()=>this.T_()))}I_(e){this.E_(),this.stream.send(e)}async T_(){if(this.c_())return this.close(0)}E_(){this.s_&&(this.s_.cancel(),this.s_=null)}d_(){this.o_&&(this.o_.cancel(),this.o_=null)}async close(e,t){this.E_(),this.d_(),this.a_.cancel(),this.i_++,e!==4?this.a_.reset():t&&t.code===H.RESOURCE_EXHAUSTED?(Pn(t.toString()),Pn("Using maximum backoff delay to prevent overloading the backend."),this.a_.Zo()):t&&t.code===H.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.A_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.Lo(t)}A_(){}auth(){this.state=1;let e=this.R_(this.i_),t=this.i_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([n,s])=>{this.i_===t&&this.V_(n,s)},n=>{e(()=>{let s=new ne(H.UNKNOWN,"Fetching auth token failed: "+n.message);return this.m_(s)})})}V_(e,t){let n=this.R_(this.i_);this.stream=this.f_(e,t),this.stream.xo(()=>{n(()=>this.listener.xo())}),this.stream.No(()=>{n(()=>(this.state=2,this.o_=this.Ti.enqueueAfterDelay(this.r_,1e4,()=>(this.c_()&&(this.state=3),Promise.resolve())),this.listener.No()))}),this.stream.Lo(s=>{n(()=>this.m_(s))}),this.stream.onMessage(s=>{n(()=>++this.__==1?this.g_(s):this.onNext(s))})}l_(){this.state=5,this.a_.Xo(async()=>{this.state=0,this.start()})}m_(e){return X(Tb,`close with error: ${e}`),this.stream=null,this.close(4,e)}R_(e){return t=>{this.Ti.enqueueAndForget(()=>this.i_===e?t():(X(Tb,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}},Sm=class extends Ih{constructor(e,t,n,s,a,c){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,n,s,c),this.serializer=a}f_(e,t){return this.connection.Wo("Listen",e,t)}g_(e){return this.onNext(e)}onNext(e){this.a_.reset();let t=IM(this.serializer,e),n=function(a){if(!("targetChange"in a))return me.min();let c=a.targetChange;return c.targetIds&&c.targetIds.length?me.min():c.readTime?Hr(c.readTime):me.min()}(e);return this.listener.p_(t,n)}y_(e){let t={};t.database=Yp(this.serializer),t.addTarget=function(a,c){let h,f=c.target;if(h=Mp(f)?{documents:SM(a,f)}:{query:RM(a,f).ht},h.targetId=c.targetId,c.resumeToken.approximateByteSize()>0){h.resumeToken=bT(a,c.resumeToken);let m=Hp(a,c.expectedCount);m!==null&&(h.expectedCount=m)}else if(c.snapshotVersion.compareTo(me.min())>0){h.readTime=_h(a,c.snapshotVersion.toTimestamp());let m=Hp(a,c.expectedCount);m!==null&&(h.expectedCount=m)}return h}(this.serializer,e);let n=CM(this.serializer,e);n&&(t.labels=n),this.I_(t)}w_(e){let t={};t.database=Yp(this.serializer),t.removeTarget=e,this.I_(t)}},Rm=class extends Ih{constructor(e,t,n,s,a,c){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,n,s,c),this.serializer=a}get S_(){return this.__>0}start(){this.lastStreamToken=void 0,super.start()}A_(){this.S_&&this.b_([])}f_(e,t){return this.connection.Wo("Write",e,t)}g_(e){return Le(!!e.streamToken),this.lastStreamToken=e.streamToken,Le(!e.writeResults||e.writeResults.length===0),this.listener.D_()}onNext(e){Le(!!e.streamToken),this.lastStreamToken=e.streamToken,this.a_.reset();let t=AM(e.writeResults,e.commitTime),n=Hr(e.commitTime);return this.listener.v_(n,t)}C_(){let e={};e.database=Yp(this.serializer),this.I_(e)}b_(e){let t={streamToken:this.lastStreamToken,writes:e.map(n=>xM(this.serializer,n))};this.I_(t)}};var Pm=class{},Cm=class extends Pm{constructor(e,t,n,s){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer=s,this.F_=!1}M_(){if(this.F_)throw new ne(H.FAILED_PRECONDITION,"The client has already been terminated.")}So(e,t,n,s){return this.M_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([a,c])=>this.connection.So(e,Qp(t,n),s,a,c)).catch(a=>{throw a.name==="FirebaseError"?(a.code===H.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new ne(H.UNKNOWN,a.toString())})}Co(e,t,n,s,a){return this.M_(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([c,h])=>this.connection.Co(e,Qp(t,n),s,c,h,a)).catch(c=>{throw c.name==="FirebaseError"?(c.code===H.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),c):new ne(H.UNKNOWN,c.toString())})}terminate(){this.F_=!0,this.connection.terminate()}},Dm=class{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.x_=0,this.O_=null,this.N_=!0}B_(){this.x_===0&&(this.L_("Unknown"),this.O_=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.O_=null,this.k_("Backend didn't respond within 10 seconds."),this.L_("Offline"),Promise.resolve())))}q_(e){this.state==="Online"?this.L_("Unknown"):(this.x_++,this.x_>=1&&(this.Q_(),this.k_(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.L_("Offline")))}set(e){this.Q_(),this.x_=0,e==="Online"&&(this.N_=!1),this.L_(e)}L_(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}k_(e){let t=`Could not reach Cloud Firestore backend. ${e}
|
|
37
|
+
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.N_?(Pn(t),this.N_=!1):X("OnlineStateTracker",t)}Q_(){this.O_!==null&&(this.O_.cancel(),this.O_=null)}};var ps="RemoteStore",Om=class{constructor(e,t,n,s,a){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.K_=[],this.U_=new Map,this.W_=new Set,this.G_=[],this.z_=a,this.z_.To(c=>{n.enqueueAndForget(async()=>{ms(this)&&(X(ps,"Restarting streams for network reachability change."),await async function(f){let m=fe(f);m.W_.add(4),await Cu(m),m.j_.set("Unknown"),m.W_.delete(4),await Wh(m)}(this))})}),this.j_=new Dm(n,s)}};async function Wh(r){if(ms(r))for(let e of r.G_)await e(!0)}async function Cu(r){for(let e of r.G_)await e(!1)}function DT(r,e){let t=fe(r);t.U_.has(e.targetId)||(t.U_.set(e.targetId,e),fg(t)?hg(t):ea(t).c_()&&lg(t,e))}function cg(r,e){let t=fe(r),n=ea(t);t.U_.delete(e),n.c_()&&OT(t,e),t.U_.size===0&&(n.c_()?n.P_():ms(t)&&t.j_.set("Unknown"))}function lg(r,e){if(r.H_.Ne(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(me.min())>0){let t=r.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(t)}ea(r).y_(e)}function OT(r,e){r.H_.Ne(e),ea(r).w_(e)}function hg(r){r.H_=new Kp({getRemoteKeysForTarget:e=>r.remoteSyncer.getRemoteKeysForTarget(e),lt:e=>r.U_.get(e)||null,it:()=>r.datastore.serializer.databaseId}),ea(r).start(),r.j_.B_()}function fg(r){return ms(r)&&!ea(r).u_()&&r.U_.size>0}function ms(r){return fe(r).W_.size===0}function kT(r){r.H_=void 0}async function WM(r){r.j_.set("Online")}async function HM(r){r.U_.forEach((e,t)=>{lg(r,e)})}async function QM(r,e){kT(r),fg(r)?(r.j_.q_(e),hg(r)):r.j_.set("Unknown")}async function JM(r,e,t){if(r.j_.set("Online"),e instanceof mh&&e.state===2&&e.cause)try{await async function(s,a){let c=a.cause;for(let h of a.targetIds)s.U_.has(h)&&(await s.remoteSyncer.rejectListen(h,c),s.U_.delete(h),s.H_.removeTarget(h))}(r,e)}catch(n){X(ps,"Failed to remove targets %s: %s ",e.targetIds.join(","),n),await xh(r,n)}else if(e instanceof ko?r.H_.We(e):e instanceof ph?r.H_.Ze(e):r.H_.je(e),!t.isEqual(me.min()))try{let n=await CT(r.localStore);t.compareTo(n)>=0&&await function(a,c){let h=a.H_.ot(c);return h.targetChanges.forEach((f,m)=>{if(f.resumeToken.approximateByteSize()>0){let _=a.U_.get(m);_&&a.U_.set(m,_.withResumeToken(f.resumeToken,c))}}),h.targetMismatches.forEach((f,m)=>{let _=a.U_.get(f);if(!_)return;a.U_.set(f,_.withResumeToken(Rt.EMPTY_BYTE_STRING,_.snapshotVersion)),OT(a,f);let E=new wu(_.target,f,m,_.sequenceNumber);lg(a,E)}),a.remoteSyncer.applyRemoteEvent(h)}(r,t)}catch(n){X(ps,"Failed to raise snapshot:",n),await xh(r,n)}}async function xh(r,e,t){if(!Zo(e))throw e;r.W_.add(1),await Cu(r),r.j_.set("Offline"),t||(t=()=>CT(r.localStore)),r.asyncQueue.enqueueRetryable(async()=>{X(ps,"Retrying IndexedDB access"),await t(),r.W_.delete(1),await Wh(r)})}function NT(r,e){return e().catch(t=>xh(r,t,e))}async function Hh(r){let e=fe(r),t=vi(e),n=e.K_.length>0?e.K_[e.K_.length-1].batchId:Zm;for(;YM(e);)try{let s=await qM(e.localStore,n);if(s===null){e.K_.length===0&&t.P_();break}n=s.batchId,XM(e,s)}catch(s){await xh(e,s)}VT(e)&<(e)}function YM(r){return ms(r)&&r.K_.length<10}function XM(r,e){r.K_.push(e);let t=vi(r);t.c_()&&t.S_&&t.b_(e.mutations)}function VT(r){return ms(r)&&!vi(r).u_()&&r.K_.length>0}function LT(r){vi(r).start()}async function ZM(r){vi(r).C_()}async function eF(r){let e=vi(r);for(let t of r.K_)e.b_(t.mutations)}async function tF(r,e,t){let n=r.K_.shift(),s=$p.from(n,e,t);await NT(r,()=>r.remoteSyncer.applySuccessfulWrite(s)),await Hh(r)}async function rF(r,e){e&&vi(r).S_&&await async function(n,s){if(function(c){return gM(c)&&c!==H.ABORTED}(s.code)){let a=n.K_.shift();vi(n).h_(),await NT(n,()=>n.remoteSyncer.rejectFailedWrite(a.batchId,s)),await Hh(n)}}(r,e),VT(r)&<(r)}async function Eb(r,e){let t=fe(r);t.asyncQueue.verifyOperationInProgress(),X(ps,"RemoteStore received new credentials");let n=ms(t);t.W_.add(3),await Cu(t),n&&t.j_.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.W_.delete(3),await Wh(t)}async function nF(r,e){let t=fe(r);e?(t.W_.delete(2),await Wh(t)):e||(t.W_.add(2),await Cu(t),t.j_.set("Unknown"))}function ea(r){return r.J_||(r.J_=function(t,n,s){let a=fe(t);return a.M_(),new Sm(n,a.connection,a.authCredentials,a.appCheckCredentials,a.serializer,s)}(r.datastore,r.asyncQueue,{xo:WM.bind(null,r),No:HM.bind(null,r),Lo:QM.bind(null,r),p_:JM.bind(null,r)}),r.G_.push(async e=>{e?(r.J_.h_(),fg(r)?hg(r):r.j_.set("Unknown")):(await r.J_.stop(),kT(r))})),r.J_}function vi(r){return r.Y_||(r.Y_=function(t,n,s){let a=fe(t);return a.M_(),new Rm(n,a.connection,a.authCredentials,a.appCheckCredentials,a.serializer,s)}(r.datastore,r.asyncQueue,{xo:()=>Promise.resolve(),No:ZM.bind(null,r),Lo:rF.bind(null,r),D_:eF.bind(null,r),v_:tF.bind(null,r)}),r.G_.push(async e=>{e?(r.Y_.h_(),await Hh(r)):(await r.Y_.stop(),r.K_.length>0&&(X(ps,`Stopping write stream with ${r.K_.length} pending writes`),r.K_=[]))})),r.Y_}var km=class r{constructor(e,t,n,s,a){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=s,this.removalCallback=a,this.deferred=new Gr,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(c=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,n,s,a){let c=Date.now()+n,h=new r(e,t,c,s,a);return h.start(n),h}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new ne(H.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}};function dg(r,e){if(Pn("AsyncQueue",`${e}: ${r}`),Zo(r))return new ne(H.UNAVAILABLE,`${e}: ${r}`);throw r}var Ah=class r{static emptySet(e){return new r(e.comparator)}constructor(e){this.comparator=e?(t,n)=>e(t,n)||ce.comparator(t.key,n.key):(t,n)=>ce.comparator(t.key,n.key),this.keyedMap=lu(),this.sortedSet=new Ye(this.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){let t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,n)=>(e(t),!1))}add(e){let t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){let t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof r)||this.size!==e.size)return!1;let t=this.sortedSet.getIterator(),n=e.sortedSet.getIterator();for(;t.hasNext();){let s=t.getNext().key,a=n.getNext().key;if(!s.isEqual(a))return!1}return!0}toString(){let e=[];return this.forEach(t=>{e.push(t.toString())}),e.length===0?"DocumentSet ()":`DocumentSet (
|
|
38
38
|
`+e.join(`
|
|
39
39
|
`)+`
|
|
40
|
-
)`}copy(e,t){let n=new r;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}};var Sh=class{constructor(){this.Z_=new Ye(ce.comparator)}track(e){let t=e.doc.key,n=this.Z_.get(t);n?e.type!==0&&n.type===3?this.Z_=this.Z_.insert(t,e):e.type===3&&n.type!==1?this.Z_=this.Z_.insert(t,{type:n.type,doc:e.doc}):e.type===2&&n.type===2?this.Z_=this.Z_.insert(t,{type:2,doc:e.doc}):e.type===2&&n.type===0?this.Z_=this.Z_.insert(t,{type:0,doc:e.doc}):e.type===1&&n.type===0?this.Z_=this.Z_.remove(t):e.type===1&&n.type===2?this.Z_=this.Z_.insert(t,{type:1,doc:n.doc}):e.type===0&&n.type===1?this.Z_=this.Z_.insert(t,{type:2,doc:e.doc}):ue():this.Z_=this.Z_.insert(t,e)}X_(){let e=[];return this.Z_.inorderTraversal((t,n)=>{e.push(n)}),e}},Ho=class r{constructor(e,t,n,s,a,c,h,f,m){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=s,this.mutatedKeys=a,this.fromCache=c,this.syncStateChanged=h,this.excludesMetadataChanges=f,this.hasCachedResults=m}static fromInitialDocuments(e,t,n,s,a){let c=[];return t.forEach(h=>{c.push({type:0,doc:h})}),new r(e,t,Ah.emptySet(t),c,n,s,!0,!1,a)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&zh(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;let t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(let s=0;s<t.length;s++)if(t[s].type!==n[s].type||!t[s].doc.isEqual(n[s].doc))return!1;return!0}};var Nm=class{constructor(){this.ea=void 0,this.ta=[]}na(){return this.ta.some(e=>e.ra())}},Vm=class{constructor(){this.queries=Eb(),this.onlineState="Unknown",this.ia=new Set}terminate(){(function(t,n){let s=fe(t),a=s.queries;s.queries=Eb(),a.forEach((c,h)=>{for(let f of h.ta)f.onError(n)})})(this,new ne(H.ABORTED,"Firestore shutting down"))}};function Eb(){return new On(r=>aT(r),zh)}async function LT(r,e){let t=fe(r),n=3,s=e.query,a=t.queries.get(s);a?!a.na()&&e.ra()&&(n=2):(a=new Nm,n=e.ra()?0:1);try{switch(n){case 0:a.ea=await t.onListen(s,!0);break;case 1:a.ea=await t.onListen(s,!1);break;case 2:await t.onFirstRemoteStoreListen(s)}}catch(c){let h=dg(c,`Initialization of query '${Po(e.query)}' failed`);return void e.onError(h)}t.queries.set(s,a),a.ta.push(e),e.sa(t.onlineState),a.ea&&e.oa(a.ea)&&pg(t)}async function MT(r,e){let t=fe(r),n=e.query,s=3,a=t.queries.get(n);if(a){let c=a.ta.indexOf(e);c>=0&&(a.ta.splice(c,1),a.ta.length===0?s=e.ra()?0:1:!a.na()&&e.ra()&&(s=2))}switch(s){case 0:return t.queries.delete(n),t.onUnlisten(n,!0);case 1:return t.queries.delete(n),t.onUnlisten(n,!1);case 2:return t.onLastRemoteStoreUnlisten(n);default:return}}function iF(r,e){let t=fe(r),n=!1;for(let s of e){let a=s.query,c=t.queries.get(a);if(c){for(let h of c.ta)h.oa(s)&&(n=!0);c.ea=s}}n&&pg(t)}function sF(r,e,t){let n=fe(r),s=n.queries.get(e);if(s)for(let a of s.ta)a.onError(t);n.queries.delete(e)}function pg(r){r.ia.forEach(e=>{e.next()})}var Lm,Ib;(Ib=Lm||(Lm={}))._a="default",Ib.Cache="cache";var Rh=class{constructor(e,t,n){this.query=e,this.aa=t,this.ua=!1,this.ca=null,this.onlineState="Unknown",this.options=n||{}}oa(e){if(!this.options.includeMetadataChanges){let n=[];for(let s of e.docChanges)s.type!==3&&n.push(s);e=new Ho(e.query,e.docs,e.oldDocs,n,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.ua?this.la(e)&&(this.aa.next(e),t=!0):this.ha(e,this.onlineState)&&(this.Pa(e),t=!0),this.ca=e,t}onError(e){this.aa.error(e)}sa(e){this.onlineState=e;let t=!1;return this.ca&&!this.ua&&this.ha(this.ca,e)&&(this.Pa(this.ca),t=!0),t}ha(e,t){if(!e.fromCache||!this.ra())return!0;let n=t!=="Offline";return(!this.options.Ta||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}la(e){if(e.docChanges.length>0)return!0;let t=this.ca&&this.ca.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}Pa(e){e=Ho.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.ua=!0,this.aa.next(e)}ra(){return this.options.source!==Lm.Cache}};var Ph=class{constructor(e){this.key=e}},Ch=class{constructor(e){this.key=e}},Mm=class{constructor(e,t){this.query=e,this.fa=t,this.ga=null,this.hasCachedResults=!1,this.current=!1,this.pa=xe(),this.mutatedKeys=xe(),this.ya=uT(e),this.wa=new Ah(this.ya)}get Sa(){return this.fa}ba(e,t){let n=t?t.Da:new Sh,s=t?t.wa:this.wa,a=t?t.mutatedKeys:this.mutatedKeys,c=s,h=!1,f=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,m=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(e.inorderTraversal((_,E)=>{let I=s.get(_),k=Gh(this.query,E)?E:null,B=!!I&&this.mutatedKeys.has(I.key),G=!!k&&(k.hasLocalMutations||this.mutatedKeys.has(k.key)&&k.hasCommittedMutations),j=!1;I&&k?I.data.isEqual(k.data)?B!==G&&(n.track({type:3,doc:k}),j=!0):this.va(I,k)||(n.track({type:2,doc:k}),j=!0,(f&&this.ya(k,f)>0||m&&this.ya(k,m)<0)&&(h=!0)):!I&&k?(n.track({type:0,doc:k}),j=!0):I&&!k&&(n.track({type:1,doc:I}),j=!0,(f||m)&&(h=!0)),j&&(k?(c=c.add(k),a=G?a.add(_):a.delete(_)):(c=c.delete(_),a=a.delete(_)))}),this.query.limit!==null)for(;c.size>this.query.limit;){let _=this.query.limitType==="F"?c.last():c.first();c=c.delete(_.key),a=a.delete(_.key),n.track({type:1,doc:_})}return{wa:c,Da:n,ls:h,mutatedKeys:a}}va(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n,s){let a=this.wa;this.wa=e.wa,this.mutatedKeys=e.mutatedKeys;let c=e.Da.X_();c.sort((_,E)=>function(k,B){let G=j=>{switch(j){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return ue()}};return G(k)-G(B)}(_.type,E.type)||this.ya(_.doc,E.doc)),this.Ca(n),s=s!=null&&s;let h=t&&!s?this.Fa():[],f=this.pa.size===0&&this.current&&!s?1:0,m=f!==this.ga;return this.ga=f,c.length!==0||m?{snapshot:new Ho(this.query,e.wa,a,c,e.mutatedKeys,f===0,m,!1,!!n&&n.resumeToken.approximateByteSize()>0),Ma:h}:{Ma:h}}sa(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({wa:this.wa,Da:new Sh,mutatedKeys:this.mutatedKeys,ls:!1},!1)):{Ma:[]}}xa(e){return!this.fa.has(e)&&!!this.wa.has(e)&&!this.wa.get(e).hasLocalMutations}Ca(e){e&&(e.addedDocuments.forEach(t=>this.fa=this.fa.add(t)),e.modifiedDocuments.forEach(t=>{}),e.removedDocuments.forEach(t=>this.fa=this.fa.delete(t)),this.current=e.current)}Fa(){if(!this.current)return[];let e=this.pa;this.pa=xe(),this.wa.forEach(n=>{this.xa(n.key)&&(this.pa=this.pa.add(n.key))});let t=[];return e.forEach(n=>{this.pa.has(n)||t.push(new Ch(n))}),this.pa.forEach(n=>{e.has(n)||t.push(new Ph(n))}),t}Oa(e){this.fa=e.gs,this.pa=xe();let t=this.ba(e.documents);return this.applyChanges(t,!0)}Na(){return Ho.fromInitialDocuments(this.query,this.wa,this.mutatedKeys,this.ga===0,this.hasCachedResults)}},mg="SyncEngine",Fm=class{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}},Um=class{constructor(e){this.key=e,this.Ba=!1}},Bm=class{constructor(e,t,n,s,a,c){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=s,this.currentUser=a,this.maxConcurrentLimboResolutions=c,this.La={},this.ka=new On(h=>aT(h),zh),this.qa=new Map,this.Qa=new Set,this.$a=new Ye(ce.comparator),this.Ka=new Map,this.Ua=new Tu,this.Wa={},this.Ga=new Map,this.za=bu.Un(),this.onlineState="Unknown",this.ja=void 0}get isPrimaryClient(){return this.ja===!0}};async function oF(r,e,t=!0){let n=qT(r),s,a=n.ka.get(e);return a?(n.sharedClientState.addLocalQueryTarget(a.targetId),s=a.view.Na()):s=await FT(n,e,t,!0),s}async function aF(r,e){let t=qT(r);await FT(t,e,!0,!1)}async function FT(r,e,t,n){let s=await zM(r.localStore,Wr(e)),a=s.targetId,c=r.sharedClientState.addLocalQueryTarget(a,t),h;return n&&(h=await uF(r,e,a,c==="current",s.resumeToken)),r.isPrimaryClient&&t&&CT(r.remoteStore,s),h}async function uF(r,e,t,n,s){r.Ha=(E,I,k)=>async function(G,j,J,ee){let re=j.view.ba(J);re.ls&&(re=await vb(G.localStore,j.query,!1).then(({documents:C})=>j.view.ba(C,re)));let le=ee&&ee.targetChanges.get(j.targetId),de=ee&&ee.targetMismatches.get(j.targetId)!=null,ie=j.view.applyChanges(re,G.isPrimaryClient,le,de);return Ab(G,j.targetId,ie.Ma),ie.snapshot}(r,E,I,k);let a=await vb(r.localStore,e,!0),c=new Mm(e,a.gs),h=c.ba(a.documents),f=vu.createSynthesizedTargetChangeForCurrentChange(t,n&&r.onlineState!=="Offline",s),m=c.applyChanges(h,r.isPrimaryClient,f);Ab(r,t,m.Ma);let _=new Fm(e,t,c);return r.ka.set(e,_),r.qa.has(t)?r.qa.get(t).push(e):r.qa.set(t,[e]),m.snapshot}async function cF(r,e,t){let n=fe(r),s=n.ka.get(e),a=n.qa.get(s.targetId);if(a.length>1)return n.qa.set(s.targetId,a.filter(c=>!zh(c,e))),void n.ka.delete(e);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(s.targetId),n.sharedClientState.isActiveQueryTarget(s.targetId)||await wm(n.localStore,s.targetId,!1).then(()=>{n.sharedClientState.clearQueryState(s.targetId),t&&cg(n.remoteStore,s.targetId),jm(n,s.targetId)}).catch(Xo)):(jm(n,s.targetId),await wm(n.localStore,s.targetId,!0))}async function lF(r,e){let t=fe(r),n=t.ka.get(e),s=t.qa.get(n.targetId);t.isPrimaryClient&&s.length===1&&(t.sharedClientState.removeLocalQueryTarget(n.targetId),cg(t.remoteStore,n.targetId))}async function hF(r,e,t){let n=yF(r);try{let s=await function(c,h){let f=fe(c),m=wt.now(),_=h.reduce((k,B)=>k.add(B.key),xe()),E,I;return f.persistence.runTransaction("Locally write mutations","readwrite",k=>{let B=kn(),G=xe();return f.ds.getEntries(k,_).next(j=>{B=j,B.forEach((J,ee)=>{ee.isValidDocument()||(G=G.add(J))})}).next(()=>f.localDocuments.getOverlayedDocuments(k,B)).next(j=>{E=j;let J=[];for(let ee of h){let re=mM(ee,E.get(ee.key).overlayedDocument);re!=null&&J.push(new Xr(ee.key,re,tT(re.value.mapValue),_i.exists(!0)))}return f.mutationQueue.addMutationBatch(k,m,J,h)}).next(j=>{I=j;let J=j.applyToLocalDocumentSet(E,G);return f.documentOverlayCache.saveOverlays(k,j.batchId,J)})}).then(()=>({batchId:I.batchId,changes:lT(E)}))}(n.localStore,e);n.sharedClientState.addPendingMutation(s.batchId),function(c,h,f){let m=c.Wa[c.currentUser.toKey()];m||(m=new Ye(Re)),m=m.insert(h,f),c.Wa[c.currentUser.toKey()]=m}(n,s.batchId,t),await Du(n,s.changes),await Hh(n.remoteStore)}catch(s){let a=dg(s,"Failed to persist write");t.reject(a)}}async function UT(r,e){let t=fe(r);try{let n=await jM(t.localStore,e);e.targetChanges.forEach((s,a)=>{let c=t.Ka.get(a);c&&(Le(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1),s.addedDocuments.size>0?c.Ba=!0:s.modifiedDocuments.size>0?Le(c.Ba):s.removedDocuments.size>0&&(Le(c.Ba),c.Ba=!1))}),await Du(t,n,e)}catch(n){await Xo(n)}}function xb(r,e,t){let n=fe(r);if(n.isPrimaryClient&&t===0||!n.isPrimaryClient&&t===1){let s=[];n.ka.forEach((a,c)=>{let h=c.view.sa(e);h.snapshot&&s.push(h.snapshot)}),function(c,h){let f=fe(c);f.onlineState=h;let m=!1;f.queries.forEach((_,E)=>{for(let I of E.ta)I.sa(h)&&(m=!0)}),m&&pg(f)}(n.eventManager,e),s.length&&n.La.p_(s),n.onlineState=e,n.isPrimaryClient&&n.sharedClientState.setOnlineState(e)}}async function fF(r,e,t){let n=fe(r);n.sharedClientState.updateQueryState(e,"rejected",t);let s=n.Ka.get(e),a=s&&s.key;if(a){let c=new Ye(ce.comparator);c=c.insert(a,Sr.newNoDocument(a,me.min()));let h=xe().add(a),f=new dh(me.min(),new Map,new Ye(Re),c,h);await UT(n,f),n.$a=n.$a.remove(a),n.Ka.delete(e),gg(n)}else await wm(n.localStore,e,!1).then(()=>jm(n,e,t)).catch(Xo)}async function dF(r,e){let t=fe(r),n=e.batch.batchId;try{let s=await BM(t.localStore,e);jT(t,n,null),BT(t,n),t.sharedClientState.updateMutationState(n,"acknowledged"),await Du(t,s)}catch(s){await Xo(s)}}async function pF(r,e,t){let n=fe(r);try{let s=await function(c,h){let f=fe(c);return f.persistence.runTransaction("Reject batch","readwrite-primary",m=>{let _;return f.mutationQueue.lookupMutationBatch(m,h).next(E=>(Le(E!==null),_=E.keys(),f.mutationQueue.removeMutationBatch(m,E))).next(()=>f.mutationQueue.performConsistencyCheck(m)).next(()=>f.documentOverlayCache.removeOverlaysForBatchId(m,_,h)).next(()=>f.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(m,_)).next(()=>f.localDocuments.getDocuments(m,_))})}(n.localStore,e);jT(n,e,t),BT(n,e),n.sharedClientState.updateMutationState(e,"rejected",t),await Du(n,s)}catch(s){await Xo(s)}}function BT(r,e){(r.Ga.get(e)||[]).forEach(t=>{t.resolve()}),r.Ga.delete(e)}function jT(r,e,t){let n=fe(r),s=n.Wa[n.currentUser.toKey()];if(s){let a=s.get(e);a&&(t?a.reject(t):a.resolve(),s=s.remove(e)),n.Wa[n.currentUser.toKey()]=s}}function jm(r,e,t=null){r.sharedClientState.removeLocalQueryTarget(e);for(let n of r.qa.get(e))r.ka.delete(n),t&&r.La.Ja(n,t);r.qa.delete(e),r.isPrimaryClient&&r.Ua.br(e).forEach(n=>{r.Ua.containsKey(n)||$T(r,n)})}function $T(r,e){r.Qa.delete(e.path.canonicalString());let t=r.$a.get(e);t!==null&&(cg(r.remoteStore,t),r.$a=r.$a.remove(e),r.Ka.delete(t),gg(r))}function Ab(r,e,t){for(let n of t)n instanceof Ph?(r.Ua.addReference(n.key,e),mF(r,n)):n instanceof Ch?(X(mg,"Document no longer in limbo: "+n.key),r.Ua.removeReference(n.key,e),r.Ua.containsKey(n.key)||$T(r,n.key)):ue()}function mF(r,e){let t=e.key,n=t.path.canonicalString();r.$a.get(t)||r.Qa.has(n)||(X(mg,"New document in limbo: "+t),r.Qa.add(n),gg(r))}function gg(r){for(;r.Qa.size>0&&r.$a.size<r.maxConcurrentLimboResolutions;){let e=r.Qa.values().next().value;r.Qa.delete(e);let t=new ce(ot.fromString(e)),n=r.za.next();r.Ka.set(n,new Um(t)),r.$a=r.$a.insert(t,n),CT(r.remoteStore,new wu(Wr(qh(t.path)),n,"TargetPurposeLimboResolution",Mo.ae))}}async function Du(r,e,t){let n=fe(r),s=[],a=[],c=[];n.ka.isEmpty()||(n.ka.forEach((h,f)=>{c.push(n.Ha(f,e,t).then(m=>{var _;if((m||t)&&n.isPrimaryClient){let E=m?!m.fromCache:(_=t==null?void 0:t.targetChanges.get(f.targetId))===null||_===void 0?void 0:_.current;n.sharedClientState.updateQueryState(f.targetId,E?"current":"not-current")}if(m){s.push(m);let E=gm.Yi(f.targetId,m);a.push(E)}}))}),await Promise.all(c),n.La.p_(s),await async function(f,m){let _=fe(f);try{await _.persistence.runTransaction("notifyLocalViewChanges","readwrite",E=>W.forEach(m,I=>W.forEach(I.Hi,k=>_.persistence.referenceDelegate.addReference(E,I.targetId,k)).next(()=>W.forEach(I.Ji,k=>_.persistence.referenceDelegate.removeReference(E,I.targetId,k)))))}catch(E){if(!Zo(E))throw E;X(ug,"Failed to update sequence numbers: "+E)}for(let E of m){let I=E.targetId;if(!E.fromCache){let k=_.Ts.get(I),B=k.snapshotVersion,G=k.withLastLimboFreeSnapshotVersion(B);_.Ts=_.Ts.insert(I,G)}}}(n.localStore,a))}async function gF(r,e){let t=fe(r);if(!t.currentUser.isEqual(e)){X(mg,"User change. New user:",e.toKey());let n=await RT(t.localStore,e);t.currentUser=e,function(a,c){a.Ga.forEach(h=>{h.forEach(f=>{f.reject(new ne(H.CANCELLED,c))})}),a.Ga.clear()}(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,n.removedBatchIds,n.addedBatchIds),await Du(t,n.Rs)}}function _F(r,e){let t=fe(r),n=t.Ka.get(e);if(n&&n.Ba)return xe().add(n.key);{let s=xe(),a=t.qa.get(e);if(!a)return s;for(let c of a){let h=t.ka.get(c);s=s.unionWith(h.view.Sa)}return s}}function qT(r){let e=fe(r);return e.remoteStore.remoteSyncer.applyRemoteEvent=UT.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=_F.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=fF.bind(null,e),e.La.p_=iF.bind(null,e.eventManager),e.La.Ja=sF.bind(null,e.eventManager),e}function yF(r){let e=fe(r);return e.remoteStore.remoteSyncer.applySuccessfulWrite=dF.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=pF.bind(null,e),e}var Qo=class{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=Kh(e.databaseInfo.databaseId),this.sharedClientState=this.Za(e),this.persistence=this.Xa(e),await this.persistence.start(),this.localStore=this.eu(e),this.gcScheduler=this.tu(e,this.localStore),this.indexBackfillerScheduler=this.nu(e,this.localStore)}tu(e,t){return null}nu(e,t){return null}eu(e){return UM(this.persistence,new ym,e.initialUser,this.serializer)}Xa(e){return new vh(mm.ri,this.serializer)}Za(e){return new bm}async terminate(){var e,t;(e=this.gcScheduler)===null||e===void 0||e.stop(),(t=this.indexBackfillerScheduler)===null||t===void 0||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}};Qo.provider={build:()=>new Qo};var $m=class extends Qo{constructor(e){super(),this.cacheSizeBytes=e}tu(e,t){Le(this.persistence.referenceDelegate instanceof wh);let n=this.persistence.referenceDelegate.garbageCollector;return new rm(n,e.asyncQueue,t)}Xa(e){let t=this.cacheSizeBytes!==void 0?lr.withCacheSize(this.cacheSizeBytes):lr.DEFAULT;return new vh(n=>wh.ri(n,t),this.serializer)}};var Eu=class{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=n=>xb(this.syncEngine,n,1),this.remoteStore.remoteSyncer.handleCredentialChange=gF.bind(null,this.syncEngine),await nF(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new Vm}()}createDatastore(e){let t=Kh(e.databaseInfo.databaseId),n=function(a){return new Am(a)}(e.databaseInfo);return function(a,c,h,f){return new Cm(a,c,h,f)}(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return function(n,s,a,c,h){return new Om(n,s,a,c,h)}(this.localStore,this.datastore,e.asyncQueue,t=>xb(this.syncEngine,t,0),function(){return Th.D()?new Th:new Tm}())}createSyncEngine(e,t){return function(s,a,c,h,f,m,_){let E=new Bm(s,a,c,h,f,m);return _&&(E.ja=!0),E}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await async function(s){let a=fe(s);X(ps,"RemoteStore shutting down."),a.W_.add(5),await Cu(a),a.z_.shutdown(),a.j_.set("Unknown")}(this.remoteStore),(e=this.datastore)===null||e===void 0||e.terminate(),(t=this.eventManager)===null||t===void 0||t.terminate()}};Eu.provider={build:()=>new Eu};var Dh=class{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.iu(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.iu(this.observer.error,e):Pn("Uncaught Error in snapshot listener:",e.toString()))}su(){this.muted=!0}iu(e,t){setTimeout(()=>{this.muted||e(t)},0)}};var wi="FirestoreClient",qm=class{constructor(e,t,n,s,a){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=s,this.user=_t.UNAUTHENTICATED,this.clientId=sh.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=a,this.authCredentials.start(n,async c=>{X(wi,"Received user=",c.uid),await this.authCredentialListener(c),this.user=c}),this.appCheckCredentials.start(n,c=>(X(wi,"Received new app check token=",c),this.appCheckCredentialListener(c,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(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();let e=new Gr;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){let n=dg(t,"Failed to shutdown persistence");e.reject(n)}}),e.promise}};async function gp(r,e){r.asyncQueue.verifyOperationInProgress(),X(wi,"Initializing OfflineComponentProvider");let t=r.configuration;await e.initialize(t);let n=t.initialUser;r.setCredentialChangeListener(async s=>{n.isEqual(s)||(await RT(e.localStore,s),n=s)}),e.persistence.setDatabaseDeletedListener(()=>r.terminate()),r._offlineComponents=e}async function Sb(r,e){r.asyncQueue.verifyOperationInProgress();let t=await vF(r);X(wi,"Initializing OnlineComponentProvider"),await e.initialize(t,r.configuration),r.setCredentialChangeListener(n=>Tb(e.remoteStore,n)),r.setAppCheckTokenChangeListener((n,s)=>Tb(e.remoteStore,s)),r._onlineComponents=e}async function vF(r){if(!r._offlineComponents)if(r._uninitializedComponentsProvider){X(wi,"Using user provided OfflineComponentProvider");try{await gp(r,r._uninitializedComponentsProvider._offline)}catch(e){let t=e;if(!function(s){return s.name==="FirebaseError"?s.code===H.FAILED_PRECONDITION||s.code===H.UNIMPLEMENTED:!(typeof DOMException!="undefined"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11}(t))throw t;Vo("Error using user provided cache. Falling back to memory cache: "+t),await gp(r,new Qo)}}else X(wi,"Using default OfflineComponentProvider"),await gp(r,new $m(void 0));return r._offlineComponents}async function zT(r){return r._onlineComponents||(r._uninitializedComponentsProvider?(X(wi,"Using user provided OnlineComponentProvider"),await Sb(r,r._uninitializedComponentsProvider._online)):(X(wi,"Using default OnlineComponentProvider"),await Sb(r,new Eu))),r._onlineComponents}function wF(r){return zT(r).then(e=>e.syncEngine)}async function zm(r){let e=await zT(r),t=e.eventManager;return t.onListen=oF.bind(null,e.syncEngine),t.onUnlisten=cF.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=aF.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=lF.bind(null,e.syncEngine),t}function bF(r,e,t={}){let n=new Gr;return r.asyncQueue.enqueueAndForget(async()=>function(a,c,h,f,m){let _=new Dh({next:I=>{_.su(),c.enqueueAndForget(()=>MT(a,E));let k=I.docs.has(h);!k&&I.fromCache?m.reject(new ne(H.UNAVAILABLE,"Failed to get document because the client is offline.")):k&&I.fromCache&&f&&f.source==="server"?m.reject(new ne(H.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.)')):m.resolve(I)},error:I=>m.reject(I)}),E=new Rh(qh(h.path),_,{includeMetadataChanges:!0,Ta:!0});return LT(a,E)}(await zm(r),r.asyncQueue,e,t,n)),n.promise}function GT(r){let e={};return r.timeoutSeconds!==void 0&&(e.timeoutSeconds=r.timeoutSeconds),e}var Rb=new Map;function TF(r,e,t){if(!t)throw new ne(H.INVALID_ARGUMENT,`Function ${r}() cannot be called with an empty ${e}.`)}function EF(r,e,t,n){if(e===!0&&n===!0)throw new ne(H.INVALID_ARGUMENT,`${r} and ${t} cannot be used together.`)}function Pb(r){if(!ce.isDocumentKey(r))throw new ne(H.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${r} has ${r.length}.`)}function _g(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";{let e=function(n){return n.constructor?n.constructor.name:null}(r);return e?`a custom ${e} object`:"an object"}}return typeof r=="function"?"a function":ue()}function Qr(r,e){if("_delegate"in r&&(r=r._delegate),!(r instanceof e)){if(e.name===r.constructor.name)throw new ne(H.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{let t=_g(r);throw new ne(H.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return r}var KT="firestore.googleapis.com",Cb=!0,Oh=class{constructor(e){var t,n;if(e.host===void 0){if(e.ssl!==void 0)throw new ne(H.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=KT,this.ssl=Cb}else this.host=e.host,this.ssl=(t=e.ssl)!==null&&t!==void 0?t:Cb;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=ST;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<LM)throw new ne(H.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}EF("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=GT((n=e.experimentalLongPollingOptions)!==null&&n!==void 0?n:{}),function(a){if(a.timeoutSeconds!==void 0){if(isNaN(a.timeoutSeconds))throw new ne(H.INVALID_ARGUMENT,`invalid long polling timeout: ${a.timeoutSeconds} (must not be NaN)`);if(a.timeoutSeconds<5)throw new ne(H.INVALID_ARGUMENT,`invalid long polling timeout: ${a.timeoutSeconds} (minimum allowed value is 5)`);if(a.timeoutSeconds>30)throw new ne(H.INVALID_ARGUMENT,`invalid long polling timeout: ${a.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(n,s){return n.timeoutSeconds===s.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}},Iu=class{constructor(e,t,n,s){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=n,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Oh({}),this._settingsFrozen=!1,this._terminateTask="notTerminated"}get app(){if(!this._app)throw new ne(H.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(e){if(this._settingsFrozen)throw new ne(H.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 Oh(e),e.credentials!==void 0&&(this._authCredentials=function(n){if(!n)return new _p;switch(n.type){case"firstParty":return new bp(n.sessionIndex||"0",n.iamToken||null,n.authTokenFactory||null);case"provider":return n.client;default:throw new ne(H.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_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(t){let n=Rb.get(t);n&&(X("ComponentProvider","Removing Datastore"),Rb.delete(t),n.terminate())}(this),Promise.resolve()}};function IF(r,e,t,n={}){var s;let a=(r=Qr(r,Iu))._getSettings(),c=`${e}:${t}`;if(a.host!==KT&&a.host!==c&&Vo("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),r._setSettings(Object.assign(Object.assign({},a),{host:c,ssl:!1})),n.mockUserToken){let h,f;if(typeof n.mockUserToken=="string")h=n.mockUserToken,f=_t.MOCK_USER;else{h=T0(n.mockUserToken,(s=r._app)===null||s===void 0?void 0:s.options.projectId);let m=n.mockUserToken.sub||n.mockUserToken.user_id;if(!m)throw new ne(H.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");f=new _t(m)}r._authCredentials=new yp(new nh(h,f))}}var kh=class r{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new r(this.firestore,e,this._query)}},zt=class r{constructor(e,t,n){this.converter=t,this._key=n,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new xu(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new r(this.firestore,e,this._key)}},xu=class r extends kh{constructor(e,t,n){super(e,t,qh(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){let e=this._path.popLast();return e.isEmpty()?null:new zt(this.firestore,null,new ce(e))}withConverter(e){return new r(this.firestore,e,this._path)}};function Ou(r,e,...t){if(r=In(r),arguments.length===1&&(e=sh.newId()),TF("doc","path",e),r instanceof Iu){let n=ot.fromString(e,...t);return Pb(n),new zt(r,null,new ce(n))}{if(!(r instanceof zt||r instanceof xu))throw new ne(H.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let n=r._path.child(ot.fromString(e,...t));return Pb(n),new zt(r.firestore,r instanceof xu?r.converter:null,new ce(n))}}var Db="AsyncQueue",Nh=class{constructor(e=Promise.resolve()){this.Vu=[],this.mu=!1,this.fu=[],this.gu=null,this.pu=!1,this.yu=!1,this.wu=[],this.a_=new Eh(this,"async_queue_retry"),this.Su=()=>{let n=mp();n&&X(Db,"Visibility state changed to "+n.visibilityState),this.a_.t_()},this.bu=e;let t=mp();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this.Su)}get isShuttingDown(){return this.mu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.Du(),this.vu(e)}enterRestrictedMode(e){if(!this.mu){this.mu=!0,this.yu=e||!1;let t=mp();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this.Su)}}enqueue(e){if(this.Du(),this.mu)return new Promise(()=>{});let t=new Gr;return this.vu(()=>this.mu&&this.yu?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Vu.push(e),this.Cu()))}async Cu(){if(this.Vu.length!==0){try{await this.Vu[0](),this.Vu.shift(),this.a_.reset()}catch(e){if(!Zo(e))throw e;X(Db,"Operation failed with retryable error: "+e)}this.Vu.length>0&&this.a_.Xo(()=>this.Cu())}}vu(e){let t=this.bu.then(()=>(this.pu=!0,e().catch(n=>{this.gu=n,this.pu=!1;let s=function(c){let h=c.message||"";return c.stack&&(h=c.stack.includes(c.message)?c.stack:c.message+`
|
|
41
|
-
`+c.stack),h}(n);throw Pn("INTERNAL UNHANDLED ERROR: ",s),n}).then(n=>(this.pu=!1,n))));return this.bu=t,t}enqueueAfterDelay(e,t,n){this.Du(),this.wu.indexOf(e)>-1&&(t=0);let s=km.createAndSchedule(this,e,t,n,a=>this.Fu(a));return this.fu.push(s),s}Du(){this.gu&&ue()}verifyOperationInProgress(){}async Mu(){let e;do e=this.bu,await e;while(e!==this.bu)}xu(e){for(let t of this.fu)if(t.timerId===e)return!0;return!1}Ou(e){return this.Mu().then(()=>{this.fu.sort((t,n)=>t.targetTimeMs-n.targetTimeMs);for(let t of this.fu)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.Mu()})}Nu(e){this.wu.push(e)}Fu(e){let t=this.fu.indexOf(e);this.fu.splice(t,1)}};function Ob(r){return function(t,n){if(typeof t!="object"||t===null)return!1;let s=t;for(let a of n)if(a in s&&typeof s[a]=="function")return!0;return!1}(r,["next","error","complete"])}var bi=class extends Iu{constructor(e,t,n,s){super(e,t,n,s),this.type="firestore",this._queue=new Nh,this._persistenceKey=(s==null?void 0:s.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new Nh(e),this._firestoreClient=void 0,await e}}};function WT(r,e){let t=typeof r=="object"?r:j0(),n=typeof r=="string"?r:e||ch,s=F0(t,"firestore").getImmediate({identifier:n});if(!s._initialized){let a=b0("firestore");a&&IF(s,...a)}return s}function yg(r){if(r._terminated)throw new ne(H.FAILED_PRECONDITION,"The client has already been terminated.");return r._firestoreClient||xF(r),r._firestoreClient}function xF(r){var e,t,n;let s=r._freezeSettings(),a=function(h,f,m,_){return new xp(h,f,m,_.host,_.ssl,_.experimentalForceLongPolling,_.experimentalAutoDetectLongPolling,GT(_.experimentalLongPollingOptions),_.useFetchStreams)}(r._databaseId,((e=r._app)===null||e===void 0?void 0:e.options.appId)||"",r._persistenceKey,s);r._componentsProvider||!((t=s.localCache)===null||t===void 0)&&t._offlineComponentProvider&&(!((n=s.localCache)===null||n===void 0)&&n._onlineComponentProvider)&&(r._componentsProvider={_offline:s.localCache._offlineComponentProvider,_online:s.localCache._onlineComponentProvider}),r._firestoreClient=new qm(r._authCredentials,r._appCheckCredentials,r._queue,a,r._componentsProvider&&function(h){let f=h==null?void 0:h._online.build();return{_offline:h==null?void 0:h._offline.build(f),_online:f}}(r._componentsProvider))}var Au=class r{constructor(e){this._byteString=e}static fromBase64String(e){try{return new r(Rt.fromBase64String(e))}catch(t){throw new ne(H.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new r(Rt.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}};var Jo=class{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new ne(H.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new tr(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}};var Su=class{constructor(e){this._methodName=e}};var Ru=class{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new ne(H.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new ne(H.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(e){return Re(this._lat,e._lat)||Re(this._long,e._long)}};var Pu=class{constructor(e){this._values=(e||[]).map(t=>t)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(n,s){if(n.length!==s.length)return!1;for(let a=0;a<n.length;++a)if(n[a]!==s[a])return!1;return!0}(this._values,e._values)}};var AF=/^__.*__$/,Gm=class{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return this.fieldMask!==null?new Xr(e,this.data,this.fieldMask,t,this.fieldTransforms):new ds(e,this.data,t,this.fieldTransforms)}},Vh=class{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new Xr(e,this.data,this.fieldMask,t,this.fieldTransforms)}};function HT(r){switch(r){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw ue()}}var Km=class r{constructor(e,t,n,s,a,c){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=s,a===void 0&&this.Bu(),this.fieldTransforms=a||[],this.fieldMask=c||[]}get path(){return this.settings.path}get Lu(){return this.settings.Lu}ku(e){return new r(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}qu(e){var t;let n=(t=this.path)===null||t===void 0?void 0:t.child(e),s=this.ku({path:n,Qu:!1});return s.$u(e),s}Ku(e){var t;let n=(t=this.path)===null||t===void 0?void 0:t.child(e),s=this.ku({path:n,Qu:!1});return s.Bu(),s}Uu(e){return this.ku({path:void 0,Qu:!0})}Wu(e){return Mh(e,this.settings.methodName,this.settings.Gu||!1,this.path,this.settings.zu)}contains(e){return this.fieldMask.find(t=>e.isPrefixOf(t))!==void 0||this.fieldTransforms.find(t=>e.isPrefixOf(t.field))!==void 0}Bu(){if(this.path)for(let e=0;e<this.path.length;e++)this.$u(this.path.get(e))}$u(e){if(e.length===0)throw this.Wu("Document fields must not be empty");if(HT(this.Lu)&&AF.test(e))throw this.Wu('Document fields cannot begin and end with "__"')}},Wm=class{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||Kh(e)}ju(e,t,n,s=!1){return new Km({Lu:e,methodName:t,zu:n,path:tr.emptyPath(),Qu:!1,Gu:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}};function QT(r){let e=r._freezeSettings(),t=Kh(r._databaseId);return new Wm(r._databaseId,!!e.ignoreUndefinedProperties,t)}function SF(r,e,t,n,s,a={}){let c=r.ju(a.merge||a.mergeFields?2:0,e,t,s);vg("Data must be an object, but it was:",c,n);let h=JT(n,c),f,m;if(a.merge)f=new hr(c.fieldMask),m=c.fieldTransforms;else if(a.mergeFields){let _=[];for(let E of a.mergeFields){let I=Hm(e,E,t);if(!c.contains(I))throw new ne(H.INVALID_ARGUMENT,`Field '${I}' is specified in your field mask but missing from your input data.`);XT(_,I)||_.push(I)}f=new hr(_),m=c.fieldTransforms.filter(E=>f.covers(E.field))}else f=null,m=c.fieldTransforms;return new Gm(new er(h),f,m)}var Lh=class r extends Su{_toFieldTransform(e){if(e.Lu!==2)throw e.Lu===1?e.Wu(`${this._methodName}() can only appear at the top level of your update data`):e.Wu(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof r}};function RF(r,e,t,n){let s=r.ju(1,e,t);vg("Data must be an object, but it was:",s,n);let a=[],c=er.empty();Ti(n,(f,m)=>{let _=wg(e,f,t);m=In(m);let E=s.Ku(_);if(m instanceof Lh)a.push(_);else{let I=Qh(m,E);I!=null&&(a.push(_),c.set(_,I))}});let h=new hr(a);return new Vh(c,h,s.fieldTransforms)}function PF(r,e,t,n,s,a){let c=r.ju(1,e,t),h=[Hm(e,n,t)],f=[s];if(a.length%2!=0)throw new ne(H.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let I=0;I<a.length;I+=2)h.push(Hm(e,a[I])),f.push(a[I+1]);let m=[],_=er.empty();for(let I=h.length-1;I>=0;--I)if(!XT(m,h[I])){let k=h[I],B=f[I];B=In(B);let G=c.Ku(k);if(B instanceof Lh)m.push(k);else{let j=Qh(B,G);j!=null&&(m.push(k),_.set(k,j))}}let E=new hr(m);return new Vh(_,E,c.fieldTransforms)}function Qh(r,e){if(YT(r=In(r)))return vg("Unsupported field value:",e,r),JT(r,e);if(r instanceof Su)return function(n,s){if(!HT(s.Lu))throw s.Wu(`${n._methodName}() can only be used with update() and set()`);if(!s.path)throw s.Wu(`${n._methodName}() is not currently supported inside arrays`);let a=n._toFieldTransform(s);a&&s.fieldTransforms.push(a)}(r,e),null;if(r===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),r instanceof Array){if(e.settings.Qu&&e.Lu!==4)throw e.Wu("Nested arrays are not supported");return function(n,s){let a=[],c=0;for(let h of n){let f=Qh(h,s.Uu(c));f==null&&(f={nullValue:"NULL_VALUE"}),a.push(f),c++}return{arrayValue:{values:a}}}(r,e)}return function(n,s){if((n=In(n))===null)return{nullValue:"NULL_VALUE"};if(typeof n=="number")return lM(s.serializer,n);if(typeof n=="boolean")return{booleanValue:n};if(typeof n=="string")return{stringValue:n};if(n instanceof Date){let a=wt.fromDate(n);return{timestampValue:_h(s.serializer,a)}}if(n instanceof wt){let a=new wt(n.seconds,1e3*Math.floor(n.nanoseconds/1e3));return{timestampValue:_h(s.serializer,a)}}if(n instanceof Ru)return{geoPointValue:{latitude:n.latitude,longitude:n.longitude}};if(n instanceof Au)return{bytesValue:wT(s.serializer,n._byteString)};if(n instanceof zt){let a=s.databaseId,c=n.firestore._databaseId;if(!c.isEqual(a))throw s.Wu(`Document reference is for database ${c.projectId}/${c.database} but should be for database ${a.projectId}/${a.database}`);return{referenceValue:ag(n.firestore._databaseId||s.databaseId,n._key.path)}}if(n instanceof Pu)return function(c,h){return{mapValue:{fields:{[tg]:{stringValue:rg},[Fo]:{arrayValue:{values:c.toArray().map(m=>{if(typeof m!="number")throw h.Wu("VectorValues must only contain numeric values.");return og(h.serializer,m)})}}}}}}(n,s);throw s.Wu(`Unsupported field value: ${_g(n)}`)}(r,e)}function JT(r,e){let t={};return Wb(r)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):Ti(r,(n,s)=>{let a=Qh(s,e.qu(n));a!=null&&(t[n]=a)}),{mapValue:{fields:t}}}function YT(r){return!(typeof r!="object"||r===null||r instanceof Array||r instanceof Date||r instanceof wt||r instanceof Ru||r instanceof Au||r instanceof zt||r instanceof Su||r instanceof Pu)}function vg(r,e,t){if(!YT(t)||!function(s){return typeof s=="object"&&s!==null&&(Object.getPrototypeOf(s)===Object.prototype||Object.getPrototypeOf(s)===null)}(t)){let n=_g(t);throw n==="an object"?e.Wu(r+" a custom object"):e.Wu(r+" "+n)}}function Hm(r,e,t){if((e=In(e))instanceof Jo)return e._internalPath;if(typeof e=="string")return wg(r,e);throw Mh("Field path arguments must be of type string or ",r,!1,void 0,t)}var CF=new RegExp("[~\\*/\\[\\]]");function wg(r,e,t){if(e.search(CF)>=0)throw Mh(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,r,!1,void 0,t);try{return new Jo(...e.split("."))._internalPath}catch{throw Mh(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,r,!1,void 0,t)}}function Mh(r,e,t,n,s){let a=n&&!n.isEmpty(),c=s!==void 0,h=`Function ${e}() called with invalid data`;t&&(h+=" (via `toFirestore()`)"),h+=". ";let f="";return(a||c)&&(f+=" (found",a&&(f+=` in field ${n}`),c&&(f+=` in document ${s}`),f+=")"),new ne(H.INVALID_ARGUMENT,h+r+f)}function XT(r,e){return r.some(t=>t.isEqual(e))}var Fh=class{constructor(e,t,n,s,a){this._firestore=e,this._userDataWriter=t,this._key=n,this._document=s,this._converter=a}get id(){return this._key.path.lastSegment()}get ref(){return new zt(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){let e=new Qm(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){let t=this._document.data.field(ZT("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}},Qm=class extends Fh{data(){return super.data()}};function ZT(r,e){return typeof e=="string"?wg(r,e):e instanceof Jo?e._internalPath:e._delegate._internalPath}function DF(r){if(r.limitType==="L"&&r.explicitOrderBy.length===0)throw new ne(H.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}var Jm=class{convertValue(e,t="none"){switch(yi(e)){case 0:return null;case 1:return e.booleanValue;case 2:return Ge(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Dn(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw ue()}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){let n={};return Ti(e,(s,a)=>{n[s]=this.convertValue(a,t)}),n}convertVectorValue(e){var t,n,s;let a=(s=(n=(t=e.fields)===null||t===void 0?void 0:t[Fo].arrayValue)===null||n===void 0?void 0:n.values)===null||s===void 0?void 0:s.map(c=>Ge(c.doubleValue));return new Pu(a)}convertGeoPoint(e){return new Ru(Ge(e.latitude),Ge(e.longitude))}convertArray(e,t){return(e.values||[]).map(n=>this.convertValue(n,t))}convertServerTimestamp(e,t){switch(t){case"previous":let n=$h(e);return n==null?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(_u(e));default:return null}}convertTimestamp(e){let t=Cn(e);return new wt(t.seconds,t.nanos)}convertDocumentKey(e,t){let n=ot.fromString(e);Le(AT(n));let s=new lh(n.get(1),n.get(3)),a=new ce(n.popFirst(5));return s.isEqual(t)||Pn(`Document ${a} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),a}};function OF(r,e,t){let n;return n=r?t&&(t.merge||t.mergeFields)?r.toFirestore(e,t):r.toFirestore(e):e,n}var us=class{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}},Uh=class extends Fh{constructor(e,t,n,s,a,c){super(e,t,n,s,c),this._firestore=e,this._firestoreImpl=e,this.metadata=a}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){let t=new No(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){let n=this._document.data.field(ZT("DocumentSnapshot.get",e));if(n!==null)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}},No=class extends Uh{data(e={}){return super.data(e)}},Ym=class{constructor(e,t,n,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new us(s.hasPendingWrites,s.fromCache),this.query=n}get docs(){let e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach(n=>{e.call(t,new No(this._firestore,this._userDataWriter,n.key,n,new us(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){let t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new ne(H.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(s,a){if(s._snapshot.oldDocs.isEmpty()){let c=0;return s._snapshot.docChanges.map(h=>{let f=new No(s._firestore,s._userDataWriter,h.doc.key,h.doc,new us(s._snapshot.mutatedKeys.has(h.doc.key),s._snapshot.fromCache),s.query.converter);return h.doc,{type:"added",doc:f,oldIndex:-1,newIndex:c++}})}{let c=s._snapshot.oldDocs;return s._snapshot.docChanges.filter(h=>a||h.type!==3).map(h=>{let f=new No(s._firestore,s._userDataWriter,h.doc.key,h.doc,new us(s._snapshot.mutatedKeys.has(h.doc.key),s._snapshot.fromCache),s.query.converter),m=-1,_=-1;return h.type!==0&&(m=c.indexOf(h.doc.key),c=c.delete(h.doc.key)),h.type!==1&&(c=c.add(h.doc),_=c.indexOf(h.doc.key)),{type:kF(h.type),doc:f,oldIndex:m,newIndex:_}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}};function kF(r){switch(r){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return ue()}}function Jh(r){r=Qr(r,zt);let e=Qr(r.firestore,bi);return bF(yg(e),r._key).then(t=>nE(e,r,t))}var Bh=class extends Jm{constructor(e){super(),this.firestore=e}convertBytes(e){return new Au(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new zt(this.firestore,null,t)}};function bg(r,e,t){r=Qr(r,zt);let n=Qr(r.firestore,bi),s=OF(r.converter,e,t);return rE(n,[SF(QT(n),"setDoc",r._key,s,r.converter!==null,t).toMutation(r._key,_i.none())])}function eE(r,e,t,...n){r=Qr(r,zt);let s=Qr(r.firestore,bi),a=QT(s),c;return c=typeof(e=In(e))=="string"||e instanceof Jo?PF(a,"updateDoc",r._key,e,t,n):RF(a,"updateDoc",r._key,e),rE(s,[c.toMutation(r._key,_i.exists(!0))])}function tE(r,...e){var t,n,s;r=In(r);let a={includeMetadataChanges:!1,source:"default"},c=0;typeof e[c]!="object"||Ob(e[c])||(a=e[c],c++);let h={includeMetadataChanges:a.includeMetadataChanges,source:a.source};if(Ob(e[c])){let E=e[c];e[c]=(t=E.next)===null||t===void 0?void 0:t.bind(E),e[c+1]=(n=E.error)===null||n===void 0?void 0:n.bind(E),e[c+2]=(s=E.complete)===null||s===void 0?void 0:s.bind(E)}let f,m,_;if(r instanceof zt)m=Qr(r.firestore,bi),_=qh(r._key.path),f={next:E=>{e[c]&&e[c](nE(m,r,E))},error:e[c+1],complete:e[c+2]};else{let E=Qr(r,kh);m=Qr(E.firestore,bi),_=E._query;let I=new Bh(m);f={next:k=>{e[c]&&e[c](new Ym(m,I,E,k))},error:e[c+1],complete:e[c+2]},DF(r._query)}return function(I,k,B,G){let j=new Dh(G),J=new Rh(k,j,B);return I.asyncQueue.enqueueAndForget(async()=>LT(await zm(I),J)),()=>{j.su(),I.asyncQueue.enqueueAndForget(async()=>MT(await zm(I),J))}}(yg(m),_,h,f)}function rE(r,e){return function(n,s){let a=new Gr;return n.asyncQueue.enqueueAndForget(async()=>hF(await wF(n),s,a)),a.promise}(yg(r),e)}function nE(r,e,t){let n=t.docs.get(e._key),s=new Bh(r);return new Uh(r,s,e._key,n,new us(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){(function(s){Yo=s})(B0),au(new xn("firestore",(n,{instanceIdentifier:s,options:a})=>{let c=n.getProvider("app").getImmediate(),h=new bi(new vp(n.getProvider("auth-internal")),new Tp(c,n.getProvider("app-check-internal")),function(m,_){if(!Object.prototype.hasOwnProperty.apply(m.options,["projectId"]))throw new ne(H.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new lh(m.options.projectId,_)}(c,s),c);return a=Object.assign({useFetchStreams:t},a),h._setSettings(a),h},"PUBLIC").setMultipleInstances(!0)),gi(K0,W0,e),gi(K0,W0,"esm2017")})();var iE=r=>{let e;return r?e=r:typeof fetch=="undefined"?e=(...t)=>Promise.resolve().then(()=>(Ei(),gs)).then(({default:n})=>n(...t)):e=fetch,(...t)=>e(...t)};var ku=class extends Error{constructor(e,t="FunctionsError",n){super(e),this.name=t,this.context=n}},Yh=class extends ku{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}},Xh=class extends ku{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}},Zh=class extends ku{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}},ef;(function(r){r.Any="any",r.ApNortheast1="ap-northeast-1",r.ApNortheast2="ap-northeast-2",r.ApSouth1="ap-south-1",r.ApSoutheast1="ap-southeast-1",r.ApSoutheast2="ap-southeast-2",r.CaCentral1="ca-central-1",r.EuCentral1="eu-central-1",r.EuWest1="eu-west-1",r.EuWest2="eu-west-2",r.EuWest3="eu-west-3",r.SaEast1="sa-east-1",r.UsEast1="us-east-1",r.UsWest1="us-west-1",r.UsWest2="us-west-2"})(ef||(ef={}));var FF=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},Nu=class{constructor(e,{headers:t={},customFetch:n,region:s=ef.Any}={}){this.url=e,this.headers=t,this.region=s,this.fetch=iE(n)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,t={}){var n;return FF(this,void 0,void 0,function*(){try{let{headers:s,method:a,body:c}=t,h={},{region:f}=t;f||(f=this.region),f&&f!=="any"&&(h["x-region"]=f);let m;c&&(s&&!Object.prototype.hasOwnProperty.call(s,"Content-Type")||!s)&&(typeof Blob!="undefined"&&c instanceof Blob||c instanceof ArrayBuffer?(h["Content-Type"]="application/octet-stream",m=c):typeof c=="string"?(h["Content-Type"]="text/plain",m=c):typeof FormData!="undefined"&&c instanceof FormData?m=c:(h["Content-Type"]="application/json",m=JSON.stringify(c)));let _=yield this.fetch(`${this.url}/${e}`,{method:a||"POST",headers:Object.assign(Object.assign(Object.assign({},h),this.headers),s),body:m}).catch(B=>{throw new Yh(B)}),E=_.headers.get("x-relay-error");if(E&&E==="true")throw new Xh(_);if(!_.ok)throw new Zh(_);let I=((n=_.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),k;return I==="application/json"?k=yield _.json():I==="application/octet-stream"?k=yield _.blob():I==="text/event-stream"?k=_:I==="multipart/form-data"?k=yield _.formData():k=yield _.text(),{data:k,error:null}}catch(s){return{data:null,error:s}}})}};var _E=Dd(gE(),1),{PostgrestClient:yE,PostgrestQueryBuilder:BK,PostgrestFilterBuilder:jK,PostgrestTransformBuilder:$K,PostgrestBuilder:qK,PostgrestError:JF}=_E.default;var vE="2.11.2";var wE={"X-Client-Info":`realtime-js/${vE}`},bE="1.0.0",of=1e4,TE=1e3,_s;(function(r){r[r.connecting=0]="connecting",r[r.open=1]="open",r[r.closing=2]="closing",r[r.closed=3]="closed"})(_s||(_s={}));var Gt;(function(r){r.closed="closed",r.errored="errored",r.joined="joined",r.joining="joining",r.leaving="leaving"})(Gt||(Gt={}));var rr;(function(r){r.close="phx_close",r.error="phx_error",r.join="phx_join",r.reply="phx_reply",r.leave="phx_leave",r.access_token="access_token"})(rr||(rr={}));var sf;(function(r){r.websocket="websocket"})(sf||(sf={}));var Ii;(function(r){r.Connecting="connecting",r.Open="open",r.Closing="closing",r.Closed="closed"})(Ii||(Ii={}));var ju=class{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):t(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){let t=new DataView(e),n=new TextDecoder;return this._decodeBroadcast(e,t,n)}_decodeBroadcast(e,t,n){let s=t.getUint8(1),a=t.getUint8(2),c=this.HEADER_LENGTH+2,h=n.decode(e.slice(c,c+s));c=c+s;let f=n.decode(e.slice(c,c+a));c=c+a;let m=JSON.parse(n.decode(e.slice(c,e.byteLength)));return{ref:null,topic:h,event:f,payload:m}}};var ys=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=t}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}};var je;(function(r){r.abstime="abstime",r.bool="bool",r.date="date",r.daterange="daterange",r.float4="float4",r.float8="float8",r.int2="int2",r.int4="int4",r.int4range="int4range",r.int8="int8",r.int8range="int8range",r.json="json",r.jsonb="jsonb",r.money="money",r.numeric="numeric",r.oid="oid",r.reltime="reltime",r.text="text",r.time="time",r.timestamp="timestamp",r.timestamptz="timestamptz",r.timetz="timetz",r.tsrange="tsrange",r.tstzrange="tstzrange"})(je||(je={}));var Lg=(r,e,t={})=>{var n;let s=(n=t.skipTypes)!==null&&n!==void 0?n:[];return Object.keys(e).reduce((a,c)=>(a[c]=YF(c,r,e,s),a),{})},YF=(r,e,t,n)=>{let s=e.find(h=>h.name===r),a=s==null?void 0:s.type,c=t[r];return a&&!n.includes(a)?EE(a,c):Vg(c)},EE=(r,e)=>{if(r.charAt(0)==="_"){let t=r.slice(1,r.length);return tU(e,t)}switch(r){case je.bool:return XF(e);case je.float4:case je.float8:case je.int2:case je.int4:case je.int8:case je.numeric:case je.oid:return ZF(e);case je.json:case je.jsonb:return eU(e);case je.timestamp:return rU(e);case je.abstime:case je.date:case je.daterange:case je.int4range:case je.int8range:case je.money:case je.reltime:case je.text:case je.time:case je.timestamptz:case je.timetz:case je.tsrange:case je.tstzrange:return Vg(e);default:return Vg(e)}},Vg=r=>r,XF=r=>{switch(r){case"t":return!0;case"f":return!1;default:return r}},ZF=r=>{if(typeof r=="string"){let e=parseFloat(r);if(!Number.isNaN(e))return e}return r},eU=r=>{if(typeof r=="string")try{return JSON.parse(r)}catch(e){return console.log(`JSON parse error: ${e}`),r}return r},tU=(r,e)=>{if(typeof r!="string")return r;let t=r.length-1,n=r[t];if(r[0]==="{"&&n==="}"){let a,c=r.slice(1,t);try{a=JSON.parse("["+c+"]")}catch{a=c?c.split(","):[]}return a.map(h=>EE(e,h))}return r},rU=r=>typeof r=="string"?r.replace(" ","T"):r,af=r=>{let e=r;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")};var vs=class{constructor(e,t,n={},s=of){this.channel=e,this.event=t,this.payload=n,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,t){var n;return this._hasReceived(e)&&t((n=this.receivedResp)===null||n===void 0?void 0:n.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);let e=t=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=t,this._matchReceive(t)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,t){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:t})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:t}){this.recHooks.filter(n=>n.status===e).forEach(n=>n.callback(t))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}};var Mg;(function(r){r.SYNC="sync",r.JOIN="join",r.LEAVE="leave"})(Mg||(Mg={}));var na=class r{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};let n=(t==null?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(n.state,{},s=>{let{onJoin:a,onLeave:c,onSync:h}=this.caller;this.joinRef=this.channel._joinRef(),this.state=r.syncState(this.state,s,a,c),this.pendingDiffs.forEach(f=>{this.state=r.syncDiff(this.state,f,a,c)}),this.pendingDiffs=[],h()}),this.channel._on(n.diff,{},s=>{let{onJoin:a,onLeave:c,onSync:h}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=r.syncDiff(this.state,s,a,c),h())}),this.onJoin((s,a,c)=>{this.channel._trigger("presence",{event:"join",key:s,currentPresences:a,newPresences:c})}),this.onLeave((s,a,c)=>{this.channel._trigger("presence",{event:"leave",key:s,currentPresences:a,leftPresences:c})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,t,n,s){let a=this.cloneDeep(e),c=this.transformState(t),h={},f={};return this.map(a,(m,_)=>{c[m]||(f[m]=_)}),this.map(c,(m,_)=>{let E=a[m];if(E){let I=_.map(j=>j.presence_ref),k=E.map(j=>j.presence_ref),B=_.filter(j=>k.indexOf(j.presence_ref)<0),G=E.filter(j=>I.indexOf(j.presence_ref)<0);B.length>0&&(h[m]=B),G.length>0&&(f[m]=G)}else h[m]=_}),this.syncDiff(a,{joins:h,leaves:f},n,s)}static syncDiff(e,t,n,s){let{joins:a,leaves:c}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return n||(n=()=>{}),s||(s=()=>{}),this.map(a,(h,f)=>{var m;let _=(m=e[h])!==null&&m!==void 0?m:[];if(e[h]=this.cloneDeep(f),_.length>0){let E=e[h].map(k=>k.presence_ref),I=_.filter(k=>E.indexOf(k.presence_ref)<0);e[h].unshift(...I)}n(h,_,f)}),this.map(c,(h,f)=>{let m=e[h];if(!m)return;let _=f.map(E=>E.presence_ref);m=m.filter(E=>_.indexOf(E.presence_ref)<0),e[h]=m,s(h,m,f),m.length===0&&delete e[h]}),e}static map(e,t){return Object.getOwnPropertyNames(e).map(n=>t(n,e[n]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((t,n)=>{let s=e[n];return"metas"in s?t[n]=s.metas.map(a=>(a.presence_ref=a.phx_ref,delete a.phx_ref,delete a.phx_ref_prev,a)):t[n]=s,t},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}};var Fg;(function(r){r.ALL="*",r.INSERT="INSERT",r.UPDATE="UPDATE",r.DELETE="DELETE"})(Fg||(Fg={}));var Ug;(function(r){r.BROADCAST="broadcast",r.PRESENCE="presence",r.POSTGRES_CHANGES="postgres_changes",r.SYSTEM="system"})(Ug||(Ug={}));var Zr;(function(r){r.SUBSCRIBED="SUBSCRIBED",r.TIMED_OUT="TIMED_OUT",r.CLOSED="CLOSED",r.CHANNEL_ERROR="CHANNEL_ERROR"})(Zr||(Zr={}));var ia=class r{constructor(e,t={config:{}},n){this.topic=e,this.params=t,this.socket=n,this.bindings={},this.state=Gt.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""},private:!1},t.config),this.timeout=this.socket.timeout,this.joinPush=new vs(this,rr.join,this.params,this.timeout),this.rejoinTimer=new ys(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Gt.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=Gt.closed,this.socket._remove(this)}),this._onError(s=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,s),this.state=Gt.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Gt.errored,this.rejoinTimer.scheduleTimeout())}),this._on(rr.reply,{},(s,a)=>{this._trigger(this._replyEventName(a),s)}),this.presence=new na(this),this.broadcastEndpointURL=af(this.socket.endPoint)+"/api/broadcast",this.private=this.params.config.private||!1}subscribe(e,t=this.timeout){var n,s;if(this.socket.isConnected()||this.socket.connect(),this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{let{config:{broadcast:a,presence:c,private:h}}=this.params;this._onError(_=>e==null?void 0:e(Zr.CHANNEL_ERROR,_)),this._onClose(()=>e==null?void 0:e(Zr.CLOSED));let f={},m={broadcast:a,presence:c,postgres_changes:(s=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(_=>_.filter))!==null&&s!==void 0?s:[],private:h};this.socket.accessTokenValue&&(f.access_token=this.socket.accessTokenValue),this.updateJoinPayload(Object.assign({config:m},f)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",async({postgres_changes:_})=>{var E;if(this.socket.setAuth(),_===void 0){e==null||e(Zr.SUBSCRIBED);return}else{let I=this.bindings.postgres_changes,k=(E=I==null?void 0:I.length)!==null&&E!==void 0?E:0,B=[];for(let G=0;G<k;G++){let j=I[G],{filter:{event:J,schema:ee,table:re,filter:le}}=j,de=_&&_[G];if(de&&de.event===J&&de.schema===ee&&de.table===re&&de.filter===le)B.push(Object.assign(Object.assign({},j),{id:de.id}));else{this.unsubscribe(),e==null||e(Zr.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=B,e&&e(Zr.SUBSCRIBED);return}}).receive("error",_=>{e==null||e(Zr.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(_).join(", ")||"error")))}).receive("timeout",()=>{e==null||e(Zr.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,t={}){return await this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,t,n){return this._on(e,t,n)}async send(e,t={}){var n,s;if(!this._canPush()&&e.type==="broadcast"){let{event:a,payload:c}=e,f={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:a,payload:c,private:this.private}]})};try{let m=await this._fetchWithTimeout(this.broadcastEndpointURL,f,(n=t.timeout)!==null&&n!==void 0?n:this.timeout);return await((s=m.body)===null||s===void 0?void 0:s.cancel()),m.ok?"ok":"error"}catch(m){return m.name==="AbortError"?"timed out":"error"}}else return new Promise(a=>{var c,h,f;let m=this._push(e.type,e,t.timeout||this.timeout);e.type==="broadcast"&&!(!((f=(h=(c=this.params)===null||c===void 0?void 0:c.config)===null||h===void 0?void 0:h.broadcast)===null||f===void 0)&&f.ack)&&a("ok"),m.receive("ok",()=>a("ok")),m.receive("error",()=>a("error")),m.receive("timeout",()=>a("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=Gt.leaving;let t=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(rr.close,"leave",this._joinRef())};return this.rejoinTimer.reset(),this.joinPush.destroy(),new Promise(n=>{let s=new vs(this,rr.leave,{},e);s.receive("ok",()=>{t(),n("ok")}).receive("timeout",()=>{t(),n("timed out")}).receive("error",()=>{n("error")}),s.send(),this._canPush()||s.trigger("ok",{})})}async _fetchWithTimeout(e,t,n){let s=new AbortController,a=setTimeout(()=>s.abort(),n),c=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:s.signal}));return clearTimeout(a),c}_push(e,t,n=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let s=new vs(this,e,t,n);return this._canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}_onMessage(e,t,n){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,n){var s,a;let c=e.toLocaleLowerCase(),{close:h,error:f,leave:m,join:_}=rr;if(n&&[h,f,m,_].indexOf(c)>=0&&n!==this._joinRef())return;let I=this._onMessage(c,t,n);if(t&&!I)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(c)?(s=this.bindings.postgres_changes)===null||s===void 0||s.filter(k=>{var B,G,j;return((B=k.filter)===null||B===void 0?void 0:B.event)==="*"||((j=(G=k.filter)===null||G===void 0?void 0:G.event)===null||j===void 0?void 0:j.toLocaleLowerCase())===c}).map(k=>k.callback(I,n)):(a=this.bindings[c])===null||a===void 0||a.filter(k=>{var B,G,j,J,ee,re;if(["broadcast","presence","postgres_changes"].includes(c))if("id"in k){let le=k.id,de=(B=k.filter)===null||B===void 0?void 0:B.event;return le&&((G=t.ids)===null||G===void 0?void 0:G.includes(le))&&(de==="*"||(de==null?void 0:de.toLocaleLowerCase())===((j=t.data)===null||j===void 0?void 0:j.type.toLocaleLowerCase()))}else{let le=(ee=(J=k==null?void 0:k.filter)===null||J===void 0?void 0:J.event)===null||ee===void 0?void 0:ee.toLocaleLowerCase();return le==="*"||le===((re=t==null?void 0:t.event)===null||re===void 0?void 0:re.toLocaleLowerCase())}else return k.type.toLocaleLowerCase()===c}).map(k=>{if(typeof I=="object"&&"ids"in I){let B=I.data,{schema:G,table:j,commit_timestamp:J,type:ee,errors:re}=B;I=Object.assign(Object.assign({},{schema:G,table:j,commit_timestamp:J,eventType:ee,new:{},old:{},errors:re}),this._getPayloadRecords(B))}k.callback(I,n)})}_isClosed(){return this.state===Gt.closed}_isJoined(){return this.state===Gt.joined}_isJoining(){return this.state===Gt.joining}_isLeaving(){return this.state===Gt.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,n){let s=e.toLocaleLowerCase(),a={type:s,filter:t,callback:n};return this.bindings[s]?this.bindings[s].push(a):this.bindings[s]=[a],this}_off(e,t){let n=e.toLocaleLowerCase();return this.bindings[n]=this.bindings[n].filter(s=>{var a;return!(((a=s.type)===null||a===void 0?void 0:a.toLocaleLowerCase())===n&&r.isEqual(s.filter,t))}),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(rr.close,{},e)}_onError(e){this._on(rr.error,{},t=>e(t))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Gt.joining,this.joinPush.resend(e))}_getPayloadRecords(e){let t={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(t.new=Lg(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(t.old=Lg(e.columns,e.old_record)),t}};var iU=()=>{},sU=typeof WebSocket!="undefined",oU=`
|
|
40
|
+
)`}copy(e,t){let n=new r;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}};var Sh=class{constructor(){this.Z_=new Ye(ce.comparator)}track(e){let t=e.doc.key,n=this.Z_.get(t);n?e.type!==0&&n.type===3?this.Z_=this.Z_.insert(t,e):e.type===3&&n.type!==1?this.Z_=this.Z_.insert(t,{type:n.type,doc:e.doc}):e.type===2&&n.type===2?this.Z_=this.Z_.insert(t,{type:2,doc:e.doc}):e.type===2&&n.type===0?this.Z_=this.Z_.insert(t,{type:0,doc:e.doc}):e.type===1&&n.type===0?this.Z_=this.Z_.remove(t):e.type===1&&n.type===2?this.Z_=this.Z_.insert(t,{type:1,doc:n.doc}):e.type===0&&n.type===1?this.Z_=this.Z_.insert(t,{type:2,doc:e.doc}):ue():this.Z_=this.Z_.insert(t,e)}X_(){let e=[];return this.Z_.inorderTraversal((t,n)=>{e.push(n)}),e}},Ho=class r{constructor(e,t,n,s,a,c,h,f,m){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=s,this.mutatedKeys=a,this.fromCache=c,this.syncStateChanged=h,this.excludesMetadataChanges=f,this.hasCachedResults=m}static fromInitialDocuments(e,t,n,s,a){let c=[];return t.forEach(h=>{c.push({type:0,doc:h})}),new r(e,t,Ah.emptySet(t),c,n,s,!0,!1,a)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&zh(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;let t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(let s=0;s<t.length;s++)if(t[s].type!==n[s].type||!t[s].doc.isEqual(n[s].doc))return!1;return!0}};var Nm=class{constructor(){this.ea=void 0,this.ta=[]}na(){return this.ta.some(e=>e.ra())}},Vm=class{constructor(){this.queries=Ib(),this.onlineState="Unknown",this.ia=new Set}terminate(){(function(t,n){let s=fe(t),a=s.queries;s.queries=Ib(),a.forEach((c,h)=>{for(let f of h.ta)f.onError(n)})})(this,new ne(H.ABORTED,"Firestore shutting down"))}};function Ib(){return new On(r=>uT(r),zh)}async function MT(r,e){let t=fe(r),n=3,s=e.query,a=t.queries.get(s);a?!a.na()&&e.ra()&&(n=2):(a=new Nm,n=e.ra()?0:1);try{switch(n){case 0:a.ea=await t.onListen(s,!0);break;case 1:a.ea=await t.onListen(s,!1);break;case 2:await t.onFirstRemoteStoreListen(s)}}catch(c){let h=dg(c,`Initialization of query '${Po(e.query)}' failed`);return void e.onError(h)}t.queries.set(s,a),a.ta.push(e),e.sa(t.onlineState),a.ea&&e.oa(a.ea)&&pg(t)}async function FT(r,e){let t=fe(r),n=e.query,s=3,a=t.queries.get(n);if(a){let c=a.ta.indexOf(e);c>=0&&(a.ta.splice(c,1),a.ta.length===0?s=e.ra()?0:1:!a.na()&&e.ra()&&(s=2))}switch(s){case 0:return t.queries.delete(n),t.onUnlisten(n,!0);case 1:return t.queries.delete(n),t.onUnlisten(n,!1);case 2:return t.onLastRemoteStoreUnlisten(n);default:return}}function iF(r,e){let t=fe(r),n=!1;for(let s of e){let a=s.query,c=t.queries.get(a);if(c){for(let h of c.ta)h.oa(s)&&(n=!0);c.ea=s}}n&&pg(t)}function sF(r,e,t){let n=fe(r),s=n.queries.get(e);if(s)for(let a of s.ta)a.onError(t);n.queries.delete(e)}function pg(r){r.ia.forEach(e=>{e.next()})}var Lm,xb;(xb=Lm||(Lm={}))._a="default",xb.Cache="cache";var Rh=class{constructor(e,t,n){this.query=e,this.aa=t,this.ua=!1,this.ca=null,this.onlineState="Unknown",this.options=n||{}}oa(e){if(!this.options.includeMetadataChanges){let n=[];for(let s of e.docChanges)s.type!==3&&n.push(s);e=new Ho(e.query,e.docs,e.oldDocs,n,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.ua?this.la(e)&&(this.aa.next(e),t=!0):this.ha(e,this.onlineState)&&(this.Pa(e),t=!0),this.ca=e,t}onError(e){this.aa.error(e)}sa(e){this.onlineState=e;let t=!1;return this.ca&&!this.ua&&this.ha(this.ca,e)&&(this.Pa(this.ca),t=!0),t}ha(e,t){if(!e.fromCache||!this.ra())return!0;let n=t!=="Offline";return(!this.options.Ta||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}la(e){if(e.docChanges.length>0)return!0;let t=this.ca&&this.ca.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}Pa(e){e=Ho.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.ua=!0,this.aa.next(e)}ra(){return this.options.source!==Lm.Cache}};var Ph=class{constructor(e){this.key=e}},Ch=class{constructor(e){this.key=e}},Mm=class{constructor(e,t){this.query=e,this.fa=t,this.ga=null,this.hasCachedResults=!1,this.current=!1,this.pa=xe(),this.mutatedKeys=xe(),this.ya=cT(e),this.wa=new Ah(this.ya)}get Sa(){return this.fa}ba(e,t){let n=t?t.Da:new Sh,s=t?t.wa:this.wa,a=t?t.mutatedKeys:this.mutatedKeys,c=s,h=!1,f=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,m=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(e.inorderTraversal((_,E)=>{let I=s.get(_),k=Gh(this.query,E)?E:null,B=!!I&&this.mutatedKeys.has(I.key),G=!!k&&(k.hasLocalMutations||this.mutatedKeys.has(k.key)&&k.hasCommittedMutations),j=!1;I&&k?I.data.isEqual(k.data)?B!==G&&(n.track({type:3,doc:k}),j=!0):this.va(I,k)||(n.track({type:2,doc:k}),j=!0,(f&&this.ya(k,f)>0||m&&this.ya(k,m)<0)&&(h=!0)):!I&&k?(n.track({type:0,doc:k}),j=!0):I&&!k&&(n.track({type:1,doc:I}),j=!0,(f||m)&&(h=!0)),j&&(k?(c=c.add(k),a=G?a.add(_):a.delete(_)):(c=c.delete(_),a=a.delete(_)))}),this.query.limit!==null)for(;c.size>this.query.limit;){let _=this.query.limitType==="F"?c.last():c.first();c=c.delete(_.key),a=a.delete(_.key),n.track({type:1,doc:_})}return{wa:c,Da:n,ls:h,mutatedKeys:a}}va(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n,s){let a=this.wa;this.wa=e.wa,this.mutatedKeys=e.mutatedKeys;let c=e.Da.X_();c.sort((_,E)=>function(k,B){let G=j=>{switch(j){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return ue()}};return G(k)-G(B)}(_.type,E.type)||this.ya(_.doc,E.doc)),this.Ca(n),s=s!=null&&s;let h=t&&!s?this.Fa():[],f=this.pa.size===0&&this.current&&!s?1:0,m=f!==this.ga;return this.ga=f,c.length!==0||m?{snapshot:new Ho(this.query,e.wa,a,c,e.mutatedKeys,f===0,m,!1,!!n&&n.resumeToken.approximateByteSize()>0),Ma:h}:{Ma:h}}sa(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({wa:this.wa,Da:new Sh,mutatedKeys:this.mutatedKeys,ls:!1},!1)):{Ma:[]}}xa(e){return!this.fa.has(e)&&!!this.wa.has(e)&&!this.wa.get(e).hasLocalMutations}Ca(e){e&&(e.addedDocuments.forEach(t=>this.fa=this.fa.add(t)),e.modifiedDocuments.forEach(t=>{}),e.removedDocuments.forEach(t=>this.fa=this.fa.delete(t)),this.current=e.current)}Fa(){if(!this.current)return[];let e=this.pa;this.pa=xe(),this.wa.forEach(n=>{this.xa(n.key)&&(this.pa=this.pa.add(n.key))});let t=[];return e.forEach(n=>{this.pa.has(n)||t.push(new Ch(n))}),this.pa.forEach(n=>{e.has(n)||t.push(new Ph(n))}),t}Oa(e){this.fa=e.gs,this.pa=xe();let t=this.ba(e.documents);return this.applyChanges(t,!0)}Na(){return Ho.fromInitialDocuments(this.query,this.wa,this.mutatedKeys,this.ga===0,this.hasCachedResults)}},mg="SyncEngine",Fm=class{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}},Um=class{constructor(e){this.key=e,this.Ba=!1}},Bm=class{constructor(e,t,n,s,a,c){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=s,this.currentUser=a,this.maxConcurrentLimboResolutions=c,this.La={},this.ka=new On(h=>uT(h),zh),this.qa=new Map,this.Qa=new Set,this.$a=new Ye(ce.comparator),this.Ka=new Map,this.Ua=new Tu,this.Wa={},this.Ga=new Map,this.za=bu.Un(),this.onlineState="Unknown",this.ja=void 0}get isPrimaryClient(){return this.ja===!0}};async function oF(r,e,t=!0){let n=zT(r),s,a=n.ka.get(e);return a?(n.sharedClientState.addLocalQueryTarget(a.targetId),s=a.view.Na()):s=await UT(n,e,t,!0),s}async function aF(r,e){let t=zT(r);await UT(t,e,!0,!1)}async function UT(r,e,t,n){let s=await zM(r.localStore,Wr(e)),a=s.targetId,c=r.sharedClientState.addLocalQueryTarget(a,t),h;return n&&(h=await uF(r,e,a,c==="current",s.resumeToken)),r.isPrimaryClient&&t&&DT(r.remoteStore,s),h}async function uF(r,e,t,n,s){r.Ha=(E,I,k)=>async function(G,j,J,ee){let re=j.view.ba(J);re.ls&&(re=await wb(G.localStore,j.query,!1).then(({documents:C})=>j.view.ba(C,re)));let le=ee&&ee.targetChanges.get(j.targetId),de=ee&&ee.targetMismatches.get(j.targetId)!=null,ie=j.view.applyChanges(re,G.isPrimaryClient,le,de);return Sb(G,j.targetId,ie.Ma),ie.snapshot}(r,E,I,k);let a=await wb(r.localStore,e,!0),c=new Mm(e,a.gs),h=c.ba(a.documents),f=vu.createSynthesizedTargetChangeForCurrentChange(t,n&&r.onlineState!=="Offline",s),m=c.applyChanges(h,r.isPrimaryClient,f);Sb(r,t,m.Ma);let _=new Fm(e,t,c);return r.ka.set(e,_),r.qa.has(t)?r.qa.get(t).push(e):r.qa.set(t,[e]),m.snapshot}async function cF(r,e,t){let n=fe(r),s=n.ka.get(e),a=n.qa.get(s.targetId);if(a.length>1)return n.qa.set(s.targetId,a.filter(c=>!zh(c,e))),void n.ka.delete(e);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(s.targetId),n.sharedClientState.isActiveQueryTarget(s.targetId)||await wm(n.localStore,s.targetId,!1).then(()=>{n.sharedClientState.clearQueryState(s.targetId),t&&cg(n.remoteStore,s.targetId),jm(n,s.targetId)}).catch(Xo)):(jm(n,s.targetId),await wm(n.localStore,s.targetId,!0))}async function lF(r,e){let t=fe(r),n=t.ka.get(e),s=t.qa.get(n.targetId);t.isPrimaryClient&&s.length===1&&(t.sharedClientState.removeLocalQueryTarget(n.targetId),cg(t.remoteStore,n.targetId))}async function hF(r,e,t){let n=yF(r);try{let s=await function(c,h){let f=fe(c),m=wt.now(),_=h.reduce((k,B)=>k.add(B.key),xe()),E,I;return f.persistence.runTransaction("Locally write mutations","readwrite",k=>{let B=kn(),G=xe();return f.ds.getEntries(k,_).next(j=>{B=j,B.forEach((J,ee)=>{ee.isValidDocument()||(G=G.add(J))})}).next(()=>f.localDocuments.getOverlayedDocuments(k,B)).next(j=>{E=j;let J=[];for(let ee of h){let re=mM(ee,E.get(ee.key).overlayedDocument);re!=null&&J.push(new Xr(ee.key,re,rT(re.value.mapValue),_i.exists(!0)))}return f.mutationQueue.addMutationBatch(k,m,J,h)}).next(j=>{I=j;let J=j.applyToLocalDocumentSet(E,G);return f.documentOverlayCache.saveOverlays(k,j.batchId,J)})}).then(()=>({batchId:I.batchId,changes:hT(E)}))}(n.localStore,e);n.sharedClientState.addPendingMutation(s.batchId),function(c,h,f){let m=c.Wa[c.currentUser.toKey()];m||(m=new Ye(Re)),m=m.insert(h,f),c.Wa[c.currentUser.toKey()]=m}(n,s.batchId,t),await Du(n,s.changes),await Hh(n.remoteStore)}catch(s){let a=dg(s,"Failed to persist write");t.reject(a)}}async function BT(r,e){let t=fe(r);try{let n=await jM(t.localStore,e);e.targetChanges.forEach((s,a)=>{let c=t.Ka.get(a);c&&(Le(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1),s.addedDocuments.size>0?c.Ba=!0:s.modifiedDocuments.size>0?Le(c.Ba):s.removedDocuments.size>0&&(Le(c.Ba),c.Ba=!1))}),await Du(t,n,e)}catch(n){await Xo(n)}}function Ab(r,e,t){let n=fe(r);if(n.isPrimaryClient&&t===0||!n.isPrimaryClient&&t===1){let s=[];n.ka.forEach((a,c)=>{let h=c.view.sa(e);h.snapshot&&s.push(h.snapshot)}),function(c,h){let f=fe(c);f.onlineState=h;let m=!1;f.queries.forEach((_,E)=>{for(let I of E.ta)I.sa(h)&&(m=!0)}),m&&pg(f)}(n.eventManager,e),s.length&&n.La.p_(s),n.onlineState=e,n.isPrimaryClient&&n.sharedClientState.setOnlineState(e)}}async function fF(r,e,t){let n=fe(r);n.sharedClientState.updateQueryState(e,"rejected",t);let s=n.Ka.get(e),a=s&&s.key;if(a){let c=new Ye(ce.comparator);c=c.insert(a,Sr.newNoDocument(a,me.min()));let h=xe().add(a),f=new dh(me.min(),new Map,new Ye(Re),c,h);await BT(n,f),n.$a=n.$a.remove(a),n.Ka.delete(e),gg(n)}else await wm(n.localStore,e,!1).then(()=>jm(n,e,t)).catch(Xo)}async function dF(r,e){let t=fe(r),n=e.batch.batchId;try{let s=await BM(t.localStore,e);$T(t,n,null),jT(t,n),t.sharedClientState.updateMutationState(n,"acknowledged"),await Du(t,s)}catch(s){await Xo(s)}}async function pF(r,e,t){let n=fe(r);try{let s=await function(c,h){let f=fe(c);return f.persistence.runTransaction("Reject batch","readwrite-primary",m=>{let _;return f.mutationQueue.lookupMutationBatch(m,h).next(E=>(Le(E!==null),_=E.keys(),f.mutationQueue.removeMutationBatch(m,E))).next(()=>f.mutationQueue.performConsistencyCheck(m)).next(()=>f.documentOverlayCache.removeOverlaysForBatchId(m,_,h)).next(()=>f.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(m,_)).next(()=>f.localDocuments.getDocuments(m,_))})}(n.localStore,e);$T(n,e,t),jT(n,e),n.sharedClientState.updateMutationState(e,"rejected",t),await Du(n,s)}catch(s){await Xo(s)}}function jT(r,e){(r.Ga.get(e)||[]).forEach(t=>{t.resolve()}),r.Ga.delete(e)}function $T(r,e,t){let n=fe(r),s=n.Wa[n.currentUser.toKey()];if(s){let a=s.get(e);a&&(t?a.reject(t):a.resolve(),s=s.remove(e)),n.Wa[n.currentUser.toKey()]=s}}function jm(r,e,t=null){r.sharedClientState.removeLocalQueryTarget(e);for(let n of r.qa.get(e))r.ka.delete(n),t&&r.La.Ja(n,t);r.qa.delete(e),r.isPrimaryClient&&r.Ua.br(e).forEach(n=>{r.Ua.containsKey(n)||qT(r,n)})}function qT(r,e){r.Qa.delete(e.path.canonicalString());let t=r.$a.get(e);t!==null&&(cg(r.remoteStore,t),r.$a=r.$a.remove(e),r.Ka.delete(t),gg(r))}function Sb(r,e,t){for(let n of t)n instanceof Ph?(r.Ua.addReference(n.key,e),mF(r,n)):n instanceof Ch?(X(mg,"Document no longer in limbo: "+n.key),r.Ua.removeReference(n.key,e),r.Ua.containsKey(n.key)||qT(r,n.key)):ue()}function mF(r,e){let t=e.key,n=t.path.canonicalString();r.$a.get(t)||r.Qa.has(n)||(X(mg,"New document in limbo: "+t),r.Qa.add(n),gg(r))}function gg(r){for(;r.Qa.size>0&&r.$a.size<r.maxConcurrentLimboResolutions;){let e=r.Qa.values().next().value;r.Qa.delete(e);let t=new ce(ot.fromString(e)),n=r.za.next();r.Ka.set(n,new Um(t)),r.$a=r.$a.insert(t,n),DT(r.remoteStore,new wu(Wr(qh(t.path)),n,"TargetPurposeLimboResolution",Mo.ae))}}async function Du(r,e,t){let n=fe(r),s=[],a=[],c=[];n.ka.isEmpty()||(n.ka.forEach((h,f)=>{c.push(n.Ha(f,e,t).then(m=>{var _;if((m||t)&&n.isPrimaryClient){let E=m?!m.fromCache:(_=t==null?void 0:t.targetChanges.get(f.targetId))===null||_===void 0?void 0:_.current;n.sharedClientState.updateQueryState(f.targetId,E?"current":"not-current")}if(m){s.push(m);let E=gm.Yi(f.targetId,m);a.push(E)}}))}),await Promise.all(c),n.La.p_(s),await async function(f,m){let _=fe(f);try{await _.persistence.runTransaction("notifyLocalViewChanges","readwrite",E=>W.forEach(m,I=>W.forEach(I.Hi,k=>_.persistence.referenceDelegate.addReference(E,I.targetId,k)).next(()=>W.forEach(I.Ji,k=>_.persistence.referenceDelegate.removeReference(E,I.targetId,k)))))}catch(E){if(!Zo(E))throw E;X(ug,"Failed to update sequence numbers: "+E)}for(let E of m){let I=E.targetId;if(!E.fromCache){let k=_.Ts.get(I),B=k.snapshotVersion,G=k.withLastLimboFreeSnapshotVersion(B);_.Ts=_.Ts.insert(I,G)}}}(n.localStore,a))}async function gF(r,e){let t=fe(r);if(!t.currentUser.isEqual(e)){X(mg,"User change. New user:",e.toKey());let n=await PT(t.localStore,e);t.currentUser=e,function(a,c){a.Ga.forEach(h=>{h.forEach(f=>{f.reject(new ne(H.CANCELLED,c))})}),a.Ga.clear()}(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,n.removedBatchIds,n.addedBatchIds),await Du(t,n.Rs)}}function _F(r,e){let t=fe(r),n=t.Ka.get(e);if(n&&n.Ba)return xe().add(n.key);{let s=xe(),a=t.qa.get(e);if(!a)return s;for(let c of a){let h=t.ka.get(c);s=s.unionWith(h.view.Sa)}return s}}function zT(r){let e=fe(r);return e.remoteStore.remoteSyncer.applyRemoteEvent=BT.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=_F.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=fF.bind(null,e),e.La.p_=iF.bind(null,e.eventManager),e.La.Ja=sF.bind(null,e.eventManager),e}function yF(r){let e=fe(r);return e.remoteStore.remoteSyncer.applySuccessfulWrite=dF.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=pF.bind(null,e),e}var Qo=class{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=Kh(e.databaseInfo.databaseId),this.sharedClientState=this.Za(e),this.persistence=this.Xa(e),await this.persistence.start(),this.localStore=this.eu(e),this.gcScheduler=this.tu(e,this.localStore),this.indexBackfillerScheduler=this.nu(e,this.localStore)}tu(e,t){return null}nu(e,t){return null}eu(e){return UM(this.persistence,new ym,e.initialUser,this.serializer)}Xa(e){return new vh(mm.ri,this.serializer)}Za(e){return new bm}async terminate(){var e,t;(e=this.gcScheduler)===null||e===void 0||e.stop(),(t=this.indexBackfillerScheduler)===null||t===void 0||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}};Qo.provider={build:()=>new Qo};var $m=class extends Qo{constructor(e){super(),this.cacheSizeBytes=e}tu(e,t){Le(this.persistence.referenceDelegate instanceof wh);let n=this.persistence.referenceDelegate.garbageCollector;return new rm(n,e.asyncQueue,t)}Xa(e){let t=this.cacheSizeBytes!==void 0?lr.withCacheSize(this.cacheSizeBytes):lr.DEFAULT;return new vh(n=>wh.ri(n,t),this.serializer)}};var Eu=class{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=n=>Ab(this.syncEngine,n,1),this.remoteStore.remoteSyncer.handleCredentialChange=gF.bind(null,this.syncEngine),await nF(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new Vm}()}createDatastore(e){let t=Kh(e.databaseInfo.databaseId),n=function(a){return new Am(a)}(e.databaseInfo);return function(a,c,h,f){return new Cm(a,c,h,f)}(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return function(n,s,a,c,h){return new Om(n,s,a,c,h)}(this.localStore,this.datastore,e.asyncQueue,t=>Ab(this.syncEngine,t,0),function(){return Th.D()?new Th:new Tm}())}createSyncEngine(e,t){return function(s,a,c,h,f,m,_){let E=new Bm(s,a,c,h,f,m);return _&&(E.ja=!0),E}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await async function(s){let a=fe(s);X(ps,"RemoteStore shutting down."),a.W_.add(5),await Cu(a),a.z_.shutdown(),a.j_.set("Unknown")}(this.remoteStore),(e=this.datastore)===null||e===void 0||e.terminate(),(t=this.eventManager)===null||t===void 0||t.terminate()}};Eu.provider={build:()=>new Eu};var Dh=class{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.iu(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.iu(this.observer.error,e):Pn("Uncaught Error in snapshot listener:",e.toString()))}su(){this.muted=!0}iu(e,t){setTimeout(()=>{this.muted||e(t)},0)}};var wi="FirestoreClient",qm=class{constructor(e,t,n,s,a){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=s,this.user=_t.UNAUTHENTICATED,this.clientId=sh.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=a,this.authCredentials.start(n,async c=>{X(wi,"Received user=",c.uid),await this.authCredentialListener(c),this.user=c}),this.appCheckCredentials.start(n,c=>(X(wi,"Received new app check token=",c),this.appCheckCredentialListener(c,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(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();let e=new Gr;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){let n=dg(t,"Failed to shutdown persistence");e.reject(n)}}),e.promise}};async function gp(r,e){r.asyncQueue.verifyOperationInProgress(),X(wi,"Initializing OfflineComponentProvider");let t=r.configuration;await e.initialize(t);let n=t.initialUser;r.setCredentialChangeListener(async s=>{n.isEqual(s)||(await PT(e.localStore,s),n=s)}),e.persistence.setDatabaseDeletedListener(()=>r.terminate()),r._offlineComponents=e}async function Rb(r,e){r.asyncQueue.verifyOperationInProgress();let t=await vF(r);X(wi,"Initializing OnlineComponentProvider"),await e.initialize(t,r.configuration),r.setCredentialChangeListener(n=>Eb(e.remoteStore,n)),r.setAppCheckTokenChangeListener((n,s)=>Eb(e.remoteStore,s)),r._onlineComponents=e}async function vF(r){if(!r._offlineComponents)if(r._uninitializedComponentsProvider){X(wi,"Using user provided OfflineComponentProvider");try{await gp(r,r._uninitializedComponentsProvider._offline)}catch(e){let t=e;if(!function(s){return s.name==="FirebaseError"?s.code===H.FAILED_PRECONDITION||s.code===H.UNIMPLEMENTED:!(typeof DOMException!="undefined"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11}(t))throw t;Vo("Error using user provided cache. Falling back to memory cache: "+t),await gp(r,new Qo)}}else X(wi,"Using default OfflineComponentProvider"),await gp(r,new $m(void 0));return r._offlineComponents}async function GT(r){return r._onlineComponents||(r._uninitializedComponentsProvider?(X(wi,"Using user provided OnlineComponentProvider"),await Rb(r,r._uninitializedComponentsProvider._online)):(X(wi,"Using default OnlineComponentProvider"),await Rb(r,new Eu))),r._onlineComponents}function wF(r){return GT(r).then(e=>e.syncEngine)}async function zm(r){let e=await GT(r),t=e.eventManager;return t.onListen=oF.bind(null,e.syncEngine),t.onUnlisten=cF.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=aF.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=lF.bind(null,e.syncEngine),t}function bF(r,e,t={}){let n=new Gr;return r.asyncQueue.enqueueAndForget(async()=>function(a,c,h,f,m){let _=new Dh({next:I=>{_.su(),c.enqueueAndForget(()=>FT(a,E));let k=I.docs.has(h);!k&&I.fromCache?m.reject(new ne(H.UNAVAILABLE,"Failed to get document because the client is offline.")):k&&I.fromCache&&f&&f.source==="server"?m.reject(new ne(H.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.)')):m.resolve(I)},error:I=>m.reject(I)}),E=new Rh(qh(h.path),_,{includeMetadataChanges:!0,Ta:!0});return MT(a,E)}(await zm(r),r.asyncQueue,e,t,n)),n.promise}function KT(r){let e={};return r.timeoutSeconds!==void 0&&(e.timeoutSeconds=r.timeoutSeconds),e}var Pb=new Map;function TF(r,e,t){if(!t)throw new ne(H.INVALID_ARGUMENT,`Function ${r}() cannot be called with an empty ${e}.`)}function EF(r,e,t,n){if(e===!0&&n===!0)throw new ne(H.INVALID_ARGUMENT,`${r} and ${t} cannot be used together.`)}function Cb(r){if(!ce.isDocumentKey(r))throw new ne(H.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${r} has ${r.length}.`)}function _g(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";{let e=function(n){return n.constructor?n.constructor.name:null}(r);return e?`a custom ${e} object`:"an object"}}return typeof r=="function"?"a function":ue()}function Qr(r,e){if("_delegate"in r&&(r=r._delegate),!(r instanceof e)){if(e.name===r.constructor.name)throw new ne(H.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{let t=_g(r);throw new ne(H.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return r}var WT="firestore.googleapis.com",Db=!0,Oh=class{constructor(e){var t,n;if(e.host===void 0){if(e.ssl!==void 0)throw new ne(H.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=WT,this.ssl=Db}else this.host=e.host,this.ssl=(t=e.ssl)!==null&&t!==void 0?t:Db;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=RT;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<LM)throw new ne(H.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}EF("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=KT((n=e.experimentalLongPollingOptions)!==null&&n!==void 0?n:{}),function(a){if(a.timeoutSeconds!==void 0){if(isNaN(a.timeoutSeconds))throw new ne(H.INVALID_ARGUMENT,`invalid long polling timeout: ${a.timeoutSeconds} (must not be NaN)`);if(a.timeoutSeconds<5)throw new ne(H.INVALID_ARGUMENT,`invalid long polling timeout: ${a.timeoutSeconds} (minimum allowed value is 5)`);if(a.timeoutSeconds>30)throw new ne(H.INVALID_ARGUMENT,`invalid long polling timeout: ${a.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(n,s){return n.timeoutSeconds===s.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}},Iu=class{constructor(e,t,n,s){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=n,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Oh({}),this._settingsFrozen=!1,this._terminateTask="notTerminated"}get app(){if(!this._app)throw new ne(H.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(e){if(this._settingsFrozen)throw new ne(H.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 Oh(e),e.credentials!==void 0&&(this._authCredentials=function(n){if(!n)return new _p;switch(n.type){case"firstParty":return new bp(n.sessionIndex||"0",n.iamToken||null,n.authTokenFactory||null);case"provider":return n.client;default:throw new ne(H.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_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(t){let n=Pb.get(t);n&&(X("ComponentProvider","Removing Datastore"),Pb.delete(t),n.terminate())}(this),Promise.resolve()}};function IF(r,e,t,n={}){var s;let a=(r=Qr(r,Iu))._getSettings(),c=`${e}:${t}`;if(a.host!==WT&&a.host!==c&&Vo("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),r._setSettings(Object.assign(Object.assign({},a),{host:c,ssl:!1})),n.mockUserToken){let h,f;if(typeof n.mockUserToken=="string")h=n.mockUserToken,f=_t.MOCK_USER;else{h=E0(n.mockUserToken,(s=r._app)===null||s===void 0?void 0:s.options.projectId);let m=n.mockUserToken.sub||n.mockUserToken.user_id;if(!m)throw new ne(H.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");f=new _t(m)}r._authCredentials=new yp(new nh(h,f))}}var kh=class r{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new r(this.firestore,e,this._query)}},zt=class r{constructor(e,t,n){this.converter=t,this._key=n,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new xu(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new r(this.firestore,e,this._key)}},xu=class r extends kh{constructor(e,t,n){super(e,t,qh(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){let e=this._path.popLast();return e.isEmpty()?null:new zt(this.firestore,null,new ce(e))}withConverter(e){return new r(this.firestore,e,this._path)}};function Ou(r,e,...t){if(r=In(r),arguments.length===1&&(e=sh.newId()),TF("doc","path",e),r instanceof Iu){let n=ot.fromString(e,...t);return Cb(n),new zt(r,null,new ce(n))}{if(!(r instanceof zt||r instanceof xu))throw new ne(H.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let n=r._path.child(ot.fromString(e,...t));return Cb(n),new zt(r.firestore,r instanceof xu?r.converter:null,new ce(n))}}var Ob="AsyncQueue",Nh=class{constructor(e=Promise.resolve()){this.Vu=[],this.mu=!1,this.fu=[],this.gu=null,this.pu=!1,this.yu=!1,this.wu=[],this.a_=new Eh(this,"async_queue_retry"),this.Su=()=>{let n=mp();n&&X(Ob,"Visibility state changed to "+n.visibilityState),this.a_.t_()},this.bu=e;let t=mp();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this.Su)}get isShuttingDown(){return this.mu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.Du(),this.vu(e)}enterRestrictedMode(e){if(!this.mu){this.mu=!0,this.yu=e||!1;let t=mp();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this.Su)}}enqueue(e){if(this.Du(),this.mu)return new Promise(()=>{});let t=new Gr;return this.vu(()=>this.mu&&this.yu?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Vu.push(e),this.Cu()))}async Cu(){if(this.Vu.length!==0){try{await this.Vu[0](),this.Vu.shift(),this.a_.reset()}catch(e){if(!Zo(e))throw e;X(Ob,"Operation failed with retryable error: "+e)}this.Vu.length>0&&this.a_.Xo(()=>this.Cu())}}vu(e){let t=this.bu.then(()=>(this.pu=!0,e().catch(n=>{this.gu=n,this.pu=!1;let s=function(c){let h=c.message||"";return c.stack&&(h=c.stack.includes(c.message)?c.stack:c.message+`
|
|
41
|
+
`+c.stack),h}(n);throw Pn("INTERNAL UNHANDLED ERROR: ",s),n}).then(n=>(this.pu=!1,n))));return this.bu=t,t}enqueueAfterDelay(e,t,n){this.Du(),this.wu.indexOf(e)>-1&&(t=0);let s=km.createAndSchedule(this,e,t,n,a=>this.Fu(a));return this.fu.push(s),s}Du(){this.gu&&ue()}verifyOperationInProgress(){}async Mu(){let e;do e=this.bu,await e;while(e!==this.bu)}xu(e){for(let t of this.fu)if(t.timerId===e)return!0;return!1}Ou(e){return this.Mu().then(()=>{this.fu.sort((t,n)=>t.targetTimeMs-n.targetTimeMs);for(let t of this.fu)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.Mu()})}Nu(e){this.wu.push(e)}Fu(e){let t=this.fu.indexOf(e);this.fu.splice(t,1)}};function kb(r){return function(t,n){if(typeof t!="object"||t===null)return!1;let s=t;for(let a of n)if(a in s&&typeof s[a]=="function")return!0;return!1}(r,["next","error","complete"])}var bi=class extends Iu{constructor(e,t,n,s){super(e,t,n,s),this.type="firestore",this._queue=new Nh,this._persistenceKey=(s==null?void 0:s.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new Nh(e),this._firestoreClient=void 0,await e}}};function HT(r,e){let t=typeof r=="object"?r:$0(),n=typeof r=="string"?r:e||ch,s=U0(t,"firestore").getImmediate({identifier:n});if(!s._initialized){let a=T0("firestore");a&&IF(s,...a)}return s}function yg(r){if(r._terminated)throw new ne(H.FAILED_PRECONDITION,"The client has already been terminated.");return r._firestoreClient||xF(r),r._firestoreClient}function xF(r){var e,t,n;let s=r._freezeSettings(),a=function(h,f,m,_){return new xp(h,f,m,_.host,_.ssl,_.experimentalForceLongPolling,_.experimentalAutoDetectLongPolling,KT(_.experimentalLongPollingOptions),_.useFetchStreams)}(r._databaseId,((e=r._app)===null||e===void 0?void 0:e.options.appId)||"",r._persistenceKey,s);r._componentsProvider||!((t=s.localCache)===null||t===void 0)&&t._offlineComponentProvider&&(!((n=s.localCache)===null||n===void 0)&&n._onlineComponentProvider)&&(r._componentsProvider={_offline:s.localCache._offlineComponentProvider,_online:s.localCache._onlineComponentProvider}),r._firestoreClient=new qm(r._authCredentials,r._appCheckCredentials,r._queue,a,r._componentsProvider&&function(h){let f=h==null?void 0:h._online.build();return{_offline:h==null?void 0:h._offline.build(f),_online:f}}(r._componentsProvider))}var Au=class r{constructor(e){this._byteString=e}static fromBase64String(e){try{return new r(Rt.fromBase64String(e))}catch(t){throw new ne(H.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new r(Rt.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}};var Jo=class{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new ne(H.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new tr(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}};var Su=class{constructor(e){this._methodName=e}};var Ru=class{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new ne(H.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new ne(H.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(e){return Re(this._lat,e._lat)||Re(this._long,e._long)}};var Pu=class{constructor(e){this._values=(e||[]).map(t=>t)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(n,s){if(n.length!==s.length)return!1;for(let a=0;a<n.length;++a)if(n[a]!==s[a])return!1;return!0}(this._values,e._values)}};var AF=/^__.*__$/,Gm=class{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return this.fieldMask!==null?new Xr(e,this.data,this.fieldMask,t,this.fieldTransforms):new ds(e,this.data,t,this.fieldTransforms)}},Vh=class{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new Xr(e,this.data,this.fieldMask,t,this.fieldTransforms)}};function QT(r){switch(r){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw ue()}}var Km=class r{constructor(e,t,n,s,a,c){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=s,a===void 0&&this.Bu(),this.fieldTransforms=a||[],this.fieldMask=c||[]}get path(){return this.settings.path}get Lu(){return this.settings.Lu}ku(e){return new r(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}qu(e){var t;let n=(t=this.path)===null||t===void 0?void 0:t.child(e),s=this.ku({path:n,Qu:!1});return s.$u(e),s}Ku(e){var t;let n=(t=this.path)===null||t===void 0?void 0:t.child(e),s=this.ku({path:n,Qu:!1});return s.Bu(),s}Uu(e){return this.ku({path:void 0,Qu:!0})}Wu(e){return Mh(e,this.settings.methodName,this.settings.Gu||!1,this.path,this.settings.zu)}contains(e){return this.fieldMask.find(t=>e.isPrefixOf(t))!==void 0||this.fieldTransforms.find(t=>e.isPrefixOf(t.field))!==void 0}Bu(){if(this.path)for(let e=0;e<this.path.length;e++)this.$u(this.path.get(e))}$u(e){if(e.length===0)throw this.Wu("Document fields must not be empty");if(QT(this.Lu)&&AF.test(e))throw this.Wu('Document fields cannot begin and end with "__"')}},Wm=class{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||Kh(e)}ju(e,t,n,s=!1){return new Km({Lu:e,methodName:t,zu:n,path:tr.emptyPath(),Qu:!1,Gu:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}};function JT(r){let e=r._freezeSettings(),t=Kh(r._databaseId);return new Wm(r._databaseId,!!e.ignoreUndefinedProperties,t)}function SF(r,e,t,n,s,a={}){let c=r.ju(a.merge||a.mergeFields?2:0,e,t,s);vg("Data must be an object, but it was:",c,n);let h=YT(n,c),f,m;if(a.merge)f=new hr(c.fieldMask),m=c.fieldTransforms;else if(a.mergeFields){let _=[];for(let E of a.mergeFields){let I=Hm(e,E,t);if(!c.contains(I))throw new ne(H.INVALID_ARGUMENT,`Field '${I}' is specified in your field mask but missing from your input data.`);ZT(_,I)||_.push(I)}f=new hr(_),m=c.fieldTransforms.filter(E=>f.covers(E.field))}else f=null,m=c.fieldTransforms;return new Gm(new er(h),f,m)}var Lh=class r extends Su{_toFieldTransform(e){if(e.Lu!==2)throw e.Lu===1?e.Wu(`${this._methodName}() can only appear at the top level of your update data`):e.Wu(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof r}};function RF(r,e,t,n){let s=r.ju(1,e,t);vg("Data must be an object, but it was:",s,n);let a=[],c=er.empty();Ti(n,(f,m)=>{let _=wg(e,f,t);m=In(m);let E=s.Ku(_);if(m instanceof Lh)a.push(_);else{let I=Qh(m,E);I!=null&&(a.push(_),c.set(_,I))}});let h=new hr(a);return new Vh(c,h,s.fieldTransforms)}function PF(r,e,t,n,s,a){let c=r.ju(1,e,t),h=[Hm(e,n,t)],f=[s];if(a.length%2!=0)throw new ne(H.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let I=0;I<a.length;I+=2)h.push(Hm(e,a[I])),f.push(a[I+1]);let m=[],_=er.empty();for(let I=h.length-1;I>=0;--I)if(!ZT(m,h[I])){let k=h[I],B=f[I];B=In(B);let G=c.Ku(k);if(B instanceof Lh)m.push(k);else{let j=Qh(B,G);j!=null&&(m.push(k),_.set(k,j))}}let E=new hr(m);return new Vh(_,E,c.fieldTransforms)}function Qh(r,e){if(XT(r=In(r)))return vg("Unsupported field value:",e,r),YT(r,e);if(r instanceof Su)return function(n,s){if(!QT(s.Lu))throw s.Wu(`${n._methodName}() can only be used with update() and set()`);if(!s.path)throw s.Wu(`${n._methodName}() is not currently supported inside arrays`);let a=n._toFieldTransform(s);a&&s.fieldTransforms.push(a)}(r,e),null;if(r===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),r instanceof Array){if(e.settings.Qu&&e.Lu!==4)throw e.Wu("Nested arrays are not supported");return function(n,s){let a=[],c=0;for(let h of n){let f=Qh(h,s.Uu(c));f==null&&(f={nullValue:"NULL_VALUE"}),a.push(f),c++}return{arrayValue:{values:a}}}(r,e)}return function(n,s){if((n=In(n))===null)return{nullValue:"NULL_VALUE"};if(typeof n=="number")return lM(s.serializer,n);if(typeof n=="boolean")return{booleanValue:n};if(typeof n=="string")return{stringValue:n};if(n instanceof Date){let a=wt.fromDate(n);return{timestampValue:_h(s.serializer,a)}}if(n instanceof wt){let a=new wt(n.seconds,1e3*Math.floor(n.nanoseconds/1e3));return{timestampValue:_h(s.serializer,a)}}if(n instanceof Ru)return{geoPointValue:{latitude:n.latitude,longitude:n.longitude}};if(n instanceof Au)return{bytesValue:bT(s.serializer,n._byteString)};if(n instanceof zt){let a=s.databaseId,c=n.firestore._databaseId;if(!c.isEqual(a))throw s.Wu(`Document reference is for database ${c.projectId}/${c.database} but should be for database ${a.projectId}/${a.database}`);return{referenceValue:ag(n.firestore._databaseId||s.databaseId,n._key.path)}}if(n instanceof Pu)return function(c,h){return{mapValue:{fields:{[tg]:{stringValue:rg},[Fo]:{arrayValue:{values:c.toArray().map(m=>{if(typeof m!="number")throw h.Wu("VectorValues must only contain numeric values.");return og(h.serializer,m)})}}}}}}(n,s);throw s.Wu(`Unsupported field value: ${_g(n)}`)}(r,e)}function YT(r,e){let t={};return Hb(r)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):Ti(r,(n,s)=>{let a=Qh(s,e.qu(n));a!=null&&(t[n]=a)}),{mapValue:{fields:t}}}function XT(r){return!(typeof r!="object"||r===null||r instanceof Array||r instanceof Date||r instanceof wt||r instanceof Ru||r instanceof Au||r instanceof zt||r instanceof Su||r instanceof Pu)}function vg(r,e,t){if(!XT(t)||!function(s){return typeof s=="object"&&s!==null&&(Object.getPrototypeOf(s)===Object.prototype||Object.getPrototypeOf(s)===null)}(t)){let n=_g(t);throw n==="an object"?e.Wu(r+" a custom object"):e.Wu(r+" "+n)}}function Hm(r,e,t){if((e=In(e))instanceof Jo)return e._internalPath;if(typeof e=="string")return wg(r,e);throw Mh("Field path arguments must be of type string or ",r,!1,void 0,t)}var CF=new RegExp("[~\\*/\\[\\]]");function wg(r,e,t){if(e.search(CF)>=0)throw Mh(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,r,!1,void 0,t);try{return new Jo(...e.split("."))._internalPath}catch{throw Mh(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,r,!1,void 0,t)}}function Mh(r,e,t,n,s){let a=n&&!n.isEmpty(),c=s!==void 0,h=`Function ${e}() called with invalid data`;t&&(h+=" (via `toFirestore()`)"),h+=". ";let f="";return(a||c)&&(f+=" (found",a&&(f+=` in field ${n}`),c&&(f+=` in document ${s}`),f+=")"),new ne(H.INVALID_ARGUMENT,h+r+f)}function ZT(r,e){return r.some(t=>t.isEqual(e))}var Fh=class{constructor(e,t,n,s,a){this._firestore=e,this._userDataWriter=t,this._key=n,this._document=s,this._converter=a}get id(){return this._key.path.lastSegment()}get ref(){return new zt(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){let e=new Qm(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){let t=this._document.data.field(eE("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}},Qm=class extends Fh{data(){return super.data()}};function eE(r,e){return typeof e=="string"?wg(r,e):e instanceof Jo?e._internalPath:e._delegate._internalPath}function DF(r){if(r.limitType==="L"&&r.explicitOrderBy.length===0)throw new ne(H.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}var Jm=class{convertValue(e,t="none"){switch(yi(e)){case 0:return null;case 1:return e.booleanValue;case 2:return Ge(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Dn(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw ue()}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){let n={};return Ti(e,(s,a)=>{n[s]=this.convertValue(a,t)}),n}convertVectorValue(e){var t,n,s;let a=(s=(n=(t=e.fields)===null||t===void 0?void 0:t[Fo].arrayValue)===null||n===void 0?void 0:n.values)===null||s===void 0?void 0:s.map(c=>Ge(c.doubleValue));return new Pu(a)}convertGeoPoint(e){return new Ru(Ge(e.latitude),Ge(e.longitude))}convertArray(e,t){return(e.values||[]).map(n=>this.convertValue(n,t))}convertServerTimestamp(e,t){switch(t){case"previous":let n=$h(e);return n==null?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(_u(e));default:return null}}convertTimestamp(e){let t=Cn(e);return new wt(t.seconds,t.nanos)}convertDocumentKey(e,t){let n=ot.fromString(e);Le(ST(n));let s=new lh(n.get(1),n.get(3)),a=new ce(n.popFirst(5));return s.isEqual(t)||Pn(`Document ${a} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),a}};function OF(r,e,t){let n;return n=r?t&&(t.merge||t.mergeFields)?r.toFirestore(e,t):r.toFirestore(e):e,n}var us=class{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}},Uh=class extends Fh{constructor(e,t,n,s,a,c){super(e,t,n,s,c),this._firestore=e,this._firestoreImpl=e,this.metadata=a}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){let t=new No(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){let n=this._document.data.field(eE("DocumentSnapshot.get",e));if(n!==null)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}},No=class extends Uh{data(e={}){return super.data(e)}},Ym=class{constructor(e,t,n,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new us(s.hasPendingWrites,s.fromCache),this.query=n}get docs(){let e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach(n=>{e.call(t,new No(this._firestore,this._userDataWriter,n.key,n,new us(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){let t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new ne(H.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(s,a){if(s._snapshot.oldDocs.isEmpty()){let c=0;return s._snapshot.docChanges.map(h=>{let f=new No(s._firestore,s._userDataWriter,h.doc.key,h.doc,new us(s._snapshot.mutatedKeys.has(h.doc.key),s._snapshot.fromCache),s.query.converter);return h.doc,{type:"added",doc:f,oldIndex:-1,newIndex:c++}})}{let c=s._snapshot.oldDocs;return s._snapshot.docChanges.filter(h=>a||h.type!==3).map(h=>{let f=new No(s._firestore,s._userDataWriter,h.doc.key,h.doc,new us(s._snapshot.mutatedKeys.has(h.doc.key),s._snapshot.fromCache),s.query.converter),m=-1,_=-1;return h.type!==0&&(m=c.indexOf(h.doc.key),c=c.delete(h.doc.key)),h.type!==1&&(c=c.add(h.doc),_=c.indexOf(h.doc.key)),{type:kF(h.type),doc:f,oldIndex:m,newIndex:_}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}};function kF(r){switch(r){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return ue()}}function Jh(r){r=Qr(r,zt);let e=Qr(r.firestore,bi);return bF(yg(e),r._key).then(t=>iE(e,r,t))}var Bh=class extends Jm{constructor(e){super(),this.firestore=e}convertBytes(e){return new Au(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new zt(this.firestore,null,t)}};function bg(r,e,t){r=Qr(r,zt);let n=Qr(r.firestore,bi),s=OF(r.converter,e,t);return nE(n,[SF(JT(n),"setDoc",r._key,s,r.converter!==null,t).toMutation(r._key,_i.none())])}function tE(r,e,t,...n){r=Qr(r,zt);let s=Qr(r.firestore,bi),a=JT(s),c;return c=typeof(e=In(e))=="string"||e instanceof Jo?PF(a,"updateDoc",r._key,e,t,n):RF(a,"updateDoc",r._key,e),nE(s,[c.toMutation(r._key,_i.exists(!0))])}function rE(r,...e){var t,n,s;r=In(r);let a={includeMetadataChanges:!1,source:"default"},c=0;typeof e[c]!="object"||kb(e[c])||(a=e[c],c++);let h={includeMetadataChanges:a.includeMetadataChanges,source:a.source};if(kb(e[c])){let E=e[c];e[c]=(t=E.next)===null||t===void 0?void 0:t.bind(E),e[c+1]=(n=E.error)===null||n===void 0?void 0:n.bind(E),e[c+2]=(s=E.complete)===null||s===void 0?void 0:s.bind(E)}let f,m,_;if(r instanceof zt)m=Qr(r.firestore,bi),_=qh(r._key.path),f={next:E=>{e[c]&&e[c](iE(m,r,E))},error:e[c+1],complete:e[c+2]};else{let E=Qr(r,kh);m=Qr(E.firestore,bi),_=E._query;let I=new Bh(m);f={next:k=>{e[c]&&e[c](new Ym(m,I,E,k))},error:e[c+1],complete:e[c+2]},DF(r._query)}return function(I,k,B,G){let j=new Dh(G),J=new Rh(k,j,B);return I.asyncQueue.enqueueAndForget(async()=>MT(await zm(I),J)),()=>{j.su(),I.asyncQueue.enqueueAndForget(async()=>FT(await zm(I),J))}}(yg(m),_,h,f)}function nE(r,e){return function(n,s){let a=new Gr;return n.asyncQueue.enqueueAndForget(async()=>hF(await wF(n),s,a)),a.promise}(yg(r),e)}function iE(r,e,t){let n=t.docs.get(e._key),s=new Bh(r);return new Uh(r,s,e._key,n,new us(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){(function(s){Yo=s})(j0),au(new xn("firestore",(n,{instanceIdentifier:s,options:a})=>{let c=n.getProvider("app").getImmediate(),h=new bi(new vp(n.getProvider("auth-internal")),new Tp(c,n.getProvider("app-check-internal")),function(m,_){if(!Object.prototype.hasOwnProperty.apply(m.options,["projectId"]))throw new ne(H.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new lh(m.options.projectId,_)}(c,s),c);return a=Object.assign({useFetchStreams:t},a),h._setSettings(a),h},"PUBLIC").setMultipleInstances(!0)),gi(W0,H0,e),gi(W0,H0,"esm2017")})();var sE=r=>{let e;return r?e=r:typeof fetch=="undefined"?e=(...t)=>Promise.resolve().then(()=>(Ei(),gs)).then(({default:n})=>n(...t)):e=fetch,(...t)=>e(...t)};var ku=class extends Error{constructor(e,t="FunctionsError",n){super(e),this.name=t,this.context=n}},Yh=class extends ku{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}},Xh=class extends ku{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}},Zh=class extends ku{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}},ef;(function(r){r.Any="any",r.ApNortheast1="ap-northeast-1",r.ApNortheast2="ap-northeast-2",r.ApSouth1="ap-south-1",r.ApSoutheast1="ap-southeast-1",r.ApSoutheast2="ap-southeast-2",r.CaCentral1="ca-central-1",r.EuCentral1="eu-central-1",r.EuWest1="eu-west-1",r.EuWest2="eu-west-2",r.EuWest3="eu-west-3",r.SaEast1="sa-east-1",r.UsEast1="us-east-1",r.UsWest1="us-west-1",r.UsWest2="us-west-2"})(ef||(ef={}));var FF=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},Nu=class{constructor(e,{headers:t={},customFetch:n,region:s=ef.Any}={}){this.url=e,this.headers=t,this.region=s,this.fetch=sE(n)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,t={}){var n;return FF(this,void 0,void 0,function*(){try{let{headers:s,method:a,body:c}=t,h={},{region:f}=t;f||(f=this.region),f&&f!=="any"&&(h["x-region"]=f);let m;c&&(s&&!Object.prototype.hasOwnProperty.call(s,"Content-Type")||!s)&&(typeof Blob!="undefined"&&c instanceof Blob||c instanceof ArrayBuffer?(h["Content-Type"]="application/octet-stream",m=c):typeof c=="string"?(h["Content-Type"]="text/plain",m=c):typeof FormData!="undefined"&&c instanceof FormData?m=c:(h["Content-Type"]="application/json",m=JSON.stringify(c)));let _=yield this.fetch(`${this.url}/${e}`,{method:a||"POST",headers:Object.assign(Object.assign(Object.assign({},h),this.headers),s),body:m}).catch(B=>{throw new Yh(B)}),E=_.headers.get("x-relay-error");if(E&&E==="true")throw new Xh(_);if(!_.ok)throw new Zh(_);let I=((n=_.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),k;return I==="application/json"?k=yield _.json():I==="application/octet-stream"?k=yield _.blob():I==="text/event-stream"?k=_:I==="multipart/form-data"?k=yield _.formData():k=yield _.text(),{data:k,error:null}}catch(s){return{data:null,error:s}}})}};var yE=Dd(_E(),1),{PostgrestClient:vE,PostgrestQueryBuilder:BK,PostgrestFilterBuilder:jK,PostgrestTransformBuilder:$K,PostgrestBuilder:qK,PostgrestError:JF}=yE.default;var wE="2.11.2";var bE={"X-Client-Info":`realtime-js/${wE}`},TE="1.0.0",of=1e4,EE=1e3,_s;(function(r){r[r.connecting=0]="connecting",r[r.open=1]="open",r[r.closing=2]="closing",r[r.closed=3]="closed"})(_s||(_s={}));var Gt;(function(r){r.closed="closed",r.errored="errored",r.joined="joined",r.joining="joining",r.leaving="leaving"})(Gt||(Gt={}));var rr;(function(r){r.close="phx_close",r.error="phx_error",r.join="phx_join",r.reply="phx_reply",r.leave="phx_leave",r.access_token="access_token"})(rr||(rr={}));var sf;(function(r){r.websocket="websocket"})(sf||(sf={}));var Ii;(function(r){r.Connecting="connecting",r.Open="open",r.Closing="closing",r.Closed="closed"})(Ii||(Ii={}));var ju=class{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):t(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){let t=new DataView(e),n=new TextDecoder;return this._decodeBroadcast(e,t,n)}_decodeBroadcast(e,t,n){let s=t.getUint8(1),a=t.getUint8(2),c=this.HEADER_LENGTH+2,h=n.decode(e.slice(c,c+s));c=c+s;let f=n.decode(e.slice(c,c+a));c=c+a;let m=JSON.parse(n.decode(e.slice(c,e.byteLength)));return{ref:null,topic:h,event:f,payload:m}}};var ys=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=t}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}};var je;(function(r){r.abstime="abstime",r.bool="bool",r.date="date",r.daterange="daterange",r.float4="float4",r.float8="float8",r.int2="int2",r.int4="int4",r.int4range="int4range",r.int8="int8",r.int8range="int8range",r.json="json",r.jsonb="jsonb",r.money="money",r.numeric="numeric",r.oid="oid",r.reltime="reltime",r.text="text",r.time="time",r.timestamp="timestamp",r.timestamptz="timestamptz",r.timetz="timetz",r.tsrange="tsrange",r.tstzrange="tstzrange"})(je||(je={}));var Lg=(r,e,t={})=>{var n;let s=(n=t.skipTypes)!==null&&n!==void 0?n:[];return Object.keys(e).reduce((a,c)=>(a[c]=YF(c,r,e,s),a),{})},YF=(r,e,t,n)=>{let s=e.find(h=>h.name===r),a=s==null?void 0:s.type,c=t[r];return a&&!n.includes(a)?IE(a,c):Vg(c)},IE=(r,e)=>{if(r.charAt(0)==="_"){let t=r.slice(1,r.length);return tU(e,t)}switch(r){case je.bool:return XF(e);case je.float4:case je.float8:case je.int2:case je.int4:case je.int8:case je.numeric:case je.oid:return ZF(e);case je.json:case je.jsonb:return eU(e);case je.timestamp:return rU(e);case je.abstime:case je.date:case je.daterange:case je.int4range:case je.int8range:case je.money:case je.reltime:case je.text:case je.time:case je.timestamptz:case je.timetz:case je.tsrange:case je.tstzrange:return Vg(e);default:return Vg(e)}},Vg=r=>r,XF=r=>{switch(r){case"t":return!0;case"f":return!1;default:return r}},ZF=r=>{if(typeof r=="string"){let e=parseFloat(r);if(!Number.isNaN(e))return e}return r},eU=r=>{if(typeof r=="string")try{return JSON.parse(r)}catch(e){return console.log(`JSON parse error: ${e}`),r}return r},tU=(r,e)=>{if(typeof r!="string")return r;let t=r.length-1,n=r[t];if(r[0]==="{"&&n==="}"){let a,c=r.slice(1,t);try{a=JSON.parse("["+c+"]")}catch{a=c?c.split(","):[]}return a.map(h=>IE(e,h))}return r},rU=r=>typeof r=="string"?r.replace(" ","T"):r,af=r=>{let e=r;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")};var vs=class{constructor(e,t,n={},s=of){this.channel=e,this.event=t,this.payload=n,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,t){var n;return this._hasReceived(e)&&t((n=this.receivedResp)===null||n===void 0?void 0:n.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);let e=t=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=t,this._matchReceive(t)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,t){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:t})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:t}){this.recHooks.filter(n=>n.status===e).forEach(n=>n.callback(t))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}};var Mg;(function(r){r.SYNC="sync",r.JOIN="join",r.LEAVE="leave"})(Mg||(Mg={}));var na=class r{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};let n=(t==null?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(n.state,{},s=>{let{onJoin:a,onLeave:c,onSync:h}=this.caller;this.joinRef=this.channel._joinRef(),this.state=r.syncState(this.state,s,a,c),this.pendingDiffs.forEach(f=>{this.state=r.syncDiff(this.state,f,a,c)}),this.pendingDiffs=[],h()}),this.channel._on(n.diff,{},s=>{let{onJoin:a,onLeave:c,onSync:h}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=r.syncDiff(this.state,s,a,c),h())}),this.onJoin((s,a,c)=>{this.channel._trigger("presence",{event:"join",key:s,currentPresences:a,newPresences:c})}),this.onLeave((s,a,c)=>{this.channel._trigger("presence",{event:"leave",key:s,currentPresences:a,leftPresences:c})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,t,n,s){let a=this.cloneDeep(e),c=this.transformState(t),h={},f={};return this.map(a,(m,_)=>{c[m]||(f[m]=_)}),this.map(c,(m,_)=>{let E=a[m];if(E){let I=_.map(j=>j.presence_ref),k=E.map(j=>j.presence_ref),B=_.filter(j=>k.indexOf(j.presence_ref)<0),G=E.filter(j=>I.indexOf(j.presence_ref)<0);B.length>0&&(h[m]=B),G.length>0&&(f[m]=G)}else h[m]=_}),this.syncDiff(a,{joins:h,leaves:f},n,s)}static syncDiff(e,t,n,s){let{joins:a,leaves:c}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return n||(n=()=>{}),s||(s=()=>{}),this.map(a,(h,f)=>{var m;let _=(m=e[h])!==null&&m!==void 0?m:[];if(e[h]=this.cloneDeep(f),_.length>0){let E=e[h].map(k=>k.presence_ref),I=_.filter(k=>E.indexOf(k.presence_ref)<0);e[h].unshift(...I)}n(h,_,f)}),this.map(c,(h,f)=>{let m=e[h];if(!m)return;let _=f.map(E=>E.presence_ref);m=m.filter(E=>_.indexOf(E.presence_ref)<0),e[h]=m,s(h,m,f),m.length===0&&delete e[h]}),e}static map(e,t){return Object.getOwnPropertyNames(e).map(n=>t(n,e[n]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((t,n)=>{let s=e[n];return"metas"in s?t[n]=s.metas.map(a=>(a.presence_ref=a.phx_ref,delete a.phx_ref,delete a.phx_ref_prev,a)):t[n]=s,t},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}};var Fg;(function(r){r.ALL="*",r.INSERT="INSERT",r.UPDATE="UPDATE",r.DELETE="DELETE"})(Fg||(Fg={}));var Ug;(function(r){r.BROADCAST="broadcast",r.PRESENCE="presence",r.POSTGRES_CHANGES="postgres_changes",r.SYSTEM="system"})(Ug||(Ug={}));var Zr;(function(r){r.SUBSCRIBED="SUBSCRIBED",r.TIMED_OUT="TIMED_OUT",r.CLOSED="CLOSED",r.CHANNEL_ERROR="CHANNEL_ERROR"})(Zr||(Zr={}));var ia=class r{constructor(e,t={config:{}},n){this.topic=e,this.params=t,this.socket=n,this.bindings={},this.state=Gt.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""},private:!1},t.config),this.timeout=this.socket.timeout,this.joinPush=new vs(this,rr.join,this.params,this.timeout),this.rejoinTimer=new ys(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Gt.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=Gt.closed,this.socket._remove(this)}),this._onError(s=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,s),this.state=Gt.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Gt.errored,this.rejoinTimer.scheduleTimeout())}),this._on(rr.reply,{},(s,a)=>{this._trigger(this._replyEventName(a),s)}),this.presence=new na(this),this.broadcastEndpointURL=af(this.socket.endPoint)+"/api/broadcast",this.private=this.params.config.private||!1}subscribe(e,t=this.timeout){var n,s;if(this.socket.isConnected()||this.socket.connect(),this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{let{config:{broadcast:a,presence:c,private:h}}=this.params;this._onError(_=>e==null?void 0:e(Zr.CHANNEL_ERROR,_)),this._onClose(()=>e==null?void 0:e(Zr.CLOSED));let f={},m={broadcast:a,presence:c,postgres_changes:(s=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(_=>_.filter))!==null&&s!==void 0?s:[],private:h};this.socket.accessTokenValue&&(f.access_token=this.socket.accessTokenValue),this.updateJoinPayload(Object.assign({config:m},f)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",async({postgres_changes:_})=>{var E;if(this.socket.setAuth(),_===void 0){e==null||e(Zr.SUBSCRIBED);return}else{let I=this.bindings.postgres_changes,k=(E=I==null?void 0:I.length)!==null&&E!==void 0?E:0,B=[];for(let G=0;G<k;G++){let j=I[G],{filter:{event:J,schema:ee,table:re,filter:le}}=j,de=_&&_[G];if(de&&de.event===J&&de.schema===ee&&de.table===re&&de.filter===le)B.push(Object.assign(Object.assign({},j),{id:de.id}));else{this.unsubscribe(),e==null||e(Zr.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=B,e&&e(Zr.SUBSCRIBED);return}}).receive("error",_=>{e==null||e(Zr.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(_).join(", ")||"error")))}).receive("timeout",()=>{e==null||e(Zr.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,t={}){return await this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,t,n){return this._on(e,t,n)}async send(e,t={}){var n,s;if(!this._canPush()&&e.type==="broadcast"){let{event:a,payload:c}=e,f={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:a,payload:c,private:this.private}]})};try{let m=await this._fetchWithTimeout(this.broadcastEndpointURL,f,(n=t.timeout)!==null&&n!==void 0?n:this.timeout);return await((s=m.body)===null||s===void 0?void 0:s.cancel()),m.ok?"ok":"error"}catch(m){return m.name==="AbortError"?"timed out":"error"}}else return new Promise(a=>{var c,h,f;let m=this._push(e.type,e,t.timeout||this.timeout);e.type==="broadcast"&&!(!((f=(h=(c=this.params)===null||c===void 0?void 0:c.config)===null||h===void 0?void 0:h.broadcast)===null||f===void 0)&&f.ack)&&a("ok"),m.receive("ok",()=>a("ok")),m.receive("error",()=>a("error")),m.receive("timeout",()=>a("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=Gt.leaving;let t=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(rr.close,"leave",this._joinRef())};return this.rejoinTimer.reset(),this.joinPush.destroy(),new Promise(n=>{let s=new vs(this,rr.leave,{},e);s.receive("ok",()=>{t(),n("ok")}).receive("timeout",()=>{t(),n("timed out")}).receive("error",()=>{n("error")}),s.send(),this._canPush()||s.trigger("ok",{})})}async _fetchWithTimeout(e,t,n){let s=new AbortController,a=setTimeout(()=>s.abort(),n),c=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:s.signal}));return clearTimeout(a),c}_push(e,t,n=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let s=new vs(this,e,t,n);return this._canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}_onMessage(e,t,n){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,n){var s,a;let c=e.toLocaleLowerCase(),{close:h,error:f,leave:m,join:_}=rr;if(n&&[h,f,m,_].indexOf(c)>=0&&n!==this._joinRef())return;let I=this._onMessage(c,t,n);if(t&&!I)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(c)?(s=this.bindings.postgres_changes)===null||s===void 0||s.filter(k=>{var B,G,j;return((B=k.filter)===null||B===void 0?void 0:B.event)==="*"||((j=(G=k.filter)===null||G===void 0?void 0:G.event)===null||j===void 0?void 0:j.toLocaleLowerCase())===c}).map(k=>k.callback(I,n)):(a=this.bindings[c])===null||a===void 0||a.filter(k=>{var B,G,j,J,ee,re;if(["broadcast","presence","postgres_changes"].includes(c))if("id"in k){let le=k.id,de=(B=k.filter)===null||B===void 0?void 0:B.event;return le&&((G=t.ids)===null||G===void 0?void 0:G.includes(le))&&(de==="*"||(de==null?void 0:de.toLocaleLowerCase())===((j=t.data)===null||j===void 0?void 0:j.type.toLocaleLowerCase()))}else{let le=(ee=(J=k==null?void 0:k.filter)===null||J===void 0?void 0:J.event)===null||ee===void 0?void 0:ee.toLocaleLowerCase();return le==="*"||le===((re=t==null?void 0:t.event)===null||re===void 0?void 0:re.toLocaleLowerCase())}else return k.type.toLocaleLowerCase()===c}).map(k=>{if(typeof I=="object"&&"ids"in I){let B=I.data,{schema:G,table:j,commit_timestamp:J,type:ee,errors:re}=B;I=Object.assign(Object.assign({},{schema:G,table:j,commit_timestamp:J,eventType:ee,new:{},old:{},errors:re}),this._getPayloadRecords(B))}k.callback(I,n)})}_isClosed(){return this.state===Gt.closed}_isJoined(){return this.state===Gt.joined}_isJoining(){return this.state===Gt.joining}_isLeaving(){return this.state===Gt.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,n){let s=e.toLocaleLowerCase(),a={type:s,filter:t,callback:n};return this.bindings[s]?this.bindings[s].push(a):this.bindings[s]=[a],this}_off(e,t){let n=e.toLocaleLowerCase();return this.bindings[n]=this.bindings[n].filter(s=>{var a;return!(((a=s.type)===null||a===void 0?void 0:a.toLocaleLowerCase())===n&&r.isEqual(s.filter,t))}),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(rr.close,{},e)}_onError(e){this._on(rr.error,{},t=>e(t))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Gt.joining,this.joinPush.resend(e))}_getPayloadRecords(e){let t={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(t.new=Lg(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(t.old=Lg(e.columns,e.old_record)),t}};var iU=()=>{},sU=typeof WebSocket!="undefined",oU=`
|
|
42
42
|
addEventListener("message", (e) => {
|
|
43
43
|
if (e.data.event === "start") {
|
|
44
44
|
setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
|
|
45
45
|
}
|
|
46
|
-
});`,sa=class{constructor(e,t){var n;this.accessTokenValue=null,this.apiKey=null,this.channels=[],this.endPoint="",this.httpEndpoint="",this.headers=wE,this.params={},this.timeout=of,this.heartbeatIntervalMs=3e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=iU,this.conn=null,this.sendBuffer=[],this.serializer=new ju,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._resolveFetch=a=>{let c;return a?c=a:typeof fetch=="undefined"?c=(...h)=>Promise.resolve().then(()=>(Ei(),gs)).then(({default:f})=>f(...h)):c=fetch,(...h)=>c(...h)},this.endPoint=`${e}/${sf.websocket}`,this.httpEndpoint=af(e),t!=null&&t.transport?this.transport=t.transport:this.transport=null,t!=null&&t.params&&(this.params=t.params),t!=null&&t.headers&&(this.headers=Object.assign(Object.assign({},this.headers),t.headers)),t!=null&&t.timeout&&(this.timeout=t.timeout),t!=null&&t.logger&&(this.logger=t.logger),t!=null&&t.heartbeatIntervalMs&&(this.heartbeatIntervalMs=t.heartbeatIntervalMs);let s=(n=t==null?void 0:t.params)===null||n===void 0?void 0:n.apikey;if(s&&(this.accessTokenValue=s,this.apiKey=s),this.reconnectAfterMs=t!=null&&t.reconnectAfterMs?t.reconnectAfterMs:a=>[1e3,2e3,5e3,1e4][a-1]||1e4,this.encode=t!=null&&t.encode?t.encode:(a,c)=>c(JSON.stringify(a)),this.decode=t!=null&&t.decode?t.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new ys(async()=>{this.disconnect(),this.connect()},this.reconnectAfterMs),this.fetch=this._resolveFetch(t==null?void 0:t.fetch),t!=null&&t.worker){if(typeof window!="undefined"&&!window.Worker)throw new Error("Web Worker is not supported");this.worker=(t==null?void 0:t.worker)||!1,this.workerUrl=t==null?void 0:t.workerUrl}this.accessToken=(t==null?void 0:t.accessToken)||null}connect(){if(!this.conn){if(this.transport){this.conn=new this.transport(this.endpointURL(),void 0,{headers:this.headers});return}if(sU){this.conn=new WebSocket(this.endpointURL()),this.setupConnection();return}this.conn=new Bg(this.endpointURL(),void 0,{close:()=>{this.conn=null}}),Promise.resolve().then(()=>Dd(xE())).then(({default:e})=>{this.conn=new e(this.endpointURL(),void 0,{headers:this.headers}),this.setupConnection()})}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:bE}))}disconnect(e,t){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,t!=null?t:""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset())}getChannels(){return this.channels}async removeChannel(e){let t=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),t}async removeAllChannels(){let e=await Promise.all(this.channels.map(t=>t.unsubscribe()));return this.disconnect(),e}log(e,t,n){this.logger(e,t,n)}connectionState(){switch(this.conn&&this.conn.readyState){case _s.connecting:return Ii.Connecting;case _s.open:return Ii.Open;case _s.closing:return Ii.Closing;default:return Ii.Closed}}isConnected(){return this.connectionState()===Ii.Open}channel(e,t={config:{}}){let n=new ia(`realtime:${e}`,t,this);return this.channels.push(n),n}push(e){let{topic:t,event:n,payload:s,ref:a}=e,c=()=>{this.encode(e,h=>{var f;(f=this.conn)===null||f===void 0||f.send(h)})};this.log("push",`${t} ${n} (${a})`,s),this.isConnected()?c():this.sendBuffer.push(c)}async setAuth(e=null){let t=e||this.accessToken&&await this.accessToken()||this.accessTokenValue;if(t){let n=null;try{n=JSON.parse(atob(t.split(".")[1]))}catch{}if(n&&n.exp&&!(Math.floor(Date.now()/1e3)-n.exp<0))return this.log("auth",`InvalidJWTToken: Invalid value for JWT claim "exp" with value ${n.exp}`),Promise.reject(`InvalidJWTToken: Invalid value for JWT claim "exp" with value ${n.exp}`);this.accessTokenValue=t,this.channels.forEach(s=>{t&&s.updateJoinPayload({access_token:t}),s.joinedOnce&&s._isJoined()&&s._push(rr.access_token,{access_token:t})})}}async sendHeartbeat(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),(e=this.conn)===null||e===void 0||e.close(TE,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth()}}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let t=this.channels.find(n=>n.topic===e&&(n._isJoined()||n._isJoining()));t&&(this.log("transport",`leaving duplicate topic "${e}"`),t.unsubscribe())}_remove(e){this.channels=this.channels.filter(t=>t._joinRef()!==e._joinRef())}setupConnection(){this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_onConnMessage(e){this.decode(e.data,t=>{let{topic:n,event:s,payload:a,ref:c}=t;c&&c===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null),this.log("receive",`${a.status||""} ${n} ${s} ${c&&"("+c+")"||""}`,a),this.channels.filter(h=>h._isMember(n)).forEach(h=>h._trigger(s,a,c)),this.stateChangeCallbacks.message.forEach(h=>h(t))})}async _onConnOpen(){if(this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this.reconnectTimer.reset(),!this.worker)this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs);else{this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");let e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=t=>{this.log("worker","worker error",t.message),this.workerRef.terminate()},this.workerRef.onmessage=t=>{t.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}this.stateChangeCallbacks.open.forEach(e=>e())}_onConnClose(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(t=>t(e))}_onConnError(e){this.log("transport",e.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach(t=>t(e))}_triggerChanError(){this.channels.forEach(e=>e._trigger(rr.error))}_appendParams(e,t){if(Object.keys(t).length===0)return e;let n=e.match(/\?/)?"&":"?",s=new URLSearchParams(t);return`${e}${n}${s}`}_workerObjectUrl(e){let t;if(e)t=e;else{let n=new Blob([oU],{type:"application/javascript"});t=URL.createObjectURL(n)}return t}},Bg=class{constructor(e,t,n){this.binaryType="arraybuffer",this.onclose=()=>{},this.onerror=()=>{},this.onmessage=()=>{},this.onopen=()=>{},this.readyState=_s.connecting,this.send=()=>{},this.url=null,this.url=e,this.close=n.close}};var oa=class extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}};function at(r){return typeof r=="object"&&r!==null&&"__isStorageError"in r}var uf=class extends oa{constructor(e,t){super(e),this.name="StorageApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}},ws=class extends oa{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}};var aU=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},lf=r=>{let e;return r?e=r:typeof fetch=="undefined"?e=(...t)=>Promise.resolve().then(()=>(Ei(),gs)).then(({default:n})=>n(...t)):e=fetch,(...t)=>e(...t)},AE=()=>aU(void 0,void 0,void 0,function*(){return typeof Response=="undefined"?(yield Promise.resolve().then(()=>(Ei(),gs))).Response:Response}),cf=r=>{if(Array.isArray(r))return r.map(t=>cf(t));if(typeof r=="function"||r!==Object(r))return r;let e={};return Object.entries(r).forEach(([t,n])=>{let s=t.replace(/([-_][a-z])/gi,a=>a.toUpperCase().replace(/[-_]/g,""));e[s]=cf(n)}),e};var bs=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},jg=r=>r.msg||r.message||r.error_description||r.error||JSON.stringify(r),uU=(r,e,t)=>bs(void 0,void 0,void 0,function*(){let n=yield AE();r instanceof n&&!(t!=null&&t.noResolveJson)?r.json().then(s=>{e(new uf(jg(s),r.status||500))}).catch(s=>{e(new ws(jg(s),s))}):e(new ws(jg(r),r))}),cU=(r,e,t,n)=>{let s={method:r,headers:(e==null?void 0:e.headers)||{}};return r==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json"},e==null?void 0:e.headers),n&&(s.body=JSON.stringify(n)),Object.assign(Object.assign({},s),t))};function $u(r,e,t,n,s,a){return bs(this,void 0,void 0,function*(){return new Promise((c,h)=>{r(t,cU(e,n,s,a)).then(f=>{if(!f.ok)throw f;return n!=null&&n.noResolveJson?f:f.json()}).then(f=>c(f)).catch(f=>uU(f,h,n))})})}function aa(r,e,t,n){return bs(this,void 0,void 0,function*(){return $u(r,"GET",e,t,n)})}function en(r,e,t,n,s){return bs(this,void 0,void 0,function*(){return $u(r,"POST",e,n,s,t)})}function SE(r,e,t,n,s){return bs(this,void 0,void 0,function*(){return $u(r,"PUT",e,n,s,t)})}function RE(r,e,t,n){return bs(this,void 0,void 0,function*(){return $u(r,"HEAD",e,Object.assign(Object.assign({},t),{noResolveJson:!0}),n)})}function hf(r,e,t,n,s){return bs(this,void 0,void 0,function*(){return $u(r,"DELETE",e,n,s,t)})}var Kt=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},lU={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},PE={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1},qu=class{constructor(e,t={},n,s){this.url=e,this.headers=t,this.bucketId=n,this.fetch=lf(s)}uploadOrUpdate(e,t,n,s){return Kt(this,void 0,void 0,function*(){try{let a,c=Object.assign(Object.assign({},PE),s),h=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(c.upsert)}),f=c.metadata;typeof Blob!="undefined"&&n instanceof Blob?(a=new FormData,a.append("cacheControl",c.cacheControl),f&&a.append("metadata",this.encodeMetadata(f)),a.append("",n)):typeof FormData!="undefined"&&n instanceof FormData?(a=n,a.append("cacheControl",c.cacheControl),f&&a.append("metadata",this.encodeMetadata(f))):(a=n,h["cache-control"]=`max-age=${c.cacheControl}`,h["content-type"]=c.contentType,f&&(h["x-metadata"]=this.toBase64(this.encodeMetadata(f)))),s!=null&&s.headers&&(h=Object.assign(Object.assign({},h),s.headers));let m=this._removeEmptyFolders(t),_=this._getFinalPath(m),E=yield this.fetch(`${this.url}/object/${_}`,Object.assign({method:e,body:a,headers:h},c!=null&&c.duplex?{duplex:c.duplex}:{})),I=yield E.json();return E.ok?{data:{path:m,id:I.Id,fullPath:I.Key},error:null}:{data:null,error:I}}catch(a){if(at(a))return{data:null,error:a};throw a}})}upload(e,t,n){return Kt(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,t,n)})}uploadToSignedUrl(e,t,n,s){return Kt(this,void 0,void 0,function*(){let a=this._removeEmptyFolders(e),c=this._getFinalPath(a),h=new URL(this.url+`/object/upload/sign/${c}`);h.searchParams.set("token",t);try{let f,m=Object.assign({upsert:PE.upsert},s),_=Object.assign(Object.assign({},this.headers),{"x-upsert":String(m.upsert)});typeof Blob!="undefined"&&n instanceof Blob?(f=new FormData,f.append("cacheControl",m.cacheControl),f.append("",n)):typeof FormData!="undefined"&&n instanceof FormData?(f=n,f.append("cacheControl",m.cacheControl)):(f=n,_["cache-control"]=`max-age=${m.cacheControl}`,_["content-type"]=m.contentType);let E=yield this.fetch(h.toString(),{method:"PUT",body:f,headers:_}),I=yield E.json();return E.ok?{data:{path:a,fullPath:I.Key},error:null}:{data:null,error:I}}catch(f){if(at(f))return{data:null,error:f};throw f}})}createSignedUploadUrl(e,t){return Kt(this,void 0,void 0,function*(){try{let n=this._getFinalPath(e),s=Object.assign({},this.headers);t!=null&&t.upsert&&(s["x-upsert"]="true");let a=yield en(this.fetch,`${this.url}/object/upload/sign/${n}`,{},{headers:s}),c=new URL(this.url+a.url),h=c.searchParams.get("token");if(!h)throw new oa("No token returned by API");return{data:{signedUrl:c.toString(),path:e,token:h},error:null}}catch(n){if(at(n))return{data:null,error:n};throw n}})}update(e,t,n){return Kt(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,t,n)})}move(e,t,n){return Kt(this,void 0,void 0,function*(){try{return{data:yield en(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers}),error:null}}catch(s){if(at(s))return{data:null,error:s};throw s}})}copy(e,t,n){return Kt(this,void 0,void 0,function*(){try{return{data:{path:(yield en(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers})).Key},error:null}}catch(s){if(at(s))return{data:null,error:s};throw s}})}createSignedUrl(e,t,n){return Kt(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),a=yield en(this.fetch,`${this.url}/object/sign/${s}`,Object.assign({expiresIn:t},n!=null&&n.transform?{transform:n.transform}:{}),{headers:this.headers}),c=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return a={signedUrl:encodeURI(`${this.url}${a.signedURL}${c}`)},{data:a,error:null}}catch(s){if(at(s))return{data:null,error:s};throw s}})}createSignedUrls(e,t,n){return Kt(this,void 0,void 0,function*(){try{let s=yield en(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),a=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return{data:s.map(c=>Object.assign(Object.assign({},c),{signedUrl:c.signedURL?encodeURI(`${this.url}${c.signedURL}${a}`):null})),error:null}}catch(s){if(at(s))return{data:null,error:s};throw s}})}download(e,t){return Kt(this,void 0,void 0,function*(){let s=typeof(t==null?void 0:t.transform)!="undefined"?"render/image/authenticated":"object",a=this.transformOptsToQueryString((t==null?void 0:t.transform)||{}),c=a?`?${a}`:"";try{let h=this._getFinalPath(e);return{data:yield(yield aa(this.fetch,`${this.url}/${s}/${h}${c}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(h){if(at(h))return{data:null,error:h};throw h}})}info(e){return Kt(this,void 0,void 0,function*(){let t=this._getFinalPath(e);try{let n=yield aa(this.fetch,`${this.url}/object/info/${t}`,{headers:this.headers});return{data:cf(n),error:null}}catch(n){if(at(n))return{data:null,error:n};throw n}})}exists(e){return Kt(this,void 0,void 0,function*(){let t=this._getFinalPath(e);try{return yield RE(this.fetch,`${this.url}/object/${t}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(at(n)&&n instanceof ws){let s=n.originalError;if([400,404].includes(s==null?void 0:s.status))return{data:!1,error:n}}throw n}})}getPublicUrl(e,t){let n=this._getFinalPath(e),s=[],a=t!=null&&t.download?`download=${t.download===!0?"":t.download}`:"";a!==""&&s.push(a);let h=typeof(t==null?void 0:t.transform)!="undefined"?"render/image":"object",f=this.transformOptsToQueryString((t==null?void 0:t.transform)||{});f!==""&&s.push(f);let m=s.join("&");return m!==""&&(m=`?${m}`),{data:{publicUrl:encodeURI(`${this.url}/${h}/public/${n}${m}`)}}}remove(e){return Kt(this,void 0,void 0,function*(){try{return{data:yield hf(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(t){if(at(t))return{data:null,error:t};throw t}})}list(e,t,n){return Kt(this,void 0,void 0,function*(){try{let s=Object.assign(Object.assign(Object.assign({},lU),t),{prefix:e||""});return{data:yield en(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},n),error:null}}catch(s){if(at(s))return{data:null,error:s};throw s}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer!="undefined"?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){let t=[];return e.width&&t.push(`width=${e.width}`),e.height&&t.push(`height=${e.height}`),e.resize&&t.push(`resize=${e.resize}`),e.format&&t.push(`format=${e.format}`),e.quality&&t.push(`quality=${e.quality}`),t.join("&")}};var CE="2.7.1";var DE={"X-Client-Info":`storage-js/${CE}`};var ua=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},zu=class{constructor(e,t={},n){this.url=e,this.headers=Object.assign(Object.assign({},DE),t),this.fetch=lf(n)}listBuckets(){return ua(this,void 0,void 0,function*(){try{return{data:yield aa(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(at(e))return{data:null,error:e};throw e}})}getBucket(e){return ua(this,void 0,void 0,function*(){try{return{data:yield aa(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(t){if(at(t))return{data:null,error:t};throw t}})}createBucket(e,t={public:!1}){return ua(this,void 0,void 0,function*(){try{return{data:yield en(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(at(n))return{data:null,error:n};throw n}})}updateBucket(e,t){return ua(this,void 0,void 0,function*(){try{return{data:yield SE(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(at(n))return{data:null,error:n};throw n}})}emptyBucket(e){return ua(this,void 0,void 0,function*(){try{return{data:yield en(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(t){if(at(t))return{data:null,error:t};throw t}})}deleteBucket(e){return ua(this,void 0,void 0,function*(){try{return{data:yield hf(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(t){if(at(t))return{data:null,error:t};throw t}})}};var Gu=class extends zu{constructor(e,t={},n){super(e,t,n)}from(e){return new qu(this.url,this.headers,e,this.fetch)}};var OE="2.48.1";var Ku="";typeof Deno!="undefined"?Ku="deno":typeof document!="undefined"?Ku="web":typeof navigator!="undefined"&&navigator.product==="ReactNative"?Ku="react-native":Ku="node";var hU={"X-Client-Info":`supabase-js-${Ku}/${OE}`},kE={headers:hU},NE={schema:"public"},VE={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},LE={};Ei();var fU=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},dU=r=>{let e;return r?e=r:typeof fetch=="undefined"?e=Tg:e=fetch,(...t)=>e(...t)},pU=()=>typeof Headers=="undefined"?Eg:Headers,ME=(r,e,t)=>{let n=dU(t),s=pU();return(a,c)=>fU(void 0,void 0,void 0,function*(){var h;let f=(h=yield e())!==null&&h!==void 0?h:r,m=new s(c==null?void 0:c.headers);return m.has("apikey")||m.set("apikey",r),m.has("Authorization")||m.set("Authorization",`Bearer ${f}`),n(a,Object.assign(Object.assign({},c),{headers:m}))})};var mU=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})};function FE(r){return r.replace(/\/$/,"")}function UE(r,e){let{db:t,auth:n,realtime:s,global:a}=r,{db:c,auth:h,realtime:f,global:m}=e,_={db:Object.assign(Object.assign({},c),t),auth:Object.assign(Object.assign({},h),n),realtime:Object.assign(Object.assign({},f),s),global:Object.assign(Object.assign({},m),a),accessToken:()=>mU(this,void 0,void 0,function*(){return""})};return r.accessToken?_.accessToken=r.accessToken:delete _.accessToken,_}var ff="2.67.3";var BE="http://localhost:9999",jE="supabase.auth.token";var $E={"X-Client-Info":`gotrue-js/${ff}`},$g=10;var Wu="X-Supabase-Api-Version",qg={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}};function qE(r){return Math.round(Date.now()/1e3)+r}function zE(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){let e=Math.random()*16|0;return(r=="x"?e:e&3|8).toString(16)})}var Rr=()=>typeof window!="undefined"&&typeof document!="undefined",Ts={tested:!1,writable:!1},xi=()=>{if(!Rr())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Ts.tested)return Ts.writable;let r=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(r,r),globalThis.localStorage.removeItem(r),Ts.tested=!0,Ts.writable=!0}catch{Ts.tested=!0,Ts.writable=!1}return Ts.writable};function GE(r){let e={},t=new URL(r);if(t.hash&&t.hash[0]==="#")try{new URLSearchParams(t.hash.substring(1)).forEach((s,a)=>{e[a]=s})}catch{}return t.searchParams.forEach((n,s)=>{e[s]=n}),e}var df=r=>{let e;return r?e=r:typeof fetch=="undefined"?e=(...t)=>Promise.resolve().then(()=>(Ei(),gs)).then(({default:n})=>n(...t)):e=fetch,(...t)=>e(...t)},KE=r=>typeof r=="object"&&r!==null&&"status"in r&&"ok"in r&&"json"in r&&typeof r.json=="function",zg=async(r,e,t)=>{await r.setItem(e,JSON.stringify(t))},Qu=async(r,e)=>{let t=await r.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return t}},Ju=async(r,e)=>{await r.removeItem(e)};function gU(r){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t="",n,s,a,c,h,f,m,_=0;for(r=r.replace("-","+").replace("_","/");_<r.length;)c=e.indexOf(r.charAt(_++)),h=e.indexOf(r.charAt(_++)),f=e.indexOf(r.charAt(_++)),m=e.indexOf(r.charAt(_++)),n=c<<2|h>>4,s=(h&15)<<4|f>>2,a=(f&3)<<6|m,t=t+String.fromCharCode(n),f!=64&&s!=0&&(t=t+String.fromCharCode(s)),m!=64&&a!=0&&(t=t+String.fromCharCode(a));return t}var Hu=class r{constructor(){this.promise=new r.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}};Hu.promiseConstructor=Promise;function Gg(r){let e=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i,t=r.split(".");if(t.length!==3)throw new Error("JWT is not valid: not a JWT structure");if(!e.test(t[1]))throw new Error("JWT is not valid: payload is not in base64url format");let n=t[1];return JSON.parse(gU(n))}async function WE(r){return await new Promise(e=>{setTimeout(()=>e(null),r)})}function HE(r,e){return new Promise((n,s)=>{(async()=>{for(let a=0;a<1/0;a++)try{let c=await r(a);if(!e(a,null,c)){n(c);return}}catch(c){if(!e(a,c)){s(c);return}}})()})}function _U(r){return("0"+r.toString(16)).substr(-2)}function yU(){let e=new Uint32Array(56);if(typeof crypto=="undefined"){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=t.length,s="";for(let a=0;a<56;a++)s+=t.charAt(Math.floor(Math.random()*n));return s}return crypto.getRandomValues(e),Array.from(e,_U).join("")}async function vU(r){let t=new TextEncoder().encode(r),n=await crypto.subtle.digest("SHA-256",t),s=new Uint8Array(n);return Array.from(s).map(a=>String.fromCharCode(a)).join("")}function wU(r){return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function bU(r){if(!(typeof crypto!="undefined"&&typeof crypto.subtle!="undefined"&&typeof TextEncoder!="undefined"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),r;let t=await vU(r);return wU(t)}async function Es(r,e,t=!1){let n=yU(),s=n;t&&(s+="/PASSWORD_RECOVERY"),await zg(r,`${e}-code-verifier`,s);let a=await bU(n);return[a,n===a?"plain":"s256"]}var TU=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function QE(r){let e=r.headers.get(Wu);if(!e||!e.match(TU))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}var Yu=class extends Error{constructor(e,t,n){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t,this.code=n}};function ge(r){return typeof r=="object"&&r!==null&&"__isAuthError"in r}var pf=class extends Yu{constructor(e,t,n){super(e,t,n),this.name="AuthApiError",this.status=t,this.code=n}};function JE(r){return ge(r)&&r.name==="AuthApiError"}var ca=class extends Yu{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}},Nn=class extends Yu{constructor(e,t,n,s){super(e,n,s),this.name=t,this.status=n}},fr=class extends Nn{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}};function YE(r){return ge(r)&&r.name==="AuthSessionMissingError"}var la=class extends Nn{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}},Is=class extends Nn{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}},xs=class extends Nn{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}};function XE(r){return ge(r)&&r.name==="AuthImplicitGrantRedirectError"}var Xu=class extends Nn{constructor(e,t=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}},ha=class extends Nn{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}};function mf(r){return ge(r)&&r.name==="AuthRetryableFetchError"}var Zu=class extends Nn{constructor(e,t,n){super(e,"AuthWeakPasswordError",t,"weak_password"),this.reasons=n}};var EU=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t},As=r=>r.msg||r.message||r.error_description||r.error||JSON.stringify(r),IU=[502,503,504];async function ZE(r){var e;if(!KE(r))throw new ha(As(r),0);if(IU.includes(r.status))throw new ha(As(r),r.status);let t;try{t=await r.json()}catch(a){throw new ca(As(a),a)}let n,s=QE(r);if(s&&s.getTime()>=qg["2024-01-01"].timestamp&&typeof t=="object"&&t&&typeof t.code=="string"?n=t.code:typeof t=="object"&&t&&typeof t.error_code=="string"&&(n=t.error_code),n){if(n==="weak_password")throw new Zu(As(t),r.status,((e=t.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(n==="session_not_found")throw new fr}else if(typeof t=="object"&&t&&typeof t.weak_password=="object"&&t.weak_password&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.reasons.reduce((a,c)=>a&&typeof c=="string",!0))throw new Zu(As(t),r.status,t.weak_password.reasons);throw new pf(As(t),r.status||500,n)}var xU=(r,e,t,n)=>{let s={method:r,headers:(e==null?void 0:e.headers)||{}};return r==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),s.body=JSON.stringify(n),Object.assign(Object.assign({},s),t))};async function Ee(r,e,t,n){var s;let a=Object.assign({},n==null?void 0:n.headers);a[Wu]||(a[Wu]=qg["2024-01-01"].name),n!=null&&n.jwt&&(a.Authorization=`Bearer ${n.jwt}`);let c=(s=n==null?void 0:n.query)!==null&&s!==void 0?s:{};n!=null&&n.redirectTo&&(c.redirect_to=n.redirectTo);let h=Object.keys(c).length?"?"+new URLSearchParams(c).toString():"",f=await AU(r,e,t+h,{headers:a,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(f):{data:Object.assign({},f),error:null}}async function AU(r,e,t,n,s,a){let c=xU(e,n,s,a),h;try{h=await r(t,Object.assign({},c))}catch(f){throw console.error(f),new ha(As(f),0)}if(h.ok||await ZE(h),n!=null&&n.noResolveJson)return h;try{return await h.json()}catch(f){await ZE(f)}}function Vn(r){var e;let t=null;SU(r)&&(t=Object.assign({},r),r.expires_at||(t.expires_at=qE(r.expires_in)));let n=(e=r.user)!==null&&e!==void 0?e:r;return{data:{session:t,user:n},error:null}}function Kg(r){let e=Vn(r);return!e.error&&r.weak_password&&typeof r.weak_password=="object"&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.message&&typeof r.weak_password.message=="string"&&r.weak_password.reasons.reduce((t,n)=>t&&typeof n=="string",!0)&&(e.data.weak_password=r.weak_password),e}function tn(r){var e;return{data:{user:(e=r.user)!==null&&e!==void 0?e:r},error:null}}function eI(r){return{data:r,error:null}}function tI(r){let{action_link:e,email_otp:t,hashed_token:n,redirect_to:s,verification_type:a}=r,c=EU(r,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),h={action_link:e,email_otp:t,hashed_token:n,redirect_to:s,verification_type:a},f=Object.assign({},c);return{data:{properties:h,user:f},error:null}}function rI(r){return r}function SU(r){return r.access_token&&r.refresh_token&&r.expires_in}var RU=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t},Ss=class{constructor({url:e="",headers:t={},fetch:n}){this.url=e,this.headers=t,this.fetch=df(n),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}async signOut(e,t="global"){try{return await Ee(this.fetch,"POST",`${this.url}/logout?scope=${t}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(n){if(ge(n))return{data:null,error:n};throw n}}async inviteUserByEmail(e,t={}){try{return await Ee(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:tn})}catch(n){if(ge(n))return{data:{user:null},error:n};throw n}}async generateLink(e){try{let{options:t}=e,n=RU(e,["options"]),s=Object.assign(Object.assign({},n),t);return"newEmail"in n&&(s.new_email=n==null?void 0:n.newEmail,delete s.newEmail),await Ee(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:tI,redirectTo:t==null?void 0:t.redirectTo})}catch(t){if(ge(t))return{data:{properties:null,user:null},error:t};throw t}}async createUser(e){try{return await Ee(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:tn})}catch(t){if(ge(t))return{data:{user:null},error:t};throw t}}async listUsers(e){var t,n,s,a,c,h,f;try{let m={nextPage:null,lastPage:0,total:0},_=await Ee(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(t=e==null?void 0:e.page)===null||t===void 0?void 0:t.toString())!==null&&n!==void 0?n:"",per_page:(a=(s=e==null?void 0:e.perPage)===null||s===void 0?void 0:s.toString())!==null&&a!==void 0?a:""},xform:rI});if(_.error)throw _.error;let E=await _.json(),I=(c=_.headers.get("x-total-count"))!==null&&c!==void 0?c:0,k=(f=(h=_.headers.get("link"))===null||h===void 0?void 0:h.split(","))!==null&&f!==void 0?f:[];return k.length>0&&(k.forEach(B=>{let G=parseInt(B.split(";")[0].split("=")[1].substring(0,1)),j=JSON.parse(B.split(";")[1].split("=")[1]);m[`${j}Page`]=G}),m.total=parseInt(I)),{data:Object.assign(Object.assign({},E),m),error:null}}catch(m){if(ge(m))return{data:{users:[]},error:m};throw m}}async getUserById(e){try{return await Ee(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:tn})}catch(t){if(ge(t))return{data:{user:null},error:t};throw t}}async updateUserById(e,t){try{return await Ee(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:tn})}catch(n){if(ge(n))return{data:{user:null},error:n};throw n}}async deleteUser(e,t=!1){try{return await Ee(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:tn})}catch(n){if(ge(n))return{data:{user:null},error:n};throw n}}async _listFactors(e){try{let{data:t,error:n}=await Ee(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:t,error:n}}catch(t){if(ge(t))return{data:null,error:t};throw t}}async _deleteFactor(e){try{return{data:await Ee(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(t){if(ge(t))return{data:null,error:t};throw t}}};var nI={getItem:r=>xi()?globalThis.localStorage.getItem(r):null,setItem:(r,e)=>{xi()&&globalThis.localStorage.setItem(r,e)},removeItem:r=>{xi()&&globalThis.localStorage.removeItem(r)}};function Wg(r={}){return{getItem:e=>r[e]||null,setItem:(e,t)=>{r[e]=t},removeItem:e=>{delete r[e]}}}function iI(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self!="undefined"&&(self.globalThis=self)}}var Rs={debug:!!(globalThis&&xi()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")},ec=class extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}},gf=class extends ec{};async function Hg(r,e,t){Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",r,e);let n=new globalThis.AbortController;return e>0&&setTimeout(()=>{n.abort(),Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",r)},e),await Promise.resolve().then(()=>globalThis.navigator.locks.request(r,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async s=>{if(s){Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",r,s.name);try{return await t()}finally{Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",r,s.name)}}else{if(e===0)throw Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",r),new gf(`Acquiring an exclusive Navigator LockManager lock "${r}" immediately failed`);if(Rs.debug)try{let a=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(a,null," "))}catch(a){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",a)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await t()}}))}iI();var PU={url:BE,storageKey:jE,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:$E,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1},tc=30*1e3,sI=3;async function oI(r,e,t){return await t()}var Ps=class r{constructor(e){var t,n;this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=r.nextInstanceID,r.nextInstanceID+=1,this.instanceID>0&&Rr()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");let s=Object.assign(Object.assign({},PU),e);if(this.logDebugMessages=!!s.debug,typeof s.debug=="function"&&(this.logger=s.debug),this.persistSession=s.persistSession,this.storageKey=s.storageKey,this.autoRefreshToken=s.autoRefreshToken,this.admin=new Ss({url:s.url,headers:s.headers,fetch:s.fetch}),this.url=s.url,this.headers=s.headers,this.fetch=df(s.fetch),this.lock=s.lock||oI,this.detectSessionInUrl=s.detectSessionInUrl,this.flowType=s.flowType,this.hasCustomAuthorizationHeader=s.hasCustomAuthorizationHeader,s.lock?this.lock=s.lock:Rr()&&(!((t=globalThis==null?void 0:globalThis.navigator)===null||t===void 0)&&t.locks)?this.lock=Hg:this.lock=oI,this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?s.storage?this.storage=s.storage:xi()?this.storage=nI:(this.memoryStorage={},this.storage=Wg(this.memoryStorage)):(this.memoryStorage={},this.storage=Wg(this.memoryStorage)),Rr()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(a){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",a)}(n=this.broadcastChannel)===null||n===void 0||n.addEventListener("message",async a=>{this._debug("received broadcast notification from other tab or client",a),await this._notifyAllSubscribers(a.data.event,a.data.session,!1)})}this.initialize()}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${ff}) ${new Date().toISOString()}`,...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{let t=GE(window.location.href),n="none";if(this._isImplicitGrantCallback(t)?n="implicit":await this._isPKCECallback(t)&&(n="pkce"),Rr()&&this.detectSessionInUrl&&n!=="none"){let{data:s,error:a}=await this._getSessionFromURL(t,n);if(a){if(this._debug("#_initialize()","error detecting session from URL",a),XE(a)){let f=(e=a.details)===null||e===void 0?void 0:e.code;if(f==="identity_already_exists"||f==="identity_not_found"||f==="single_identity_not_deletable")return{error:a}}return await this._removeSession(),{error:a}}let{session:c,redirectType:h}=s;return this._debug("#_initialize()","detected session in URL",c,"redirect type",h),await this._saveSession(c),setTimeout(async()=>{h==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",c):await this._notifyAllSubscribers("SIGNED_IN",c)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(t){return ge(t)?{error:t}:{error:new ca("Unexpected error during initialization",t)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var t,n,s;try{let a=await Ee(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(t=e==null?void 0:e.options)===null||t===void 0?void 0:t.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.captchaToken}},xform:Vn}),{data:c,error:h}=a;if(h||!c)return{data:{user:null,session:null},error:h};let f=c.session,m=c.user;return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",f)),{data:{user:m,session:f},error:null}}catch(a){if(ge(a))return{data:{user:null,session:null},error:a};throw a}}async signUp(e){var t,n,s;try{let a;if("email"in e){let{email:_,password:E,options:I}=e,k=null,B=null;this.flowType==="pkce"&&([k,B]=await Es(this.storage,this.storageKey)),a=await Ee(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:I==null?void 0:I.emailRedirectTo,body:{email:_,password:E,data:(t=I==null?void 0:I.data)!==null&&t!==void 0?t:{},gotrue_meta_security:{captcha_token:I==null?void 0:I.captchaToken},code_challenge:k,code_challenge_method:B},xform:Vn})}else if("phone"in e){let{phone:_,password:E,options:I}=e;a=await Ee(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:_,password:E,data:(n=I==null?void 0:I.data)!==null&&n!==void 0?n:{},channel:(s=I==null?void 0:I.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:I==null?void 0:I.captchaToken}},xform:Vn})}else throw new Is("You must provide either an email or phone number and a password");let{data:c,error:h}=a;if(h||!c)return{data:{user:null,session:null},error:h};let f=c.session,m=c.user;return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",f)),{data:{user:m,session:f},error:null}}catch(a){if(ge(a))return{data:{user:null,session:null},error:a};throw a}}async signInWithPassword(e){try{let t;if("email"in e){let{email:a,password:c,options:h}=e;t=await Ee(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:a,password:c,gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken}},xform:Kg})}else if("phone"in e){let{phone:a,password:c,options:h}=e;t=await Ee(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:a,password:c,gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken}},xform:Kg})}else throw new Is("You must provide either an email or phone number and a password");let{data:n,error:s}=t;return s?{data:{user:null,session:null},error:s}:!n||!n.session||!n.user?{data:{user:null,session:null},error:new la}:(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),{data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:s})}catch(t){if(ge(t))return{data:{user:null,session:null},error:t};throw t}}async signInWithOAuth(e){var t,n,s,a;return await this._handleProviderSignIn(e.provider,{redirectTo:(t=e.options)===null||t===void 0?void 0:t.redirectTo,scopes:(n=e.options)===null||n===void 0?void 0:n.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(a=e.options)===null||a===void 0?void 0:a.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async _exchangeCodeForSession(e){let t=await Qu(this.storage,`${this.storageKey}-code-verifier`),[n,s]=(t!=null?t:"").split("/");try{let{data:a,error:c}=await Ee(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:Vn});if(await Ju(this.storage,`${this.storageKey}-code-verifier`),c)throw c;return!a||!a.session||!a.user?{data:{user:null,session:null,redirectType:null},error:new la}:(a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",a.session)),{data:Object.assign(Object.assign({},a),{redirectType:s!=null?s:null}),error:c})}catch(a){if(ge(a))return{data:{user:null,session:null,redirectType:null},error:a};throw a}}async signInWithIdToken(e){try{let{options:t,provider:n,token:s,access_token:a,nonce:c}=e,h=await Ee(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:s,access_token:a,nonce:c,gotrue_meta_security:{captcha_token:t==null?void 0:t.captchaToken}},xform:Vn}),{data:f,error:m}=h;return m?{data:{user:null,session:null},error:m}:!f||!f.session||!f.user?{data:{user:null,session:null},error:new la}:(f.session&&(await this._saveSession(f.session),await this._notifyAllSubscribers("SIGNED_IN",f.session)),{data:f,error:m})}catch(t){if(ge(t))return{data:{user:null,session:null},error:t};throw t}}async signInWithOtp(e){var t,n,s,a,c;try{if("email"in e){let{email:h,options:f}=e,m=null,_=null;this.flowType==="pkce"&&([m,_]=await Es(this.storage,this.storageKey));let{error:E}=await Ee(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:h,data:(t=f==null?void 0:f.data)!==null&&t!==void 0?t:{},create_user:(n=f==null?void 0:f.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},code_challenge:m,code_challenge_method:_},redirectTo:f==null?void 0:f.emailRedirectTo});return{data:{user:null,session:null},error:E}}if("phone"in e){let{phone:h,options:f}=e,{data:m,error:_}=await Ee(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:h,data:(s=f==null?void 0:f.data)!==null&&s!==void 0?s:{},create_user:(a=f==null?void 0:f.shouldCreateUser)!==null&&a!==void 0?a:!0,gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},channel:(c=f==null?void 0:f.channel)!==null&&c!==void 0?c:"sms"}});return{data:{user:null,session:null,messageId:m==null?void 0:m.message_id},error:_}}throw new Is("You must provide either an email or phone number.")}catch(h){if(ge(h))return{data:{user:null,session:null},error:h};throw h}}async verifyOtp(e){var t,n;try{let s,a;"options"in e&&(s=(t=e.options)===null||t===void 0?void 0:t.redirectTo,a=(n=e.options)===null||n===void 0?void 0:n.captchaToken);let{data:c,error:h}=await Ee(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:a}}),redirectTo:s,xform:Vn});if(h)throw h;if(!c)throw new Error("An error occurred on token verification.");let f=c.session,m=c.user;return f!=null&&f.access_token&&(await this._saveSession(f),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",f)),{data:{user:m,session:f},error:null}}catch(s){if(ge(s))return{data:{user:null,session:null},error:s};throw s}}async signInWithSSO(e){var t,n,s;try{let a=null,c=null;return this.flowType==="pkce"&&([a,c]=await Es(this.storage,this.storageKey)),await Ee(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(n=(t=e.options)===null||t===void 0?void 0:t.redirectTo)!==null&&n!==void 0?n:void 0}),!((s=e==null?void 0:e.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:c}),headers:this.headers,xform:eI})}catch(a){if(ge(a))return{data:null,error:a};throw a}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{let{data:{session:t},error:n}=e;if(n)throw n;if(!t)throw new fr;let{error:s}=await Ee(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:t.access_token});return{data:{user:null,session:null},error:s}})}catch(e){if(ge(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{let t=`${this.url}/resend`;if("email"in e){let{email:n,type:s,options:a}=e,{error:c}=await Ee(this.fetch,"POST",t,{headers:this.headers,body:{email:n,type:s,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},redirectTo:a==null?void 0:a.emailRedirectTo});return{data:{user:null,session:null},error:c}}else if("phone"in e){let{phone:n,type:s,options:a}=e,{data:c,error:h}=await Ee(this.fetch,"POST",t,{headers:this.headers,body:{phone:n,type:s,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}}});return{data:{user:null,session:null,messageId:c==null?void 0:c.message_id},error:h}}throw new Is("You must provide either an email or phone number and a type")}catch(t){if(ge(t))return{data:{user:null,session:null},error:t};throw t}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async t=>t))}async _acquireLock(e,t){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){let n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await n,await t()))();return this.pendingInLock.push((async()=>{try{await s}catch{}})()),s}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;let n=t();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){let s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{let t=await this.__loadSession();return await e(t)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null,t=await Qu(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",t),t!==null&&(this._isValidSession(t)?e=t:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};let n=e.expires_at?e.expires_at<=Date.now()/1e3:!1;if(this._debug("#__loadSession()",`session has${n?"":" not"} expired`,"expires_at",e.expires_at),!n){if(this.storage.isServer){let c=this.suppressGetSessionWarning;e=new Proxy(e,{get:(f,m,_)=>(!c&&m==="user"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),c=!0,this.suppressGetSessionWarning=!0),Reflect.get(f,m,_))})}return{data:{session:e},error:null}}let{session:s,error:a}=await this._callRefreshToken(e.refresh_token);return a?{data:{session:null},error:a}:{data:{session:s},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await Ee(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:tn}):await this._useSession(async t=>{var n,s,a;let{data:c,error:h}=t;if(h)throw h;return!(!((n=c.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new fr}:await Ee(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(a=(s=c.session)===null||s===void 0?void 0:s.access_token)!==null&&a!==void 0?a:void 0,xform:tn})})}catch(t){if(ge(t))return YE(t)&&(await this._removeSession(),await Ju(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:t};throw t}}async updateUser(e,t={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,t))}async _updateUser(e,t={}){try{return await this._useSession(async n=>{let{data:s,error:a}=n;if(a)throw a;if(!s.session)throw new fr;let c=s.session,h=null,f=null;this.flowType==="pkce"&&e.email!=null&&([h,f]=await Es(this.storage,this.storageKey));let{data:m,error:_}=await Ee(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:t==null?void 0:t.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:h,code_challenge_method:f}),jwt:c.access_token,xform:tn});if(_)throw _;return c.user=m.user,await this._saveSession(c),await this._notifyAllSubscribers("USER_UPDATED",c),{data:{user:c.user},error:null}})}catch(n){if(ge(n))return{data:{user:null},error:n};throw n}}_decodeJWT(e){return Gg(e)}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new fr;let t=Date.now()/1e3,n=t,s=!0,a=null,c=Gg(e.access_token);if(c.exp&&(n=c.exp,s=n<=t),s){let{session:h,error:f}=await this._callRefreshToken(e.refresh_token);if(f)return{data:{user:null,session:null},error:f};if(!h)return{data:{user:null,session:null},error:null};a=h}else{let{data:h,error:f}=await this._getUser(e.access_token);if(f)throw f;a={access_token:e.access_token,refresh_token:e.refresh_token,user:h.user,token_type:"bearer",expires_in:n-t,expires_at:n},await this._saveSession(a),await this._notifyAllSubscribers("SIGNED_IN",a)}return{data:{user:a.user,session:a},error:null}}catch(t){if(ge(t))return{data:{session:null,user:null},error:t};throw t}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async t=>{var n;if(!e){let{data:c,error:h}=t;if(h)throw h;e=(n=c.session)!==null&&n!==void 0?n:void 0}if(!(e!=null&&e.refresh_token))throw new fr;let{session:s,error:a}=await this._callRefreshToken(e.refresh_token);return a?{data:{user:null,session:null},error:a}:s?{data:{user:s.user,session:s},error:null}:{data:{user:null,session:null},error:null}})}catch(t){if(ge(t))return{data:{user:null,session:null},error:t};throw t}}async _getSessionFromURL(e,t){try{if(!Rr())throw new xs("No browser detected.");if(e.error||e.error_description||e.error_code)throw new xs(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(t){case"implicit":if(this.flowType==="pkce")throw new Xu("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new xs("Not a valid implicit grant flow url.");break;default:}if(t==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Xu("No code detected.");let{data:ee,error:re}=await this._exchangeCodeForSession(e.code);if(re)throw re;let le=new URL(window.location.href);return le.searchParams.delete("code"),window.history.replaceState(window.history.state,"",le.toString()),{data:{session:ee.session,redirectType:null},error:null}}let{provider_token:n,provider_refresh_token:s,access_token:a,refresh_token:c,expires_in:h,expires_at:f,token_type:m}=e;if(!a||!h||!c||!m)throw new xs("No session defined in URL");let _=Math.round(Date.now()/1e3),E=parseInt(h),I=_+E;f&&(I=parseInt(f));let k=I-_;k*1e3<=tc&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${k}s, should have been closer to ${E}s`);let B=I-E;_-B>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",B,I,_):_-B<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",B,I,_);let{data:G,error:j}=await this._getUser(a);if(j)throw j;let J={provider_token:n,provider_refresh_token:s,access_token:a,expires_in:E,expires_at:I,refresh_token:c,token_type:m,user:G.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:J,redirectType:e.type},error:null}}catch(n){if(ge(n))return{data:{session:null,redirectType:null},error:n};throw n}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){let t=await Qu(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&t)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async t=>{var n;let{data:s,error:a}=t;if(a)return{error:a};let c=(n=s.session)===null||n===void 0?void 0:n.access_token;if(c){let{error:h}=await this.admin.signOut(c,e);if(h&&!(JE(h)&&(h.status===404||h.status===401||h.status===403)))return{error:h}}return e!=="others"&&(await this._removeSession(),await Ju(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){let t=zE(),n={id:t,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",t),this.stateChangeEmitters.delete(t)}};return this._debug("#onAuthStateChange()","registered callback with id",t),this.stateChangeEmitters.set(t,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(t)})))(),{data:{subscription:n}}}async _emitInitialSession(e){return await this._useSession(async t=>{var n,s;try{let{data:{session:a},error:c}=t;if(c)throw c;await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",a)),this._debug("INITIAL_SESSION","callback id",e,"session",a)}catch(a){await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",a),console.error(a)}})}async resetPasswordForEmail(e,t={}){let n=null,s=null;this.flowType==="pkce"&&([n,s]=await Es(this.storage,this.storageKey,!0));try{return await Ee(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:n,code_challenge_method:s,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(a){if(ge(a))return{data:null,error:a};throw a}}async getUserIdentities(){var e;try{let{data:t,error:n}=await this.getUser();if(n)throw n;return{data:{identities:(e=t.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(t){if(ge(t))return{data:null,error:t};throw t}}async linkIdentity(e){var t;try{let{data:n,error:s}=await this._useSession(async a=>{var c,h,f,m,_;let{data:E,error:I}=a;if(I)throw I;let k=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(c=e.options)===null||c===void 0?void 0:c.redirectTo,scopes:(h=e.options)===null||h===void 0?void 0:h.scopes,queryParams:(f=e.options)===null||f===void 0?void 0:f.queryParams,skipBrowserRedirect:!0});return await Ee(this.fetch,"GET",k,{headers:this.headers,jwt:(_=(m=E.session)===null||m===void 0?void 0:m.access_token)!==null&&_!==void 0?_:void 0})});if(s)throw s;return Rr()&&!(!((t=e.options)===null||t===void 0)&&t.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),{data:{provider:e.provider,url:n==null?void 0:n.url},error:null}}catch(n){if(ge(n))return{data:{provider:e.provider,url:null},error:n};throw n}}async unlinkIdentity(e){try{return await this._useSession(async t=>{var n,s;let{data:a,error:c}=t;if(c)throw c;return await Ee(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(s=(n=a.session)===null||n===void 0?void 0:n.access_token)!==null&&s!==void 0?s:void 0})})}catch(t){if(ge(t))return{data:null,error:t};throw t}}async _refreshAccessToken(e){let t=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(t,"begin");try{let n=Date.now();return await HE(async s=>(s>0&&await WE(200*Math.pow(2,s-1)),this._debug(t,"refreshing attempt",s),await Ee(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Vn})),(s,a)=>{let c=200*Math.pow(2,s);return a&&mf(a)&&Date.now()+c-n<tc})}catch(n){if(this._debug(t,"error",n),ge(n))return{data:{session:null,user:null},error:n};throw n}finally{this._debug(t,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,t){let n=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",t,"url",n),Rr()&&!t.skipBrowserRedirect&&window.location.assign(n),{data:{provider:e,url:n},error:null}}async _recoverAndRefresh(){var e;let t="#_recoverAndRefresh()";this._debug(t,"begin");try{let n=await Qu(this.storage,this.storageKey);if(this._debug(t,"session from storage",n),!this._isValidSession(n)){this._debug(t,"session is not valid"),n!==null&&await this._removeSession();return}let s=Math.round(Date.now()/1e3),a=((e=n.expires_at)!==null&&e!==void 0?e:1/0)<s+$g;if(this._debug(t,`session has${a?"":" not"} expired with margin of ${$g}s`),a){if(this.autoRefreshToken&&n.refresh_token){let{error:c}=await this._callRefreshToken(n.refresh_token);c&&(console.error(c),mf(c)||(this._debug(t,"refresh failed with a non-retryable error, removing the session",c),await this._removeSession()))}}else await this._notifyAllSubscribers("SIGNED_IN",n)}catch(n){this._debug(t,"error",n),console.error(n);return}finally{this._debug(t,"end")}}async _callRefreshToken(e){var t,n;if(!e)throw new fr;if(this.refreshingDeferred)return this.refreshingDeferred.promise;let s=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new Hu;let{data:a,error:c}=await this._refreshAccessToken(e);if(c)throw c;if(!a.session)throw new fr;await this._saveSession(a.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",a.session);let h={session:a.session,error:null};return this.refreshingDeferred.resolve(h),h}catch(a){if(this._debug(s,"error",a),ge(a)){let c={session:null,error:a};return mf(a)||await this._removeSession(),(t=this.refreshingDeferred)===null||t===void 0||t.resolve(c),c}throw(n=this.refreshingDeferred)===null||n===void 0||n.reject(a),a}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(e,t,n=!0){let s=`#_notifyAllSubscribers(${e})`;this._debug(s,"begin",t,`broadcast = ${n}`);try{this.broadcastChannel&&n&&this.broadcastChannel.postMessage({event:e,session:t});let a=[],c=Array.from(this.stateChangeEmitters.values()).map(async h=>{try{await h.callback(e,t)}catch(f){a.push(f)}});if(await Promise.all(c),a.length>0){for(let h=0;h<a.length;h+=1)console.error(a[h]);throw a[0]}}finally{this._debug(s,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await zg(this.storage,this.storageKey,e)}async _removeSession(){this._debug("#_removeSession()"),await Ju(this.storage,this.storageKey),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");let e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&Rr()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(t){console.error("removing visibilitychange callback failed",t)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");let e=setInterval(()=>this._autoRefreshTokenTick(),tc);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno!="undefined"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");let e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{let e=Date.now();try{return await this._useSession(async t=>{let{data:{session:n}}=t;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}let s=Math.floor((n.expires_at*1e3-e)/tc);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${tc}ms, refresh threshold is ${sI} ticks`),s<=sI&&await this._callRefreshToken(n.refresh_token)})}catch(t){console.error("Auto refresh tick failed with error. This is likely a transient error.",t)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof ec)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Rr()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){let t=`#_onVisibilityChanged(${e})`;this._debug(t,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(t,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t,n){let s=[`provider=${encodeURIComponent(t)}`];if(n!=null&&n.redirectTo&&s.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n!=null&&n.scopes&&s.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){let[a,c]=await Es(this.storage,this.storageKey),h=new URLSearchParams({code_challenge:`${encodeURIComponent(a)}`,code_challenge_method:`${encodeURIComponent(c)}`});s.push(h.toString())}if(n!=null&&n.queryParams){let a=new URLSearchParams(n.queryParams);s.push(a.toString())}return n!=null&&n.skipBrowserRedirect&&s.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async t=>{var n;let{data:s,error:a}=t;return a?{data:null,error:a}:await Ee(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token})})}catch(t){if(ge(t))return{data:null,error:t};throw t}}async _enroll(e){try{return await this._useSession(async t=>{var n,s;let{data:a,error:c}=t;if(c)return{data:null,error:c};let h=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:{issuer:e.issuer}),{data:f,error:m}=await Ee(this.fetch,"POST",`${this.url}/factors`,{body:h,headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token});return m?{data:null,error:m}:(e.factorType==="totp"&&(!((s=f==null?void 0:f.totp)===null||s===void 0)&&s.qr_code)&&(f.totp.qr_code=`data:image/svg+xml;utf-8,${f.totp.qr_code}`),{data:f,error:null})})}catch(t){if(ge(t))return{data:null,error:t};throw t}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var n;let{data:s,error:a}=t;if(a)return{data:null,error:a};let{data:c,error:h}=await Ee(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token});return h?{data:null,error:h}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+c.expires_in},c)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",c),{data:c,error:h})})}catch(t){if(ge(t))return{data:null,error:t};throw t}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var n;let{data:s,error:a}=t;return a?{data:null,error:a}:await Ee(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:{channel:e.channel},headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token})})}catch(t){if(ge(t))return{data:null,error:t};throw t}})}async _challengeAndVerify(e){let{data:t,error:n}=await this._challenge({factorId:e.factorId});return n?{data:null,error:n}:await this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})}async _listFactors(){let{data:{user:e},error:t}=await this.getUser();if(t)return{data:null,error:t};let n=(e==null?void 0:e.factors)||[],s=n.filter(c=>c.factor_type==="totp"&&c.status==="verified"),a=n.filter(c=>c.factor_type==="phone"&&c.status==="verified");return{data:{all:n,totp:s,phone:a},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var t,n;let{data:{session:s},error:a}=e;if(a)return{data:null,error:a};if(!s)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let c=this._decodeJWT(s.access_token),h=null;c.aal&&(h=c.aal);let f=h;((n=(t=s.user.factors)===null||t===void 0?void 0:t.filter(E=>E.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(f="aal2");let _=c.amr||[];return{data:{currentLevel:h,nextLevel:f,currentAuthenticationMethods:_},error:null}}))}};Ps.nextInstanceID=0;var CU=Ps,Qg=CU;var _f=class extends Qg{constructor(e){super(e)}};var DU=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},rc=class{constructor(e,t,n){var s,a,c;if(this.supabaseUrl=e,this.supabaseKey=t,!e)throw new Error("supabaseUrl is required.");if(!t)throw new Error("supabaseKey is required.");let h=FE(e);this.realtimeUrl=`${h}/realtime/v1`.replace(/^http/i,"ws"),this.authUrl=`${h}/auth/v1`,this.storageUrl=`${h}/storage/v1`,this.functionsUrl=`${h}/functions/v1`;let f=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,m={db:NE,realtime:LE,auth:Object.assign(Object.assign({},VE),{storageKey:f}),global:kE},_=UE(n!=null?n:{},m);this.storageKey=(s=_.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(a=_.global.headers)!==null&&a!==void 0?a:{},_.accessToken?(this.accessToken=_.accessToken,this.auth=new Proxy({},{get:(E,I)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(I)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((c=_.auth)!==null&&c!==void 0?c:{},this.headers,_.global.fetch),this.fetch=ME(t,this._getAccessToken.bind(this),_.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},_.realtime)),this.rest=new yE(`${h}/rest/v1`,{headers:this.headers,schema:_.db.schema,fetch:this.fetch}),_.accessToken||this._listenForAuthEvents()}get functions(){return new Nu(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new Gu(this.storageUrl,this.headers,this.fetch)}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,t={},n={}){return this.rest.rpc(e,t,n)}channel(e,t={config:{}}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,t;return DU(this,void 0,void 0,function*(){if(this.accessToken)return yield this.accessToken();let{data:n}=yield this.auth.getSession();return(t=(e=n.session)===null||e===void 0?void 0:e.access_token)!==null&&t!==void 0?t:null})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:n,storage:s,storageKey:a,flowType:c,lock:h,debug:f},m,_){let E={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new _f({url:this.authUrl,headers:Object.assign(Object.assign({},E),m),storageKey:a,autoRefreshToken:e,persistSession:t,detectSessionInUrl:n,storage:s,flowType:c,lock:h,debug:f,fetch:_,hasCustomAuthorizationHeader:"Authorization"in this.headers})}_initRealtimeClient(e){return new sa(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,n)=>{this._handleTokenChanged(t,"CLIENT",n==null?void 0:n.access_token)})}_handleTokenChanged(e,t,n){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==n?this.changedAccessToken=n:e==="SIGNED_OUT"&&(this.realtime.setAuth(),t=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};var aI=(r,e,t)=>new rc(r,e,t);var vI=Dd(hI(),1);var fI={id:"~date",test:r=>r instanceof Date,serialize:r=>({_:"~date",v:r.toISOString()}),deserialize:r=>new Date(r.v)};var dI={id:"~function",test:r=>typeof r=="function",serialize:r=>({_:"~function",v:r.toString()}),deserialize:v=>eval(v.v.toString())};var pI={id:"~infinity",test:r=>r===1/0||r===-1/0,serialize:r=>({_:"~infinity",v:r===1/0?1:0}),deserialize:r=>r.v==1?1/0:-1/0};var mI={id:"~nan",test:r=>Number.isNaN(r),serialize:r=>({_:"~nan"}),deserialize:r=>NaN};var gI={id:"~regexp",test:r=>r instanceof RegExp,serialize:r=>({_:"~regexp",v:r.source,f:r.flags}),deserialize:r=>new RegExp(r.v,r.f)};var _I={id:"~set",test:r=>r instanceof Set,serialize:r=>({_:"~set",v:Array.from(r)}),deserialize:r=>new Set(r.v)};var yI={id:"~undefined",test:r=>r===void 0,serialize:r=>({_:"~undefined"}),deserialize:r=>{}};var da={settings:{stringify:!0,destringify:!0,clone:!1,depth:0,modules:[fI,dI,pI,mI,gI,_I,yI],circular:!0,symetric:!1},loadedModules:{},loadModules(r){return r.map(e=>{if(De(e)){if(!e.id)throw new Error("Provided custom module does not expose an `id` property");return da.loadedModules[e.id]=e}else throw new Error("Unknown module type")})},serialize(r,e){let t=zl(e,da.settings),n=da.loadModules(t.modules),s=t.symetric?(0,vI.keyArrangeDeep)(r):t.clone?qr(r):r,a=new Map,c=(h,f)=>{let m=De(h);if(m&&t.circular){let I=a.get(h);if(I)return pi(s,f,{_:"~circular",p:I.join(".")});a.set(h,f)}let _=n.find(I=>I.test(h)),E=(!t.depth||f.length<t.depth)&&m;if(_){let I=_.serialize(h);if(_.recursive&&E){let k=At(h);t.symetric&&k.sort(),pi(s,f,I),k.forEach(B=>c(h[B],f.concat(B)))}else f.length?pi(s,f,I):s=I}else if(E){let I=At(h);t.symetric&&I.sort(),I.forEach(k=>c(h[k],f.concat(k)))}};return c(s,[]),t.stringify?JSON.stringify(s):s},deserialize(r,e){let t=zl(e,da.settings),n=da.loadModules(t.modules),s=Bd(n,"id"),a=t.destringify?JSON.parse(r):t.clone?qr(r):r,c=(h,f)=>{if(De(h)&&h._&&typeof h._=="string"&&h._.startsWith("~")&&s[h._]){let m=s[h._].deserialize(h);f.length?s[h._].recursive&&De(m)?(pi(a,f,m),At(m).forEach(_=>c(h[_],[...f,_]))):pi(a,f,m):a=m}else t.circular&&De(h)&&h._&&h._=="~circular"?pi(a,f,ru(a,h.p)):(!t.depth||f.length<t.depth)&&De(h)&&At(h).forEach(m=>c(h[m],f.concat(m)))};return c(a,[]),a}},ic=da;var wI="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var bI=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)e+=wI[t[r]&63];return e};var $e=class $e{constructor(e,t){gt(this,"path");gt(this,"docRef");gt(this,"value");gt(this,"throttle",250);gt(this,"heartbeatInterval",3e4);gt(this,"_destroyActions",[]);gt(this,"_heartbeatTimer");this.path=e,Object.assign(this,t),$e.session||($e.session=`syncro_${bI()}`)}debug(...e){}destroy(){return this.debug("Destroy!"),Promise.all(this._destroyActions.map(e=>e())).then(()=>this._destroyActions=[])}getReactive(e){console.warn("Syncro.getReactive has not been subclassed, assuming a POJO response");let t={...e};return{doc:t,setState(n){Object.entries(n||{}).forEach(([s,a])=>t[s]=a)},getState(){return qr(t)},watch(n){}}}static pathSplit(e){var n;let t={...(n=/^(?<entity>\w+?)::(?<id>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:::(?<relation>\w+?))?$/.exec(e))==null?void 0:n.groups};if(!t)throw new Error(`Invalid session path syntax "${e}"`);if(!(t.entity in Yg))throw new Error(`Unsupported entity "${e}" -> Entity="${t.entity}"`);return{...t,fsCollection:t.entity,fsId:t.relation?`${t.id}::${t.relation}`:t.id}}static toFirestore(e={}){return ic.serialize(e,{circular:!1,clone:!0,modules:[TI,...ic.settings.modules],stringify:!1})}static fromFirestore(e={}){return ic.deserialize(e,{circular:!1,clone:!0,modules:[TI,...ic.settings.modules],destringify:!1})}static fromFirestoreFields(e={}){let t={};for(let n in e){let s=e[n];if(["stringValue","booleanValue","doubleValue","integerValue","timestampValue","mapValue","arrayValue"].find(c=>c===n)){if(["stringValue","booleanValue","doubleValue","integerValue","timestampValue"].find(h=>h===n))return s;if(n=="mapValue")return $e.fromFirestoreFields(s.fields||{});if(n=="arrayValue"){let h=s.values;return h?h.map(f=>$e.fromFirestoreFields(f)):[]}}else t[n]=$e.fromFirestoreFields(s)}return t}static getSnapshot(e){let{fsCollection:t,fsId:n}=$e.pathSplit(e);return Promise.resolve().then(async()=>Jh(Ou($e.firestore,t,n))).then(s=>s?$e.fromFirestore(s.data()):null)}static setSnapshot(e,t,n){let s={method:"merge",...n},{fsCollection:a,fsId:c}=$e.pathSplit(e);return Promise.resolve().then(()=>(s.method=="merge"?"FirestoreUpdateDoc":"FirestoreSetDoc")(Ou($e.firestore,a,c),$e.toFirestore(t))).then(()=>t)}static wrapSupabase(e){return Promise.resolve(e).then(t=>{var n,s;if(t!=null&&t.error)throw/JSON object requested, multiple \(or no\) rows returned$/.test(t.error.message)?(console.warn("Supabase query threw record not found against query",e.url.search),console.warn("Supabase raw error",t),new Error("NOT-FOUND")):(console.warn("Supabase query threw",t.error.message),new Error(`${((n=t.error)==null?void 0:n.code)||"UnknownError"}: ${((s=t.error)==null?void 0:s.message)||"Unknown Supabase error"}`));if(t.data)return t.data})}mount(){let{fsCollection:e,fsId:t,entity:n,id:s,relation:a}=$e.pathSplit(this.path),c,h;return Promise.resolve().then(()=>this.setHeartbeat(!1)).then(async()=>{this.docRef=Ou($e.firestore,e,t);let f=$e.fromFirestore((await Jh(this.docRef)).data());if(c=this.getReactive(f),!c.doc||!c.setState||!c.getState||!c.watch)throw new Error("Syncro.getReactive() requires a returned `doc`, `setState()`, `getState()` + `watch()`");this.value=h=c.doc,this.debug("Initial state",{doc:h}),this._destroyActions.push(tE(this.docRef,m=>{let _=$e.fromFirestore(m.data());this.debug("Incoming snapshot",{snapshotData:_}),c.setState(_)}))}).then(()=>{if(Fd(h))return this.debug("Populate initial state"),Promise.resolve().then(()=>Yg[n]||Promise.reject(`Unknown Sync entity "${n}"`)).then(()=>Yg[n].initState({supabase:$e.supabase,fsCollection:e,fsId:t,entity:n,id:s,relation:a})).then(f=>bg(this.docRef,$e.toFirestore(f)))}).then(()=>{c.watch(jd(f=>{this.debug("Local change",{newState:f}),eE(this.docRef,$e.toFirestore(f))},this.throttle))}).then(()=>this.setHeartbeat(!0,{immediate:!0})).then(()=>this)}setHeartbeat(e=!0,t){let n={immediate:!0,...t};clearTimeout(this._heartbeatTimer),e&&(this._heartbeatTimer=setTimeout(async()=>{await this.heartbeat(),e&&this.setHeartbeat(!0)},this.heartbeatInterval),n.immediate&&this.heartbeat())}async heartbeat(){this.debug("heartbeat!");let e=new Date().toISOString(),t=Ou($e.firestore,"presence",this.path),n=await Jh(t);await bg(t,{latest:e,...!n.exists()&&{created:e,lastFlush:null},sessions:{[$e.session]:e}},{merge:!0})}flush(e){let t={destroy:!1,...e};return fetch(`https://tera-tools.com/api/sync/${this.path}/flush`+(t.destroy?"?destroy=1":""),{method:"post"}).then(n=>n.ok?null:Promise.reject(n.statusText||"An error occured"))}};gt($e,"firebase"),gt($e,"firestore"),gt($e,"supabase"),gt($e,"session");var Tt=$e;var Yg={projects:{singular:"project",initState({supabase:r,id:e}){return Tt.wrapSupabase(r.from("projects").select("data").limit(1).eq("id",e)).then(t=>t.length==1?t[0]:Promise.reject(`Syncro project "${e}" not found`)).then(t=>t.data)},flushState({supabase:r,state:e,fsId:t}){return Tt.wrapSupabase(r.rpc("syncro_merge_data",{table_name:"projects",entity_id:t,new_data:e}))}},project_namespaces:{singular:"project namespace",initState({supabase:r,id:e,relation:t}){if(!t)throw new Error('Project namespace relation missing, path should resemble "project_namespaces::${PROJECT}::${RELATION}"');return Tt.wrapSupabase(r.from("project_namespaces").select("data").limit(1).eq("project",e).eq("name",t)).then(n=>n.length==1?n[0]:Tt.wrapSupabase(r.from("project_namespaces").insert({project:e,name:t,data:{}}).select("data"))).then(n=>n.data)},flushState({supabase:r,state:e,id:t,relation:n}){return Tt.wrapSupabase(r.from("project_namespaces").update({edited_at:new Date,data:e}).eq("project",t).eq("name",n))}},test:{singular:"test",initState({supabase:r,id:e}){return Tt.wrapSupabase(r.from("test").select("data").limit(1).eq("id",e)).then(t=>t.length==1?t[0]:Promise.reject(`Syncro test item "${e}" not found`)).then(t=>t.data)},flushState({supabase:r,state:e,fsId:t}){return Tt.wrapSupabase(r.rpc("syncro_merge_data",{table_name:"test",entity_id:t,new_data:e}))}},users:{singular:"user",initState({supabase:r,id:e}){return Tt.wrapSupabase(r.from("users").select("data").limit(1).eq("id",e)).then(t=>t.length==1?t[0]:Promise.reject(`Syncro user "${e}" not found`)).then(t=>t.data)},flushState({supabase:r,state:e,fsId:t}){return Tt.wrapSupabase(r.rpc("syncro_merge_data",{table_name:"users",entity_id:t,new_data:e}))}}},TI={id:"~array",recursive:!0,test:r=>Array.isArray(r),serialize:r=>({_:"~array",...r}),deserialize:r=>{let e=Array.from({length:Object.keys(r).length-1});return Object.entries(r).filter(([t])=>t!=="_").forEach(([t,n])=>e[+t]=n),e}};var sc=class{init(){}constructor(e,t){}};var oc=class extends sc{constructor(){super(...arguments);gt(this,"syncros",{})}async init(t){let n={firebaseApiKey:null,firebaseAuthDomain:null,firebaseProjectId:null,firebaseAppId:null,supabaseUrl:null,supabaseKey:null,...await this.getCredentials(),...t},s=Object.keys(n).filter(a=>a===null);if(s.length>0)throw new Error("Firebase plugin requires mandatory options: "+s.join(", "));Tt.firebase=op({apiKey:n.firebaseApiKey,authDomain:n.firebaseAuthDomain,projectId:n.firebaseProjectId,appId:n.firebaseAppId}),Tt.firestore=WT(this.firebase),Tt.supabase=aI(n.supabaseUrl,n.supabaseKey)}_mountNamespace(t){let n;return Promise.resolve().then(()=>this.requireProject()).then(s=>{let a=t=="_PROJECT"?`projects::${s.id}`:`project_namespaces::${s.id}::${t}`;return n=this.syncros[t]=new Tt(a,{debug:(...c)=>this.debug(`SYNCRO://${a}`,...c),getReactive:this.getReactive}),n.mount()}).then(()=>{this.namespaces[t]=n.value})}_unmountNamespace(t){let n=this.syncros[t];return delete this.namespaces[t],delete this.syncros[t],n.destroy()}};var Xg=class extends oc{constructor(){super(...arguments);gt(this,"Vue");gt(this,"project",null);gt(this,"reactiveId",1001)}async init(t){let n={app:null,Vue:null,globalName:"$tera",...t};if(!n.Vue)throw new Error("Vue instance to use must be specified in init options as `Vue`");if(this.Vue=n.Vue,!n.app)throw new Error("Vue Root / App instance to use must be specified in init options as `app`");this.app=n.app,n.globalName&&(this.Vue.prototype[n.globalName]=this),await super.init(n),this.project=await this.mountNamespace("_PROJECT")}getReactive(t){let n=this.Vue.observable(t),s=`_teraFy_${this.reactiveId++}`;return this.app[s]=n,{doc:n,setState(a){Object.entries(a||{}).filter(([c])=>!Ud(n[c],a[c])).forEach(([c,h])=>n[c]=h)},getState(){return qr(n)},watch:a=>{this.app.$watch(s,a,{deep:!0})}}}bindProjectState(t){let n={component:null,componentKey:null,autoRequire:!0,read:!0,write:!0,throttle:{wait:200,maxWait:2e3,leading:!1,trailing:!0},...t};return Promise.resolve().then(()=>Promise.all([this.getProjectState({autoRequire:n.autoRequire}),(()=>{if(!n.componentKey){for(let s=0;s<50;s++){let a=`terafy_${s}`;if(!Object.hasOwnProperty(n.component,a)){n.componentKey=a;return}}throw new Error("Unable to find unique key to allocate against Vue2 component")}})()])).then(([s])=>{this.debug("INFO",2,"Got project snapshot",s);let a=this.Vue.observable(s);if(n.component[n.componentKey]=a,n.read&&this.events.on(`update:projects/${a.id}`,c=>{var h;(h=c==null?void 0:c.lastPatch)!=null&&h.session&&c.lastPatch.session==this.settings.session||(this.debug("INFO",5,"Update Vue2 Remote->Local",{new:c,old:a}),this.merge(a,c))}),n.write){if(!n.component)throw new Error("bindProjectState requires a VueComponent specified as `component`");let c=qr(s),h=()=>{let f=qr(s);this.debug("INFO",5,"Update Vue2 Local->Remote",{new:f,old:c}),this.createProjectStatePatch(f,c),c=f};n.component.$watch(n.componentKey,n.throttle?debounce(h,n.throttle.wait,n.throttle):h,{deep:!0})}return a})}merge(t,...n){return n.forEach(s=>Object.keys(s).forEach(a=>{isPlainObject(s[a])?(a in t||this.Vue.set(t,a,{}),this.merge(t[a],s[a])):this.Vue.set(t,a,s[a])})),t}};export{Xg as default};
|
|
46
|
+
});`,sa=class{constructor(e,t){var n;this.accessTokenValue=null,this.apiKey=null,this.channels=[],this.endPoint="",this.httpEndpoint="",this.headers=bE,this.params={},this.timeout=of,this.heartbeatIntervalMs=3e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=iU,this.conn=null,this.sendBuffer=[],this.serializer=new ju,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._resolveFetch=a=>{let c;return a?c=a:typeof fetch=="undefined"?c=(...h)=>Promise.resolve().then(()=>(Ei(),gs)).then(({default:f})=>f(...h)):c=fetch,(...h)=>c(...h)},this.endPoint=`${e}/${sf.websocket}`,this.httpEndpoint=af(e),t!=null&&t.transport?this.transport=t.transport:this.transport=null,t!=null&&t.params&&(this.params=t.params),t!=null&&t.headers&&(this.headers=Object.assign(Object.assign({},this.headers),t.headers)),t!=null&&t.timeout&&(this.timeout=t.timeout),t!=null&&t.logger&&(this.logger=t.logger),t!=null&&t.heartbeatIntervalMs&&(this.heartbeatIntervalMs=t.heartbeatIntervalMs);let s=(n=t==null?void 0:t.params)===null||n===void 0?void 0:n.apikey;if(s&&(this.accessTokenValue=s,this.apiKey=s),this.reconnectAfterMs=t!=null&&t.reconnectAfterMs?t.reconnectAfterMs:a=>[1e3,2e3,5e3,1e4][a-1]||1e4,this.encode=t!=null&&t.encode?t.encode:(a,c)=>c(JSON.stringify(a)),this.decode=t!=null&&t.decode?t.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new ys(async()=>{this.disconnect(),this.connect()},this.reconnectAfterMs),this.fetch=this._resolveFetch(t==null?void 0:t.fetch),t!=null&&t.worker){if(typeof window!="undefined"&&!window.Worker)throw new Error("Web Worker is not supported");this.worker=(t==null?void 0:t.worker)||!1,this.workerUrl=t==null?void 0:t.workerUrl}this.accessToken=(t==null?void 0:t.accessToken)||null}connect(){if(!this.conn){if(this.transport){this.conn=new this.transport(this.endpointURL(),void 0,{headers:this.headers});return}if(sU){this.conn=new WebSocket(this.endpointURL()),this.setupConnection();return}this.conn=new Bg(this.endpointURL(),void 0,{close:()=>{this.conn=null}}),Promise.resolve().then(()=>Dd(AE())).then(({default:e})=>{this.conn=new e(this.endpointURL(),void 0,{headers:this.headers}),this.setupConnection()})}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:TE}))}disconnect(e,t){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,t!=null?t:""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset())}getChannels(){return this.channels}async removeChannel(e){let t=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),t}async removeAllChannels(){let e=await Promise.all(this.channels.map(t=>t.unsubscribe()));return this.disconnect(),e}log(e,t,n){this.logger(e,t,n)}connectionState(){switch(this.conn&&this.conn.readyState){case _s.connecting:return Ii.Connecting;case _s.open:return Ii.Open;case _s.closing:return Ii.Closing;default:return Ii.Closed}}isConnected(){return this.connectionState()===Ii.Open}channel(e,t={config:{}}){let n=new ia(`realtime:${e}`,t,this);return this.channels.push(n),n}push(e){let{topic:t,event:n,payload:s,ref:a}=e,c=()=>{this.encode(e,h=>{var f;(f=this.conn)===null||f===void 0||f.send(h)})};this.log("push",`${t} ${n} (${a})`,s),this.isConnected()?c():this.sendBuffer.push(c)}async setAuth(e=null){let t=e||this.accessToken&&await this.accessToken()||this.accessTokenValue;if(t){let n=null;try{n=JSON.parse(atob(t.split(".")[1]))}catch{}if(n&&n.exp&&!(Math.floor(Date.now()/1e3)-n.exp<0))return this.log("auth",`InvalidJWTToken: Invalid value for JWT claim "exp" with value ${n.exp}`),Promise.reject(`InvalidJWTToken: Invalid value for JWT claim "exp" with value ${n.exp}`);this.accessTokenValue=t,this.channels.forEach(s=>{t&&s.updateJoinPayload({access_token:t}),s.joinedOnce&&s._isJoined()&&s._push(rr.access_token,{access_token:t})})}}async sendHeartbeat(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),(e=this.conn)===null||e===void 0||e.close(EE,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth()}}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let t=this.channels.find(n=>n.topic===e&&(n._isJoined()||n._isJoining()));t&&(this.log("transport",`leaving duplicate topic "${e}"`),t.unsubscribe())}_remove(e){this.channels=this.channels.filter(t=>t._joinRef()!==e._joinRef())}setupConnection(){this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_onConnMessage(e){this.decode(e.data,t=>{let{topic:n,event:s,payload:a,ref:c}=t;c&&c===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null),this.log("receive",`${a.status||""} ${n} ${s} ${c&&"("+c+")"||""}`,a),this.channels.filter(h=>h._isMember(n)).forEach(h=>h._trigger(s,a,c)),this.stateChangeCallbacks.message.forEach(h=>h(t))})}async _onConnOpen(){if(this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this.reconnectTimer.reset(),!this.worker)this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs);else{this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");let e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=t=>{this.log("worker","worker error",t.message),this.workerRef.terminate()},this.workerRef.onmessage=t=>{t.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}this.stateChangeCallbacks.open.forEach(e=>e())}_onConnClose(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(t=>t(e))}_onConnError(e){this.log("transport",e.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach(t=>t(e))}_triggerChanError(){this.channels.forEach(e=>e._trigger(rr.error))}_appendParams(e,t){if(Object.keys(t).length===0)return e;let n=e.match(/\?/)?"&":"?",s=new URLSearchParams(t);return`${e}${n}${s}`}_workerObjectUrl(e){let t;if(e)t=e;else{let n=new Blob([oU],{type:"application/javascript"});t=URL.createObjectURL(n)}return t}},Bg=class{constructor(e,t,n){this.binaryType="arraybuffer",this.onclose=()=>{},this.onerror=()=>{},this.onmessage=()=>{},this.onopen=()=>{},this.readyState=_s.connecting,this.send=()=>{},this.url=null,this.url=e,this.close=n.close}};var oa=class extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}};function at(r){return typeof r=="object"&&r!==null&&"__isStorageError"in r}var uf=class extends oa{constructor(e,t){super(e),this.name="StorageApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}},ws=class extends oa{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}};var aU=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},lf=r=>{let e;return r?e=r:typeof fetch=="undefined"?e=(...t)=>Promise.resolve().then(()=>(Ei(),gs)).then(({default:n})=>n(...t)):e=fetch,(...t)=>e(...t)},SE=()=>aU(void 0,void 0,void 0,function*(){return typeof Response=="undefined"?(yield Promise.resolve().then(()=>(Ei(),gs))).Response:Response}),cf=r=>{if(Array.isArray(r))return r.map(t=>cf(t));if(typeof r=="function"||r!==Object(r))return r;let e={};return Object.entries(r).forEach(([t,n])=>{let s=t.replace(/([-_][a-z])/gi,a=>a.toUpperCase().replace(/[-_]/g,""));e[s]=cf(n)}),e};var bs=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},jg=r=>r.msg||r.message||r.error_description||r.error||JSON.stringify(r),uU=(r,e,t)=>bs(void 0,void 0,void 0,function*(){let n=yield SE();r instanceof n&&!(t!=null&&t.noResolveJson)?r.json().then(s=>{e(new uf(jg(s),r.status||500))}).catch(s=>{e(new ws(jg(s),s))}):e(new ws(jg(r),r))}),cU=(r,e,t,n)=>{let s={method:r,headers:(e==null?void 0:e.headers)||{}};return r==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json"},e==null?void 0:e.headers),n&&(s.body=JSON.stringify(n)),Object.assign(Object.assign({},s),t))};function $u(r,e,t,n,s,a){return bs(this,void 0,void 0,function*(){return new Promise((c,h)=>{r(t,cU(e,n,s,a)).then(f=>{if(!f.ok)throw f;return n!=null&&n.noResolveJson?f:f.json()}).then(f=>c(f)).catch(f=>uU(f,h,n))})})}function aa(r,e,t,n){return bs(this,void 0,void 0,function*(){return $u(r,"GET",e,t,n)})}function en(r,e,t,n,s){return bs(this,void 0,void 0,function*(){return $u(r,"POST",e,n,s,t)})}function RE(r,e,t,n,s){return bs(this,void 0,void 0,function*(){return $u(r,"PUT",e,n,s,t)})}function PE(r,e,t,n){return bs(this,void 0,void 0,function*(){return $u(r,"HEAD",e,Object.assign(Object.assign({},t),{noResolveJson:!0}),n)})}function hf(r,e,t,n,s){return bs(this,void 0,void 0,function*(){return $u(r,"DELETE",e,n,s,t)})}var Kt=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},lU={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},CE={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1},qu=class{constructor(e,t={},n,s){this.url=e,this.headers=t,this.bucketId=n,this.fetch=lf(s)}uploadOrUpdate(e,t,n,s){return Kt(this,void 0,void 0,function*(){try{let a,c=Object.assign(Object.assign({},CE),s),h=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(c.upsert)}),f=c.metadata;typeof Blob!="undefined"&&n instanceof Blob?(a=new FormData,a.append("cacheControl",c.cacheControl),f&&a.append("metadata",this.encodeMetadata(f)),a.append("",n)):typeof FormData!="undefined"&&n instanceof FormData?(a=n,a.append("cacheControl",c.cacheControl),f&&a.append("metadata",this.encodeMetadata(f))):(a=n,h["cache-control"]=`max-age=${c.cacheControl}`,h["content-type"]=c.contentType,f&&(h["x-metadata"]=this.toBase64(this.encodeMetadata(f)))),s!=null&&s.headers&&(h=Object.assign(Object.assign({},h),s.headers));let m=this._removeEmptyFolders(t),_=this._getFinalPath(m),E=yield this.fetch(`${this.url}/object/${_}`,Object.assign({method:e,body:a,headers:h},c!=null&&c.duplex?{duplex:c.duplex}:{})),I=yield E.json();return E.ok?{data:{path:m,id:I.Id,fullPath:I.Key},error:null}:{data:null,error:I}}catch(a){if(at(a))return{data:null,error:a};throw a}})}upload(e,t,n){return Kt(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,t,n)})}uploadToSignedUrl(e,t,n,s){return Kt(this,void 0,void 0,function*(){let a=this._removeEmptyFolders(e),c=this._getFinalPath(a),h=new URL(this.url+`/object/upload/sign/${c}`);h.searchParams.set("token",t);try{let f,m=Object.assign({upsert:CE.upsert},s),_=Object.assign(Object.assign({},this.headers),{"x-upsert":String(m.upsert)});typeof Blob!="undefined"&&n instanceof Blob?(f=new FormData,f.append("cacheControl",m.cacheControl),f.append("",n)):typeof FormData!="undefined"&&n instanceof FormData?(f=n,f.append("cacheControl",m.cacheControl)):(f=n,_["cache-control"]=`max-age=${m.cacheControl}`,_["content-type"]=m.contentType);let E=yield this.fetch(h.toString(),{method:"PUT",body:f,headers:_}),I=yield E.json();return E.ok?{data:{path:a,fullPath:I.Key},error:null}:{data:null,error:I}}catch(f){if(at(f))return{data:null,error:f};throw f}})}createSignedUploadUrl(e,t){return Kt(this,void 0,void 0,function*(){try{let n=this._getFinalPath(e),s=Object.assign({},this.headers);t!=null&&t.upsert&&(s["x-upsert"]="true");let a=yield en(this.fetch,`${this.url}/object/upload/sign/${n}`,{},{headers:s}),c=new URL(this.url+a.url),h=c.searchParams.get("token");if(!h)throw new oa("No token returned by API");return{data:{signedUrl:c.toString(),path:e,token:h},error:null}}catch(n){if(at(n))return{data:null,error:n};throw n}})}update(e,t,n){return Kt(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,t,n)})}move(e,t,n){return Kt(this,void 0,void 0,function*(){try{return{data:yield en(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers}),error:null}}catch(s){if(at(s))return{data:null,error:s};throw s}})}copy(e,t,n){return Kt(this,void 0,void 0,function*(){try{return{data:{path:(yield en(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers})).Key},error:null}}catch(s){if(at(s))return{data:null,error:s};throw s}})}createSignedUrl(e,t,n){return Kt(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),a=yield en(this.fetch,`${this.url}/object/sign/${s}`,Object.assign({expiresIn:t},n!=null&&n.transform?{transform:n.transform}:{}),{headers:this.headers}),c=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return a={signedUrl:encodeURI(`${this.url}${a.signedURL}${c}`)},{data:a,error:null}}catch(s){if(at(s))return{data:null,error:s};throw s}})}createSignedUrls(e,t,n){return Kt(this,void 0,void 0,function*(){try{let s=yield en(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),a=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return{data:s.map(c=>Object.assign(Object.assign({},c),{signedUrl:c.signedURL?encodeURI(`${this.url}${c.signedURL}${a}`):null})),error:null}}catch(s){if(at(s))return{data:null,error:s};throw s}})}download(e,t){return Kt(this,void 0,void 0,function*(){let s=typeof(t==null?void 0:t.transform)!="undefined"?"render/image/authenticated":"object",a=this.transformOptsToQueryString((t==null?void 0:t.transform)||{}),c=a?`?${a}`:"";try{let h=this._getFinalPath(e);return{data:yield(yield aa(this.fetch,`${this.url}/${s}/${h}${c}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(h){if(at(h))return{data:null,error:h};throw h}})}info(e){return Kt(this,void 0,void 0,function*(){let t=this._getFinalPath(e);try{let n=yield aa(this.fetch,`${this.url}/object/info/${t}`,{headers:this.headers});return{data:cf(n),error:null}}catch(n){if(at(n))return{data:null,error:n};throw n}})}exists(e){return Kt(this,void 0,void 0,function*(){let t=this._getFinalPath(e);try{return yield PE(this.fetch,`${this.url}/object/${t}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(at(n)&&n instanceof ws){let s=n.originalError;if([400,404].includes(s==null?void 0:s.status))return{data:!1,error:n}}throw n}})}getPublicUrl(e,t){let n=this._getFinalPath(e),s=[],a=t!=null&&t.download?`download=${t.download===!0?"":t.download}`:"";a!==""&&s.push(a);let h=typeof(t==null?void 0:t.transform)!="undefined"?"render/image":"object",f=this.transformOptsToQueryString((t==null?void 0:t.transform)||{});f!==""&&s.push(f);let m=s.join("&");return m!==""&&(m=`?${m}`),{data:{publicUrl:encodeURI(`${this.url}/${h}/public/${n}${m}`)}}}remove(e){return Kt(this,void 0,void 0,function*(){try{return{data:yield hf(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(t){if(at(t))return{data:null,error:t};throw t}})}list(e,t,n){return Kt(this,void 0,void 0,function*(){try{let s=Object.assign(Object.assign(Object.assign({},lU),t),{prefix:e||""});return{data:yield en(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},n),error:null}}catch(s){if(at(s))return{data:null,error:s};throw s}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer!="undefined"?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){let t=[];return e.width&&t.push(`width=${e.width}`),e.height&&t.push(`height=${e.height}`),e.resize&&t.push(`resize=${e.resize}`),e.format&&t.push(`format=${e.format}`),e.quality&&t.push(`quality=${e.quality}`),t.join("&")}};var DE="2.7.1";var OE={"X-Client-Info":`storage-js/${DE}`};var ua=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},zu=class{constructor(e,t={},n){this.url=e,this.headers=Object.assign(Object.assign({},OE),t),this.fetch=lf(n)}listBuckets(){return ua(this,void 0,void 0,function*(){try{return{data:yield aa(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(at(e))return{data:null,error:e};throw e}})}getBucket(e){return ua(this,void 0,void 0,function*(){try{return{data:yield aa(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(t){if(at(t))return{data:null,error:t};throw t}})}createBucket(e,t={public:!1}){return ua(this,void 0,void 0,function*(){try{return{data:yield en(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(at(n))return{data:null,error:n};throw n}})}updateBucket(e,t){return ua(this,void 0,void 0,function*(){try{return{data:yield RE(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(at(n))return{data:null,error:n};throw n}})}emptyBucket(e){return ua(this,void 0,void 0,function*(){try{return{data:yield en(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(t){if(at(t))return{data:null,error:t};throw t}})}deleteBucket(e){return ua(this,void 0,void 0,function*(){try{return{data:yield hf(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(t){if(at(t))return{data:null,error:t};throw t}})}};var Gu=class extends zu{constructor(e,t={},n){super(e,t,n)}from(e){return new qu(this.url,this.headers,e,this.fetch)}};var kE="2.48.1";var Ku="";typeof Deno!="undefined"?Ku="deno":typeof document!="undefined"?Ku="web":typeof navigator!="undefined"&&navigator.product==="ReactNative"?Ku="react-native":Ku="node";var hU={"X-Client-Info":`supabase-js-${Ku}/${kE}`},NE={headers:hU},VE={schema:"public"},LE={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},ME={};Ei();var fU=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},dU=r=>{let e;return r?e=r:typeof fetch=="undefined"?e=Tg:e=fetch,(...t)=>e(...t)},pU=()=>typeof Headers=="undefined"?Eg:Headers,FE=(r,e,t)=>{let n=dU(t),s=pU();return(a,c)=>fU(void 0,void 0,void 0,function*(){var h;let f=(h=yield e())!==null&&h!==void 0?h:r,m=new s(c==null?void 0:c.headers);return m.has("apikey")||m.set("apikey",r),m.has("Authorization")||m.set("Authorization",`Bearer ${f}`),n(a,Object.assign(Object.assign({},c),{headers:m}))})};var mU=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})};function UE(r){return r.replace(/\/$/,"")}function BE(r,e){let{db:t,auth:n,realtime:s,global:a}=r,{db:c,auth:h,realtime:f,global:m}=e,_={db:Object.assign(Object.assign({},c),t),auth:Object.assign(Object.assign({},h),n),realtime:Object.assign(Object.assign({},f),s),global:Object.assign(Object.assign({},m),a),accessToken:()=>mU(this,void 0,void 0,function*(){return""})};return r.accessToken?_.accessToken=r.accessToken:delete _.accessToken,_}var ff="2.67.3";var jE="http://localhost:9999",$E="supabase.auth.token";var qE={"X-Client-Info":`gotrue-js/${ff}`},$g=10;var Wu="X-Supabase-Api-Version",qg={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}};function zE(r){return Math.round(Date.now()/1e3)+r}function GE(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){let e=Math.random()*16|0;return(r=="x"?e:e&3|8).toString(16)})}var Rr=()=>typeof window!="undefined"&&typeof document!="undefined",Ts={tested:!1,writable:!1},xi=()=>{if(!Rr())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Ts.tested)return Ts.writable;let r=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(r,r),globalThis.localStorage.removeItem(r),Ts.tested=!0,Ts.writable=!0}catch{Ts.tested=!0,Ts.writable=!1}return Ts.writable};function KE(r){let e={},t=new URL(r);if(t.hash&&t.hash[0]==="#")try{new URLSearchParams(t.hash.substring(1)).forEach((s,a)=>{e[a]=s})}catch{}return t.searchParams.forEach((n,s)=>{e[s]=n}),e}var df=r=>{let e;return r?e=r:typeof fetch=="undefined"?e=(...t)=>Promise.resolve().then(()=>(Ei(),gs)).then(({default:n})=>n(...t)):e=fetch,(...t)=>e(...t)},WE=r=>typeof r=="object"&&r!==null&&"status"in r&&"ok"in r&&"json"in r&&typeof r.json=="function",zg=async(r,e,t)=>{await r.setItem(e,JSON.stringify(t))},Qu=async(r,e)=>{let t=await r.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return t}},Ju=async(r,e)=>{await r.removeItem(e)};function gU(r){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t="",n,s,a,c,h,f,m,_=0;for(r=r.replace("-","+").replace("_","/");_<r.length;)c=e.indexOf(r.charAt(_++)),h=e.indexOf(r.charAt(_++)),f=e.indexOf(r.charAt(_++)),m=e.indexOf(r.charAt(_++)),n=c<<2|h>>4,s=(h&15)<<4|f>>2,a=(f&3)<<6|m,t=t+String.fromCharCode(n),f!=64&&s!=0&&(t=t+String.fromCharCode(s)),m!=64&&a!=0&&(t=t+String.fromCharCode(a));return t}var Hu=class r{constructor(){this.promise=new r.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}};Hu.promiseConstructor=Promise;function Gg(r){let e=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i,t=r.split(".");if(t.length!==3)throw new Error("JWT is not valid: not a JWT structure");if(!e.test(t[1]))throw new Error("JWT is not valid: payload is not in base64url format");let n=t[1];return JSON.parse(gU(n))}async function HE(r){return await new Promise(e=>{setTimeout(()=>e(null),r)})}function QE(r,e){return new Promise((n,s)=>{(async()=>{for(let a=0;a<1/0;a++)try{let c=await r(a);if(!e(a,null,c)){n(c);return}}catch(c){if(!e(a,c)){s(c);return}}})()})}function _U(r){return("0"+r.toString(16)).substr(-2)}function yU(){let e=new Uint32Array(56);if(typeof crypto=="undefined"){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=t.length,s="";for(let a=0;a<56;a++)s+=t.charAt(Math.floor(Math.random()*n));return s}return crypto.getRandomValues(e),Array.from(e,_U).join("")}async function vU(r){let t=new TextEncoder().encode(r),n=await crypto.subtle.digest("SHA-256",t),s=new Uint8Array(n);return Array.from(s).map(a=>String.fromCharCode(a)).join("")}function wU(r){return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function bU(r){if(!(typeof crypto!="undefined"&&typeof crypto.subtle!="undefined"&&typeof TextEncoder!="undefined"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),r;let t=await vU(r);return wU(t)}async function Es(r,e,t=!1){let n=yU(),s=n;t&&(s+="/PASSWORD_RECOVERY"),await zg(r,`${e}-code-verifier`,s);let a=await bU(n);return[a,n===a?"plain":"s256"]}var TU=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function JE(r){let e=r.headers.get(Wu);if(!e||!e.match(TU))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}var Yu=class extends Error{constructor(e,t,n){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t,this.code=n}};function ge(r){return typeof r=="object"&&r!==null&&"__isAuthError"in r}var pf=class extends Yu{constructor(e,t,n){super(e,t,n),this.name="AuthApiError",this.status=t,this.code=n}};function YE(r){return ge(r)&&r.name==="AuthApiError"}var ca=class extends Yu{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}},Nn=class extends Yu{constructor(e,t,n,s){super(e,n,s),this.name=t,this.status=n}},fr=class extends Nn{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}};function XE(r){return ge(r)&&r.name==="AuthSessionMissingError"}var la=class extends Nn{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}},Is=class extends Nn{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}},xs=class extends Nn{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}};function ZE(r){return ge(r)&&r.name==="AuthImplicitGrantRedirectError"}var Xu=class extends Nn{constructor(e,t=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}},ha=class extends Nn{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}};function mf(r){return ge(r)&&r.name==="AuthRetryableFetchError"}var Zu=class extends Nn{constructor(e,t,n){super(e,"AuthWeakPasswordError",t,"weak_password"),this.reasons=n}};var EU=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t},As=r=>r.msg||r.message||r.error_description||r.error||JSON.stringify(r),IU=[502,503,504];async function eI(r){var e;if(!WE(r))throw new ha(As(r),0);if(IU.includes(r.status))throw new ha(As(r),r.status);let t;try{t=await r.json()}catch(a){throw new ca(As(a),a)}let n,s=JE(r);if(s&&s.getTime()>=qg["2024-01-01"].timestamp&&typeof t=="object"&&t&&typeof t.code=="string"?n=t.code:typeof t=="object"&&t&&typeof t.error_code=="string"&&(n=t.error_code),n){if(n==="weak_password")throw new Zu(As(t),r.status,((e=t.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(n==="session_not_found")throw new fr}else if(typeof t=="object"&&t&&typeof t.weak_password=="object"&&t.weak_password&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.reasons.reduce((a,c)=>a&&typeof c=="string",!0))throw new Zu(As(t),r.status,t.weak_password.reasons);throw new pf(As(t),r.status||500,n)}var xU=(r,e,t,n)=>{let s={method:r,headers:(e==null?void 0:e.headers)||{}};return r==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),s.body=JSON.stringify(n),Object.assign(Object.assign({},s),t))};async function Ee(r,e,t,n){var s;let a=Object.assign({},n==null?void 0:n.headers);a[Wu]||(a[Wu]=qg["2024-01-01"].name),n!=null&&n.jwt&&(a.Authorization=`Bearer ${n.jwt}`);let c=(s=n==null?void 0:n.query)!==null&&s!==void 0?s:{};n!=null&&n.redirectTo&&(c.redirect_to=n.redirectTo);let h=Object.keys(c).length?"?"+new URLSearchParams(c).toString():"",f=await AU(r,e,t+h,{headers:a,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(f):{data:Object.assign({},f),error:null}}async function AU(r,e,t,n,s,a){let c=xU(e,n,s,a),h;try{h=await r(t,Object.assign({},c))}catch(f){throw console.error(f),new ha(As(f),0)}if(h.ok||await eI(h),n!=null&&n.noResolveJson)return h;try{return await h.json()}catch(f){await eI(f)}}function Vn(r){var e;let t=null;SU(r)&&(t=Object.assign({},r),r.expires_at||(t.expires_at=zE(r.expires_in)));let n=(e=r.user)!==null&&e!==void 0?e:r;return{data:{session:t,user:n},error:null}}function Kg(r){let e=Vn(r);return!e.error&&r.weak_password&&typeof r.weak_password=="object"&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.message&&typeof r.weak_password.message=="string"&&r.weak_password.reasons.reduce((t,n)=>t&&typeof n=="string",!0)&&(e.data.weak_password=r.weak_password),e}function tn(r){var e;return{data:{user:(e=r.user)!==null&&e!==void 0?e:r},error:null}}function tI(r){return{data:r,error:null}}function rI(r){let{action_link:e,email_otp:t,hashed_token:n,redirect_to:s,verification_type:a}=r,c=EU(r,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),h={action_link:e,email_otp:t,hashed_token:n,redirect_to:s,verification_type:a},f=Object.assign({},c);return{data:{properties:h,user:f},error:null}}function nI(r){return r}function SU(r){return r.access_token&&r.refresh_token&&r.expires_in}var RU=function(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t},Ss=class{constructor({url:e="",headers:t={},fetch:n}){this.url=e,this.headers=t,this.fetch=df(n),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}async signOut(e,t="global"){try{return await Ee(this.fetch,"POST",`${this.url}/logout?scope=${t}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(n){if(ge(n))return{data:null,error:n};throw n}}async inviteUserByEmail(e,t={}){try{return await Ee(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:tn})}catch(n){if(ge(n))return{data:{user:null},error:n};throw n}}async generateLink(e){try{let{options:t}=e,n=RU(e,["options"]),s=Object.assign(Object.assign({},n),t);return"newEmail"in n&&(s.new_email=n==null?void 0:n.newEmail,delete s.newEmail),await Ee(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:rI,redirectTo:t==null?void 0:t.redirectTo})}catch(t){if(ge(t))return{data:{properties:null,user:null},error:t};throw t}}async createUser(e){try{return await Ee(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:tn})}catch(t){if(ge(t))return{data:{user:null},error:t};throw t}}async listUsers(e){var t,n,s,a,c,h,f;try{let m={nextPage:null,lastPage:0,total:0},_=await Ee(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(t=e==null?void 0:e.page)===null||t===void 0?void 0:t.toString())!==null&&n!==void 0?n:"",per_page:(a=(s=e==null?void 0:e.perPage)===null||s===void 0?void 0:s.toString())!==null&&a!==void 0?a:""},xform:nI});if(_.error)throw _.error;let E=await _.json(),I=(c=_.headers.get("x-total-count"))!==null&&c!==void 0?c:0,k=(f=(h=_.headers.get("link"))===null||h===void 0?void 0:h.split(","))!==null&&f!==void 0?f:[];return k.length>0&&(k.forEach(B=>{let G=parseInt(B.split(";")[0].split("=")[1].substring(0,1)),j=JSON.parse(B.split(";")[1].split("=")[1]);m[`${j}Page`]=G}),m.total=parseInt(I)),{data:Object.assign(Object.assign({},E),m),error:null}}catch(m){if(ge(m))return{data:{users:[]},error:m};throw m}}async getUserById(e){try{return await Ee(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:tn})}catch(t){if(ge(t))return{data:{user:null},error:t};throw t}}async updateUserById(e,t){try{return await Ee(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:tn})}catch(n){if(ge(n))return{data:{user:null},error:n};throw n}}async deleteUser(e,t=!1){try{return await Ee(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:tn})}catch(n){if(ge(n))return{data:{user:null},error:n};throw n}}async _listFactors(e){try{let{data:t,error:n}=await Ee(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:t,error:n}}catch(t){if(ge(t))return{data:null,error:t};throw t}}async _deleteFactor(e){try{return{data:await Ee(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(t){if(ge(t))return{data:null,error:t};throw t}}};var iI={getItem:r=>xi()?globalThis.localStorage.getItem(r):null,setItem:(r,e)=>{xi()&&globalThis.localStorage.setItem(r,e)},removeItem:r=>{xi()&&globalThis.localStorage.removeItem(r)}};function Wg(r={}){return{getItem:e=>r[e]||null,setItem:(e,t)=>{r[e]=t},removeItem:e=>{delete r[e]}}}function sI(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self!="undefined"&&(self.globalThis=self)}}var Rs={debug:!!(globalThis&&xi()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")},ec=class extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}},gf=class extends ec{};async function Hg(r,e,t){Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",r,e);let n=new globalThis.AbortController;return e>0&&setTimeout(()=>{n.abort(),Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",r)},e),await Promise.resolve().then(()=>globalThis.navigator.locks.request(r,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async s=>{if(s){Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",r,s.name);try{return await t()}finally{Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",r,s.name)}}else{if(e===0)throw Rs.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",r),new gf(`Acquiring an exclusive Navigator LockManager lock "${r}" immediately failed`);if(Rs.debug)try{let a=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(a,null," "))}catch(a){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",a)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await t()}}))}sI();var PU={url:jE,storageKey:$E,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:qE,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1},tc=30*1e3,oI=3;async function aI(r,e,t){return await t()}var Ps=class r{constructor(e){var t,n;this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=r.nextInstanceID,r.nextInstanceID+=1,this.instanceID>0&&Rr()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");let s=Object.assign(Object.assign({},PU),e);if(this.logDebugMessages=!!s.debug,typeof s.debug=="function"&&(this.logger=s.debug),this.persistSession=s.persistSession,this.storageKey=s.storageKey,this.autoRefreshToken=s.autoRefreshToken,this.admin=new Ss({url:s.url,headers:s.headers,fetch:s.fetch}),this.url=s.url,this.headers=s.headers,this.fetch=df(s.fetch),this.lock=s.lock||aI,this.detectSessionInUrl=s.detectSessionInUrl,this.flowType=s.flowType,this.hasCustomAuthorizationHeader=s.hasCustomAuthorizationHeader,s.lock?this.lock=s.lock:Rr()&&(!((t=globalThis==null?void 0:globalThis.navigator)===null||t===void 0)&&t.locks)?this.lock=Hg:this.lock=aI,this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?s.storage?this.storage=s.storage:xi()?this.storage=iI:(this.memoryStorage={},this.storage=Wg(this.memoryStorage)):(this.memoryStorage={},this.storage=Wg(this.memoryStorage)),Rr()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(a){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",a)}(n=this.broadcastChannel)===null||n===void 0||n.addEventListener("message",async a=>{this._debug("received broadcast notification from other tab or client",a),await this._notifyAllSubscribers(a.data.event,a.data.session,!1)})}this.initialize()}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${ff}) ${new Date().toISOString()}`,...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{let t=KE(window.location.href),n="none";if(this._isImplicitGrantCallback(t)?n="implicit":await this._isPKCECallback(t)&&(n="pkce"),Rr()&&this.detectSessionInUrl&&n!=="none"){let{data:s,error:a}=await this._getSessionFromURL(t,n);if(a){if(this._debug("#_initialize()","error detecting session from URL",a),ZE(a)){let f=(e=a.details)===null||e===void 0?void 0:e.code;if(f==="identity_already_exists"||f==="identity_not_found"||f==="single_identity_not_deletable")return{error:a}}return await this._removeSession(),{error:a}}let{session:c,redirectType:h}=s;return this._debug("#_initialize()","detected session in URL",c,"redirect type",h),await this._saveSession(c),setTimeout(async()=>{h==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",c):await this._notifyAllSubscribers("SIGNED_IN",c)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(t){return ge(t)?{error:t}:{error:new ca("Unexpected error during initialization",t)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var t,n,s;try{let a=await Ee(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(t=e==null?void 0:e.options)===null||t===void 0?void 0:t.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.captchaToken}},xform:Vn}),{data:c,error:h}=a;if(h||!c)return{data:{user:null,session:null},error:h};let f=c.session,m=c.user;return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",f)),{data:{user:m,session:f},error:null}}catch(a){if(ge(a))return{data:{user:null,session:null},error:a};throw a}}async signUp(e){var t,n,s;try{let a;if("email"in e){let{email:_,password:E,options:I}=e,k=null,B=null;this.flowType==="pkce"&&([k,B]=await Es(this.storage,this.storageKey)),a=await Ee(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:I==null?void 0:I.emailRedirectTo,body:{email:_,password:E,data:(t=I==null?void 0:I.data)!==null&&t!==void 0?t:{},gotrue_meta_security:{captcha_token:I==null?void 0:I.captchaToken},code_challenge:k,code_challenge_method:B},xform:Vn})}else if("phone"in e){let{phone:_,password:E,options:I}=e;a=await Ee(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:_,password:E,data:(n=I==null?void 0:I.data)!==null&&n!==void 0?n:{},channel:(s=I==null?void 0:I.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:I==null?void 0:I.captchaToken}},xform:Vn})}else throw new Is("You must provide either an email or phone number and a password");let{data:c,error:h}=a;if(h||!c)return{data:{user:null,session:null},error:h};let f=c.session,m=c.user;return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",f)),{data:{user:m,session:f},error:null}}catch(a){if(ge(a))return{data:{user:null,session:null},error:a};throw a}}async signInWithPassword(e){try{let t;if("email"in e){let{email:a,password:c,options:h}=e;t=await Ee(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:a,password:c,gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken}},xform:Kg})}else if("phone"in e){let{phone:a,password:c,options:h}=e;t=await Ee(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:a,password:c,gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken}},xform:Kg})}else throw new Is("You must provide either an email or phone number and a password");let{data:n,error:s}=t;return s?{data:{user:null,session:null},error:s}:!n||!n.session||!n.user?{data:{user:null,session:null},error:new la}:(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),{data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:s})}catch(t){if(ge(t))return{data:{user:null,session:null},error:t};throw t}}async signInWithOAuth(e){var t,n,s,a;return await this._handleProviderSignIn(e.provider,{redirectTo:(t=e.options)===null||t===void 0?void 0:t.redirectTo,scopes:(n=e.options)===null||n===void 0?void 0:n.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(a=e.options)===null||a===void 0?void 0:a.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async _exchangeCodeForSession(e){let t=await Qu(this.storage,`${this.storageKey}-code-verifier`),[n,s]=(t!=null?t:"").split("/");try{let{data:a,error:c}=await Ee(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:Vn});if(await Ju(this.storage,`${this.storageKey}-code-verifier`),c)throw c;return!a||!a.session||!a.user?{data:{user:null,session:null,redirectType:null},error:new la}:(a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",a.session)),{data:Object.assign(Object.assign({},a),{redirectType:s!=null?s:null}),error:c})}catch(a){if(ge(a))return{data:{user:null,session:null,redirectType:null},error:a};throw a}}async signInWithIdToken(e){try{let{options:t,provider:n,token:s,access_token:a,nonce:c}=e,h=await Ee(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:s,access_token:a,nonce:c,gotrue_meta_security:{captcha_token:t==null?void 0:t.captchaToken}},xform:Vn}),{data:f,error:m}=h;return m?{data:{user:null,session:null},error:m}:!f||!f.session||!f.user?{data:{user:null,session:null},error:new la}:(f.session&&(await this._saveSession(f.session),await this._notifyAllSubscribers("SIGNED_IN",f.session)),{data:f,error:m})}catch(t){if(ge(t))return{data:{user:null,session:null},error:t};throw t}}async signInWithOtp(e){var t,n,s,a,c;try{if("email"in e){let{email:h,options:f}=e,m=null,_=null;this.flowType==="pkce"&&([m,_]=await Es(this.storage,this.storageKey));let{error:E}=await Ee(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:h,data:(t=f==null?void 0:f.data)!==null&&t!==void 0?t:{},create_user:(n=f==null?void 0:f.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},code_challenge:m,code_challenge_method:_},redirectTo:f==null?void 0:f.emailRedirectTo});return{data:{user:null,session:null},error:E}}if("phone"in e){let{phone:h,options:f}=e,{data:m,error:_}=await Ee(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:h,data:(s=f==null?void 0:f.data)!==null&&s!==void 0?s:{},create_user:(a=f==null?void 0:f.shouldCreateUser)!==null&&a!==void 0?a:!0,gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},channel:(c=f==null?void 0:f.channel)!==null&&c!==void 0?c:"sms"}});return{data:{user:null,session:null,messageId:m==null?void 0:m.message_id},error:_}}throw new Is("You must provide either an email or phone number.")}catch(h){if(ge(h))return{data:{user:null,session:null},error:h};throw h}}async verifyOtp(e){var t,n;try{let s,a;"options"in e&&(s=(t=e.options)===null||t===void 0?void 0:t.redirectTo,a=(n=e.options)===null||n===void 0?void 0:n.captchaToken);let{data:c,error:h}=await Ee(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:a}}),redirectTo:s,xform:Vn});if(h)throw h;if(!c)throw new Error("An error occurred on token verification.");let f=c.session,m=c.user;return f!=null&&f.access_token&&(await this._saveSession(f),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",f)),{data:{user:m,session:f},error:null}}catch(s){if(ge(s))return{data:{user:null,session:null},error:s};throw s}}async signInWithSSO(e){var t,n,s;try{let a=null,c=null;return this.flowType==="pkce"&&([a,c]=await Es(this.storage,this.storageKey)),await Ee(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(n=(t=e.options)===null||t===void 0?void 0:t.redirectTo)!==null&&n!==void 0?n:void 0}),!((s=e==null?void 0:e.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:c}),headers:this.headers,xform:tI})}catch(a){if(ge(a))return{data:null,error:a};throw a}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{let{data:{session:t},error:n}=e;if(n)throw n;if(!t)throw new fr;let{error:s}=await Ee(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:t.access_token});return{data:{user:null,session:null},error:s}})}catch(e){if(ge(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{let t=`${this.url}/resend`;if("email"in e){let{email:n,type:s,options:a}=e,{error:c}=await Ee(this.fetch,"POST",t,{headers:this.headers,body:{email:n,type:s,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},redirectTo:a==null?void 0:a.emailRedirectTo});return{data:{user:null,session:null},error:c}}else if("phone"in e){let{phone:n,type:s,options:a}=e,{data:c,error:h}=await Ee(this.fetch,"POST",t,{headers:this.headers,body:{phone:n,type:s,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}}});return{data:{user:null,session:null,messageId:c==null?void 0:c.message_id},error:h}}throw new Is("You must provide either an email or phone number and a type")}catch(t){if(ge(t))return{data:{user:null,session:null},error:t};throw t}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async t=>t))}async _acquireLock(e,t){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){let n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await n,await t()))();return this.pendingInLock.push((async()=>{try{await s}catch{}})()),s}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;let n=t();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){let s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{let t=await this.__loadSession();return await e(t)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null,t=await Qu(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",t),t!==null&&(this._isValidSession(t)?e=t:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};let n=e.expires_at?e.expires_at<=Date.now()/1e3:!1;if(this._debug("#__loadSession()",`session has${n?"":" not"} expired`,"expires_at",e.expires_at),!n){if(this.storage.isServer){let c=this.suppressGetSessionWarning;e=new Proxy(e,{get:(f,m,_)=>(!c&&m==="user"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),c=!0,this.suppressGetSessionWarning=!0),Reflect.get(f,m,_))})}return{data:{session:e},error:null}}let{session:s,error:a}=await this._callRefreshToken(e.refresh_token);return a?{data:{session:null},error:a}:{data:{session:s},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await Ee(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:tn}):await this._useSession(async t=>{var n,s,a;let{data:c,error:h}=t;if(h)throw h;return!(!((n=c.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new fr}:await Ee(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(a=(s=c.session)===null||s===void 0?void 0:s.access_token)!==null&&a!==void 0?a:void 0,xform:tn})})}catch(t){if(ge(t))return XE(t)&&(await this._removeSession(),await Ju(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:t};throw t}}async updateUser(e,t={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,t))}async _updateUser(e,t={}){try{return await this._useSession(async n=>{let{data:s,error:a}=n;if(a)throw a;if(!s.session)throw new fr;let c=s.session,h=null,f=null;this.flowType==="pkce"&&e.email!=null&&([h,f]=await Es(this.storage,this.storageKey));let{data:m,error:_}=await Ee(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:t==null?void 0:t.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:h,code_challenge_method:f}),jwt:c.access_token,xform:tn});if(_)throw _;return c.user=m.user,await this._saveSession(c),await this._notifyAllSubscribers("USER_UPDATED",c),{data:{user:c.user},error:null}})}catch(n){if(ge(n))return{data:{user:null},error:n};throw n}}_decodeJWT(e){return Gg(e)}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new fr;let t=Date.now()/1e3,n=t,s=!0,a=null,c=Gg(e.access_token);if(c.exp&&(n=c.exp,s=n<=t),s){let{session:h,error:f}=await this._callRefreshToken(e.refresh_token);if(f)return{data:{user:null,session:null},error:f};if(!h)return{data:{user:null,session:null},error:null};a=h}else{let{data:h,error:f}=await this._getUser(e.access_token);if(f)throw f;a={access_token:e.access_token,refresh_token:e.refresh_token,user:h.user,token_type:"bearer",expires_in:n-t,expires_at:n},await this._saveSession(a),await this._notifyAllSubscribers("SIGNED_IN",a)}return{data:{user:a.user,session:a},error:null}}catch(t){if(ge(t))return{data:{session:null,user:null},error:t};throw t}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async t=>{var n;if(!e){let{data:c,error:h}=t;if(h)throw h;e=(n=c.session)!==null&&n!==void 0?n:void 0}if(!(e!=null&&e.refresh_token))throw new fr;let{session:s,error:a}=await this._callRefreshToken(e.refresh_token);return a?{data:{user:null,session:null},error:a}:s?{data:{user:s.user,session:s},error:null}:{data:{user:null,session:null},error:null}})}catch(t){if(ge(t))return{data:{user:null,session:null},error:t};throw t}}async _getSessionFromURL(e,t){try{if(!Rr())throw new xs("No browser detected.");if(e.error||e.error_description||e.error_code)throw new xs(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(t){case"implicit":if(this.flowType==="pkce")throw new Xu("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new xs("Not a valid implicit grant flow url.");break;default:}if(t==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new Xu("No code detected.");let{data:ee,error:re}=await this._exchangeCodeForSession(e.code);if(re)throw re;let le=new URL(window.location.href);return le.searchParams.delete("code"),window.history.replaceState(window.history.state,"",le.toString()),{data:{session:ee.session,redirectType:null},error:null}}let{provider_token:n,provider_refresh_token:s,access_token:a,refresh_token:c,expires_in:h,expires_at:f,token_type:m}=e;if(!a||!h||!c||!m)throw new xs("No session defined in URL");let _=Math.round(Date.now()/1e3),E=parseInt(h),I=_+E;f&&(I=parseInt(f));let k=I-_;k*1e3<=tc&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${k}s, should have been closer to ${E}s`);let B=I-E;_-B>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",B,I,_):_-B<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",B,I,_);let{data:G,error:j}=await this._getUser(a);if(j)throw j;let J={provider_token:n,provider_refresh_token:s,access_token:a,expires_in:E,expires_at:I,refresh_token:c,token_type:m,user:G.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:J,redirectType:e.type},error:null}}catch(n){if(ge(n))return{data:{session:null,redirectType:null},error:n};throw n}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){let t=await Qu(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&t)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async t=>{var n;let{data:s,error:a}=t;if(a)return{error:a};let c=(n=s.session)===null||n===void 0?void 0:n.access_token;if(c){let{error:h}=await this.admin.signOut(c,e);if(h&&!(YE(h)&&(h.status===404||h.status===401||h.status===403)))return{error:h}}return e!=="others"&&(await this._removeSession(),await Ju(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){let t=GE(),n={id:t,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",t),this.stateChangeEmitters.delete(t)}};return this._debug("#onAuthStateChange()","registered callback with id",t),this.stateChangeEmitters.set(t,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(t)})))(),{data:{subscription:n}}}async _emitInitialSession(e){return await this._useSession(async t=>{var n,s;try{let{data:{session:a},error:c}=t;if(c)throw c;await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",a)),this._debug("INITIAL_SESSION","callback id",e,"session",a)}catch(a){await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",a),console.error(a)}})}async resetPasswordForEmail(e,t={}){let n=null,s=null;this.flowType==="pkce"&&([n,s]=await Es(this.storage,this.storageKey,!0));try{return await Ee(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:n,code_challenge_method:s,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(a){if(ge(a))return{data:null,error:a};throw a}}async getUserIdentities(){var e;try{let{data:t,error:n}=await this.getUser();if(n)throw n;return{data:{identities:(e=t.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(t){if(ge(t))return{data:null,error:t};throw t}}async linkIdentity(e){var t;try{let{data:n,error:s}=await this._useSession(async a=>{var c,h,f,m,_;let{data:E,error:I}=a;if(I)throw I;let k=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(c=e.options)===null||c===void 0?void 0:c.redirectTo,scopes:(h=e.options)===null||h===void 0?void 0:h.scopes,queryParams:(f=e.options)===null||f===void 0?void 0:f.queryParams,skipBrowserRedirect:!0});return await Ee(this.fetch,"GET",k,{headers:this.headers,jwt:(_=(m=E.session)===null||m===void 0?void 0:m.access_token)!==null&&_!==void 0?_:void 0})});if(s)throw s;return Rr()&&!(!((t=e.options)===null||t===void 0)&&t.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),{data:{provider:e.provider,url:n==null?void 0:n.url},error:null}}catch(n){if(ge(n))return{data:{provider:e.provider,url:null},error:n};throw n}}async unlinkIdentity(e){try{return await this._useSession(async t=>{var n,s;let{data:a,error:c}=t;if(c)throw c;return await Ee(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(s=(n=a.session)===null||n===void 0?void 0:n.access_token)!==null&&s!==void 0?s:void 0})})}catch(t){if(ge(t))return{data:null,error:t};throw t}}async _refreshAccessToken(e){let t=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(t,"begin");try{let n=Date.now();return await QE(async s=>(s>0&&await HE(200*Math.pow(2,s-1)),this._debug(t,"refreshing attempt",s),await Ee(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Vn})),(s,a)=>{let c=200*Math.pow(2,s);return a&&mf(a)&&Date.now()+c-n<tc})}catch(n){if(this._debug(t,"error",n),ge(n))return{data:{session:null,user:null},error:n};throw n}finally{this._debug(t,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,t){let n=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",t,"url",n),Rr()&&!t.skipBrowserRedirect&&window.location.assign(n),{data:{provider:e,url:n},error:null}}async _recoverAndRefresh(){var e;let t="#_recoverAndRefresh()";this._debug(t,"begin");try{let n=await Qu(this.storage,this.storageKey);if(this._debug(t,"session from storage",n),!this._isValidSession(n)){this._debug(t,"session is not valid"),n!==null&&await this._removeSession();return}let s=Math.round(Date.now()/1e3),a=((e=n.expires_at)!==null&&e!==void 0?e:1/0)<s+$g;if(this._debug(t,`session has${a?"":" not"} expired with margin of ${$g}s`),a){if(this.autoRefreshToken&&n.refresh_token){let{error:c}=await this._callRefreshToken(n.refresh_token);c&&(console.error(c),mf(c)||(this._debug(t,"refresh failed with a non-retryable error, removing the session",c),await this._removeSession()))}}else await this._notifyAllSubscribers("SIGNED_IN",n)}catch(n){this._debug(t,"error",n),console.error(n);return}finally{this._debug(t,"end")}}async _callRefreshToken(e){var t,n;if(!e)throw new fr;if(this.refreshingDeferred)return this.refreshingDeferred.promise;let s=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new Hu;let{data:a,error:c}=await this._refreshAccessToken(e);if(c)throw c;if(!a.session)throw new fr;await this._saveSession(a.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",a.session);let h={session:a.session,error:null};return this.refreshingDeferred.resolve(h),h}catch(a){if(this._debug(s,"error",a),ge(a)){let c={session:null,error:a};return mf(a)||await this._removeSession(),(t=this.refreshingDeferred)===null||t===void 0||t.resolve(c),c}throw(n=this.refreshingDeferred)===null||n===void 0||n.reject(a),a}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(e,t,n=!0){let s=`#_notifyAllSubscribers(${e})`;this._debug(s,"begin",t,`broadcast = ${n}`);try{this.broadcastChannel&&n&&this.broadcastChannel.postMessage({event:e,session:t});let a=[],c=Array.from(this.stateChangeEmitters.values()).map(async h=>{try{await h.callback(e,t)}catch(f){a.push(f)}});if(await Promise.all(c),a.length>0){for(let h=0;h<a.length;h+=1)console.error(a[h]);throw a[0]}}finally{this._debug(s,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,await zg(this.storage,this.storageKey,e)}async _removeSession(){this._debug("#_removeSession()"),await Ju(this.storage,this.storageKey),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");let e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&Rr()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(t){console.error("removing visibilitychange callback failed",t)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");let e=setInterval(()=>this._autoRefreshTokenTick(),tc);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno!="undefined"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");let e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{let e=Date.now();try{return await this._useSession(async t=>{let{data:{session:n}}=t;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}let s=Math.floor((n.expires_at*1e3-e)/tc);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${tc}ms, refresh threshold is ${oI} ticks`),s<=oI&&await this._callRefreshToken(n.refresh_token)})}catch(t){console.error("Auto refresh tick failed with error. This is likely a transient error.",t)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof ec)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Rr()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){let t=`#_onVisibilityChanged(${e})`;this._debug(t,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(t,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,t,n){let s=[`provider=${encodeURIComponent(t)}`];if(n!=null&&n.redirectTo&&s.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n!=null&&n.scopes&&s.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){let[a,c]=await Es(this.storage,this.storageKey),h=new URLSearchParams({code_challenge:`${encodeURIComponent(a)}`,code_challenge_method:`${encodeURIComponent(c)}`});s.push(h.toString())}if(n!=null&&n.queryParams){let a=new URLSearchParams(n.queryParams);s.push(a.toString())}return n!=null&&n.skipBrowserRedirect&&s.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async t=>{var n;let{data:s,error:a}=t;return a?{data:null,error:a}:await Ee(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token})})}catch(t){if(ge(t))return{data:null,error:t};throw t}}async _enroll(e){try{return await this._useSession(async t=>{var n,s;let{data:a,error:c}=t;if(c)return{data:null,error:c};let h=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:{issuer:e.issuer}),{data:f,error:m}=await Ee(this.fetch,"POST",`${this.url}/factors`,{body:h,headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token});return m?{data:null,error:m}:(e.factorType==="totp"&&(!((s=f==null?void 0:f.totp)===null||s===void 0)&&s.qr_code)&&(f.totp.qr_code=`data:image/svg+xml;utf-8,${f.totp.qr_code}`),{data:f,error:null})})}catch(t){if(ge(t))return{data:null,error:t};throw t}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var n;let{data:s,error:a}=t;if(a)return{data:null,error:a};let{data:c,error:h}=await Ee(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token});return h?{data:null,error:h}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+c.expires_in},c)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",c),{data:c,error:h})})}catch(t){if(ge(t))return{data:null,error:t};throw t}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async t=>{var n;let{data:s,error:a}=t;return a?{data:null,error:a}:await Ee(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:{channel:e.channel},headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token})})}catch(t){if(ge(t))return{data:null,error:t};throw t}})}async _challengeAndVerify(e){let{data:t,error:n}=await this._challenge({factorId:e.factorId});return n?{data:null,error:n}:await this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})}async _listFactors(){let{data:{user:e},error:t}=await this.getUser();if(t)return{data:null,error:t};let n=(e==null?void 0:e.factors)||[],s=n.filter(c=>c.factor_type==="totp"&&c.status==="verified"),a=n.filter(c=>c.factor_type==="phone"&&c.status==="verified");return{data:{all:n,totp:s,phone:a},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var t,n;let{data:{session:s},error:a}=e;if(a)return{data:null,error:a};if(!s)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};let c=this._decodeJWT(s.access_token),h=null;c.aal&&(h=c.aal);let f=h;((n=(t=s.user.factors)===null||t===void 0?void 0:t.filter(E=>E.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(f="aal2");let _=c.amr||[];return{data:{currentLevel:h,nextLevel:f,currentAuthenticationMethods:_},error:null}}))}};Ps.nextInstanceID=0;var CU=Ps,Qg=CU;var _f=class extends Qg{constructor(e){super(e)}};var DU=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(c){c(a)})}return new(t||(t=Promise))(function(a,c){function h(_){try{m(n.next(_))}catch(E){c(E)}}function f(_){try{m(n.throw(_))}catch(E){c(E)}}function m(_){_.done?a(_.value):s(_.value).then(h,f)}m((n=n.apply(r,e||[])).next())})},rc=class{constructor(e,t,n){var s,a,c;if(this.supabaseUrl=e,this.supabaseKey=t,!e)throw new Error("supabaseUrl is required.");if(!t)throw new Error("supabaseKey is required.");let h=UE(e);this.realtimeUrl=`${h}/realtime/v1`.replace(/^http/i,"ws"),this.authUrl=`${h}/auth/v1`,this.storageUrl=`${h}/storage/v1`,this.functionsUrl=`${h}/functions/v1`;let f=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,m={db:VE,realtime:ME,auth:Object.assign(Object.assign({},LE),{storageKey:f}),global:NE},_=BE(n!=null?n:{},m);this.storageKey=(s=_.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(a=_.global.headers)!==null&&a!==void 0?a:{},_.accessToken?(this.accessToken=_.accessToken,this.auth=new Proxy({},{get:(E,I)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(I)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((c=_.auth)!==null&&c!==void 0?c:{},this.headers,_.global.fetch),this.fetch=FE(t,this._getAccessToken.bind(this),_.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},_.realtime)),this.rest=new vE(`${h}/rest/v1`,{headers:this.headers,schema:_.db.schema,fetch:this.fetch}),_.accessToken||this._listenForAuthEvents()}get functions(){return new Nu(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new Gu(this.storageUrl,this.headers,this.fetch)}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,t={},n={}){return this.rest.rpc(e,t,n)}channel(e,t={config:{}}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,t;return DU(this,void 0,void 0,function*(){if(this.accessToken)return yield this.accessToken();let{data:n}=yield this.auth.getSession();return(t=(e=n.session)===null||e===void 0?void 0:e.access_token)!==null&&t!==void 0?t:null})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:n,storage:s,storageKey:a,flowType:c,lock:h,debug:f},m,_){let E={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new _f({url:this.authUrl,headers:Object.assign(Object.assign({},E),m),storageKey:a,autoRefreshToken:e,persistSession:t,detectSessionInUrl:n,storage:s,flowType:c,lock:h,debug:f,fetch:_,hasCustomAuthorizationHeader:"Authorization"in this.headers})}_initRealtimeClient(e){return new sa(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,n)=>{this._handleTokenChanged(t,"CLIENT",n==null?void 0:n.access_token)})}_handleTokenChanged(e,t,n){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==n?this.changedAccessToken=n:e==="SIGNED_OUT"&&(this.realtime.setAuth(),t=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};var uI=(r,e,t)=>new rc(r,e,t);var wI=Dd(fI(),1);var dI={id:"~date",test:r=>r instanceof Date,serialize:r=>({_:"~date",v:r.toISOString()}),deserialize:r=>new Date(r.v)};var pI={id:"~function",test:r=>typeof r=="function",serialize:r=>({_:"~function",v:r.toString()}),deserialize:v=>eval(v.v.toString())};var mI={id:"~infinity",test:r=>r===1/0||r===-1/0,serialize:r=>({_:"~infinity",v:r===1/0?1:0}),deserialize:r=>r.v==1?1/0:-1/0};var gI={id:"~nan",test:r=>Number.isNaN(r),serialize:r=>({_:"~nan"}),deserialize:r=>NaN};var _I={id:"~regexp",test:r=>r instanceof RegExp,serialize:r=>({_:"~regexp",v:r.source,f:r.flags}),deserialize:r=>new RegExp(r.v,r.f)};var yI={id:"~set",test:r=>r instanceof Set,serialize:r=>({_:"~set",v:Array.from(r)}),deserialize:r=>new Set(r.v)};var vI={id:"~undefined",test:r=>r===void 0,serialize:r=>({_:"~undefined"}),deserialize:r=>{}};var da={settings:{stringify:!0,destringify:!0,clone:!1,depth:0,modules:[dI,pI,mI,gI,_I,yI,vI],circular:!0,symetric:!1},loadedModules:{},loadModules(r){return r.map(e=>{if(De(e)){if(!e.id)throw new Error("Provided custom module does not expose an `id` property");return da.loadedModules[e.id]=e}else throw new Error("Unknown module type")})},serialize(r,e){let t=zl(e,da.settings),n=da.loadModules(t.modules),s=t.symetric?(0,wI.keyArrangeDeep)(r):t.clone?qr(r):r,a=new Map,c=(h,f)=>{let m=De(h);if(m&&t.circular){let I=a.get(h);if(I)return pi(s,f,{_:"~circular",p:I.join(".")});a.set(h,f)}let _=n.find(I=>I.test(h)),E=(!t.depth||f.length<t.depth)&&m;if(_){let I=_.serialize(h);if(_.recursive&&E){let k=At(h);t.symetric&&k.sort(),pi(s,f,I),k.forEach(B=>c(h[B],f.concat(B)))}else f.length?pi(s,f,I):s=I}else if(E){let I=At(h);t.symetric&&I.sort(),I.forEach(k=>c(h[k],f.concat(k)))}};return c(s,[]),t.stringify?JSON.stringify(s):s},deserialize(r,e){let t=zl(e,da.settings),n=da.loadModules(t.modules),s=Bd(n,"id"),a=t.destringify?JSON.parse(r):t.clone?qr(r):r,c=(h,f)=>{if(De(h)&&h._&&typeof h._=="string"&&h._.startsWith("~")&&s[h._]){let m=s[h._].deserialize(h);f.length?s[h._].recursive&&De(m)?(pi(a,f,m),At(m).forEach(_=>c(h[_],[...f,_]))):pi(a,f,m):a=m}else t.circular&&De(h)&&h._&&h._=="~circular"?pi(a,f,ru(a,h.p)):(!t.depth||f.length<t.depth)&&De(h)&&At(h).forEach(m=>c(h[m],f.concat(m)))};return c(a,[]),a}},ic=da;var bI="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Yg=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)e+=bI[t[r]&63];return e};var $e=class $e{constructor(e,t){gt(this,"path");gt(this,"docRef");gt(this,"value");gt(this,"throttle",250);gt(this,"heartbeatInterval",3e4);gt(this,"_destroyActions",[]);gt(this,"_heartbeatTimer");this.path=e,Object.assign(this,t),$e.session||($e.session=`syncro_${Yg()}`)}debug(...e){}destroy(){return this.debug("Destroy!"),Promise.all(this._destroyActions.map(e=>e())).then(()=>this._destroyActions=[])}getReactive(e){console.warn("Syncro.getReactive has not been subclassed, assuming a POJO response");let t={...e};return{doc:t,setState(n){Object.entries(n||{}).forEach(([s,a])=>t[s]=a)},getState(){return qr(t)},watch(n){}}}static pathSplit(e){var n;let t={...(n=/^(?<entity>\w+?)::(?<id>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:::(?<relation>\w+?))?$/.exec(e))==null?void 0:n.groups};if(!t)throw new Error(`Invalid session path syntax "${e}"`);if(!(t.entity in Xg))throw new Error(`Unsupported entity "${e}" -> Entity="${t.entity}"`);return{...t,fsCollection:t.entity,fsId:t.relation?`${t.id}::${t.relation}`:t.id}}static toFirestore(e={}){return ic.serialize(e,{circular:!1,clone:!0,modules:[TI,...ic.settings.modules],stringify:!1})}static fromFirestore(e={}){return ic.deserialize(e,{circular:!1,clone:!0,modules:[TI,...ic.settings.modules],destringify:!1})}static fromFirestoreFields(e={}){let t={};for(let n in e){let s=e[n];if(["stringValue","booleanValue","doubleValue","integerValue","timestampValue","mapValue","arrayValue"].find(c=>c===n)){if(["stringValue","booleanValue","doubleValue","integerValue","timestampValue"].find(h=>h===n))return s;if(n=="mapValue")return $e.fromFirestoreFields(s.fields||{});if(n=="arrayValue"){let h=s.values;return h?h.map(f=>$e.fromFirestoreFields(f)):[]}}else t[n]=$e.fromFirestoreFields(s)}return t}static getSnapshot(e){let{fsCollection:t,fsId:n}=$e.pathSplit(e);return Promise.resolve().then(async()=>Jh(Ou($e.firestore,t,n))).then(s=>s?$e.fromFirestore(s.data()):null)}static setSnapshot(e,t,n){let s={method:"merge",...n},{fsCollection:a,fsId:c}=$e.pathSplit(e);return Promise.resolve().then(()=>(s.method=="merge"?"FirestoreUpdateDoc":"FirestoreSetDoc")(Ou($e.firestore,a,c),$e.toFirestore(t))).then(()=>t)}static wrapSupabase(e){return Promise.resolve(e).then(t=>{var n,s;if(t!=null&&t.error)throw/JSON object requested, multiple \(or no\) rows returned$/.test(t.error.message)?(console.warn("Supabase query threw record not found against query",e.url.search),console.warn("Supabase raw error",t),new Error("NOT-FOUND")):(console.warn("Supabase query threw",t.error.message),new Error(`${((n=t.error)==null?void 0:n.code)||"UnknownError"}: ${((s=t.error)==null?void 0:s.message)||"Unknown Supabase error"}`));if(t.data)return t.data})}mount(e){let{fsCollection:t,fsId:n,entity:s,id:a,relation:c}=$e.pathSplit(this.path),h,f;return Promise.resolve().then(()=>this.setHeartbeat(!1)).then(async()=>{this.docRef=Ou($e.firestore,t,n);let m=$e.fromFirestore((await Jh(this.docRef)).data());if(h=this.getReactive(m),!h.doc||!h.setState||!h.getState||!h.watch)throw new Error("Syncro.getReactive() requires a returned `doc`, `setState()`, `getState()` + `watch()`");this.value=f=h.doc,this.debug("Initial state",{doc:f}),this._destroyActions.push(rE(this.docRef,_=>{let E=$e.fromFirestore(_.data());this.debug("Incoming snapshot",{snapshotData:E}),h.setState(E)}))}).then(()=>{if(Fd(f))return this.debug("Populate initial state"),Promise.resolve().then(()=>Xg[s]||Promise.reject(`Unknown Sync entity "${s}"`)).then(()=>Xg[s].initState({supabase:$e.supabase,fsCollection:t,fsId:n,entity:s,id:a,relation:c,tera:e})).then(m=>bg(this.docRef,$e.toFirestore(m)))}).then(()=>{h.watch(jd(m=>{this.debug("Local change",{newState:m}),tE(this.docRef,$e.toFirestore(m))},this.throttle))}).then(()=>this.setHeartbeat(!0,{immediate:!0})).then(()=>this)}setHeartbeat(e=!0,t){let n={immediate:!0,...t};clearTimeout(this._heartbeatTimer),e&&(this._heartbeatTimer=setTimeout(async()=>{await this.heartbeat(),e&&this.setHeartbeat(!0)},this.heartbeatInterval),n.immediate&&this.heartbeat())}async heartbeat(){this.debug("heartbeat!");let e=new Date().toISOString(),t=Ou($e.firestore,"presence",this.path),n=await Jh(t);await bg(t,{latest:e,...!n.exists()&&{created:e,lastFlush:null},sessions:{[$e.session]:e}},{merge:!0})}flush(e){let t={destroy:!1,...e};return fetch(`https://tera-tools.com/api/sync/${this.path}/flush`+(t.destroy?"?destroy=1":""),{method:"post"}).then(n=>n.ok?null:Promise.reject(n.statusText||"An error occured"))}};gt($e,"firebase"),gt($e,"firestore"),gt($e,"supabase"),gt($e,"session");var Tt=$e;var Xg={projects:{singular:"project",async initState({supabase:r,id:e,tera:t}){let n=await Tt.wrapSupabase(r.from("projects").select("data").limit(1).eq("id",e));if(n.length!==1)throw new Error(`Syncro project "${e}" not found`);let s=n[0].data;if(console.log("[MIGRATION] State of temp at start:",s.temp),!s.temp)return s;let a=!1;for(let c in s.temp){if(typeof s.temp[c]!="object"){console.log(`[MIGRATION] Skipping conversion of ${c}, not an object:`,s.temp[c]);return}a||(a=!0,console.log("[MIGRATION] showing alert"),alert("Data found that will be migrated to new TERA file storage system. This may take a few minutes, please do not close your browser or refresh."));let f=`data-${c.split("-")[0]}-${Yg()}.json`;console.log("[MIGRATION] Creating filename:",f);let m=await t.createProjectFile(f);console.log("[MIGRATION] Setting file contents:",m,"to:",s.temp[c]),await m.setContents(s.temp[c]),console.log("[MIGRATION] Overwriting temp key with filepath:",f),s.temp[c]=f}return console.log("[MIGRATION] State of temp at end:",s.temp),s},flushState({supabase:r,state:e,fsId:t}){return Tt.wrapSupabase(r.rpc("syncro_merge_data",{table_name:"projects",entity_id:t,new_data:e}))}},project_namespaces:{singular:"project namespace",initState({supabase:r,id:e,relation:t}){if(!t)throw new Error('Project namespace relation missing, path should resemble "project_namespaces::${PROJECT}::${RELATION}"');return Tt.wrapSupabase(r.from("project_namespaces").select("data").limit(1).eq("project",e).eq("name",t)).then(n=>n.length==1?n[0]:Tt.wrapSupabase(r.from("project_namespaces").insert({project:e,name:t,data:{}}).select("data"))).then(n=>n.data)},flushState({supabase:r,state:e,id:t,relation:n}){return Tt.wrapSupabase(r.from("project_namespaces").update({edited_at:new Date,data:e}).eq("project",t).eq("name",n))}},test:{singular:"test",initState({supabase:r,id:e}){return Tt.wrapSupabase(r.from("test").select("data").limit(1).eq("id",e)).then(t=>t.length==1?t[0]:Promise.reject(`Syncro test item "${e}" not found`)).then(t=>t.data)},flushState({supabase:r,state:e,fsId:t}){return Tt.wrapSupabase(r.rpc("syncro_merge_data",{table_name:"test",entity_id:t,new_data:e}))}},users:{singular:"user",initState({supabase:r,id:e}){return Tt.wrapSupabase(r.from("users").select("data").limit(1).eq("id",e)).then(t=>t.length==1?t[0]:Promise.reject(`Syncro user "${e}" not found`)).then(t=>t.data)},flushState({supabase:r,state:e,fsId:t}){return Tt.wrapSupabase(r.rpc("syncro_merge_data",{table_name:"users",entity_id:t,new_data:e}))}}},TI={id:"~array",recursive:!0,test:r=>Array.isArray(r),serialize:r=>({_:"~array",...r}),deserialize:r=>{let e=Array.from({length:Object.keys(r).length-1});return Object.entries(r).filter(([t])=>t!=="_").forEach(([t,n])=>e[+t]=n),e}};var sc=class{init(){}constructor(e,t){}};var oc=class extends sc{constructor(){super(...arguments);gt(this,"syncros",{})}async init(t){let n={firebaseApiKey:null,firebaseAuthDomain:null,firebaseProjectId:null,firebaseAppId:null,supabaseUrl:null,supabaseKey:null,...await this.getCredentials(),...t},s=Object.keys(n).filter(a=>a===null);if(s.length>0)throw new Error("Firebase plugin requires mandatory options: "+s.join(", "));Tt.firebase=op({apiKey:n.firebaseApiKey,authDomain:n.firebaseAuthDomain,projectId:n.firebaseProjectId,appId:n.firebaseAppId}),Tt.firestore=HT(this.firebase),Tt.supabase=uI(n.supabaseUrl,n.supabaseKey)}_mountNamespace(t){let n;return Promise.resolve().then(()=>this.requireProject()).then(s=>{let a=t=="_PROJECT"?`projects::${s.id}`:`project_namespaces::${s.id}::${t}`;return n=this.syncros[t]=new Tt(a,{debug:(...c)=>this.debug(`SYNCRO://${a}`,...c),getReactive:this.getReactive}),n.mount()}).then(()=>{this.namespaces[t]=n.value})}_unmountNamespace(t){let n=this.syncros[t];return delete this.namespaces[t],delete this.syncros[t],n.destroy()}};var Zg=class extends oc{constructor(){super(...arguments);gt(this,"Vue");gt(this,"project",null);gt(this,"reactiveId",1001)}async init(t){let n={app:null,Vue:null,globalName:"$tera",...t};if(!n.Vue)throw new Error("Vue instance to use must be specified in init options as `Vue`");if(this.Vue=n.Vue,!n.app)throw new Error("Vue Root / App instance to use must be specified in init options as `app`");this.app=n.app,n.globalName&&(this.Vue.prototype[n.globalName]=this),await super.init(n),this.project=await this.mountNamespace("_PROJECT")}getReactive(t){let n=this.Vue.observable(t),s=`_teraFy_${this.reactiveId++}`;return this.app[s]=n,{doc:n,setState(a){Object.entries(a||{}).filter(([c])=>!Ud(n[c],a[c])).forEach(([c,h])=>n[c]=h)},getState(){return qr(n)},watch:a=>{this.app.$watch(s,a,{deep:!0})}}}bindProjectState(t){let n={component:null,componentKey:null,autoRequire:!0,read:!0,write:!0,throttle:{wait:200,maxWait:2e3,leading:!1,trailing:!0},...t};return Promise.resolve().then(()=>Promise.all([this.getProjectState({autoRequire:n.autoRequire}),(()=>{if(!n.componentKey){for(let s=0;s<50;s++){let a=`terafy_${s}`;if(!Object.hasOwnProperty(n.component,a)){n.componentKey=a;return}}throw new Error("Unable to find unique key to allocate against Vue2 component")}})()])).then(([s])=>{this.debug("INFO",2,"Got project snapshot",s);let a=this.Vue.observable(s);if(n.component[n.componentKey]=a,n.read&&this.events.on(`update:projects/${a.id}`,c=>{var h;(h=c==null?void 0:c.lastPatch)!=null&&h.session&&c.lastPatch.session==this.settings.session||(this.debug("INFO",5,"Update Vue2 Remote->Local",{new:c,old:a}),this.merge(a,c))}),n.write){if(!n.component)throw new Error("bindProjectState requires a VueComponent specified as `component`");let c=qr(s),h=()=>{let f=qr(s);this.debug("INFO",5,"Update Vue2 Local->Remote",{new:f,old:c}),this.createProjectStatePatch(f,c),c=f};n.component.$watch(n.componentKey,n.throttle?debounce(h,n.throttle.wait,n.throttle):h,{deep:!0})}return a})}merge(t,...n){return n.forEach(s=>Object.keys(s).forEach(a=>{isPlainObject(s[a])?(a in t||this.Vue.set(t,a,{}),this.merge(t[a],s[a])):this.Vue.set(t,a,s[a])})),t}};export{Zg as default};
|
|
47
47
|
/*! Bundled license information:
|
|
48
48
|
|
|
49
49
|
lodash/lodash.js:
|