cic-kit 0.0.8 → 0.0.11

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/index.cjs CHANGED
@@ -1 +1,38 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),E=require("vue-router"),C=["id"],N={class:"accordion-item"},V={class:"accordion-header"},$=["data-bs-target","aria-controls","disabled"],S=["id","data-bs-parent"],x={class:"accordion-body"},D={key:0},v=e.defineComponent({inheritAttrs:!1,__name:"AccordionCmp",props:{id:{},title:{},defaultOpen:{type:Boolean},disabled:{type:Boolean}},emits:["open"],setup(o,{emit:l}){const t=o,i=l,c=e.useSlots(),p=e.useAttrs(),r=e.computed(()=>t.id??"accordionDefault"),u=e.computed(()=>!!t.disabled),f=e.computed(()=>!!c.default?.().length),m=e.computed(()=>!!c.header?.().length);function d(s){if(u.value){s.preventDefault(),s.stopPropagation();return}i("open",s)}return(s,b)=>(e.openBlock(),e.createElementBlock("div",e.mergeProps({class:"accordion",id:r.value},e.unref(p)),[e.createElementVNode("div",N,[e.createElementVNode("h2",V,[e.createElementVNode("button",{class:"accordion-button collapsed p-2",type:"button","data-bs-toggle":"collapse","data-bs-target":`#collapseOne-${r.value}`,"aria-expanded":"false","aria-controls":`collapseOne-${r.value}`,disabled:u.value,onClick:d},[m.value?e.renderSlot(s.$slots,"header",{key:0}):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(t.title??"- default -"),1)],64))],8,$)]),e.createElementVNode("div",{id:`collapseOne-${r.value}`,class:"accordion-collapse collapse","data-bs-parent":`#${r.value}`},[e.createElementVNode("div",x,[f.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",D,[...b[0]||(b[0]=[e.createTextVNode(" - ",-1),e.createElementVNode("span",{class:"material-symbols-outlined text-warning"}," warning ",-1),e.createTextVNode(" - ",-1)])])),e.renderSlot(s.$slots,"default")])],8,S)])],16,C))}});async function w({url:o,text:l,title:t}){if(navigator.share)try{await navigator.share({title:t??"Condividi",text:l??"",url:o})}catch{await navigator.clipboard.writeText(o)}else await navigator.clipboard.writeText(o)}const A=["type","disabled","aria-busy"],T={class:"material-symbols-outlined","aria-hidden":"true"},O=e.defineComponent({inheritAttrs:!1,__name:"BtnCmp",props:{variant:{},color:{},size:{},block:{type:Boolean},disabled:{type:Boolean},type:{},to:{},loading:{type:Boolean},icon:{},share:{}},emits:["click"],setup(o,{emit:l}){const t=o,i=l,c=e.useSlots(),p=e.useAttrs(),r=E.useRouter(),u=e.computed(()=>!!t.disabled||!!t.loading),f=e.computed(()=>{const a=t.color??"dark",k=(t.variant??"solid")==="solid"?`btn-${a}`:`btn-outline-${a}`,y=t.variant==="ghost"?"border-0":"",h=t.size?`btn-${t.size}`:"",B=t.block?"w-100":"",_=t.variant==="link"?"btn-ms-link":"";return["btn",k,_,y,h,B].filter(Boolean).join(" ")}),m=e.computed(()=>!!c.default?.().length),d=e.computed(()=>{if(t.icon&&t.icon.trim().length>0)return t.icon.trim();if(!m.value)return"error"});function s(n){if(u.value){n.preventDefault(),n.stopPropagation();return}i("click",n),t.share&&w(t.share),t.to&&(t.type==="submit"&&n.preventDefault(),n.stopPropagation(),r.push(t.to))}const b=e.computed(()=>t.to?"button":t.type??"button");return(n,a)=>(e.openBlock(),e.createElementBlock("button",e.mergeProps(e.unref(p),{class:[f.value,e.unref(p).class],type:b.value,disabled:u.value,"aria-busy":o.loading||void 0,onClick:s}),[o.loading&&d.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[a[0]||(a[0]=e.createElementVNode("span",{class:"me-2 d-inline-flex align-middle"},[e.createElementVNode("span",{class:"spinner-border spinner-border-sm align-middle",role:"status","aria-hidden":"true"})],-1)),e.renderSlot(n.$slots,"default",{},void 0,!0)],64)):o.loading&&!d.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[a[1]||(a[1]=e.createElementVNode("span",{class:"spinner-border spinner-border-sm align-middle",role:"status","aria-hidden":"true"},null,-1)),a[2]||(a[2]=e.createElementVNode("span",{class:"visually-hidden"},"Loading…",-1))],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[d.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(`${m.value?"me-2 ":""}d-inline-flex align-middle`)},[e.createElementVNode("span",T,e.toDisplayString(d.value),1)],2)):e.createCommentVNode("",!0),e.renderSlot(n.$slots,"default",{},void 0,!0)],64))],16,A))}}),P=(o,l)=>{const t=o.__vccOpts||o;for(const[i,c]of l)t[i]=c;return t},g=P(O,[["__scopeId","data-v-1fbd412d"]]),z={install(o){o.component("AccordionCmp",v),o.component("BtnCmp",g)}};exports.AccordionCmp=v;exports.BtnCmp=g;exports.default=z;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("vue"),gm=require("vue-router"),_m=["id"],ym={class:"accordion-item"},Tm={class:"accordion-header"},wm=["data-bs-target","aria-controls","disabled"],Em=["id","data-bs-parent"],vm={class:"accordion-body"},Im={key:0},Eh=_.defineComponent({inheritAttrs:!1,__name:"Accordion",props:{id:{},title:{},defaultOpen:{type:Boolean},disabled:{type:Boolean}},emits:["open"],setup(n,{emit:e}){const t=n,r=e,s=_.useSlots(),i=_.useAttrs(),a=_.computed(()=>t.id??"accordionDefault"),c=_.computed(()=>!!t.disabled),u=_.computed(()=>!!s.default?.().length),h=_.computed(()=>!!s.header?.().length);function f(m){if(c.value){m.preventDefault(),m.stopPropagation();return}r("open",m)}return(m,y)=>(_.openBlock(),_.createElementBlock("div",_.mergeProps({class:"accordion",id:a.value},_.unref(i)),[_.createElementVNode("div",ym,[_.createElementVNode("h2",Tm,[_.createElementVNode("button",{class:"accordion-button collapsed p-2",type:"button","data-bs-toggle":"collapse","data-bs-target":`#collapseOne-${a.value}`,"aria-expanded":"false","aria-controls":`collapseOne-${a.value}`,disabled:c.value,onClick:f},[h.value?_.renderSlot(m.$slots,"header",{key:0}):(_.openBlock(),_.createElementBlock(_.Fragment,{key:1},[_.createTextVNode(_.toDisplayString(t.title??"- default -"),1)],64))],8,wm)]),_.createElementVNode("div",{id:`collapseOne-${a.value}`,class:"accordion-collapse collapse","data-bs-parent":`#${a.value}`},[_.createElementVNode("div",vm,[u.value?_.createCommentVNode("",!0):(_.openBlock(),_.createElementBlock("p",Im,[...y[0]||(y[0]=[_.createTextVNode(" - ",-1),_.createElementVNode("span",{class:"material-symbols-outlined text-warning"}," warning ",-1),_.createTextVNode(" - ",-1)])])),_.renderSlot(m.$slots,"default")])],8,Em)])],16,_m))}});let Am=(n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");class vh{type;id;title;message;duration;timer;createdAt;logo;component;componentProps;actions;closeAction;constructor({type:e="info",title:t,message:r,logo:s,duration:i=3e3,component:a,componentProps:c,actions:u,closeAction:h}){if(this.type=e,this.id=Am(),this.title=t,this.message=r,this.duration=i,this.component=a,this.componentProps=c,this.actions=u,this.closeAction=h,this.timer=null,this.createdAt=null,this.logo=s,!this.logo)switch(e){case"info":this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="M480-80q-33 0-56.5-23.5T400-160h160q0 33-23.5 56.5T480-80ZM320-200v-80h320v80H320Zm10-120q-69-41-109.5-110T180-580q0-125 87.5-212.5T480-880q125 0 212.5 87.5T780-580q0 81-40.5 150T630-320H330Zm24-80h252q45-32 69.5-79T700-580q0-92-64-156t-156-64q-92 0-156 64t-64 156q0 54 24.5 101t69.5 79Zm126 0Z"/></svg>';break;case"error":this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="M480-280q17 0 28.5-11.5T520-320q0-17-11.5-28.5T480-360q-17 0-28.5 11.5T440-320q0 17 11.5 28.5T480-280Zm-40-160h80v-240h-80v240Zm40 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" /></svg>';break;case"success":this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q65 0 123 19t107 53l-58 59q-38-24-81-37.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160q133 0 226.5-93.5T800-480q0-18-2-36t-6-35l65-65q11 32 17 66t6 70q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm-56-216L254-466l56-56 114 114 400-401 56 56-456 457Z" /></svg>';break;case"warning":this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="m40-120 440-760 440 760H40Zm138-80h604L480-720 178-200Zm302-40q17 0 28.5-11.5T520-280q0-17-11.5-28.5T480-320q-17 0-28.5 11.5T440-280q0 17 11.5 28.5T480-240Zm-40-120h80v-200h-80v200Zm40-100Z"/></svg>';break;case"primary":this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-80q-100 0-170-70t-70-170q0-100 70-170t170-70q100 0 170 70t70 170q0 100-70 170t-170 70Zm0-80q66 0 113-47t47-113q0-66-47-113t-113-47q-66 0-113 47t-47 113q0 66 47 113t113 47Zm0-80q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Z"/></svg>';break;case"log":this.logo='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#0400ffff"><path d="M480-200q66 0 113-47t47-113v-160q0-66-47-113t-113-47q-66 0-113 47t-47 113v160q0 66 47 113t113 47Zm-80-120h160v-80H400v80Zm0-160h160v-80H400v80Zm80 40Zm0 320q-65 0-120.5-32T272-240H160v-80h84q-3-20-3.5-40t-.5-40h-80v-80h80q0-20 .5-40t3.5-40h-84v-80h112q14-23 31.5-43t40.5-35l-64-66 56-56 86 86q28-9 57-9t57 9l88-86 56 56-66 66q23 15 41.5 34.5T688-640h112v80h-84q3 20 3.5 40t.5 40h80v80h-80q0 20-.5 40t-3.5 40h84v80H688q-32 56-87.5 88T480-120Z"/></svg>';break;case"logError":this.logo='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#ff0000ff"><path d="M480-200q66 0 113-47t47-113v-160q0-66-47-113t-113-47q-66 0-113 47t-47 113v160q0 66 47 113t113 47Zm-80-120h160v-80H400v80Zm0-160h160v-80H400v80Zm80 40Zm0 320q-65 0-120.5-32T272-240H160v-80h84q-3-20-3.5-40t-.5-40h-80v-80h80q0-20 .5-40t3.5-40h-84v-80h112q14-23 31.5-43t40.5-35l-64-66 56-56 86 86q28-9 57-9t57 9l88-86 56 56-66 66q23 15 41.5 34.5T688-640h112v80h-84q3 20 3.5 40t.5 40h80v80h-80q0 20-.5 40t-3.5 40h84v80H688q-32 56-87.5 88T480-120ZM40-720v-120q0-33 23.5-56.5T120-920h120v80H120v120H40ZM240-40H120q-33 0-56.5-23.5T40-120v-120h80v120h120v80Zm480 0v-80h120v-120h80v120q0 33-23.5 56.5T840-40H720Zm120-680v-120H720v-80h120q33 0 56.5 23.5T920-840v120h-80Z"/></svg>';break;default:this.logo='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 -960 960 960" fill="currentcolor"><path d="M160-200v-80h80v-280q0-83 50-147.5T420-792v-28q0-25 17.5-42.5T480-880q25 0 42.5 17.5T540-820v28q80 20 130 84.5T720-560v280h80v80H160Zm320-300Zm0 420q-33 0-56.5-23.5T400-160h160q0 33-23.5 56.5T480-80ZM320-280h320v-280q0-66-47-113t-113-47q-66 0-113 47t-47 113v280Z" /></svg>';break}}start(e){if(this.duration===null){this.createdAt=null,this.timer=null;return}this.createdAt=Date.now(),this.timer=e}stop(){if(this.timer){if(clearTimeout(this.timer),this.timer=null,this.duration===null){this.createdAt=null;return}const e=Date.now()-(this.createdAt??Date.now()),t=this.duration-e;this.duration=Math.max(t,0)}}}function bm(n,e){try{return JSON.parse(n)}catch{U.logError(`Errore${e?' "'+e+'"':""} nel JSON.parse`);return}}const Ce={defaultKey:{isDev:"isDev",debugMod:"debugMod",currentUser:"currentUser",appConfig:"appConfig",lastLoginCurrentUser:"lastLoginCurrentUser"},getStr(n){const e=localStorage.getItem(n);if(e)return e},getParsed(n){const e=this.getStr(n);return e&&bm(e,n)},set(n,e){try{const t=JSON.stringify(e);return localStorage.setItem(n,t),t}catch(t){const r=t?.name==="QuotaExceededError"?"Spazio di archiviazione locale esaurito":`Errore nel salvataggio di "${n}"`;return U.logError(r),null}},update(n,e){const t=this.getParsed(n);return Array.isArray(t)?(t.push(e),this.set(n,t)):t&&typeof t=="object"?this.set(n,{...t,...e}):(U.logError("Devi usare set. typeof existing non è un object o array"),t)},push(n,...e){const t=this.getParsed(n);return Array.isArray(t)?(t.push(...e),this.set(n,t)):(U.logError(`push fallito: "${n}" non è un array`),t)},remove(n){try{localStorage.removeItem(n)}catch{U.logError(`Errore nella rimozione di "${n}"`)}},delete(n){this.remove(n)},has(n){try{return localStorage.getItem(n)!==null}catch{return!1}},keys(){return Object.keys(localStorage)},clear(n){try{const e=new Set(n?Array.isArray(n)?n:[n]:[]);for(let t=localStorage.length-1;t>=0;t--){const r=localStorage.key(t);r&&(e.has(r)||localStorage.removeItem(r))}}catch{U.logError("Errore nel pulire lo storage")}},migrate(n,e){const t=this.getStr(n);t!==void 0&&(this.set(e,t),this.remove(n))}},je=_.reactive({isDev:Ce.getParsed(Ce.defaultKey.isDev)!==void 0?Ce.getParsed(Ce.defaultKey.isDev):location.hostname==="localhost"||location.hostname==="127.0.0.1",debugMod:Ce.getParsed(Ce.defaultKey.debugMod),debugFirestore:!1}),U=_.reactive({queue:[],start(n){if(n.duration===null){n.start(null);return}n.start(setTimeout(()=>this.removeToastById(n.id),n.duration))},startAll(){for(const n of this.queue)this.start(n)},stop(n){if(n.timer){if(clearTimeout(n.timer),n.timer=null,n.duration===null){n.createdAt=null;return}const e=Date.now()-(n.createdAt??Date.now()),t=n.duration-e;n.duration=Math.max(t,0)}},stopAll(){for(const n of this.queue)n.stop()},removeToastByIndex(n){const e=this.queue[n];e?this.stop(e):console.error("toast to stop not found"),this.queue.splice(n,1)},removeToastById(n){for(const e in this.queue){const t=Number(e);if(this.queue[t]?.id===n){this.removeToastByIndex(t);break}}},_addToast(n,e,t){t=t===void 0?3e3:t;const r=new vh({type:n,title:typeof e=="object"?e.title:e,message:typeof e=="object"?e.message:void 0,logo:typeof e=="object"?e.logo:void 0,component:typeof e=="object"?e.component:void 0,componentProps:typeof e=="object"?e.componentProps:void 0,actions:typeof e=="object"?e.actions:void 0,closeAction:typeof e=="object"?e.closeAction:void 0,duration:t});this.queue.push(r),this.start(r)},info(n,e){this._addToast("info",n,e)},error(n,e){if(je.debugMod){const t=typeof n=="object"?`${n.title} ${n?.message??""} `:n;console.log("[ERROR]: "+t),console.error(t)}this._addToast("error",n,e)},danger(n,e){this.error(n,e)},success(n,e){this._addToast("success",n,e)},warning(n,e){if(je.debugMod){const t=typeof n=="object"?`${n.title} ${n?.message??""} `:n;console.log("[WARNING]: "+t),console.warn(t)}this._addToast("warning",n,e)},primary(n,e){this._addToast("primary",n,e)},secondary(n,e){this._addToast("secondary",n,e)},log(n,e){je.debugMod&&(console.log(typeof n=="object"?`${n.title} ${n?.message??""} `:n),this._addToast("log",n,e===void 0?5e3:e))},logError(n,e){if(!je.debugMod)return;const t=typeof n=="object"?`${n.title} ${n?.message??""} `:n;console.log("[ERROR]: "+t),console.error(t),this._addToast("logError",n,e===void 0?5e3:e)}});async function Ih({url:n,text:e,title:t}){if(navigator.share)try{await navigator.share({title:t??"Condividi",text:e??"",url:n})}catch{await navigator.clipboard.writeText(n),U.success("Link copiato negli appunti")}else await navigator.clipboard.writeText(n),U.success("Link copiato negli appunti")}const Sm=["type","disabled","aria-busy"],Rm={class:"material-symbols-outlined","aria-hidden":"true"},Pm=_.defineComponent({inheritAttrs:!1,__name:"Btn",props:{variant:{},color:{},size:{},block:{type:Boolean},disabled:{type:Boolean},type:{},to:{},loading:{type:Boolean},icon:{},share:{}},emits:["click"],setup(n,{emit:e}){const t=n,r=e,s=_.useSlots(),i=_.useAttrs(),a=gm.useRouter(),c=_.computed(()=>!!t.disabled||!!t.loading),u=_.computed(()=>{const k=t.color??"dark",V=(t.variant??"solid")==="solid"?`btn-${k}`:`btn-outline-${k}`,N=t.variant==="ghost"?"border-0":"",$=t.size?`btn-${t.size}`:"",W=t.block?"w-100":"",Q=t.variant==="link"?"btn-ms-link":"";return["btn",V,Q,N,$,W].filter(Boolean).join(" ")}),h=_.computed(()=>!!s.default?.().length),f=_.computed(()=>{if(t.icon&&t.icon.trim().length>0)return t.icon.trim();if(!h.value)return"error"});function m(S){if(c.value){S.preventDefault(),S.stopPropagation();return}r("click",S),t.share&&Ih(t.share),t.to&&(t.type==="submit"&&S.preventDefault(),S.stopPropagation(),a.push(t.to))}const y=_.computed(()=>t.to?"button":t.type??"button");return(S,k)=>(_.openBlock(),_.createElementBlock("button",_.mergeProps(_.unref(i),{class:[u.value,_.unref(i).class],type:y.value,disabled:c.value,"aria-busy":n.loading||void 0,onClick:m}),[n.loading&&f.value?(_.openBlock(),_.createElementBlock(_.Fragment,{key:0},[k[0]||(k[0]=_.createElementVNode("span",{class:"me-2 d-inline-flex align-middle"},[_.createElementVNode("span",{class:"spinner-border spinner-border-sm align-middle",role:"status","aria-hidden":"true"})],-1)),_.renderSlot(S.$slots,"default",{},void 0,!0)],64)):n.loading&&!f.value?(_.openBlock(),_.createElementBlock(_.Fragment,{key:1},[k[1]||(k[1]=_.createElementVNode("span",{class:"spinner-border spinner-border-sm align-middle",role:"status","aria-hidden":"true"},null,-1)),k[2]||(k[2]=_.createElementVNode("span",{class:"visually-hidden"},"Loading…",-1))],64)):(_.openBlock(),_.createElementBlock(_.Fragment,{key:2},[f.value?(_.openBlock(),_.createElementBlock("span",{key:0,class:_.normalizeClass(`${h.value?"me-2 ":""}d-inline-flex align-middle`)},[_.createElementVNode("span",Rm,_.toDisplayString(f.value),1)],2)):_.createCommentVNode("",!0),_.renderSlot(S.$slots,"default",{},void 0,!0)],64))],16,Sm))}}),ca=(n,e)=>{const t=n.__vccOpts||n;for(const[r,s]of e)t[r]=s;return t},gr=ca(Pm,[["__scopeId","data-v-1caf3817"]]),Cm=["onMouseenter"],km=["innerHTML"],Nm={class:"message-text-container text-dark"},Dm={class:"message-text mb-0"},Vm={class:"sub-content"},Om={key:0,class:"sub-text mb-0"},Lm={key:2,class:"text-end"},Mm=["onClick"],xm=_.defineComponent({__name:"ToastCmp",setup(n){const e=_.ref(null),t=_.computed(()=>U.queue||[]);function r(a){e.value=a,U.stopAll()}function s(){e.value=null,U.startAll()}function i(a){e.value=null,U.removeToastById(a)}return(a,c)=>(_.openBlock(),_.createBlock(_.TransitionGroup,{name:"toast-fade",tag:"div",class:"toast-wrapper"},{default:_.withCtx(()=>[(_.openBlock(!0),_.createElementBlock(_.Fragment,null,_.renderList(t.value,(u,h)=>(_.openBlock(),_.createElementBlock("div",{key:u.id,class:_.normalizeClass(["toast-card",[u.type,{expanded:e.value===null?h===t.value.length-1:e.value===u.id}]]),onMouseenter:f=>r(u.id),onMouseleave:s},[_.createElementVNode("div",{class:"icon-container",innerHTML:u.logo},null,8,km),_.createElementVNode("div",Nm,[_.createElementVNode("p",Dm,_.toDisplayString(u.title),1),_.createElementVNode("div",Vm,[u.message?(_.openBlock(),_.createElementBlock("p",Om,_.toDisplayString(u.message),1)):_.createCommentVNode("",!0),u.component?(_.openBlock(),_.createBlock(_.resolveDynamicComponent(u.component),_.mergeProps({key:1,ref_for:!0},u.componentProps,{class:"mt-2 me-2"}),_.createSlots({_:2},[u.componentProps?.children?{name:"default",fn:_.withCtx(()=>[_.createTextVNode(_.toDisplayString(typeof u.componentProps.children=="function"?u.componentProps.children():u.componentProps.children),1)]),key:"0"}:void 0]),1040)):_.createCommentVNode("",!0),u.actions?(_.openBlock(),_.createElementBlock("div",Lm,[u.closeAction!==!1?(_.openBlock(),_.createBlock(gr,{key:0,variant:"link",class:"mt-2 me-1"},{default:_.withCtx(()=>[...c[0]||(c[0]=[_.createTextVNode("close",-1)])]),_:1})):_.createCommentVNode("",!0),(_.openBlock(!0),_.createElementBlock(_.Fragment,null,_.renderList(u.actions,(f,m)=>(_.openBlock(),_.createElementBlock(_.Fragment,{key:u.id+"-action-"+m},[f.content?(_.openBlock(),_.createBlock(gr,{key:0,onClick:()=>{f.onClick(),i(u.id)},icon:f.icon,variant:f.variant,color:f.color,disabled:typeof f.disabled=="function"?f.disabled():f.disabled,class:_.normalizeClass(["mt-2","me-2",f.class]),style:_.normalizeStyle(f.style)},{default:_.withCtx(()=>[_.createTextVNode(_.toDisplayString(f.content),1)]),_:2},1032,["onClick","icon","variant","color","disabled","class","style"])):(_.openBlock(),_.createBlock(gr,{key:1,onClick:()=>{f.onClick(),i(u.id)},icon:f.icon,variant:f.variant,color:f.color,disabled:typeof f.disabled=="function"?f.disabled():f.disabled,class:_.normalizeClass(["mt-2","me-2",f.class]),style:_.normalizeStyle(f.style)},null,8,["onClick","icon","variant","color","disabled","class","style"]))],64))),128))])):_.createCommentVNode("",!0)])]),(_.openBlock(),_.createElementBlock("svg",{class:"cross-icon",viewBox:"0 0 15 15",fill:"currentColor",onClick:f=>i(u.id)},[...c[1]||(c[1]=[_.createElementVNode("path",{d:"M11.78 4.03c.23-.23.23-.6 0-.83s-.6-.23-.83 0L7.5 6.69 4.03 3.2c-.23-.23-.6-.23-.83 0s-.23.6 0 .83L6.69 7.5 3.2 10.97c-.23.23-.23.6 0 .83s.6.23.83 0L7.5 8.31l3.47 3.47c.23.23.6.23.83 0s.23-.6 0-.83L8.31 7.5l3.47-3.47z"},null,-1)])],8,Mm))],42,Cm))),128))]),_:1}))}}),Ah=ca(xm,[["__scopeId","data-v-2cc28e46"]]),Fm=["for"],Um={key:0,class:"text-danger"},Bm=["disabled","readonly"],qm={value:""},$m=["id"],bh=_.defineComponent({__name:"FieldGender",props:{modelValue:{},field:{},fv:{},label:{type:[String,Boolean],default:!1},placeholder:{default:"—"},errors:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},required:{type:Boolean,default:!1},class:{},style:{},classLabel:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,r=e,s=_.computed({get(){return t.modelValue??""},set(a){r("update:modelValue",a??"")}}),i=_.computed(()=>typeof t.label!="string"&&t.label!==!0&&t.label!==!1);return(a,c)=>(_.openBlock(),_.createElementBlock(_.Fragment,null,[n.label&&!i.value?(_.openBlock(),_.createElementBlock("label",{key:0,class:_.normalizeClass(["form-label",t.classLabel]),for:n.fv.getFieldId(n.field)},[_.createTextVNode(_.toDisplayString(n.label===!0?n.field:n.label)+" ",1),n.required?(_.openBlock(),_.createElementBlock("span",Um," *")):_.createCommentVNode("",!0)],10,Fm)):n.label&&i.value?(_.openBlock(),_.createBlock(_.resolveDynamicComponent(n.label),{key:1,for:n.fv.getFieldId(n.field)},null,8,["for"])):_.createCommentVNode("",!0),_.withDirectives(_.createElementVNode("select",_.mergeProps({class:"form-select","onUpdate:modelValue":c[0]||(c[0]=u=>s.value=u)},n.fv.getFieldProps(n.field),{class:t.class,style:t.style,disabled:n.disabled,readonly:n.readonly}),[_.createElementVNode("option",qm,_.toDisplayString(n.placeholder),1),c[1]||(c[1]=_.createElementVNode("option",{value:"m"},"Maschio",-1)),c[2]||(c[2]=_.createElementVNode("option",{value:"f"},"Femmina",-1)),c[3]||(c[3]=_.createElementVNode("option",{value:"o"},"Altro / Preferisco non dirlo",-1))],16,Bm),[[_.vModelSelect,s.value]]),n.errors?(_.openBlock(),_.createElementBlock("div",{key:2,id:n.fv.getFieldIdError(n.field),class:"invalid-feedback"},_.toDisplayString(n.fv.showError(n.field)),9,$m)):_.createCommentVNode("",!0)],64))}}),jm=["for"],zm={class:"d-flex gap-2"},Hm=["placeholder","disabled","readonly"],Gm=["placeholder","disabled","readonly"],Km=["id"],Wm=_.defineComponent({__name:"FieldPhoneNumber",props:{modelValue:{},field:{},fv:{},label:{type:[String,Boolean],default:!1},placeholder:{default:"333 1234567"},placeholderPrefix:{default:"+39"},errors:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},class:{},style:{},disabledPrefix:{type:Boolean},disabledNumber:{type:Boolean},readonlyPrefix:{type:Boolean},readonlyNumber:{type:Boolean},classPrefix:{},classNumber:{},stylePrefix:{},styleNumber:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,r=e,s=_.computed({get(){return t.modelValue?.[0]??t.placeholderPrefix??""},set(k){r("update:modelValue",[k,t.modelValue?.[1]??""])}}),i=_.computed({get(){return t.modelValue?.[1]??""},set(k){r("update:modelValue",[t.modelValue?.[0]??t.placeholderPrefix??"",k])}}),a=_.computed(()=>t.disabledPrefix??t.disabled),c=_.computed(()=>t.disabledNumber??t.disabled),u=_.computed(()=>t.readonlyPrefix??t.readonly),h=_.computed(()=>t.readonlyNumber??t.readonly),f=_.computed(()=>[t.class,t.classPrefix]),m=_.computed(()=>[t.class,t.classNumber]),y=_.computed(()=>[t.style,t.stylePrefix]),S=_.computed(()=>[t.style,t.styleNumber]);return(k,V)=>(_.openBlock(),_.createElementBlock(_.Fragment,null,[n.label?(_.openBlock(),_.createElementBlock("label",{key:0,class:"form-label",for:n.fv.getFieldId(n.field)},_.toDisplayString(n.label===!0?n.field:n.label),9,jm)):_.createCommentVNode("",!0),_.createElementVNode("div",zm,[_.withDirectives(_.createElementVNode("input",{type:"text","onUpdate:modelValue":V[0]||(V[0]=N=>s.value=N),class:_.normalizeClass(["form-control prefix-width",f.value]),style:_.normalizeStyle(y.value),placeholder:n.placeholderPrefix,disabled:a.value,readonly:u.value,autocomplete:"tel-country-code",inputmode:"tel"},null,14,Hm),[[_.vModelText,s.value]]),_.withDirectives(_.createElementVNode("input",_.mergeProps({type:"text","onUpdate:modelValue":V[1]||(V[1]=N=>i.value=N)},n.fv.getFieldProps(n.field),{class:["form-control",m.value],style:S.value,placeholder:n.placeholder,disabled:c.value,readonly:h.value,autocomplete:"tel",inputmode:"tel"}),null,16,Gm),[[_.vModelText,i.value]])]),n.errors?(_.openBlock(),_.createElementBlock("div",{key:1,id:n.fv.getFieldIdError(n.field),class:"invalid-feedback"},_.toDisplayString(n.fv.showError(n.field)),9,Km)):_.createCommentVNode("",!0)],64))}}),Sh=ca(Wm,[["__scopeId","data-v-d70bf135"]]),Qm=["for"],Jm={key:0,class:"text-danger"},Ym=["type","placeholder","disabled","readonly","autocomplete","inputmode"],Xm=["id"],Rh=_.defineComponent({__name:"InputField",props:{modelValue:{},field:{},fv:{},label:{type:[String,Boolean],default:!1},placeholder:{default:""},errors:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},required:{type:Boolean,default:!1},class:{},style:{},classLabel:{},type:{default:"text"},autocomplete:{},inputmode:{}},emits:["update:modelValue"],setup(n,{emit:e}){const t=n,r=e,s=_.computed({get(){return t.modelValue??""},set(a){r("update:modelValue",a??"")}}),i=_.computed(()=>typeof t.label!="string"&&t.label!==!0&&t.label!==!1);return(a,c)=>(_.openBlock(),_.createElementBlock(_.Fragment,null,[n.label&&!i.value?(_.openBlock(),_.createElementBlock("label",{key:0,class:_.normalizeClass(["form-label",t.classLabel]),for:n.fv.getFieldId(n.field)},[_.createTextVNode(_.toDisplayString(n.label===!0?n.field:n.label)+" ",1),n.required?(_.openBlock(),_.createElementBlock("span",Jm," *")):_.createCommentVNode("",!0)],10,Qm)):n.label&&i.value?(_.openBlock(),_.createBlock(_.resolveDynamicComponent(n.label),{key:1,for:n.fv.getFieldId(n.field)},null,8,["for"])):_.createCommentVNode("",!0),_.withDirectives(_.createElementVNode("input",_.mergeProps({type:n.type,"onUpdate:modelValue":c[0]||(c[0]=u=>s.value=u)},n.fv.getFieldProps(n.field),{class:["form-control",t.class],style:t.style,placeholder:n.placeholder,disabled:n.disabled,readonly:n.readonly,autocomplete:n.autocomplete,inputmode:n.inputmode}),null,16,Ym),[[_.vModelDynamic,s.value]]),n.errors?(_.openBlock(),_.createElementBlock("div",{key:2,id:n.fv.getFieldIdError(n.field),class:"invalid-feedback"},_.toDisplayString(n.fv.showError(n.field)),9,Xm)):_.createCommentVNode("",!0)],64))}}),Zm=()=>{};const Ph=function(n){const e=[];let t=0;for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&r+1<n.length&&(n.charCodeAt(r+1)&64512)===56320?(s=65536+((s&1023)<<10)+(n.charCodeAt(++r)&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},eg=function(n){const e=[];let t=0,r=0;for(;t<n.length;){const s=n[t++];if(s<128)e[r++]=String.fromCharCode(s);else if(s>191&&s<224){const i=n[t++];e[r++]=String.fromCharCode((s&31)<<6|i&63)}else if(s>239&&s<365){const i=n[t++],a=n[t++],c=n[t++],u=((s&7)<<18|(i&63)<<12|(a&63)<<6|c&63)-65536;e[r++]=String.fromCharCode(55296+(u>>10)),e[r++]=String.fromCharCode(56320+(u&1023))}else{const i=n[t++],a=n[t++];e[r++]=String.fromCharCode((s&15)<<12|(i&63)<<6|a&63)}}return e.join("")},Ch={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(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();const t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let s=0;s<n.length;s+=3){const i=n[s],a=s+1<n.length,c=a?n[s+1]:0,u=s+2<n.length,h=u?n[s+2]:0,f=i>>2,m=(i&3)<<4|c>>4;let y=(c&15)<<2|h>>6,S=h&63;u||(S=64,a||(y=64)),r.push(t[f],t[m],t[y],t[S])}return r.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(Ph(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):eg(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let s=0;s<n.length;){const i=t[n.charAt(s++)],c=s<n.length?t[n.charAt(s)]:0;++s;const h=s<n.length?t[n.charAt(s)]:64;++s;const m=s<n.length?t[n.charAt(s)]:64;if(++s,i==null||c==null||h==null||m==null)throw new tg;const y=i<<2|c>>4;if(r.push(y),h!==64){const S=c<<4&240|h>>2;if(r.push(S),m!==64){const k=h<<6&192|m;r.push(k)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}};class tg extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const ng=function(n){const e=Ph(n);return Ch.encodeByteArray(e,!0)},Ss=function(n){return ng(n).replace(/\./g,"")},kh=function(n){try{return Ch.decodeString(n,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function rg(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}const sg=()=>rg().__FIREBASE_DEFAULTS__,ig=()=>{if(typeof process>"u"||typeof process.env>"u")return;const n=process.env.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},og=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&kh(n[1]);return e&&JSON.parse(e)},si=()=>{try{return Zm()||sg()||ig()||og()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},Nh=n=>si()?.emulatorHosts?.[n],la=n=>{const e=Nh(n);if(!e)return;const t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const r=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),r]:[e.substring(0,t),r]},Dh=()=>si()?.config,Vh=n=>si()?.[`_${n}`];class ag{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,r)=>{t?this.reject(t):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,r))}}}function vt(n){try{return(n.startsWith("http://")||n.startsWith("https://")?new URL(n).hostname:n).endsWith(".cloudworkstations.dev")}catch{return!1}}async function ii(n){return(await fetch(n,{credentials:"include"})).ok}function Oh(n,e){if(n.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const t={alg:"none",type:"JWT"},r=e||"demo-project",s=n.iat||0,i=n.sub||n.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const a={iss:`https://securetoken.google.com/${r}`,aud:r,iat:s,exp:s+3600,auth_time:s,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}},...n};return[Ss(JSON.stringify(t)),Ss(JSON.stringify(a)),""].join(".")}const _r={};function cg(){const n={prod:[],emulator:[]};for(const e of Object.keys(_r))_r[e]?n.emulator.push(e):n.prod.push(e);return n}function lg(n){let e=document.getElementById(n),t=!1;return e||(e=document.createElement("div"),e.setAttribute("id",n),t=!0),{created:t,element:e}}let Il=!1;function oi(n,e){if(typeof window>"u"||typeof document>"u"||!vt(window.location.host)||_r[n]===e||_r[n]||Il)return;_r[n]=e;function t(y){return`__firebase__banner__${y}`}const r="__firebase__banner",i=cg().prod.length>0;function a(){const y=document.getElementById(r);y&&y.remove()}function c(y){y.style.display="flex",y.style.background="#7faaf0",y.style.position="fixed",y.style.bottom="5px",y.style.left="5px",y.style.padding=".5em",y.style.borderRadius="5px",y.style.alignItems="center"}function u(y,S){y.setAttribute("width","24"),y.setAttribute("id",S),y.setAttribute("height","24"),y.setAttribute("viewBox","0 0 24 24"),y.setAttribute("fill","none"),y.style.marginLeft="-6px"}function h(){const y=document.createElement("span");return y.style.cursor="pointer",y.style.marginLeft="16px",y.style.fontSize="24px",y.innerHTML=" &times;",y.onclick=()=>{Il=!0,a()},y}function f(y,S){y.setAttribute("id",S),y.innerText="Learn more",y.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",y.setAttribute("target","__blank"),y.style.paddingLeft="5px",y.style.textDecoration="underline"}function m(){const y=lg(r),S=t("text"),k=document.getElementById(S)||document.createElement("span"),V=t("learnmore"),N=document.getElementById(V)||document.createElement("a"),$=t("preprendIcon"),W=document.getElementById($)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(y.created){const Q=y.element;c(Q),f(N,V);const te=h();u(W,$),Q.append(W,k,N,te),document.body.appendChild(Q)}i?(k.innerText="Preview backend disconnected.",W.innerHTML=`<g clip-path="url(#clip0_6013_33858)">
2
+ <path d="M4.8 17.6L12 5.6L19.2 17.6H4.8ZM6.91667 16.4H17.0833L12 7.93333L6.91667 16.4ZM12 15.6C12.1667 15.6 12.3056 15.5444 12.4167 15.4333C12.5389 15.3111 12.6 15.1667 12.6 15C12.6 14.8333 12.5389 14.6944 12.4167 14.5833C12.3056 14.4611 12.1667 14.4 12 14.4C11.8333 14.4 11.6889 14.4611 11.5667 14.5833C11.4556 14.6944 11.4 14.8333 11.4 15C11.4 15.1667 11.4556 15.3111 11.5667 15.4333C11.6889 15.5444 11.8333 15.6 12 15.6ZM11.4 13.6H12.6V10.4H11.4V13.6Z" fill="#212121"/>
3
+ </g>
4
+ <defs>
5
+ <clipPath id="clip0_6013_33858">
6
+ <rect width="24" height="24" fill="white"/>
7
+ </clipPath>
8
+ </defs>`):(W.innerHTML=`<g clip-path="url(#clip0_6083_34804)">
9
+ <path d="M11.4 15.2H12.6V11.2H11.4V15.2ZM12 10C12.1667 10 12.3056 9.94444 12.4167 9.83333C12.5389 9.71111 12.6 9.56667 12.6 9.4C12.6 9.23333 12.5389 9.09444 12.4167 8.98333C12.3056 8.86111 12.1667 8.8 12 8.8C11.8333 8.8 11.6889 8.86111 11.5667 8.98333C11.4556 9.09444 11.4 9.23333 11.4 9.4C11.4 9.56667 11.4556 9.71111 11.5667 9.83333C11.6889 9.94444 11.8333 10 12 10ZM12 18.4C11.1222 18.4 10.2944 18.2333 9.51667 17.9C8.73889 17.5667 8.05556 17.1111 7.46667 16.5333C6.88889 15.9444 6.43333 15.2611 6.1 14.4833C5.76667 13.7056 5.6 12.8778 5.6 12C5.6 11.1111 5.76667 10.2833 6.1 9.51667C6.43333 8.73889 6.88889 8.06111 7.46667 7.48333C8.05556 6.89444 8.73889 6.43333 9.51667 6.1C10.2944 5.76667 11.1222 5.6 12 5.6C12.8889 5.6 13.7167 5.76667 14.4833 6.1C15.2611 6.43333 15.9389 6.89444 16.5167 7.48333C17.1056 8.06111 17.5667 8.73889 17.9 9.51667C18.2333 10.2833 18.4 11.1111 18.4 12C18.4 12.8778 18.2333 13.7056 17.9 14.4833C17.5667 15.2611 17.1056 15.9444 16.5167 16.5333C15.9389 17.1111 15.2611 17.5667 14.4833 17.9C13.7167 18.2333 12.8889 18.4 12 18.4ZM12 17.2C13.4444 17.2 14.6722 16.6944 15.6833 15.6833C16.6944 14.6722 17.2 13.4444 17.2 12C17.2 10.5556 16.6944 9.32778 15.6833 8.31667C14.6722 7.30555 13.4444 6.8 12 6.8C10.5556 6.8 9.32778 7.30555 8.31667 8.31667C7.30556 9.32778 6.8 10.5556 6.8 12C6.8 13.4444 7.30556 14.6722 8.31667 15.6833C9.32778 16.6944 10.5556 17.2 12 17.2Z" fill="#212121"/>
10
+ </g>
11
+ <defs>
12
+ <clipPath id="clip0_6083_34804">
13
+ <rect width="24" height="24" fill="white"/>
14
+ </clipPath>
15
+ </defs>`,k.innerText="Preview backend running in this workspace."),k.setAttribute("id",S)}document.readyState==="loading"?window.addEventListener("DOMContentLoaded",m):m()}function Se(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function ug(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(Se())}function hg(){const n=si()?.forceEnvironment;if(n==="node")return!0;if(n==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function dg(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function Lh(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function fg(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function pg(){const n=Se();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function mg(){return!hg()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function ua(){try{return typeof indexedDB=="object"}catch{return!1}}function ha(){return new Promise((n,e)=>{try{let t=!0;const r="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(r);s.onsuccess=()=>{s.result.close(),t||self.indexedDB.deleteDatabase(r),n(!0)},s.onupgradeneeded=()=>{t=!1},s.onerror=()=>{e(s.error?.message||"")}}catch(t){e(t)}})}function Mh(){return!(typeof navigator>"u"||!navigator.cookieEnabled)}const gg="FirebaseError";class $e extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name=gg,Object.setPrototypeOf(this,$e.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Kt.prototype.create)}}class Kt{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){const r=t[0]||{},s=`${this.service}/${e}`,i=this.errors[e],a=i?_g(i,r):"Error",c=`${this.serviceName}: ${a} (${s}).`;return new $e(s,c,r)}}function _g(n,e){return n.replace(yg,(t,r)=>{const s=e[r];return s!=null?String(s):`<${r}?>`})}const yg=/\{\$([^}]+)}/g;function Tg(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function Ut(n,e){if(n===e)return!0;const t=Object.keys(n),r=Object.keys(e);for(const s of t){if(!r.includes(s))return!1;const i=n[s],a=e[s];if(Al(i)&&Al(a)){if(!Ut(i,a))return!1}else if(i!==a)return!1}for(const s of r)if(!t.includes(s))return!1;return!0}function Al(n){return n!==null&&typeof n=="object"}function Mr(n){const e=[];for(const[t,r]of Object.entries(n))Array.isArray(r)?r.forEach(s=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(s))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function wg(n,e){const t=new Eg(n,e);return t.subscribe.bind(t)}class Eg{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(r=>{this.error(r)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let s;if(e===void 0&&t===void 0&&r===void 0)throw new Error("Missing Observer.");vg(e,["next","error","complete"])?s=e:s={next:e,error:t,complete:r},s.next===void 0&&(s.next=no),s.error===void 0&&(s.error=no),s.complete===void 0&&(s.complete=no);const i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?s.error(this.finalError):s.complete()}catch{}}),this.observers.push(s),i}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{t(this.observers[e])}catch(r){typeof console<"u"&&console.error&&console.error(r)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function vg(n,e){if(typeof n!="object"||n===null)return!1;for(const t of e)if(t in n&&typeof n[t]=="function")return!0;return!1}function no(){}const Ig=1e3,Ag=2,bg=14400*1e3,Sg=.5;function bl(n,e=Ig,t=Ag){const r=e*Math.pow(t,n),s=Math.round(Sg*r*(Math.random()-.5)*2);return Math.min(bg,r+s)}function ee(n){return n&&n._delegate?n._delegate:n}class Ne{constructor(e,t,r){this.name=e,this.instanceFactory=t,this.type=r,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}}const nn="[DEFAULT]";class Rg{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const r=new ag;if(this.instancesDeferred.set(t,r),this.isInitialized(t)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:t});s&&r.resolve(s)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){const t=this.normalizeInstanceIdentifier(e?.identifier),r=e?.optional??!1;if(this.isInitialized(t)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:t})}catch(s){if(r)return null;throw s}else{if(r)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(Cg(e))try{this.getOrInitializeService({instanceIdentifier:nn})}catch{}for(const[t,r]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(t);try{const i=this.getOrInitializeService({instanceIdentifier:s});r.resolve(i)}catch{}}}}clearInstance(e=nn){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(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=nn){return this.instances.has(e)}getOptions(e=nn){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,r=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const s=this.getOrInitializeService({instanceIdentifier:r,options:t});for(const[i,a]of this.instancesDeferred.entries()){const c=this.normalizeInstanceIdentifier(i);r===c&&a.resolve(s)}return s}onInit(e,t){const r=this.normalizeInstanceIdentifier(t),s=this.onInitCallbacks.get(r)??new Set;s.add(e),this.onInitCallbacks.set(r,s);const i=this.instances.get(r);return i&&e(i,r),()=>{s.delete(e)}}invokeOnInitCallbacks(e,t){const r=this.onInitCallbacks.get(t);if(r)for(const s of r)try{s(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:Pg(e),options:t}),this.instances.set(e,r),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r)}catch{}return r||null}normalizeInstanceIdentifier(e=nn){return this.component?this.component.multipleInstances?e:nn:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function Pg(n){return n===nn?void 0:n}function Cg(n){return n.instantiationMode==="EAGER"}class kg{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new Rg(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}var H;(function(n){n[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT"})(H||(H={}));const Ng={debug:H.DEBUG,verbose:H.VERBOSE,info:H.INFO,warn:H.WARN,error:H.ERROR,silent:H.SILENT},Dg=H.INFO,Vg={[H.DEBUG]:"log",[H.VERBOSE]:"log",[H.INFO]:"info",[H.WARN]:"warn",[H.ERROR]:"error"},Og=(n,e,...t)=>{if(e<n.logLevel)return;const r=new Date().toISOString(),s=Vg[e];if(s)console[s](`[${r}] ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class ai{constructor(e){this.name=e,this._logLevel=Dg,this._logHandler=Og,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in H))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?Ng[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,H.DEBUG,...e),this._logHandler(this,H.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,H.VERBOSE,...e),this._logHandler(this,H.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,H.INFO,...e),this._logHandler(this,H.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,H.WARN,...e),this._logHandler(this,H.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,H.ERROR,...e),this._logHandler(this,H.ERROR,...e)}}const Lg=(n,e)=>e.some(t=>n instanceof t);let Sl,Rl;function Mg(){return Sl||(Sl=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function xg(){return Rl||(Rl=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const xh=new WeakMap,So=new WeakMap,Fh=new WeakMap,ro=new WeakMap,da=new WeakMap;function Fg(n){const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("success",i),n.removeEventListener("error",a)},i=()=>{t(gt(n.result)),s()},a=()=>{r(n.error),s()};n.addEventListener("success",i),n.addEventListener("error",a)});return e.then(t=>{t instanceof IDBCursor&&xh.set(t,n)}).catch(()=>{}),da.set(e,n),e}function Ug(n){if(So.has(n))return;const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("complete",i),n.removeEventListener("error",a),n.removeEventListener("abort",a)},i=()=>{t(),s()},a=()=>{r(n.error||new DOMException("AbortError","AbortError")),s()};n.addEventListener("complete",i),n.addEventListener("error",a),n.addEventListener("abort",a)});So.set(n,e)}let Ro={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return So.get(n);if(e==="objectStoreNames")return n.objectStoreNames||Fh.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return gt(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function Bg(n){Ro=n(Ro)}function qg(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const r=n.call(so(this),e,...t);return Fh.set(r,e.sort?e.sort():[e]),gt(r)}:xg().includes(n)?function(...e){return n.apply(so(this),e),gt(xh.get(this))}:function(...e){return gt(n.apply(so(this),e))}}function $g(n){return typeof n=="function"?qg(n):(n instanceof IDBTransaction&&Ug(n),Lg(n,Mg())?new Proxy(n,Ro):n)}function gt(n){if(n instanceof IDBRequest)return Fg(n);if(ro.has(n))return ro.get(n);const e=$g(n);return e!==n&&(ro.set(n,e),da.set(e,n)),e}const so=n=>da.get(n);function ci(n,e,{blocked:t,upgrade:r,blocking:s,terminated:i}={}){const a=indexedDB.open(n,e),c=gt(a);return r&&a.addEventListener("upgradeneeded",u=>{r(gt(a.result),u.oldVersion,u.newVersion,gt(a.transaction),u)}),t&&a.addEventListener("blocked",u=>t(u.oldVersion,u.newVersion,u)),c.then(u=>{i&&u.addEventListener("close",()=>i()),s&&u.addEventListener("versionchange",h=>s(h.oldVersion,h.newVersion,h))}).catch(()=>{}),c}function io(n,{blocked:e}={}){const t=indexedDB.deleteDatabase(n);return e&&t.addEventListener("blocked",r=>e(r.oldVersion,r)),gt(t).then(()=>{})}const jg=["get","getKey","getAll","getAllKeys","count"],zg=["put","add","delete","clear"],oo=new Map;function Pl(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(oo.get(e))return oo.get(e);const t=e.replace(/FromIndex$/,""),r=e!==t,s=zg.includes(t);if(!(t in(r?IDBIndex:IDBObjectStore).prototype)||!(s||jg.includes(t)))return;const i=async function(a,...c){const u=this.transaction(a,s?"readwrite":"readonly");let h=u.store;return r&&(h=h.index(c.shift())),(await Promise.all([h[t](...c),s&&u.done]))[0]};return oo.set(e,i),i}Bg(n=>({...n,get:(e,t,r)=>Pl(e,t)||n.get(e,t,r),has:(e,t)=>!!Pl(e,t)||n.has(e,t)}));class Hg{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(Gg(t)){const r=t.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(t=>t).join(" ")}}function Gg(n){return n.getComponent()?.type==="VERSION"}const Po="@firebase/app",Cl="0.14.7";const yt=new ai("@firebase/app"),Kg="@firebase/app-compat",Wg="@firebase/analytics-compat",Qg="@firebase/analytics",Jg="@firebase/app-check-compat",Yg="@firebase/app-check",Xg="@firebase/auth",Zg="@firebase/auth-compat",e_="@firebase/database",t_="@firebase/data-connect",n_="@firebase/database-compat",r_="@firebase/functions",s_="@firebase/functions-compat",i_="@firebase/installations",o_="@firebase/installations-compat",a_="@firebase/messaging",c_="@firebase/messaging-compat",l_="@firebase/performance",u_="@firebase/performance-compat",h_="@firebase/remote-config",d_="@firebase/remote-config-compat",f_="@firebase/storage",p_="@firebase/storage-compat",m_="@firebase/firestore",g_="@firebase/ai",__="@firebase/firestore-compat",y_="firebase",T_="12.8.0";const Co="[DEFAULT]",w_={[Po]:"fire-core",[Kg]:"fire-core-compat",[Qg]:"fire-analytics",[Wg]:"fire-analytics-compat",[Yg]:"fire-app-check",[Jg]:"fire-app-check-compat",[Xg]:"fire-auth",[Zg]:"fire-auth-compat",[e_]:"fire-rtdb",[t_]:"fire-data-connect",[n_]:"fire-rtdb-compat",[r_]:"fire-fn",[s_]:"fire-fn-compat",[i_]:"fire-iid",[o_]:"fire-iid-compat",[a_]:"fire-fcm",[c_]:"fire-fcm-compat",[l_]:"fire-perf",[u_]:"fire-perf-compat",[h_]:"fire-rc",[d_]:"fire-rc-compat",[f_]:"fire-gcs",[p_]:"fire-gcs-compat",[m_]:"fire-fst",[__]:"fire-fst-compat",[g_]:"fire-vertex","fire-js":"fire-js",[y_]:"fire-js-all"};const Rs=new Map,E_=new Map,ko=new Map;function kl(n,e){try{n.container.addComponent(e)}catch(t){yt.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function Me(n){const e=n.name;if(ko.has(e))return yt.debug(`There were multiple attempts to register component ${e}.`),!1;ko.set(e,n);for(const t of Rs.values())kl(t,n);for(const t of E_.values())kl(t,n);return!0}function ut(n,e){const t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}function Fe(n){return n==null?!1:n.settings!==void 0}const v_={"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."},Mt=new Kt("app","Firebase",v_);class I_{constructor(e,t,r){this._isDeleted=!1,this._options={...e},this._config={...t},this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new Ne("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 Mt.create("app-deleted",{appName:this._name})}}const yn=T_;function Uh(n,e={}){let t=n;typeof e!="object"&&(e={name:e});const r={name:Co,automaticDataCollectionEnabled:!0,...e},s=r.name;if(typeof s!="string"||!s)throw Mt.create("bad-app-name",{appName:String(s)});if(t||(t=Dh()),!t)throw Mt.create("no-options");const i=Rs.get(s);if(i){if(Ut(t,i.options)&&Ut(r,i.config))return i;throw Mt.create("duplicate-app",{appName:s})}const a=new kg(s);for(const u of ko.values())a.addComponent(u);const c=new I_(t,r,a);return Rs.set(s,c),c}function $n(n=Co){const e=Rs.get(n);if(!e&&n===Co&&Dh())return Uh();if(!e)throw Mt.create("no-app",{appName:n});return e}function me(n,e,t){let r=w_[n]??n;t&&(r+=`-${t}`);const s=r.match(/\s|\//),i=e.match(/\s|\//);if(s||i){const a=[`Unable to register library "${r}" with version "${e}":`];s&&a.push(`library name "${r}" contains illegal characters (whitespace or "/")`),s&&i&&a.push("and"),i&&a.push(`version name "${e}" contains illegal characters (whitespace or "/")`),yt.warn(a.join(" "));return}Me(new Ne(`${r}-version`,()=>({library:r,version:e}),"VERSION"))}const A_="firebase-heartbeat-database",b_=1,br="firebase-heartbeat-store";let ao=null;function Bh(){return ao||(ao=ci(A_,b_,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore(br)}catch(t){console.warn(t)}}}}).catch(n=>{throw Mt.create("idb-open",{originalErrorMessage:n.message})})),ao}async function S_(n){try{const t=(await Bh()).transaction(br),r=await t.objectStore(br).get(qh(n));return await t.done,r}catch(e){if(e instanceof $e)yt.warn(e.message);else{const t=Mt.create("idb-get",{originalErrorMessage:e?.message});yt.warn(t.message)}}}async function Nl(n,e){try{const r=(await Bh()).transaction(br,"readwrite");await r.objectStore(br).put(e,qh(n)),await r.done}catch(t){if(t instanceof $e)yt.warn(t.message);else{const r=Mt.create("idb-set",{originalErrorMessage:t?.message});yt.warn(r.message)}}}function qh(n){return`${n.name}!${n.options.appId}`}const R_=1024,P_=30;class C_{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new N_(t),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){try{const t=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),r=Dl();if(this._heartbeatsCache?.heartbeats==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null)||this._heartbeatsCache.lastSentHeartbeatDate===r||this._heartbeatsCache.heartbeats.some(s=>s.date===r))return;if(this._heartbeatsCache.heartbeats.push({date:r,agent:t}),this._heartbeatsCache.heartbeats.length>P_){const s=D_(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(s,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){yt.warn(e)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return"";const e=Dl(),{heartbeatsToSend:t,unsentEntries:r}=k_(this._heartbeatsCache.heartbeats),s=Ss(JSON.stringify({version:2,heartbeats:t}));return this._heartbeatsCache.lastSentHeartbeatDate=e,r.length>0?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),s}catch(e){return yt.warn(e),""}}}function Dl(){return new Date().toISOString().substring(0,10)}function k_(n,e=R_){const t=[];let r=n.slice();for(const s of n){const i=t.find(a=>a.agent===s.agent);if(i){if(i.dates.push(s.date),Vl(t)>e){i.dates.pop();break}}else if(t.push({agent:s.agent,dates:[s.date]}),Vl(t)>e){t.pop();break}r=r.slice(1)}return{heartbeatsToSend:t,unsentEntries:r}}class N_{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return ua()?ha().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const t=await S_(this.app);return t?.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return Nl(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return Nl(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...e.heartbeats]})}else return}}function Vl(n){return Ss(JSON.stringify({version:2,heartbeats:n})).length}function D_(n){if(n.length===0)return-1;let e=0,t=n[0].date;for(let r=1;r<n.length;r++)n[r].date<t&&(t=n[r].date,e=r);return e}function V_(n){Me(new Ne("platform-logger",e=>new Hg(e),"PRIVATE")),Me(new Ne("heartbeat",e=>new C_(e),"PRIVATE")),me(Po,Cl,n),me(Po,Cl,"esm2020"),me("fire-js","")}V_("");var O_="firebase",L_="12.8.0";me(O_,L_,"app");const $h="@firebase/installations",fa="0.6.19";const jh=1e4,zh=`w:${fa}`,Hh="FIS_v2",M_="https://firebaseinstallations.googleapis.com/v1",x_=3600*1e3,F_="installations",U_="Installations";const B_={"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."},hn=new Kt(F_,U_,B_);function Gh(n){return n instanceof $e&&n.code.includes("request-failed")}function Kh({projectId:n}){return`${M_}/projects/${n}/installations`}function Wh(n){return{token:n.token,requestStatus:2,expiresIn:$_(n.expiresIn),creationTime:Date.now()}}async function Qh(n,e){const r=(await e.json()).error;return hn.create("request-failed",{requestName:n,serverCode:r.code,serverMessage:r.message,serverStatus:r.status})}function Jh({apiKey:n}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":n})}function q_(n,{refreshToken:e}){const t=Jh(n);return t.append("Authorization",j_(e)),t}async function Yh(n){const e=await n();return e.status>=500&&e.status<600?n():e}function $_(n){return Number(n.replace("s","000"))}function j_(n){return`${Hh} ${n}`}async function z_({appConfig:n,heartbeatServiceProvider:e},{fid:t}){const r=Kh(n),s=Jh(n),i=e.getImmediate({optional:!0});if(i){const h=await i.getHeartbeatsHeader();h&&s.append("x-firebase-client",h)}const a={fid:t,authVersion:Hh,appId:n.appId,sdkVersion:zh},c={method:"POST",headers:s,body:JSON.stringify(a)},u=await Yh(()=>fetch(r,c));if(u.ok){const h=await u.json();return{fid:h.fid||t,registrationStatus:2,refreshToken:h.refreshToken,authToken:Wh(h.authToken)}}else throw await Qh("Create Installation",u)}function Xh(n){return new Promise(e=>{setTimeout(e,n)})}function H_(n){return btoa(String.fromCharCode(...n)).replace(/\+/g,"-").replace(/\//g,"_")}const G_=/^[cdef][\w-]{21}$/,No="";function K_(){try{const n=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(n),n[0]=112+n[0]%16;const t=W_(n);return G_.test(t)?t:No}catch{return No}}function W_(n){return H_(n).substr(0,22)}function li(n){return`${n.appName}!${n.appId}`}const Zh=new Map;function ed(n,e){const t=li(n);td(t,e),Q_(t,e)}function td(n,e){const t=Zh.get(n);if(t)for(const r of t)r(e)}function Q_(n,e){const t=J_();t&&t.postMessage({key:n,fid:e}),Y_()}let rn=null;function J_(){return!rn&&"BroadcastChannel"in self&&(rn=new BroadcastChannel("[Firebase] FID Change"),rn.onmessage=n=>{td(n.data.key,n.data.fid)}),rn}function Y_(){Zh.size===0&&rn&&(rn.close(),rn=null)}const X_="firebase-installations-database",Z_=1,dn="firebase-installations-store";let co=null;function pa(){return co||(co=ci(X_,Z_,{upgrade:(n,e)=>{e===0&&n.createObjectStore(dn)}})),co}async function Ps(n,e){const t=li(n),s=(await pa()).transaction(dn,"readwrite"),i=s.objectStore(dn),a=await i.get(t);return await i.put(e,t),await s.done,(!a||a.fid!==e.fid)&&ed(n,e.fid),e}async function nd(n){const e=li(n),r=(await pa()).transaction(dn,"readwrite");await r.objectStore(dn).delete(e),await r.done}async function ui(n,e){const t=li(n),s=(await pa()).transaction(dn,"readwrite"),i=s.objectStore(dn),a=await i.get(t),c=e(a);return c===void 0?await i.delete(t):await i.put(c,t),await s.done,c&&(!a||a.fid!==c.fid)&&ed(n,c.fid),c}async function ma(n){let e;const t=await ui(n.appConfig,r=>{const s=ey(r),i=ty(n,s);return e=i.registrationPromise,i.installationEntry});return t.fid===No?{installationEntry:await e}:{installationEntry:t,registrationPromise:e}}function ey(n){const e=n||{fid:K_(),registrationStatus:0};return rd(e)}function ty(n,e){if(e.registrationStatus===0){if(!navigator.onLine){const s=Promise.reject(hn.create("app-offline"));return{installationEntry:e,registrationPromise:s}}const t={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},r=ny(n,t);return{installationEntry:t,registrationPromise:r}}else return e.registrationStatus===1?{installationEntry:e,registrationPromise:ry(n)}:{installationEntry:e}}async function ny(n,e){try{const t=await z_(n,e);return Ps(n.appConfig,t)}catch(t){throw Gh(t)&&t.customData.serverCode===409?await nd(n.appConfig):await Ps(n.appConfig,{fid:e.fid,registrationStatus:0}),t}}async function ry(n){let e=await Ol(n.appConfig);for(;e.registrationStatus===1;)await Xh(100),e=await Ol(n.appConfig);if(e.registrationStatus===0){const{installationEntry:t,registrationPromise:r}=await ma(n);return r||t}return e}function Ol(n){return ui(n,e=>{if(!e)throw hn.create("installation-not-found");return rd(e)})}function rd(n){return sy(n)?{fid:n.fid,registrationStatus:0}:n}function sy(n){return n.registrationStatus===1&&n.registrationTime+jh<Date.now()}async function iy({appConfig:n,heartbeatServiceProvider:e},t){const r=oy(n,t),s=q_(n,t),i=e.getImmediate({optional:!0});if(i){const h=await i.getHeartbeatsHeader();h&&s.append("x-firebase-client",h)}const a={installation:{sdkVersion:zh,appId:n.appId}},c={method:"POST",headers:s,body:JSON.stringify(a)},u=await Yh(()=>fetch(r,c));if(u.ok){const h=await u.json();return Wh(h)}else throw await Qh("Generate Auth Token",u)}function oy(n,{fid:e}){return`${Kh(n)}/${e}/authTokens:generate`}async function ga(n,e=!1){let t;const r=await ui(n.appConfig,i=>{if(!sd(i))throw hn.create("not-registered");const a=i.authToken;if(!e&&ly(a))return i;if(a.requestStatus===1)return t=ay(n,e),i;{if(!navigator.onLine)throw hn.create("app-offline");const c=hy(i);return t=cy(n,c),c}});return t?await t:r.authToken}async function ay(n,e){let t=await Ll(n.appConfig);for(;t.authToken.requestStatus===1;)await Xh(100),t=await Ll(n.appConfig);const r=t.authToken;return r.requestStatus===0?ga(n,e):r}function Ll(n){return ui(n,e=>{if(!sd(e))throw hn.create("not-registered");const t=e.authToken;return dy(t)?{...e,authToken:{requestStatus:0}}:e})}async function cy(n,e){try{const t=await iy(n,e),r={...e,authToken:t};return await Ps(n.appConfig,r),t}catch(t){if(Gh(t)&&(t.customData.serverCode===401||t.customData.serverCode===404))await nd(n.appConfig);else{const r={...e,authToken:{requestStatus:0}};await Ps(n.appConfig,r)}throw t}}function sd(n){return n!==void 0&&n.registrationStatus===2}function ly(n){return n.requestStatus===2&&!uy(n)}function uy(n){const e=Date.now();return e<n.creationTime||n.creationTime+n.expiresIn<e+x_}function hy(n){const e={requestStatus:1,requestTime:Date.now()};return{...n,authToken:e}}function dy(n){return n.requestStatus===1&&n.requestTime+jh<Date.now()}async function fy(n){const e=n,{installationEntry:t,registrationPromise:r}=await ma(e);return r?r.catch(console.error):ga(e).catch(console.error),t.fid}async function py(n,e=!1){const t=n;return await my(t),(await ga(t,e)).token}async function my(n){const{registrationPromise:e}=await ma(n);e&&await e}function gy(n){if(!n||!n.options)throw lo("App Configuration");if(!n.name)throw lo("App Name");const e=["projectId","apiKey","appId"];for(const t of e)if(!n.options[t])throw lo(t);return{appName:n.name,projectId:n.options.projectId,apiKey:n.options.apiKey,appId:n.options.appId}}function lo(n){return hn.create("missing-app-config-values",{valueName:n})}const id="installations",_y="installations-internal",yy=n=>{const e=n.getProvider("app").getImmediate(),t=gy(e),r=ut(e,"heartbeat");return{app:e,appConfig:t,heartbeatServiceProvider:r,_delete:()=>Promise.resolve()}},Ty=n=>{const e=n.getProvider("app").getImmediate(),t=ut(e,id).getImmediate();return{getId:()=>fy(t),getToken:s=>py(t,s)}};function wy(){Me(new Ne(id,yy,"PUBLIC")),Me(new Ne(_y,Ty,"PRIVATE"))}wy();me($h,fa);me($h,fa,"esm2020");const Cs="analytics",Ey="firebase_id",vy="origin",Iy=60*1e3,Ay="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig",_a="https://www.googletagmanager.com/gtag/js";const ke=new ai("@firebase/analytics");const by={"already-exists":"A Firebase Analytics instance with the appId {$id} already exists. Only one Firebase Analytics instance can be created for each appId.","already-initialized":"initializeAnalytics() cannot be called again with different options than those it was initially called with. It can be called again with the same options to return the existing instance, or getAnalytics() can be used to get a reference to the already-initialized instance.","already-initialized-settings":"Firebase Analytics has already been initialized.settings() must be called before initializing any Analytics instanceor it will have no effect.","interop-component-reg-failed":"Firebase Analytics Interop Component failed to instantiate: {$reason}","invalid-analytics-context":"Firebase Analytics is not supported in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","indexeddb-unavailable":"IndexedDB unavailable or restricted in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","fetch-throttle":"The config fetch request timed out while in an exponential backoff state. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.","config-fetch-failed":"Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}","no-api-key":'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid API key.',"no-app-id":'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid app ID.',"no-client-id":'The "client_id" field is empty.',"invalid-gtag-resource":"Trusted Types detected an invalid gtag resource: {$gtagURL}."},Be=new Kt("analytics","Analytics",by);function Sy(n){if(!n.startsWith(_a)){const e=Be.create("invalid-gtag-resource",{gtagURL:n});return ke.warn(e.message),""}return n}function od(n){return Promise.all(n.map(e=>e.catch(t=>t)))}function Ry(n,e){let t;return window.trustedTypes&&(t=window.trustedTypes.createPolicy(n,e)),t}function Py(n,e){const t=Ry("firebase-js-sdk-policy",{createScriptURL:Sy}),r=document.createElement("script"),s=`${_a}?l=${n}&id=${e}`;r.src=t?t?.createScriptURL(s):s,r.async=!0,document.head.appendChild(r)}function Cy(n){let e=[];return Array.isArray(window[n])?e=window[n]:window[n]=e,e}async function ky(n,e,t,r,s,i){const a=r[s];try{if(a)await e[a];else{const u=(await od(t)).find(h=>h.measurementId===s);u&&await e[u.appId]}}catch(c){ke.error(c)}n("config",s,i)}async function Ny(n,e,t,r,s){try{let i=[];if(s&&s.send_to){let a=s.send_to;Array.isArray(a)||(a=[a]);const c=await od(t);for(const u of a){const h=c.find(m=>m.measurementId===u),f=h&&e[h.appId];if(f)i.push(f);else{i=[];break}}}i.length===0&&(i=Object.values(e)),await Promise.all(i),n("event",r,s||{})}catch(i){ke.error(i)}}function Dy(n,e,t,r){async function s(i,...a){try{if(i==="event"){const[c,u]=a;await Ny(n,e,t,c,u)}else if(i==="config"){const[c,u]=a;await ky(n,e,t,r,c,u)}else if(i==="consent"){const[c,u]=a;n("consent",c,u)}else if(i==="get"){const[c,u,h]=a;n("get",c,u,h)}else if(i==="set"){const[c]=a;n("set",c)}else n(i,...a)}catch(c){ke.error(c)}}return s}function Vy(n,e,t,r,s){let i=function(...a){window[r].push(arguments)};return window[s]&&typeof window[s]=="function"&&(i=window[s]),window[s]=Dy(i,n,e,t),{gtagCore:i,wrappedGtag:window[s]}}function Oy(n){const e=window.document.getElementsByTagName("script");for(const t of Object.values(e))if(t.src&&t.src.includes(_a)&&t.src.includes(n))return t;return null}const Ly=30,My=1e3;class xy{constructor(e={},t=My){this.throttleMetadata=e,this.intervalMillis=t}getThrottleMetadata(e){return this.throttleMetadata[e]}setThrottleMetadata(e,t){this.throttleMetadata[e]=t}deleteThrottleMetadata(e){delete this.throttleMetadata[e]}}const ad=new xy;function Fy(n){return new Headers({Accept:"application/json","x-goog-api-key":n})}async function Uy(n){const{appId:e,apiKey:t}=n,r={method:"GET",headers:Fy(t)},s=Ay.replace("{app-id}",e),i=await fetch(s,r);if(i.status!==200&&i.status!==304){let a="";try{const c=await i.json();c.error?.message&&(a=c.error.message)}catch{}throw Be.create("config-fetch-failed",{httpStatus:i.status,responseMessage:a})}return i.json()}async function By(n,e=ad,t){const{appId:r,apiKey:s,measurementId:i}=n.options;if(!r)throw Be.create("no-app-id");if(!s){if(i)return{measurementId:i,appId:r};throw Be.create("no-api-key")}const a=e.getThrottleMetadata(r)||{backoffCount:0,throttleEndTimeMillis:Date.now()},c=new jy;return setTimeout(async()=>{c.abort()},Iy),cd({appId:r,apiKey:s,measurementId:i},a,c,e)}async function cd(n,{throttleEndTimeMillis:e,backoffCount:t},r,s=ad){const{appId:i,measurementId:a}=n;try{await qy(r,e)}catch(c){if(a)return ke.warn(`Timed out fetching this Firebase app's measurement ID from the server. Falling back to the measurement ID ${a} provided in the "measurementId" field in the local Firebase config. [${c?.message}]`),{appId:i,measurementId:a};throw c}try{const c=await Uy(n);return s.deleteThrottleMetadata(i),c}catch(c){const u=c;if(!$y(u)){if(s.deleteThrottleMetadata(i),a)return ke.warn(`Failed to fetch this Firebase app's measurement ID from the server. Falling back to the measurement ID ${a} provided in the "measurementId" field in the local Firebase config. [${u?.message}]`),{appId:i,measurementId:a};throw c}const h=Number(u?.customData?.httpStatus)===503?bl(t,s.intervalMillis,Ly):bl(t,s.intervalMillis),f={throttleEndTimeMillis:Date.now()+h,backoffCount:t+1};return s.setThrottleMetadata(i,f),ke.debug(`Calling attemptFetch again in ${h} millis`),cd(n,f,r,s)}}function qy(n,e){return new Promise((t,r)=>{const s=Math.max(e-Date.now(),0),i=setTimeout(t,s);n.addEventListener(()=>{clearTimeout(i),r(Be.create("fetch-throttle",{throttleEndTimeMillis:e}))})})}function $y(n){if(!(n instanceof $e)||!n.customData)return!1;const e=Number(n.customData.httpStatus);return e===429||e===500||e===503||e===504}class jy{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}async function zy(n,e,t,r,s){if(s&&s.global){n("event",t,r);return}else{const i=await e,a={...r,send_to:i};n("event",t,a)}}async function Hy(n,e,t,r){if(r&&r.global){const s={};for(const i of Object.keys(t))s[`user_properties.${i}`]=t[i];return n("set",s),Promise.resolve()}else{const s=await e;n("config",s,{update:!0,user_properties:t})}}async function Gy(){if(ua())try{await ha()}catch(n){return ke.warn(Be.create("indexeddb-unavailable",{errorInfo:n?.toString()}).message),!1}else return ke.warn(Be.create("indexeddb-unavailable",{errorInfo:"IndexedDB is not available in this environment."}).message),!1;return!0}async function Ky(n,e,t,r,s,i,a){const c=By(n);c.then(y=>{t[y.measurementId]=y.appId,n.options.measurementId&&y.measurementId!==n.options.measurementId&&ke.warn(`The measurement ID in the local Firebase config (${n.options.measurementId}) does not match the measurement ID fetched from the server (${y.measurementId}). To ensure analytics events are always sent to the correct Analytics property, update the measurement ID field in the local config or remove it from the local config.`)}).catch(y=>ke.error(y)),e.push(c);const u=Gy().then(y=>{if(y)return r.getId()}),[h,f]=await Promise.all([c,u]);Oy(i)||Py(i,h.measurementId),s("js",new Date);const m=a?.config??{};return m[vy]="firebase",m.update=!0,f!=null&&(m[Ey]=f),s("config",h.measurementId,m),h.measurementId}class Wy{constructor(e){this.app=e}_delete(){return delete Pn[this.app.options.appId],Promise.resolve()}}let Pn={},Ml=[];const xl={};let uo="dataLayer",Qy="gtag",Fl,ya,Ul=!1;function Jy(){const n=[];if(Lh()&&n.push("This is a browser extension environment."),Mh()||n.push("Cookies are not available."),n.length>0){const e=n.map((r,s)=>`(${s+1}) ${r}`).join(" "),t=Be.create("invalid-analytics-context",{errorInfo:e});ke.warn(t.message)}}function Yy(n,e,t){Jy();const r=n.options.appId;if(!r)throw Be.create("no-app-id");if(!n.options.apiKey)if(n.options.measurementId)ke.warn(`The "apiKey" field is empty in the local Firebase config. This is needed to fetch the latest measurement ID for this Firebase app. Falling back to the measurement ID ${n.options.measurementId} provided in the "measurementId" field in the local Firebase config.`);else throw Be.create("no-api-key");if(Pn[r]!=null)throw Be.create("already-exists",{id:r});if(!Ul){Cy(uo);const{wrappedGtag:i,gtagCore:a}=Vy(Pn,Ml,xl,uo,Qy);ya=i,Fl=a,Ul=!0}return Pn[r]=Ky(n,Ml,xl,e,Fl,uo,t),new Wy(n)}function Xy(n=$n()){n=ee(n);const e=ut(n,Cs);return e.isInitialized()?e.getImmediate():Zy(n)}function Zy(n,e={}){const t=ut(n,Cs);if(t.isInitialized()){const s=t.getImmediate();if(Ut(e,t.getOptions()))return s;throw Be.create("already-initialized")}return t.initialize({options:e})}function eT(n,e,t){n=ee(n),Hy(ya,Pn[n.app.options.appId],e,t).catch(r=>ke.error(r))}function tT(n,e,t,r){n=ee(n),zy(ya,Pn[n.app.options.appId],e,t,r).catch(s=>ke.error(s))}const Bl="@firebase/analytics",ql="0.10.19";function nT(){Me(new Ne(Cs,(e,{options:t})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("installations-internal").getImmediate();return Yy(r,s,t)},"PUBLIC")),Me(new Ne("analytics-internal",n,"PRIVATE")),me(Bl,ql),me(Bl,ql,"esm2020");function n(e){try{const t=e.getProvider(Cs).getImmediate();return{logEvent:(r,s,i)=>tT(t,r,s,i),setUserProperties:(r,s)=>eT(t,r,s)}}catch(t){throw Be.create("interop-component-reg-failed",{reason:t})}}}nT();function ld(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}const rT=ld,ud=new Kt("auth","Firebase",ld());const ks=new ai("@firebase/auth");function sT(n,...e){ks.logLevel<=H.WARN&&ks.warn(`Auth (${yn}): ${n}`,...e)}function ms(n,...e){ks.logLevel<=H.ERROR&&ks.error(`Auth (${yn}): ${n}`,...e)}function at(n,...e){throw wa(n,...e)}function Qe(n,...e){return wa(n,...e)}function Ta(n,e,t){const r={...rT(),[e]:t};return new Kt("auth","Firebase",r).create(e,{appName:n.name})}function an(n){return Ta(n,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function iT(n,e,t){const r=t;if(!(e instanceof r))throw r.name!==e.constructor.name&&at(n,"argument-error"),Ta(n,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function wa(n,...e){if(typeof n!="string"){const t=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=n.name),n._errorFactory.create(t,...r)}return ud.create(n,...e)}function F(n,e,...t){if(!n)throw wa(e,...t)}function pt(n){const e="INTERNAL ASSERTION FAILED: "+n;throw ms(e),new Error(e)}function Tt(n,e){n||pt(e)}function Do(){return typeof self<"u"&&self.location?.href||""}function oT(){return $l()==="http:"||$l()==="https:"}function $l(){return typeof self<"u"&&self.location?.protocol||null}function aT(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(oT()||Lh()||"connection"in navigator)?navigator.onLine:!0}function cT(){if(typeof navigator>"u")return null;const n=navigator;return n.languages&&n.languages[0]||n.language||null}class xr{constructor(e,t){this.shortDelay=e,this.longDelay=t,Tt(t>e,"Short delay should be less than long delay!"),this.isMobile=ug()||fg()}get(){return aT()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}function Ea(n,e){Tt(n.emulator,"Emulator should always be set here");const{url:t}=n.emulator;return e?`${t}${e.startsWith("/")?e.slice(1):e}`:t}class hd{static initialize(e,t,r){this.fetchImpl=e,t&&(this.headersImpl=t),r&&(this.responseImpl=r)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;pt("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<"u"&&"Headers"in self)return self.Headers;if(typeof globalThis<"u"&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<"u")return Headers;pt("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;if(typeof globalThis<"u"&&globalThis.Response)return globalThis.Response;if(typeof Response<"u")return Response;pt("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}const lT={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"};const uT=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],hT=new xr(3e4,6e4);function va(n,e){return n.tenantId&&!e.tenantId?{...e,tenantId:n.tenantId}:e}async function jn(n,e,t,r,s={}){return dd(n,s,async()=>{let i={},a={};r&&(e==="GET"?a=r:i={body:JSON.stringify(r)});const c=Mr({key:n.config.apiKey,...a}).slice(1),u=await n._getAdditionalHeaders();u["Content-Type"]="application/json",n.languageCode&&(u["X-Firebase-Locale"]=n.languageCode);const h={method:e,headers:u,...i};return dg()||(h.referrerPolicy="no-referrer"),n.emulatorConfig&&vt(n.emulatorConfig.host)&&(h.credentials="include"),hd.fetch()(await fd(n,n.config.apiHost,t,c),h)})}async function dd(n,e,t){n._canInitEmulator=!1;const r={...lT,...e};try{const s=new fT(n),i=await Promise.race([t(),s.promise]);s.clearNetworkTimeout();const a=await i.json();if("needConfirmation"in a)throw cs(n,"account-exists-with-different-credential",a);if(i.ok&&!("errorMessage"in a))return a;{const c=i.ok?a.errorMessage:a.error.message,[u,h]=c.split(" : ");if(u==="FEDERATED_USER_ID_ALREADY_LINKED")throw cs(n,"credential-already-in-use",a);if(u==="EMAIL_EXISTS")throw cs(n,"email-already-in-use",a);if(u==="USER_DISABLED")throw cs(n,"user-disabled",a);const f=r[u]||u.toLowerCase().replace(/[_\s]+/g,"-");if(h)throw Ta(n,f,h);at(n,f)}}catch(s){if(s instanceof $e)throw s;at(n,"network-request-failed",{message:String(s)})}}async function dT(n,e,t,r,s={}){const i=await jn(n,e,t,r,s);return"mfaPendingCredential"in i&&at(n,"multi-factor-auth-required",{_serverResponse:i}),i}async function fd(n,e,t,r){const s=`${e}${t}?${r}`,i=n,a=i.config.emulator?Ea(n.config,s):`${n.config.apiScheme}://${s}`;return uT.includes(t)&&(await i._persistenceManagerAvailable,i._getPersistenceType()==="COOKIE")?i._getPersistence()._getFinalTarget(a).toString():a}class fT{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,r)=>{this.timer=setTimeout(()=>r(Qe(this.auth,"network-request-failed")),hT.get())})}}function cs(n,e,t){const r={appName:n.name};t.email&&(r.email=t.email),t.phoneNumber&&(r.phoneNumber=t.phoneNumber);const s=Qe(n,e,r);return s.customData._tokenResponse=t,s}async function pT(n,e){return jn(n,"POST","/v1/accounts:delete",e)}async function Ns(n,e){return jn(n,"POST","/v1/accounts:lookup",e)}function yr(n){if(n)try{const e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function mT(n,e=!1){const t=ee(n),r=await t.getIdToken(e),s=Ia(r);F(s&&s.exp&&s.auth_time&&s.iat,t.auth,"internal-error");const i=typeof s.firebase=="object"?s.firebase:void 0,a=i?.sign_in_provider;return{claims:s,token:r,authTime:yr(ho(s.auth_time)),issuedAtTime:yr(ho(s.iat)),expirationTime:yr(ho(s.exp)),signInProvider:a||null,signInSecondFactor:i?.sign_in_second_factor||null}}function ho(n){return Number(n)*1e3}function Ia(n){const[e,t,r]=n.split(".");if(e===void 0||t===void 0||r===void 0)return ms("JWT malformed, contained fewer than 3 sections"),null;try{const s=kh(t);return s?JSON.parse(s):(ms("Failed to decode base64 JWT payload"),null)}catch(s){return ms("Caught error parsing JWT payload as JSON",s?.toString()),null}}function jl(n){const e=Ia(n);return F(e,"internal-error"),F(typeof e.exp<"u","internal-error"),F(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}async function Sr(n,e,t=!1){if(t)return e;try{return await e}catch(r){throw r instanceof $e&&gT(r)&&n.auth.currentUser===n&&await n.auth.signOut(),r}}function gT({code:n}){return n==="auth/user-disabled"||n==="auth/user-token-expired"}class _T{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){if(e){const t=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),t}else{this.errorBackoff=3e4;const r=(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5;return Math.max(0,r)}}schedule(e=!1){if(!this.isRunning)return;const t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){e?.code==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}class Vo{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=yr(this.lastLoginAt),this.creationTime=yr(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function Ds(n){const e=n.auth,t=await n.getIdToken(),r=await Sr(n,Ns(e,{idToken:t}));F(r?.users.length,e,"internal-error");const s=r.users[0];n._notifyReloadListener(s);const i=s.providerUserInfo?.length?pd(s.providerUserInfo):[],a=TT(n.providerData,i),c=n.isAnonymous,u=!(n.email&&s.passwordHash)&&!a?.length,h=c?u:!1,f={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:a,metadata:new Vo(s.createdAt,s.lastLoginAt),isAnonymous:h};Object.assign(n,f)}async function yT(n){const e=ee(n);await Ds(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function TT(n,e){return[...n.filter(r=>!e.some(s=>s.providerId===r.providerId)),...e]}function pd(n){return n.map(({providerId:e,...t})=>({providerId:e,uid:t.rawId||"",displayName:t.displayName||null,email:t.email||null,phoneNumber:t.phoneNumber||null,photoURL:t.photoUrl||null}))}async function wT(n,e){const t=await dd(n,{},async()=>{const r=Mr({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:s,apiKey:i}=n.config,a=await fd(n,s,"/v1/token",`key=${i}`),c=await n._getAdditionalHeaders();c["Content-Type"]="application/x-www-form-urlencoded";const u={method:"POST",headers:c,body:r};return n.emulatorConfig&&vt(n.emulatorConfig.host)&&(u.credentials="include"),hd.fetch()(a,u)});return{accessToken:t.access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token}}async function ET(n,e){return jn(n,"POST","/v2/accounts:revokeToken",va(n,e))}class Cn{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){F(e.idToken,"internal-error"),F(typeof e.idToken<"u","internal-error"),F(typeof e.refreshToken<"u","internal-error");const t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):jl(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){F(e.length!==0,"internal-error");const t=jl(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(F(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:r,refreshToken:s,expiresIn:i}=await wT(e,t);this.updateTokensAndExpiration(r,s,Number(i))}updateTokensAndExpiration(e,t,r){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+r*1e3}static fromJSON(e,t){const{refreshToken:r,accessToken:s,expirationTime:i}=t,a=new Cn;return r&&(F(typeof r=="string","internal-error",{appName:e}),a.refreshToken=r),s&&(F(typeof s=="string","internal-error",{appName:e}),a.accessToken=s),i&&(F(typeof i=="number","internal-error",{appName:e}),a.expirationTime=i),a}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new Cn,this.toJSON())}_performRefresh(){return pt("not implemented")}}function kt(n,e){F(typeof n=="string"||typeof n>"u","internal-error",{appName:e})}class Ke{constructor({uid:e,auth:t,stsTokenManager:r,...s}){this.providerId="firebase",this.proactiveRefresh=new _T(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=t,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=s.displayName||null,this.email=s.email||null,this.emailVerified=s.emailVerified||!1,this.phoneNumber=s.phoneNumber||null,this.photoURL=s.photoURL||null,this.isAnonymous=s.isAnonymous||!1,this.tenantId=s.tenantId||null,this.providerData=s.providerData?[...s.providerData]:[],this.metadata=new Vo(s.createdAt||void 0,s.lastLoginAt||void 0)}async getIdToken(e){const t=await Sr(this,this.stsTokenManager.getToken(this.auth,e));return F(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return mT(this,e)}reload(){return yT(this)}_assign(e){this!==e&&(F(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(t=>({...t})),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new Ke({...this,auth:e,stsTokenManager:this.stsTokenManager._clone()});return t.metadata._copy(this.metadata),t}_onReload(e){F(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),t&&await Ds(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(Fe(this.auth.app))return Promise.reject(an(this.auth));const e=await this.getIdToken();return await Sr(this,pT(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return{uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>({...e})),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId,...this.metadata.toJSON(),apiKey:this.auth.config.apiKey,appName:this.auth.name}}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){const r=t.displayName??void 0,s=t.email??void 0,i=t.phoneNumber??void 0,a=t.photoURL??void 0,c=t.tenantId??void 0,u=t._redirectEventId??void 0,h=t.createdAt??void 0,f=t.lastLoginAt??void 0,{uid:m,emailVerified:y,isAnonymous:S,providerData:k,stsTokenManager:V}=t;F(m&&V,e,"internal-error");const N=Cn.fromJSON(this.name,V);F(typeof m=="string",e,"internal-error"),kt(r,e.name),kt(s,e.name),F(typeof y=="boolean",e,"internal-error"),F(typeof S=="boolean",e,"internal-error"),kt(i,e.name),kt(a,e.name),kt(c,e.name),kt(u,e.name),kt(h,e.name),kt(f,e.name);const $=new Ke({uid:m,auth:e,email:s,emailVerified:y,displayName:r,isAnonymous:S,photoURL:a,phoneNumber:i,tenantId:c,stsTokenManager:N,createdAt:h,lastLoginAt:f});return k&&Array.isArray(k)&&($.providerData=k.map(W=>({...W}))),u&&($._redirectEventId=u),$}static async _fromIdTokenResponse(e,t,r=!1){const s=new Cn;s.updateFromServerResponse(t);const i=new Ke({uid:t.localId,auth:e,stsTokenManager:s,isAnonymous:r});return await Ds(i),i}static async _fromGetAccountInfoResponse(e,t,r){const s=t.users[0];F(s.localId!==void 0,"internal-error");const i=s.providerUserInfo!==void 0?pd(s.providerUserInfo):[],a=!(s.email&&s.passwordHash)&&!i?.length,c=new Cn;c.updateFromIdToken(r);const u=new Ke({uid:s.localId,auth:e,stsTokenManager:c,isAnonymous:a}),h={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:i,metadata:new Vo(s.createdAt,s.lastLoginAt),isAnonymous:!(s.email&&s.passwordHash)&&!i?.length};return Object.assign(u,h),u}}const zl=new Map;function mt(n){Tt(n instanceof Function,"Expected a class definition");let e=zl.get(n);return e?(Tt(e instanceof n,"Instance stored in cache mismatched with class"),e):(e=new n,zl.set(n,e),e)}class md{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){const t=this.storage[e];return t===void 0?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}md.type="NONE";const Hl=md;function gs(n,e,t){return`firebase:${n}:${e}:${t}`}class kn{constructor(e,t,r){this.persistence=e,this.auth=t,this.userKey=r;const{config:s,name:i}=this.auth;this.fullUserKey=gs(this.userKey,s.apiKey,i),this.fullPersistenceKey=gs("persistence",s.apiKey,i),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);if(!e)return null;if(typeof e=="string"){const t=await Ns(this.auth,{idToken:e}).catch(()=>{});return t?Ke._fromGetAccountInfoResponse(this.auth,t,e):null}return Ke._fromJSON(this.auth,e)}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const t=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,t)return this.setCurrentUser(t)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,r="authUser"){if(!t.length)return new kn(mt(Hl),e,r);const s=(await Promise.all(t.map(async h=>{if(await h._isAvailable())return h}))).filter(h=>h);let i=s[0]||mt(Hl);const a=gs(r,e.config.apiKey,e.name);let c=null;for(const h of t)try{const f=await h._get(a);if(f){let m;if(typeof f=="string"){const y=await Ns(e,{idToken:f}).catch(()=>{});if(!y)break;m=await Ke._fromGetAccountInfoResponse(e,y,f)}else m=Ke._fromJSON(e,f);h!==i&&(c=m),i=h;break}}catch{}const u=s.filter(h=>h._shouldAllowMigration);return!i._shouldAllowMigration||!u.length?new kn(i,e,r):(i=u[0],c&&await i._set(a,c.toJSON()),await Promise.all(t.map(async h=>{if(h!==i)try{await h._remove(a)}catch{}})),new kn(i,e,r))}}function Gl(n){const e=n.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(Td(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(gd(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(Ed(e))return"Blackberry";if(vd(e))return"Webos";if(_d(e))return"Safari";if((e.includes("chrome/")||yd(e))&&!e.includes("edge/"))return"Chrome";if(wd(e))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,r=n.match(t);if(r?.length===2)return r[1]}return"Other"}function gd(n=Se()){return/firefox\//i.test(n)}function _d(n=Se()){const e=n.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function yd(n=Se()){return/crios\//i.test(n)}function Td(n=Se()){return/iemobile/i.test(n)}function wd(n=Se()){return/android/i.test(n)}function Ed(n=Se()){return/blackberry/i.test(n)}function vd(n=Se()){return/webos/i.test(n)}function Aa(n=Se()){return/iphone|ipad|ipod/i.test(n)||/macintosh/i.test(n)&&/mobile/i.test(n)}function vT(n=Se()){return Aa(n)&&!!window.navigator?.standalone}function IT(){return pg()&&document.documentMode===10}function Id(n=Se()){return Aa(n)||wd(n)||vd(n)||Ed(n)||/windows phone/i.test(n)||Td(n)}function Ad(n,e=[]){let t;switch(n){case"Browser":t=Gl(Se());break;case"Worker":t=`${Gl(Se())}-${n}`;break;default:t=n}const r=e.length?e.join(","):"FirebaseCore-web";return`${t}/JsCore/${yn}/${r}`}class AT{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const r=i=>new Promise((a,c)=>{try{const u=e(i);a(u)}catch(u){c(u)}});r.onAbort=t,this.queue.push(r);const s=this.queue.length-1;return()=>{this.queue[s]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const r of this.queue)await r(e),r.onAbort&&t.push(r.onAbort)}catch(r){t.reverse();for(const s of t)try{s()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:r?.message})}}}async function bT(n,e={}){return jn(n,"GET","/v2/passwordPolicy",va(n,e))}const ST=6;class RT{constructor(e){const t=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=t.minPasswordLength??ST,t.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=t.maxPasswordLength),t.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=t.containsLowercaseCharacter),t.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=t.containsUppercaseCharacter),t.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=t.containsNumericCharacter),t.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=t.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=e.allowedNonAlphanumericCharacters?.join("")??"",this.forceUpgradeOnSignin=e.forceUpgradeOnSignin??!1,this.schemaVersion=e.schemaVersion}validatePassword(e){const t={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,t),this.validatePasswordCharacterOptions(e,t),t.isValid&&(t.isValid=t.meetsMinPasswordLength??!0),t.isValid&&(t.isValid=t.meetsMaxPasswordLength??!0),t.isValid&&(t.isValid=t.containsLowercaseLetter??!0),t.isValid&&(t.isValid=t.containsUppercaseLetter??!0),t.isValid&&(t.isValid=t.containsNumericCharacter??!0),t.isValid&&(t.isValid=t.containsNonAlphanumericCharacter??!0),t}validatePasswordLengthOptions(e,t){const r=this.customStrengthOptions.minPasswordLength,s=this.customStrengthOptions.maxPasswordLength;r&&(t.meetsMinPasswordLength=e.length>=r),s&&(t.meetsMaxPasswordLength=e.length<=s)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let r;for(let s=0;s<e.length;s++)r=e.charAt(s),this.updatePasswordCharacterOptionsStatuses(t,r>="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(e,t,r,s,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=s)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=i))}}class PT{constructor(e,t,r,s){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=r,this.config=s,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new Kl(this),this.idTokenSubscription=new Kl(this),this.beforeStateQueue=new AT(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=ud,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=s.sdkClientVersion,this._persistenceManagerAvailable=new Promise(i=>this._resolvePersistenceManagerAvailable=i)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=mt(t)),this._initializationPromise=this.queue(async()=>{if(!this._deleted&&(this.persistenceManager=await kn.create(this,e),this._resolvePersistenceManagerAvailable?.(),!this._deleted)){if(this._popupRedirectResolver?._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(t),this.lastNotifiedUid=this.currentUser?.uid||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{const t=await Ns(this,{idToken:e}),r=await Ke._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(r)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){if(Fe(this.app)){const i=this.app.settings.authIdToken;return i?new Promise(a=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(i).then(a,a))}):this.directlySetCurrentUser(null)}const t=await this.assertedPersistence.getCurrentUser();let r=t,s=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const i=this.redirectUser?._redirectEventId,a=r?._redirectEventId,c=await this.tryRedirectSignIn(e);(!i||i===a)&&c?.user&&(r=c.user,s=!0)}if(!r)return this.directlySetCurrentUser(null);if(!r._redirectEventId){if(s)try{await this.beforeStateQueue.runMiddleware(r)}catch(i){r=t,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(i))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return F(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await Ds(e)}catch(t){if(t?.code!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=cT()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(Fe(this.app))return Promise.reject(an(this));const t=e?ee(e):null;return t&&F(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&F(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return Fe(this.app)?Promise.reject(an(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return Fe(this.app)?Promise.reject(an(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(mt(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await bT(this),t=new RT(e);this.tenantId===null?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new Kt("auth","Firebase",e())}onAuthStateChanged(e,t,r){return this.registerStateListener(this.authStateSubscription,e,t,r)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,r){return this.registerStateListener(this.idTokenSubscription,e,t,r)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{const r=this.onAuthStateChanged(()=>{r(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t=await this.currentUser.getIdToken(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t};this.tenantId!=null&&(r.tenantId=this.tenantId),await ET(this,r)}}toJSON(){return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:this._currentUser?.toJSON()}}async _setRedirectUser(e,t){const r=await this.getOrInitRedirectPersistenceManager(t);return e===null?r.removeCurrentUser():r.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&mt(e)||this._popupRedirectResolver;F(t,this,"argument-error"),this.redirectPersistenceManager=await kn.create(this,[mt(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){return this._isInitialized&&await this.queue(async()=>{}),this._currentUser?._redirectEventId===e?this._currentUser:this.redirectUser?._redirectEventId===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const e=this.currentUser?.uid??null;this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,r,s){if(this._deleted)return()=>{};const i=typeof t=="function"?t:t.next.bind(t);let a=!1;const c=this._isInitialized?Promise.resolve():this._initializationPromise;if(F(c,this,"internal-error"),c.then(()=>{a||i(this.currentUser)}),typeof t=="function"){const u=e.addObserver(t,r,s);return()=>{a=!0,u()}}else{const u=e.addObserver(t);return()=>{a=!0,u()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return F(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=Ad(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){const e={"X-Client-Version":this.clientVersion};this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId);const t=await this.heartbeatServiceProvider.getImmediate({optional:!0})?.getHeartbeatsHeader();t&&(e["X-Firebase-Client"]=t);const r=await this._getAppCheckToken();return r&&(e["X-Firebase-AppCheck"]=r),e}async _getAppCheckToken(){if(Fe(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=await this.appCheckServiceProvider.getImmediate({optional:!0})?.getToken();return e?.error&&sT(`Error while retrieving App Check token: ${e.error}`),e?.token}}function hi(n){return ee(n)}class Kl{constructor(e){this.auth=e,this.observer=null,this.addObserver=wg(t=>this.observer=t)}get next(){return F(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let ba={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function CT(n){ba=n}function kT(n){return ba.loadJS(n)}function NT(){return ba.gapiScript}function DT(n){return`__${n}${Math.floor(Math.random()*1e6)}`}function VT(n,e){const t=ut(n,"auth");if(t.isInitialized()){const s=t.getImmediate(),i=t.getOptions();if(Ut(i,e??{}))return s;at(s,"already-initialized")}return t.initialize({options:e})}function OT(n,e){const t=e?.persistence||[],r=(Array.isArray(t)?t:[t]).map(mt);e?.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(r,e?.popupRedirectResolver)}function bd(n,e,t){const r=hi(n);F(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const s=!1,i=Sd(e),{host:a,port:c}=LT(e),u=c===null?"":`:${c}`,h={url:`${i}//${a}${u}/`},f=Object.freeze({host:a,port:c,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:s})});if(!r._canInitEmulator){F(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),F(Ut(h,r.config.emulator)&&Ut(f,r.emulatorConfig),r,"emulator-config-failed");return}r.config.emulator=h,r.emulatorConfig=f,r.settings.appVerificationDisabledForTesting=!0,vt(a)?(ii(`${i}//${a}${u}`),oi("Auth",!0)):MT()}function Sd(n){const e=n.indexOf(":");return e<0?"":n.substr(0,e+1)}function LT(n){const e=Sd(n),t=/(\/\/)?([^?#/]+)/.exec(n.substr(e.length));if(!t)return{host:"",port:null};const r=t[2].split("@").pop()||"",s=/^(\[[^\]]+\])(:|$)/.exec(r);if(s){const i=s[1];return{host:i,port:Wl(r.substr(i.length+1))}}else{const[i,a]=r.split(":");return{host:i,port:Wl(a)}}}function Wl(n){if(!n)return null;const e=Number(n);return isNaN(e)?null:e}function MT(){function n(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}typeof console<"u"&&typeof console.info=="function"&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",n):n())}class Rd{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return pt("not implemented")}_getIdTokenResponse(e){return pt("not implemented")}_linkToIdToken(e,t){return pt("not implemented")}_getReauthenticationResolver(e){return pt("not implemented")}}async function Nn(n,e){return dT(n,"POST","/v1/accounts:signInWithIdp",va(n,e))}const xT="http://localhost";class fn extends Rd{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new fn(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):at("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e,{providerId:r,signInMethod:s,...i}=t;if(!r||!s)return null;const a=new fn(r,s);return a.idToken=i.idToken||void 0,a.accessToken=i.accessToken||void 0,a.secret=i.secret,a.nonce=i.nonce,a.pendingToken=i.pendingToken||null,a}_getIdTokenResponse(e){const t=this.buildRequest();return Nn(e,t)}_linkToIdToken(e,t){const r=this.buildRequest();return r.idToken=t,Nn(e,r)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,Nn(e,t)}buildRequest(){const e={requestUri:xT,returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=Mr(t)}return e}}class Sa{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}class Fr extends Sa{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class Dt extends Fr{constructor(){super("facebook.com")}static credential(e){return fn._fromParams({providerId:Dt.PROVIDER_ID,signInMethod:Dt.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Dt.credentialFromTaggedObject(e)}static credentialFromError(e){return Dt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Dt.credential(e.oauthAccessToken)}catch{return null}}}Dt.FACEBOOK_SIGN_IN_METHOD="facebook.com";Dt.PROVIDER_ID="facebook.com";class ft extends Fr{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return fn._fromParams({providerId:ft.PROVIDER_ID,signInMethod:ft.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return ft.credentialFromTaggedObject(e)}static credentialFromError(e){return ft.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:r}=e;if(!t&&!r)return null;try{return ft.credential(t,r)}catch{return null}}}ft.GOOGLE_SIGN_IN_METHOD="google.com";ft.PROVIDER_ID="google.com";class Vt extends Fr{constructor(){super("github.com")}static credential(e){return fn._fromParams({providerId:Vt.PROVIDER_ID,signInMethod:Vt.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Vt.credentialFromTaggedObject(e)}static credentialFromError(e){return Vt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Vt.credential(e.oauthAccessToken)}catch{return null}}}Vt.GITHUB_SIGN_IN_METHOD="github.com";Vt.PROVIDER_ID="github.com";class Ot extends Fr{constructor(){super("twitter.com")}static credential(e,t){return fn._fromParams({providerId:Ot.PROVIDER_ID,signInMethod:Ot.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return Ot.credentialFromTaggedObject(e)}static credentialFromError(e){return Ot.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:r}=e;if(!t||!r)return null;try{return Ot.credential(t,r)}catch{return null}}}Ot.TWITTER_SIGN_IN_METHOD="twitter.com";Ot.PROVIDER_ID="twitter.com";class On{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,r,s=!1){const i=await Ke._fromIdTokenResponse(e,r,s),a=Ql(r);return new On({user:i,providerId:a,_tokenResponse:r,operationType:t})}static async _forOperation(e,t,r){await e._updateTokensIfNecessary(r,!0);const s=Ql(r);return new On({user:e,providerId:s,_tokenResponse:r,operationType:t})}}function Ql(n){return n.providerId?n.providerId:"phoneNumber"in n?"phone":null}class Vs extends $e{constructor(e,t,r,s){super(t.code,t.message),this.operationType=r,this.user=s,Object.setPrototypeOf(this,Vs.prototype),this.customData={appName:e.name,tenantId:e.tenantId??void 0,_serverResponse:t.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,t,r,s){return new Vs(e,t,r,s)}}function Pd(n,e,t,r){return(e==="reauthenticate"?t._getReauthenticationResolver(n):t._getIdTokenResponse(n)).catch(i=>{throw i.code==="auth/multi-factor-auth-required"?Vs._fromErrorAndOperation(n,i,e,r):i})}async function FT(n,e,t=!1){const r=await Sr(n,e._linkToIdToken(n.auth,await n.getIdToken()),t);return On._forOperation(n,"link",r)}async function UT(n,e,t=!1){const{auth:r}=n;if(Fe(r.app))return Promise.reject(an(r));const s="reauthenticate";try{const i=await Sr(n,Pd(r,s,e,n),t);F(i.idToken,r,"internal-error");const a=Ia(i.idToken);F(a,r,"internal-error");const{sub:c}=a;return F(n.uid===c,r,"user-mismatch"),On._forOperation(n,s,i)}catch(i){throw i?.code==="auth/user-not-found"&&at(r,"user-mismatch"),i}}async function BT(n,e,t=!1){if(Fe(n.app))return Promise.reject(an(n));const r="signIn",s=await Pd(n,r,e),i=await On._fromIdTokenResponse(n,r,s);return t||await n._updateCurrentUser(i.user),i}function qT(n,e,t,r){return ee(n).onIdTokenChanged(e,t,r)}function $T(n,e,t){return ee(n).beforeAuthStateChanged(e,t)}const Os="__sak";class Cd{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Os,"1"),this.storage.removeItem(Os),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){const t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}const jT=1e3,zT=10;class kd extends Cd{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=Id(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const r=this.storage.getItem(t),s=this.localCache[t];r!==s&&e(t,s,r)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((a,c,u)=>{this.notifyListeners(a,u)});return}const r=e.key;t?this.detachListener():this.stopPolling();const s=()=>{const a=this.storage.getItem(r);!t&&this.localCache[r]===a||this.notifyListeners(r,a)},i=this.storage.getItem(r);IT()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(s,zT):s()}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,r)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:r}),!0)})},jT)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Object.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){const t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}kd.type="LOCAL";const HT=kd;class Nd extends Cd{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Nd.type="SESSION";const Dd=Nd;function GT(n){return Promise.all(n.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(t){return{fulfilled:!1,reason:t}}}))}class di{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find(s=>s.isListeningto(e));if(t)return t;const r=new di(e);return this.receivers.push(r),r}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:r,eventType:s,data:i}=t.data,a=this.handlersMap[s];if(!a?.size)return;t.ports[0].postMessage({status:"ack",eventId:r,eventType:s});const c=Array.from(a).map(async h=>h(t.origin,i)),u=await GT(c);t.ports[0].postMessage({status:"done",eventId:r,eventType:s,response:u})}_subscribe(e,t){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),(!t||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}di.receivers=[];function Ra(n="",e=10){let t="";for(let r=0;r<e;r++)t+=Math.floor(Math.random()*10);return n+t}class KT{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,r=50){const s=typeof MessageChannel<"u"?new MessageChannel:null;if(!s)throw new Error("connection_unavailable");let i,a;return new Promise((c,u)=>{const h=Ra("",20);s.port1.start();const f=setTimeout(()=>{u(new Error("unsupported_event"))},r);a={messageChannel:s,onMessage(m){const y=m;if(y.data.eventId===h)switch(y.data.status){case"ack":clearTimeout(f),i=setTimeout(()=>{u(new Error("timeout"))},3e3);break;case"done":clearTimeout(i),c(y.data.response);break;default:clearTimeout(f),clearTimeout(i),u(new Error("invalid_response"));break}}},this.handlers.add(a),s.port1.addEventListener("message",a.onMessage),this.target.postMessage({eventType:e,eventId:h,data:t},[s.port2])}).finally(()=>{a&&this.removeMessageHandler(a)})}}function rt(){return window}function WT(n){rt().location.href=n}function Vd(){return typeof rt().WorkerGlobalScope<"u"&&typeof rt().importScripts=="function"}async function QT(){if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function JT(){return navigator?.serviceWorker?.controller||null}function YT(){return Vd()?self:null}const Od="firebaseLocalStorageDb",XT=1,Ls="firebaseLocalStorage",Ld="fbase_key";class Ur{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{t(this.request.error)})})}}function fi(n,e){return n.transaction([Ls],e?"readwrite":"readonly").objectStore(Ls)}function ZT(){const n=indexedDB.deleteDatabase(Od);return new Ur(n).toPromise()}function Oo(){const n=indexedDB.open(Od,XT);return new Promise((e,t)=>{n.addEventListener("error",()=>{t(n.error)}),n.addEventListener("upgradeneeded",()=>{const r=n.result;try{r.createObjectStore(Ls,{keyPath:Ld})}catch(s){t(s)}}),n.addEventListener("success",async()=>{const r=n.result;r.objectStoreNames.contains(Ls)?e(r):(r.close(),await ZT(),e(await Oo()))})})}async function Jl(n,e,t){const r=fi(n,!0).put({[Ld]:e,value:t});return new Ur(r).toPromise()}async function ew(n,e){const t=fi(n,!1).get(e),r=await new Ur(t).toPromise();return r===void 0?null:r.value}function Yl(n,e){const t=fi(n,!0).delete(e);return new Ur(t).toPromise()}const tw=800,nw=3;class Md{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db?this.db:(this.db=await Oo(),this.db)}async _withRetries(e){let t=0;for(;;)try{const r=await this._openDb();return await e(r)}catch(r){if(t++>nw)throw r;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Vd()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=di._getInstance(YT()),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){if(this.activeServiceWorker=await QT(),!this.activeServiceWorker)return;this.sender=new KT(this.activeServiceWorker);const e=await this.sender._send("ping",{},800);e&&e[0]?.fulfilled&&e[0]?.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||JT()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await Oo();return await Jl(e,Os,"1"),await Yl(e,Os),!0}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(r=>Jl(r,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(r=>ew(r,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>Yl(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(s=>{const i=fi(s,!1).getAll();return new Ur(i).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const t=[],r=new Set;if(e.length!==0)for(const{fbase_key:s,value:i}of e)r.add(s),JSON.stringify(this.localCache[s])!==JSON.stringify(i)&&(this.notifyListeners(s,i),t.push(s));for(const s of Object.keys(this.localCache))this.localCache[s]&&!r.has(s)&&(this.notifyListeners(s,null),t.push(s));return t}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),tw)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Object.keys(this.listeners).length===0&&this.stopPolling()}}Md.type="LOCAL";const rw=Md;new xr(3e4,6e4);function xd(n,e){return e?mt(e):(F(n._popupRedirectResolver,n,"argument-error"),n._popupRedirectResolver)}class Pa extends Rd{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return Nn(e,this._buildIdpRequest())}_linkToIdToken(e,t){return Nn(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return Nn(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function sw(n){return BT(n.auth,new Pa(n),n.bypassAuthState)}function iw(n){const{auth:e,user:t}=n;return F(t,e,"internal-error"),UT(t,new Pa(n),n.bypassAuthState)}async function ow(n){const{auth:e,user:t}=n;return F(t,e,"internal-error"),FT(t,new Pa(n),n.bypassAuthState)}class Fd{constructor(e,t,r,s,i=!1){this.auth=e,this.resolver=r,this.user=s,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(r){this.reject(r)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:r,postBody:s,tenantId:i,error:a,type:c}=e;if(a){this.reject(a);return}const u={auth:this.auth,requestUri:t,sessionId:r,tenantId:i||void 0,postBody:s||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(c)(u))}catch(h){this.reject(h)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return sw;case"linkViaPopup":case"linkViaRedirect":return ow;case"reauthViaPopup":case"reauthViaRedirect":return iw;default:at(this.auth,"internal-error")}}resolve(e){Tt(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){Tt(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}const aw=new xr(2e3,1e4);async function cw(n,e,t){if(Fe(n.app))return Promise.reject(Qe(n,"operation-not-supported-in-this-environment"));const r=hi(n);iT(n,e,Sa);const s=xd(r,t);return new sn(r,"signInViaPopup",e,s).executeNotNull()}class sn extends Fd{constructor(e,t,r,s,i){super(e,t,s,i),this.provider=r,this.authWindow=null,this.pollId=null,sn.currentPopupAction&&sn.currentPopupAction.cancel(),sn.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return F(e,this.auth,"internal-error"),e}async onExecution(){Tt(this.filter.length===1,"Popup operations only handle one event");const e=Ra();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(t=>{this.reject(t)}),this.resolver._isIframeWebStorageSupported(this.auth,t=>{t||this.reject(Qe(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(Qe(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,sn.currentPopupAction=null}pollUserCancellation(){const e=()=>{if(this.authWindow?.window?.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Qe(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,aw.get())};e()}}sn.currentPopupAction=null;const lw="pendingRedirect",_s=new Map;class uw extends Fd{constructor(e,t,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,r),this.eventId=null}async execute(){let e=_s.get(this.auth._key());if(!e){try{const r=await hw(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(r)}catch(t){e=()=>Promise.reject(t)}_s.set(this.auth._key(),e)}return this.bypassAuthState||_s.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if(e.type==="signInViaRedirect")return super.onAuthEvent(e);if(e.type==="unknown"){this.resolve(null);return}if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function hw(n,e){const t=pw(e),r=fw(n);if(!await r._isAvailable())return!1;const s=await r._get(t)==="true";return await r._remove(t),s}function dw(n,e){_s.set(n._key(),e)}function fw(n){return mt(n._redirectPersistence)}function pw(n){return gs(lw,n.config.apiKey,n.name)}async function mw(n,e,t=!1){if(Fe(n.app))return Promise.reject(an(n));const r=hi(n),s=xd(r,e),a=await new uw(r,s,t).execute();return a&&!t&&(delete a.user._redirectEventId,await r._persistUserIfCurrent(a.user),await r._setRedirectUser(null,e)),a}const gw=600*1e3;class _w{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(r=>{this.isEventForConsumer(e,r)&&(t=!0,this.sendToConsumer(e,r),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!yw(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){if(e.error&&!Ud(e)){const r=e.error.code?.split("auth/")[1]||"internal-error";t.onError(Qe(this.auth,r))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const r=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&r}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=gw&&this.cachedEventUids.clear(),this.cachedEventUids.has(Xl(e))}saveEventToCache(e){this.cachedEventUids.add(Xl(e)),this.lastProcessedEventTime=Date.now()}}function Xl(n){return[n.type,n.eventId,n.sessionId,n.tenantId].filter(e=>e).join("-")}function Ud({type:n,error:e}){return n==="unknown"&&e?.code==="auth/no-auth-event"}function yw(n){switch(n.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return Ud(n);default:return!1}}async function Tw(n,e={}){return jn(n,"GET","/v1/projects",e)}const ww=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,Ew=/^https?/;async function vw(n){if(n.config.emulator)return;const{authorizedDomains:e}=await Tw(n);for(const t of e)try{if(Iw(t))return}catch{}at(n,"unauthorized-domain")}function Iw(n){const e=Do(),{protocol:t,hostname:r}=new URL(e);if(n.startsWith("chrome-extension://")){const a=new URL(n);return a.hostname===""&&r===""?t==="chrome-extension:"&&n.replace("chrome-extension://","")===e.replace("chrome-extension://",""):t==="chrome-extension:"&&a.hostname===r}if(!Ew.test(t))return!1;if(ww.test(n))return r===n;const s=n.replace(/\./g,"\\.");return new RegExp("^(.+\\."+s+"|"+s+")$","i").test(r)}const Aw=new xr(3e4,6e4);function Zl(){const n=rt().___jsl;if(n?.H){for(const e of Object.keys(n.H))if(n.H[e].r=n.H[e].r||[],n.H[e].L=n.H[e].L||[],n.H[e].r=[...n.H[e].L],n.CP)for(let t=0;t<n.CP.length;t++)n.CP[t]=null}}function bw(n){return new Promise((e,t)=>{function r(){Zl(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{Zl(),t(Qe(n,"network-request-failed"))},timeout:Aw.get()})}if(rt().gapi?.iframes?.Iframe)e(gapi.iframes.getContext());else if(rt().gapi?.load)r();else{const s=DT("iframefcb");return rt()[s]=()=>{gapi.load?r():t(Qe(n,"network-request-failed"))},kT(`${NT()}?onload=${s}`).catch(i=>t(i))}}).catch(e=>{throw ys=null,e})}let ys=null;function Sw(n){return ys=ys||bw(n),ys}const Rw=new xr(5e3,15e3),Pw="__/auth/iframe",Cw="emulator/auth/iframe",kw={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},Nw=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function Dw(n){const e=n.config;F(e.authDomain,n,"auth-domain-config-required");const t=e.emulator?Ea(e,Cw):`https://${n.config.authDomain}/${Pw}`,r={apiKey:e.apiKey,appName:n.name,v:yn},s=Nw.get(n.config.apiHost);s&&(r.eid=s);const i=n._getFrameworks();return i.length&&(r.fw=i.join(",")),`${t}?${Mr(r).slice(1)}`}async function Vw(n){const e=await Sw(n),t=rt().gapi;return F(t,n,"internal-error"),e.open({where:document.body,url:Dw(n),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:kw,dontclear:!0},r=>new Promise(async(s,i)=>{await r.restyle({setHideOnLeave:!1});const a=Qe(n,"network-request-failed"),c=rt().setTimeout(()=>{i(a)},Rw.get());function u(){rt().clearTimeout(c),s(r)}r.ping(u).then(u,()=>{i(a)})}))}const Ow={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},Lw=500,Mw=600,xw="_blank",Fw="http://localhost";class eu{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function Uw(n,e,t,r=Lw,s=Mw){const i=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWidth-r)/2,0).toString();let c="";const u={...Ow,width:r.toString(),height:s.toString(),top:i,left:a},h=Se().toLowerCase();t&&(c=yd(h)?xw:t),gd(h)&&(e=e||Fw,u.scrollbars="yes");const f=Object.entries(u).reduce((y,[S,k])=>`${y}${S}=${k},`,"");if(vT(h)&&c!=="_self")return Bw(e||"",c),new eu(null);const m=window.open(e||"",c,f);F(m,n,"popup-blocked");try{m.focus()}catch{}return new eu(m)}function Bw(n,e){const t=document.createElement("a");t.href=n,t.target=e;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(r)}const qw="__/auth/handler",$w="emulator/auth/handler",jw=encodeURIComponent("fac");async function tu(n,e,t,r,s,i){F(n.config.authDomain,n,"auth-domain-config-required"),F(n.config.apiKey,n,"invalid-api-key");const a={apiKey:n.config.apiKey,appName:n.name,authType:t,redirectUrl:r,v:yn,eventId:s};if(e instanceof Sa){e.setDefaultLanguage(n.languageCode),a.providerId=e.providerId||"",Tg(e.getCustomParameters())||(a.customParameters=JSON.stringify(e.getCustomParameters()));for(const[f,m]of Object.entries({}))a[f]=m}if(e instanceof Fr){const f=e.getScopes().filter(m=>m!=="");f.length>0&&(a.scopes=f.join(","))}n.tenantId&&(a.tid=n.tenantId);const c=a;for(const f of Object.keys(c))c[f]===void 0&&delete c[f];const u=await n._getAppCheckToken(),h=u?`#${jw}=${encodeURIComponent(u)}`:"";return`${zw(n)}?${Mr(c).slice(1)}${h}`}function zw({config:n}){return n.emulator?Ea(n,$w):`https://${n.authDomain}/${qw}`}const fo="webStorageSupport";class Hw{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Dd,this._completeRedirectFn=mw,this._overrideRedirectResult=dw}async _openPopup(e,t,r,s){Tt(this.eventManagers[e._key()]?.manager,"_initialize() not called before _openPopup()");const i=await tu(e,t,r,Do(),s);return Uw(e,i,Ra())}async _openRedirect(e,t,r,s){await this._originValidation(e);const i=await tu(e,t,r,Do(),s);return WT(i),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:s,promise:i}=this.eventManagers[t];return s?Promise.resolve(s):(Tt(i,"If manager is not set, promise should be"),i)}const r=this.initAndGetManager(e);return this.eventManagers[t]={promise:r},r.catch(()=>{delete this.eventManagers[t]}),r}async initAndGetManager(e){const t=await Vw(e),r=new _w(e);return t.register("authEvent",s=>(F(s?.authEvent,e,"invalid-auth-event"),{status:r.onEvent(s.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:r},this.iframes[e._key()]=t,r}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(fo,{type:fo},s=>{const i=s?.[0]?.[fo];i!==void 0&&t(!!i),at(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=vw(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return Id()||_d()||Aa()}}const Gw=Hw;var nu="@firebase/auth",ru="1.12.0";class Kw{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){return this.assertAuthConfigured(),this.auth.currentUser?.uid||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(r=>{e(r?.stsTokenManager.accessToken||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){F(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}function Ww(n){switch(n){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function Qw(n){Me(new Ne("auth",(e,{options:t})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("heartbeat"),i=e.getProvider("app-check-internal"),{apiKey:a,authDomain:c}=r.options;F(a&&!a.includes(":"),"invalid-api-key",{appName:r.name});const u={apiKey:a,authDomain:c,clientPlatform:n,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:Ad(n)},h=new PT(r,s,i,u);return OT(h,t),h},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,r)=>{e.getProvider("auth-internal").initialize()})),Me(new Ne("auth-internal",e=>{const t=hi(e.getProvider("auth").getImmediate());return(r=>new Kw(r))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),me(nu,ru,Ww(n)),me(nu,ru,"esm2020")}const Jw=300,Yw=Vh("authIdTokenMaxAge")||Jw;let su=null;const Xw=n=>async e=>{const t=e&&await e.getIdTokenResult(),r=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(r&&r>Yw)return;const s=t?.token;su!==s&&(su=s,await fetch(n,{method:s?"POST":"DELETE",headers:s?{Authorization:`Bearer ${s}`}:{}}))};function Zw(n=$n()){const e=ut(n,"auth");if(e.isInitialized())return e.getImmediate();const t=VT(n,{popupRedirectResolver:Gw,persistence:[rw,HT,Dd]}),r=Vh("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const i=new URL(r,location.origin);if(location.origin===i.origin){const a=Xw(i.toString());$T(t,a,()=>a(t.currentUser)),qT(t,c=>a(c))}}const s=Nh("auth");return s&&bd(t,`http://${s}`),t}function eE(){return document.getElementsByTagName("head")?.[0]??document}CT({loadJS(n){return new Promise((e,t)=>{const r=document.createElement("script");r.setAttribute("src",n),r.onload=e,r.onerror=s=>{const i=Qe("internal-error");i.customData=s,t(i)},r.type="text/javascript",r.charset="UTF-8",eE().appendChild(r)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});Qw("Browser");var iu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var xt,Bd;(function(){var n;function e(v,g){function w(){}w.prototype=g.prototype,v.F=g.prototype,v.prototype=new w,v.prototype.constructor=v,v.D=function(I,E,b){for(var T=Array(arguments.length-2),De=2;De<arguments.length;De++)T[De-2]=arguments[De];return g.prototype[E].apply(I,T)}}function t(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.C=Array(this.blockSize),this.o=this.h=0,this.u()}e(r,t),r.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function s(v,g,w){w||(w=0);const I=Array(16);if(typeof g=="string")for(var E=0;E<16;++E)I[E]=g.charCodeAt(w++)|g.charCodeAt(w++)<<8|g.charCodeAt(w++)<<16|g.charCodeAt(w++)<<24;else for(E=0;E<16;++E)I[E]=g[w++]|g[w++]<<8|g[w++]<<16|g[w++]<<24;g=v.g[0],w=v.g[1],E=v.g[2];let b=v.g[3],T;T=g+(b^w&(E^b))+I[0]+3614090360&4294967295,g=w+(T<<7&4294967295|T>>>25),T=b+(E^g&(w^E))+I[1]+3905402710&4294967295,b=g+(T<<12&4294967295|T>>>20),T=E+(w^b&(g^w))+I[2]+606105819&4294967295,E=b+(T<<17&4294967295|T>>>15),T=w+(g^E&(b^g))+I[3]+3250441966&4294967295,w=E+(T<<22&4294967295|T>>>10),T=g+(b^w&(E^b))+I[4]+4118548399&4294967295,g=w+(T<<7&4294967295|T>>>25),T=b+(E^g&(w^E))+I[5]+1200080426&4294967295,b=g+(T<<12&4294967295|T>>>20),T=E+(w^b&(g^w))+I[6]+2821735955&4294967295,E=b+(T<<17&4294967295|T>>>15),T=w+(g^E&(b^g))+I[7]+4249261313&4294967295,w=E+(T<<22&4294967295|T>>>10),T=g+(b^w&(E^b))+I[8]+1770035416&4294967295,g=w+(T<<7&4294967295|T>>>25),T=b+(E^g&(w^E))+I[9]+2336552879&4294967295,b=g+(T<<12&4294967295|T>>>20),T=E+(w^b&(g^w))+I[10]+4294925233&4294967295,E=b+(T<<17&4294967295|T>>>15),T=w+(g^E&(b^g))+I[11]+2304563134&4294967295,w=E+(T<<22&4294967295|T>>>10),T=g+(b^w&(E^b))+I[12]+1804603682&4294967295,g=w+(T<<7&4294967295|T>>>25),T=b+(E^g&(w^E))+I[13]+4254626195&4294967295,b=g+(T<<12&4294967295|T>>>20),T=E+(w^b&(g^w))+I[14]+2792965006&4294967295,E=b+(T<<17&4294967295|T>>>15),T=w+(g^E&(b^g))+I[15]+1236535329&4294967295,w=E+(T<<22&4294967295|T>>>10),T=g+(E^b&(w^E))+I[1]+4129170786&4294967295,g=w+(T<<5&4294967295|T>>>27),T=b+(w^E&(g^w))+I[6]+3225465664&4294967295,b=g+(T<<9&4294967295|T>>>23),T=E+(g^w&(b^g))+I[11]+643717713&4294967295,E=b+(T<<14&4294967295|T>>>18),T=w+(b^g&(E^b))+I[0]+3921069994&4294967295,w=E+(T<<20&4294967295|T>>>12),T=g+(E^b&(w^E))+I[5]+3593408605&4294967295,g=w+(T<<5&4294967295|T>>>27),T=b+(w^E&(g^w))+I[10]+38016083&4294967295,b=g+(T<<9&4294967295|T>>>23),T=E+(g^w&(b^g))+I[15]+3634488961&4294967295,E=b+(T<<14&4294967295|T>>>18),T=w+(b^g&(E^b))+I[4]+3889429448&4294967295,w=E+(T<<20&4294967295|T>>>12),T=g+(E^b&(w^E))+I[9]+568446438&4294967295,g=w+(T<<5&4294967295|T>>>27),T=b+(w^E&(g^w))+I[14]+3275163606&4294967295,b=g+(T<<9&4294967295|T>>>23),T=E+(g^w&(b^g))+I[3]+4107603335&4294967295,E=b+(T<<14&4294967295|T>>>18),T=w+(b^g&(E^b))+I[8]+1163531501&4294967295,w=E+(T<<20&4294967295|T>>>12),T=g+(E^b&(w^E))+I[13]+2850285829&4294967295,g=w+(T<<5&4294967295|T>>>27),T=b+(w^E&(g^w))+I[2]+4243563512&4294967295,b=g+(T<<9&4294967295|T>>>23),T=E+(g^w&(b^g))+I[7]+1735328473&4294967295,E=b+(T<<14&4294967295|T>>>18),T=w+(b^g&(E^b))+I[12]+2368359562&4294967295,w=E+(T<<20&4294967295|T>>>12),T=g+(w^E^b)+I[5]+4294588738&4294967295,g=w+(T<<4&4294967295|T>>>28),T=b+(g^w^E)+I[8]+2272392833&4294967295,b=g+(T<<11&4294967295|T>>>21),T=E+(b^g^w)+I[11]+1839030562&4294967295,E=b+(T<<16&4294967295|T>>>16),T=w+(E^b^g)+I[14]+4259657740&4294967295,w=E+(T<<23&4294967295|T>>>9),T=g+(w^E^b)+I[1]+2763975236&4294967295,g=w+(T<<4&4294967295|T>>>28),T=b+(g^w^E)+I[4]+1272893353&4294967295,b=g+(T<<11&4294967295|T>>>21),T=E+(b^g^w)+I[7]+4139469664&4294967295,E=b+(T<<16&4294967295|T>>>16),T=w+(E^b^g)+I[10]+3200236656&4294967295,w=E+(T<<23&4294967295|T>>>9),T=g+(w^E^b)+I[13]+681279174&4294967295,g=w+(T<<4&4294967295|T>>>28),T=b+(g^w^E)+I[0]+3936430074&4294967295,b=g+(T<<11&4294967295|T>>>21),T=E+(b^g^w)+I[3]+3572445317&4294967295,E=b+(T<<16&4294967295|T>>>16),T=w+(E^b^g)+I[6]+76029189&4294967295,w=E+(T<<23&4294967295|T>>>9),T=g+(w^E^b)+I[9]+3654602809&4294967295,g=w+(T<<4&4294967295|T>>>28),T=b+(g^w^E)+I[12]+3873151461&4294967295,b=g+(T<<11&4294967295|T>>>21),T=E+(b^g^w)+I[15]+530742520&4294967295,E=b+(T<<16&4294967295|T>>>16),T=w+(E^b^g)+I[2]+3299628645&4294967295,w=E+(T<<23&4294967295|T>>>9),T=g+(E^(w|~b))+I[0]+4096336452&4294967295,g=w+(T<<6&4294967295|T>>>26),T=b+(w^(g|~E))+I[7]+1126891415&4294967295,b=g+(T<<10&4294967295|T>>>22),T=E+(g^(b|~w))+I[14]+2878612391&4294967295,E=b+(T<<15&4294967295|T>>>17),T=w+(b^(E|~g))+I[5]+4237533241&4294967295,w=E+(T<<21&4294967295|T>>>11),T=g+(E^(w|~b))+I[12]+1700485571&4294967295,g=w+(T<<6&4294967295|T>>>26),T=b+(w^(g|~E))+I[3]+2399980690&4294967295,b=g+(T<<10&4294967295|T>>>22),T=E+(g^(b|~w))+I[10]+4293915773&4294967295,E=b+(T<<15&4294967295|T>>>17),T=w+(b^(E|~g))+I[1]+2240044497&4294967295,w=E+(T<<21&4294967295|T>>>11),T=g+(E^(w|~b))+I[8]+1873313359&4294967295,g=w+(T<<6&4294967295|T>>>26),T=b+(w^(g|~E))+I[15]+4264355552&4294967295,b=g+(T<<10&4294967295|T>>>22),T=E+(g^(b|~w))+I[6]+2734768916&4294967295,E=b+(T<<15&4294967295|T>>>17),T=w+(b^(E|~g))+I[13]+1309151649&4294967295,w=E+(T<<21&4294967295|T>>>11),T=g+(E^(w|~b))+I[4]+4149444226&4294967295,g=w+(T<<6&4294967295|T>>>26),T=b+(w^(g|~E))+I[11]+3174756917&4294967295,b=g+(T<<10&4294967295|T>>>22),T=E+(g^(b|~w))+I[2]+718787259&4294967295,E=b+(T<<15&4294967295|T>>>17),T=w+(b^(E|~g))+I[9]+3951481745&4294967295,v.g[0]=v.g[0]+g&4294967295,v.g[1]=v.g[1]+(E+(T<<21&4294967295|T>>>11))&4294967295,v.g[2]=v.g[2]+E&4294967295,v.g[3]=v.g[3]+b&4294967295}r.prototype.v=function(v,g){g===void 0&&(g=v.length);const w=g-this.blockSize,I=this.C;let E=this.h,b=0;for(;b<g;){if(E==0)for(;b<=w;)s(this,v,b),b+=this.blockSize;if(typeof v=="string"){for(;b<g;)if(I[E++]=v.charCodeAt(b++),E==this.blockSize){s(this,I),E=0;break}}else for(;b<g;)if(I[E++]=v[b++],E==this.blockSize){s(this,I),E=0;break}}this.h=E,this.o+=g},r.prototype.A=function(){var v=Array((this.h<56?this.blockSize:this.blockSize*2)-this.h);v[0]=128;for(var g=1;g<v.length-8;++g)v[g]=0;g=this.o*8;for(var w=v.length-8;w<v.length;++w)v[w]=g&255,g/=256;for(this.v(v),v=Array(16),g=0,w=0;w<4;++w)for(let I=0;I<32;I+=8)v[g++]=this.g[w]>>>I&255;return v};function i(v,g){var w=c;return Object.prototype.hasOwnProperty.call(w,v)?w[v]:w[v]=g(v)}function a(v,g){this.h=g;const w=[];let I=!0;for(let E=v.length-1;E>=0;E--){const b=v[E]|0;I&&b==g||(w[E]=b,I=!1)}this.g=w}var c={};function u(v){return-128<=v&&v<128?i(v,function(g){return new a([g|0],g<0?-1:0)}):new a([v|0],v<0?-1:0)}function h(v){if(isNaN(v)||!isFinite(v))return m;if(v<0)return N(h(-v));const g=[];let w=1;for(let I=0;v>=w;I++)g[I]=v/w|0,w*=4294967296;return new a(g,0)}function f(v,g){if(v.length==0)throw Error("number format error: empty string");if(g=g||10,g<2||36<g)throw Error("radix out of range: "+g);if(v.charAt(0)=="-")return N(f(v.substring(1),g));if(v.indexOf("-")>=0)throw Error('number format error: interior "-" character');const w=h(Math.pow(g,8));let I=m;for(let b=0;b<v.length;b+=8){var E=Math.min(8,v.length-b);const T=parseInt(v.substring(b,b+E),g);E<8?(E=h(Math.pow(g,E)),I=I.j(E).add(h(T))):(I=I.j(w),I=I.add(h(T)))}return I}var m=u(0),y=u(1),S=u(16777216);n=a.prototype,n.m=function(){if(V(this))return-N(this).m();let v=0,g=1;for(let w=0;w<this.g.length;w++){const I=this.i(w);v+=(I>=0?I:4294967296+I)*g,g*=4294967296}return v},n.toString=function(v){if(v=v||10,v<2||36<v)throw Error("radix out of range: "+v);if(k(this))return"0";if(V(this))return"-"+N(this).toString(v);const g=h(Math.pow(v,6));var w=this;let I="";for(;;){const E=te(w,g).g;w=$(w,E.j(g));let b=((w.g.length>0?w.g[0]:w.h)>>>0).toString(v);if(w=E,k(w))return b+I;for(;b.length<6;)b="0"+b;I=b+I}},n.i=function(v){return v<0?0:v<this.g.length?this.g[v]:this.h};function k(v){if(v.h!=0)return!1;for(let g=0;g<v.g.length;g++)if(v.g[g]!=0)return!1;return!0}function V(v){return v.h==-1}n.l=function(v){return v=$(this,v),V(v)?-1:k(v)?0:1};function N(v){const g=v.g.length,w=[];for(let I=0;I<g;I++)w[I]=~v.g[I];return new a(w,~v.h).add(y)}n.abs=function(){return V(this)?N(this):this},n.add=function(v){const g=Math.max(this.g.length,v.g.length),w=[];let I=0;for(let E=0;E<=g;E++){let b=I+(this.i(E)&65535)+(v.i(E)&65535),T=(b>>>16)+(this.i(E)>>>16)+(v.i(E)>>>16);I=T>>>16,b&=65535,T&=65535,w[E]=T<<16|b}return new a(w,w[w.length-1]&-2147483648?-1:0)};function $(v,g){return v.add(N(g))}n.j=function(v){if(k(this)||k(v))return m;if(V(this))return V(v)?N(this).j(N(v)):N(N(this).j(v));if(V(v))return N(this.j(N(v)));if(this.l(S)<0&&v.l(S)<0)return h(this.m()*v.m());const g=this.g.length+v.g.length,w=[];for(var I=0;I<2*g;I++)w[I]=0;for(I=0;I<this.g.length;I++)for(let E=0;E<v.g.length;E++){const b=this.i(I)>>>16,T=this.i(I)&65535,De=v.i(E)>>>16,Jt=v.i(E)&65535;w[2*I+2*E]+=T*Jt,W(w,2*I+2*E),w[2*I+2*E+1]+=b*Jt,W(w,2*I+2*E+1),w[2*I+2*E+1]+=T*De,W(w,2*I+2*E+1),w[2*I+2*E+2]+=b*De,W(w,2*I+2*E+2)}for(v=0;v<g;v++)w[v]=w[2*v+1]<<16|w[2*v];for(v=g;v<2*g;v++)w[v]=0;return new a(w,0)};function W(v,g){for(;(v[g]&65535)!=v[g];)v[g+1]+=v[g]>>>16,v[g]&=65535,g++}function Q(v,g){this.g=v,this.h=g}function te(v,g){if(k(g))throw Error("division by zero");if(k(v))return new Q(m,m);if(V(v))return g=te(N(v),g),new Q(N(g.g),N(g.h));if(V(g))return g=te(v,N(g)),new Q(N(g.g),g.h);if(v.g.length>30){if(V(v)||V(g))throw Error("slowDivide_ only works with positive integers.");for(var w=y,I=g;I.l(v)<=0;)w=we(w),I=we(I);var E=oe(w,1),b=oe(I,1);for(I=oe(I,2),w=oe(w,2);!k(I);){var T=b.add(I);T.l(v)<=0&&(E=E.add(w),b=T),I=oe(I,1),w=oe(w,1)}return g=$(v,E.j(g)),new Q(E,g)}for(E=m;v.l(g)>=0;){for(w=Math.max(1,Math.floor(v.m()/g.m())),I=Math.ceil(Math.log(w)/Math.LN2),I=I<=48?1:Math.pow(2,I-48),b=h(w),T=b.j(g);V(T)||T.l(v)>0;)w-=I,b=h(w),T=b.j(g);k(b)&&(b=y),E=E.add(b),v=$(v,T)}return new Q(E,v)}n.B=function(v){return te(this,v).h},n.and=function(v){const g=Math.max(this.g.length,v.g.length),w=[];for(let I=0;I<g;I++)w[I]=this.i(I)&v.i(I);return new a(w,this.h&v.h)},n.or=function(v){const g=Math.max(this.g.length,v.g.length),w=[];for(let I=0;I<g;I++)w[I]=this.i(I)|v.i(I);return new a(w,this.h|v.h)},n.xor=function(v){const g=Math.max(this.g.length,v.g.length),w=[];for(let I=0;I<g;I++)w[I]=this.i(I)^v.i(I);return new a(w,this.h^v.h)};function we(v){const g=v.g.length+1,w=[];for(let I=0;I<g;I++)w[I]=v.i(I)<<1|v.i(I-1)>>>31;return new a(w,v.h)}function oe(v,g){const w=g>>5;g%=32;const I=v.g.length-w,E=[];for(let b=0;b<I;b++)E[b]=g>0?v.i(b+w)>>>g|v.i(b+w+1)<<32-g:v.i(b+w);return new a(E,v.h)}r.prototype.digest=r.prototype.A,r.prototype.reset=r.prototype.u,r.prototype.update=r.prototype.v,Bd=r,a.prototype.add=a.prototype.add,a.prototype.multiply=a.prototype.j,a.prototype.modulo=a.prototype.B,a.prototype.compare=a.prototype.l,a.prototype.toNumber=a.prototype.m,a.prototype.toString=a.prototype.toString,a.prototype.getBits=a.prototype.i,a.fromNumber=h,a.fromString=f,xt=a}).apply(typeof iu<"u"?iu:typeof self<"u"?self:typeof window<"u"?window:{});var ls=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var qd,dr,$d,Ts,Lo,jd,zd,Hd;(function(){var n,e=Object.defineProperty;function t(o){o=[typeof globalThis=="object"&&globalThis,o,typeof window=="object"&&window,typeof self=="object"&&self,typeof ls=="object"&&ls];for(var l=0;l<o.length;++l){var d=o[l];if(d&&d.Math==Math)return d}throw Error("Cannot find global object")}var r=t(this);function s(o,l){if(l)e:{var d=r;o=o.split(".");for(var p=0;p<o.length-1;p++){var A=o[p];if(!(A in d))break e;d=d[A]}o=o[o.length-1],p=d[o],l=l(p),l!=p&&l!=null&&e(d,o,{configurable:!0,writable:!0,value:l})}}s("Symbol.dispose",function(o){return o||Symbol("Symbol.dispose")}),s("Array.prototype.values",function(o){return o||function(){return this[Symbol.iterator]()}}),s("Object.entries",function(o){return o||function(l){var d=[],p;for(p in l)Object.prototype.hasOwnProperty.call(l,p)&&d.push([p,l[p]]);return d}});var i=i||{},a=this||self;function c(o){var l=typeof o;return l=="object"&&o!=null||l=="function"}function u(o,l,d){return o.call.apply(o.bind,arguments)}function h(o,l,d){return h=u,h.apply(null,arguments)}function f(o,l){var d=Array.prototype.slice.call(arguments,1);return function(){var p=d.slice();return p.push.apply(p,arguments),o.apply(this,p)}}function m(o,l){function d(){}d.prototype=l.prototype,o.Z=l.prototype,o.prototype=new d,o.prototype.constructor=o,o.Ob=function(p,A,R){for(var D=Array(arguments.length-2),j=2;j<arguments.length;j++)D[j-2]=arguments[j];return l.prototype[A].apply(p,D)}}var y=typeof AsyncContext<"u"&&typeof AsyncContext.Snapshot=="function"?o=>o&&AsyncContext.Snapshot.wrap(o):o=>o;function S(o){const l=o.length;if(l>0){const d=Array(l);for(let p=0;p<l;p++)d[p]=o[p];return d}return[]}function k(o,l){for(let p=1;p<arguments.length;p++){const A=arguments[p];var d=typeof A;if(d=d!="object"?d:A?Array.isArray(A)?"array":d:"null",d=="array"||d=="object"&&typeof A.length=="number"){d=o.length||0;const R=A.length||0;o.length=d+R;for(let D=0;D<R;D++)o[d+D]=A[D]}else o.push(A)}}class V{constructor(l,d){this.i=l,this.j=d,this.h=0,this.g=null}get(){let l;return this.h>0?(this.h--,l=this.g,this.g=l.next,l.next=null):l=this.i(),l}}function N(o){a.setTimeout(()=>{throw o},0)}function $(){var o=v;let l=null;return o.g&&(l=o.g,o.g=o.g.next,o.g||(o.h=null),l.next=null),l}class W{constructor(){this.h=this.g=null}add(l,d){const p=Q.get();p.set(l,d),this.h?this.h.next=p:this.g=p,this.h=p}}var Q=new V(()=>new te,o=>o.reset());class te{constructor(){this.next=this.g=this.h=null}set(l,d){this.h=l,this.g=d,this.next=null}reset(){this.next=this.g=this.h=null}}let we,oe=!1,v=new W,g=()=>{const o=Promise.resolve(void 0);we=()=>{o.then(w)}};function w(){for(var o;o=$();){try{o.h.call(o.g)}catch(d){N(d)}var l=Q;l.j(o),l.h<100&&(l.h++,o.next=l.g,l.g=o)}oe=!1}function I(){this.u=this.u,this.C=this.C}I.prototype.u=!1,I.prototype.dispose=function(){this.u||(this.u=!0,this.N())},I.prototype[Symbol.dispose]=function(){this.dispose()},I.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function E(o,l){this.type=o,this.g=this.target=l,this.defaultPrevented=!1}E.prototype.h=function(){this.defaultPrevented=!0};var b=(function(){if(!a.addEventListener||!Object.defineProperty)return!1;var o=!1,l=Object.defineProperty({},"passive",{get:function(){o=!0}});try{const d=()=>{};a.addEventListener("test",d,l),a.removeEventListener("test",d,l)}catch{}return o})();function T(o){return/^[\s\xa0]*$/.test(o)}function De(o,l){E.call(this,o?o.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,o&&this.init(o,l)}m(De,E),De.prototype.init=function(o,l){const d=this.type=o.type,p=o.changedTouches&&o.changedTouches.length?o.changedTouches[0]:null;this.target=o.target||o.srcElement,this.g=l,l=o.relatedTarget,l||(d=="mouseover"?l=o.fromElement:d=="mouseout"&&(l=o.toElement)),this.relatedTarget=l,p?(this.clientX=p.clientX!==void 0?p.clientX:p.pageX,this.clientY=p.clientY!==void 0?p.clientY:p.pageY,this.screenX=p.screenX||0,this.screenY=p.screenY||0):(this.clientX=o.clientX!==void 0?o.clientX:o.pageX,this.clientY=o.clientY!==void 0?o.clientY:o.pageY,this.screenX=o.screenX||0,this.screenY=o.screenY||0),this.button=o.button,this.key=o.key||"",this.ctrlKey=o.ctrlKey,this.altKey=o.altKey,this.shiftKey=o.shiftKey,this.metaKey=o.metaKey,this.pointerId=o.pointerId||0,this.pointerType=o.pointerType,this.state=o.state,this.i=o,o.defaultPrevented&&De.Z.h.call(this)},De.prototype.h=function(){De.Z.h.call(this);const o=this.i;o.preventDefault?o.preventDefault():o.returnValue=!1};var Jt="closure_listenable_"+(Math.random()*1e6|0),Fp=0;function Up(o,l,d,p,A){this.listener=o,this.proxy=null,this.src=l,this.type=d,this.capture=!!p,this.ha=A,this.key=++Fp,this.da=this.fa=!1}function Kr(o){o.da=!0,o.listener=null,o.proxy=null,o.src=null,o.ha=null}function Wr(o,l,d){for(const p in o)l.call(d,o[p],p,o)}function Bp(o,l){for(const d in o)l.call(void 0,o[d],d,o)}function vc(o){const l={};for(const d in o)l[d]=o[d];return l}const Ic="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function Ac(o,l){let d,p;for(let A=1;A<arguments.length;A++){p=arguments[A];for(d in p)o[d]=p[d];for(let R=0;R<Ic.length;R++)d=Ic[R],Object.prototype.hasOwnProperty.call(p,d)&&(o[d]=p[d])}}function Qr(o){this.src=o,this.g={},this.h=0}Qr.prototype.add=function(o,l,d,p,A){const R=o.toString();o=this.g[R],o||(o=this.g[R]=[],this.h++);const D=Vi(o,l,p,A);return D>-1?(l=o[D],d||(l.fa=!1)):(l=new Up(l,this.src,R,!!p,A),l.fa=d,o.push(l)),l};function Di(o,l){const d=l.type;if(d in o.g){var p=o.g[d],A=Array.prototype.indexOf.call(p,l,void 0),R;(R=A>=0)&&Array.prototype.splice.call(p,A,1),R&&(Kr(l),o.g[d].length==0&&(delete o.g[d],o.h--))}}function Vi(o,l,d,p){for(let A=0;A<o.length;++A){const R=o[A];if(!R.da&&R.listener==l&&R.capture==!!d&&R.ha==p)return A}return-1}var Oi="closure_lm_"+(Math.random()*1e6|0),Li={};function bc(o,l,d,p,A){if(Array.isArray(l)){for(let R=0;R<l.length;R++)bc(o,l[R],d,p,A);return null}return d=Pc(d),o&&o[Jt]?o.J(l,d,c(p)?!!p.capture:!1,A):qp(o,l,d,!1,p,A)}function qp(o,l,d,p,A,R){if(!l)throw Error("Invalid event type");const D=c(A)?!!A.capture:!!A;let j=xi(o);if(j||(o[Oi]=j=new Qr(o)),d=j.add(l,d,p,D,R),d.proxy)return d;if(p=$p(),d.proxy=p,p.src=o,p.listener=d,o.addEventListener)b||(A=D),A===void 0&&(A=!1),o.addEventListener(l.toString(),p,A);else if(o.attachEvent)o.attachEvent(Rc(l.toString()),p);else if(o.addListener&&o.removeListener)o.addListener(p);else throw Error("addEventListener and attachEvent are unavailable.");return d}function $p(){function o(d){return l.call(o.src,o.listener,d)}const l=jp;return o}function Sc(o,l,d,p,A){if(Array.isArray(l))for(var R=0;R<l.length;R++)Sc(o,l[R],d,p,A);else p=c(p)?!!p.capture:!!p,d=Pc(d),o&&o[Jt]?(o=o.i,R=String(l).toString(),R in o.g&&(l=o.g[R],d=Vi(l,d,p,A),d>-1&&(Kr(l[d]),Array.prototype.splice.call(l,d,1),l.length==0&&(delete o.g[R],o.h--)))):o&&(o=xi(o))&&(l=o.g[l.toString()],o=-1,l&&(o=Vi(l,d,p,A)),(d=o>-1?l[o]:null)&&Mi(d))}function Mi(o){if(typeof o!="number"&&o&&!o.da){var l=o.src;if(l&&l[Jt])Di(l.i,o);else{var d=o.type,p=o.proxy;l.removeEventListener?l.removeEventListener(d,p,o.capture):l.detachEvent?l.detachEvent(Rc(d),p):l.addListener&&l.removeListener&&l.removeListener(p),(d=xi(l))?(Di(d,o),d.h==0&&(d.src=null,l[Oi]=null)):Kr(o)}}}function Rc(o){return o in Li?Li[o]:Li[o]="on"+o}function jp(o,l){if(o.da)o=!0;else{l=new De(l,this);const d=o.listener,p=o.ha||o.src;o.fa&&Mi(o),o=d.call(p,l)}return o}function xi(o){return o=o[Oi],o instanceof Qr?o:null}var Fi="__closure_events_fn_"+(Math.random()*1e9>>>0);function Pc(o){return typeof o=="function"?o:(o[Fi]||(o[Fi]=function(l){return o.handleEvent(l)}),o[Fi])}function Ee(){I.call(this),this.i=new Qr(this),this.M=this,this.G=null}m(Ee,I),Ee.prototype[Jt]=!0,Ee.prototype.removeEventListener=function(o,l,d,p){Sc(this,o,l,d,p)};function Re(o,l){var d,p=o.G;if(p)for(d=[];p;p=p.G)d.push(p);if(o=o.M,p=l.type||l,typeof l=="string")l=new E(l,o);else if(l instanceof E)l.target=l.target||o;else{var A=l;l=new E(p,o),Ac(l,A)}A=!0;let R,D;if(d)for(D=d.length-1;D>=0;D--)R=l.g=d[D],A=Jr(R,p,!0,l)&&A;if(R=l.g=o,A=Jr(R,p,!0,l)&&A,A=Jr(R,p,!1,l)&&A,d)for(D=0;D<d.length;D++)R=l.g=d[D],A=Jr(R,p,!1,l)&&A}Ee.prototype.N=function(){if(Ee.Z.N.call(this),this.i){var o=this.i;for(const l in o.g){const d=o.g[l];for(let p=0;p<d.length;p++)Kr(d[p]);delete o.g[l],o.h--}}this.G=null},Ee.prototype.J=function(o,l,d,p){return this.i.add(String(o),l,!1,d,p)},Ee.prototype.K=function(o,l,d,p){return this.i.add(String(o),l,!0,d,p)};function Jr(o,l,d,p){if(l=o.i.g[String(l)],!l)return!0;l=l.concat();let A=!0;for(let R=0;R<l.length;++R){const D=l[R];if(D&&!D.da&&D.capture==d){const j=D.listener,he=D.ha||D.src;D.fa&&Di(o.i,D),A=j.call(he,p)!==!1&&A}}return A&&!p.defaultPrevented}function zp(o,l){if(typeof o!="function")if(o&&typeof o.handleEvent=="function")o=h(o.handleEvent,o);else throw Error("Invalid listener argument");return Number(l)>2147483647?-1:a.setTimeout(o,l||0)}function Cc(o){o.g=zp(()=>{o.g=null,o.i&&(o.i=!1,Cc(o))},o.l);const l=o.h;o.h=null,o.m.apply(null,l)}class Hp extends I{constructor(l,d){super(),this.m=l,this.l=d,this.h=null,this.i=!1,this.g=null}j(l){this.h=arguments,this.g?this.i=!0:Cc(this)}N(){super.N(),this.g&&(a.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function Qn(o){I.call(this),this.h=o,this.g={}}m(Qn,I);var kc=[];function Nc(o){Wr(o.g,function(l,d){this.g.hasOwnProperty(d)&&Mi(l)},o),o.g={}}Qn.prototype.N=function(){Qn.Z.N.call(this),Nc(this)},Qn.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Ui=a.JSON.stringify,Gp=a.JSON.parse,Kp=class{stringify(o){return a.JSON.stringify(o,void 0)}parse(o){return a.JSON.parse(o,void 0)}};function Dc(){}function Vc(){}var Jn={OPEN:"a",hb:"b",ERROR:"c",tb:"d"};function Bi(){E.call(this,"d")}m(Bi,E);function qi(){E.call(this,"c")}m(qi,E);var Yt={},Oc=null;function Yr(){return Oc=Oc||new Ee}Yt.Ia="serverreachability";function Lc(o){E.call(this,Yt.Ia,o)}m(Lc,E);function Yn(o){const l=Yr();Re(l,new Lc(l))}Yt.STAT_EVENT="statevent";function Mc(o,l){E.call(this,Yt.STAT_EVENT,o),this.stat=l}m(Mc,E);function Pe(o){const l=Yr();Re(l,new Mc(l,o))}Yt.Ja="timingevent";function xc(o,l){E.call(this,Yt.Ja,o),this.size=l}m(xc,E);function Xn(o,l){if(typeof o!="function")throw Error("Fn must not be null and must be a function");return a.setTimeout(function(){o()},l)}function Zn(){this.g=!0}Zn.prototype.ua=function(){this.g=!1};function Wp(o,l,d,p,A,R){o.info(function(){if(o.g)if(R){var D="",j=R.split("&");for(let X=0;X<j.length;X++){var he=j[X].split("=");if(he.length>1){const fe=he[0];he=he[1];const et=fe.split("_");D=et.length>=2&&et[1]=="type"?D+(fe+"="+he+"&"):D+(fe+"=redacted&")}}}else D=null;else D=R;return"XMLHTTP REQ ("+p+") [attempt "+A+"]: "+l+`
16
+ `+d+`
17
+ `+D})}function Qp(o,l,d,p,A,R,D){o.info(function(){return"XMLHTTP RESP ("+p+") [ attempt "+A+"]: "+l+`
18
+ `+d+`
19
+ `+R+" "+D})}function En(o,l,d,p){o.info(function(){return"XMLHTTP TEXT ("+l+"): "+Yp(o,d)+(p?" "+p:"")})}function Jp(o,l){o.info(function(){return"TIMEOUT: "+l})}Zn.prototype.info=function(){};function Yp(o,l){if(!o.g)return l;if(!l)return null;try{const R=JSON.parse(l);if(R){for(o=0;o<R.length;o++)if(Array.isArray(R[o])){var d=R[o];if(!(d.length<2)){var p=d[1];if(Array.isArray(p)&&!(p.length<1)){var A=p[0];if(A!="noop"&&A!="stop"&&A!="close")for(let D=1;D<p.length;D++)p[D]=""}}}}return Ui(R)}catch{return l}}var Xr={NO_ERROR:0,cb:1,qb:2,pb:3,kb:4,ob:5,rb:6,Ga:7,TIMEOUT:8,ub:9},Fc={ib:"complete",Fb:"success",ERROR:"error",Ga:"abort",xb:"ready",yb:"readystatechange",TIMEOUT:"timeout",sb:"incrementaldata",wb:"progress",lb:"downloadprogress",Nb:"uploadprogress"},Uc;function $i(){}m($i,Dc),$i.prototype.g=function(){return new XMLHttpRequest},Uc=new $i;function er(o){return encodeURIComponent(String(o))}function Xp(o){var l=1;o=o.split(":");const d=[];for(;l>0&&o.length;)d.push(o.shift()),l--;return o.length&&d.push(o.join(":")),d}function At(o,l,d,p){this.j=o,this.i=l,this.l=d,this.S=p||1,this.V=new Qn(this),this.H=45e3,this.J=null,this.o=!1,this.u=this.B=this.A=this.M=this.F=this.T=this.D=null,this.G=[],this.g=null,this.C=0,this.m=this.v=null,this.X=-1,this.K=!1,this.P=0,this.O=null,this.W=this.L=this.U=this.R=!1,this.h=new Bc}function Bc(){this.i=null,this.g="",this.h=!1}var qc={},ji={};function zi(o,l,d){o.M=1,o.A=es(Ze(l)),o.u=d,o.R=!0,$c(o,null)}function $c(o,l){o.F=Date.now(),Zr(o),o.B=Ze(o.A);var d=o.B,p=o.S;Array.isArray(p)||(p=[String(p)]),tl(d.i,"t",p),o.C=0,d=o.j.L,o.h=new Bc,o.g=Tl(o.j,d?l:null,!o.u),o.P>0&&(o.O=new Hp(h(o.Y,o,o.g),o.P)),l=o.V,d=o.g,p=o.ba;var A="readystatechange";Array.isArray(A)||(A&&(kc[0]=A.toString()),A=kc);for(let R=0;R<A.length;R++){const D=bc(d,A[R],p||l.handleEvent,!1,l.h||l);if(!D)break;l.g[D.key]=D}l=o.J?vc(o.J):{},o.u?(o.v||(o.v="POST"),l["Content-Type"]="application/x-www-form-urlencoded",o.g.ea(o.B,o.v,o.u,l)):(o.v="GET",o.g.ea(o.B,o.v,null,l)),Yn(),Wp(o.i,o.v,o.B,o.l,o.S,o.u)}At.prototype.ba=function(o){o=o.target;const l=this.O;l&&Rt(o)==3?l.j():this.Y(o)},At.prototype.Y=function(o){try{if(o==this.g)e:{const j=Rt(this.g),he=this.g.ya(),X=this.g.ca();if(!(j<3)&&(j!=3||this.g&&(this.h.h||this.g.la()||cl(this.g)))){this.K||j!=4||he==7||(he==8||X<=0?Yn(3):Yn(2)),Hi(this);var l=this.g.ca();this.X=l;var d=Zp(this);if(this.o=l==200,Qp(this.i,this.v,this.B,this.l,this.S,j,l),this.o){if(this.U&&!this.L){t:{if(this.g){var p,A=this.g;if((p=A.g?A.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!T(p)){var R=p;break t}}R=null}if(o=R)En(this.i,this.l,o,"Initial handshake response via X-HTTP-Initial-Response"),this.L=!0,Gi(this,o);else{this.o=!1,this.m=3,Pe(12),Xt(this),tr(this);break e}}if(this.R){o=!0;let fe;for(;!this.K&&this.C<d.length;)if(fe=em(this,d),fe==ji){j==4&&(this.m=4,Pe(14),o=!1),En(this.i,this.l,null,"[Incomplete Response]");break}else if(fe==qc){this.m=4,Pe(15),En(this.i,this.l,d,"[Invalid Chunk]"),o=!1;break}else En(this.i,this.l,fe,null),Gi(this,fe);if(jc(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),j!=4||d.length!=0||this.h.h||(this.m=1,Pe(16),o=!1),this.o=this.o&&o,!o)En(this.i,this.l,d,"[Invalid Chunked Response]"),Xt(this),tr(this);else if(d.length>0&&!this.W){this.W=!0;var D=this.j;D.g==this&&D.aa&&!D.P&&(D.j.info("Great, no buffering proxy detected. Bytes received: "+d.length),eo(D),D.P=!0,Pe(11))}}else En(this.i,this.l,d,null),Gi(this,d);j==4&&Xt(this),this.o&&!this.K&&(j==4?ml(this.j,this):(this.o=!1,Zr(this)))}else pm(this.g),l==400&&d.indexOf("Unknown SID")>0?(this.m=3,Pe(12)):(this.m=0,Pe(13)),Xt(this),tr(this)}}}catch{}};function Zp(o){if(!jc(o))return o.g.la();const l=cl(o.g);if(l==="")return"";let d="";const p=l.length,A=Rt(o.g)==4;if(!o.h.i){if(typeof TextDecoder>"u")return Xt(o),tr(o),"";o.h.i=new a.TextDecoder}for(let R=0;R<p;R++)o.h.h=!0,d+=o.h.i.decode(l[R],{stream:!(A&&R==p-1)});return l.length=0,o.h.g+=d,o.C=0,o.h.g}function jc(o){return o.g?o.v=="GET"&&o.M!=2&&o.j.Aa:!1}function em(o,l){var d=o.C,p=l.indexOf(`
20
+ `,d);return p==-1?ji:(d=Number(l.substring(d,p)),isNaN(d)?qc:(p+=1,p+d>l.length?ji:(l=l.slice(p,p+d),o.C=p+d,l)))}At.prototype.cancel=function(){this.K=!0,Xt(this)};function Zr(o){o.T=Date.now()+o.H,zc(o,o.H)}function zc(o,l){if(o.D!=null)throw Error("WatchDog timer not null");o.D=Xn(h(o.aa,o),l)}function Hi(o){o.D&&(a.clearTimeout(o.D),o.D=null)}At.prototype.aa=function(){this.D=null;const o=Date.now();o-this.T>=0?(Jp(this.i,this.B),this.M!=2&&(Yn(),Pe(17)),Xt(this),this.m=2,tr(this)):zc(this,this.T-o)};function tr(o){o.j.I==0||o.K||ml(o.j,o)}function Xt(o){Hi(o);var l=o.O;l&&typeof l.dispose=="function"&&l.dispose(),o.O=null,Nc(o.V),o.g&&(l=o.g,o.g=null,l.abort(),l.dispose())}function Gi(o,l){try{var d=o.j;if(d.I!=0&&(d.g==o||Ki(d.h,o))){if(!o.L&&Ki(d.h,o)&&d.I==3){try{var p=d.Ba.g.parse(l)}catch{p=null}if(Array.isArray(p)&&p.length==3){var A=p;if(A[0]==0){e:if(!d.v){if(d.g)if(d.g.F+3e3<o.F)is(d),rs(d);else break e;Zi(d),Pe(18)}}else d.xa=A[1],0<d.xa-d.K&&A[2]<37500&&d.F&&d.A==0&&!d.C&&(d.C=Xn(h(d.Va,d),6e3));Kc(d.h)<=1&&d.ta&&(d.ta=void 0)}else en(d,11)}else if((o.L||d.g==o)&&is(d),!T(l))for(A=d.Ba.g.parse(l),l=0;l<A.length;l++){let X=A[l];const fe=X[0];if(!(fe<=d.K))if(d.K=fe,X=X[1],d.I==2)if(X[0]=="c"){d.M=X[1],d.ba=X[2];const et=X[3];et!=null&&(d.ka=et,d.j.info("VER="+d.ka));const tn=X[4];tn!=null&&(d.za=tn,d.j.info("SVER="+d.za));const Pt=X[5];Pt!=null&&typeof Pt=="number"&&Pt>0&&(p=1.5*Pt,d.O=p,d.j.info("backChannelRequestTimeoutMs_="+p)),p=d;const Ct=o.g;if(Ct){const as=Ct.g?Ct.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(as){var R=p.h;R.g||as.indexOf("spdy")==-1&&as.indexOf("quic")==-1&&as.indexOf("h2")==-1||(R.j=R.l,R.g=new Set,R.h&&(Wi(R,R.h),R.h=null))}if(p.G){const to=Ct.g?Ct.g.getResponseHeader("X-HTTP-Session-Id"):null;to&&(p.wa=to,ne(p.J,p.G,to))}}d.I=3,d.l&&d.l.ra(),d.aa&&(d.T=Date.now()-o.F,d.j.info("Handshake RTT: "+d.T+"ms")),p=d;var D=o;if(p.na=yl(p,p.L?p.ba:null,p.W),D.L){Wc(p.h,D);var j=D,he=p.O;he&&(j.H=he),j.D&&(Hi(j),Zr(j)),p.g=D}else fl(p);d.i.length>0&&ss(d)}else X[0]!="stop"&&X[0]!="close"||en(d,7);else d.I==3&&(X[0]=="stop"||X[0]=="close"?X[0]=="stop"?en(d,7):Xi(d):X[0]!="noop"&&d.l&&d.l.qa(X),d.A=0)}}Yn(4)}catch{}}var tm=class{constructor(o,l){this.g=o,this.map=l}};function Hc(o){this.l=o||10,a.PerformanceNavigationTiming?(o=a.performance.getEntriesByType("navigation"),o=o.length>0&&(o[0].nextHopProtocol=="hq"||o[0].nextHopProtocol=="h2")):o=!!(a.chrome&&a.chrome.loadTimes&&a.chrome.loadTimes()&&a.chrome.loadTimes().wasFetchedViaSpdy),this.j=o?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function Gc(o){return o.h?!0:o.g?o.g.size>=o.j:!1}function Kc(o){return o.h?1:o.g?o.g.size:0}function Ki(o,l){return o.h?o.h==l:o.g?o.g.has(l):!1}function Wi(o,l){o.g?o.g.add(l):o.h=l}function Wc(o,l){o.h&&o.h==l?o.h=null:o.g&&o.g.has(l)&&o.g.delete(l)}Hc.prototype.cancel=function(){if(this.i=Qc(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const o of this.g.values())o.cancel();this.g.clear()}};function Qc(o){if(o.h!=null)return o.i.concat(o.h.G);if(o.g!=null&&o.g.size!==0){let l=o.i;for(const d of o.g.values())l=l.concat(d.G);return l}return S(o.i)}var Jc=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function nm(o,l){if(o){o=o.split("&");for(let d=0;d<o.length;d++){const p=o[d].indexOf("=");let A,R=null;p>=0?(A=o[d].substring(0,p),R=o[d].substring(p+1)):A=o[d],l(A,R?decodeURIComponent(R.replace(/\+/g," ")):"")}}}function bt(o){this.g=this.o=this.j="",this.u=null,this.m=this.h="",this.l=!1;let l;o instanceof bt?(this.l=o.l,nr(this,o.j),this.o=o.o,this.g=o.g,rr(this,o.u),this.h=o.h,Qi(this,nl(o.i)),this.m=o.m):o&&(l=String(o).match(Jc))?(this.l=!1,nr(this,l[1]||"",!0),this.o=sr(l[2]||""),this.g=sr(l[3]||"",!0),rr(this,l[4]),this.h=sr(l[5]||"",!0),Qi(this,l[6]||"",!0),this.m=sr(l[7]||"")):(this.l=!1,this.i=new or(null,this.l))}bt.prototype.toString=function(){const o=[];var l=this.j;l&&o.push(ir(l,Yc,!0),":");var d=this.g;return(d||l=="file")&&(o.push("//"),(l=this.o)&&o.push(ir(l,Yc,!0),"@"),o.push(er(d).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),d=this.u,d!=null&&o.push(":",String(d))),(d=this.h)&&(this.g&&d.charAt(0)!="/"&&o.push("/"),o.push(ir(d,d.charAt(0)=="/"?im:sm,!0))),(d=this.i.toString())&&o.push("?",d),(d=this.m)&&o.push("#",ir(d,am)),o.join("")},bt.prototype.resolve=function(o){const l=Ze(this);let d=!!o.j;d?nr(l,o.j):d=!!o.o,d?l.o=o.o:d=!!o.g,d?l.g=o.g:d=o.u!=null;var p=o.h;if(d)rr(l,o.u);else if(d=!!o.h){if(p.charAt(0)!="/")if(this.g&&!this.h)p="/"+p;else{var A=l.h.lastIndexOf("/");A!=-1&&(p=l.h.slice(0,A+1)+p)}if(A=p,A==".."||A==".")p="";else if(A.indexOf("./")!=-1||A.indexOf("/.")!=-1){p=A.lastIndexOf("/",0)==0,A=A.split("/");const R=[];for(let D=0;D<A.length;){const j=A[D++];j=="."?p&&D==A.length&&R.push(""):j==".."?((R.length>1||R.length==1&&R[0]!="")&&R.pop(),p&&D==A.length&&R.push("")):(R.push(j),p=!0)}p=R.join("/")}else p=A}return d?l.h=p:d=o.i.toString()!=="",d?Qi(l,nl(o.i)):d=!!o.m,d&&(l.m=o.m),l};function Ze(o){return new bt(o)}function nr(o,l,d){o.j=d?sr(l,!0):l,o.j&&(o.j=o.j.replace(/:$/,""))}function rr(o,l){if(l){if(l=Number(l),isNaN(l)||l<0)throw Error("Bad port number "+l);o.u=l}else o.u=null}function Qi(o,l,d){l instanceof or?(o.i=l,cm(o.i,o.l)):(d||(l=ir(l,om)),o.i=new or(l,o.l))}function ne(o,l,d){o.i.set(l,d)}function es(o){return ne(o,"zx",Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),o}function sr(o,l){return o?l?decodeURI(o.replace(/%25/g,"%2525")):decodeURIComponent(o):""}function ir(o,l,d){return typeof o=="string"?(o=encodeURI(o).replace(l,rm),d&&(o=o.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),o):null}function rm(o){return o=o.charCodeAt(0),"%"+(o>>4&15).toString(16)+(o&15).toString(16)}var Yc=/[#\/\?@]/g,sm=/[#\?:]/g,im=/[#\?]/g,om=/[#\?@]/g,am=/#/g;function or(o,l){this.h=this.g=null,this.i=o||null,this.j=!!l}function Zt(o){o.g||(o.g=new Map,o.h=0,o.i&&nm(o.i,function(l,d){o.add(decodeURIComponent(l.replace(/\+/g," ")),d)}))}n=or.prototype,n.add=function(o,l){Zt(this),this.i=null,o=vn(this,o);let d=this.g.get(o);return d||this.g.set(o,d=[]),d.push(l),this.h+=1,this};function Xc(o,l){Zt(o),l=vn(o,l),o.g.has(l)&&(o.i=null,o.h-=o.g.get(l).length,o.g.delete(l))}function Zc(o,l){return Zt(o),l=vn(o,l),o.g.has(l)}n.forEach=function(o,l){Zt(this),this.g.forEach(function(d,p){d.forEach(function(A){o.call(l,A,p,this)},this)},this)};function el(o,l){Zt(o);let d=[];if(typeof l=="string")Zc(o,l)&&(d=d.concat(o.g.get(vn(o,l))));else for(o=Array.from(o.g.values()),l=0;l<o.length;l++)d=d.concat(o[l]);return d}n.set=function(o,l){return Zt(this),this.i=null,o=vn(this,o),Zc(this,o)&&(this.h-=this.g.get(o).length),this.g.set(o,[l]),this.h+=1,this},n.get=function(o,l){return o?(o=el(this,o),o.length>0?String(o[0]):l):l};function tl(o,l,d){Xc(o,l),d.length>0&&(o.i=null,o.g.set(vn(o,l),S(d)),o.h+=d.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const o=[],l=Array.from(this.g.keys());for(let p=0;p<l.length;p++){var d=l[p];const A=er(d);d=el(this,d);for(let R=0;R<d.length;R++){let D=A;d[R]!==""&&(D+="="+er(d[R])),o.push(D)}}return this.i=o.join("&")};function nl(o){const l=new or;return l.i=o.i,o.g&&(l.g=new Map(o.g),l.h=o.h),l}function vn(o,l){return l=String(l),o.j&&(l=l.toLowerCase()),l}function cm(o,l){l&&!o.j&&(Zt(o),o.i=null,o.g.forEach(function(d,p){const A=p.toLowerCase();p!=A&&(Xc(this,p),tl(this,A,d))},o)),o.j=l}function lm(o,l){const d=new Zn;if(a.Image){const p=new Image;p.onload=f(St,d,"TestLoadImage: loaded",!0,l,p),p.onerror=f(St,d,"TestLoadImage: error",!1,l,p),p.onabort=f(St,d,"TestLoadImage: abort",!1,l,p),p.ontimeout=f(St,d,"TestLoadImage: timeout",!1,l,p),a.setTimeout(function(){p.ontimeout&&p.ontimeout()},1e4),p.src=o}else l(!1)}function um(o,l){const d=new Zn,p=new AbortController,A=setTimeout(()=>{p.abort(),St(d,"TestPingServer: timeout",!1,l)},1e4);fetch(o,{signal:p.signal}).then(R=>{clearTimeout(A),R.ok?St(d,"TestPingServer: ok",!0,l):St(d,"TestPingServer: server error",!1,l)}).catch(()=>{clearTimeout(A),St(d,"TestPingServer: error",!1,l)})}function St(o,l,d,p,A){try{A&&(A.onload=null,A.onerror=null,A.onabort=null,A.ontimeout=null),p(d)}catch{}}function hm(){this.g=new Kp}function Ji(o){this.i=o.Sb||null,this.h=o.ab||!1}m(Ji,Dc),Ji.prototype.g=function(){return new ts(this.i,this.h)};function ts(o,l){Ee.call(this),this.H=o,this.o=l,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.A=new Headers,this.h=null,this.F="GET",this.D="",this.g=!1,this.B=this.j=this.l=null,this.v=new AbortController}m(ts,Ee),n=ts.prototype,n.open=function(o,l){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.F=o,this.D=l,this.readyState=1,cr(this)},n.send=function(o){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");if(this.v.signal.aborted)throw this.abort(),Error("Request was aborted.");this.g=!0;const l={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};o&&(l.body=o),(this.H||a).fetch(new Request(this.D,l)).then(this.Pa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.A=new Headers,this.status=0,this.v.abort(),this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),this.readyState>=1&&this.g&&this.readyState!=4&&(this.g=!1,ar(this)),this.readyState=0},n.Pa=function(o){if(this.g&&(this.l=o,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=o.headers,this.readyState=2,cr(this)),this.g&&(this.readyState=3,cr(this),this.g)))if(this.responseType==="arraybuffer")o.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(typeof a.ReadableStream<"u"&&"body"in o){if(this.j=o.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.B=new TextDecoder;rl(this)}else o.text().then(this.Oa.bind(this),this.ga.bind(this))};function rl(o){o.j.read().then(o.Ma.bind(o)).catch(o.ga.bind(o))}n.Ma=function(o){if(this.g){if(this.o&&o.value)this.response.push(o.value);else if(!this.o){var l=o.value?o.value:new Uint8Array(0);(l=this.B.decode(l,{stream:!o.done}))&&(this.response=this.responseText+=l)}o.done?ar(this):cr(this),this.readyState==3&&rl(this)}},n.Oa=function(o){this.g&&(this.response=this.responseText=o,ar(this))},n.Na=function(o){this.g&&(this.response=o,ar(this))},n.ga=function(){this.g&&ar(this)};function ar(o){o.readyState=4,o.l=null,o.j=null,o.B=null,cr(o)}n.setRequestHeader=function(o,l){this.A.append(o,l)},n.getResponseHeader=function(o){return this.h&&this.h.get(o.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const o=[],l=this.h.entries();for(var d=l.next();!d.done;)d=d.value,o.push(d[0]+": "+d[1]),d=l.next();return o.join(`\r
21
+ `)};function cr(o){o.onreadystatechange&&o.onreadystatechange.call(o)}Object.defineProperty(ts.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(o){this.m=o?"include":"same-origin"}});function sl(o){let l="";return Wr(o,function(d,p){l+=p,l+=":",l+=d,l+=`\r
22
+ `}),l}function Yi(o,l,d){e:{for(p in d){var p=!1;break e}p=!0}p||(d=sl(d),typeof o=="string"?d!=null&&er(d):ne(o,l,d))}function se(o){Ee.call(this),this.headers=new Map,this.L=o||null,this.h=!1,this.g=null,this.D="",this.o=0,this.l="",this.j=this.B=this.v=this.A=!1,this.m=null,this.F="",this.H=!1}m(se,Ee);var dm=/^https?$/i,fm=["POST","PUT"];n=se.prototype,n.Fa=function(o){this.H=o},n.ea=function(o,l,d,p){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+o);l=l?l.toUpperCase():"GET",this.D=o,this.l="",this.o=0,this.A=!1,this.h=!0,this.g=this.L?this.L.g():Uc.g(),this.g.onreadystatechange=y(h(this.Ca,this));try{this.B=!0,this.g.open(l,String(o),!0),this.B=!1}catch(R){il(this,R);return}if(o=d||"",d=new Map(this.headers),p)if(Object.getPrototypeOf(p)===Object.prototype)for(var A in p)d.set(A,p[A]);else if(typeof p.keys=="function"&&typeof p.get=="function")for(const R of p.keys())d.set(R,p.get(R));else throw Error("Unknown input type for opt_headers: "+String(p));p=Array.from(d.keys()).find(R=>R.toLowerCase()=="content-type"),A=a.FormData&&o instanceof a.FormData,!(Array.prototype.indexOf.call(fm,l,void 0)>=0)||p||A||d.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[R,D]of d)this.g.setRequestHeader(R,D);this.F&&(this.g.responseType=this.F),"withCredentials"in this.g&&this.g.withCredentials!==this.H&&(this.g.withCredentials=this.H);try{this.m&&(clearTimeout(this.m),this.m=null),this.v=!0,this.g.send(o),this.v=!1}catch(R){il(this,R)}};function il(o,l){o.h=!1,o.g&&(o.j=!0,o.g.abort(),o.j=!1),o.l=l,o.o=5,ol(o),ns(o)}function ol(o){o.A||(o.A=!0,Re(o,"complete"),Re(o,"error"))}n.abort=function(o){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=o||7,Re(this,"complete"),Re(this,"abort"),ns(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),ns(this,!0)),se.Z.N.call(this)},n.Ca=function(){this.u||(this.B||this.v||this.j?al(this):this.Xa())},n.Xa=function(){al(this)};function al(o){if(o.h&&typeof i<"u"){if(o.v&&Rt(o)==4)setTimeout(o.Ca.bind(o),0);else if(Re(o,"readystatechange"),Rt(o)==4){o.h=!1;try{const R=o.ca();e:switch(R){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var l=!0;break e;default:l=!1}var d;if(!(d=l)){var p;if(p=R===0){let D=String(o.D).match(Jc)[1]||null;!D&&a.self&&a.self.location&&(D=a.self.location.protocol.slice(0,-1)),p=!dm.test(D?D.toLowerCase():"")}d=p}if(d)Re(o,"complete"),Re(o,"success");else{o.o=6;try{var A=Rt(o)>2?o.g.statusText:""}catch{A=""}o.l=A+" ["+o.ca()+"]",ol(o)}}finally{ns(o)}}}}function ns(o,l){if(o.g){o.m&&(clearTimeout(o.m),o.m=null);const d=o.g;o.g=null,l||Re(o,"ready");try{d.onreadystatechange=null}catch{}}}n.isActive=function(){return!!this.g};function Rt(o){return o.g?o.g.readyState:0}n.ca=function(){try{return Rt(this)>2?this.g.status:-1}catch{return-1}},n.la=function(){try{return this.g?this.g.responseText:""}catch{return""}},n.La=function(o){if(this.g){var l=this.g.responseText;return o&&l.indexOf(o)==0&&(l=l.substring(o.length)),Gp(l)}};function cl(o){try{if(!o.g)return null;if("response"in o.g)return o.g.response;switch(o.F){case"":case"text":return o.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in o.g)return o.g.mozResponseArrayBuffer}return null}catch{return null}}function pm(o){const l={};o=(o.g&&Rt(o)>=2&&o.g.getAllResponseHeaders()||"").split(`\r
23
+ `);for(let p=0;p<o.length;p++){if(T(o[p]))continue;var d=Xp(o[p]);const A=d[0];if(d=d[1],typeof d!="string")continue;d=d.trim();const R=l[A]||[];l[A]=R,R.push(d)}Bp(l,function(p){return p.join(", ")})}n.ya=function(){return this.o},n.Ha=function(){return typeof this.l=="string"?this.l:String(this.l)};function lr(o,l,d){return d&&d.internalChannelParams&&d.internalChannelParams[o]||l}function ll(o){this.za=0,this.i=[],this.j=new Zn,this.ba=this.na=this.J=this.W=this.g=this.wa=this.G=this.H=this.u=this.U=this.o=null,this.Ya=this.V=0,this.Sa=lr("failFast",!1,o),this.F=this.C=this.v=this.m=this.l=null,this.X=!0,this.xa=this.K=-1,this.Y=this.A=this.D=0,this.Qa=lr("baseRetryDelayMs",5e3,o),this.Za=lr("retryDelaySeedMs",1e4,o),this.Ta=lr("forwardChannelMaxRetries",2,o),this.va=lr("forwardChannelRequestTimeoutMs",2e4,o),this.ma=o&&o.xmlHttpFactory||void 0,this.Ua=o&&o.Rb||void 0,this.Aa=o&&o.useFetchStreams||!1,this.O=void 0,this.L=o&&o.supportsCrossDomainXhr||!1,this.M="",this.h=new Hc(o&&o.concurrentRequestLimit),this.Ba=new hm,this.S=o&&o.fastHandshake||!1,this.R=o&&o.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=o&&o.Pb||!1,o&&o.ua&&this.j.ua(),o&&o.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&o&&o.detectBufferingProxy||!1,this.ia=void 0,o&&o.longPollingTimeout&&o.longPollingTimeout>0&&(this.ia=o.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}n=ll.prototype,n.ka=8,n.I=1,n.connect=function(o,l,d,p){Pe(0),this.W=o,this.H=l||{},d&&p!==void 0&&(this.H.OSID=d,this.H.OAID=p),this.F=this.X,this.J=yl(this,null,this.W),ss(this)};function Xi(o){if(ul(o),o.I==3){var l=o.V++,d=Ze(o.J);if(ne(d,"SID",o.M),ne(d,"RID",l),ne(d,"TYPE","terminate"),ur(o,d),l=new At(o,o.j,l),l.M=2,l.A=es(Ze(d)),d=!1,a.navigator&&a.navigator.sendBeacon)try{d=a.navigator.sendBeacon(l.A.toString(),"")}catch{}!d&&a.Image&&(new Image().src=l.A,d=!0),d||(l.g=Tl(l.j,null),l.g.ea(l.A)),l.F=Date.now(),Zr(l)}_l(o)}function rs(o){o.g&&(eo(o),o.g.cancel(),o.g=null)}function ul(o){rs(o),o.v&&(a.clearTimeout(o.v),o.v=null),is(o),o.h.cancel(),o.m&&(typeof o.m=="number"&&a.clearTimeout(o.m),o.m=null)}function ss(o){if(!Gc(o.h)&&!o.m){o.m=!0;var l=o.Ea;we||g(),oe||(we(),oe=!0),v.add(l,o),o.D=0}}function mm(o,l){return Kc(o.h)>=o.h.j-(o.m?1:0)?!1:o.m?(o.i=l.G.concat(o.i),!0):o.I==1||o.I==2||o.D>=(o.Sa?0:o.Ta)?!1:(o.m=Xn(h(o.Ea,o,l),gl(o,o.D)),o.D++,!0)}n.Ea=function(o){if(this.m)if(this.m=null,this.I==1){if(!o){this.V=Math.floor(Math.random()*1e5),o=this.V++;const A=new At(this,this.j,o);let R=this.o;if(this.U&&(R?(R=vc(R),Ac(R,this.U)):R=this.U),this.u!==null||this.R||(A.J=R,R=null),this.S)e:{for(var l=0,d=0;d<this.i.length;d++){t:{var p=this.i[d];if("__data__"in p.map&&(p=p.map.__data__,typeof p=="string")){p=p.length;break t}p=void 0}if(p===void 0)break;if(l+=p,l>4096){l=d;break e}if(l===4096||d===this.i.length-1){l=d+1;break e}}l=1e3}else l=1e3;l=dl(this,A,l),d=Ze(this.J),ne(d,"RID",o),ne(d,"CVER",22),this.G&&ne(d,"X-HTTP-Session-Id",this.G),ur(this,d),R&&(this.R?l="headers="+er(sl(R))+"&"+l:this.u&&Yi(d,this.u,R)),Wi(this.h,A),this.Ra&&ne(d,"TYPE","init"),this.S?(ne(d,"$req",l),ne(d,"SID","null"),A.U=!0,zi(A,d,null)):zi(A,d,l),this.I=2}}else this.I==3&&(o?hl(this,o):this.i.length==0||Gc(this.h)||hl(this))};function hl(o,l){var d;l?d=l.l:d=o.V++;const p=Ze(o.J);ne(p,"SID",o.M),ne(p,"RID",d),ne(p,"AID",o.K),ur(o,p),o.u&&o.o&&Yi(p,o.u,o.o),d=new At(o,o.j,d,o.D+1),o.u===null&&(d.J=o.o),l&&(o.i=l.G.concat(o.i)),l=dl(o,d,1e3),d.H=Math.round(o.va*.5)+Math.round(o.va*.5*Math.random()),Wi(o.h,d),zi(d,p,l)}function ur(o,l){o.H&&Wr(o.H,function(d,p){ne(l,p,d)}),o.l&&Wr({},function(d,p){ne(l,p,d)})}function dl(o,l,d){d=Math.min(o.i.length,d);const p=o.l?h(o.l.Ka,o.l,o):null;e:{var A=o.i;let j=-1;for(;;){const he=["count="+d];j==-1?d>0?(j=A[0].g,he.push("ofs="+j)):j=0:he.push("ofs="+j);let X=!0;for(let fe=0;fe<d;fe++){var R=A[fe].g;const et=A[fe].map;if(R-=j,R<0)j=Math.max(0,A[fe].g-100),X=!1;else try{R="req"+R+"_"||"";try{var D=et instanceof Map?et:Object.entries(et);for(const[tn,Pt]of D){let Ct=Pt;c(Pt)&&(Ct=Ui(Pt)),he.push(R+tn+"="+encodeURIComponent(Ct))}}catch(tn){throw he.push(R+"type="+encodeURIComponent("_badmap")),tn}}catch{p&&p(et)}}if(X){D=he.join("&");break e}}D=void 0}return o=o.i.splice(0,d),l.G=o,D}function fl(o){if(!o.g&&!o.v){o.Y=1;var l=o.Da;we||g(),oe||(we(),oe=!0),v.add(l,o),o.A=0}}function Zi(o){return o.g||o.v||o.A>=3?!1:(o.Y++,o.v=Xn(h(o.Da,o),gl(o,o.A)),o.A++,!0)}n.Da=function(){if(this.v=null,pl(this),this.aa&&!(this.P||this.g==null||this.T<=0)){var o=4*this.T;this.j.info("BP detection timer enabled: "+o),this.B=Xn(h(this.Wa,this),o)}},n.Wa=function(){this.B&&(this.B=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.P=!0,Pe(10),rs(this),pl(this))};function eo(o){o.B!=null&&(a.clearTimeout(o.B),o.B=null)}function pl(o){o.g=new At(o,o.j,"rpc",o.Y),o.u===null&&(o.g.J=o.o),o.g.P=0;var l=Ze(o.na);ne(l,"RID","rpc"),ne(l,"SID",o.M),ne(l,"AID",o.K),ne(l,"CI",o.F?"0":"1"),!o.F&&o.ia&&ne(l,"TO",o.ia),ne(l,"TYPE","xmlhttp"),ur(o,l),o.u&&o.o&&Yi(l,o.u,o.o),o.O&&(o.g.H=o.O);var d=o.g;o=o.ba,d.M=1,d.A=es(Ze(l)),d.u=null,d.R=!0,$c(d,o)}n.Va=function(){this.C!=null&&(this.C=null,rs(this),Zi(this),Pe(19))};function is(o){o.C!=null&&(a.clearTimeout(o.C),o.C=null)}function ml(o,l){var d=null;if(o.g==l){is(o),eo(o),o.g=null;var p=2}else if(Ki(o.h,l))d=l.G,Wc(o.h,l),p=1;else return;if(o.I!=0){if(l.o)if(p==1){d=l.u?l.u.length:0,l=Date.now()-l.F;var A=o.D;p=Yr(),Re(p,new xc(p,d)),ss(o)}else fl(o);else if(A=l.m,A==3||A==0&&l.X>0||!(p==1&&mm(o,l)||p==2&&Zi(o)))switch(d&&d.length>0&&(l=o.h,l.i=l.i.concat(d)),A){case 1:en(o,5);break;case 4:en(o,10);break;case 3:en(o,6);break;default:en(o,2)}}}function gl(o,l){let d=o.Qa+Math.floor(Math.random()*o.Za);return o.isActive()||(d*=2),d*l}function en(o,l){if(o.j.info("Error code "+l),l==2){var d=h(o.bb,o),p=o.Ua;const A=!p;p=new bt(p||"//www.google.com/images/cleardot.gif"),a.location&&a.location.protocol=="http"||nr(p,"https"),es(p),A?lm(p.toString(),d):um(p.toString(),d)}else Pe(2);o.I=0,o.l&&o.l.pa(l),_l(o),ul(o)}n.bb=function(o){o?(this.j.info("Successfully pinged google.com"),Pe(2)):(this.j.info("Failed to ping google.com"),Pe(1))};function _l(o){if(o.I=0,o.ja=[],o.l){const l=Qc(o.h);(l.length!=0||o.i.length!=0)&&(k(o.ja,l),k(o.ja,o.i),o.h.i.length=0,S(o.i),o.i.length=0),o.l.oa()}}function yl(o,l,d){var p=d instanceof bt?Ze(d):new bt(d);if(p.g!="")l&&(p.g=l+"."+p.g),rr(p,p.u);else{var A=a.location;p=A.protocol,l=l?l+"."+A.hostname:A.hostname,A=+A.port;const R=new bt(null);p&&nr(R,p),l&&(R.g=l),A&&rr(R,A),d&&(R.h=d),p=R}return d=o.G,l=o.wa,d&&l&&ne(p,d,l),ne(p,"VER",o.ka),ur(o,p),p}function Tl(o,l,d){if(l&&!o.L)throw Error("Can't create secondary domain capable XhrIo object.");return l=o.Aa&&!o.ma?new se(new Ji({ab:d})):new se(o.ma),l.Fa(o.L),l}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function wl(){}n=wl.prototype,n.ra=function(){},n.qa=function(){},n.pa=function(){},n.oa=function(){},n.isActive=function(){return!0},n.Ka=function(){};function os(){}os.prototype.g=function(o,l){return new xe(o,l)};function xe(o,l){Ee.call(this),this.g=new ll(l),this.l=o,this.h=l&&l.messageUrlParams||null,o=l&&l.messageHeaders||null,l&&l.clientProtocolHeaderRequired&&(o?o["X-Client-Protocol"]="webchannel":o={"X-Client-Protocol":"webchannel"}),this.g.o=o,o=l&&l.initMessageHeaders||null,l&&l.messageContentType&&(o?o["X-WebChannel-Content-Type"]=l.messageContentType:o={"X-WebChannel-Content-Type":l.messageContentType}),l&&l.sa&&(o?o["X-WebChannel-Client-Profile"]=l.sa:o={"X-WebChannel-Client-Profile":l.sa}),this.g.U=o,(o=l&&l.Qb)&&!T(o)&&(this.g.u=o),this.A=l&&l.supportsCrossDomainXhr||!1,this.v=l&&l.sendRawJson||!1,(l=l&&l.httpSessionIdParam)&&!T(l)&&(this.g.G=l,o=this.h,o!==null&&l in o&&(o=this.h,l in o&&delete o[l])),this.j=new In(this)}m(xe,Ee),xe.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},xe.prototype.close=function(){Xi(this.g)},xe.prototype.o=function(o){var l=this.g;if(typeof o=="string"){var d={};d.__data__=o,o=d}else this.v&&(d={},d.__data__=Ui(o),o=d);l.i.push(new tm(l.Ya++,o)),l.I==3&&ss(l)},xe.prototype.N=function(){this.g.l=null,delete this.j,Xi(this.g),delete this.g,xe.Z.N.call(this)};function El(o){Bi.call(this),o.__headers__&&(this.headers=o.__headers__,this.statusCode=o.__status__,delete o.__headers__,delete o.__status__);var l=o.__sm__;if(l){e:{for(const d in l){o=d;break e}o=void 0}(this.i=o)&&(o=this.i,l=l!==null&&o in l?l[o]:void 0),this.data=l}else this.data=o}m(El,Bi);function vl(){qi.call(this),this.status=1}m(vl,qi);function In(o){this.g=o}m(In,wl),In.prototype.ra=function(){Re(this.g,"a")},In.prototype.qa=function(o){Re(this.g,new El(o))},In.prototype.pa=function(o){Re(this.g,new vl)},In.prototype.oa=function(){Re(this.g,"b")},os.prototype.createWebChannel=os.prototype.g,xe.prototype.send=xe.prototype.o,xe.prototype.open=xe.prototype.m,xe.prototype.close=xe.prototype.close,Hd=function(){return new os},zd=function(){return Yr()},jd=Yt,Lo={jb:0,mb:1,nb:2,Hb:3,Mb:4,Jb:5,Kb:6,Ib:7,Gb:8,Lb:9,PROXY:10,NOPROXY:11,Eb:12,Ab:13,Bb:14,zb:15,Cb:16,Db:17,fb:18,eb:19,gb:20},Xr.NO_ERROR=0,Xr.TIMEOUT=8,Xr.HTTP_ERROR=6,Ts=Xr,Fc.COMPLETE="complete",$d=Fc,Vc.EventType=Jn,Jn.OPEN="a",Jn.CLOSE="b",Jn.ERROR="c",Jn.MESSAGE="d",Ee.prototype.listen=Ee.prototype.J,dr=Vc,se.prototype.listenOnce=se.prototype.K,se.prototype.getLastError=se.prototype.Ha,se.prototype.getLastErrorCode=se.prototype.ya,se.prototype.getStatus=se.prototype.ca,se.prototype.getResponseJson=se.prototype.La,se.prototype.getResponseText=se.prototype.la,se.prototype.send=se.prototype.ea,se.prototype.setWithCredentials=se.prototype.Fa,qd=se}).apply(typeof ls<"u"?ls:typeof self<"u"?self:typeof window<"u"?window:{});let Ie=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}};Ie.UNAUTHENTICATED=new Ie(null),Ie.GOOGLE_CREDENTIALS=new Ie("google-credentials-uid"),Ie.FIRST_PARTY=new Ie("first-party-uid"),Ie.MOCK_USER=new Ie("mock-user");let zn="12.8.0";function tE(n){zn=n}const pn=new ai("@firebase/firestore");function An(){return pn.logLevel}function L(n,...e){if(pn.logLevel<=H.DEBUG){const t=e.map(Ca);pn.debug(`Firestore (${zn}): ${n}`,...t)}}function wt(n,...e){if(pn.logLevel<=H.ERROR){const t=e.map(Ca);pn.error(`Firestore (${zn}): ${n}`,...t)}}function Ln(n,...e){if(pn.logLevel<=H.WARN){const t=e.map(Ca);pn.warn(`Firestore (${zn}): ${n}`,...t)}}function Ca(n){if(typeof n=="string")return n;try{return(function(t){return JSON.stringify(t)})(n)}catch{return n}}function x(n,e,t){let r="Unexpected state";typeof e=="string"?r=e:t=e,Gd(n,r,t)}function Gd(n,e,t){let r=`FIRESTORE (${zn}) INTERNAL ASSERTION FAILED: ${e} (ID: ${n.toString(16)})`;if(t!==void 0)try{r+=" CONTEXT: "+JSON.stringify(t)}catch{r+=" CONTEXT: "+t}throw wt(r),new Error(r)}function Y(n,e,t,r){let s="Unexpected state";typeof t=="string"?s=t:r=t,n||Gd(e,s,r)}function q(n,e){return n}const P={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class O extends $e{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class _t{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class Kd{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class nE{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(Ie.UNAUTHENTICATED)))}shutdown(){}}class rE{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}}class sE{constructor(e){this.t=e,this.currentUser=Ie.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){Y(this.o===void 0,42304);let r=this.i;const s=u=>this.i!==r?(r=this.i,t(u)):Promise.resolve();let i=new _t;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new _t,e.enqueueRetryable((()=>s(this.currentUser)))};const a=()=>{const u=i;e.enqueueRetryable((async()=>{await u.promise,await s(this.currentUser)}))},c=u=>{L("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=u,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit((u=>c(u))),setTimeout((()=>{if(!this.auth){const u=this.t.getImmediate({optional:!0});u?c(u):(L("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new _t)}}),0),a()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((r=>this.i!==e?(L("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(Y(typeof r.accessToken=="string",31837,{l:r}),new Kd(r.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const e=this.auth&&this.auth.getUid();return Y(e===null||typeof e=="string",2055,{h:e}),new Ie(e)}}class iE{constructor(e,t,r){this.P=e,this.T=t,this.I=r,this.type="FirstParty",this.user=Ie.FIRST_PARTY,this.R=new Map}A(){return this.I?this.I():null}get headers(){this.R.set("X-Goog-AuthUser",this.P);const e=this.A();return e&&this.R.set("Authorization",e),this.T&&this.R.set("X-Goog-Iam-Authorization-Token",this.T),this.R}}class oE{constructor(e,t,r){this.P=e,this.T=t,this.I=r}getToken(){return Promise.resolve(new iE(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable((()=>t(Ie.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class ou{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class aE{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,Fe(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){Y(this.o===void 0,3512);const r=i=>{i.error!=null&&L("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${i.error.message}`);const a=i.token!==this.m;return this.m=i.token,L("FirebaseAppCheckTokenProvider",`Received ${a?"new":"existing"} token.`),a?t(i.token):Promise.resolve()};this.o=i=>{e.enqueueRetryable((()=>r(i)))};const s=i=>{L("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=i,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit((i=>s(i))),setTimeout((()=>{if(!this.appCheck){const i=this.V.getImmediate({optional:!0});i?s(i):L("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){if(this.p)return Promise.resolve(new ou(this.p));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((t=>t?(Y(typeof t.token=="string",44558,{tokenResult:t}),this.m=t.token,new ou(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 cE(n){const e=typeof self<"u"&&(self.crypto||self.msCrypto),t=new Uint8Array(n);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let r=0;r<n;r++)t[r]=Math.floor(256*Math.random());return t}class ka{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=62*Math.floor(4.129032258064516);let r="";for(;r.length<20;){const s=cE(40);for(let i=0;i<s.length;++i)r.length<20&&s[i]<t&&(r+=e.charAt(s[i]%62))}return r}}function G(n,e){return n<e?-1:n>e?1:0}function Mo(n,e){const t=Math.min(n.length,e.length);for(let r=0;r<t;r++){const s=n.charAt(r),i=e.charAt(r);if(s!==i)return po(s)===po(i)?G(s,i):po(s)?1:-1}return G(n.length,e.length)}const lE=55296,uE=57343;function po(n){const e=n.charCodeAt(0);return e>=lE&&e<=uE}function Mn(n,e,t){return n.length===e.length&&n.every(((r,s)=>t(r,e[s])))}const xo="__name__";class tt{constructor(e,t,r){t===void 0?t=0:t>e.length&&x(637,{offset:t,range:e.length}),r===void 0?r=e.length-t:r>e.length-t&&x(1746,{length:r,range:e.length-t}),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return tt.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof tt?e.forEach((r=>{t.push(r)})):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,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const r=Math.min(e.length,t.length);for(let s=0;s<r;s++){const i=tt.compareSegments(e.get(s),t.get(s));if(i!==0)return i}return G(e.length,t.length)}static compareSegments(e,t){const r=tt.isNumericId(e),s=tt.isNumericId(t);return r&&!s?-1:!r&&s?1:r&&s?tt.extractNumericId(e).compare(tt.extractNumericId(t)):Mo(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return xt.fromString(e.substring(4,e.length-2))}}class Z extends tt{construct(e,t,r){return new Z(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const r of e){if(r.indexOf("//")>=0)throw new O(P.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter((s=>s.length>0)))}return new Z(t)}static emptyPath(){return new Z([])}}const hE=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class ye extends tt{construct(e,t,r){return new ye(e,t,r)}static isValidIdentifier(e){return hE.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),ye.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===xo}static keyField(){return new ye([xo])}static fromServerFormat(e){const t=[];let r="",s=0;const i=()=>{if(r.length===0)throw new O(P.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(r),r=""};let a=!1;for(;s<e.length;){const c=e[s];if(c==="\\"){if(s+1===e.length)throw new O(P.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const u=e[s+1];if(u!=="\\"&&u!=="."&&u!=="`")throw new O(P.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=u,s+=2}else c==="`"?(a=!a,s++):c!=="."||a?(r+=c,s++):(i(),s++)}if(i(),a)throw new O(P.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new ye(t)}static emptyPath(){return new ye([])}}class M{constructor(e){this.path=e}static fromPath(e){return new M(Z.fromString(e))}static fromName(e){return new M(Z.fromString(e).popFirst(5))}static empty(){return new M(Z.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&&Z.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return Z.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new M(new Z(e.slice()))}}function Wd(n,e,t){if(!t)throw new O(P.INVALID_ARGUMENT,`Function ${n}() cannot be called with an empty ${e}.`)}function dE(n,e,t,r){if(e===!0&&r===!0)throw new O(P.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function au(n){if(!M.isDocumentKey(n))throw new O(P.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${n} has ${n.length}.`)}function cu(n){if(M.isDocumentKey(n))throw new O(P.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${n} has ${n.length}.`)}function Qd(n){return typeof n=="object"&&n!==null&&(Object.getPrototypeOf(n)===Object.prototype||Object.getPrototypeOf(n)===null)}function pi(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n.length>20&&(n=`${n.substring(0,20)}...`),JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return""+n;if(typeof n=="object"){if(n instanceof Array)return"an array";{const e=(function(r){return r.constructor?r.constructor.name:null})(n);return e?`a custom ${e} object`:"an object"}}return typeof n=="function"?"a function":x(12329,{type:typeof n})}function qe(n,e){if("_delegate"in n&&(n=n._delegate),!(n instanceof e)){if(e.name===n.constructor.name)throw new O(P.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const t=pi(n);throw new O(P.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return n}function fE(n,e){if(e<=0)throw new O(P.INVALID_ARGUMENT,`Function ${n}() requires a positive number, but it was: ${e}.`)}function ue(n,e){const t={typeString:n};return e&&(t.value=e),t}function Br(n,e){if(!Qd(n))throw new O(P.INVALID_ARGUMENT,"JSON must be an object");let t;for(const r in e)if(e[r]){const s=e[r].typeString,i="value"in e[r]?{value:e[r].value}:void 0;if(!(r in n)){t=`JSON missing required field: '${r}'`;break}const a=n[r];if(s&&typeof a!==s){t=`JSON field '${r}' must be a ${s}.`;break}if(i!==void 0&&a!==i.value){t=`Expected '${r}' field to equal '${i.value}'`;break}}if(t)throw new O(P.INVALID_ARGUMENT,t);return!0}const lu=-62135596800,uu=1e6;class z{static now(){return z.fromMillis(Date.now())}static fromDate(e){return z.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),r=Math.floor((e-1e3*t)*uu);return new z(t,r)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new O(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new O(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<lu)throw new O(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new O(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/uu}_compareTo(e){return this.seconds===e.seconds?G(this.nanoseconds,e.nanoseconds):G(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{type:z._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(Br(e,z._jsonSchema))return new z(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-lu;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}z._jsonSchemaVersion="firestore/timestamp/1.0",z._jsonSchema={type:ue("string",z._jsonSchemaVersion),seconds:ue("number"),nanoseconds:ue("number")};class B{static fromTimestamp(e){return new B(e)}static min(){return new B(new z(0,0))}static max(){return new B(new z(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}}const Rr=-1;function pE(n,e){const t=n.toTimestamp().seconds,r=n.toTimestamp().nanoseconds+1,s=B.fromTimestamp(r===1e9?new z(t+1,0):new z(t,r));return new Bt(s,M.empty(),e)}function mE(n){return new Bt(n.readTime,n.key,Rr)}class Bt{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new Bt(B.min(),M.empty(),Rr)}static max(){return new Bt(B.max(),M.empty(),Rr)}}function gE(n,e){let t=n.readTime.compareTo(e.readTime);return t!==0?t:(t=M.comparator(n.documentKey,e.documentKey),t!==0?t:G(n.largestBatchId,e.largestBatchId))}const _E="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class yE{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}}async function Hn(n){if(n.code!==P.FAILED_PRECONDITION||n.message!==_E)throw n;L("LocalStore","Unexpectedly lost primary lease")}class C{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&&x(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new C(((r,s)=>{this.nextCallback=i=>{this.wrapSuccess(e,i).next(r,s)},this.catchCallback=i=>{this.wrapFailure(t,i).next(r,s)}}))}toPromise(){return new Promise(((e,t)=>{this.next(e,t)}))}wrapUserFunction(e){try{const t=e();return t instanceof C?t:C.resolve(t)}catch(t){return C.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction((()=>e(t))):C.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction((()=>e(t))):C.reject(t)}static resolve(e){return new C(((t,r)=>{t(e)}))}static reject(e){return new C(((t,r)=>{r(e)}))}static waitFor(e){return new C(((t,r)=>{let s=0,i=0,a=!1;e.forEach((c=>{++s,c.next((()=>{++i,a&&i===s&&t()}),(u=>r(u)))})),a=!0,i===s&&t()}))}static or(e){let t=C.resolve(!1);for(const r of e)t=t.next((s=>s?C.resolve(s):r()));return t}static forEach(e,t){const r=[];return e.forEach(((s,i)=>{r.push(t.call(this,s,i))})),this.waitFor(r)}static mapArray(e,t){return new C(((r,s)=>{const i=e.length,a=new Array(i);let c=0;for(let u=0;u<i;u++){const h=u;t(e[h]).next((f=>{a[h]=f,++c,c===i&&r(a)}),(f=>s(f)))}}))}static doWhile(e,t){return new C(((r,s)=>{const i=()=>{e()===!0?t().next((()=>{i()}),s):r()};i()}))}}function TE(n){const e=n.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function Gn(n){return n.name==="IndexedDbTransactionError"}class mi{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=r=>this.ae(r),this.ue=r=>t.writeSequenceNumber(r))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.ue&&this.ue(e),e}}mi.ce=-1;const Na=-1;function gi(n){return n==null}function Ms(n){return n===0&&1/n==-1/0}function wE(n){return typeof n=="number"&&Number.isInteger(n)&&!Ms(n)&&n<=Number.MAX_SAFE_INTEGER&&n>=Number.MIN_SAFE_INTEGER}const Jd="";function EE(n){let e="";for(let t=0;t<n.length;t++)e.length>0&&(e=hu(e)),e=vE(n.get(t),e);return hu(e)}function vE(n,e){let t=e;const r=n.length;for(let s=0;s<r;s++){const i=n.charAt(s);switch(i){case"\0":t+="";break;case Jd:t+="";break;default:t+=i}}return t}function hu(n){return n+Jd+""}function du(n){let e=0;for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e++;return e}function Wt(n,e){for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(t,n[t])}function Yd(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}class re{constructor(e,t){this.comparator=e,this.root=t||_e.EMPTY}insert(e,t){return new re(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,_e.BLACK,null,null))}remove(e){return new re(this.comparator,this.root.remove(e,this.comparator).copy(null,null,_e.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const r=this.comparator(e,t.key);if(r===0)return t.value;r<0?t=t.left:r>0&&(t=t.right)}return null}indexOf(e){let t=0,r=this.root;for(;!r.isEmpty();){const s=this.comparator(e,r.key);if(s===0)return t+r.left.size;s<0?r=r.left:(t+=r.left.size+1,r=r.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,r)=>(e(t,r),!1)))}toString(){const e=[];return this.inorderTraversal(((t,r)=>(e.push(`${t}:${r}`),!1))),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new us(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new us(this.root,e,this.comparator,!1)}getReverseIterator(){return new us(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new us(this.root,e,this.comparator,!0)}}class us{constructor(e,t,r,s){this.isReverse=s,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?r(e.key,t):1,t&&s&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(i===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const 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;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class _e{constructor(e,t,r,s,i){this.key=e,this.value=t,this.color=r??_e.RED,this.left=s??_e.EMPTY,this.right=i??_e.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,s,i){return new _e(e??this.key,t??this.value,r??this.color,s??this.left,i??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,r){let s=this;const i=r(e,s.key);return s=i<0?s.copy(null,null,null,s.left.insert(e,t,r),null):i===0?s.copy(null,t,null,null,null):s.copy(null,null,null,null,s.right.insert(e,t,r)),s.fixUp()}removeMin(){if(this.left.isEmpty())return _e.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 r,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 _e.EMPTY;r=s.right.min(),s=s.copy(r.key,r.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(){const e=this.copy(null,null,_e.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,_e.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw x(43730,{key:this.key,value:this.value});if(this.right.isRed())throw x(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw x(27949);return e+(this.isRed()?0:1)}}_e.EMPTY=null,_e.RED=!0,_e.BLACK=!1;_e.EMPTY=new class{constructor(){this.size=0}get key(){throw x(57766)}get value(){throw x(16141)}get color(){throw x(16727)}get left(){throw x(29726)}get right(){throw x(36894)}copy(e,t,r,s,i){return this}insert(e,t,r){return new _e(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}};class de{constructor(e){this.comparator=e,this.data=new re(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,r)=>(e(t),!1)))}forEachInRange(e,t){const r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){const s=r.getNext();if(this.comparator(s.key,e[1])>=0)return;t(s.key)}}forEachWhile(e,t){let r;for(r=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new fu(this.data.getIterator())}getIteratorFrom(e){return new fu(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((r=>{t=t.add(r)})),t}isEqual(e){if(!(e instanceof de)||this.size!==e.size)return!1;const t=this.data.getIterator(),r=e.data.getIterator();for(;t.hasNext();){const s=t.getNext().key,i=r.getNext().key;if(this.comparator(s,i)!==0)return!1}return!0}toArray(){const e=[];return this.forEach((t=>{e.push(t)})),e}toString(){const e=[];return this.forEach((t=>e.push(t))),"SortedSet("+e.toString()+")"}copy(e){const t=new de(this.comparator);return t.data=e,t}}class fu{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}class Ue{constructor(e){this.fields=e,e.sort(ye.comparator)}static empty(){return new Ue([])}unionWith(e){let t=new de(ye.comparator);for(const r of this.fields)t=t.add(r);for(const r of e)t=t.add(r);return new Ue(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return Mn(this.fields,e.fields,((t,r)=>t.isEqual(r)))}}class Xd extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class Te{constructor(e){this.binaryString=e}static fromBase64String(e){const t=(function(s){try{return atob(s)}catch(i){throw typeof DOMException<"u"&&i instanceof DOMException?new Xd("Invalid base64 string: "+i):i}})(e);return new Te(t)}static fromUint8Array(e){const t=(function(s){let i="";for(let a=0;a<s.length;++a)i+=String.fromCharCode(s[a]);return i})(e);return new Te(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){const r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r})(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return G(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}Te.EMPTY_BYTE_STRING=new Te("");const IE=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function qt(n){if(Y(!!n,39018),typeof n=="string"){let e=0;const t=IE.exec(n);if(Y(!!t,46558,{timestamp:n}),t[1]){let s=t[1];s=(s+"000000000").substr(0,9),e=Number(s)}const r=new Date(n);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:ae(n.seconds),nanos:ae(n.nanos)}}function ae(n){return typeof n=="number"?n:typeof n=="string"?Number(n):0}function $t(n){return typeof n=="string"?Te.fromBase64String(n):Te.fromUint8Array(n)}const Zd="server_timestamp",ef="__type__",tf="__previous_value__",nf="__local_write_time__";function Da(n){return(n?.mapValue?.fields||{})[ef]?.stringValue===Zd}function _i(n){const e=n.mapValue.fields[tf];return Da(e)?_i(e):e}function Pr(n){const e=qt(n.mapValue.fields[nf].timestampValue);return new z(e.seconds,e.nanos)}class AE{constructor(e,t,r,s,i,a,c,u,h,f,m){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=s,this.ssl=i,this.forceLongPolling=a,this.autoDetectLongPolling=c,this.longPollingOptions=u,this.useFetchStreams=h,this.isUsingEmulator=f,this.apiKey=m}}const xs="(default)";class Cr{constructor(e,t){this.projectId=e,this.database=t||xs}static empty(){return new Cr("","")}get isDefaultDatabase(){return this.database===xs}isEqual(e){return e instanceof Cr&&e.projectId===this.projectId&&e.database===this.database}}function bE(n,e){if(!Object.prototype.hasOwnProperty.apply(n.options,["projectId"]))throw new O(P.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new Cr(n.options.projectId,e)}const rf="__type__",SE="__max__",hs={mapValue:{}},sf="__vector__",Fs="value";function jt(n){return"nullValue"in n?0:"booleanValue"in n?1:"integerValue"in n||"doubleValue"in n?2:"timestampValue"in n?3:"stringValue"in n?5:"bytesValue"in n?6:"referenceValue"in n?7:"geoPointValue"in n?8:"arrayValue"in n?9:"mapValue"in n?Da(n)?4:PE(n)?9007199254740991:RE(n)?10:11:x(28295,{value:n})}function ct(n,e){if(n===e)return!0;const t=jt(n);if(t!==jt(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===e.booleanValue;case 4:return Pr(n).isEqual(Pr(e));case 3:return(function(s,i){if(typeof s.timestampValue=="string"&&typeof i.timestampValue=="string"&&s.timestampValue.length===i.timestampValue.length)return s.timestampValue===i.timestampValue;const a=qt(s.timestampValue),c=qt(i.timestampValue);return a.seconds===c.seconds&&a.nanos===c.nanos})(n,e);case 5:return n.stringValue===e.stringValue;case 6:return(function(s,i){return $t(s.bytesValue).isEqual($t(i.bytesValue))})(n,e);case 7:return n.referenceValue===e.referenceValue;case 8:return(function(s,i){return ae(s.geoPointValue.latitude)===ae(i.geoPointValue.latitude)&&ae(s.geoPointValue.longitude)===ae(i.geoPointValue.longitude)})(n,e);case 2:return(function(s,i){if("integerValue"in s&&"integerValue"in i)return ae(s.integerValue)===ae(i.integerValue);if("doubleValue"in s&&"doubleValue"in i){const a=ae(s.doubleValue),c=ae(i.doubleValue);return a===c?Ms(a)===Ms(c):isNaN(a)&&isNaN(c)}return!1})(n,e);case 9:return Mn(n.arrayValue.values||[],e.arrayValue.values||[],ct);case 10:case 11:return(function(s,i){const a=s.mapValue.fields||{},c=i.mapValue.fields||{};if(du(a)!==du(c))return!1;for(const u in a)if(a.hasOwnProperty(u)&&(c[u]===void 0||!ct(a[u],c[u])))return!1;return!0})(n,e);default:return x(52216,{left:n})}}function kr(n,e){return(n.values||[]).find((t=>ct(t,e)))!==void 0}function xn(n,e){if(n===e)return 0;const t=jt(n),r=jt(e);if(t!==r)return G(t,r);switch(t){case 0:case 9007199254740991:return 0;case 1:return G(n.booleanValue,e.booleanValue);case 2:return(function(i,a){const c=ae(i.integerValue||i.doubleValue),u=ae(a.integerValue||a.doubleValue);return c<u?-1:c>u?1:c===u?0:isNaN(c)?isNaN(u)?0:-1:1})(n,e);case 3:return pu(n.timestampValue,e.timestampValue);case 4:return pu(Pr(n),Pr(e));case 5:return Mo(n.stringValue,e.stringValue);case 6:return(function(i,a){const c=$t(i),u=$t(a);return c.compareTo(u)})(n.bytesValue,e.bytesValue);case 7:return(function(i,a){const c=i.split("/"),u=a.split("/");for(let h=0;h<c.length&&h<u.length;h++){const f=G(c[h],u[h]);if(f!==0)return f}return G(c.length,u.length)})(n.referenceValue,e.referenceValue);case 8:return(function(i,a){const c=G(ae(i.latitude),ae(a.latitude));return c!==0?c:G(ae(i.longitude),ae(a.longitude))})(n.geoPointValue,e.geoPointValue);case 9:return mu(n.arrayValue,e.arrayValue);case 10:return(function(i,a){const c=i.fields||{},u=a.fields||{},h=c[Fs]?.arrayValue,f=u[Fs]?.arrayValue,m=G(h?.values?.length||0,f?.values?.length||0);return m!==0?m:mu(h,f)})(n.mapValue,e.mapValue);case 11:return(function(i,a){if(i===hs.mapValue&&a===hs.mapValue)return 0;if(i===hs.mapValue)return 1;if(a===hs.mapValue)return-1;const c=i.fields||{},u=Object.keys(c),h=a.fields||{},f=Object.keys(h);u.sort(),f.sort();for(let m=0;m<u.length&&m<f.length;++m){const y=Mo(u[m],f[m]);if(y!==0)return y;const S=xn(c[u[m]],h[f[m]]);if(S!==0)return S}return G(u.length,f.length)})(n.mapValue,e.mapValue);default:throw x(23264,{he:t})}}function pu(n,e){if(typeof n=="string"&&typeof e=="string"&&n.length===e.length)return G(n,e);const t=qt(n),r=qt(e),s=G(t.seconds,r.seconds);return s!==0?s:G(t.nanos,r.nanos)}function mu(n,e){const t=n.values||[],r=e.values||[];for(let s=0;s<t.length&&s<r.length;++s){const i=xn(t[s],r[s]);if(i)return i}return G(t.length,r.length)}function Fn(n){return Fo(n)}function Fo(n){return"nullValue"in n?"null":"booleanValue"in n?""+n.booleanValue:"integerValue"in n?""+n.integerValue:"doubleValue"in n?""+n.doubleValue:"timestampValue"in n?(function(t){const r=qt(t);return`time(${r.seconds},${r.nanos})`})(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?(function(t){return $t(t).toBase64()})(n.bytesValue):"referenceValue"in n?(function(t){return M.fromName(t).toString()})(n.referenceValue):"geoPointValue"in n?(function(t){return`geo(${t.latitude},${t.longitude})`})(n.geoPointValue):"arrayValue"in n?(function(t){let r="[",s=!0;for(const i of t.values||[])s?s=!1:r+=",",r+=Fo(i);return r+"]"})(n.arrayValue):"mapValue"in n?(function(t){const r=Object.keys(t.fields||{}).sort();let s="{",i=!0;for(const a of r)i?i=!1:s+=",",s+=`${a}:${Fo(t.fields[a])}`;return s+"}"})(n.mapValue):x(61005,{value:n})}function ws(n){switch(jt(n)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const e=_i(n);return e?16+ws(e):16;case 5:return 2*n.stringValue.length;case 6:return $t(n.bytesValue).approximateByteSize();case 7:return n.referenceValue.length;case 9:return(function(r){return(r.values||[]).reduce(((s,i)=>s+ws(i)),0)})(n.arrayValue);case 10:case 11:return(function(r){let s=0;return Wt(r.fields,((i,a)=>{s+=i.length+ws(a)})),s})(n.mapValue);default:throw x(13486,{value:n})}}function gu(n,e){return{referenceValue:`projects/${n.projectId}/databases/${n.database}/documents/${e.path.canonicalString()}`}}function Uo(n){return!!n&&"integerValue"in n}function Va(n){return!!n&&"arrayValue"in n}function _u(n){return!!n&&"nullValue"in n}function yu(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function Es(n){return!!n&&"mapValue"in n}function RE(n){return(n?.mapValue?.fields||{})[rf]?.stringValue===sf}function Tr(n){if(n.geoPointValue)return{geoPointValue:{...n.geoPointValue}};if(n.timestampValue&&typeof n.timestampValue=="object")return{timestampValue:{...n.timestampValue}};if(n.mapValue){const e={mapValue:{fields:{}}};return Wt(n.mapValue.fields,((t,r)=>e.mapValue.fields[t]=Tr(r))),e}if(n.arrayValue){const e={arrayValue:{values:[]}};for(let t=0;t<(n.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=Tr(n.arrayValue.values[t]);return e}return{...n}}function PE(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue===SE}class Oe{constructor(e){this.value=e}static empty(){return new Oe({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let r=0;r<e.length-1;++r)if(t=(t.mapValue.fields||{})[e.get(r)],!Es(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=Tr(t)}setAll(e){let t=ye.emptyPath(),r={},s=[];e.forEach(((a,c)=>{if(!t.isImmediateParentOf(c)){const u=this.getFieldsMap(t);this.applyChanges(u,r,s),r={},s=[],t=c.popLast()}a?r[c.lastSegment()]=Tr(a):s.push(c.lastSegment())}));const i=this.getFieldsMap(t);this.applyChanges(i,r,s)}delete(e){const t=this.field(e.popLast());Es(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return ct(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let r=0;r<e.length;++r){let s=t.mapValue.fields[e.get(r)];Es(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=s),t=s}return t.mapValue.fields}applyChanges(e,t,r){Wt(t,((s,i)=>e[s]=i));for(const s of r)delete e[s]}clone(){return new Oe(Tr(this.value))}}function of(n){const e=[];return Wt(n.fields,((t,r)=>{const s=new ye([t]);if(Es(r)){const i=of(r.mapValue).fields;if(i.length===0)e.push(s);else for(const a of i)e.push(s.child(a))}else e.push(s)})),new Ue(e)}class Ae{constructor(e,t,r,s,i,a,c){this.key=e,this.documentType=t,this.version=r,this.readTime=s,this.createTime=i,this.data=a,this.documentState=c}static newInvalidDocument(e){return new Ae(e,0,B.min(),B.min(),B.min(),Oe.empty(),0)}static newFoundDocument(e,t,r,s){return new Ae(e,1,t,B.min(),r,s,0)}static newNoDocument(e,t){return new Ae(e,2,t,B.min(),B.min(),Oe.empty(),0)}static newUnknownDocument(e,t){return new Ae(e,3,t,B.min(),B.min(),Oe.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(B.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=Oe.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Oe.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=B.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 Ae&&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 Ae(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}})`}}class Us{constructor(e,t){this.position=e,this.inclusive=t}}function Tu(n,e,t){let r=0;for(let s=0;s<n.position.length;s++){const i=e[s],a=n.position[s];if(i.field.isKeyField()?r=M.comparator(M.fromName(a.referenceValue),t.key):r=xn(a,t.data.field(i.field)),i.dir==="desc"&&(r*=-1),r!==0)break}return r}function wu(n,e){if(n===null)return e===null;if(e===null||n.inclusive!==e.inclusive||n.position.length!==e.position.length)return!1;for(let t=0;t<n.position.length;t++)if(!ct(n.position[t],e.position[t]))return!1;return!0}class Nr{constructor(e,t="asc"){this.field=e,this.dir=t}}function CE(n,e){return n.dir===e.dir&&n.field.isEqual(e.field)}class af{}class le extends af{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,r):new NE(e,t,r):t==="array-contains"?new OE(e,r):t==="in"?new LE(e,r):t==="not-in"?new ME(e,r):t==="array-contains-any"?new xE(e,r):new le(e,t,r)}static createKeyFieldInFilter(e,t,r){return t==="in"?new DE(e,r):new VE(e,r)}matches(e){const t=e.data.field(this.field);return this.op==="!="?t!==null&&t.nullValue===void 0&&this.matchesComparison(xn(t,this.value)):t!==null&&jt(this.value)===jt(t)&&this.matchesComparison(xn(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 x(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class Xe extends af{constructor(e,t){super(),this.filters=e,this.op=t,this.Pe=null}static create(e,t){return new Xe(e,t)}matches(e){return cf(this)?this.filters.find((t=>!t.matches(e)))===void 0:this.filters.find((t=>t.matches(e)))!==void 0}getFlattenedFilters(){return this.Pe!==null||(this.Pe=this.filters.reduce(((e,t)=>e.concat(t.getFlattenedFilters())),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function cf(n){return n.op==="and"}function lf(n){return kE(n)&&cf(n)}function kE(n){for(const e of n.filters)if(e instanceof Xe)return!1;return!0}function Bo(n){if(n instanceof le)return n.field.canonicalString()+n.op.toString()+Fn(n.value);if(lf(n))return n.filters.map((e=>Bo(e))).join(",");{const e=n.filters.map((t=>Bo(t))).join(",");return`${n.op}(${e})`}}function uf(n,e){return n instanceof le?(function(r,s){return s instanceof le&&r.op===s.op&&r.field.isEqual(s.field)&&ct(r.value,s.value)})(n,e):n instanceof Xe?(function(r,s){return s instanceof Xe&&r.op===s.op&&r.filters.length===s.filters.length?r.filters.reduce(((i,a,c)=>i&&uf(a,s.filters[c])),!0):!1})(n,e):void x(19439)}function hf(n){return n instanceof le?(function(t){return`${t.field.canonicalString()} ${t.op} ${Fn(t.value)}`})(n):n instanceof Xe?(function(t){return t.op.toString()+" {"+t.getFilters().map(hf).join(" ,")+"}"})(n):"Filter"}class NE extends le{constructor(e,t,r){super(e,t,r),this.key=M.fromName(r.referenceValue)}matches(e){const t=M.comparator(e.key,this.key);return this.matchesComparison(t)}}class DE extends le{constructor(e,t){super(e,"in",t),this.keys=df("in",t)}matches(e){return this.keys.some((t=>t.isEqual(e.key)))}}class VE extends le{constructor(e,t){super(e,"not-in",t),this.keys=df("not-in",t)}matches(e){return!this.keys.some((t=>t.isEqual(e.key)))}}function df(n,e){return(e.arrayValue?.values||[]).map((t=>M.fromName(t.referenceValue)))}class OE extends le{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return Va(t)&&kr(t.arrayValue,this.value)}}class LE extends le{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return t!==null&&kr(this.value.arrayValue,t)}}class ME extends le{constructor(e,t){super(e,"not-in",t)}matches(e){if(kr(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return t!==null&&t.nullValue===void 0&&!kr(this.value.arrayValue,t)}}class xE extends le{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!Va(t)||!t.arrayValue.values)&&t.arrayValue.values.some((r=>kr(this.value.arrayValue,r)))}}class FE{constructor(e,t=null,r=[],s=[],i=null,a=null,c=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=s,this.limit=i,this.startAt=a,this.endAt=c,this.Te=null}}function Eu(n,e=null,t=[],r=[],s=null,i=null,a=null){return new FE(n,e,t,r,s,i,a)}function Oa(n){const e=q(n);if(e.Te===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map((r=>Bo(r))).join(","),t+="|ob:",t+=e.orderBy.map((r=>(function(i){return i.field.canonicalString()+i.dir})(r))).join(","),gi(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((r=>Fn(r))).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((r=>Fn(r))).join(",")),e.Te=t}return e.Te}function La(n,e){if(n.limit!==e.limit||n.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<n.orderBy.length;t++)if(!CE(n.orderBy[t],e.orderBy[t]))return!1;if(n.filters.length!==e.filters.length)return!1;for(let t=0;t<n.filters.length;t++)if(!uf(n.filters[t],e.filters[t]))return!1;return n.collectionGroup===e.collectionGroup&&!!n.path.isEqual(e.path)&&!!wu(n.startAt,e.startAt)&&wu(n.endAt,e.endAt)}function qo(n){return M.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}class Kn{constructor(e,t=null,r=[],s=[],i=null,a="F",c=null,u=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=s,this.limit=i,this.limitType=a,this.startAt=c,this.endAt=u,this.Ie=null,this.Ee=null,this.Re=null,this.startAt,this.endAt}}function UE(n,e,t,r,s,i,a,c){return new Kn(n,e,t,r,s,i,a,c)}function yi(n){return new Kn(n)}function vu(n){return n.filters.length===0&&n.limit===null&&n.startAt==null&&n.endAt==null&&(n.explicitOrderBy.length===0||n.explicitOrderBy.length===1&&n.explicitOrderBy[0].field.isKeyField())}function BE(n){return M.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}function ff(n){return n.collectionGroup!==null}function wr(n){const e=q(n);if(e.Ie===null){e.Ie=[];const t=new Set;for(const i of e.explicitOrderBy)e.Ie.push(i),t.add(i.field.canonicalString());const r=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(a){let c=new de(ye.comparator);return a.filters.forEach((u=>{u.getFlattenedFilters().forEach((h=>{h.isInequality()&&(c=c.add(h.field))}))})),c})(e).forEach((i=>{t.has(i.canonicalString())||i.isKeyField()||e.Ie.push(new Nr(i,r))})),t.has(ye.keyField().canonicalString())||e.Ie.push(new Nr(ye.keyField(),r))}return e.Ie}function st(n){const e=q(n);return e.Ee||(e.Ee=qE(e,wr(n))),e.Ee}function qE(n,e){if(n.limitType==="F")return Eu(n.path,n.collectionGroup,e,n.filters,n.limit,n.startAt,n.endAt);{e=e.map((s=>{const i=s.dir==="desc"?"asc":"desc";return new Nr(s.field,i)}));const t=n.endAt?new Us(n.endAt.position,n.endAt.inclusive):null,r=n.startAt?new Us(n.startAt.position,n.startAt.inclusive):null;return Eu(n.path,n.collectionGroup,e,n.filters,n.limit,t,r)}}function $o(n,e){const t=n.filters.concat([e]);return new Kn(n.path,n.collectionGroup,n.explicitOrderBy.slice(),t,n.limit,n.limitType,n.startAt,n.endAt)}function $E(n,e){const t=n.explicitOrderBy.concat([e]);return new Kn(n.path,n.collectionGroup,t,n.filters.slice(),n.limit,n.limitType,n.startAt,n.endAt)}function Bs(n,e,t){return new Kn(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),e,t,n.startAt,n.endAt)}function Ti(n,e){return La(st(n),st(e))&&n.limitType===e.limitType}function pf(n){return`${Oa(st(n))}|lt:${n.limitType}`}function bn(n){return`Query(target=${(function(t){let r=t.path.canonicalString();return t.collectionGroup!==null&&(r+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(r+=`, filters: [${t.filters.map((s=>hf(s))).join(", ")}]`),gi(t.limit)||(r+=", limit: "+t.limit),t.orderBy.length>0&&(r+=`, orderBy: [${t.orderBy.map((s=>(function(a){return`${a.field.canonicalString()} (${a.dir})`})(s))).join(", ")}]`),t.startAt&&(r+=", startAt: ",r+=t.startAt.inclusive?"b:":"a:",r+=t.startAt.position.map((s=>Fn(s))).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map((s=>Fn(s))).join(",")),`Target(${r})`})(st(n))}; limitType=${n.limitType})`}function wi(n,e){return e.isFoundDocument()&&(function(r,s){const i=s.key.path;return r.collectionGroup!==null?s.key.hasCollectionId(r.collectionGroup)&&r.path.isPrefixOf(i):M.isDocumentKey(r.path)?r.path.isEqual(i):r.path.isImmediateParentOf(i)})(n,e)&&(function(r,s){for(const i of wr(r))if(!i.field.isKeyField()&&s.data.field(i.field)===null)return!1;return!0})(n,e)&&(function(r,s){for(const i of r.filters)if(!i.matches(s))return!1;return!0})(n,e)&&(function(r,s){return!(r.startAt&&!(function(a,c,u){const h=Tu(a,c,u);return a.inclusive?h<=0:h<0})(r.startAt,wr(r),s)||r.endAt&&!(function(a,c,u){const h=Tu(a,c,u);return a.inclusive?h>=0:h>0})(r.endAt,wr(r),s))})(n,e)}function jE(n){return n.collectionGroup||(n.path.length%2==1?n.path.lastSegment():n.path.get(n.path.length-2))}function mf(n){return(e,t)=>{let r=!1;for(const s of wr(n)){const i=zE(s,e,t);if(i!==0)return i;r=r||s.field.isKeyField()}return 0}}function zE(n,e,t){const r=n.field.isKeyField()?M.comparator(e.key,t.key):(function(i,a,c){const u=a.data.field(i),h=c.data.field(i);return u!==null&&h!==null?xn(u,h):x(42886)})(n.field,e,t);switch(n.dir){case"asc":return r;case"desc":return-1*r;default:return x(19790,{direction:n.dir})}}class Tn{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r!==void 0){for(const[s,i]of r)if(this.equalsFn(s,e))return i}}has(e){return this.get(e)!==void 0}set(e,t){const r=this.mapKeyFn(e),s=this.inner[r];if(s===void 0)return this.inner[r]=[[e,t]],void this.innerSize++;for(let i=0;i<s.length;i++)if(this.equalsFn(s[i][0],e))return void(s[i]=[e,t]);s.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r===void 0)return!1;for(let s=0;s<r.length;s++)if(this.equalsFn(r[s][0],e))return r.length===1?delete this.inner[t]:r.splice(s,1),this.innerSize--,!0;return!1}forEach(e){Wt(this.inner,((t,r)=>{for(const[s,i]of r)e(s,i)}))}isEmpty(){return Yd(this.inner)}size(){return this.innerSize}}const HE=new re(M.comparator);function Et(){return HE}const gf=new re(M.comparator);function fr(...n){let e=gf;for(const t of n)e=e.insert(t.key,t);return e}function _f(n){let e=gf;return n.forEach(((t,r)=>e=e.insert(t,r.overlayedDocument))),e}function on(){return Er()}function yf(){return Er()}function Er(){return new Tn((n=>n.toString()),((n,e)=>n.isEqual(e)))}const GE=new re(M.comparator),KE=new de(M.comparator);function K(...n){let e=KE;for(const t of n)e=e.add(t);return e}const WE=new de(G);function QE(){return WE}function Ma(n,e){if(n.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Ms(e)?"-0":e}}function Tf(n){return{integerValue:""+n}}function JE(n,e){return wE(e)?Tf(e):Ma(n,e)}class Ei{constructor(){this._=void 0}}function YE(n,e,t){return n instanceof qs?(function(s,i){const a={fields:{[ef]:{stringValue:Zd},[nf]:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return i&&Da(i)&&(i=_i(i)),i&&(a.fields[tf]=i),{mapValue:a}})(t,e):n instanceof Dr?Ef(n,e):n instanceof Vr?vf(n,e):(function(s,i){const a=wf(s,i),c=Iu(a)+Iu(s.Ae);return Uo(a)&&Uo(s.Ae)?Tf(c):Ma(s.serializer,c)})(n,e)}function XE(n,e,t){return n instanceof Dr?Ef(n,e):n instanceof Vr?vf(n,e):t}function wf(n,e){return n instanceof $s?(function(r){return Uo(r)||(function(i){return!!i&&"doubleValue"in i})(r)})(e)?e:{integerValue:0}:null}class qs extends Ei{}class Dr extends Ei{constructor(e){super(),this.elements=e}}function Ef(n,e){const t=If(e);for(const r of n.elements)t.some((s=>ct(s,r)))||t.push(r);return{arrayValue:{values:t}}}class Vr extends Ei{constructor(e){super(),this.elements=e}}function vf(n,e){let t=If(e);for(const r of n.elements)t=t.filter((s=>!ct(s,r)));return{arrayValue:{values:t}}}class $s extends Ei{constructor(e,t){super(),this.serializer=e,this.Ae=t}}function Iu(n){return ae(n.integerValue||n.doubleValue)}function If(n){return Va(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}function ZE(n,e){return n.field.isEqual(e.field)&&(function(r,s){return r instanceof Dr&&s instanceof Dr||r instanceof Vr&&s instanceof Vr?Mn(r.elements,s.elements,ct):r instanceof $s&&s instanceof $s?ct(r.Ae,s.Ae):r instanceof qs&&s instanceof qs})(n.transform,e.transform)}class ev{constructor(e,t){this.version=e,this.transformResults=t}}class Je{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Je}static exists(e){return new Je(void 0,e)}static updateTime(e){return new Je(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 vs(n,e){return n.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(n.updateTime):n.exists===void 0||n.exists===e.isFoundDocument()}class vi{}function Af(n,e){if(!n.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return n.isNoDocument()?new xa(n.key,Je.none()):new qr(n.key,n.data,Je.none());{const t=n.data,r=Oe.empty();let s=new de(ye.comparator);for(let i of e.fields)if(!s.has(i)){let a=t.field(i);a===null&&i.length>1&&(i=i.popLast(),a=t.field(i)),a===null?r.delete(i):r.set(i,a),s=s.add(i)}return new Qt(n.key,r,new Ue(s.toArray()),Je.none())}}function tv(n,e,t){n instanceof qr?(function(s,i,a){const c=s.value.clone(),u=bu(s.fieldTransforms,i,a.transformResults);c.setAll(u),i.convertToFoundDocument(a.version,c).setHasCommittedMutations()})(n,e,t):n instanceof Qt?(function(s,i,a){if(!vs(s.precondition,i))return void i.convertToUnknownDocument(a.version);const c=bu(s.fieldTransforms,i,a.transformResults),u=i.data;u.setAll(bf(s)),u.setAll(c),i.convertToFoundDocument(a.version,u).setHasCommittedMutations()})(n,e,t):(function(s,i,a){i.convertToNoDocument(a.version).setHasCommittedMutations()})(0,e,t)}function vr(n,e,t,r){return n instanceof qr?(function(i,a,c,u){if(!vs(i.precondition,a))return c;const h=i.value.clone(),f=Su(i.fieldTransforms,u,a);return h.setAll(f),a.convertToFoundDocument(a.version,h).setHasLocalMutations(),null})(n,e,t,r):n instanceof Qt?(function(i,a,c,u){if(!vs(i.precondition,a))return c;const h=Su(i.fieldTransforms,u,a),f=a.data;return f.setAll(bf(i)),f.setAll(h),a.convertToFoundDocument(a.version,f).setHasLocalMutations(),c===null?null:c.unionWith(i.fieldMask.fields).unionWith(i.fieldTransforms.map((m=>m.field)))})(n,e,t,r):(function(i,a,c){return vs(i.precondition,a)?(a.convertToNoDocument(a.version).setHasLocalMutations(),null):c})(n,e,t)}function nv(n,e){let t=null;for(const r of n.fieldTransforms){const s=e.data.field(r.field),i=wf(r.transform,s||null);i!=null&&(t===null&&(t=Oe.empty()),t.set(r.field,i))}return t||null}function Au(n,e){return n.type===e.type&&!!n.key.isEqual(e.key)&&!!n.precondition.isEqual(e.precondition)&&!!(function(r,s){return r===void 0&&s===void 0||!(!r||!s)&&Mn(r,s,((i,a)=>ZE(i,a)))})(n.fieldTransforms,e.fieldTransforms)&&(n.type===0?n.value.isEqual(e.value):n.type!==1||n.data.isEqual(e.data)&&n.fieldMask.isEqual(e.fieldMask))}class qr extends vi{constructor(e,t,r,s=[]){super(),this.key=e,this.value=t,this.precondition=r,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}}class Qt extends vi{constructor(e,t,r,s,i=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=s,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function bf(n){const e=new Map;return n.fieldMask.fields.forEach((t=>{if(!t.isEmpty()){const r=n.data.field(t);e.set(t,r)}})),e}function bu(n,e,t){const r=new Map;Y(n.length===t.length,32656,{Ve:t.length,de:n.length});for(let s=0;s<t.length;s++){const i=n[s],a=i.transform,c=e.data.field(i.field);r.set(i.field,XE(a,c,t[s]))}return r}function Su(n,e,t){const r=new Map;for(const s of n){const i=s.transform,a=t.data.field(s.field);r.set(s.field,YE(i,a,e))}return r}class xa extends vi{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class rv extends vi{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class sv{constructor(e,t,r,s){this.batchId=e,this.localWriteTime=t,this.baseMutations=r,this.mutations=s}applyToRemoteDocument(e,t){const r=t.mutationResults;for(let s=0;s<this.mutations.length;s++){const i=this.mutations[s];i.key.isEqual(e.key)&&tv(i,e,r[s])}}applyToLocalView(e,t){for(const r of this.baseMutations)r.key.isEqual(e.key)&&(t=vr(r,e,t,this.localWriteTime));for(const r of this.mutations)r.key.isEqual(e.key)&&(t=vr(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const r=yf();return this.mutations.forEach((s=>{const i=e.get(s.key),a=i.overlayedDocument;let c=this.applyToLocalView(a,i.mutatedFields);c=t.has(s.key)?null:c;const u=Af(a,c);u!==null&&r.set(s.key,u),a.isValidDocument()||a.convertToNoDocument(B.min())})),r}keys(){return this.mutations.reduce(((e,t)=>e.add(t.key)),K())}isEqual(e){return this.batchId===e.batchId&&Mn(this.mutations,e.mutations,((t,r)=>Au(t,r)))&&Mn(this.baseMutations,e.baseMutations,((t,r)=>Au(t,r)))}}class Fa{constructor(e,t,r,s){this.batch=e,this.commitVersion=t,this.mutationResults=r,this.docVersions=s}static from(e,t,r){Y(e.mutations.length===r.length,58842,{me:e.mutations.length,fe:r.length});let s=(function(){return GE})();const i=e.mutations;for(let a=0;a<i.length;a++)s=s.insert(i[a].key,r[a].version);return new Fa(e,t,r,s)}}class iv{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{
24
+ largestBatchId: ${this.largestBatchId},
25
+ mutation: ${this.mutation.toString()}
26
+ }`}}class ov{constructor(e,t){this.count=e,this.unchangedNames=t}}var ce,J;function av(n){switch(n){case P.OK:return x(64938);case P.CANCELLED:case P.UNKNOWN:case P.DEADLINE_EXCEEDED:case P.RESOURCE_EXHAUSTED:case P.INTERNAL:case P.UNAVAILABLE:case P.UNAUTHENTICATED:return!1;case P.INVALID_ARGUMENT:case P.NOT_FOUND:case P.ALREADY_EXISTS:case P.PERMISSION_DENIED:case P.FAILED_PRECONDITION:case P.ABORTED:case P.OUT_OF_RANGE:case P.UNIMPLEMENTED:case P.DATA_LOSS:return!0;default:return x(15467,{code:n})}}function Sf(n){if(n===void 0)return wt("GRPC error has no .code"),P.UNKNOWN;switch(n){case ce.OK:return P.OK;case ce.CANCELLED:return P.CANCELLED;case ce.UNKNOWN:return P.UNKNOWN;case ce.DEADLINE_EXCEEDED:return P.DEADLINE_EXCEEDED;case ce.RESOURCE_EXHAUSTED:return P.RESOURCE_EXHAUSTED;case ce.INTERNAL:return P.INTERNAL;case ce.UNAVAILABLE:return P.UNAVAILABLE;case ce.UNAUTHENTICATED:return P.UNAUTHENTICATED;case ce.INVALID_ARGUMENT:return P.INVALID_ARGUMENT;case ce.NOT_FOUND:return P.NOT_FOUND;case ce.ALREADY_EXISTS:return P.ALREADY_EXISTS;case ce.PERMISSION_DENIED:return P.PERMISSION_DENIED;case ce.FAILED_PRECONDITION:return P.FAILED_PRECONDITION;case ce.ABORTED:return P.ABORTED;case ce.OUT_OF_RANGE:return P.OUT_OF_RANGE;case ce.UNIMPLEMENTED:return P.UNIMPLEMENTED;case ce.DATA_LOSS:return P.DATA_LOSS;default:return x(39323,{code:n})}}(J=ce||(ce={}))[J.OK=0]="OK",J[J.CANCELLED=1]="CANCELLED",J[J.UNKNOWN=2]="UNKNOWN",J[J.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",J[J.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",J[J.NOT_FOUND=5]="NOT_FOUND",J[J.ALREADY_EXISTS=6]="ALREADY_EXISTS",J[J.PERMISSION_DENIED=7]="PERMISSION_DENIED",J[J.UNAUTHENTICATED=16]="UNAUTHENTICATED",J[J.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",J[J.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",J[J.ABORTED=10]="ABORTED",J[J.OUT_OF_RANGE=11]="OUT_OF_RANGE",J[J.UNIMPLEMENTED=12]="UNIMPLEMENTED",J[J.INTERNAL=13]="INTERNAL",J[J.UNAVAILABLE=14]="UNAVAILABLE",J[J.DATA_LOSS=15]="DATA_LOSS";function cv(){return new TextEncoder}const lv=new xt([4294967295,4294967295],0);function Ru(n){const e=cv().encode(n),t=new Bd;return t.update(e),new Uint8Array(t.digest())}function Pu(n){const e=new DataView(n.buffer),t=e.getUint32(0,!0),r=e.getUint32(4,!0),s=e.getUint32(8,!0),i=e.getUint32(12,!0);return[new xt([t,r],0),new xt([s,i],0)]}class Ua{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||t>=8)throw new pr(`Invalid padding: ${t}`);if(r<0)throw new pr(`Invalid hash count: ${r}`);if(e.length>0&&this.hashCount===0)throw new pr(`Invalid hash count: ${r}`);if(e.length===0&&t!==0)throw new pr(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.pe=xt.fromNumber(this.ge)}ye(e,t,r){let s=e.add(t.multiply(xt.fromNumber(r)));return s.compare(lv)===1&&(s=new xt([s.getBits(0),s.getBits(1)],0)),s.modulo(this.pe).toNumber()}we(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.ge===0)return!1;const t=Ru(e),[r,s]=Pu(t);for(let i=0;i<this.hashCount;i++){const a=this.ye(r,s,i);if(!this.we(a))return!1}return!0}static create(e,t,r){const s=e%8==0?0:8-e%8,i=new Uint8Array(Math.ceil(e/8)),a=new Ua(i,s,t);return r.forEach((c=>a.insert(c))),a}insert(e){if(this.ge===0)return;const t=Ru(e),[r,s]=Pu(t);for(let i=0;i<this.hashCount;i++){const a=this.ye(r,s,i);this.be(a)}}be(e){const t=Math.floor(e/8),r=e%8;this.bitmap[t]|=1<<r}}class pr extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class Ii{constructor(e,t,r,s,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=s,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,r){const s=new Map;return s.set(e,$r.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new Ii(B.min(),s,new re(G),Et(),K())}}class $r{constructor(e,t,r,s,i){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=s,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new $r(r,t,K(),K(),K())}}class Is{constructor(e,t,r,s){this.Se=e,this.removedTargetIds=t,this.key=r,this.De=s}}class Rf{constructor(e,t){this.targetId=e,this.Ce=t}}class Pf{constructor(e,t,r=Te.EMPTY_BYTE_STRING,s=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=s}}class Cu{constructor(){this.ve=0,this.Fe=ku(),this.Me=Te.EMPTY_BYTE_STRING,this.xe=!1,this.Oe=!0}get current(){return this.xe}get resumeToken(){return this.Me}get Ne(){return this.ve!==0}get Be(){return this.Oe}Le(e){e.approximateByteSize()>0&&(this.Oe=!0,this.Me=e)}ke(){let e=K(),t=K(),r=K();return this.Fe.forEach(((s,i)=>{switch(i){case 0:e=e.add(s);break;case 2:t=t.add(s);break;case 1:r=r.add(s);break;default:x(38017,{changeType:i})}})),new $r(this.Me,this.xe,e,t,r)}Ke(){this.Oe=!1,this.Fe=ku()}qe(e,t){this.Oe=!0,this.Fe=this.Fe.insert(e,t)}Ue(e){this.Oe=!0,this.Fe=this.Fe.remove(e)}$e(){this.ve+=1}We(){this.ve-=1,Y(this.ve>=0,3241,{ve:this.ve})}Qe(){this.Oe=!0,this.xe=!0}}class uv{constructor(e){this.Ge=e,this.ze=new Map,this.je=Et(),this.He=ds(),this.Je=ds(),this.Ze=new re(G)}Xe(e){for(const t of e.Se)e.De&&e.De.isFoundDocument()?this.Ye(t,e.De):this.et(t,e.key,e.De);for(const t of e.removedTargetIds)this.et(t,e.key,e.De)}tt(e){this.forEachTarget(e,(t=>{const r=this.nt(t);switch(e.state){case 0:this.rt(t)&&r.Le(e.resumeToken);break;case 1:r.We(),r.Ne||r.Ke(),r.Le(e.resumeToken);break;case 2:r.We(),r.Ne||this.removeTarget(t);break;case 3:this.rt(t)&&(r.Qe(),r.Le(e.resumeToken));break;case 4:this.rt(t)&&(this.it(t),r.Le(e.resumeToken));break;default:x(56790,{state:e.state})}}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.ze.forEach(((r,s)=>{this.rt(s)&&t(s)}))}st(e){const t=e.targetId,r=e.Ce.count,s=this.ot(t);if(s){const i=s.target;if(qo(i))if(r===0){const a=new M(i.path);this.et(t,a,Ae.newNoDocument(a,B.min()))}else Y(r===1,20013,{expectedCount:r});else{const a=this._t(t);if(a!==r){const c=this.ut(e),u=c?this.ct(c,e,a):1;if(u!==0){this.it(t);const h=u===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ze=this.Ze.insert(t,h)}}}}}ut(e){const t=e.Ce.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:r="",padding:s=0},hashCount:i=0}=t;let a,c;try{a=$t(r).toUint8Array()}catch(u){if(u instanceof Xd)return Ln("Decoding the base64 bloom filter in existence filter failed ("+u.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw u}try{c=new Ua(a,s,i)}catch(u){return Ln(u instanceof pr?"BloomFilter error: ":"Applying bloom filter failed: ",u),null}return c.ge===0?null:c}ct(e,t,r){return t.Ce.count===r-this.Pt(e,t.targetId)?0:2}Pt(e,t){const r=this.Ge.getRemoteKeysForTarget(t);let s=0;return r.forEach((i=>{const a=this.Ge.ht(),c=`projects/${a.projectId}/databases/${a.database}/documents/${i.path.canonicalString()}`;e.mightContain(c)||(this.et(t,i,null),s++)})),s}Tt(e){const t=new Map;this.ze.forEach(((i,a)=>{const c=this.ot(a);if(c){if(i.current&&qo(c.target)){const u=new M(c.target.path);this.It(u).has(a)||this.Et(a,u)||this.et(a,u,Ae.newNoDocument(u,e))}i.Be&&(t.set(a,i.ke()),i.Ke())}}));let r=K();this.Je.forEach(((i,a)=>{let c=!0;a.forEachWhile((u=>{const h=this.ot(u);return!h||h.purpose==="TargetPurposeLimboResolution"||(c=!1,!1)})),c&&(r=r.add(i))})),this.je.forEach(((i,a)=>a.setReadTime(e)));const s=new Ii(e,t,this.Ze,this.je,r);return this.je=Et(),this.He=ds(),this.Je=ds(),this.Ze=new re(G),s}Ye(e,t){if(!this.rt(e))return;const r=this.Et(e,t.key)?2:0;this.nt(e).qe(t.key,r),this.je=this.je.insert(t.key,t),this.He=this.He.insert(t.key,this.It(t.key).add(e)),this.Je=this.Je.insert(t.key,this.Rt(t.key).add(e))}et(e,t,r){if(!this.rt(e))return;const s=this.nt(e);this.Et(e,t)?s.qe(t,1):s.Ue(t),this.Je=this.Je.insert(t,this.Rt(t).delete(e)),this.Je=this.Je.insert(t,this.Rt(t).add(e)),r&&(this.je=this.je.insert(t,r))}removeTarget(e){this.ze.delete(e)}_t(e){const t=this.nt(e).ke();return this.Ge.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}$e(e){this.nt(e).$e()}nt(e){let t=this.ze.get(e);return t||(t=new Cu,this.ze.set(e,t)),t}Rt(e){let t=this.Je.get(e);return t||(t=new de(G),this.Je=this.Je.insert(e,t)),t}It(e){let t=this.He.get(e);return t||(t=new de(G),this.He=this.He.insert(e,t)),t}rt(e){const t=this.ot(e)!==null;return t||L("WatchChangeAggregator","Detected inactive target",e),t}ot(e){const t=this.ze.get(e);return t&&t.Ne?null:this.Ge.At(e)}it(e){this.ze.set(e,new Cu),this.Ge.getRemoteKeysForTarget(e).forEach((t=>{this.et(e,t,null)}))}Et(e,t){return this.Ge.getRemoteKeysForTarget(e).has(t)}}function ds(){return new re(M.comparator)}function ku(){return new re(M.comparator)}const hv={asc:"ASCENDING",desc:"DESCENDING"},dv={"<":"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"},fv={and:"AND",or:"OR"};class pv{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function jo(n,e){return n.useProto3Json||gi(e)?e:{value:e}}function js(n,e){return n.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function Cf(n,e){return n.useProto3Json?e.toBase64():e.toUint8Array()}function mv(n,e){return js(n,e.toTimestamp())}function it(n){return Y(!!n,49232),B.fromTimestamp((function(t){const r=qt(t);return new z(r.seconds,r.nanos)})(n))}function Ba(n,e){return zo(n,e).canonicalString()}function zo(n,e){const t=(function(s){return new Z(["projects",s.projectId,"databases",s.database])})(n).child("documents");return e===void 0?t:t.child(e)}function kf(n){const e=Z.fromString(n);return Y(Lf(e),10190,{key:e.toString()}),e}function Ho(n,e){return Ba(n.databaseId,e.path)}function mo(n,e){const t=kf(e);if(t.get(1)!==n.databaseId.projectId)throw new O(P.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+n.databaseId.projectId);if(t.get(3)!==n.databaseId.database)throw new O(P.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+n.databaseId.database);return new M(Df(t))}function Nf(n,e){return Ba(n.databaseId,e)}function gv(n){const e=kf(n);return e.length===4?Z.emptyPath():Df(e)}function Go(n){return new Z(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function Df(n){return Y(n.length>4&&n.get(4)==="documents",29091,{key:n.toString()}),n.popFirst(5)}function Nu(n,e,t){return{name:Ho(n,e),fields:t.value.mapValue.fields}}function _v(n,e){let t;if("targetChange"in e){e.targetChange;const r=(function(h){return h==="NO_CHANGE"?0:h==="ADD"?1:h==="REMOVE"?2:h==="CURRENT"?3:h==="RESET"?4:x(39313,{state:h})})(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],i=(function(h,f){return h.useProto3Json?(Y(f===void 0||typeof f=="string",58123),Te.fromBase64String(f||"")):(Y(f===void 0||f instanceof Buffer||f instanceof Uint8Array,16193),Te.fromUint8Array(f||new Uint8Array))})(n,e.targetChange.resumeToken),a=e.targetChange.cause,c=a&&(function(h){const f=h.code===void 0?P.UNKNOWN:Sf(h.code);return new O(f,h.message||"")})(a);t=new Pf(r,s,i,c||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const s=mo(n,r.document.name),i=it(r.document.updateTime),a=r.document.createTime?it(r.document.createTime):B.min(),c=new Oe({mapValue:{fields:r.document.fields}}),u=Ae.newFoundDocument(s,i,a,c),h=r.targetIds||[],f=r.removedTargetIds||[];t=new Is(h,f,u.key,u)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const s=mo(n,r.document),i=r.readTime?it(r.readTime):B.min(),a=Ae.newNoDocument(s,i),c=r.removedTargetIds||[];t=new Is([],c,a.key,a)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const s=mo(n,r.document),i=r.removedTargetIds||[];t=new Is([],i,s,null)}else{if(!("filter"in e))return x(11601,{Vt:e});{e.filter;const r=e.filter;r.targetId;const{count:s=0,unchangedNames:i}=r,a=new ov(s,i),c=r.targetId;t=new Rf(c,a)}}return t}function yv(n,e){let t;if(e instanceof qr)t={update:Nu(n,e.key,e.value)};else if(e instanceof xa)t={delete:Ho(n,e.key)};else if(e instanceof Qt)t={update:Nu(n,e.key,e.data),updateMask:Rv(e.fieldMask)};else{if(!(e instanceof rv))return x(16599,{dt:e.type});t={verify:Ho(n,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map((r=>(function(i,a){const c=a.transform;if(c instanceof qs)return{fieldPath:a.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(c instanceof Dr)return{fieldPath:a.field.canonicalString(),appendMissingElements:{values:c.elements}};if(c instanceof Vr)return{fieldPath:a.field.canonicalString(),removeAllFromArray:{values:c.elements}};if(c instanceof $s)return{fieldPath:a.field.canonicalString(),increment:c.Ae};throw x(20930,{transform:a.transform})})(0,r)))),e.precondition.isNone||(t.currentDocument=(function(s,i){return i.updateTime!==void 0?{updateTime:mv(s,i.updateTime)}:i.exists!==void 0?{exists:i.exists}:x(27497)})(n,e.precondition)),t}function Tv(n,e){return n&&n.length>0?(Y(e!==void 0,14353),n.map((t=>(function(s,i){let a=s.updateTime?it(s.updateTime):it(i);return a.isEqual(B.min())&&(a=it(i)),new ev(a,s.transformResults||[])})(t,e)))):[]}function wv(n,e){return{documents:[Nf(n,e.path)]}}function Ev(n,e){const t={structuredQuery:{}},r=e.path;let s;e.collectionGroup!==null?(s=r,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(s=r.popLast(),t.structuredQuery.from=[{collectionId:r.lastSegment()}]),t.parent=Nf(n,s);const i=(function(h){if(h.length!==0)return Of(Xe.create(h,"and"))})(e.filters);i&&(t.structuredQuery.where=i);const a=(function(h){if(h.length!==0)return h.map((f=>(function(y){return{field:Sn(y.field),direction:Av(y.dir)}})(f)))})(e.orderBy);a&&(t.structuredQuery.orderBy=a);const c=jo(n,e.limit);return c!==null&&(t.structuredQuery.limit=c),e.startAt&&(t.structuredQuery.startAt=(function(h){return{before:h.inclusive,values:h.position}})(e.startAt)),e.endAt&&(t.structuredQuery.endAt=(function(h){return{before:!h.inclusive,values:h.position}})(e.endAt)),{ft:t,parent:s}}function vv(n){let e=gv(n.parent);const t=n.structuredQuery,r=t.from?t.from.length:0;let s=null;if(r>0){Y(r===1,65062);const f=t.from[0];f.allDescendants?s=f.collectionId:e=e.child(f.collectionId)}let i=[];t.where&&(i=(function(m){const y=Vf(m);return y instanceof Xe&&lf(y)?y.getFilters():[y]})(t.where));let a=[];t.orderBy&&(a=(function(m){return m.map((y=>(function(k){return new Nr(Rn(k.field),(function(N){switch(N){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}})(k.direction))})(y)))})(t.orderBy));let c=null;t.limit&&(c=(function(m){let y;return y=typeof m=="object"?m.value:m,gi(y)?null:y})(t.limit));let u=null;t.startAt&&(u=(function(m){const y=!!m.before,S=m.values||[];return new Us(S,y)})(t.startAt));let h=null;return t.endAt&&(h=(function(m){const y=!m.before,S=m.values||[];return new Us(S,y)})(t.endAt)),UE(e,s,a,i,c,"F",u,h)}function Iv(n,e){const 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 x(28987,{purpose:s})}})(e.purpose);return t==null?null:{"goog-listen-tags":t}}function Vf(n){return n.unaryFilter!==void 0?(function(t){switch(t.unaryFilter.op){case"IS_NAN":const r=Rn(t.unaryFilter.field);return le.create(r,"==",{doubleValue:NaN});case"IS_NULL":const s=Rn(t.unaryFilter.field);return le.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const i=Rn(t.unaryFilter.field);return le.create(i,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const a=Rn(t.unaryFilter.field);return le.create(a,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return x(61313);default:return x(60726)}})(n):n.fieldFilter!==void 0?(function(t){return le.create(Rn(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";case"OPERATOR_UNSPECIFIED":return x(58110);default:return x(50506)}})(t.fieldFilter.op),t.fieldFilter.value)})(n):n.compositeFilter!==void 0?(function(t){return Xe.create(t.compositeFilter.filters.map((r=>Vf(r))),(function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return x(1026)}})(t.compositeFilter.op))})(n):x(30097,{filter:n})}function Av(n){return hv[n]}function bv(n){return dv[n]}function Sv(n){return fv[n]}function Sn(n){return{fieldPath:n.canonicalString()}}function Rn(n){return ye.fromServerFormat(n.fieldPath)}function Of(n){return n instanceof le?(function(t){if(t.op==="=="){if(yu(t.value))return{unaryFilter:{field:Sn(t.field),op:"IS_NAN"}};if(_u(t.value))return{unaryFilter:{field:Sn(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(yu(t.value))return{unaryFilter:{field:Sn(t.field),op:"IS_NOT_NAN"}};if(_u(t.value))return{unaryFilter:{field:Sn(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Sn(t.field),op:bv(t.op),value:t.value}}})(n):n instanceof Xe?(function(t){const r=t.getFilters().map((s=>Of(s)));return r.length===1?r[0]:{compositeFilter:{op:Sv(t.op),filters:r}}})(n):x(54877,{filter:n})}function Rv(n){const e=[];return n.fields.forEach((t=>e.push(t.canonicalString()))),{fieldPaths:e}}function Lf(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}function Mf(n){return!!n&&typeof n._toProto=="function"&&n._protoValueType==="ProtoValue"}class Lt{constructor(e,t,r,s,i=B.min(),a=B.min(),c=Te.EMPTY_BYTE_STRING,u=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=s,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=a,this.resumeToken=c,this.expectedCount=u}withSequenceNumber(e){return new Lt(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new Lt(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new Lt(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new Lt(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class Pv{constructor(e){this.yt=e}}function Cv(n){const e=vv({parent:n.parent,structuredQuery:n.structuredQuery});return n.limitType==="LAST"?Bs(e,e.limit,"L"):e}class kv{constructor(){this.Sn=new Nv}addToCollectionParentIndex(e,t){return this.Sn.add(t),C.resolve()}getCollectionParents(e,t){return C.resolve(this.Sn.getEntries(t))}addFieldIndex(e,t){return C.resolve()}deleteFieldIndex(e,t){return C.resolve()}deleteAllFieldIndexes(e){return C.resolve()}createTargetIndexes(e,t){return C.resolve()}getDocumentsMatchingTarget(e,t){return C.resolve(null)}getIndexType(e,t){return C.resolve(0)}getFieldIndexes(e,t){return C.resolve([])}getNextCollectionGroupToUpdate(e){return C.resolve(null)}getMinOffset(e,t){return C.resolve(Bt.min())}getMinOffsetFromCollectionGroup(e,t){return C.resolve(Bt.min())}updateCollectionGroup(e,t,r){return C.resolve()}updateIndexEntries(e,t){return C.resolve()}}class Nv{constructor(){this.index={}}add(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t]||new de(Z.comparator),i=!s.has(r);return this.index[t]=s.add(r),i}has(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t];return s&&s.has(r)}getEntries(e){return(this.index[e]||new de(Z.comparator)).toArray()}}const Du={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},xf=41943040;class Ve{static withCacheSize(e){return new Ve(e,Ve.DEFAULT_COLLECTION_PERCENTILE,Ve.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}}Ve.DEFAULT_COLLECTION_PERCENTILE=10,Ve.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Ve.DEFAULT=new Ve(xf,Ve.DEFAULT_COLLECTION_PERCENTILE,Ve.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Ve.DISABLED=new Ve(-1,0,0);class Un{constructor(e){this.sr=e}next(){return this.sr+=2,this.sr}static _r(){return new Un(0)}static ar(){return new Un(-1)}}const Vu="LruGarbageCollector",Dv=1048576;function Ou([n,e],[t,r]){const s=G(n,t);return s===0?G(e,r):s}class Vv{constructor(e){this.Pr=e,this.buffer=new de(Ou),this.Tr=0}Ir(){return++this.Tr}Er(e){const t=[e,this.Ir()];if(this.buffer.size<this.Pr)this.buffer=this.buffer.add(t);else{const r=this.buffer.last();Ou(t,r)<0&&(this.buffer=this.buffer.delete(r).add(t))}}get maxValue(){return this.buffer.last()[0]}}class Ov{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.Rr=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Ar(6e4)}stop(){this.Rr&&(this.Rr.cancel(),this.Rr=null)}get started(){return this.Rr!==null}Ar(e){L(Vu,`Garbage collection scheduled in ${e}ms`),this.Rr=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,(async()=>{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){Gn(t)?L(Vu,"Ignoring IndexedDB error during garbage collection: ",t):await Hn(t)}await this.Ar(3e5)}))}}class Lv{constructor(e,t){this.Vr=e,this.params=t}calculateTargetCount(e,t){return this.Vr.dr(e).next((r=>Math.floor(t/100*r)))}nthSequenceNumber(e,t){if(t===0)return C.resolve(mi.ce);const r=new Vv(t);return this.Vr.forEachTarget(e,(s=>r.Er(s.sequenceNumber))).next((()=>this.Vr.mr(e,(s=>r.Er(s))))).next((()=>r.maxValue))}removeTargets(e,t,r){return this.Vr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.Vr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(L("LruGarbageCollector","Garbage collection skipped; disabled"),C.resolve(Du)):this.getCacheSize(e).next((r=>r<this.params.cacheSizeCollectionThreshold?(L("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Du):this.gr(e,t)))}getCacheSize(e){return this.Vr.getCacheSize(e)}gr(e,t){let r,s,i,a,c,u,h;const f=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next((m=>(m>this.params.maximumSequenceNumbersToCollect?(L("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${m}`),s=this.params.maximumSequenceNumbersToCollect):s=m,a=Date.now(),this.nthSequenceNumber(e,s)))).next((m=>(r=m,c=Date.now(),this.removeTargets(e,r,t)))).next((m=>(i=m,u=Date.now(),this.removeOrphanedDocuments(e,r)))).next((m=>(h=Date.now(),An()<=H.DEBUG&&L("LruGarbageCollector",`LRU Garbage Collection
27
+ Counted targets in ${a-f}ms
28
+ Determined least recently used ${s} in `+(c-a)+`ms
29
+ Removed ${i} targets in `+(u-c)+`ms
30
+ Removed ${m} documents in `+(h-u)+`ms
31
+ Total Duration: ${h-f}ms`),C.resolve({didRun:!0,sequenceNumbersCollected:s,targetsRemoved:i,documentsRemoved:m}))))}}function Mv(n,e){return new Lv(n,e)}class xv{constructor(){this.changes=new Tn((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,Ae.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const r=this.changes.get(t);return r!==void 0?C.resolve(r):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}class Fv{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class Uv{constructor(e,t,r,s){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=s}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next((s=>(r=s,this.remoteDocumentCache.getEntry(e,t)))).next((s=>(r!==null&&vr(r.mutation,s,Ue.empty(),z.now()),s)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((r=>this.getLocalViewOfDocuments(e,r,K()).next((()=>r))))}getLocalViewOfDocuments(e,t,r=K()){const s=on();return this.populateOverlays(e,s,t).next((()=>this.computeViews(e,t,s,r).next((i=>{let a=fr();return i.forEach(((c,u)=>{a=a.insert(c,u.overlayedDocument)})),a}))))}getOverlayedDocuments(e,t){const r=on();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,K())))}populateOverlays(e,t,r){const s=[];return r.forEach((i=>{t.has(i)||s.push(i)})),this.documentOverlayCache.getOverlays(e,s).next((i=>{i.forEach(((a,c)=>{t.set(a,c)}))}))}computeViews(e,t,r,s){let i=Et();const a=Er(),c=(function(){return Er()})();return t.forEach(((u,h)=>{const f=r.get(h.key);s.has(h.key)&&(f===void 0||f.mutation instanceof Qt)?i=i.insert(h.key,h):f!==void 0?(a.set(h.key,f.mutation.getFieldMask()),vr(f.mutation,h,f.mutation.getFieldMask(),z.now())):a.set(h.key,Ue.empty())})),this.recalculateAndSaveOverlays(e,i).next((u=>(u.forEach(((h,f)=>a.set(h,f))),t.forEach(((h,f)=>c.set(h,new Fv(f,a.get(h)??null)))),c)))}recalculateAndSaveOverlays(e,t){const r=Er();let s=new re(((a,c)=>a-c)),i=K();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next((a=>{for(const c of a)c.keys().forEach((u=>{const h=t.get(u);if(h===null)return;let f=r.get(u)||Ue.empty();f=c.applyToLocalView(h,f),r.set(u,f);const m=(s.get(c.batchId)||K()).add(u);s=s.insert(c.batchId,m)}))})).next((()=>{const a=[],c=s.getReverseIterator();for(;c.hasNext();){const u=c.getNext(),h=u.key,f=u.value,m=yf();f.forEach((y=>{if(!i.has(y)){const S=Af(t.get(y),r.get(y));S!==null&&m.set(y,S),i=i.add(y)}})),a.push(this.documentOverlayCache.saveOverlays(e,h,m))}return C.waitFor(a)})).next((()=>r))}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next((r=>this.recalculateAndSaveOverlays(e,r)))}getDocumentsMatchingQuery(e,t,r,s){return BE(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):ff(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,s):this.getDocumentsMatchingCollectionQuery(e,t,r,s)}getNextDocuments(e,t,r,s){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,r,s).next((i=>{const a=s-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,s-i.size):C.resolve(on());let c=Rr,u=i;return a.next((h=>C.forEach(h,((f,m)=>(c<m.largestBatchId&&(c=m.largestBatchId),i.get(f)?C.resolve():this.remoteDocumentCache.getEntry(e,f).next((y=>{u=u.insert(f,y)}))))).next((()=>this.populateOverlays(e,h,i))).next((()=>this.computeViews(e,u,h,K()))).next((f=>({batchId:c,changes:_f(f)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new M(t)).next((r=>{let s=fr();return r.isFoundDocument()&&(s=s.insert(r.key,r)),s}))}getDocumentsMatchingCollectionGroupQuery(e,t,r,s){const i=t.collectionGroup;let a=fr();return this.indexManager.getCollectionParents(e,i).next((c=>C.forEach(c,(u=>{const h=(function(m,y){return new Kn(y,null,m.explicitOrderBy.slice(),m.filters.slice(),m.limit,m.limitType,m.startAt,m.endAt)})(t,u.child(i));return this.getDocumentsMatchingCollectionQuery(e,h,r,s).next((f=>{f.forEach(((m,y)=>{a=a.insert(m,y)}))}))})).next((()=>a))))}getDocumentsMatchingCollectionQuery(e,t,r,s){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next((a=>(i=a,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,i,s)))).next((a=>{i.forEach(((u,h)=>{const f=h.getKey();a.get(f)===null&&(a=a.insert(f,Ae.newInvalidDocument(f)))}));let c=fr();return a.forEach(((u,h)=>{const f=i.get(u);f!==void 0&&vr(f.mutation,h,Ue.empty(),z.now()),wi(t,h)&&(c=c.insert(u,h))})),c}))}}class Bv{constructor(e){this.serializer=e,this.Nr=new Map,this.Br=new Map}getBundleMetadata(e,t){return C.resolve(this.Nr.get(t))}saveBundleMetadata(e,t){return this.Nr.set(t.id,(function(s){return{id:s.id,version:s.version,createTime:it(s.createTime)}})(t)),C.resolve()}getNamedQuery(e,t){return C.resolve(this.Br.get(t))}saveNamedQuery(e,t){return this.Br.set(t.name,(function(s){return{name:s.name,query:Cv(s.bundledQuery),readTime:it(s.readTime)}})(t)),C.resolve()}}class qv{constructor(){this.overlays=new re(M.comparator),this.Lr=new Map}getOverlay(e,t){return C.resolve(this.overlays.get(t))}getOverlays(e,t){const r=on();return C.forEach(t,(s=>this.getOverlay(e,s).next((i=>{i!==null&&r.set(s,i)})))).next((()=>r))}saveOverlays(e,t,r){return r.forEach(((s,i)=>{this.bt(e,t,i)})),C.resolve()}removeOverlaysForBatchId(e,t,r){const s=this.Lr.get(r);return s!==void 0&&(s.forEach((i=>this.overlays=this.overlays.remove(i))),this.Lr.delete(r)),C.resolve()}getOverlaysForCollection(e,t,r){const s=on(),i=t.length+1,a=new M(t.child("")),c=this.overlays.getIteratorFrom(a);for(;c.hasNext();){const u=c.getNext().value,h=u.getKey();if(!t.isPrefixOf(h.path))break;h.path.length===i&&u.largestBatchId>r&&s.set(u.getKey(),u)}return C.resolve(s)}getOverlaysForCollectionGroup(e,t,r,s){let i=new re(((h,f)=>h-f));const a=this.overlays.getIterator();for(;a.hasNext();){const h=a.getNext().value;if(h.getKey().getCollectionGroup()===t&&h.largestBatchId>r){let f=i.get(h.largestBatchId);f===null&&(f=on(),i=i.insert(h.largestBatchId,f)),f.set(h.getKey(),h)}}const c=on(),u=i.getIterator();for(;u.hasNext()&&(u.getNext().value.forEach(((h,f)=>c.set(h,f))),!(c.size()>=s)););return C.resolve(c)}bt(e,t,r){const s=this.overlays.get(r.key);if(s!==null){const a=this.Lr.get(s.largestBatchId).delete(r.key);this.Lr.set(s.largestBatchId,a)}this.overlays=this.overlays.insert(r.key,new iv(t,r));let i=this.Lr.get(t);i===void 0&&(i=K(),this.Lr.set(t,i)),this.Lr.set(t,i.add(r.key))}}class $v{constructor(){this.sessionToken=Te.EMPTY_BYTE_STRING}getSessionToken(e){return C.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,C.resolve()}}class qa{constructor(){this.kr=new de(pe.Kr),this.qr=new de(pe.Ur)}isEmpty(){return this.kr.isEmpty()}addReference(e,t){const r=new pe(e,t);this.kr=this.kr.add(r),this.qr=this.qr.add(r)}$r(e,t){e.forEach((r=>this.addReference(r,t)))}removeReference(e,t){this.Wr(new pe(e,t))}Qr(e,t){e.forEach((r=>this.removeReference(r,t)))}Gr(e){const t=new M(new Z([])),r=new pe(t,e),s=new pe(t,e+1),i=[];return this.qr.forEachInRange([r,s],(a=>{this.Wr(a),i.push(a.key)})),i}zr(){this.kr.forEach((e=>this.Wr(e)))}Wr(e){this.kr=this.kr.delete(e),this.qr=this.qr.delete(e)}jr(e){const t=new M(new Z([])),r=new pe(t,e),s=new pe(t,e+1);let i=K();return this.qr.forEachInRange([r,s],(a=>{i=i.add(a.key)})),i}containsKey(e){const t=new pe(e,0),r=this.kr.firstAfterOrEqual(t);return r!==null&&e.isEqual(r.key)}}class pe{constructor(e,t){this.key=e,this.Hr=t}static Kr(e,t){return M.comparator(e.key,t.key)||G(e.Hr,t.Hr)}static Ur(e,t){return G(e.Hr,t.Hr)||M.comparator(e.key,t.key)}}class jv{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Yn=1,this.Jr=new de(pe.Kr)}checkEmpty(e){return C.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,r,s){const i=this.Yn;this.Yn++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const a=new sv(i,t,r,s);this.mutationQueue.push(a);for(const c of s)this.Jr=this.Jr.add(new pe(c.key,i)),this.indexManager.addToCollectionParentIndex(e,c.key.path.popLast());return C.resolve(a)}lookupMutationBatch(e,t){return C.resolve(this.Zr(t))}getNextMutationBatchAfterBatchId(e,t){const r=t+1,s=this.Xr(r),i=s<0?0:s;return C.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return C.resolve(this.mutationQueue.length===0?Na:this.Yn-1)}getAllMutationBatches(e){return C.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const r=new pe(t,0),s=new pe(t,Number.POSITIVE_INFINITY),i=[];return this.Jr.forEachInRange([r,s],(a=>{const c=this.Zr(a.Hr);i.push(c)})),C.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new de(G);return t.forEach((s=>{const i=new pe(s,0),a=new pe(s,Number.POSITIVE_INFINITY);this.Jr.forEachInRange([i,a],(c=>{r=r.add(c.Hr)}))})),C.resolve(this.Yr(r))}getAllMutationBatchesAffectingQuery(e,t){const r=t.path,s=r.length+1;let i=r;M.isDocumentKey(i)||(i=i.child(""));const a=new pe(new M(i),0);let c=new de(G);return this.Jr.forEachWhile((u=>{const h=u.key.path;return!!r.isPrefixOf(h)&&(h.length===s&&(c=c.add(u.Hr)),!0)}),a),C.resolve(this.Yr(c))}Yr(e){const t=[];return e.forEach((r=>{const s=this.Zr(r);s!==null&&t.push(s)})),t}removeMutationBatch(e,t){Y(this.ei(t.batchId,"removed")===0,55003),this.mutationQueue.shift();let r=this.Jr;return C.forEach(t.mutations,(s=>{const i=new pe(s.key,t.batchId);return r=r.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,s.key)})).next((()=>{this.Jr=r}))}nr(e){}containsKey(e,t){const r=new pe(t,0),s=this.Jr.firstAfterOrEqual(r);return C.resolve(t.isEqual(s&&s.key))}performConsistencyCheck(e){return this.mutationQueue.length,C.resolve()}ei(e,t){return this.Xr(e)}Xr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Zr(e){const t=this.Xr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class zv{constructor(e){this.ti=e,this.docs=(function(){return new re(M.comparator)})(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const r=t.key,s=this.docs.get(r),i=s?s.size:0,a=this.ti(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:a}),this.size+=a-i,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const r=this.docs.get(t);return C.resolve(r?r.document.mutableCopy():Ae.newInvalidDocument(t))}getEntries(e,t){let r=Et();return t.forEach((s=>{const i=this.docs.get(s);r=r.insert(s,i?i.document.mutableCopy():Ae.newInvalidDocument(s))})),C.resolve(r)}getDocumentsMatchingQuery(e,t,r,s){let i=Et();const a=t.path,c=new M(a.child("__id-9223372036854775808__")),u=this.docs.getIteratorFrom(c);for(;u.hasNext();){const{key:h,value:{document:f}}=u.getNext();if(!a.isPrefixOf(h.path))break;h.path.length>a.length+1||gE(mE(f),r)<=0||(s.has(f.key)||wi(t,f))&&(i=i.insert(f.key,f.mutableCopy()))}return C.resolve(i)}getAllFromCollectionGroup(e,t,r,s){x(9500)}ni(e,t){return C.forEach(this.docs,(r=>t(r)))}newChangeBuffer(e){return new Hv(this)}getSize(e){return C.resolve(this.size)}}class Hv extends xv{constructor(e){super(),this.Mr=e}applyChanges(e){const t=[];return this.changes.forEach(((r,s)=>{s.isValidDocument()?t.push(this.Mr.addEntry(e,s)):this.Mr.removeEntry(r)})),C.waitFor(t)}getFromCache(e,t){return this.Mr.getEntry(e,t)}getAllFromCache(e,t){return this.Mr.getEntries(e,t)}}class Gv{constructor(e){this.persistence=e,this.ri=new Tn((t=>Oa(t)),La),this.lastRemoteSnapshotVersion=B.min(),this.highestTargetId=0,this.ii=0,this.si=new qa,this.targetCount=0,this.oi=Un._r()}forEachTarget(e,t){return this.ri.forEach(((r,s)=>t(s))),C.resolve()}getLastRemoteSnapshotVersion(e){return C.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return C.resolve(this.ii)}allocateTargetId(e){return this.highestTargetId=this.oi.next(),C.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.ii&&(this.ii=t),C.resolve()}lr(e){this.ri.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.oi=new Un(t),this.highestTargetId=t),e.sequenceNumber>this.ii&&(this.ii=e.sequenceNumber)}addTargetData(e,t){return this.lr(t),this.targetCount+=1,C.resolve()}updateTargetData(e,t){return this.lr(t),C.resolve()}removeTargetData(e,t){return this.ri.delete(t.target),this.si.Gr(t.targetId),this.targetCount-=1,C.resolve()}removeTargets(e,t,r){let s=0;const i=[];return this.ri.forEach(((a,c)=>{c.sequenceNumber<=t&&r.get(c.targetId)===null&&(this.ri.delete(a),i.push(this.removeMatchingKeysForTargetId(e,c.targetId)),s++)})),C.waitFor(i).next((()=>s))}getTargetCount(e){return C.resolve(this.targetCount)}getTargetData(e,t){const r=this.ri.get(t)||null;return C.resolve(r)}addMatchingKeys(e,t,r){return this.si.$r(t,r),C.resolve()}removeMatchingKeys(e,t,r){this.si.Qr(t,r);const s=this.persistence.referenceDelegate,i=[];return s&&t.forEach((a=>{i.push(s.markPotentiallyOrphaned(e,a))})),C.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.si.Gr(t),C.resolve()}getMatchingKeysForTargetId(e,t){const r=this.si.jr(t);return C.resolve(r)}containsKey(e,t){return C.resolve(this.si.containsKey(t))}}class Ff{constructor(e,t){this._i={},this.overlays={},this.ai=new mi(0),this.ui=!1,this.ui=!0,this.ci=new $v,this.referenceDelegate=e(this),this.li=new Gv(this),this.indexManager=new kv,this.remoteDocumentCache=(function(s){return new zv(s)})((r=>this.referenceDelegate.hi(r))),this.serializer=new Pv(t),this.Pi=new Bv(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ui=!1,Promise.resolve()}get started(){return this.ui}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new qv,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this._i[e.toKey()];return r||(r=new jv(t,this.referenceDelegate),this._i[e.toKey()]=r),r}getGlobalsCache(){return this.ci}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Pi}runTransaction(e,t,r){L("MemoryPersistence","Starting transaction:",e);const s=new Kv(this.ai.next());return this.referenceDelegate.Ti(),r(s).next((i=>this.referenceDelegate.Ii(s).next((()=>i)))).toPromise().then((i=>(s.raiseOnCommittedEvent(),i)))}Ei(e,t){return C.or(Object.values(this._i).map((r=>()=>r.containsKey(e,t))))}}class Kv extends yE{constructor(e){super(),this.currentSequenceNumber=e}}class $a{constructor(e){this.persistence=e,this.Ri=new qa,this.Ai=null}static Vi(e){return new $a(e)}get di(){if(this.Ai)return this.Ai;throw x(60996)}addReference(e,t,r){return this.Ri.addReference(r,t),this.di.delete(r.toString()),C.resolve()}removeReference(e,t,r){return this.Ri.removeReference(r,t),this.di.add(r.toString()),C.resolve()}markPotentiallyOrphaned(e,t){return this.di.add(t.toString()),C.resolve()}removeTarget(e,t){this.Ri.Gr(t.targetId).forEach((s=>this.di.add(s.toString())));const r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next((s=>{s.forEach((i=>this.di.add(i.toString())))})).next((()=>r.removeTargetData(e,t)))}Ti(){this.Ai=new Set}Ii(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return C.forEach(this.di,(r=>{const s=M.fromPath(r);return this.mi(e,s).next((i=>{i||t.removeEntry(s,B.min())}))})).next((()=>(this.Ai=null,t.apply(e))))}updateLimboDocument(e,t){return this.mi(e,t).next((r=>{r?this.di.delete(t.toString()):this.di.add(t.toString())}))}hi(e){return 0}mi(e,t){return C.or([()=>C.resolve(this.Ri.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ei(e,t)])}}class zs{constructor(e,t){this.persistence=e,this.fi=new Tn((r=>EE(r.path)),((r,s)=>r.isEqual(s))),this.garbageCollector=Mv(this,t)}static Vi(e,t){return new zs(e,t)}Ti(){}Ii(e){return C.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}dr(e){const t=this.pr(e);return this.persistence.getTargetCache().getTargetCount(e).next((r=>t.next((s=>r+s))))}pr(e){let t=0;return this.mr(e,(r=>{t++})).next((()=>t))}mr(e,t){return C.forEach(this.fi,((r,s)=>this.wr(e,r,s).next((i=>i?C.resolve():t(s)))))}removeTargets(e,t,r){return this.persistence.getTargetCache().removeTargets(e,t,r)}removeOrphanedDocuments(e,t){let r=0;const s=this.persistence.getRemoteDocumentCache(),i=s.newChangeBuffer();return s.ni(e,(a=>this.wr(e,a,t).next((c=>{c||(r++,i.removeEntry(a,B.min()))})))).next((()=>i.apply(e))).next((()=>r))}markPotentiallyOrphaned(e,t){return this.fi.set(t,e.currentSequenceNumber),C.resolve()}removeTarget(e,t){const r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.fi.set(r,e.currentSequenceNumber),C.resolve()}removeReference(e,t,r){return this.fi.set(r,e.currentSequenceNumber),C.resolve()}updateLimboDocument(e,t){return this.fi.set(t,e.currentSequenceNumber),C.resolve()}hi(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=ws(e.data.value)),t}wr(e,t,r){return C.or([()=>this.persistence.Ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{const s=this.fi.get(t);return C.resolve(s!==void 0&&s>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class ja{constructor(e,t,r,s){this.targetId=e,this.fromCache=t,this.Ts=r,this.Is=s}static Es(e,t){let r=K(),s=K();for(const i of t.docChanges)switch(i.type){case 0:r=r.add(i.doc.key);break;case 1:s=s.add(i.doc.key)}return new ja(e,t.fromCache,r,s)}}class Wv{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class Qv{constructor(){this.Rs=!1,this.As=!1,this.Vs=100,this.ds=(function(){return mg()?8:TE(Se())>0?6:4})()}initialize(e,t){this.fs=e,this.indexManager=t,this.Rs=!0}getDocumentsMatchingQuery(e,t,r,s){const i={result:null};return this.gs(e,t).next((a=>{i.result=a})).next((()=>{if(!i.result)return this.ps(e,t,s,r).next((a=>{i.result=a}))})).next((()=>{if(i.result)return;const a=new Wv;return this.ys(e,t,a).next((c=>{if(i.result=c,this.As)return this.ws(e,t,a,c.size)}))})).next((()=>i.result))}ws(e,t,r,s){return r.documentReadCount<this.Vs?(An()<=H.DEBUG&&L("QueryEngine","SDK will not create cache indexes for query:",bn(t),"since it only creates cache indexes for collection contains","more than or equal to",this.Vs,"documents"),C.resolve()):(An()<=H.DEBUG&&L("QueryEngine","Query:",bn(t),"scans",r.documentReadCount,"local documents and returns",s,"documents as results."),r.documentReadCount>this.ds*s?(An()<=H.DEBUG&&L("QueryEngine","The SDK decides to create cache indexes for query:",bn(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,st(t))):C.resolve())}gs(e,t){if(vu(t))return C.resolve(null);let r=st(t);return this.indexManager.getIndexType(e,r).next((s=>s===0?null:(t.limit!==null&&s===1&&(t=Bs(t,null,"F"),r=st(t)),this.indexManager.getDocumentsMatchingTarget(e,r).next((i=>{const a=K(...i);return this.fs.getDocuments(e,a).next((c=>this.indexManager.getMinOffset(e,r).next((u=>{const h=this.bs(t,c);return this.Ss(t,h,a,u.readTime)?this.gs(e,Bs(t,null,"F")):this.Ds(e,h,t,u)}))))})))))}ps(e,t,r,s){return vu(t)||s.isEqual(B.min())?C.resolve(null):this.fs.getDocuments(e,r).next((i=>{const a=this.bs(t,i);return this.Ss(t,a,r,s)?C.resolve(null):(An()<=H.DEBUG&&L("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),bn(t)),this.Ds(e,a,t,pE(s,Rr)).next((c=>c)))}))}bs(e,t){let r=new de(mf(e));return t.forEach(((s,i)=>{wi(e,i)&&(r=r.add(i))})),r}Ss(e,t,r,s){if(e.limit===null)return!1;if(r.size!==t.size)return!0;const i=e.limitType==="F"?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(s)>0)}ys(e,t,r){return An()<=H.DEBUG&&L("QueryEngine","Using full collection scan to execute query:",bn(t)),this.fs.getDocumentsMatchingQuery(e,t,Bt.min(),r)}Ds(e,t,r,s){return this.fs.getDocumentsMatchingQuery(e,r,s).next((i=>(t.forEach((a=>{i=i.insert(a.key,a)})),i)))}}const za="LocalStore",Jv=3e8;class Yv{constructor(e,t,r,s){this.persistence=e,this.Cs=t,this.serializer=s,this.vs=new re(G),this.Fs=new Tn((i=>Oa(i)),La),this.Ms=new Map,this.xs=e.getRemoteDocumentCache(),this.li=e.getTargetCache(),this.Pi=e.getBundleCache(),this.Os(r)}Os(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new Uv(this.xs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.xs.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(t=>e.collect(t,this.vs)))}}function Xv(n,e,t,r){return new Yv(n,e,t,r)}async function Uf(n,e){const t=q(n);return await t.persistence.runTransaction("Handle user change","readonly",(r=>{let s;return t.mutationQueue.getAllMutationBatches(r).next((i=>(s=i,t.Os(e),t.mutationQueue.getAllMutationBatches(r)))).next((i=>{const a=[],c=[];let u=K();for(const h of s){a.push(h.batchId);for(const f of h.mutations)u=u.add(f.key)}for(const h of i){c.push(h.batchId);for(const f of h.mutations)u=u.add(f.key)}return t.localDocuments.getDocuments(r,u).next((h=>({Ns:h,removedBatchIds:a,addedBatchIds:c})))}))}))}function Zv(n,e){const t=q(n);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",(r=>{const s=e.batch.keys(),i=t.xs.newChangeBuffer({trackRemovals:!0});return(function(c,u,h,f){const m=h.batch,y=m.keys();let S=C.resolve();return y.forEach((k=>{S=S.next((()=>f.getEntry(u,k))).next((V=>{const N=h.docVersions.get(k);Y(N!==null,48541),V.version.compareTo(N)<0&&(m.applyToRemoteDocument(V,h),V.isValidDocument()&&(V.setReadTime(h.commitVersion),f.addEntry(V)))}))})),S.next((()=>c.mutationQueue.removeMutationBatch(u,m)))})(t,r,e,i).next((()=>i.apply(r))).next((()=>t.mutationQueue.performConsistencyCheck(r))).next((()=>t.documentOverlayCache.removeOverlaysForBatchId(r,s,e.batch.batchId))).next((()=>t.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(r,(function(c){let u=K();for(let h=0;h<c.mutationResults.length;++h)c.mutationResults[h].transformResults.length>0&&(u=u.add(c.batch.mutations[h].key));return u})(e)))).next((()=>t.localDocuments.getDocuments(r,s)))}))}function Bf(n){const e=q(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(t=>e.li.getLastRemoteSnapshotVersion(t)))}function eI(n,e){const t=q(n),r=e.snapshotVersion;let s=t.vs;return t.persistence.runTransaction("Apply remote event","readwrite-primary",(i=>{const a=t.xs.newChangeBuffer({trackRemovals:!0});s=t.vs;const c=[];e.targetChanges.forEach(((f,m)=>{const y=s.get(m);if(!y)return;c.push(t.li.removeMatchingKeys(i,f.removedDocuments,m).next((()=>t.li.addMatchingKeys(i,f.addedDocuments,m))));let S=y.withSequenceNumber(i.currentSequenceNumber);e.targetMismatches.get(m)!==null?S=S.withResumeToken(Te.EMPTY_BYTE_STRING,B.min()).withLastLimboFreeSnapshotVersion(B.min()):f.resumeToken.approximateByteSize()>0&&(S=S.withResumeToken(f.resumeToken,r)),s=s.insert(m,S),(function(V,N,$){return V.resumeToken.approximateByteSize()===0||N.snapshotVersion.toMicroseconds()-V.snapshotVersion.toMicroseconds()>=Jv?!0:$.addedDocuments.size+$.modifiedDocuments.size+$.removedDocuments.size>0})(y,S,f)&&c.push(t.li.updateTargetData(i,S))}));let u=Et(),h=K();if(e.documentUpdates.forEach((f=>{e.resolvedLimboDocuments.has(f)&&c.push(t.persistence.referenceDelegate.updateLimboDocument(i,f))})),c.push(tI(i,a,e.documentUpdates).next((f=>{u=f.Bs,h=f.Ls}))),!r.isEqual(B.min())){const f=t.li.getLastRemoteSnapshotVersion(i).next((m=>t.li.setTargetsMetadata(i,i.currentSequenceNumber,r)));c.push(f)}return C.waitFor(c).next((()=>a.apply(i))).next((()=>t.localDocuments.getLocalViewOfDocuments(i,u,h))).next((()=>u))})).then((i=>(t.vs=s,i)))}function tI(n,e,t){let r=K(),s=K();return t.forEach((i=>r=r.add(i))),e.getEntries(n,r).next((i=>{let a=Et();return t.forEach(((c,u)=>{const h=i.get(c);u.isFoundDocument()!==h.isFoundDocument()&&(s=s.add(c)),u.isNoDocument()&&u.version.isEqual(B.min())?(e.removeEntry(c,u.readTime),a=a.insert(c,u)):!h.isValidDocument()||u.version.compareTo(h.version)>0||u.version.compareTo(h.version)===0&&h.hasPendingWrites?(e.addEntry(u),a=a.insert(c,u)):L(za,"Ignoring outdated watch update for ",c,". Current version:",h.version," Watch version:",u.version)})),{Bs:a,Ls:s}}))}function nI(n,e){const t=q(n);return t.persistence.runTransaction("Get next mutation batch","readonly",(r=>(e===void 0&&(e=Na),t.mutationQueue.getNextMutationBatchAfterBatchId(r,e))))}function rI(n,e){const t=q(n);return t.persistence.runTransaction("Allocate target","readwrite",(r=>{let s;return t.li.getTargetData(r,e).next((i=>i?(s=i,C.resolve(s)):t.li.allocateTargetId(r).next((a=>(s=new Lt(e,a,"TargetPurposeListen",r.currentSequenceNumber),t.li.addTargetData(r,s).next((()=>s)))))))})).then((r=>{const s=t.vs.get(r.targetId);return(s===null||r.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(t.vs=t.vs.insert(r.targetId,r),t.Fs.set(e,r.targetId)),r}))}async function Ko(n,e,t){const r=q(n),s=r.vs.get(e),i=t?"readwrite":"readwrite-primary";try{t||await r.persistence.runTransaction("Release target",i,(a=>r.persistence.referenceDelegate.removeTarget(a,s)))}catch(a){if(!Gn(a))throw a;L(za,`Failed to update sequence numbers for target ${e}: ${a}`)}r.vs=r.vs.remove(e),r.Fs.delete(s.target)}function Lu(n,e,t){const r=q(n);let s=B.min(),i=K();return r.persistence.runTransaction("Execute query","readwrite",(a=>(function(u,h,f){const m=q(u),y=m.Fs.get(f);return y!==void 0?C.resolve(m.vs.get(y)):m.li.getTargetData(h,f)})(r,a,st(e)).next((c=>{if(c)return s=c.lastLimboFreeSnapshotVersion,r.li.getMatchingKeysForTargetId(a,c.targetId).next((u=>{i=u}))})).next((()=>r.Cs.getDocumentsMatchingQuery(a,e,t?s:B.min(),t?i:K()))).next((c=>(sI(r,jE(e),c),{documents:c,ks:i})))))}function sI(n,e,t){let r=n.Ms.get(e)||B.min();t.forEach(((s,i)=>{i.readTime.compareTo(r)>0&&(r=i.readTime)})),n.Ms.set(e,r)}class Mu{constructor(){this.activeTargetIds=QE()}Qs(e){this.activeTargetIds=this.activeTargetIds.add(e)}Gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Ws(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class iI{constructor(){this.vo=new Mu,this.Fo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.vo.Qs(e),this.Fo[e]||"not-current"}updateQueryState(e,t,r){this.Fo[e]=t}removeLocalQueryTarget(e){this.vo.Gs(e)}isLocalQueryTarget(e){return this.vo.activeTargetIds.has(e)}clearQueryState(e){delete this.Fo[e]}getAllActiveQueryTargets(){return this.vo.activeTargetIds}isActiveQueryTarget(e){return this.vo.activeTargetIds.has(e)}start(){return this.vo=new Mu,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class oI{Mo(e){}shutdown(){}}const xu="ConnectivityMonitor";class Fu{constructor(){this.xo=()=>this.Oo(),this.No=()=>this.Bo(),this.Lo=[],this.ko()}Mo(e){this.Lo.push(e)}shutdown(){window.removeEventListener("online",this.xo),window.removeEventListener("offline",this.No)}ko(){window.addEventListener("online",this.xo),window.addEventListener("offline",this.No)}Oo(){L(xu,"Network connectivity changed: AVAILABLE");for(const e of this.Lo)e(0)}Bo(){L(xu,"Network connectivity changed: UNAVAILABLE");for(const e of this.Lo)e(1)}static v(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}let fs=null;function Wo(){return fs===null?fs=(function(){return 268435456+Math.round(2147483648*Math.random())})():fs++,"0x"+fs.toString(16)}const go="RestConnection",aI={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class cI{get Ko(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.qo=t+"://"+e.host,this.Uo=`projects/${r}/databases/${s}`,this.$o=this.databaseId.database===xs?`project_id=${r}`:`project_id=${r}&database_id=${s}`}Wo(e,t,r,s,i){const a=Wo(),c=this.Qo(e,t.toUriEncodedString());L(go,`Sending RPC '${e}' ${a}:`,c,r);const u={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.$o};this.Go(u,s,i);const{host:h}=new URL(c),f=vt(h);return this.zo(e,c,u,r,f).then((m=>(L(go,`Received RPC '${e}' ${a}: `,m),m)),(m=>{throw Ln(go,`RPC '${e}' ${a} failed with error: `,m,"url: ",c,"request:",r),m}))}jo(e,t,r,s,i,a){return this.Wo(e,t,r,s,i)}Go(e,t,r){e["X-Goog-Api-Client"]=(function(){return"gl-js/ fire/"+zn})(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach(((s,i)=>e[i]=s)),r&&r.headers.forEach(((s,i)=>e[i]=s))}Qo(e,t){const r=aI[e];let s=`${this.qo}/v1/${t}:${r}`;return this.databaseInfo.apiKey&&(s=`${s}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),s}terminate(){}}class lI{constructor(e){this.Ho=e.Ho,this.Jo=e.Jo}Zo(e){this.Xo=e}Yo(e){this.e_=e}t_(e){this.n_=e}onMessage(e){this.r_=e}close(){this.Jo()}send(e){this.Ho(e)}i_(){this.Xo()}s_(){this.e_()}o_(e){this.n_(e)}__(e){this.r_(e)}}const ve="WebChannelConnection",hr=(n,e,t)=>{n.listen(e,(r=>{try{t(r)}catch(s){setTimeout((()=>{throw s}),0)}}))};class Dn extends cI{constructor(e){super(e),this.a_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static u_(){if(!Dn.c_){const e=zd();hr(e,jd.STAT_EVENT,(t=>{t.stat===Lo.PROXY?L(ve,"STAT_EVENT: detected buffering proxy"):t.stat===Lo.NOPROXY&&L(ve,"STAT_EVENT: detected no buffering proxy")})),Dn.c_=!0}}zo(e,t,r,s,i){const a=Wo();return new Promise(((c,u)=>{const h=new qd;h.setWithCredentials(!0),h.listenOnce($d.COMPLETE,(()=>{try{switch(h.getLastErrorCode()){case Ts.NO_ERROR:const m=h.getResponseJson();L(ve,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(m)),c(m);break;case Ts.TIMEOUT:L(ve,`RPC '${e}' ${a} timed out`),u(new O(P.DEADLINE_EXCEEDED,"Request time out"));break;case Ts.HTTP_ERROR:const y=h.getStatus();if(L(ve,`RPC '${e}' ${a} failed with status:`,y,"response text:",h.getResponseText()),y>0){let S=h.getResponseJson();Array.isArray(S)&&(S=S[0]);const k=S?.error;if(k&&k.status&&k.message){const V=(function($){const W=$.toLowerCase().replace(/_/g,"-");return Object.values(P).indexOf(W)>=0?W:P.UNKNOWN})(k.status);u(new O(V,k.message))}else u(new O(P.UNKNOWN,"Server responded with status "+h.getStatus()))}else u(new O(P.UNAVAILABLE,"Connection failed."));break;default:x(9055,{l_:e,streamId:a,h_:h.getLastErrorCode(),P_:h.getLastError()})}}finally{L(ve,`RPC '${e}' ${a} completed.`)}}));const f=JSON.stringify(s);L(ve,`RPC '${e}' ${a} sending request:`,s),h.send(t,"POST",f,r,15)}))}T_(e,t,r){const s=Wo(),i=[this.qo,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=this.createWebChannelTransport(),c={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},u=this.longPollingOptions.timeoutSeconds;u!==void 0&&(c.longPollingTimeout=Math.round(1e3*u)),this.useFetchStreams&&(c.useFetchStreams=!0),this.Go(c.initMessageHeaders,t,r),c.encodeInitMessageHeaders=!0;const h=i.join("");L(ve,`Creating RPC '${e}' stream ${s}: ${h}`,c);const f=a.createWebChannel(h,c);this.I_(f);let m=!1,y=!1;const S=new lI({Ho:k=>{y?L(ve,`Not sending because RPC '${e}' stream ${s} is closed:`,k):(m||(L(ve,`Opening RPC '${e}' stream ${s} transport.`),f.open(),m=!0),L(ve,`RPC '${e}' stream ${s} sending:`,k),f.send(k))},Jo:()=>f.close()});return hr(f,dr.EventType.OPEN,(()=>{y||(L(ve,`RPC '${e}' stream ${s} transport opened.`),S.i_())})),hr(f,dr.EventType.CLOSE,(()=>{y||(y=!0,L(ve,`RPC '${e}' stream ${s} transport closed`),S.o_(),this.E_(f))})),hr(f,dr.EventType.ERROR,(k=>{y||(y=!0,Ln(ve,`RPC '${e}' stream ${s} transport errored. Name:`,k.name,"Message:",k.message),S.o_(new O(P.UNAVAILABLE,"The operation could not be completed")))})),hr(f,dr.EventType.MESSAGE,(k=>{if(!y){const V=k.data[0];Y(!!V,16349);const N=V,$=N?.error||N[0]?.error;if($){L(ve,`RPC '${e}' stream ${s} received error:`,$);const W=$.status;let Q=(function(oe){const v=ce[oe];if(v!==void 0)return Sf(v)})(W),te=$.message;Q===void 0&&(Q=P.INTERNAL,te="Unknown error status: "+W+" with message "+$.message),y=!0,S.o_(new O(Q,te)),f.close()}else L(ve,`RPC '${e}' stream ${s} received:`,V),S.__(V)}})),Dn.u_(),setTimeout((()=>{S.s_()}),0),S}terminate(){this.a_.forEach((e=>e.close())),this.a_=[]}I_(e){this.a_.push(e)}E_(e){this.a_=this.a_.filter((t=>t===e))}Go(e,t,r){super.Go(e,t,r),this.databaseInfo.apiKey&&(e["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return Hd()}}function uI(n){return new Dn(n)}function _o(){return typeof document<"u"?document:null}function Ai(n){return new pv(n,!0)}Dn.c_=!1;class qf{constructor(e,t,r=1e3,s=1.5,i=6e4){this.Ci=e,this.timerId=t,this.R_=r,this.A_=s,this.V_=i,this.d_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.d_=0}g_(){this.d_=this.V_}p_(e){this.cancel();const t=Math.floor(this.d_+this.y_()),r=Math.max(0,Date.now()-this.f_),s=Math.max(0,t-r);s>0&&L("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.d_} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.m_=this.Ci.enqueueAfterDelay(this.timerId,s,(()=>(this.f_=Date.now(),e()))),this.d_*=this.A_,this.d_<this.R_&&(this.d_=this.R_),this.d_>this.V_&&(this.d_=this.V_)}w_(){this.m_!==null&&(this.m_.skipDelay(),this.m_=null)}cancel(){this.m_!==null&&(this.m_.cancel(),this.m_=null)}y_(){return(Math.random()-.5)*this.d_}}const Uu="PersistentStream";class $f{constructor(e,t,r,s,i,a,c,u){this.Ci=e,this.b_=r,this.S_=s,this.connection=i,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=c,this.listener=u,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new qf(e,t)}x_(){return this.state===1||this.state===5||this.O_()}O_(){return this.state===2||this.state===3}start(){this.F_=0,this.state!==4?this.auth():this.N_()}async stop(){this.x_()&&await this.close(0)}B_(){this.state=0,this.M_.reset()}L_(){this.O_()&&this.C_===null&&(this.C_=this.Ci.enqueueAfterDelay(this.b_,6e4,(()=>this.k_())))}K_(e){this.q_(),this.stream.send(e)}async k_(){if(this.O_())return this.close(0)}q_(){this.C_&&(this.C_.cancel(),this.C_=null)}U_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,t){this.q_(),this.U_(),this.M_.cancel(),this.D_++,e!==4?this.M_.reset():t&&t.code===P.RESOURCE_EXHAUSTED?(wt(t.toString()),wt("Using maximum backoff delay to prevent overloading the backend."),this.M_.g_()):t&&t.code===P.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.W_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.t_(t)}W_(){}auth(){this.state=1;const e=this.Q_(this.D_),t=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([r,s])=>{this.D_===t&&this.G_(r,s)}),(r=>{e((()=>{const s=new O(P.UNKNOWN,"Fetching auth token failed: "+r.message);return this.z_(s)}))}))}G_(e,t){const r=this.Q_(this.D_);this.stream=this.j_(e,t),this.stream.Zo((()=>{r((()=>this.listener.Zo()))})),this.stream.Yo((()=>{r((()=>(this.state=2,this.v_=this.Ci.enqueueAfterDelay(this.S_,1e4,(()=>(this.O_()&&(this.state=3),Promise.resolve()))),this.listener.Yo())))})),this.stream.t_((s=>{r((()=>this.z_(s)))})),this.stream.onMessage((s=>{r((()=>++this.F_==1?this.H_(s):this.onNext(s)))}))}N_(){this.state=5,this.M_.p_((async()=>{this.state=0,this.start()}))}z_(e){return L(Uu,`close with error: ${e}`),this.stream=null,this.close(4,e)}Q_(e){return t=>{this.Ci.enqueueAndForget((()=>this.D_===e?t():(L(Uu,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class hI extends $f{constructor(e,t,r,s,i,a){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,s,a),this.serializer=i}j_(e,t){return this.connection.T_("Listen",e,t)}H_(e){return this.onNext(e)}onNext(e){this.M_.reset();const t=_v(this.serializer,e),r=(function(i){if(!("targetChange"in i))return B.min();const a=i.targetChange;return a.targetIds&&a.targetIds.length?B.min():a.readTime?it(a.readTime):B.min()})(e);return this.listener.J_(t,r)}Z_(e){const t={};t.database=Go(this.serializer),t.addTarget=(function(i,a){let c;const u=a.target;if(c=qo(u)?{documents:wv(i,u)}:{query:Ev(i,u).ft},c.targetId=a.targetId,a.resumeToken.approximateByteSize()>0){c.resumeToken=Cf(i,a.resumeToken);const h=jo(i,a.expectedCount);h!==null&&(c.expectedCount=h)}else if(a.snapshotVersion.compareTo(B.min())>0){c.readTime=js(i,a.snapshotVersion.toTimestamp());const h=jo(i,a.expectedCount);h!==null&&(c.expectedCount=h)}return c})(this.serializer,e);const r=Iv(this.serializer,e);r&&(t.labels=r),this.K_(t)}X_(e){const t={};t.database=Go(this.serializer),t.removeTarget=e,this.K_(t)}}class dI extends $f{constructor(e,t,r,s,i,a){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,r,s,a),this.serializer=i}get Y_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}W_(){this.Y_&&this.ea([])}j_(e,t){return this.connection.T_("Write",e,t)}H_(e){return Y(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,Y(!e.writeResults||e.writeResults.length===0,55816),this.listener.ta()}onNext(e){Y(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.M_.reset();const t=Tv(e.writeResults,e.commitTime),r=it(e.commitTime);return this.listener.na(r,t)}ra(){const e={};e.database=Go(this.serializer),this.K_(e)}ea(e){const t={streamToken:this.lastStreamToken,writes:e.map((r=>yv(this.serializer,r)))};this.K_(t)}}class fI{}class pI extends fI{constructor(e,t,r,s){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer=s,this.ia=!1}sa(){if(this.ia)throw new O(P.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(e,t,r,s){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([i,a])=>this.connection.Wo(e,zo(t,r),s,i,a))).catch((i=>{throw i.name==="FirebaseError"?(i.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),i):new O(P.UNKNOWN,i.toString())}))}jo(e,t,r,s,i){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([a,c])=>this.connection.jo(e,zo(t,r),s,a,c,i))).catch((a=>{throw a.name==="FirebaseError"?(a.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new O(P.UNKNOWN,a.toString())}))}terminate(){this.ia=!0,this.connection.terminate()}}function mI(n,e,t,r){return new pI(n,e,t,r)}class gI{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.oa=0,this._a=null,this.aa=!0}ua(){this.oa===0&&(this.ca("Unknown"),this._a=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=>(this._a=null,this.la("Backend didn't respond within 10 seconds."),this.ca("Offline"),Promise.resolve()))))}ha(e){this.state==="Online"?this.ca("Unknown"):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ca("Offline")))}set(e){this.Pa(),this.oa=0,e==="Online"&&(this.aa=!1),this.ca(e)}ca(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}la(e){const t=`Could not reach Cloud Firestore backend. ${e}
32
+ 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.aa?(wt(t),this.aa=!1):L("OnlineStateTracker",t)}Pa(){this._a!==null&&(this._a.cancel(),this._a=null)}}const mn="RemoteStore";class _I{constructor(e,t,r,s,i){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.Ta=[],this.Ia=new Map,this.Ea=new Set,this.Ra=[],this.Aa=i,this.Aa.Mo((a=>{r.enqueueAndForget((async()=>{wn(this)&&(L(mn,"Restarting streams for network reachability change."),await(async function(u){const h=q(u);h.Ea.add(4),await jr(h),h.Va.set("Unknown"),h.Ea.delete(4),await bi(h)})(this))}))})),this.Va=new gI(r,s)}}async function bi(n){if(wn(n))for(const e of n.Ra)await e(!0)}async function jr(n){for(const e of n.Ra)await e(!1)}function jf(n,e){const t=q(n);t.Ia.has(e.targetId)||(t.Ia.set(e.targetId,e),Wa(t)?Ka(t):Wn(t).O_()&&Ga(t,e))}function Ha(n,e){const t=q(n),r=Wn(t);t.Ia.delete(e),r.O_()&&zf(t,e),t.Ia.size===0&&(r.O_()?r.L_():wn(t)&&t.Va.set("Unknown"))}function Ga(n,e){if(n.da.$e(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(B.min())>0){const t=n.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(t)}Wn(n).Z_(e)}function zf(n,e){n.da.$e(e),Wn(n).X_(e)}function Ka(n){n.da=new uv({getRemoteKeysForTarget:e=>n.remoteSyncer.getRemoteKeysForTarget(e),At:e=>n.Ia.get(e)||null,ht:()=>n.datastore.serializer.databaseId}),Wn(n).start(),n.Va.ua()}function Wa(n){return wn(n)&&!Wn(n).x_()&&n.Ia.size>0}function wn(n){return q(n).Ea.size===0}function Hf(n){n.da=void 0}async function yI(n){n.Va.set("Online")}async function TI(n){n.Ia.forEach(((e,t)=>{Ga(n,e)}))}async function wI(n,e){Hf(n),Wa(n)?(n.Va.ha(e),Ka(n)):n.Va.set("Unknown")}async function EI(n,e,t){if(n.Va.set("Online"),e instanceof Pf&&e.state===2&&e.cause)try{await(async function(s,i){const a=i.cause;for(const c of i.targetIds)s.Ia.has(c)&&(await s.remoteSyncer.rejectListen(c,a),s.Ia.delete(c),s.da.removeTarget(c))})(n,e)}catch(r){L(mn,"Failed to remove targets %s: %s ",e.targetIds.join(","),r),await Hs(n,r)}else if(e instanceof Is?n.da.Xe(e):e instanceof Rf?n.da.st(e):n.da.tt(e),!t.isEqual(B.min()))try{const r=await Bf(n.localStore);t.compareTo(r)>=0&&await(function(i,a){const c=i.da.Tt(a);return c.targetChanges.forEach(((u,h)=>{if(u.resumeToken.approximateByteSize()>0){const f=i.Ia.get(h);f&&i.Ia.set(h,f.withResumeToken(u.resumeToken,a))}})),c.targetMismatches.forEach(((u,h)=>{const f=i.Ia.get(u);if(!f)return;i.Ia.set(u,f.withResumeToken(Te.EMPTY_BYTE_STRING,f.snapshotVersion)),zf(i,u);const m=new Lt(f.target,u,h,f.sequenceNumber);Ga(i,m)})),i.remoteSyncer.applyRemoteEvent(c)})(n,t)}catch(r){L(mn,"Failed to raise snapshot:",r),await Hs(n,r)}}async function Hs(n,e,t){if(!Gn(e))throw e;n.Ea.add(1),await jr(n),n.Va.set("Offline"),t||(t=()=>Bf(n.localStore)),n.asyncQueue.enqueueRetryable((async()=>{L(mn,"Retrying IndexedDB access"),await t(),n.Ea.delete(1),await bi(n)}))}function Gf(n,e){return e().catch((t=>Hs(n,t,e)))}async function Si(n){const e=q(n),t=zt(e);let r=e.Ta.length>0?e.Ta[e.Ta.length-1].batchId:Na;for(;vI(e);)try{const s=await nI(e.localStore,r);if(s===null){e.Ta.length===0&&t.L_();break}r=s.batchId,II(e,s)}catch(s){await Hs(e,s)}Kf(e)&&Wf(e)}function vI(n){return wn(n)&&n.Ta.length<10}function II(n,e){n.Ta.push(e);const t=zt(n);t.O_()&&t.Y_&&t.ea(e.mutations)}function Kf(n){return wn(n)&&!zt(n).x_()&&n.Ta.length>0}function Wf(n){zt(n).start()}async function AI(n){zt(n).ra()}async function bI(n){const e=zt(n);for(const t of n.Ta)e.ea(t.mutations)}async function SI(n,e,t){const r=n.Ta.shift(),s=Fa.from(r,e,t);await Gf(n,(()=>n.remoteSyncer.applySuccessfulWrite(s))),await Si(n)}async function RI(n,e){e&&zt(n).Y_&&await(async function(r,s){if((function(a){return av(a)&&a!==P.ABORTED})(s.code)){const i=r.Ta.shift();zt(r).B_(),await Gf(r,(()=>r.remoteSyncer.rejectFailedWrite(i.batchId,s))),await Si(r)}})(n,e),Kf(n)&&Wf(n)}async function Bu(n,e){const t=q(n);t.asyncQueue.verifyOperationInProgress(),L(mn,"RemoteStore received new credentials");const r=wn(t);t.Ea.add(3),await jr(t),r&&t.Va.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.Ea.delete(3),await bi(t)}async function PI(n,e){const t=q(n);e?(t.Ea.delete(2),await bi(t)):e||(t.Ea.add(2),await jr(t),t.Va.set("Unknown"))}function Wn(n){return n.ma||(n.ma=(function(t,r,s){const i=q(t);return i.sa(),new hI(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)})(n.datastore,n.asyncQueue,{Zo:yI.bind(null,n),Yo:TI.bind(null,n),t_:wI.bind(null,n),J_:EI.bind(null,n)}),n.Ra.push((async e=>{e?(n.ma.B_(),Wa(n)?Ka(n):n.Va.set("Unknown")):(await n.ma.stop(),Hf(n))}))),n.ma}function zt(n){return n.fa||(n.fa=(function(t,r,s){const i=q(t);return i.sa(),new dI(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)})(n.datastore,n.asyncQueue,{Zo:()=>Promise.resolve(),Yo:AI.bind(null,n),t_:RI.bind(null,n),ta:bI.bind(null,n),na:SI.bind(null,n)}),n.Ra.push((async e=>{e?(n.fa.B_(),await Si(n)):(await n.fa.stop(),n.Ta.length>0&&(L(mn,`Stopping write stream with ${n.Ta.length} pending writes`),n.Ta=[]))}))),n.fa}class Qa{constructor(e,t,r,s,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=s,this.removalCallback=i,this.deferred=new _t,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((a=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(e,t,r,s,i){const a=Date.now()+r,c=new Qa(e,t,a,s,i);return c.start(r),c}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new O(P.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 Ja(n,e){if(wt("AsyncQueue",`${e}: ${n}`),Gn(n))return new O(P.UNAVAILABLE,`${e}: ${n}`);throw n}class Vn{static emptySet(e){return new Vn(e.comparator)}constructor(e){this.comparator=e?(t,r)=>e(t,r)||M.comparator(t.key,r.key):(t,r)=>M.comparator(t.key,r.key),this.keyedMap=fr(),this.sortedSet=new re(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){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal(((t,r)=>(e(t),!1)))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof Vn)||this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;t.hasNext();){const s=t.getNext().key,i=r.getNext().key;if(!s.isEqual(i))return!1}return!0}toString(){const e=[];return this.forEach((t=>{e.push(t.toString())})),e.length===0?"DocumentSet ()":`DocumentSet (
33
+ `+e.join(`
34
+ `)+`
35
+ )`}copy(e,t){const r=new Vn;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}class qu{constructor(){this.ga=new re(M.comparator)}track(e){const t=e.doc.key,r=this.ga.get(t);r?e.type!==0&&r.type===3?this.ga=this.ga.insert(t,e):e.type===3&&r.type!==1?this.ga=this.ga.insert(t,{type:r.type,doc:e.doc}):e.type===2&&r.type===2?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):e.type===2&&r.type===0?this.ga=this.ga.insert(t,{type:0,doc:e.doc}):e.type===1&&r.type===0?this.ga=this.ga.remove(t):e.type===1&&r.type===2?this.ga=this.ga.insert(t,{type:1,doc:r.doc}):e.type===0&&r.type===1?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):x(63341,{Vt:e,pa:r}):this.ga=this.ga.insert(t,e)}ya(){const e=[];return this.ga.inorderTraversal(((t,r)=>{e.push(r)})),e}}class Bn{constructor(e,t,r,s,i,a,c,u,h){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=s,this.mutatedKeys=i,this.fromCache=a,this.syncStateChanged=c,this.excludesMetadataChanges=u,this.hasCachedResults=h}static fromInitialDocuments(e,t,r,s,i){const a=[];return t.forEach((c=>{a.push({type:0,doc:c})})),new Bn(e,t,Vn.emptySet(t),a,r,s,!0,!1,i)}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)&&Ti(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(t[s].type!==r[s].type||!t[s].doc.isEqual(r[s].doc))return!1;return!0}}class CI{constructor(){this.wa=void 0,this.ba=[]}Sa(){return this.ba.some((e=>e.Da()))}}class kI{constructor(){this.queries=$u(),this.onlineState="Unknown",this.Ca=new Set}terminate(){(function(t,r){const s=q(t),i=s.queries;s.queries=$u(),i.forEach(((a,c)=>{for(const u of c.ba)u.onError(r)}))})(this,new O(P.ABORTED,"Firestore shutting down"))}}function $u(){return new Tn((n=>pf(n)),Ti)}async function Ya(n,e){const t=q(n);let r=3;const s=e.query;let i=t.queries.get(s);i?!i.Sa()&&e.Da()&&(r=2):(i=new CI,r=e.Da()?0:1);try{switch(r){case 0:i.wa=await t.onListen(s,!0);break;case 1:i.wa=await t.onListen(s,!1);break;case 2:await t.onFirstRemoteStoreListen(s)}}catch(a){const c=Ja(a,`Initialization of query '${bn(e.query)}' failed`);return void e.onError(c)}t.queries.set(s,i),i.ba.push(e),e.va(t.onlineState),i.wa&&e.Fa(i.wa)&&Za(t)}async function Xa(n,e){const t=q(n),r=e.query;let s=3;const i=t.queries.get(r);if(i){const a=i.ba.indexOf(e);a>=0&&(i.ba.splice(a,1),i.ba.length===0?s=e.Da()?0:1:!i.Sa()&&e.Da()&&(s=2))}switch(s){case 0:return t.queries.delete(r),t.onUnlisten(r,!0);case 1:return t.queries.delete(r),t.onUnlisten(r,!1);case 2:return t.onLastRemoteStoreUnlisten(r);default:return}}function NI(n,e){const t=q(n);let r=!1;for(const s of e){const i=s.query,a=t.queries.get(i);if(a){for(const c of a.ba)c.Fa(s)&&(r=!0);a.wa=s}}r&&Za(t)}function DI(n,e,t){const r=q(n),s=r.queries.get(e);if(s)for(const i of s.ba)i.onError(t);r.queries.delete(e)}function Za(n){n.Ca.forEach((e=>{e.next()}))}var Qo,ju;(ju=Qo||(Qo={})).Ma="default",ju.Cache="cache";class ec{constructor(e,t,r){this.query=e,this.xa=t,this.Oa=!1,this.Na=null,this.onlineState="Unknown",this.options=r||{}}Fa(e){if(!this.options.includeMetadataChanges){const r=[];for(const s of e.docChanges)s.type!==3&&r.push(s);e=new Bn(e.query,e.docs,e.oldDocs,r,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Oa?this.Ba(e)&&(this.xa.next(e),t=!0):this.La(e,this.onlineState)&&(this.ka(e),t=!0),this.Na=e,t}onError(e){this.xa.error(e)}va(e){this.onlineState=e;let t=!1;return this.Na&&!this.Oa&&this.La(this.Na,e)&&(this.ka(this.Na),t=!0),t}La(e,t){if(!e.fromCache||!this.Da())return!0;const r=t!=="Offline";return(!this.options.Ka||!r)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}Ba(e){if(e.docChanges.length>0)return!0;const t=this.Na&&this.Na.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}ka(e){e=Bn.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Oa=!0,this.xa.next(e)}Da(){return this.options.source!==Qo.Cache}}class Qf{constructor(e){this.key=e}}class Jf{constructor(e){this.key=e}}class VI{constructor(e,t){this.query=e,this.Za=t,this.Xa=null,this.hasCachedResults=!1,this.current=!1,this.Ya=K(),this.mutatedKeys=K(),this.eu=mf(e),this.tu=new Vn(this.eu)}get nu(){return this.Za}ru(e,t){const r=t?t.iu:new qu,s=t?t.tu:this.tu;let i=t?t.mutatedKeys:this.mutatedKeys,a=s,c=!1;const u=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,h=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(e.inorderTraversal(((f,m)=>{const y=s.get(f),S=wi(this.query,m)?m:null,k=!!y&&this.mutatedKeys.has(y.key),V=!!S&&(S.hasLocalMutations||this.mutatedKeys.has(S.key)&&S.hasCommittedMutations);let N=!1;y&&S?y.data.isEqual(S.data)?k!==V&&(r.track({type:3,doc:S}),N=!0):this.su(y,S)||(r.track({type:2,doc:S}),N=!0,(u&&this.eu(S,u)>0||h&&this.eu(S,h)<0)&&(c=!0)):!y&&S?(r.track({type:0,doc:S}),N=!0):y&&!S&&(r.track({type:1,doc:y}),N=!0,(u||h)&&(c=!0)),N&&(S?(a=a.add(S),i=V?i.add(f):i.delete(f)):(a=a.delete(f),i=i.delete(f)))})),this.query.limit!==null)for(;a.size>this.query.limit;){const f=this.query.limitType==="F"?a.last():a.first();a=a.delete(f.key),i=i.delete(f.key),r.track({type:1,doc:f})}return{tu:a,iu:r,Ss:c,mutatedKeys:i}}su(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,s){const i=this.tu;this.tu=e.tu,this.mutatedKeys=e.mutatedKeys;const a=e.iu.ya();a.sort(((f,m)=>(function(S,k){const V=N=>{switch(N){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return x(20277,{Vt:N})}};return V(S)-V(k)})(f.type,m.type)||this.eu(f.doc,m.doc))),this.ou(r),s=s??!1;const c=t&&!s?this._u():[],u=this.Ya.size===0&&this.current&&!s?1:0,h=u!==this.Xa;return this.Xa=u,a.length!==0||h?{snapshot:new Bn(this.query,e.tu,i,a,e.mutatedKeys,u===0,h,!1,!!r&&r.resumeToken.approximateByteSize()>0),au:c}:{au:c}}va(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({tu:this.tu,iu:new qu,mutatedKeys:this.mutatedKeys,Ss:!1},!1)):{au:[]}}uu(e){return!this.Za.has(e)&&!!this.tu.has(e)&&!this.tu.get(e).hasLocalMutations}ou(e){e&&(e.addedDocuments.forEach((t=>this.Za=this.Za.add(t))),e.modifiedDocuments.forEach((t=>{})),e.removedDocuments.forEach((t=>this.Za=this.Za.delete(t))),this.current=e.current)}_u(){if(!this.current)return[];const e=this.Ya;this.Ya=K(),this.tu.forEach((r=>{this.uu(r.key)&&(this.Ya=this.Ya.add(r.key))}));const t=[];return e.forEach((r=>{this.Ya.has(r)||t.push(new Jf(r))})),this.Ya.forEach((r=>{e.has(r)||t.push(new Qf(r))})),t}cu(e){this.Za=e.ks,this.Ya=K();const t=this.ru(e.documents);return this.applyChanges(t,!0)}lu(){return Bn.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,this.Xa===0,this.hasCachedResults)}}const tc="SyncEngine";class OI{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class LI{constructor(e){this.key=e,this.hu=!1}}class MI{constructor(e,t,r,s,i,a){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=s,this.currentUser=i,this.maxConcurrentLimboResolutions=a,this.Pu={},this.Tu=new Tn((c=>pf(c)),Ti),this.Iu=new Map,this.Eu=new Set,this.Ru=new re(M.comparator),this.Au=new Map,this.Vu=new qa,this.du={},this.mu=new Map,this.fu=Un.ar(),this.onlineState="Unknown",this.gu=void 0}get isPrimaryClient(){return this.gu===!0}}async function xI(n,e,t=!0){const r=np(n);let s;const i=r.Tu.get(e);return i?(r.sharedClientState.addLocalQueryTarget(i.targetId),s=i.view.lu()):s=await Yf(r,e,t,!0),s}async function FI(n,e){const t=np(n);await Yf(t,e,!0,!1)}async function Yf(n,e,t,r){const s=await rI(n.localStore,st(e)),i=s.targetId,a=n.sharedClientState.addLocalQueryTarget(i,t);let c;return r&&(c=await UI(n,e,i,a==="current",s.resumeToken)),n.isPrimaryClient&&t&&jf(n.remoteStore,s),c}async function UI(n,e,t,r,s){n.pu=(m,y,S)=>(async function(V,N,$,W){let Q=N.view.ru($);Q.Ss&&(Q=await Lu(V.localStore,N.query,!1).then((({documents:v})=>N.view.ru(v,Q))));const te=W&&W.targetChanges.get(N.targetId),we=W&&W.targetMismatches.get(N.targetId)!=null,oe=N.view.applyChanges(Q,V.isPrimaryClient,te,we);return Hu(V,N.targetId,oe.au),oe.snapshot})(n,m,y,S);const i=await Lu(n.localStore,e,!0),a=new VI(e,i.ks),c=a.ru(i.documents),u=$r.createSynthesizedTargetChangeForCurrentChange(t,r&&n.onlineState!=="Offline",s),h=a.applyChanges(c,n.isPrimaryClient,u);Hu(n,t,h.au);const f=new OI(e,t,a);return n.Tu.set(e,f),n.Iu.has(t)?n.Iu.get(t).push(e):n.Iu.set(t,[e]),h.snapshot}async function BI(n,e,t){const r=q(n),s=r.Tu.get(e),i=r.Iu.get(s.targetId);if(i.length>1)return r.Iu.set(s.targetId,i.filter((a=>!Ti(a,e)))),void r.Tu.delete(e);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(s.targetId),r.sharedClientState.isActiveQueryTarget(s.targetId)||await Ko(r.localStore,s.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(s.targetId),t&&Ha(r.remoteStore,s.targetId),Jo(r,s.targetId)})).catch(Hn)):(Jo(r,s.targetId),await Ko(r.localStore,s.targetId,!0))}async function qI(n,e){const t=q(n),r=t.Tu.get(e),s=t.Iu.get(r.targetId);t.isPrimaryClient&&s.length===1&&(t.sharedClientState.removeLocalQueryTarget(r.targetId),Ha(t.remoteStore,r.targetId))}async function $I(n,e,t){const r=QI(n);try{const s=await(function(a,c){const u=q(a),h=z.now(),f=c.reduce(((S,k)=>S.add(k.key)),K());let m,y;return u.persistence.runTransaction("Locally write mutations","readwrite",(S=>{let k=Et(),V=K();return u.xs.getEntries(S,f).next((N=>{k=N,k.forEach((($,W)=>{W.isValidDocument()||(V=V.add($))}))})).next((()=>u.localDocuments.getOverlayedDocuments(S,k))).next((N=>{m=N;const $=[];for(const W of c){const Q=nv(W,m.get(W.key).overlayedDocument);Q!=null&&$.push(new Qt(W.key,Q,of(Q.value.mapValue),Je.exists(!0)))}return u.mutationQueue.addMutationBatch(S,h,$,c)})).next((N=>{y=N;const $=N.applyToLocalDocumentSet(m,V);return u.documentOverlayCache.saveOverlays(S,N.batchId,$)}))})).then((()=>({batchId:y.batchId,changes:_f(m)})))})(r.localStore,e);r.sharedClientState.addPendingMutation(s.batchId),(function(a,c,u){let h=a.du[a.currentUser.toKey()];h||(h=new re(G)),h=h.insert(c,u),a.du[a.currentUser.toKey()]=h})(r,s.batchId,t),await zr(r,s.changes),await Si(r.remoteStore)}catch(s){const i=Ja(s,"Failed to persist write");t.reject(i)}}async function Xf(n,e){const t=q(n);try{const r=await eI(t.localStore,e);e.targetChanges.forEach(((s,i)=>{const a=t.Au.get(i);a&&(Y(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1,22616),s.addedDocuments.size>0?a.hu=!0:s.modifiedDocuments.size>0?Y(a.hu,14607):s.removedDocuments.size>0&&(Y(a.hu,42227),a.hu=!1))})),await zr(t,r,e)}catch(r){await Hn(r)}}function zu(n,e,t){const r=q(n);if(r.isPrimaryClient&&t===0||!r.isPrimaryClient&&t===1){const s=[];r.Tu.forEach(((i,a)=>{const c=a.view.va(e);c.snapshot&&s.push(c.snapshot)})),(function(a,c){const u=q(a);u.onlineState=c;let h=!1;u.queries.forEach(((f,m)=>{for(const y of m.ba)y.va(c)&&(h=!0)})),h&&Za(u)})(r.eventManager,e),s.length&&r.Pu.J_(s),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function jI(n,e,t){const r=q(n);r.sharedClientState.updateQueryState(e,"rejected",t);const s=r.Au.get(e),i=s&&s.key;if(i){let a=new re(M.comparator);a=a.insert(i,Ae.newNoDocument(i,B.min()));const c=K().add(i),u=new Ii(B.min(),new Map,new re(G),a,c);await Xf(r,u),r.Ru=r.Ru.remove(i),r.Au.delete(e),nc(r)}else await Ko(r.localStore,e,!1).then((()=>Jo(r,e,t))).catch(Hn)}async function zI(n,e){const t=q(n),r=e.batch.batchId;try{const s=await Zv(t.localStore,e);ep(t,r,null),Zf(t,r),t.sharedClientState.updateMutationState(r,"acknowledged"),await zr(t,s)}catch(s){await Hn(s)}}async function HI(n,e,t){const r=q(n);try{const s=await(function(a,c){const u=q(a);return u.persistence.runTransaction("Reject batch","readwrite-primary",(h=>{let f;return u.mutationQueue.lookupMutationBatch(h,c).next((m=>(Y(m!==null,37113),f=m.keys(),u.mutationQueue.removeMutationBatch(h,m)))).next((()=>u.mutationQueue.performConsistencyCheck(h))).next((()=>u.documentOverlayCache.removeOverlaysForBatchId(h,f,c))).next((()=>u.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(h,f))).next((()=>u.localDocuments.getDocuments(h,f)))}))})(r.localStore,e);ep(r,e,t),Zf(r,e),r.sharedClientState.updateMutationState(e,"rejected",t),await zr(r,s)}catch(s){await Hn(s)}}function Zf(n,e){(n.mu.get(e)||[]).forEach((t=>{t.resolve()})),n.mu.delete(e)}function ep(n,e,t){const r=q(n);let s=r.du[r.currentUser.toKey()];if(s){const i=s.get(e);i&&(t?i.reject(t):i.resolve(),s=s.remove(e)),r.du[r.currentUser.toKey()]=s}}function Jo(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(const r of n.Iu.get(e))n.Tu.delete(r),t&&n.Pu.yu(r,t);n.Iu.delete(e),n.isPrimaryClient&&n.Vu.Gr(e).forEach((r=>{n.Vu.containsKey(r)||tp(n,r)}))}function tp(n,e){n.Eu.delete(e.path.canonicalString());const t=n.Ru.get(e);t!==null&&(Ha(n.remoteStore,t),n.Ru=n.Ru.remove(e),n.Au.delete(t),nc(n))}function Hu(n,e,t){for(const r of t)r instanceof Qf?(n.Vu.addReference(r.key,e),GI(n,r)):r instanceof Jf?(L(tc,"Document no longer in limbo: "+r.key),n.Vu.removeReference(r.key,e),n.Vu.containsKey(r.key)||tp(n,r.key)):x(19791,{wu:r})}function GI(n,e){const t=e.key,r=t.path.canonicalString();n.Ru.get(t)||n.Eu.has(r)||(L(tc,"New document in limbo: "+t),n.Eu.add(r),nc(n))}function nc(n){for(;n.Eu.size>0&&n.Ru.size<n.maxConcurrentLimboResolutions;){const e=n.Eu.values().next().value;n.Eu.delete(e);const t=new M(Z.fromString(e)),r=n.fu.next();n.Au.set(r,new LI(t)),n.Ru=n.Ru.insert(t,r),jf(n.remoteStore,new Lt(st(yi(t.path)),r,"TargetPurposeLimboResolution",mi.ce))}}async function zr(n,e,t){const r=q(n),s=[],i=[],a=[];r.Tu.isEmpty()||(r.Tu.forEach(((c,u)=>{a.push(r.pu(u,e,t).then((h=>{if((h||t)&&r.isPrimaryClient){const f=h?!h.fromCache:t?.targetChanges.get(u.targetId)?.current;r.sharedClientState.updateQueryState(u.targetId,f?"current":"not-current")}if(h){s.push(h);const f=ja.Es(u.targetId,h);i.push(f)}})))})),await Promise.all(a),r.Pu.J_(s),await(async function(u,h){const f=q(u);try{await f.persistence.runTransaction("notifyLocalViewChanges","readwrite",(m=>C.forEach(h,(y=>C.forEach(y.Ts,(S=>f.persistence.referenceDelegate.addReference(m,y.targetId,S))).next((()=>C.forEach(y.Is,(S=>f.persistence.referenceDelegate.removeReference(m,y.targetId,S)))))))))}catch(m){if(!Gn(m))throw m;L(za,"Failed to update sequence numbers: "+m)}for(const m of h){const y=m.targetId;if(!m.fromCache){const S=f.vs.get(y),k=S.snapshotVersion,V=S.withLastLimboFreeSnapshotVersion(k);f.vs=f.vs.insert(y,V)}}})(r.localStore,i))}async function KI(n,e){const t=q(n);if(!t.currentUser.isEqual(e)){L(tc,"User change. New user:",e.toKey());const r=await Uf(t.localStore,e);t.currentUser=e,(function(i,a){i.mu.forEach((c=>{c.forEach((u=>{u.reject(new O(P.CANCELLED,a))}))})),i.mu.clear()})(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,r.removedBatchIds,r.addedBatchIds),await zr(t,r.Ns)}}function WI(n,e){const t=q(n),r=t.Au.get(e);if(r&&r.hu)return K().add(r.key);{let s=K();const i=t.Iu.get(e);if(!i)return s;for(const a of i){const c=t.Tu.get(a);s=s.unionWith(c.view.nu)}return s}}function np(n){const e=q(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=Xf.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=WI.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=jI.bind(null,e),e.Pu.J_=NI.bind(null,e.eventManager),e.Pu.yu=DI.bind(null,e.eventManager),e}function QI(n){const e=q(n);return e.remoteStore.remoteSyncer.applySuccessfulWrite=zI.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=HI.bind(null,e),e}class Gs{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=Ai(e.databaseInfo.databaseId),this.sharedClientState=this.Du(e),this.persistence=this.Cu(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Fu(e,this.localStore),this.indexBackfillerScheduler=this.Mu(e,this.localStore)}Fu(e,t){return null}Mu(e,t){return null}vu(e){return Xv(this.persistence,new Qv,e.initialUser,this.serializer)}Cu(e){return new Ff($a.Vi,this.serializer)}Du(e){return new iI}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}Gs.provider={build:()=>new Gs};class JI extends Gs{constructor(e){super(),this.cacheSizeBytes=e}Fu(e,t){Y(this.persistence.referenceDelegate instanceof zs,46915);const r=this.persistence.referenceDelegate.garbageCollector;return new Ov(r,e.asyncQueue,t)}Cu(e){const t=this.cacheSizeBytes!==void 0?Ve.withCacheSize(this.cacheSizeBytes):Ve.DEFAULT;return new Ff((r=>zs.Vi(r,t)),this.serializer)}}class Yo{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=r=>zu(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=KI.bind(null,this.syncEngine),await PI(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return(function(){return new kI})()}createDatastore(e){const t=Ai(e.databaseInfo.databaseId),r=uI(e.databaseInfo);return mI(e.authCredentials,e.appCheckCredentials,r,t)}createRemoteStore(e){return(function(r,s,i,a,c){return new _I(r,s,i,a,c)})(this.localStore,this.datastore,e.asyncQueue,(t=>zu(this.syncEngine,t,0)),(function(){return Fu.v()?new Fu:new oI})())}createSyncEngine(e,t){return(function(s,i,a,c,u,h,f){const m=new MI(s,i,a,c,u,h);return f&&(m.gu=!0),m})(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){await(async function(t){const r=q(t);L(mn,"RemoteStore shutting down."),r.Ea.add(5),await jr(r),r.Aa.shutdown(),r.Va.set("Unknown")})(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}}Yo.provider={build:()=>new Yo};class rc{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ou(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ou(this.observer.error,e):wt("Uncaught Error in snapshot listener:",e.toString()))}Nu(){this.muted=!0}Ou(e,t){setTimeout((()=>{this.muted||e(t)}),0)}}const Ht="FirestoreClient";class YI{constructor(e,t,r,s,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this._databaseInfo=s,this.user=Ie.UNAUTHENTICATED,this.clientId=ka.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(r,(async a=>{L(Ht,"Received user=",a.uid),await this.authCredentialListener(a),this.user=a})),this.appCheckCredentials.start(r,(a=>(L(Ht,"Received new app check token=",a),this.appCheckCredentialListener(a,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();const e=new _t;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){const r=Ja(t,"Failed to shutdown persistence");e.reject(r)}})),e.promise}}async function yo(n,e){n.asyncQueue.verifyOperationInProgress(),L(Ht,"Initializing OfflineComponentProvider");const t=n.configuration;await e.initialize(t);let r=t.initialUser;n.setCredentialChangeListener((async s=>{r.isEqual(s)||(await Uf(e.localStore,s),r=s)})),e.persistence.setDatabaseDeletedListener((()=>n.terminate())),n._offlineComponents=e}async function Gu(n,e){n.asyncQueue.verifyOperationInProgress();const t=await XI(n);L(Ht,"Initializing OnlineComponentProvider"),await e.initialize(t,n.configuration),n.setCredentialChangeListener((r=>Bu(e.remoteStore,r))),n.setAppCheckTokenChangeListener(((r,s)=>Bu(e.remoteStore,s))),n._onlineComponents=e}async function XI(n){if(!n._offlineComponents)if(n._uninitializedComponentsProvider){L(Ht,"Using user provided OfflineComponentProvider");try{await yo(n,n._uninitializedComponentsProvider._offline)}catch(e){const t=e;if(!(function(s){return s.name==="FirebaseError"?s.code===P.FAILED_PRECONDITION||s.code===P.UNIMPLEMENTED:!(typeof DOMException<"u"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11})(t))throw t;Ln("Error using user provided cache. Falling back to memory cache: "+t),await yo(n,new Gs)}}else L(Ht,"Using default OfflineComponentProvider"),await yo(n,new JI(void 0));return n._offlineComponents}async function rp(n){return n._onlineComponents||(n._uninitializedComponentsProvider?(L(Ht,"Using user provided OnlineComponentProvider"),await Gu(n,n._uninitializedComponentsProvider._online)):(L(Ht,"Using default OnlineComponentProvider"),await Gu(n,new Yo))),n._onlineComponents}function ZI(n){return rp(n).then((e=>e.syncEngine))}async function Ks(n){const e=await rp(n),t=e.eventManager;return t.onListen=xI.bind(null,e.syncEngine),t.onUnlisten=BI.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=FI.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=qI.bind(null,e.syncEngine),t}function eA(n,e,t,r){const s=new rc(r),i=new ec(e,s,t);return n.asyncQueue.enqueueAndForget((async()=>Ya(await Ks(n),i))),()=>{s.Nu(),n.asyncQueue.enqueueAndForget((async()=>Xa(await Ks(n),i)))}}function tA(n,e,t={}){const r=new _t;return n.asyncQueue.enqueueAndForget((async()=>(function(i,a,c,u,h){const f=new rc({next:y=>{f.Nu(),a.enqueueAndForget((()=>Xa(i,m)));const S=y.docs.has(c);!S&&y.fromCache?h.reject(new O(P.UNAVAILABLE,"Failed to get document because the client is offline.")):S&&y.fromCache&&u&&u.source==="server"?h.reject(new O(P.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):h.resolve(y)},error:y=>h.reject(y)}),m=new ec(yi(c.path),f,{includeMetadataChanges:!0,Ka:!0});return Ya(i,m)})(await Ks(n),n.asyncQueue,e,t,r))),r.promise}function nA(n,e,t={}){const r=new _t;return n.asyncQueue.enqueueAndForget((async()=>(function(i,a,c,u,h){const f=new rc({next:y=>{f.Nu(),a.enqueueAndForget((()=>Xa(i,m))),y.fromCache&&u.source==="server"?h.reject(new O(P.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):h.resolve(y)},error:y=>h.reject(y)}),m=new ec(c,f,{includeMetadataChanges:!0,Ka:!0});return Ya(i,m)})(await Ks(n),n.asyncQueue,e,t,r))),r.promise}function rA(n,e){const t=new _t;return n.asyncQueue.enqueueAndForget((async()=>$I(await ZI(n),e,t))),t.promise}function sp(n){const e={};return n.timeoutSeconds!==void 0&&(e.timeoutSeconds=n.timeoutSeconds),e}const sA="ComponentProvider",Ku=new Map;function iA(n,e,t,r,s){return new AE(n,e,t,s.host,s.ssl,s.experimentalForceLongPolling,s.experimentalAutoDetectLongPolling,sp(s.experimentalLongPollingOptions),s.useFetchStreams,s.isUsingEmulator,r)}const ip="firestore.googleapis.com",Wu=!0;class Qu{constructor(e){if(e.host===void 0){if(e.ssl!==void 0)throw new O(P.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=ip,this.ssl=Wu}else this.host=e.host,this.ssl=e.ssl??Wu;if(this.isUsingEmulator=e.emulatorOptions!==void 0,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=xf;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<Dv)throw new O(P.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}dE("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=sp(e.experimentalLongPollingOptions??{}),(function(r){if(r.timeoutSeconds!==void 0){if(isNaN(r.timeoutSeconds))throw new O(P.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (must not be NaN)`);if(r.timeoutSeconds<5)throw new O(P.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (minimum allowed value is 5)`);if(r.timeoutSeconds>30)throw new O(P.INVALID_ARGUMENT,`invalid long polling timeout: ${r.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(r,s){return r.timeoutSeconds===s.timeoutSeconds})(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class Ri{constructor(e,t,r,s){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Qu({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new O(P.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(e){if(this._settingsFrozen)throw new O(P.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new Qu(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=(function(r){if(!r)return new nE;switch(r.type){case"firstParty":return new oE(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new O(P.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}})(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return(function(t){const r=Ku.get(t);r&&(L(sA,"Removing Datastore"),Ku.delete(t),r.terminate())})(this),Promise.resolve()}}function op(n,e,t,r={}){n=qe(n,Ri);const s=vt(e),i=n._getSettings(),a={...i,emulatorOptions:n._getEmulatorOptions()},c=`${e}:${t}`;s&&(ii(`https://${c}`),oi("Firestore",!0)),i.host!==ip&&i.host!==c&&Ln("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const u={...i,host:c,ssl:s,emulatorOptions:r};if(!Ut(u,a)&&(n._setSettings(u),r.mockUserToken)){let h,f;if(typeof r.mockUserToken=="string")h=r.mockUserToken,f=Ie.MOCK_USER;else{h=Oh(r.mockUserToken,n._app?.options.projectId);const m=r.mockUserToken.sub||r.mockUserToken.user_id;if(!m)throw new O(P.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");f=new Ie(m)}n._authCredentials=new rE(new Kd(h,f))}}class It{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new It(this.firestore,e,this._query)}}class ie{constructor(e,t,r){this.converter=t,this._key=r,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 Ft(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new ie(this.firestore,e,this._key)}toJSON(){return{type:ie._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,r){if(Br(t,ie._jsonSchema))return new ie(e,r||null,new M(Z.fromString(t.referencePath)))}}ie._jsonSchemaVersion="firestore/documentReference/1.0",ie._jsonSchema={type:ue("string",ie._jsonSchemaVersion),referencePath:ue("string")};class Ft extends It{constructor(e,t,r){super(e,t,yi(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new ie(this.firestore,null,new M(e))}withConverter(e){return new Ft(this.firestore,e,this._path)}}function oA(n,e,...t){if(n=ee(n),Wd("collection","path",e),n instanceof Ri){const r=Z.fromString(e,...t);return cu(r),new Ft(n,null,r)}{if(!(n instanceof ie||n instanceof Ft))throw new O(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(Z.fromString(e,...t));return cu(r),new Ft(n.firestore,null,r)}}function Ir(n,e,...t){if(n=ee(n),arguments.length===1&&(e=ka.newId()),Wd("doc","path",e),n instanceof Ri){const r=Z.fromString(e,...t);return au(r),new ie(n,null,new M(r))}{if(!(n instanceof ie||n instanceof Ft))throw new O(P.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(Z.fromString(e,...t));return au(r),new ie(n.firestore,n instanceof Ft?n.converter:null,new M(r))}}const Ju="AsyncQueue";class Yu{constructor(e=Promise.resolve()){this.Yu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new qf(this,"async_queue_retry"),this._c=()=>{const r=_o();r&&L(Ju,"Visibility state changed to "+r.visibilityState),this.M_.w_()},this.ac=e;const t=_o();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this._c)}get isShuttingDown(){return this.ec}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.uc(),this.cc(e)}enterRestrictedMode(e){if(!this.ec){this.ec=!0,this.sc=e||!1;const t=_o();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this._c)}}enqueue(e){if(this.uc(),this.ec)return new Promise((()=>{}));const t=new _t;return this.cc((()=>this.ec&&this.sc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.Yu.push(e),this.lc())))}async lc(){if(this.Yu.length!==0){try{await this.Yu[0](),this.Yu.shift(),this.M_.reset()}catch(e){if(!Gn(e))throw e;L(Ju,"Operation failed with retryable error: "+e)}this.Yu.length>0&&this.M_.p_((()=>this.lc()))}}cc(e){const t=this.ac.then((()=>(this.rc=!0,e().catch((r=>{throw this.nc=r,this.rc=!1,wt("INTERNAL UNHANDLED ERROR: ",Xu(r)),r})).then((r=>(this.rc=!1,r))))));return this.ac=t,t}enqueueAfterDelay(e,t,r){this.uc(),this.oc.indexOf(e)>-1&&(t=0);const s=Qa.createAndSchedule(this,e,t,r,(i=>this.hc(i)));return this.tc.push(s),s}uc(){this.nc&&x(47125,{Pc:Xu(this.nc)})}verifyOperationInProgress(){}async Tc(){let e;do e=this.ac,await e;while(e!==this.ac)}Ic(e){for(const t of this.tc)if(t.timerId===e)return!0;return!1}Ec(e){return this.Tc().then((()=>{this.tc.sort(((t,r)=>t.targetTimeMs-r.targetTimeMs));for(const t of this.tc)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.Tc()}))}Rc(e){this.oc.push(e)}hc(e){const t=this.tc.indexOf(e);this.tc.splice(t,1)}}function Xu(n){let e=n.message||"";return n.stack&&(e=n.stack.includes(n.message)?n.stack:n.message+`
36
+ `+n.stack),e}class Gt extends Ri{constructor(e,t,r,s){super(e,t,r,s),this.type="firestore",this._queue=new Yu,this._persistenceKey=s?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new Yu(e),this._firestoreClient=void 0,await e}}}function aA(n,e){const t=typeof n=="object"?n:$n(),r=typeof n=="string"?n:xs,s=ut(t,"firestore").getImmediate({identifier:r});if(!s._initialized){const i=la("firestore");i&&op(s,...i)}return s}function Pi(n){if(n._terminated)throw new O(P.FAILED_PRECONDITION,"The client has already been terminated.");return n._firestoreClient||cA(n),n._firestoreClient}function cA(n){const e=n._freezeSettings(),t=iA(n._databaseId,n._app?.options.appId||"",n._persistenceKey,n._app?.options.apiKey,e);n._componentsProvider||e.localCache?._offlineComponentProvider&&e.localCache?._onlineComponentProvider&&(n._componentsProvider={_offline:e.localCache._offlineComponentProvider,_online:e.localCache._onlineComponentProvider}),n._firestoreClient=new YI(n._authCredentials,n._appCheckCredentials,n._queue,t,n._componentsProvider&&(function(s){const i=s?._online.build();return{_offline:s?._offline.build(i),_online:i}})(n._componentsProvider))}class ze{constructor(e){this._byteString=e}static fromBase64String(e){try{return new ze(Te.fromBase64String(e))}catch(t){throw new O(P.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new ze(Te.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)}toJSON(){return{type:ze._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(Br(e,ze._jsonSchema))return ze.fromBase64String(e.bytes)}}ze._jsonSchemaVersion="firestore/bytes/1.0",ze._jsonSchema={type:ue("string",ze._jsonSchemaVersion),bytes:ue("string")};class Ci{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new O(P.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new ye(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}function Xo(){return new Ci(xo)}class Or{constructor(e){this._methodName=e}}class ot{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new O(P.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new O(P.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}_compareTo(e){return G(this._lat,e._lat)||G(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:ot._jsonSchemaVersion}}static fromJSON(e){if(Br(e,ot._jsonSchema))return new ot(e.latitude,e.longitude)}}ot._jsonSchemaVersion="firestore/geoPoint/1.0",ot._jsonSchema={type:ue("string",ot._jsonSchemaVersion),latitude:ue("number"),longitude:ue("number")};class Ye{constructor(e){this._values=(e||[]).map((t=>t))}toArray(){return this._values.map((e=>e))}isEqual(e){return(function(r,s){if(r.length!==s.length)return!1;for(let i=0;i<r.length;++i)if(r[i]!==s[i])return!1;return!0})(this._values,e._values)}toJSON(){return{type:Ye._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(Br(e,Ye._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every((t=>typeof t=="number")))return new Ye(e.vectorValues);throw new O(P.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}Ye._jsonSchemaVersion="firestore/vectorValue/1.0",Ye._jsonSchema={type:ue("string",Ye._jsonSchemaVersion),vectorValues:ue("object")};const lA=/^__.*__$/;class uA{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return this.fieldMask!==null?new Qt(e,this.data,this.fieldMask,t,this.fieldTransforms):new qr(e,this.data,t,this.fieldTransforms)}}class ap{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return new Qt(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function cp(n){switch(n){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw x(40011,{dataSource:n})}}class sc{constructor(e,t,r,s,i,a){this.settings=e,this.databaseId=t,this.serializer=r,this.ignoreUndefinedProperties=s,i===void 0&&this.validatePath(),this.fieldTransforms=i||[],this.fieldMask=a||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}contextWith(e){return new sc({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}childContextForField(e){const t=this.path?.child(e),r=this.contextWith({path:t,arrayElement:!1});return r.validatePathSegment(e),r}childContextForFieldPath(e){const t=this.path?.child(e),r=this.contextWith({path:t,arrayElement:!1});return r.validatePath(),r}childContextForArray(e){return this.contextWith({path:void 0,arrayElement:!0})}createError(e){return Ws(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return this.fieldMask.find((t=>e.isPrefixOf(t)))!==void 0||this.fieldTransforms.find((t=>e.isPrefixOf(t.field)))!==void 0}validatePath(){if(this.path)for(let e=0;e<this.path.length;e++)this.validatePathSegment(this.path.get(e))}validatePathSegment(e){if(e.length===0)throw this.createError("Document fields must not be empty");if(cp(this.dataSource)&&lA.test(e))throw this.createError('Document fields cannot begin and end with "__"')}}class hA{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=r||Ai(e)}createContext(e,t,r,s=!1){return new sc({dataSource:e,methodName:t,targetDoc:r,path:ye.emptyPath(),arrayElement:!1,hasConverter:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function ic(n){const e=n._freezeSettings(),t=Ai(n._databaseId);return new hA(n._databaseId,!!e.ignoreUndefinedProperties,t)}function dA(n,e,t,r,s,i={}){const a=n.createContext(i.merge||i.mergeFields?2:0,e,t,s);oc("Data must be an object, but it was:",a,r);const c=lp(r,a);let u,h;if(i.merge)u=new Ue(a.fieldMask),h=a.fieldTransforms;else if(i.mergeFields){const f=[];for(const m of i.mergeFields){const y=gn(e,m,t);if(!a.contains(y))throw new O(P.INVALID_ARGUMENT,`Field '${y}' is specified in your field mask but missing from your input data.`);dp(f,y)||f.push(y)}u=new Ue(f),h=a.fieldTransforms.filter((m=>u.covers(m.field)))}else u=null,h=a.fieldTransforms;return new uA(new Oe(c),u,h)}class Hr extends Or{_toFieldTransform(e){if(e.dataSource!==2)throw e.dataSource===1?e.createError(`${this._methodName}() can only appear at the top level of your update data`):e.createError(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof Hr}}function fA(n,e,t,r){const s=n.createContext(1,e,t);oc("Data must be an object, but it was:",s,r);const i=[],a=Oe.empty();Wt(r,((u,h)=>{const f=hp(e,u,t);h=ee(h);const m=s.childContextForFieldPath(f);if(h instanceof Hr)i.push(f);else{const y=Gr(h,m);y!=null&&(i.push(f),a.set(f,y))}}));const c=new Ue(i);return new ap(a,c,s.fieldTransforms)}function pA(n,e,t,r,s,i){const a=n.createContext(1,e,t),c=[gn(e,r,t)],u=[s];if(i.length%2!=0)throw new O(P.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let y=0;y<i.length;y+=2)c.push(gn(e,i[y])),u.push(i[y+1]);const h=[],f=Oe.empty();for(let y=c.length-1;y>=0;--y)if(!dp(h,c[y])){const S=c[y];let k=u[y];k=ee(k);const V=a.childContextForFieldPath(S);if(k instanceof Hr)h.push(S);else{const N=Gr(k,V);N!=null&&(h.push(S),f.set(S,N))}}const m=new Ue(h);return new ap(f,m,a.fieldTransforms)}function mA(n,e,t,r=!1){return Gr(t,n.createContext(r?4:3,e))}function Gr(n,e){if(up(n=ee(n)))return oc("Unsupported field value:",e,n),lp(n,e);if(n instanceof Or)return(function(r,s){if(!cp(s.dataSource))throw s.createError(`${r._methodName}() can only be used with update() and set()`);if(!s.path)throw s.createError(`${r._methodName}() is not currently supported inside arrays`);const i=r._toFieldTransform(s);i&&s.fieldTransforms.push(i)})(n,e),null;if(n===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),n instanceof Array){if(e.settings.arrayElement&&e.dataSource!==4)throw e.createError("Nested arrays are not supported");return(function(r,s){const i=[];let a=0;for(const c of r){let u=Gr(c,s.childContextForArray(a));u==null&&(u={nullValue:"NULL_VALUE"}),i.push(u),a++}return{arrayValue:{values:i}}})(n,e)}return(function(r,s){if((r=ee(r))===null)return{nullValue:"NULL_VALUE"};if(typeof r=="number")return JE(s.serializer,r);if(typeof r=="boolean")return{booleanValue:r};if(typeof r=="string")return{stringValue:r};if(r instanceof Date){const i=z.fromDate(r);return{timestampValue:js(s.serializer,i)}}if(r instanceof z){const i=new z(r.seconds,1e3*Math.floor(r.nanoseconds/1e3));return{timestampValue:js(s.serializer,i)}}if(r instanceof ot)return{geoPointValue:{latitude:r.latitude,longitude:r.longitude}};if(r instanceof ze)return{bytesValue:Cf(s.serializer,r._byteString)};if(r instanceof ie){const i=s.databaseId,a=r.firestore._databaseId;if(!a.isEqual(i))throw s.createError(`Document reference is for database ${a.projectId}/${a.database} but should be for database ${i.projectId}/${i.database}`);return{referenceValue:Ba(r.firestore._databaseId||s.databaseId,r._key.path)}}if(r instanceof Ye)return(function(a,c){const u=a instanceof Ye?a.toArray():a;return{mapValue:{fields:{[rf]:{stringValue:sf},[Fs]:{arrayValue:{values:u.map((f=>{if(typeof f!="number")throw c.createError("VectorValues must only contain numeric values.");return Ma(c.serializer,f)}))}}}}}})(r,s);if(Mf(r))return r._toProto(s.serializer);throw s.createError(`Unsupported field value: ${pi(r)}`)})(n,e)}function lp(n,e){const t={};return Yd(n)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):Wt(n,((r,s)=>{const i=Gr(s,e.childContextForField(r));i!=null&&(t[r]=i)})),{mapValue:{fields:t}}}function up(n){return!(typeof n!="object"||n===null||n instanceof Array||n instanceof Date||n instanceof z||n instanceof ot||n instanceof ze||n instanceof ie||n instanceof Or||n instanceof Ye||Mf(n))}function oc(n,e,t){if(!up(t)||!Qd(t)){const r=pi(t);throw r==="an object"?e.createError(n+" a custom object"):e.createError(n+" "+r)}}function gn(n,e,t){if((e=ee(e))instanceof Ci)return e._internalPath;if(typeof e=="string")return hp(n,e);throw Ws("Field path arguments must be of type string or ",n,!1,void 0,t)}const gA=new RegExp("[~\\*/\\[\\]]");function hp(n,e,t){if(e.search(gA)>=0)throw Ws(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n,!1,void 0,t);try{return new Ci(...e.split("."))._internalPath}catch{throw Ws(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n,!1,void 0,t)}}function Ws(n,e,t,r,s){const i=r&&!r.isEmpty(),a=s!==void 0;let c=`Function ${e}() called with invalid data`;t&&(c+=" (via `toFirestore()`)"),c+=". ";let u="";return(i||a)&&(u+=" (found",i&&(u+=` in field ${r}`),a&&(u+=` in document ${s}`),u+=")"),new O(P.INVALID_ARGUMENT,c+n+u)}function dp(n,e){return n.some((t=>t.isEqual(e)))}class _A{convertValue(e,t="none"){switch(jt(e)){case 0:return null;case 1:return e.booleanValue;case 2:return ae(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($t(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 x(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const r={};return Wt(e,((s,i)=>{r[s]=this.convertValue(i,t)})),r}convertVectorValue(e){const t=e.fields?.[Fs].arrayValue?.values?.map((r=>ae(r.doubleValue)));return new Ye(t)}convertGeoPoint(e){return new ot(ae(e.latitude),ae(e.longitude))}convertArray(e,t){return(e.values||[]).map((r=>this.convertValue(r,t)))}convertServerTimestamp(e,t){switch(t){case"previous":const r=_i(e);return r==null?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(Pr(e));default:return null}}convertTimestamp(e){const t=qt(e);return new z(t.seconds,t.nanos)}convertDocumentKey(e,t){const r=Z.fromString(e);Y(Lf(r),9688,{name:e});const s=new Cr(r.get(1),r.get(3)),i=new M(r.popFirst(5));return s.isEqual(t)||wt(`Document ${i} 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.`),i}}class ac extends _A{constructor(e){super(),this.firestore=e}convertBytes(e){return new ze(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new ie(this.firestore,null,t)}}function Zo(){return new Hr("deleteField")}const Zu="@firebase/firestore",eh="4.10.0";function th(n){return(function(t,r){if(typeof t!="object"||t===null)return!1;const s=t;for(const i of r)if(i in s&&typeof s[i]=="function")return!0;return!1})(n,["next","error","complete"])}class fp{constructor(e,t,r,s,i){this._firestore=e,this._userDataWriter=t,this._key=r,this._document=s,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new ie(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new yA(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){const t=this._document.data.field(gn("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}}class yA extends fp{data(){return super.data()}}function pp(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new O(P.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class cc{}class lc extends cc{}function nh(n,e,...t){let r=[];e instanceof cc&&r.push(e),r=r.concat(t),(function(i){const a=i.filter((u=>u instanceof uc)).length,c=i.filter((u=>u instanceof ki)).length;if(a>1||a>0&&c>0)throw new O(P.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")})(r);for(const s of r)n=s._apply(n);return n}class ki extends lc{constructor(e,t,r){super(),this._field=e,this._op=t,this._value=r,this.type="where"}static _create(e,t,r){return new ki(e,t,r)}_apply(e){const t=this._parse(e);return mp(e._query,t),new It(e.firestore,e.converter,$o(e._query,t))}_parse(e){const t=ic(e.firestore);return(function(i,a,c,u,h,f,m){let y;if(h.isKeyField()){if(f==="array-contains"||f==="array-contains-any")throw new O(P.INVALID_ARGUMENT,`Invalid Query. You can't perform '${f}' queries on documentId().`);if(f==="in"||f==="not-in"){sh(m,f);const k=[];for(const V of m)k.push(rh(u,i,V));y={arrayValue:{values:k}}}else y=rh(u,i,m)}else f!=="in"&&f!=="not-in"&&f!=="array-contains-any"||sh(m,f),y=mA(c,a,m,f==="in"||f==="not-in");return le.create(h,f,y)})(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}function ea(n,e,t){const r=e,s=gn("where",n);return ki._create(s,r,t)}class uc extends cc{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new uc(e,t)}_parse(e){const t=this._queryConstraints.map((r=>r._parse(e))).filter((r=>r.getFilters().length>0));return t.length===1?t[0]:Xe.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return t.getFilters().length===0?e:((function(s,i){let a=s;const c=i.getFlattenedFilters();for(const u of c)mp(a,u),a=$o(a,u)})(e._query,t),new It(e.firestore,e.converter,$o(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}class hc extends lc{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new hc(e,t)}_apply(e){const t=(function(s,i,a){if(s.startAt!==null)throw new O(P.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(s.endAt!==null)throw new O(P.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new Nr(i,a)})(e._query,this._field,this._direction);return new It(e.firestore,e.converter,$E(e._query,t))}}function To(n,e="asc"){const t=e,r=gn("orderBy",n);return hc._create(r,t)}class dc extends lc{constructor(e,t,r){super(),this.type=e,this._limit=t,this._limitType=r}static _create(e,t,r){return new dc(e,t,r)}_apply(e){return new It(e.firestore,e.converter,Bs(e._query,this._limit,this._limitType))}}function wo(n){return fE("limit",n),dc._create("limit",n,"F")}function rh(n,e,t){if(typeof(t=ee(t))=="string"){if(t==="")throw new O(P.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!ff(e)&&t.indexOf("/")!==-1)throw new O(P.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${t}' contains a '/' character.`);const r=e.path.child(Z.fromString(t));if(!M.isDocumentKey(r))throw new O(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return gu(n,new M(r))}if(t instanceof ie)return gu(n,t._key);throw new O(P.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${pi(t)}.`)}function sh(n,e){if(!Array.isArray(n)||n.length===0)throw new O(P.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`)}function mp(n,e){const t=(function(s,i){for(const a of s)for(const c of a.getFlattenedFilters())if(i.indexOf(c.op)>=0)return c.op;return null})(n.filters,(function(s){switch(s){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}})(e.op));if(t!==null)throw t===e.op?new O(P.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new O(P.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${t.toString()}' filters.`)}function TA(n,e,t){let r;return r=n?t&&(t.merge||t.mergeFields)?n.toFirestore(e,t):n.toFirestore(e):e,r}class mr{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class cn extends fp{constructor(e,t,r,s,i,a){super(e,t,r,s,a),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new As(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){const r=this._document.data.field(gn("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new O(P.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e=this._document,t={};return t.type=cn._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),!e||!e.isValidDocument()||!e.isFoundDocument()?t:(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),t.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),t)}}cn._jsonSchemaVersion="firestore/documentSnapshot/1.0",cn._jsonSchema={type:ue("string",cn._jsonSchemaVersion),bundleSource:ue("string","DocumentSnapshot"),bundleName:ue("string"),bundle:ue("string")};class As extends cn{data(e={}){return super.data(e)}}class ln{constructor(e,t,r,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new mr(s.hasPendingWrites,s.fromCache),this.query=r}get docs(){const 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((r=>{e.call(t,new As(this._firestore,this._userDataWriter,r.key,r,new mr(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new O(P.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,i){if(s._snapshot.oldDocs.isEmpty()){let a=0;return s._snapshot.docChanges.map((c=>{const u=new As(s._firestore,s._userDataWriter,c.doc.key,c.doc,new mr(s._snapshot.mutatedKeys.has(c.doc.key),s._snapshot.fromCache),s.query.converter);return c.doc,{type:"added",doc:u,oldIndex:-1,newIndex:a++}}))}{let a=s._snapshot.oldDocs;return s._snapshot.docChanges.filter((c=>i||c.type!==3)).map((c=>{const u=new As(s._firestore,s._userDataWriter,c.doc.key,c.doc,new mr(s._snapshot.mutatedKeys.has(c.doc.key),s._snapshot.fromCache),s.query.converter);let h=-1,f=-1;return c.type!==0&&(h=a.indexOf(c.doc.key),a=a.delete(c.doc.key)),c.type!==1&&(a=a.add(c.doc),f=a.indexOf(c.doc.key)),{type:wA(c.type),doc:u,oldIndex:h,newIndex:f}}))}})(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new O(P.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=ln._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=ka.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const t=[],r=[],s=[];return this.docs.forEach((i=>{i._document!==null&&(t.push(i._document),r.push(this._userDataWriter.convertObjectMap(i._document.data.value.mapValue.fields,"previous")),s.push(i.ref.path))})),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function wA(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return x(61501,{type:n})}}ln._jsonSchemaVersion="firestore/querySnapshot/1.0",ln._jsonSchema={type:ue("string",ln._jsonSchemaVersion),bundleSource:ue("string","QuerySnapshot"),bundleName:ue("string"),bundle:ue("string")};function ta(n){n=qe(n,ie);const e=qe(n.firestore,Gt),t=Pi(e);return tA(t,n._key).then((r=>_p(e,n,r)))}function EA(n){n=qe(n,It);const e=qe(n.firestore,Gt),t=Pi(e),r=new ac(e);return pp(n._query),nA(t,n._query).then((s=>new ln(e,r,n,s)))}function gp(n,e,t){n=qe(n,ie);const r=qe(n.firestore,Gt),s=TA(n.converter,e,t),i=ic(r);return fc(r,[dA(i,"setDoc",n._key,s,n.converter!==null,t).toMutation(n._key,Je.none())])}function vA(n,e,t,...r){n=qe(n,ie);const s=qe(n.firestore,Gt),i=ic(s);let a;return a=typeof(e=ee(e))=="string"||e instanceof Ci?pA(i,"updateDoc",n._key,e,t,r):fA(i,"updateDoc",n._key,e),fc(s,[a.toMutation(n._key,Je.exists(!0))])}function IA(n){return fc(qe(n.firestore,Gt),[new xa(n._key,Je.none())])}function AA(n,...e){n=ee(n);let t={includeMetadataChanges:!1,source:"default"},r=0;typeof e[r]!="object"||th(e[r])||(t=e[r++]);const s={includeMetadataChanges:t.includeMetadataChanges,source:t.source};if(th(e[r])){const h=e[r];e[r]=h.next?.bind(h),e[r+1]=h.error?.bind(h),e[r+2]=h.complete?.bind(h)}let i,a,c;if(n instanceof ie)a=qe(n.firestore,Gt),c=yi(n._key.path),i={next:h=>{e[r]&&e[r](_p(a,n,h))},error:e[r+1],complete:e[r+2]};else{const h=qe(n,It);a=qe(h.firestore,Gt),c=h._query;const f=new ac(a);i={next:m=>{e[r]&&e[r](new ln(a,f,h,m))},error:e[r+1],complete:e[r+2]},pp(n._query)}const u=Pi(a);return eA(u,c,s,i)}function fc(n,e){const t=Pi(n);return rA(t,e)}function _p(n,e,t){const r=t.docs.get(e._key),s=new ac(n);return new cn(n,s,e._key,r,new mr(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){tE(yn),Me(new Ne("firestore",((r,{instanceIdentifier:s,options:i})=>{const a=r.getProvider("app").getImmediate(),c=new Gt(new sE(r.getProvider("auth-internal")),new aE(a,r.getProvider("app-check-internal")),bE(a,s),a);return i={useFetchStreams:t,...i},c._setSettings(i),c}),"PUBLIC").setMultipleInstances(!0)),me(Zu,eh,e),me(Zu,eh,"esm2020")})();const yp="firebasestorage.googleapis.com",bA="storageBucket",SA=120*1e3,RA=600*1e3;class ht extends $e{constructor(e,t,r=0){super(Eo(e),`Firebase Storage: ${t} (${Eo(e)})`),this.status_=r,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,ht.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return Eo(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}
37
+ ${this.customData.serverResponse}`:this.message=this._baseMessage}}var lt;(function(n){n.UNKNOWN="unknown",n.OBJECT_NOT_FOUND="object-not-found",n.BUCKET_NOT_FOUND="bucket-not-found",n.PROJECT_NOT_FOUND="project-not-found",n.QUOTA_EXCEEDED="quota-exceeded",n.UNAUTHENTICATED="unauthenticated",n.UNAUTHORIZED="unauthorized",n.UNAUTHORIZED_APP="unauthorized-app",n.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",n.INVALID_CHECKSUM="invalid-checksum",n.CANCELED="canceled",n.INVALID_EVENT_NAME="invalid-event-name",n.INVALID_URL="invalid-url",n.INVALID_DEFAULT_BUCKET="invalid-default-bucket",n.NO_DEFAULT_BUCKET="no-default-bucket",n.CANNOT_SLICE_BLOB="cannot-slice-blob",n.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",n.NO_DOWNLOAD_URL="no-download-url",n.INVALID_ARGUMENT="invalid-argument",n.INVALID_ARGUMENT_COUNT="invalid-argument-count",n.APP_DELETED="app-deleted",n.INVALID_ROOT_OPERATION="invalid-root-operation",n.INVALID_FORMAT="invalid-format",n.INTERNAL_ERROR="internal-error",n.UNSUPPORTED_ENVIRONMENT="unsupported-environment"})(lt||(lt={}));function Eo(n){return"storage/"+n}function PA(){const n="An unknown error occurred, please check the error payload for server response.";return new ht(lt.UNKNOWN,n)}function CA(){return new ht(lt.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function kA(){return new ht(lt.CANCELED,"User canceled the upload/download.")}function NA(n){return new ht(lt.INVALID_URL,"Invalid URL '"+n+"'.")}function DA(n){return new ht(lt.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+n+"'.")}function ih(n){return new ht(lt.INVALID_ARGUMENT,n)}function Tp(){return new ht(lt.APP_DELETED,"The Firebase app was deleted.")}function VA(n){return new ht(lt.INVALID_ROOT_OPERATION,"The operation '"+n+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}class We{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,t){let r;try{r=We.makeFromUrl(e,t)}catch{return new We(e,"")}if(r.path==="")return r;throw DA(e)}static makeFromUrl(e,t){let r=null;const s="([A-Za-z0-9.\\-_]+)";function i(te){te.path.charAt(te.path.length-1)==="/"&&(te.path_=te.path_.slice(0,-1))}const a="(/(.*))?$",c=new RegExp("^gs://"+s+a,"i"),u={bucket:1,path:3};function h(te){te.path_=decodeURIComponent(te.path)}const f="v[A-Za-z0-9_]+",m=t.replace(/[.]/g,"\\."),y="(/([^?#]*).*)?$",S=new RegExp(`^https?://${m}/${f}/b/${s}/o${y}`,"i"),k={bucket:1,path:3},V=t===yp?"(?:storage.googleapis.com|storage.cloud.google.com)":t,N="([^?#]*)",$=new RegExp(`^https?://${V}/${s}/${N}`,"i"),Q=[{regex:c,indices:u,postModify:i},{regex:S,indices:k,postModify:h},{regex:$,indices:{bucket:1,path:2},postModify:h}];for(let te=0;te<Q.length;te++){const we=Q[te],oe=we.regex.exec(e);if(oe){const v=oe[we.indices.bucket];let g=oe[we.indices.path];g||(g=""),r=new We(v,g),we.postModify(r);break}}if(r==null)throw NA(e);return r}}class OA{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}}function LA(n,e,t){let r=1,s=null,i=null,a=!1,c=0;function u(){return c===2}let h=!1;function f(...N){h||(h=!0,e.apply(null,N))}function m(N){s=setTimeout(()=>{s=null,n(S,u())},N)}function y(){i&&clearTimeout(i)}function S(N,...$){if(h){y();return}if(N){y(),f.call(null,N,...$);return}if(u()||a){y(),f.call(null,N,...$);return}r<64&&(r*=2);let Q;c===1?(c=2,Q=0):Q=(r+Math.random())*1e3,m(Q)}let k=!1;function V(N){k||(k=!0,y(),!h&&(s!==null?(N||(c=2),clearTimeout(s),m(0)):N||(c=1)))}return m(0),i=setTimeout(()=>{a=!0,V(!0)},t),V}function MA(n){n(!1)}function xA(n){return n!==void 0}function oh(n,e,t,r){if(r<e)throw ih(`Invalid value for '${n}'. Expected ${e} or greater.`);if(r>t)throw ih(`Invalid value for '${n}'. Expected ${t} or less.`)}function FA(n){const e=encodeURIComponent;let t="?";for(const r in n)if(n.hasOwnProperty(r)){const s=e(r)+"="+e(n[r]);t=t+s+"&"}return t=t.slice(0,-1),t}var Qs;(function(n){n[n.NO_ERROR=0]="NO_ERROR",n[n.NETWORK_ERROR=1]="NETWORK_ERROR",n[n.ABORT=2]="ABORT"})(Qs||(Qs={}));function UA(n,e){const t=n>=500&&n<600,s=[408,429].indexOf(n)!==-1,i=e.indexOf(n)!==-1;return t||s||i}class BA{constructor(e,t,r,s,i,a,c,u,h,f,m,y=!0,S=!1){this.url_=e,this.method_=t,this.headers_=r,this.body_=s,this.successCodes_=i,this.additionalRetryCodes_=a,this.callback_=c,this.errorCallback_=u,this.timeout_=h,this.progressCallback_=f,this.connectionFactory_=m,this.retry=y,this.isUsingEmulator=S,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((k,V)=>{this.resolve_=k,this.reject_=V,this.start_()})}start_(){const e=(r,s)=>{if(s){r(!1,new ps(!1,null,!0));return}const i=this.connectionFactory_();this.pendingConnection_=i;const a=c=>{const u=c.loaded,h=c.lengthComputable?c.total:-1;this.progressCallback_!==null&&this.progressCallback_(u,h)};this.progressCallback_!==null&&i.addUploadProgressListener(a),i.send(this.url_,this.method_,this.isUsingEmulator,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&i.removeUploadProgressListener(a),this.pendingConnection_=null;const c=i.getErrorCode()===Qs.NO_ERROR,u=i.getStatus();if(!c||UA(u,this.additionalRetryCodes_)&&this.retry){const f=i.getErrorCode()===Qs.ABORT;r(!1,new ps(!1,null,f));return}const h=this.successCodes_.indexOf(u)!==-1;r(!0,new ps(h,i))})},t=(r,s)=>{const i=this.resolve_,a=this.reject_,c=s.connection;if(s.wasSuccessCode)try{const u=this.callback_(c,c.getResponse());xA(u)?i(u):i()}catch(u){a(u)}else if(c!==null){const u=PA();u.serverResponse=c.getErrorText(),this.errorCallback_?a(this.errorCallback_(c,u)):a(u)}else if(s.canceled){const u=this.appDelete_?Tp():kA();a(u)}else{const u=CA();a(u)}};this.canceled_?t(!1,new ps(!1,null,!0)):this.backoffId_=LA(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&MA(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}}class ps{constructor(e,t,r){this.wasSuccessCode=e,this.connection=t,this.canceled=!!r}}function qA(n,e){e!==null&&e.length>0&&(n.Authorization="Firebase "+e)}function $A(n,e){n["X-Firebase-Storage-Version"]="webjs/"+(e??"AppManager")}function jA(n,e){e&&(n["X-Firebase-GMPID"]=e)}function zA(n,e){e!==null&&(n["X-Firebase-AppCheck"]=e)}function HA(n,e,t,r,s,i,a=!0,c=!1){const u=FA(n.urlParams),h=n.url+u,f=Object.assign({},n.headers);return jA(f,e),qA(f,t),$A(f,i),zA(f,r),new BA(h,n.method,f,n.body,n.successCodes,n.additionalRetryCodes,n.handler,n.errorHandler,n.timeout,n.progressCallback,s,a,c)}function GA(n){if(n.length===0)return null;const e=n.lastIndexOf("/");return e===-1?"":n.slice(0,e)}function KA(n){const e=n.lastIndexOf("/",n.length-2);return e===-1?n:n.slice(e+1)}class Js{constructor(e,t){this._service=e,t instanceof We?this._location=t:this._location=We.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new Js(e,t)}get root(){const e=new We(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return KA(this._location.path)}get storage(){return this._service}get parent(){const e=GA(this._location.path);if(e===null)return null;const t=new We(this._location.bucket,e);return new Js(this._service,t)}_throwIfRoot(e){if(this._location.path==="")throw VA(e)}}function ah(n,e){const t=e?.[bA];return t==null?null:We.makeFromBucketSpec(t,n)}function WA(n,e,t,r={}){n.host=`${e}:${t}`;const s=vt(e);s&&(ii(`https://${n.host}/b`),oi("Storage",!0)),n._isUsingEmulator=!0,n._protocol=s?"https":"http";const{mockUserToken:i}=r;i&&(n._overrideAuthToken=typeof i=="string"?i:Oh(i,n.app.options.projectId))}class QA{constructor(e,t,r,s,i,a=!1){this.app=e,this._authProvider=t,this._appCheckProvider=r,this._url=s,this._firebaseVersion=i,this._isUsingEmulator=a,this._bucket=null,this._host=yp,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=SA,this._maxUploadRetryTime=RA,this._requests=new Set,s!=null?this._bucket=We.makeFromBucketSpec(s,this._host):this._bucket=ah(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=We.makeFromBucketSpec(this._url,e):this._bucket=ah(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){oh("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){oh("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;const e=this._authProvider.getImmediate({optional:!0});if(e){const t=await e.getToken();if(t!==null)return t.accessToken}return null}async _getAppCheckToken(){if(Fe(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new Js(this,e)}_makeRequest(e,t,r,s,i=!0){if(this._deleted)return new OA(Tp());{const a=HA(e,this._appId,r,s,t,this._firebaseVersion,i,this._isUsingEmulator);return this._requests.add(a),a.getPromise().then(()=>this._requests.delete(a),()=>this._requests.delete(a)),a}}async makeRequestWithTokens(e,t){const[r,s]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,r,s).getPromise()}}const ch="@firebase/storage",lh="0.14.0";const wp="storage";function JA(n=$n(),e){n=ee(n);const r=ut(n,wp).getImmediate({identifier:e}),s=la("storage");return s&&Ep(r,...s),r}function Ep(n,e,t,r={}){WA(n,e,t,r)}function YA(n,{instanceIdentifier:e}){const t=n.getProvider("app").getImmediate(),r=n.getProvider("auth-internal"),s=n.getProvider("app-check-internal");return new QA(t,r,s,e,yn)}function XA(){Me(new Ne(wp,YA,"PUBLIC").setMultipleInstances(!0)),me(ch,lh,""),me(ch,lh,"esm2020")}XA();const ZA="type.googleapis.com/google.protobuf.Int64Value",e0="type.googleapis.com/google.protobuf.UInt64Value";function vp(n,e){const t={};for(const r in n)n.hasOwnProperty(r)&&(t[r]=e(n[r]));return t}function Ys(n){if(n==null)return null;if(n instanceof Number&&(n=n.valueOf()),typeof n=="number"&&isFinite(n)||n===!0||n===!1||Object.prototype.toString.call(n)==="[object String]")return n;if(n instanceof Date)return n.toISOString();if(Array.isArray(n))return n.map(e=>Ys(e));if(typeof n=="function"||typeof n=="object")return vp(n,e=>Ys(e));throw new Error("Data cannot be encoded in JSON: "+n)}function qn(n){if(n==null)return n;if(n["@type"])switch(n["@type"]){case ZA:case e0:{const e=Number(n.value);if(isNaN(e))throw new Error("Data cannot be decoded from JSON: "+n);return e}default:throw new Error("Data cannot be decoded from JSON: "+n)}return Array.isArray(n)?n.map(e=>qn(e)):typeof n=="function"||typeof n=="object"?vp(n,e=>qn(e)):n}const pc="functions";const uh={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class Le extends $e{constructor(e,t,r){super(`${pc}/${e}`,t||""),this.details=r,Object.setPrototypeOf(this,Le.prototype)}}function t0(n){if(n>=200&&n<300)return"ok";switch(n){case 0:return"internal";case 400:return"invalid-argument";case 401:return"unauthenticated";case 403:return"permission-denied";case 404:return"not-found";case 409:return"aborted";case 429:return"resource-exhausted";case 499:return"cancelled";case 500:return"internal";case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline-exceeded"}return"unknown"}function Xs(n,e){let t=t0(n),r=t,s;try{const i=e&&e.error;if(i){const a=i.status;if(typeof a=="string"){if(!uh[a])return new Le("internal","internal");t=uh[a],r=a}const c=i.message;typeof c=="string"&&(r=c),s=i.details,s!==void 0&&(s=qn(s))}}catch{}return t==="ok"?null:new Le(t,r,s)}class n0{constructor(e,t,r,s){this.app=e,this.auth=null,this.messaging=null,this.appCheck=null,this.serverAppAppCheckToken=null,Fe(e)&&e.settings.appCheckToken&&(this.serverAppAppCheckToken=e.settings.appCheckToken),this.auth=t.getImmediate({optional:!0}),this.messaging=r.getImmediate({optional:!0}),this.auth||t.get().then(i=>this.auth=i,()=>{}),this.messaging||r.get().then(i=>this.messaging=i,()=>{}),this.appCheck||s?.get().then(i=>this.appCheck=i,()=>{})}async getAuthToken(){if(this.auth)try{return(await this.auth.getToken())?.accessToken}catch{return}}async getMessagingToken(){if(!(!this.messaging||!("Notification"in self)||Notification.permission!=="granted"))try{return await this.messaging.getToken()}catch{return}}async getAppCheckToken(e){if(this.serverAppAppCheckToken)return this.serverAppAppCheckToken;if(this.appCheck){const t=e?await this.appCheck.getLimitedUseToken():await this.appCheck.getToken();return t.error?null:t.token}return null}async getContext(e){const t=await this.getAuthToken(),r=await this.getMessagingToken(),s=await this.getAppCheckToken(e);return{authToken:t,messagingToken:r,appCheckToken:s}}}const na="us-central1",r0=/^data: (.*?)(?:\n|$)/;function s0(n){let e=null;return{promise:new Promise((t,r)=>{e=setTimeout(()=>{r(new Le("deadline-exceeded","deadline-exceeded"))},n)}),cancel:()=>{e&&clearTimeout(e)}}}class i0{constructor(e,t,r,s,i=na,a=(...c)=>fetch(...c)){this.app=e,this.fetchImpl=a,this.emulatorOrigin=null,this.contextProvider=new n0(e,t,r,s),this.cancelAllRequests=new Promise(c=>{this.deleteService=()=>Promise.resolve(c())});try{const c=new URL(i);this.customDomain=c.origin+(c.pathname==="/"?"":c.pathname),this.region=na}catch{this.customDomain=null,this.region=i}}_delete(){return this.deleteService()}_url(e){const t=this.app.options.projectId;return this.emulatorOrigin!==null?`${this.emulatorOrigin}/${t}/${this.region}/${e}`:this.customDomain!==null?`${this.customDomain}/${e}`:`https://${this.region}-${t}.cloudfunctions.net/${e}`}}function o0(n,e,t){const r=vt(e);n.emulatorOrigin=`http${r?"s":""}://${e}:${t}`,r&&(ii(n.emulatorOrigin+"/backends"),oi("Functions",!0))}function a0(n,e,t){const r=s=>l0(n,e,s,{});return r.stream=(s,i)=>h0(n,e,s,i),r}function Ip(n){return n.emulatorOrigin&&vt(n.emulatorOrigin)?"include":void 0}async function c0(n,e,t,r,s){t["Content-Type"]="application/json";let i;try{i=await r(n,{method:"POST",body:JSON.stringify(e),headers:t,credentials:Ip(s)})}catch{return{status:0,json:null}}let a=null;try{a=await i.json()}catch{}return{status:i.status,json:a}}async function Ap(n,e){const t={},r=await n.contextProvider.getContext(e.limitedUseAppCheckTokens);return r.authToken&&(t.Authorization="Bearer "+r.authToken),r.messagingToken&&(t["Firebase-Instance-ID-Token"]=r.messagingToken),r.appCheckToken!==null&&(t["X-Firebase-AppCheck"]=r.appCheckToken),t}function l0(n,e,t,r){const s=n._url(e);return u0(n,s,t,r)}async function u0(n,e,t,r){t=Ys(t);const s={data:t},i=await Ap(n,r),a=r.timeout||7e4,c=s0(a),u=await Promise.race([c0(e,s,i,n.fetchImpl,n),c.promise,n.cancelAllRequests]);if(c.cancel(),!u)throw new Le("cancelled","Firebase Functions instance was deleted.");const h=Xs(u.status,u.json);if(h)throw h;if(!u.json)throw new Le("internal","Response is not valid JSON object.");let f=u.json.data;if(typeof f>"u"&&(f=u.json.result),typeof f>"u")throw new Le("internal","Response is missing data field.");return{data:qn(f)}}function h0(n,e,t,r){const s=n._url(e);return d0(n,s,t,r||{})}async function d0(n,e,t,r){t=Ys(t);const s={data:t},i=await Ap(n,r);i["Content-Type"]="application/json",i.Accept="text/event-stream";let a;try{a=await n.fetchImpl(e,{method:"POST",body:JSON.stringify(s),headers:i,signal:r?.signal,credentials:Ip(n)})}catch(y){if(y instanceof Error&&y.name==="AbortError"){const k=new Le("cancelled","Request was cancelled.");return{data:Promise.reject(k),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(k)}}}}}}const S=Xs(0,null);return{data:Promise.reject(S),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(S)}}}}}}let c,u;const h=new Promise((y,S)=>{c=y,u=S});r?.signal?.addEventListener("abort",()=>{const y=new Le("cancelled","Request was cancelled.");u(y)});const f=a.body.getReader(),m=f0(f,c,u,r?.signal);return{stream:{[Symbol.asyncIterator](){const y=m.getReader();return{async next(){const{value:S,done:k}=await y.read();return{value:S,done:k}},async return(){return await y.cancel(),{done:!0,value:void 0}}}}},data:h}}function f0(n,e,t,r){const s=(a,c)=>{const u=a.match(r0);if(!u)return;const h=u[1];try{const f=JSON.parse(h);if("result"in f){e(qn(f.result));return}if("message"in f){c.enqueue(qn(f.message));return}if("error"in f){const m=Xs(0,f);c.error(m),t(m);return}}catch(f){if(f instanceof Le){c.error(f),t(f);return}}},i=new TextDecoder;return new ReadableStream({start(a){let c="";return u();async function u(){if(r?.aborted){const h=new Le("cancelled","Request was cancelled");return a.error(h),t(h),Promise.resolve()}try{const{value:h,done:f}=await n.read();if(f){c.trim()&&s(c.trim(),a),a.close();return}if(r?.aborted){const y=new Le("cancelled","Request was cancelled");a.error(y),t(y),await n.cancel();return}c+=i.decode(h,{stream:!0});const m=c.split(`
38
+ `);c=m.pop()||"";for(const y of m)y.trim()&&s(y.trim(),a);return u()}catch(h){const f=h instanceof Le?h:Xs(0,null);a.error(f),t(f)}}},cancel(){return n.cancel()}})}const hh="@firebase/functions",dh="0.13.1";const p0="auth-internal",m0="app-check-internal",g0="messaging-internal";function _0(n){const e=(t,{instanceIdentifier:r})=>{const s=t.getProvider("app").getImmediate(),i=t.getProvider(p0),a=t.getProvider(g0),c=t.getProvider(m0);return new i0(s,i,a,c,r)};Me(new Ne(pc,e,"PUBLIC").setMultipleInstances(!0)),me(hh,dh,n),me(hh,dh,"esm2020")}function y0(n=$n(),e=na){const r=ut(ee(n),pc).getImmediate({identifier:e}),s=la("functions");return s&&bp(r,...s),r}function bp(n,e,t){o0(ee(n),e,t)}function T0(n,e,t){return a0(ee(n),e)}_0();const w0="/firebase-messaging-sw.js",E0="/firebase-cloud-messaging-push-scope",Sp="BDOU99-h67HcA6JeFXHbSNMu7e2yNNu3RzoMj8TM4W88jITfq7ZmPvIM1Iv-4_l2LxQcYwhqby2xGpWwzjfAnG4",v0="https://fcmregistrations.googleapis.com/v1",Rp="google.c.a.c_id",I0="google.c.a.c_l",A0="google.c.a.ts",b0="google.c.a.e",fh=1e4;var ph;(function(n){n[n.DATA_MESSAGE=1]="DATA_MESSAGE",n[n.DISPLAY_NOTIFICATION=3]="DISPLAY_NOTIFICATION"})(ph||(ph={}));var Lr;(function(n){n.PUSH_RECEIVED="push-received",n.NOTIFICATION_CLICKED="notification-clicked"})(Lr||(Lr={}));function dt(n){const e=new Uint8Array(n);return btoa(String.fromCharCode(...e)).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function S0(n){const e="=".repeat((4-n.length%4)%4),t=(n+e).replace(/\-/g,"+").replace(/_/g,"/"),r=atob(t),s=new Uint8Array(r.length);for(let i=0;i<r.length;++i)s[i]=r.charCodeAt(i);return s}const vo="fcm_token_details_db",R0=5,mh="fcm_token_object_Store";async function P0(n){if("databases"in indexedDB&&!(await indexedDB.databases()).map(i=>i.name).includes(vo))return null;let e=null;return(await ci(vo,R0,{upgrade:async(r,s,i,a)=>{if(s<2||!r.objectStoreNames.contains(mh))return;const c=a.objectStore(mh),u=await c.index("fcmSenderId").get(n);if(await c.clear(),!!u){if(s===2){const h=u;if(!h.auth||!h.p256dh||!h.endpoint)return;e={token:h.fcmToken,createTime:h.createTime??Date.now(),subscriptionOptions:{auth:h.auth,p256dh:h.p256dh,endpoint:h.endpoint,swScope:h.swScope,vapidKey:typeof h.vapidKey=="string"?h.vapidKey:dt(h.vapidKey)}}}else if(s===3){const h=u;e={token:h.fcmToken,createTime:h.createTime,subscriptionOptions:{auth:dt(h.auth),p256dh:dt(h.p256dh),endpoint:h.endpoint,swScope:h.swScope,vapidKey:dt(h.vapidKey)}}}else if(s===4){const h=u;e={token:h.fcmToken,createTime:h.createTime,subscriptionOptions:{auth:dt(h.auth),p256dh:dt(h.p256dh),endpoint:h.endpoint,swScope:h.swScope,vapidKey:dt(h.vapidKey)}}}}}})).close(),await io(vo),await io("fcm_vapid_details_db"),await io("undefined"),C0(e)?e:null}function C0(n){if(!n||!n.subscriptionOptions)return!1;const{subscriptionOptions:e}=n;return typeof n.createTime=="number"&&n.createTime>0&&typeof n.token=="string"&&n.token.length>0&&typeof e.auth=="string"&&e.auth.length>0&&typeof e.p256dh=="string"&&e.p256dh.length>0&&typeof e.endpoint=="string"&&e.endpoint.length>0&&typeof e.swScope=="string"&&e.swScope.length>0&&typeof e.vapidKey=="string"&&e.vapidKey.length>0}const k0="firebase-messaging-database",N0=1,_n="firebase-messaging-store";let Io=null;function mc(){return Io||(Io=ci(k0,N0,{upgrade:(n,e)=>{e===0&&n.createObjectStore(_n)}})),Io}async function Pp(n){const e=_c(n),r=await(await mc()).transaction(_n).objectStore(_n).get(e);if(r)return r;{const s=await P0(n.appConfig.senderId);if(s)return await gc(n,s),s}}async function gc(n,e){const t=_c(n),s=(await mc()).transaction(_n,"readwrite");return await s.objectStore(_n).put(e,t),await s.done,e}async function D0(n){const e=_c(n),r=(await mc()).transaction(_n,"readwrite");await r.objectStore(_n).delete(e),await r.done}function _c({appConfig:n}){return n.appId}const V0={"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"only-available-in-window":"This method is available in a Window context.","only-available-in-sw":"This method is available in a service worker context.","permission-default":"The notification permission was not granted and dismissed instead.","permission-blocked":"The notification permission was not granted and blocked instead.","unsupported-browser":"This browser doesn't support the API's required to use the Firebase SDK.","indexed-db-unsupported":"This browser doesn't support indexedDb.open() (ex. Safari iFrame, Firefox Private Browsing, etc)","failed-service-worker-registration":"We are unable to register the default service worker. {$browserErrorMessage}","token-subscribe-failed":"A problem occurred while subscribing the user to FCM: {$errorInfo}","token-subscribe-no-token":"FCM returned no token when subscribing the user to push.","token-unsubscribe-failed":"A problem occurred while unsubscribing the user from FCM: {$errorInfo}","token-update-failed":"A problem occurred while updating the user from FCM: {$errorInfo}","token-update-no-token":"FCM returned no token when updating the user to push.","use-sw-after-get-token":"The useServiceWorker() method may only be called once and must be called before calling getToken() to ensure your service worker is used.","invalid-sw-registration":"The input to useServiceWorker() must be a ServiceWorkerRegistration.","invalid-bg-handler":"The input to setBackgroundMessageHandler() must be a function.","invalid-vapid-key":"The public VAPID key must be a string.","use-vapid-key-after-get-token":"The usePublicVapidKey() method may only be called once and must be called before calling getToken() to ensure your VAPID key is used."},be=new Kt("messaging","Messaging",V0);async function O0(n,e){const t=await Tc(n),r=kp(e),s={method:"POST",headers:t,body:JSON.stringify(r)};let i;try{i=await(await fetch(yc(n.appConfig),s)).json()}catch(a){throw be.create("token-subscribe-failed",{errorInfo:a?.toString()})}if(i.error){const a=i.error.message;throw be.create("token-subscribe-failed",{errorInfo:a})}if(!i.token)throw be.create("token-subscribe-no-token");return i.token}async function L0(n,e){const t=await Tc(n),r=kp(e.subscriptionOptions),s={method:"PATCH",headers:t,body:JSON.stringify(r)};let i;try{i=await(await fetch(`${yc(n.appConfig)}/${e.token}`,s)).json()}catch(a){throw be.create("token-update-failed",{errorInfo:a?.toString()})}if(i.error){const a=i.error.message;throw be.create("token-update-failed",{errorInfo:a})}if(!i.token)throw be.create("token-update-no-token");return i.token}async function Cp(n,e){const r={method:"DELETE",headers:await Tc(n)};try{const i=await(await fetch(`${yc(n.appConfig)}/${e}`,r)).json();if(i.error){const a=i.error.message;throw be.create("token-unsubscribe-failed",{errorInfo:a})}}catch(s){throw be.create("token-unsubscribe-failed",{errorInfo:s?.toString()})}}function yc({projectId:n}){return`${v0}/projects/${n}/registrations`}async function Tc({appConfig:n,installations:e}){const t=await e.getToken();return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":n.apiKey,"x-goog-firebase-installations-auth":`FIS ${t}`})}function kp({p256dh:n,auth:e,endpoint:t,vapidKey:r}){const s={web:{endpoint:t,auth:e,p256dh:n}};return r!==Sp&&(s.web.applicationPubKey=r),s}const M0=10080*60*1e3;async function x0(n){const e=await B0(n.swRegistration,n.vapidKey),t={vapidKey:n.vapidKey,swScope:n.swRegistration.scope,endpoint:e.endpoint,auth:dt(e.getKey("auth")),p256dh:dt(e.getKey("p256dh"))},r=await Pp(n.firebaseDependencies);if(r){if(q0(r.subscriptionOptions,t))return Date.now()>=r.createTime+M0?U0(n,{token:r.token,createTime:Date.now(),subscriptionOptions:t}):r.token;try{await Cp(n.firebaseDependencies,r.token)}catch(s){console.warn(s)}return gh(n.firebaseDependencies,t)}else return gh(n.firebaseDependencies,t)}async function F0(n){const e=await Pp(n.firebaseDependencies);e&&(await Cp(n.firebaseDependencies,e.token),await D0(n.firebaseDependencies));const t=await n.swRegistration.pushManager.getSubscription();return t?t.unsubscribe():!0}async function U0(n,e){try{const t=await L0(n.firebaseDependencies,e),r={...e,token:t,createTime:Date.now()};return await gc(n.firebaseDependencies,r),t}catch(t){throw t}}async function gh(n,e){const r={token:await O0(n,e),createTime:Date.now(),subscriptionOptions:e};return await gc(n,r),r.token}async function B0(n,e){const t=await n.pushManager.getSubscription();return t||n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:S0(e)})}function q0(n,e){const t=e.vapidKey===n.vapidKey,r=e.endpoint===n.endpoint,s=e.auth===n.auth,i=e.p256dh===n.p256dh;return t&&r&&s&&i}function _h(n){const e={from:n.from,collapseKey:n.collapse_key,messageId:n.fcmMessageId};return $0(e,n),j0(e,n),z0(e,n),e}function $0(n,e){if(!e.notification)return;n.notification={};const t=e.notification.title;t&&(n.notification.title=t);const r=e.notification.body;r&&(n.notification.body=r);const s=e.notification.image;s&&(n.notification.image=s);const i=e.notification.icon;i&&(n.notification.icon=i)}function j0(n,e){e.data&&(n.data=e.data)}function z0(n,e){if(!e.fcmOptions&&!e.notification?.click_action)return;n.fcmOptions={};const t=e.fcmOptions?.link??e.notification?.click_action;t&&(n.fcmOptions.link=t);const r=e.fcmOptions?.analytics_label;r&&(n.fcmOptions.analyticsLabel=r)}function H0(n){return typeof n=="object"&&!!n&&Rp in n}function G0(n){if(!n||!n.options)throw Ao("App Configuration Object");if(!n.name)throw Ao("App Name");const e=["projectId","apiKey","appId","messagingSenderId"],{options:t}=n;for(const r of e)if(!t[r])throw Ao(r);return{appName:n.name,projectId:t.projectId,apiKey:t.apiKey,appId:t.appId,senderId:t.messagingSenderId}}function Ao(n){return be.create("missing-app-config-values",{valueName:n})}class K0{constructor(e,t,r){this.deliveryMetricsExportedToBigQueryEnabled=!1,this.onBackgroundMessageHandler=null,this.onMessageHandler=null,this.logEvents=[],this.isLogServiceStarted=!1;const s=G0(e);this.firebaseDependencies={app:e,appConfig:s,installations:t,analyticsProvider:r}}_delete(){return Promise.resolve()}}async function Np(n){try{n.swRegistration=await navigator.serviceWorker.register(w0,{scope:E0}),n.swRegistration.update().catch(()=>{}),await W0(n.swRegistration)}catch(e){throw be.create("failed-service-worker-registration",{browserErrorMessage:e?.message})}}async function W0(n){return new Promise((e,t)=>{const r=setTimeout(()=>t(new Error(`Service worker not registered after ${fh} ms`)),fh),s=n.installing||n.waiting;n.active?(clearTimeout(r),e()):s?s.onstatechange=i=>{i.target?.state==="activated"&&(s.onstatechange=null,clearTimeout(r),e())}:(clearTimeout(r),t(new Error("No incoming service worker found.")))})}async function Q0(n,e){if(!e&&!n.swRegistration&&await Np(n),!(!e&&n.swRegistration)){if(!(e instanceof ServiceWorkerRegistration))throw be.create("invalid-sw-registration");n.swRegistration=e}}async function J0(n,e){e?n.vapidKey=e:n.vapidKey||(n.vapidKey=Sp)}async function Dp(n,e){if(!navigator)throw be.create("only-available-in-window");if(Notification.permission==="default"&&await Notification.requestPermission(),Notification.permission!=="granted")throw be.create("permission-blocked");return await J0(n,e?.vapidKey),await Q0(n,e?.serviceWorkerRegistration),x0(n)}async function Y0(n,e,t){const r=X0(e);(await n.firebaseDependencies.analyticsProvider.get()).logEvent(r,{message_id:t[Rp],message_name:t[I0],message_time:t[A0],message_device_time:Math.floor(Date.now()/1e3)})}function X0(n){switch(n){case Lr.NOTIFICATION_CLICKED:return"notification_open";case Lr.PUSH_RECEIVED:return"notification_foreground";default:throw new Error}}async function Z0(n,e){const t=e.data;if(!t.isFirebaseMessaging)return;n.onMessageHandler&&t.messageType===Lr.PUSH_RECEIVED&&(typeof n.onMessageHandler=="function"?n.onMessageHandler(_h(t)):n.onMessageHandler.next(_h(t)));const r=t.data;H0(r)&&r[b0]==="1"&&await Y0(n,t.messageType,r)}const yh="@firebase/messaging",Th="0.12.23";const eb=n=>{const e=new K0(n.getProvider("app").getImmediate(),n.getProvider("installations-internal").getImmediate(),n.getProvider("analytics-internal"));return navigator.serviceWorker.addEventListener("message",t=>Z0(e,t)),e},tb=n=>{const e=n.getProvider("messaging").getImmediate();return{getToken:r=>Dp(e,r)}};function nb(){Me(new Ne("messaging",eb,"PUBLIC")),Me(new Ne("messaging-internal",tb,"PRIVATE")),me(yh,Th),me(yh,Th,"esm2020")}async function rb(){try{await ha()}catch{return!1}return typeof window<"u"&&ua()&&Mh()&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&"fetch"in window&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey")}async function sb(n){if(!navigator)throw be.create("only-available-in-window");return n.swRegistration||await Np(n),F0(n)}function ib(n=$n()){return rb().then(e=>{if(!e)throw be.create("unsupported-browser")},e=>{throw be.create("indexed-db-unsupported")}),ut(ee(n),"messaging").getImmediate()}async function ob(n,e){return n=ee(n),Dp(n,e)}function ab(n){return n=ee(n),sb(n)}nb();let He=null;exports.auth=void 0;exports.provider=void 0;exports.analytics=void 0;exports.db=void 0;exports.storage=void 0;exports.functions=void 0;exports.messaging=void 0;function cb(n){if(He)return He;const{functionsRegion:e,...t}=n;return He=Uh(t),exports.auth=Zw(He),exports.provider=new ft,exports.analytics=Xy(He),exports.db=aA(He),exports.storage=JA(He),exports.functions=y0(He,e),exports.messaging=ib(He),je.isDev&&(op(exports.db,"localhost",8080),bd(exports.auth,"http://localhost:9099"),bp(exports.functions,"localhost",5001),Ep(exports.storage,"localhost",9199)),He}function ra(){if(!He)throw new Error("[cic-kit] Firebase non inizializzato. Chiama setupFirebase(firebaseConfig) nel main.")}const Zs="Sei offline: cancello in locale, sincronizzo quando torni online.";function Vp(){return typeof navigator<"u"?!!navigator.onLine:!0}function wc(){return!Vp()}function Ar(n){if(n instanceof z)return n;try{return new z(n.seconds,n.nanoseconds)}catch{return U.logError({title:"reviveTimestamp errore:",message:`seconds:${n.seconds}; nanoseconds:${n.nanoseconds};`}),z.now()}}function sa(n){try{if(n==null||n instanceof z)return n;if(typeof n=="object"&&n.type==="firestore/timestamp/1.0"&&typeof n.seconds=="number"&&typeof n.nanoseconds=="number")return Ar(n);if(Array.isArray(n))return n.map(e=>sa(e));if(typeof n=="object"){const e={};for(const[t,r]of Object.entries(n))e[t]=sa(r);return e}return n}catch(e){return U.logError({title:"reviveTimestampsDeep error",message:e?.message??"Errore sconosciuto"}),n}}const ei=n=>{if(n==null)return n;if(n instanceof z)return n.toJSON();if(n&&typeof n=="object"&&n._methodName==="serverTimestamp")return U.logError("non puoi salvare un serverTimestamp devi usare Timestamp.now()"),z.now().toJSON();if(Array.isArray(n))return n.map(e=>ei(e));if(typeof n=="object"){const e={};for(const[t,r]of Object.entries(n))e[t]=ei(r);return e}return n},ia={unknown:"Errore sconosciuto.",undefined:"Non trovato.",cancelled:"Operazione annullata.","invalid-argument":"Argomento non valido.","deadline-exceeded":"Timeout dell’operazione.","not-found":"Risorsa non trovata.","already-exists":"La risorsa esiste già.","permission-denied":"Non hai i permessi necessari.","resource-exhausted":"Limite superato, riprova più tardi.","failed-precondition":"Stato non valido per questa operazione.",aborted:"Conflitto, operazione annullata.",unavailable:"Servizio momentaneamente non disponibile.","auth/email-already-in-use":"Questa email è già registrata.","auth/wrong-password":"Password errata.","auth/user-not-found":"Utente non trovato.","auth/invalid-email":"Indirizzo email non valido.","auth/too-many-requests":"Troppi tentativi, riprova più tardi.","auth/requires-recent-login":"Per favore effettua di nuovo il login.","storage/object-not-found":"File non trovato.","storage/unauthenticated":"Devi effettuare il login.","storage/unauthorized":"Non hai accesso a questo file.","storage/quota-exceeded":"Quota di archiviazione superata."};function lb(n){return n in ia}function nt(n,e){if(e===!1)return;const t=typeof n?.code=="string"?n?.code:"",r=lb(t)?ia[t]:!1;if(r)U.error(r);else{U.error(ia.unknown),console.log(`%cTodo gestire error.code "%c${n?.code}%c"`,"color:#fb9005; font-weight:bold;","color:#0dfb05; font-weight:bold;","color:#fb9005; font-weight:bold;");try{U.logError(String(n))}catch{U.logError("on try to parse error")}finally{console.log("[ERROR from middlewareCatchCall]:",n)}}}function ti(n,e,t,...r){!je.debugFirestore||!(i=>{if(!i)return;if(typeof je.debugFirestore=="boolean")return je.debugFirestore;const a=typeof je.debugFirestore=="string"?[je.debugFirestore]:je.debugFirestore;return a.length>0?a.includes(i):!1})(n)||console.log(`${e}[${t}] [${n??"no collectionName"}]`,...r)}function bo(n){if(wc()){if(n!==!0)throw Zs;U.warning(Zs)}}const ge={offlineAllow:!1,touchUpdate:!0,localSet:!0};class Ge{id;createdAt;updatedAt;deleteAt;constructor(e){this.id=e.id,Object.assign(this,e);const t=z.now();this.createdAt=e.createdAt?Ar(e.createdAt):t,this.updatedAt=e.updatedAt?Ar(e.updatedAt):t,this.deleteAt=e.deleteAt&&e.deleteAt!==null?Ar(e.deleteAt):null}static collectionName;debugLog(e,...t){ti(this?.collectionName??"no-collectionName","🔥📡🏪",e,t)}get ref(){const e=this.constructor,r=this.getCollectionPath?.()??e.collectionName;if(!r)throw new Error(`${e.name}: nessuna collectionName statica e nessuna getCollectionPath() definita.`);return Ir(exports.db,r,this.id)}static async get(e,t){try{ti(this?.collectionName??"no-collectionName","🔥📡🏪","get");const r=t?.collectionPath??this.collectionName;if(!r)throw new Error(`${this.name}.get: serve opts.collectionPath per collezioni dinamiche, oppure definisci static collectionName.`);const s=Ir(exports.db,r,e),i=await ta(s);if(!i.exists())return;const a=new this({id:e,...i.data()}),c=await a.onGetBeforeStoreSet(a);return c.canLocalSave(t?.localSet)&&c.localSet(),c}catch(r){throw nt(r),r}}static cleanDataAAA(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>{if(r==null)return[t,Zo()];if(typeof r=="object"&&r!==null&&!(r instanceof z)&&!(r instanceof Date))try{return[t,structuredClone(r)]}catch{return[t,JSON.parse(JSON.stringify(r))]}return[t,r]}))}static isPlainObject(e){return!!e&&typeof e=="object"}static stripUndefinedDeep(e){if(e!==void 0){if(e===null)return null;if(e instanceof z||e instanceof Date||e instanceof Or)return e;if(Array.isArray(e))return e.map(t=>Ge.stripUndefinedDeep(t)).filter(t=>t!==void 0);if(Ge.isPlainObject(e)){const t={};for(const[r,s]of Object.entries(e)){const i=Ge.stripUndefinedDeep(s);i!==void 0&&(t[r]=i)}return t}return e}}static cleanData(e){const t=Ge.stripUndefinedDeep(e);return Object.fromEntries(Object.entries(t??{}).map(([s,i])=>{if(i==null)return[s,Zo()];if((Ge.isPlainObject(i)||Array.isArray(i))&&!(i instanceof z)&&!(i instanceof Date)&&!(i instanceof Or))try{return[s,structuredClone(i)]}catch{return[s,JSON.parse(JSON.stringify(i))]}return[s,i]}))}async onGetBeforeStoreSet(e){return e}async save({offlineAllow:e=ge.offlineAllow,touchUpdate:t=ge.touchUpdate,localSet:r=ge.localSet}=ge){this.debugLog("save");try{bo(e);const s=this.toData(),i=Ge.cleanData(s);t&&!i.updatedAt&&(i.updatedAt=this.touchUpdated()),await gp(this.ref,{...i},{merge:!0}),this.canLocalSave(r)&&this.localSet()}catch(s){throw nt(s),s}}async update(e,{offlineAllow:t=ge.offlineAllow,touchUpdate:r=ge.touchUpdate,localSet:s=ge.localSet}=ge){this.debugLog("update");try{bo(t);const i=Ge.cleanData(e);r&&!i.updatedAt&&(i.updatedAt=this.touchUpdated()),await vA(this.ref,i),Object.assign(this,e),this.canLocalSave(s)&&this.localSet()}catch(i){throw nt(i),i}}async delete(e,t=ge){return this.debugLog("deleteUsingStore",`[id=${this.id}]`),await e.delete(this.id,t)}async deleteJustOnline_NotLocalStore({offlineAllow:e=ge.offlineAllow,localSet:t=ge.localSet}=ge){this.debugLog("delete");try{bo(e),await IA(this.ref),this.canLocalSave(t)&&this.localSet(!0)}catch(r){throw nt(r),r}}get isDeleted(){return this.deleteAt!==null}timestampbleProps(){return{createdAt:this.createdAt,updatedAt:this.updatedAt,deleteAt:this.deleteAt}}touchUpdated(){const e=z.now();return this.updatedAt=e,e}async softDelete(e){if(this.debugLog("softDelete"),this.deleteAt!==null){U.warning("Elemento già nel cestino.");return}const t=z.now();this.deleteAt=t,await this.update({deleteAt:t},e)}async restore(e){if(this.debugLog("restore"),this.deleteAt===null){U.warning("Elemento non è nel cestino.");return}this.deleteAt=null,await this.update({deleteAt:null},e)}canLocalSave(e){if(e===!1)return!1;try{return!!this?.localStorageKey?.()}catch{return!1}}localSet(e){this.debugLog("localSet");const t=this?.localStorageKey?.();if(!t)return;const r=this?.toData?.()??{id:this.id},s=ei(r),i=Ce.getParsed(t);if(i&&typeof i=="object"&&!Array.isArray(i)){if(e){i[this.id]&&(delete i[this.id],Ce.set(t,i));return}Ce.set(t,{...i,[this.id]:s})}else Ce.set(t,{[this.id]:s})}}function ub(n){if(wc()){if(n!==!0)throw Zs;U.warning(Zs)}}class hb{ModelInstnce;makeModel(e,t){return new this.ModelInstnce({id:e,...t})}_collectionPath;debugLog(e,...t){ti(this.collectionPath,"🔥📡📦",e,t)}items={};snapshotFnStop=null;isFirstRun=!0;prevStartQuery="";get live(){return!!this.snapshotFnStop}get ref(){return oA(exports.db,this.collectionPath)}constructor(e,t){this.ModelInstnce=e,this._collectionPath=t?.collectionPath}get collectionPath(){const e=this._collectionPath??this.ModelInstnce.collectionName;if(!e)throw new Error("collectionPath non definita");return e}get name(){return this.collectionPath}get itemsActive(){return Object.fromEntries(Object.entries(this.items).filter(([,e])=>!e.isDeleted))}get itemsDeleted(){return Object.fromEntries(Object.entries(this.items).filter(([,e])=>e.isDeleted))}get itemsArray(){return Object.values(this.items)}get itemsActiveArray(){return Object.values(this.items).filter(e=>!e.isDeleted)}get itemsDeletedArray(){return Object.values(this.items).filter(e=>e.isDeleted)}get isEmpty(){return Object.keys(this.items).length===0}get isActiveEmpty(){return this.itemsActiveArray.length===0}get isDeletedEmpty(){return this.itemsDeletedArray.length===0}get localStorageKey(){const e=this.ModelInstnce?.prototype?.localStorageKey?.();if(!e){U.logError("Impossibile svuotare LocalStorage: localStorageKey() non definita nel Model.");return}return e}itemsArrayOrderedBy(e,t){return[...t===void 0?this.itemsArray:t?this.itemsDeletedArray:this.itemsActiveArray].sort((s,i)=>{const a=s[e]?.toMillis?.()??0;return(i[e]?.toMillis?.()??0)-a})}findItemsById(e){if(!(!e||e===""))return this.items?.[e]}async get(e={}){this.debugLog("get");try{const t=oa(e),r=t?nh(this.ref,...t):this.ref,s=await EA(r);e.forceLocalSet&&(this.items={},this.localClear());for(const i of s.docs){const a=this.makeModel(i.id,i.data()),c=await a.onGetBeforeStoreSet(a);this.items[i.id]=c,(c.canLocalSave(e.localSet)||e.forceLocalSet&&c.canLocalSave())&&c.localSet()}return this.items}catch(t){throw nt(t),t}}async getIds(e){this.debugLog("getIds");const t=Array.from(new Set((e??[]).map(u=>(u??"").trim()).filter(Boolean)));if(t.length===0)return{foundIds:!1,notFoundIds:!1};const r=(u,h)=>{const f=[];for(let m=0;m<u.length;m+=h)f.push(u.slice(m,m+h));return f},s=new Set,i=r(t,10);for(const u of i){const h=await this.get({query:ea(Xo(),"in",u)});for(const f of Object.keys(h))s.add(f)}const a=Array.from(s),c=t.filter(u=>!s.has(u));return{foundIds:a.length>0?a:!1,notFoundIds:c.length>0?c:!1}}localGet(){const e=this.localStorageKey;try{if(!e){U.logError({title:"localGet "+e,message:"LocalStorageKey not found"});return}const t=Ce.getParsed(e);for(const r in t)this.items[r]=this.makeModel(r,t[r])}catch{U.logError({title:"localGet "+e,message:"errore try parse o makeModel"})}}async start(e={}){if(this.debugLog("👂 start"),!Ec(e))return;const t=JSON.stringify([e.ids,e.query,e.limit,e.orderBy].map(i=>i?.toString?.()??String(i)));if(this.live&&this.prevStartQuery===t)return;this.stop(),this.prevStartQuery=t;const r=oa(e,!0),s=r?nh(this.ref,...r):this.ref;this.snapshotFnStop=AA(s,async i=>{const a=i.docChanges();this.isFirstRun&&(this.debugLog("👂 firstRun"),this.isFirstRun=!1,this.onStartFirstRun(a,e.forceLocalSet),e.forceLocalSet&&(this.items={},this.localClear()));for(const c of a){const u=c.doc.id;if(c.type==="removed"){this.items[u]?.localSet(!0),delete this.items[u];continue}const h=c.doc.data(),f=this.makeModel(u,h),m=await f.onGetBeforeStoreSet(f);this.items[u]=m,m.canLocalSave(e.localSet)&&m.localSet()}},i=>{this.stop(),nt(i)})}onStartFirstRun(e,t){}stop(){this.snapshotFnStop&&(this.debugLog("🛑 stop"),this.prevStartQuery=null,this.snapshotFnStop(),this.snapshotFnStop=null,this.isFirstRun=!0)}async add(e,{offlineAllow:t=ge.offlineAllow,localSet:r=ge.localSet}=ge){try{this.debugLog("add"),ub(t);const{id:s,...i}=e,a=Ge.stripUndefinedDeep(i);let c=s??"";if(s){const h=Ir(exports.db,this.collectionPath,s);if((await ta(h)).exists())throw new Error("Documento già esistente")}else c=Ir(this.ref).id;const u=this.makeModel(c,a);return await u.save({offlineAllow:t,touchUpdate:!0,localSet:r}),this.items[c]=u,u}catch(s){throw nt(s),s}}async delete(e,t=ge){try{if(this.items[e]){const r=this.items[e].deleteJustOnline_NotLocalStore(t);return delete this.items[e],await r}}catch(r){throw nt(r),r}}findByUid(e){if(!(!this.itemsArray||!this.itemsArray.length))return this.itemsArray.find(t=>t.uid===e)}async getOne(e,t){this.debugLog("getOne");try{const r=Ir(exports.db,this.collectionPath,e),s=await ta(r);if(!s.exists())throw this.items[e]&&delete this.items[e],new Error("[404] non trovato");const i=s.data(),a=this.makeModel(e,i),c=await a.onGetBeforeStoreSet(a);return this.items[e]=c,c.canLocalSave(t?.localSet)&&c.localSet(),c}catch(r){throw nt(r),r}}async ensureOne(e){const t=this.items[e];return t||this.getOne(e)}localClear(){const e=this.localStorageKey;Ce.has(e)?(Ce.remove(e),U.log(`LocalStorage "${e}" svuotato con successo.`)):U.log(`Nessun dato trovato per LocalStorage "${e}".`)}}function Ec(n){if(n.ids&&n.ids.length>0){if(n.ids.length>10)return U.logError("Non puoi lanciare start con più di 10 id"),!1;if(n.query)return U.logError('Non è supportato usare "query" insieme a "ids" in start()'),!1}if(n.lastByCreate||n.lastByUpdate){if(n.lastByCreate&&n.lastByUpdate)return U.logError("Non puoi usare lastByCreate e lastByUpdate insieme"),!1;if(n.limit||n.orderBy)return U.logError("Non puoi usare limit o orderBy insieme a lastByCreate / lastByUpdate"),!1}return!0}function oa(n,e=!1){if(!e&&!Ec(n))return!1;const t=[];if(n.ids&&n.ids.length>0){const r=Array.from(new Set(n.ids.map(s=>(s??"").trim()).filter(Boolean)));r.length===1?t.push(ea(Xo(),"==",r[0])):r.length>1&&t.push(ea(Xo(),"in",r))}else n.query&&t.push(...Array.isArray(n.query)?n.query:[n.query]);return n.lastByCreate?(t.push(To("createdAt","desc")),t.push(wo(n.lastByCreate)),t):n.lastByUpdate?(t.push(To("updatedAt","desc")),t.push(wo(n.lastByUpdate)),t):(n.orderBy&&t.push(To(n.orderBy.fieldPath,n.orderBy.directionStr??"asc")),n.limit&&t.push(wo(n.limit)),t)}function db(n){let e=null;_.onBeforeUnmount(()=>{e?.(),e=null;for(const t of n)t.store.stop()})}const Op={SUPERADMIN:"SUPERADMIN",ADMIN:"ADMIN",MODAL_DEV_ON:"MODAL_DEV_ON",MANAGE_USERS:"MANAGE_USERS",OFFLINE_ALLOW:"OFFLINE_ALLOW",BETA_FEATURES:"BETA_FEATURES"};class fb extends Ge{static collectionName="users";localStorageKey(){return Ce.defaultKey.currentUser}userPublicId;name;surname;email;birthDate;phoneNumber;photoURL;description;permissions;gender;birthHideYear;fcmTokens;constructor(e){super(e),this.userPublicId=e.userPublicId,this.name=e.name,this.surname=e.surname,this.email=e.email,this.birthDate=e.birthDate,this.phoneNumber=e.phoneNumber,this.photoURL=e.photoURL,this.description=e.description,this.permissions=e.permissions??[],this.gender=e.gender,this.birthHideYear=e.birthHideYear,this.fcmTokens=e.fcmTokens}toData(){return{id:this.id,userPublicId:this.userPublicId,name:this.name,surname:this.surname,email:this.email,birthDate:this.birthDate,phoneNumber:this.phoneNumber,photoURL:this.photoURL,description:this.description,permissions:this.permissions,gender:this.gender,birthHideYear:this.birthHideYear,fcmTokens:this.fcmTokens}}async create(){try{const e=this.toData(),t=Object.fromEntries(Object.entries(e).map(([r,s])=>s==null?[r,Zo()]:[r,s]));t.permissions!==void 0&&delete t.permissions,await gp(this.ref,t,{merge:!0})}catch(e){throw U.error(String(e)),e}}get fullName(){let e=`${this.name} ${this.surname}`.trim();return e===""&&(e="-"),e}get fullNameInitials(){const e=this.fullName,t=e.split(" ").filter(Boolean);return((t[0]?.[0]||"")+(t[1]?.[0]||"")||e?.[0]||"?").toUpperCase()}async updateName(e,t){await this.update({name:e,surname:t})}async updateBirthDate(e){await this.update({birthDate:e})}hasPermission(e){return Array.isArray(this.permissions)&&this.permissions.includes(e)}hasAnyPermissions(){return Array.isArray(this.permissions)&&this.permissions.length>0}hasAnyPermissionsExclud(e){return!Array.isArray(this.permissions)||this.permissions.length===0?!1:this.permissions.some(t=>!e.includes(t))}get offlineAllow(){return this.hasPermission(Op.OFFLINE_ALLOW)}async addPermissions(e){const r=(Array.isArray(e)?e:[e]).filter(s=>!this.permissions.includes(s));return r.length===0?!1:(this.permissions.push(...r),this.update({permissions:this.permissions}).then(()=>!0))}async deletePermissions(e){const t=Array.isArray(e)?e:[e],r=this.permissions.length;return this.permissions=this.permissions.filter(s=>!t.includes(s)),this.permissions.length===r?!1:this.update({permissions:this.permissions}).then(()=>!0)}hasFcmToken(e){return e?(this.fcmTokens??[]).includes(e):!1}async addFcmToken(e){return Array.isArray(this.fcmTokens)||(this.fcmTokens=[]),this.hasFcmToken(e)?!1:(this.fcmTokens.push(e),this.update({fcmTokens:this.fcmTokens}).then(()=>!0))}async removeFcmToken(e){if(!Array.isArray(this.fcmTokens)||this.fcmTokens.length===0)return!1;const t=this.fcmTokens.length;return this.fcmTokens=this.fcmTokens.filter(r=>r!==e),this.fcmTokens.length===t?!1:this.update({fcmTokens:this.fcmTokens}).then(()=>!0)}}function wh(n){const e=typeof n=="string"?{title:n}:n,{title:t,...r}=e;return r.icon||(r.icon="/img/logo/pwa.png"),r.tag||(r.tag=`default-${new Date().toISOString().slice(0,10)}`),r.data||(r.data={url:"/"}),r?.data?.url||(r.data.url="/"),{title:t,options:r}}const aa=_.reactive({reg:void 0,VAPID_PUBLIC_KEY:void 0,isNotificationSupported:typeof Notification<"u",get permission(){return this.isNotificationSupported?Notification.permission:"denied"},get needToAskPermission(){return this.isNotificationSupported?Notification.permission==="default":!1},async askPermission(n){if(!aa.isNotificationSupported)return U.error("Le notifiche non sono supportate su questo dispositivo"),"denied";aa.permission==="denied"&&U.warning("Notifiche disabilitate. Per abilitarle cercare nelle impostazioni del browser.");const e=await Notification.requestPermission();return e!=="granted"?U.warning("Hai disabilitato le notifiche. Per abilitarle cercare nelle impostazioni del browser."):this.registerFcmToken(n),e},async send(n,e){if(!this.isNotificationSupported){U.error("Le notifiche non sono supportate su questo dispositivo");return}if(this.permission!=="granted"&&await this.askPermission(n)!=="granted")return;const{title:t,options:r}=wh(e);this.reg?await this.reg.showNotification(t,r):new Notification(t,r)},async sendTo(n,e){let t=!1;try{const r=T0(exports.functions,"sendUserPush"),{title:s,options:i}=wh(e);console.log({title:s,options:i}),await r({toUid:n,title:s,options:i}),t=!0}catch(r){console.error(r),U.error("Errore invio notifica")}return t},async getCurrentFcmToken(){return ra(),this.isNotificationSupported?this.reg?this.VAPID_PUBLIC_KEY?await ob(exports.messaging,{vapidKey:this.VAPID_PUBLIC_KEY,serviceWorkerRegistration:this.reg}).catch(()=>null)||null:(U.error("VAPID_PUBLIC_KEY mancante"),null):(U.error("ServiceWorker non registrato"),null):null},async registerFcmToken(n){if(ra(),!this.isNotificationSupported)return null;this.needToAskPermission&&await this.askPermission(n);const e=await this.getCurrentFcmToken();return e?(await n.addFcmToken(e)?U.success("Abilitato"):U.warning("Token non aggiunto possibilmente già presente."),e):null},async removeThisDeviceToken(n){const e=await this.getCurrentFcmToken();let t=!1;try{t=await ab(exports.messaging)}catch(s){console.warn("deleteToken() failed (continuo con cleanup lato currentUser):",s)}let r=!1;if(e)try{r=await n.removeFcmToken(e)}catch(s){console.warn("removeFcmToken() user failed:",s)}return t||r?(U.success("Notifiche disattivate per questo dispositivo."),!0):(U.warning("Nessun token da rimuovere per questo dispositivo."),!1)}});function bs(n){const e=globalThis.structuredClone;if(typeof e=="function")try{return e(n)}catch{return Nt(n)}return Nt(n)}function Nt(n,e=new WeakMap){if(n===null||typeof n!="object")return n;if(e.has(n))return e.get(n);if(n instanceof Date)return new Date(n.getTime());if(n instanceof Map){const r=new Map;return e.set(n,r),n.forEach((s,i)=>r.set(Nt(i,e),Nt(s,e))),r}if(n instanceof Set){const r=new Set;return e.set(n,r),n.forEach(s=>r.add(Nt(s,e))),r}if(Array.isArray(n)){const r=new Array(n.length);e.set(n,r);for(let s=0;s<n.length;s++)r[s]=Nt(n[s],e);return r}const t={};e.set(n,t);for(const r of Object.keys(n))t[r]=Nt(n[r],e);for(const r of Object.getOwnPropertySymbols(n))t[r]=Nt(n[r],e);return t}const pb=(n,e="")=>{const t=n.trim();if(t.startsWith("+")){const r=t.match(/^\+(\d{1,3})\s*(.+)$/);if(r)return[`+${r[1]}`,(r[2]??"").replace(/\s+/g,"")]}return[e,t.replace(/\s+/g,"")]};class mb{id;values;errors;touched;_initial;schema;_onSubmit;_onInvalid;_validateOnChangeMap;_touchOnChangeMap;_stopWatch;_fieldCache={};_allFields;_submitOnChange;_suspendAutoSubmit=!1;_debouncedSubmit;_syncPreference;_effects;_onAnyChange;_makeDebouncedSubmit(e){let t;return()=>{t&&clearTimeout(t),t=window.setTimeout(()=>{this._suspendAutoSubmit||this.submit()},e)}}constructor(e,t){this.id=e.id??"";const r=S=>"initialValues"in S;this._syncPreference=r(e)&&e.syncPreference?e.syncPreference:"db";const s=r(e)?e.initialValues:e,i=Object.keys(s),a=(S,k)=>{const V={};for(const N of i)V[N]=k;if(typeof S=="boolean")for(const N of i)V[N]=S;else S&&typeof S=="object"&&Object.assign(V,S);return V},c=(r(e)?e.validator:t)??{},u=r(e)?e.onSubmit:void 0,h=r(e)?e.onInvalid:void 0,f=r(e)?e.validateOnChange:void 0,m=r(e)?e.touchOnChange:void 0;this._validateOnChangeMap=a(f,!0),this._touchOnChangeMap=a(m,!0);const y=r(e)?e.syncWith:void 0;this._initial=bs(s),this.values=_.reactive(bs(s)),this.errors=_.reactive(Object.keys(s).reduce((S,k)=>(S[k]=null,S),{})),this.touched=_.reactive(Object.keys(s).reduce((S,k)=>(S[k]=!1,S),{})),this.schema=c,this._onSubmit=u,this._onInvalid=h,this._submitOnChange=r(e)?e.submitOnChange:void 0,this._effects=r(e)?e.effects:void 0,this._onAnyChange=r(e)?e.onAnyChange:void 0,typeof this._submitOnChange=="number"&&this._submitOnChange>=0&&(this._debouncedSubmit=this._makeDebouncedSubmit(this._submitOnChange)),y&&(_.isRef(y)?this._stopWatch=_.watch(y,S=>{S&&this.fill(S)},{immediate:!0}):typeof y=="function"&&(this._stopWatch=_.watch(y,S=>{S&&this.fill(S)},{immediate:!0})))}touch(e){this.touched[e]=!0}touchAll(){for(const e of Object.keys(this.touched))this.touched[e]=!0}field(e){const t=this._fieldCache[e];if(t)return t;const r=_.computed({get:()=>this.values[e],set:s=>this.set(e,s)});return this._fieldCache[e]=r,r}fields(){if(!this._allFields){const e={};for(const t of Object.keys(this.values))e[t]=this.field(t);this._allFields=e}return this._allFields}set(e,t,r){this.values[e]=t,!this.touched[e]&&(this._touchOnChangeMap[e]??!1)&&(this.touched[e]=!0),(r??!!this._validateOnChangeMap[e])&&this.validateField(e),this._effects?.[e]?.(t,this),this._onAnyChange?.(e,t,this),!this._suspendAutoSubmit&&this._submitOnChange&&(this._submitOnChange===!0?this.submit():typeof this._submitOnChange=="number"&&this._debouncedSubmit?.())}validateField(e){const t=this.schema[e]??[];for(const r of t){const s=r(this.values[e]);if(this.errors[e]=s,s)return!1}return this.errors[e]=null,!0}validateAll(){let e=!0;for(const t of Object.keys(this.values))this.validateField(t)||(this.touch(t),e=!1);return e}fill(e,t){let{validate:r}=t??{};r===void 0&&(r=!1),this._suspendAutoSubmit=!0;try{for(const s in e){if(!(s in this.values))continue;const i=s;this._syncPreference==="local"&&this.touched[i]||(this.values[i]=e[i])}r&&this.validateAll()}finally{this._suspendAutoSubmit=!1}}reset({keepTouched:e=!1}={}){for(const t of Object.keys(this._initial))this.values[t]=this._initial[t];for(const t of Object.keys(this.errors))this.errors[t]=null;if(!e)for(const t of Object.keys(this.touched))this.touched[t]=!1}resetWithInitialValues(e){this._initial=bs(e),this.reset()}bindField(e,t){return _.computed({get:()=>this.values[e],set:r=>this.set(e,r,t??this._validateOnChangeMap[e]??!1)})}showError(e){return this.touched[e]?this.errors[e]:null}hasError(e){return!!this.showError(e)}getFieldId(e){return`${this.id!==""?this.id+"_":""}field_${String(e)}`}getFieldIdError(e){return`${this.getFieldId(e)}-error`}getFieldProps(e){return{id:this.getFieldId(e),"aria-invalid":this.hasError(e),"aria-describedby":this.getFieldIdError(e),class:{"is-invalid":!!this.showError(e)}}}get isValid(){return Object.values(this.errors).every(e=>e==null)}get isDirty(){return JSON.stringify(this.values)!==JSON.stringify(this._initial)}get touchedValues(){const e={};for(const t of Object.keys(this.values))this.touched[t]&&(e[t]=this.values[t]);return e}dispose(){this._stopWatch?.()}submit=async()=>{if(!this.validateAll()){this._onInvalid?.(this.errors);return}await this._onSubmit?.(this.values,this.touchedValues,this.touched)};setSyncPreference(e){this._syncPreference=e}}const gb=(n="Obbligatorio")=>e=>e==null||typeof e=="string"&&e.trim().length===0||Array.isArray(e)&&e.length===0?n:null,_b=(n="Email non valida")=>e=>e?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)?null:n:null,yb=(n="Formato richiesto: AAAA-MM-GG")=>e=>e?/^\d{4}-\d{2}-\d{2}$/.test(e)?null:n:null,Tb=(n="URL non valido")=>e=>{if(!e)return null;try{return new URL(e),null}catch{return n}},wb=(n,e="Seleziona un’opzione")=>t=>t?n.includes(t)?null:e:null,Eb=(n="Devi accettare")=>e=>e?null:n,vb=(n="Deve essere un numero")=>e=>e==null||e===""?null:isNaN(Number(e))?n:null,Ib=(n,e)=>t=>{if(t==null||t==="")return null;const r=Number(t);return isNaN(r)?e??"Deve essere un numero":r<n?e??`Il numero deve essere ≥ ${n}`:null},Ab=(n,e)=>t=>{if(t==null||t==="")return null;const r=Number(t);return isNaN(r)?e??"Deve essere un numero":r>n?e??`Il numero deve essere ≤ ${n}`:null},bb=(n,e)=>t=>t&&t.length<n?e??`Minimo ${n} caratteri`:null,Sb=(n,e)=>t=>t&&t.length>n?e??`Massimo ${n} caratteri`:null,Lp=/^(?=.*[A-Z])(?=.*\d)(?!.*\s).+$/,Rb=(n="La password deve contenere almeno una maiuscola, un numero e nessuno spazio")=>e=>e?Lp.test(e)?null:n:null,Pb=(n,e)=>t=>t?t.length<n?e??`La password deve avere almeno ${n} caratteri`:Lp.test(t)?null:e??"La password deve contenere almeno una maiuscola, un numero e nessuno spazio":null,Cb=(n,e="Le password non coincidono")=>t=>{if(!t)return null;const r=n()??"";return t===r?null:e};function un(n){if(!n)return null;if(n instanceof Date)return isNaN(n.getTime())?null:n;if(/^\d{4}-\d{2}-\d{2}$/.test(n)){const e=new Date(n+"T00:00:00");return isNaN(e.getTime())?null:e}return null}const kb=(n,e="La data deve essere successiva")=>t=>{if(!t)return null;const r=un(t),s=un(n());return!r||!s||r>=s?null:e},Nb=(n,e="La data deve essere precedente")=>t=>{if(!t)return null;const r=un(t),s=un(n());return!r||!s||r<=s?null:e},Db=(n,e,t="La data deve essere compresa nell’intervallo")=>r=>{if(!r)return null;const s=un(r),i=un(n()),a=un(e());return!s||!i||!a||s>=i&&s<=a?null:t},ni=n=>String(n).padStart(2,"0");function ri(n){return n instanceof Date&&!isNaN(n.getTime())}function Ni(n){if(!n)return null;if(n instanceof Date)return ri(n)?n:null;if(n instanceof z)return n.toDate();if(typeof n=="string"||typeof n=="number"){const e=new Date(n);return ri(e)?e:null}return null}function Mp(n){const e=Ni(n);return e?`${e.getFullYear()}-${ni(e.getMonth()+1)}-${ni(e.getDate())}`:""}function xp(n){const e=Ni(n);return e?`${ni(e.getHours())}:${ni(e.getMinutes())}`:""}function Vb(n){const e=Ni(n);return e?`${Mp(e)}T${xp(e)}`:""}function Ob(n){if(!n)return null;const e=new Date(`${n}T00:00:00`);return ri(e)?e:null}function Lb(n,e){if(!n)return null;console.log(e);const t=e&&e!==""?e:"00:00";console.log(`${n}T${t}:00`);const r=new Date(`${n}T${t}:00`);return ri(r)?z.fromDate(r):null}function Mb(n,e=""){return n==null?e:String(n)}function xb(n){if(n==null||n==="")return"";const e=Number(n);return isNaN(e)?"":e}function Fb(n){return!!n}function Ub(n){return Array.isArray(n)?n.map(e=>String(e)).filter(Boolean):[]}function Bb(n,e){if(!n)return"";const t=String(n);return e&&!e.includes(t)?"":t}function qb(n,e=void 0){const t=Ni(n);return t?t.toLocaleString(e):""}function $b(n){if(n==null)return"-";const e=String(n).trim();return e===""?"-":e}const jb={install(n){n.component("AccordionCmp",Eh),n.component("Btn",gr),n.component("ToastCmp",Ah),n.component("FieldGender",bh),n.component("FieldPhoneNumber",Sh),n.component("InputField",Rh)}};exports.AccordionCmp=Eh;exports.Btn=gr;exports.CicKit=jb;exports.FieldGender=bh;exports.FieldPhoneNumber=Sh;exports.FirestoreModel=Ge;exports.FirestoreStore=hb;exports.FormValidator=mb;exports.InputField=Rh;exports.LS=Ce;exports.Toast=vh;exports.ToastCmp=Ah;exports.User=fb;exports.buildConstraintsFromGetProps=oa;exports.cicKitStore=je;exports.clone=bs;exports.dateAfter=kb;exports.dateBefore=Nb;exports.dateBetween=Db;exports.dateISO=yb;exports.defaultUserPermission=Op;exports.email=_b;exports.emptyToDash=$b;exports.ensureFirebase=ra;exports.fireDebugLog=ti;exports.inputDateTimeToTimestamp=Lb;exports.inputDateToDate=Ob;exports.isBrowserOffline=wc;exports.isBrowserOnline=Vp;exports.isNumber=vb;exports.maxLength=Sb;exports.maxNumber=Ab;exports.middlewareCatchCall=nt;exports.minLength=bb;exports.minNumber=Ib;exports.oneOf=wb;exports.optionFireModelDefault=ge;exports.password=Rb;exports.passwordRetype=Cb;exports.passwordWithMin=Pb;exports.phoneNumberFromString=pb;exports.pushMsg=aa;exports.required=gb;exports.requiredTrue=Eb;exports.reviveTimestamp=Ar;exports.reviveTimestampsDeep=sa;exports.serializeTimestamp=ei;exports.setupFirebase=cb;exports.shareLink=Ih;exports.signInWithPopup=cw;exports.timestampInputDate=Mp;exports.timestampInputDateTimeLocal=Vb;exports.timestampInputTime=xp;exports.timestampToLocale=qb;exports.toast=U;exports.url=Tb;exports.useStoreWatch=db;exports.validateQueryGetOpts=Ec;exports.valueToInputBoolean=Fb;exports.valueToInputNumber=xb;exports.valueToInputString=Mb;exports.valueToSelect=Bb;exports.valueToStringArray=Ub;