index.browser.esm5.js 267 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710
  1. import { __extends as t, __awaiter as e, __generator as n, __spreadArray as r } from "tslib";
  2. import { SDK_VERSION as i, _registerComponent as o, registerVersion as a, _getProvider, getApp as s, _removeServiceInstance as u } from "@firebase/app";
  3. import { Component as c } from "@firebase/component";
  4. import { Logger as l, LogLevel as f } from "@firebase/logger";
  5. import { FirebaseError as h, getModularInstance as p, getDefaultEmulatorHostnameAndPort as d, createMockUserToken as y, deepEqual as m } from "@firebase/util";
  6. /**
  7. * @license
  8. * Copyright 2017 Google LLC
  9. *
  10. * Licensed under the Apache License, Version 2.0 (the "License");
  11. * you may not use this file except in compliance with the License.
  12. * You may obtain a copy of the License at
  13. *
  14. * http://www.apache.org/licenses/LICENSE-2.0
  15. *
  16. * Unless required by applicable law or agreed to in writing, software
  17. * distributed under the License is distributed on an "AS IS" BASIS,
  18. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. * See the License for the specific language governing permissions and
  20. * limitations under the License.
  21. */
  22. /**
  23. * Simple wrapper around a nullable UID. Mostly exists to make code more
  24. * readable.
  25. */ var v = /** @class */ function() {
  26. function t(t) {
  27. this.uid = t;
  28. }
  29. return t.prototype.isAuthenticated = function() {
  30. return null != this.uid;
  31. },
  32. /**
  33. * Returns a key representing this user, suitable for inclusion in a
  34. * dictionary.
  35. */
  36. t.prototype.toKey = function() {
  37. return this.isAuthenticated() ? "uid:" + this.uid : "anonymous-user";
  38. }, t.prototype.isEqual = function(t) {
  39. return t.uid === this.uid;
  40. }, t;
  41. }();
  42. /** A user with a null UID. */ v.UNAUTHENTICATED = new v(null),
  43. // TODO(mikelehen): Look into getting a proper uid-equivalent for
  44. // non-FirebaseAuth providers.
  45. v.GOOGLE_CREDENTIALS = new v("google-credentials-uid"), v.FIRST_PARTY = new v("first-party-uid"),
  46. v.MOCK_USER = new v("mock-user");
  47. /**
  48. * @license
  49. * Copyright 2017 Google LLC
  50. *
  51. * Licensed under the Apache License, Version 2.0 (the "License");
  52. * you may not use this file except in compliance with the License.
  53. * You may obtain a copy of the License at
  54. *
  55. * http://www.apache.org/licenses/LICENSE-2.0
  56. *
  57. * Unless required by applicable law or agreed to in writing, software
  58. * distributed under the License is distributed on an "AS IS" BASIS,
  59. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  60. * See the License for the specific language governing permissions and
  61. * limitations under the License.
  62. */
  63. var g = "9.23.0", w = new l("@firebase/firestore");
  64. /**
  65. * @license
  66. * Copyright 2017 Google LLC
  67. *
  68. * Licensed under the Apache License, Version 2.0 (the "License");
  69. * you may not use this file except in compliance with the License.
  70. * You may obtain a copy of the License at
  71. *
  72. * http://www.apache.org/licenses/LICENSE-2.0
  73. *
  74. * Unless required by applicable law or agreed to in writing, software
  75. * distributed under the License is distributed on an "AS IS" BASIS,
  76. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  77. * See the License for the specific language governing permissions and
  78. * limitations under the License.
  79. */
  80. /**
  81. * Sets the verbosity of Cloud Firestore logs (debug, error, or silent).
  82. *
  83. * @param logLevel - The verbosity you set for activity and error logging. Can
  84. * be any of the following values:
  85. *
  86. * <ul>
  87. * <li>`debug` for the most verbose logging level, primarily for
  88. * debugging.</li>
  89. * <li>`error` to log errors only.</li>
  90. * <li><code>`silent` to turn off logging.</li>
  91. * </ul>
  92. */
  93. function _(t) {
  94. w.setLogLevel(t);
  95. }
  96. function b(t) {
  97. for (var e = [], n = 1; n < arguments.length; n++) e[n - 1] = arguments[n];
  98. if (w.logLevel <= f.DEBUG) {
  99. var i = e.map(S);
  100. w.debug.apply(w, r([ "Firestore (".concat(g, "): ").concat(t) ], i, !1));
  101. }
  102. }
  103. function T(t) {
  104. for (var e = [], n = 1; n < arguments.length; n++) e[n - 1] = arguments[n];
  105. if (w.logLevel <= f.ERROR) {
  106. var i = e.map(S);
  107. w.error.apply(w, r([ "Firestore (".concat(g, "): ").concat(t) ], i, !1));
  108. }
  109. }
  110. /**
  111. * @internal
  112. */ function E(t) {
  113. for (var e = [], n = 1; n < arguments.length; n++) e[n - 1] = arguments[n];
  114. if (w.logLevel <= f.WARN) {
  115. var i = e.map(S);
  116. w.warn.apply(w, r([ "Firestore (".concat(g, "): ").concat(t) ], i, !1));
  117. }
  118. }
  119. /**
  120. * Converts an additional log parameter to a string representation.
  121. */ function S(t) {
  122. if ("string" == typeof t) return t;
  123. try {
  124. return e = t, JSON.stringify(e);
  125. } catch (e) {
  126. // Converting to JSON failed, just log the object directly
  127. return t;
  128. }
  129. /**
  130. * @license
  131. * Copyright 2020 Google LLC
  132. *
  133. * Licensed under the Apache License, Version 2.0 (the "License");
  134. * you may not use this file except in compliance with the License.
  135. * You may obtain a copy of the License at
  136. *
  137. * http://www.apache.org/licenses/LICENSE-2.0
  138. *
  139. * Unless required by applicable law or agreed to in writing, software
  140. * distributed under the License is distributed on an "AS IS" BASIS,
  141. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  142. * See the License for the specific language governing permissions and
  143. * limitations under the License.
  144. */
  145. /** Formats an object as a JSON string, suitable for logging. */ var e;
  146. }
  147. /**
  148. * @license
  149. * Copyright 2017 Google LLC
  150. *
  151. * Licensed under the Apache License, Version 2.0 (the "License");
  152. * you may not use this file except in compliance with the License.
  153. * You may obtain a copy of the License at
  154. *
  155. * http://www.apache.org/licenses/LICENSE-2.0
  156. *
  157. * Unless required by applicable law or agreed to in writing, software
  158. * distributed under the License is distributed on an "AS IS" BASIS,
  159. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  160. * See the License for the specific language governing permissions and
  161. * limitations under the License.
  162. */
  163. /**
  164. * Unconditionally fails, throwing an Error with the given message.
  165. * Messages are stripped in production builds.
  166. *
  167. * Returns `never` and can be used in expressions:
  168. * @example
  169. * let futureVar = fail('not implemented yet');
  170. */ function k(t) {
  171. void 0 === t && (t = "Unexpected state");
  172. // Log the failure in addition to throw an exception, just in case the
  173. // exception is swallowed.
  174. var e = "FIRESTORE (".concat(g, ") INTERNAL ASSERTION FAILED: ") + t;
  175. // NOTE: We don't use FirestoreError here because these are internal failures
  176. // that cannot be handled by the user. (Also it would create a circular
  177. // dependency between the error and assert modules which doesn't work.)
  178. throw T(e), new Error(e)
  179. /**
  180. * Fails if the given assertion condition is false, throwing an Error with the
  181. * given message if it did.
  182. *
  183. * Messages are stripped in production builds.
  184. */;
  185. }
  186. function I(t, e) {
  187. t || k();
  188. }
  189. /**
  190. * Casts `obj` to `T`. In non-production builds, verifies that `obj` is an
  191. * instance of `T` before casting.
  192. */ function A(t,
  193. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  194. e) {
  195. return t;
  196. }
  197. /**
  198. * @license
  199. * Copyright 2017 Google LLC
  200. *
  201. * Licensed under the Apache License, Version 2.0 (the "License");
  202. * you may not use this file except in compliance with the License.
  203. * You may obtain a copy of the License at
  204. *
  205. * http://www.apache.org/licenses/LICENSE-2.0
  206. *
  207. * Unless required by applicable law or agreed to in writing, software
  208. * distributed under the License is distributed on an "AS IS" BASIS,
  209. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  210. * See the License for the specific language governing permissions and
  211. * limitations under the License.
  212. */ var F = "cancelled", P = "unknown", O = "invalid-argument", V = "deadline-exceeded", D = "not-found", N = "permission-denied", q = "unauthenticated", R = "resource-exhausted", x = "failed-precondition", C = "aborted", j = "out-of-range", L = "unimplemented", M = "internal", U = "unavailable", B = /** @class */ function(e) {
  213. /** @hideconstructor */
  214. function n(
  215. /**
  216. * The backend error code associated with this error.
  217. */
  218. t,
  219. /**
  220. * A custom error description.
  221. */
  222. n) {
  223. var r = this;
  224. return (r = e.call(this, t, n) || this).code = t, r.message = n,
  225. // HACK: We write a toString property directly because Error is not a real
  226. // class and so inheritance does not work correctly. We could alternatively
  227. // do the same "back-door inheritance" trick that FirebaseError does.
  228. r.toString = function() {
  229. return "".concat(r.name, ": [code=").concat(r.code, "]: ").concat(r.message);
  230. }, r;
  231. }
  232. return t(n, e), n;
  233. }(h), z = function() {
  234. var t = this;
  235. this.promise = new Promise((function(e, n) {
  236. t.resolve = e, t.reject = n;
  237. }));
  238. }, Q = function(t, e) {
  239. this.user = e, this.type = "OAuth", this.headers = new Map, this.headers.set("Authorization", "Bearer ".concat(t));
  240. }, K = /** @class */ function() {
  241. function t() {}
  242. return t.prototype.getToken = function() {
  243. return Promise.resolve(null);
  244. }, t.prototype.invalidateToken = function() {}, t.prototype.start = function(t, e) {
  245. // Fire with initial user.
  246. t.enqueueRetryable((function() {
  247. return e(v.UNAUTHENTICATED);
  248. }));
  249. }, t.prototype.shutdown = function() {}, t;
  250. }(), G = /** @class */ function() {
  251. function t(t) {
  252. this.token = t,
  253. /**
  254. * Stores the listener registered with setChangeListener()
  255. * This isn't actually necessary since the UID never changes, but we use this
  256. * to verify the listen contract is adhered to in tests.
  257. */
  258. this.changeListener = null;
  259. }
  260. return t.prototype.getToken = function() {
  261. return Promise.resolve(this.token);
  262. }, t.prototype.invalidateToken = function() {}, t.prototype.start = function(t, e) {
  263. var n = this;
  264. this.changeListener = e,
  265. // Fire with initial user.
  266. t.enqueueRetryable((function() {
  267. return e(n.token.user);
  268. }));
  269. }, t.prototype.shutdown = function() {
  270. this.changeListener = null;
  271. }, t;
  272. }(), W = /** @class */ function() {
  273. function t(t) {
  274. var e = this;
  275. this.auth = null, t.onInit((function(t) {
  276. e.auth = t;
  277. }));
  278. }
  279. return t.prototype.getToken = function() {
  280. var t = this;
  281. return this.auth ? this.auth.getToken().then((function(e) {
  282. return e ? (I("string" == typeof e.accessToken), new Q(e.accessToken, new v(t.auth.getUid()))) : null;
  283. })) : Promise.resolve(null);
  284. }, t.prototype.invalidateToken = function() {}, t.prototype.start = function(t, e) {},
  285. t.prototype.shutdown = function() {}, t;
  286. }(), Y = /** @class */ function() {
  287. function t(t, e, n) {
  288. this.t = t, this.i = e, this.o = n, this.type = "FirstParty", this.user = v.FIRST_PARTY,
  289. this.u = new Map
  290. /**
  291. * Gets an authorization token, using a provided factory function, or return
  292. * null.
  293. */;
  294. }
  295. return t.prototype.h = function() {
  296. return this.o ? this.o() : null;
  297. }, Object.defineProperty(t.prototype, "headers", {
  298. get: function() {
  299. this.u.set("X-Goog-AuthUser", this.t);
  300. // Use array notation to prevent minification
  301. var t = this.h();
  302. return t && this.u.set("Authorization", t), this.i && this.u.set("X-Goog-Iam-Authorization-Token", this.i),
  303. this.u;
  304. },
  305. enumerable: !1,
  306. configurable: !0
  307. }), t;
  308. }(), H = /** @class */ function() {
  309. function t(t, e, n) {
  310. this.t = t, this.i = e, this.o = n;
  311. }
  312. return t.prototype.getToken = function() {
  313. return Promise.resolve(new Y(this.t, this.i, this.o));
  314. }, t.prototype.start = function(t, e) {
  315. // Fire with initial uid.
  316. t.enqueueRetryable((function() {
  317. return e(v.FIRST_PARTY);
  318. }));
  319. }, t.prototype.shutdown = function() {}, t.prototype.invalidateToken = function() {},
  320. t;
  321. }(), J = function(t) {
  322. this.value = t, this.type = "AppCheck", this.headers = new Map, t && t.length > 0 && this.headers.set("x-firebase-appcheck", this.value);
  323. }, X = /** @class */ function() {
  324. function t(t) {
  325. var e = this;
  326. this.l = t, this.appCheck = null, t.onInit((function(t) {
  327. e.appCheck = t;
  328. }));
  329. }
  330. return t.prototype.getToken = function() {
  331. return this.appCheck ? this.appCheck.getToken().then((function(t) {
  332. return t ? (I("string" == typeof t.token), new J(t.token)) : null;
  333. })) : Promise.resolve(null);
  334. }, t.prototype.invalidateToken = function() {}, t.prototype.start = function(t, e) {},
  335. t.prototype.shutdown = function() {}, t;
  336. }(), $ =
  337. /**
  338. * Constructs a DatabaseInfo using the provided host, databaseId and
  339. * persistenceKey.
  340. *
  341. * @param databaseId - The database to use.
  342. * @param appId - The Firebase App Id.
  343. * @param persistenceKey - A unique identifier for this Firestore's local
  344. * storage (used in conjunction with the databaseId).
  345. * @param host - The Firestore backend host to connect to.
  346. * @param ssl - Whether to use SSL when connecting.
  347. * @param forceLongPolling - Whether to use the forceLongPolling option
  348. * when using WebChannel as the network transport.
  349. * @param autoDetectLongPolling - Whether to use the detectBufferingProxy
  350. * option when using WebChannel as the network transport.
  351. * @param longPollingOptions Options that configure long-polling.
  352. * @param useFetchStreams Whether to use the Fetch API instead of
  353. * XMLHTTPRequest
  354. */
  355. function(t, e, n, r, i, o, a, s, u) {
  356. this.databaseId = t, this.appId = e, this.persistenceKey = n, this.host = r, this.ssl = i,
  357. this.forceLongPolling = o, this.autoDetectLongPolling = a, this.longPollingOptions = s,
  358. this.useFetchStreams = u;
  359. }, Z = /** @class */ function() {
  360. function t(t, e) {
  361. this.projectId = t, this.database = e || "(default)";
  362. }
  363. return t.empty = function() {
  364. return new t("", "");
  365. }, Object.defineProperty(t.prototype, "isDefaultDatabase", {
  366. get: function() {
  367. return "(default)" === this.database;
  368. },
  369. enumerable: !1,
  370. configurable: !0
  371. }), t.prototype.isEqual = function(e) {
  372. return e instanceof t && e.projectId === this.projectId && e.database === this.database;
  373. }, t;
  374. }(), tt = /** @class */ function() {
  375. function t(t, e, n) {
  376. void 0 === e ? e = 0 : e > t.length && k(), void 0 === n ? n = t.length - e : n > t.length - e && k(),
  377. this.segments = t, this.offset = e, this.len = n;
  378. }
  379. return Object.defineProperty(t.prototype, "length", {
  380. get: function() {
  381. return this.len;
  382. },
  383. enumerable: !1,
  384. configurable: !0
  385. }), t.prototype.isEqual = function(e) {
  386. return 0 === t.comparator(this, e);
  387. }, t.prototype.child = function(e) {
  388. var n = this.segments.slice(this.offset, this.limit());
  389. return e instanceof t ? e.forEach((function(t) {
  390. n.push(t);
  391. })) : n.push(e), this.construct(n);
  392. },
  393. /** The index of one past the last segment of the path. */ t.prototype.limit = function() {
  394. return this.offset + this.length;
  395. }, t.prototype.popFirst = function(t) {
  396. return t = void 0 === t ? 1 : t, this.construct(this.segments, this.offset + t, this.length - t);
  397. }, t.prototype.popLast = function() {
  398. return this.construct(this.segments, this.offset, this.length - 1);
  399. }, t.prototype.firstSegment = function() {
  400. return this.segments[this.offset];
  401. }, t.prototype.lastSegment = function() {
  402. return this.get(this.length - 1);
  403. }, t.prototype.get = function(t) {
  404. return this.segments[this.offset + t];
  405. }, t.prototype.isEmpty = function() {
  406. return 0 === this.length;
  407. }, t.prototype.isPrefixOf = function(t) {
  408. if (t.length < this.length) return !1;
  409. for (var e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;
  410. return !0;
  411. }, t.prototype.isImmediateParentOf = function(t) {
  412. if (this.length + 1 !== t.length) return !1;
  413. for (var e = 0; e < this.length; e++) if (this.get(e) !== t.get(e)) return !1;
  414. return !0;
  415. }, t.prototype.forEach = function(t) {
  416. for (var e = this.offset, n = this.limit(); e < n; e++) t(this.segments[e]);
  417. }, t.prototype.toArray = function() {
  418. return this.segments.slice(this.offset, this.limit());
  419. }, t.comparator = function(t, e) {
  420. for (var n = Math.min(t.length, e.length), r = 0; r < n; r++) {
  421. var i = t.get(r), o = e.get(r);
  422. if (i < o) return -1;
  423. if (i > o) return 1;
  424. }
  425. return t.length < e.length ? -1 : t.length > e.length ? 1 : 0;
  426. }, t;
  427. }(), et = /** @class */ function(e) {
  428. function n() {
  429. return null !== e && e.apply(this, arguments) || this;
  430. }
  431. return t(n, e), n.prototype.construct = function(t, e, r) {
  432. return new n(t, e, r);
  433. }, n.prototype.canonicalString = function() {
  434. // NOTE: The client is ignorant of any path segments containing escape
  435. // sequences (e.g. __id123__) and just passes them through raw (they exist
  436. // for legacy reasons and should not be used frequently).
  437. return this.toArray().join("/");
  438. }, n.prototype.toString = function() {
  439. return this.canonicalString();
  440. },
  441. /**
  442. * Creates a resource path from the given slash-delimited string. If multiple
  443. * arguments are provided, all components are combined. Leading and trailing
  444. * slashes from all components are ignored.
  445. */
  446. n.fromString = function() {
  447. for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
  448. // NOTE: The client is ignorant of any path segments containing escape
  449. // sequences (e.g. __id123__) and just passes them through raw (they exist
  450. // for legacy reasons and should not be used frequently).
  451. for (var r = [], i = 0, o = t; i < o.length; i++) {
  452. var a = o[i];
  453. if (a.indexOf("//") >= 0) throw new B(O, "Invalid segment (".concat(a, "). Paths must not contain // in them."));
  454. // Strip leading and traling slashed.
  455. r.push.apply(r, a.split("/").filter((function(t) {
  456. return t.length > 0;
  457. })));
  458. }
  459. return new n(r);
  460. }, n.emptyPath = function() {
  461. return new n([]);
  462. }, n;
  463. }(tt), nt = /^[_a-zA-Z][_a-zA-Z0-9]*$/, rt = /** @class */ function(e) {
  464. function n() {
  465. return null !== e && e.apply(this, arguments) || this;
  466. }
  467. return t(n, e), n.prototype.construct = function(t, e, r) {
  468. return new n(t, e, r);
  469. },
  470. /**
  471. * Returns true if the string could be used as a segment in a field path
  472. * without escaping.
  473. */
  474. n.isValidIdentifier = function(t) {
  475. return nt.test(t);
  476. }, n.prototype.canonicalString = function() {
  477. return this.toArray().map((function(t) {
  478. return t = t.replace(/\\/g, "\\\\").replace(/`/g, "\\`"), n.isValidIdentifier(t) || (t = "`" + t + "`"),
  479. t;
  480. })).join(".");
  481. }, n.prototype.toString = function() {
  482. return this.canonicalString();
  483. },
  484. /**
  485. * Returns true if this field references the key of a document.
  486. */
  487. n.prototype.isKeyField = function() {
  488. return 1 === this.length && "__name__" === this.get(0);
  489. },
  490. /**
  491. * The field designating the key of a document.
  492. */
  493. n.keyField = function() {
  494. return new n([ "__name__" ]);
  495. },
  496. /**
  497. * Parses a field string from the given server-formatted string.
  498. *
  499. * - Splitting the empty string is not allowed (for now at least).
  500. * - Empty segments within the string (e.g. if there are two consecutive
  501. * separators) are not allowed.
  502. *
  503. * TODO(b/37244157): we should make this more strict. Right now, it allows
  504. * non-identifier path components, even if they aren't escaped.
  505. */
  506. n.fromServerFormat = function(t) {
  507. for (var e = [], r = "", i = 0, o = function() {
  508. if (0 === r.length) throw new B(O, "Invalid field path (".concat(t, "). Paths must not be empty, begin with '.', end with '.', or contain '..'"));
  509. e.push(r), r = "";
  510. }, a = !1; i < t.length; ) {
  511. var s = t[i];
  512. if ("\\" === s) {
  513. if (i + 1 === t.length) throw new B(O, "Path has trailing escape character: " + t);
  514. var u = t[i + 1];
  515. if ("\\" !== u && "." !== u && "`" !== u) throw new B(O, "Path has invalid escape sequence: " + t);
  516. r += u, i += 2;
  517. } else "`" === s ? (a = !a, i++) : "." !== s || a ? (r += s, i++) : (o(), i++);
  518. }
  519. if (o(), a) throw new B(O, "Unterminated ` in path: " + t);
  520. return new n(e);
  521. }, n.emptyPath = function() {
  522. return new n([]);
  523. }, n;
  524. }(tt), it = /** @class */ function() {
  525. function t(t) {
  526. this.path = t;
  527. }
  528. return t.fromPath = function(e) {
  529. return new t(et.fromString(e));
  530. }, t.fromName = function(e) {
  531. return new t(et.fromString(e).popFirst(5));
  532. }, t.empty = function() {
  533. return new t(et.emptyPath());
  534. }, Object.defineProperty(t.prototype, "collectionGroup", {
  535. get: function() {
  536. return this.path.popLast().lastSegment();
  537. },
  538. enumerable: !1,
  539. configurable: !0
  540. }),
  541. /** Returns true if the document is in the specified collectionId. */ t.prototype.hasCollectionId = function(t) {
  542. return this.path.length >= 2 && this.path.get(this.path.length - 2) === t;
  543. },
  544. /** Returns the collection group (i.e. the name of the parent collection) for this key. */ t.prototype.getCollectionGroup = function() {
  545. return this.path.get(this.path.length - 2);
  546. },
  547. /** Returns the fully qualified path to the parent collection. */ t.prototype.getCollectionPath = function() {
  548. return this.path.popLast();
  549. }, t.prototype.isEqual = function(t) {
  550. return null !== t && 0 === et.comparator(this.path, t.path);
  551. }, t.prototype.toString = function() {
  552. return this.path.toString();
  553. }, t.comparator = function(t, e) {
  554. return et.comparator(t.path, e.path);
  555. }, t.isDocumentKey = function(t) {
  556. return t.length % 2 == 0;
  557. },
  558. /**
  559. * Creates and returns a new document key with the given segments.
  560. *
  561. * @param segments - The segments of the path to the document
  562. * @returns A new instance of DocumentKey
  563. */
  564. t.fromSegments = function(e) {
  565. return new t(new et(e.slice()));
  566. }, t;
  567. }();
  568. /** An error returned by a Firestore operation. */
  569. /**
  570. * @license
  571. * Copyright 2017 Google LLC
  572. *
  573. * Licensed under the Apache License, Version 2.0 (the "License");
  574. * you may not use this file except in compliance with the License.
  575. * You may obtain a copy of the License at
  576. *
  577. * http://www.apache.org/licenses/LICENSE-2.0
  578. *
  579. * Unless required by applicable law or agreed to in writing, software
  580. * distributed under the License is distributed on an "AS IS" BASIS,
  581. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  582. * See the License for the specific language governing permissions and
  583. * limitations under the License.
  584. */
  585. function ot(t, e, n) {
  586. if (!n) throw new B(O, "Function ".concat(t, "() cannot be called with an empty ").concat(e, "."));
  587. }
  588. /**
  589. * Validates that two boolean options are not set at the same time.
  590. * @internal
  591. */
  592. /**
  593. * Validates that `path` refers to a document (indicated by the fact it contains
  594. * an even numbers of segments).
  595. */ function at(t) {
  596. if (!it.isDocumentKey(t)) throw new B(O, "Invalid document reference. Document references must have an even number of segments, but ".concat(t, " has ").concat(t.length, "."));
  597. }
  598. /**
  599. * Validates that `path` refers to a collection (indicated by the fact it
  600. * contains an odd numbers of segments).
  601. */ function st(t) {
  602. if (it.isDocumentKey(t)) throw new B(O, "Invalid collection reference. Collection references must have an odd number of segments, but ".concat(t, " has ").concat(t.length, "."));
  603. }
  604. /**
  605. * Returns true if it's a non-null object without a custom prototype
  606. * (i.e. excludes Array, Date, etc.).
  607. */
  608. /** Returns a string describing the type / value of the provided input. */ function ut(t) {
  609. if (void 0 === t) return "undefined";
  610. if (null === t) return "null";
  611. if ("string" == typeof t) return t.length > 20 && (t = "".concat(t.substring(0, 20), "...")),
  612. JSON.stringify(t);
  613. if ("number" == typeof t || "boolean" == typeof t) return "" + t;
  614. if ("object" == typeof t) {
  615. if (t instanceof Array) return "an array";
  616. var e =
  617. /** try to get the constructor name for an object. */
  618. function(t) {
  619. return t.constructor ? t.constructor.name : null;
  620. }(t);
  621. return e ? "a custom ".concat(e, " object") : "an object";
  622. }
  623. return "function" == typeof t ? "a function" : k();
  624. }
  625. function ct(t,
  626. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  627. e) {
  628. if ("_delegate" in t && (
  629. // Unwrap Compat types
  630. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  631. t = t._delegate), !(t instanceof e)) {
  632. if (e.name === t.constructor.name) throw new B(O, "Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");
  633. var n = ut(t);
  634. throw new B(O, "Expected type '".concat(e.name, "', but it was: ").concat(n));
  635. }
  636. return t;
  637. }
  638. function lt(t, e) {
  639. if (e <= 0) throw new B(O, "Function ".concat(t, "() requires a positive number, but it was: ").concat(e, "."));
  640. }
  641. /**
  642. * @license
  643. * Copyright 2023 Google LLC
  644. *
  645. * Licensed under the Apache License, Version 2.0 (the "License");
  646. * you may not use this file except in compliance with the License.
  647. * You may obtain a copy of the License at
  648. *
  649. * http://www.apache.org/licenses/LICENSE-2.0
  650. *
  651. * Unless required by applicable law or agreed to in writing, software
  652. * distributed under the License is distributed on an "AS IS" BASIS,
  653. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  654. * See the License for the specific language governing permissions and
  655. * limitations under the License.
  656. */
  657. /**
  658. * Compares two `ExperimentalLongPollingOptions` objects for equality.
  659. */
  660. /**
  661. * Creates and returns a new `ExperimentalLongPollingOptions` with the same
  662. * option values as the given instance.
  663. */ function ft(t) {
  664. var e = {};
  665. return void 0 !== t.timeoutSeconds && (e.timeoutSeconds = t.timeoutSeconds), e
  666. /**
  667. * @license
  668. * Copyright 2023 Google LLC
  669. *
  670. * Licensed under the Apache License, Version 2.0 (the "License");
  671. * you may not use this file except in compliance with the License.
  672. * You may obtain a copy of the License at
  673. *
  674. * http://www.apache.org/licenses/LICENSE-2.0
  675. *
  676. * Unless required by applicable law or agreed to in writing, software
  677. * distributed under the License is distributed on an "AS IS" BASIS,
  678. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  679. * See the License for the specific language governing permissions and
  680. * limitations under the License.
  681. */
  682. /**
  683. * The value returned from the most recent invocation of
  684. * `generateUniqueDebugId()`, or null if it has never been invoked.
  685. */;
  686. }
  687. var ht = null;
  688. /**
  689. * Generates and returns an initial value for `lastUniqueDebugId`.
  690. *
  691. * The returned value is randomly selected from a range of integers that are
  692. * represented as 8 hexadecimal digits. This means that (within reason) any
  693. * numbers generated by incrementing the returned number by 1 will also be
  694. * represented by 8 hexadecimal digits. This leads to all "IDs" having the same
  695. * length when converted to a hexadecimal string, making reading logs containing
  696. * these IDs easier to follow. And since the return value is randomly selected
  697. * it will help to differentiate between logs from different executions.
  698. */
  699. /**
  700. * Generates and returns a unique ID as a hexadecimal string.
  701. *
  702. * The returned ID is intended to be used in debug logging messages to help
  703. * correlate log messages that may be spatially separated in the logs, but
  704. * logically related. For example, a network connection could include the same
  705. * "debug ID" string in all of its log messages to help trace a specific
  706. * connection over time.
  707. *
  708. * @return the 10-character generated ID (e.g. "0xa1b2c3d4").
  709. */
  710. /**
  711. * @license
  712. * Copyright 2017 Google LLC
  713. *
  714. * Licensed under the Apache License, Version 2.0 (the "License");
  715. * you may not use this file except in compliance with the License.
  716. * You may obtain a copy of the License at
  717. *
  718. * http://www.apache.org/licenses/LICENSE-2.0
  719. *
  720. * Unless required by applicable law or agreed to in writing, software
  721. * distributed under the License is distributed on an "AS IS" BASIS,
  722. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  723. * See the License for the specific language governing permissions and
  724. * limitations under the License.
  725. */
  726. /**
  727. * Returns whether a variable is either undefined or null.
  728. */
  729. function pt(t) {
  730. return null == t;
  731. }
  732. /** Returns whether the value represents -0. */ function dt(t) {
  733. // Detect if the value is -0.0. Based on polyfill from
  734. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  735. return 0 === t && 1 / t == -1 / 0;
  736. }
  737. /**
  738. * Returns whether a value is an integer and in the safe integer range
  739. * @param value - The value to test for being an integer and in the safe range
  740. */
  741. /**
  742. * @license
  743. * Copyright 2020 Google LLC
  744. *
  745. * Licensed under the Apache License, Version 2.0 (the "License");
  746. * you may not use this file except in compliance with the License.
  747. * You may obtain a copy of the License at
  748. *
  749. * http://www.apache.org/licenses/LICENSE-2.0
  750. *
  751. * Unless required by applicable law or agreed to in writing, software
  752. * distributed under the License is distributed on an "AS IS" BASIS,
  753. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  754. * See the License for the specific language governing permissions and
  755. * limitations under the License.
  756. */ var yt, mt, vt = {
  757. BatchGetDocuments: "batchGet",
  758. Commit: "commit",
  759. RunQuery: "runQuery",
  760. RunAggregationQuery: "runAggregationQuery"
  761. };
  762. /**
  763. * Maps RPC names to the corresponding REST endpoint name.
  764. *
  765. * We use array notation to avoid mangling.
  766. */
  767. /**
  768. * @license
  769. * Copyright 2017 Google LLC
  770. *
  771. * Licensed under the Apache License, Version 2.0 (the "License");
  772. * you may not use this file except in compliance with the License.
  773. * You may obtain a copy of the License at
  774. *
  775. * http://www.apache.org/licenses/LICENSE-2.0
  776. *
  777. * Unless required by applicable law or agreed to in writing, software
  778. * distributed under the License is distributed on an "AS IS" BASIS,
  779. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  780. * See the License for the specific language governing permissions and
  781. * limitations under the License.
  782. */
  783. /**
  784. * Error Codes describing the different ways GRPC can fail. These are copied
  785. * directly from GRPC's sources here:
  786. *
  787. * https://github.com/grpc/grpc/blob/bceec94ea4fc5f0085d81235d8e1c06798dc341a/include/grpc%2B%2B/impl/codegen/status_code_enum.h
  788. *
  789. * Important! The names of these identifiers matter because the string forms
  790. * are used for reverse lookups from the webchannel stream. Do NOT change the
  791. * names of these identifiers or change this into a const enum.
  792. */
  793. /**
  794. * Converts an HTTP Status Code to the equivalent error code.
  795. *
  796. * @param status - An HTTP Status Code, like 200, 404, 503, etc.
  797. * @returns The equivalent Code. Unknown status codes are mapped to
  798. * Code.UNKNOWN.
  799. */
  800. function gt(t) {
  801. if (void 0 === t) return T("RPC_ERROR", "HTTP error has no status"), P;
  802. // The canonical error codes for Google APIs [1] specify mapping onto HTTP
  803. // status codes but the mapping is not bijective. In each case of ambiguity
  804. // this function chooses a primary error.
  805. // [1]
  806. // https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
  807. switch (t) {
  808. case 200:
  809. // OK
  810. return "ok";
  811. case 400:
  812. // Bad Request
  813. return x;
  814. // Other possibilities based on the forward mapping
  815. // return Code.INVALID_ARGUMENT;
  816. // return Code.OUT_OF_RANGE;
  817. case 401:
  818. // Unauthorized
  819. return q;
  820. case 403:
  821. // Forbidden
  822. return N;
  823. case 404:
  824. // Not Found
  825. return D;
  826. case 409:
  827. // Conflict
  828. return C;
  829. // Other possibilities:
  830. // return Code.ALREADY_EXISTS;
  831. case 416:
  832. // Range Not Satisfiable
  833. return j;
  834. case 429:
  835. // Too Many Requests
  836. return R;
  837. case 499:
  838. // Client Closed Request
  839. return F;
  840. case 500:
  841. // Internal Server Error
  842. return P;
  843. // Other possibilities:
  844. // return Code.INTERNAL;
  845. // return Code.DATA_LOSS;
  846. case 501:
  847. // Unimplemented
  848. return L;
  849. case 503:
  850. // Service Unavailable
  851. return U;
  852. case 504:
  853. // Gateway Timeout
  854. return V;
  855. default:
  856. return t >= 200 && t < 300 ? "ok" : t >= 400 && t < 500 ? x : t >= 500 && t < 600 ? M : P;
  857. }
  858. }
  859. /**
  860. * @license
  861. * Copyright 2020 Google LLC
  862. *
  863. * Licensed under the Apache License, Version 2.0 (the "License");
  864. * you may not use this file except in compliance with the License.
  865. * You may obtain a copy of the License at
  866. *
  867. * http://www.apache.org/licenses/LICENSE-2.0
  868. *
  869. * Unless required by applicable law or agreed to in writing, software
  870. * distributed under the License is distributed on an "AS IS" BASIS,
  871. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  872. * See the License for the specific language governing permissions and
  873. * limitations under the License.
  874. */
  875. /**
  876. * A Rest-based connection that relies on the native HTTP stack
  877. * (e.g. `fetch` or a polyfill).
  878. */ (mt = yt || (yt = {}))[mt.OK = 0] = "OK", mt[mt.CANCELLED = 1] = "CANCELLED",
  879. mt[mt.UNKNOWN = 2] = "UNKNOWN", mt[mt.INVALID_ARGUMENT = 3] = "INVALID_ARGUMENT",
  880. mt[mt.DEADLINE_EXCEEDED = 4] = "DEADLINE_EXCEEDED", mt[mt.NOT_FOUND = 5] = "NOT_FOUND",
  881. mt[mt.ALREADY_EXISTS = 6] = "ALREADY_EXISTS", mt[mt.PERMISSION_DENIED = 7] = "PERMISSION_DENIED",
  882. mt[mt.UNAUTHENTICATED = 16] = "UNAUTHENTICATED", mt[mt.RESOURCE_EXHAUSTED = 8] = "RESOURCE_EXHAUSTED",
  883. mt[mt.FAILED_PRECONDITION = 9] = "FAILED_PRECONDITION", mt[mt.ABORTED = 10] = "ABORTED",
  884. mt[mt.OUT_OF_RANGE = 11] = "OUT_OF_RANGE", mt[mt.UNIMPLEMENTED = 12] = "UNIMPLEMENTED",
  885. mt[mt.INTERNAL = 13] = "INTERNAL", mt[mt.UNAVAILABLE = 14] = "UNAVAILABLE", mt[mt.DATA_LOSS = 15] = "DATA_LOSS";
  886. var wt = /** @class */ function(r) {
  887. /**
  888. * @param databaseInfo - The connection info.
  889. * @param fetchImpl - `fetch` or a Polyfill that implements the fetch API.
  890. */
  891. function i(t, e) {
  892. var n = this;
  893. return (n = r.call(this, t) || this).P = e, n;
  894. }
  895. /**
  896. * Base class for all Rest-based connections to the backend (WebChannel and
  897. * HTTP).
  898. */
  899. return t(i, r), i.prototype.V = function(t, e) {
  900. throw new Error("Not supported by FetchConnection");
  901. }, i.prototype.A = function(t, r, i, o) {
  902. return e(this, void 0, void 0, (function() {
  903. var t, e, a, s, u, c, l;
  904. return n(this, (function(n) {
  905. switch (n.label) {
  906. case 0:
  907. e = JSON.stringify(o), n.label = 1;
  908. case 1:
  909. return n.trys.push([ 1, 3, , 4 ]), [ 4 /*yield*/ , this.P(r, {
  910. method: "POST",
  911. headers: i,
  912. body: e
  913. }) ];
  914. case 2:
  915. return a = n.sent(), [ 3 /*break*/ , 4 ];
  916. case 3:
  917. throw s = n.sent(), new B(gt((u = s).status), "Request failed with error: " + u.statusText);
  918. case 4:
  919. return a.ok ? [ 3 /*break*/ , 6 ] : [ 4 /*yield*/ , a.json() ];
  920. case 5:
  921. throw c = n.sent(), Array.isArray(c) && (c = c[0]), l = null === (t = null == c ? void 0 : c.error) || void 0 === t ? void 0 : t.message,
  922. new B(gt(a.status), "Request failed with error: ".concat(null != l ? l : a.statusText));
  923. case 6:
  924. return [ 2 /*return*/ , a.json() ];
  925. }
  926. }));
  927. }));
  928. }, i;
  929. }(/** @class */ function() {
  930. function t(t) {
  931. this.databaseInfo = t, this.databaseId = t.databaseId;
  932. var e = t.ssl ? "https" : "http";
  933. this.m = e + "://" + t.host, this.p = "projects/" + this.databaseId.projectId + "/databases/" + this.databaseId.database + "/documents";
  934. }
  935. return Object.defineProperty(t.prototype, "g", {
  936. get: function() {
  937. // Both `invokeRPC()` and `invokeStreamingRPC()` use their `path` arguments to determine
  938. // where to run the query, and expect the `request` to NOT specify the "path".
  939. return !1;
  940. },
  941. enumerable: !1,
  942. configurable: !0
  943. }), t.prototype.v = function(t, e, n, r, i) {
  944. var o = (null === ht ? ht = 268435456 + Math.round(2147483648 * Math.random()) : ht++,
  945. "0x" + ht.toString(16)), a = this.I(t, e);
  946. b("RestConnection", "Sending RPC '".concat(t, "' ").concat(o, ":"), a, n);
  947. var s = {};
  948. return this.T(s, r, i), this.A(t, a, s, n).then((function(e) {
  949. return b("RestConnection", "Received RPC '".concat(t, "' ").concat(o, ": "), e),
  950. e;
  951. }), (function(e) {
  952. throw E("RestConnection", "RPC '".concat(t, "' ").concat(o, " failed with error: "), e, "url: ", a, "request:", n),
  953. e;
  954. }));
  955. }, t.prototype.R = function(t, e, n, r, i, o) {
  956. // The REST API automatically aggregates all of the streamed results, so we
  957. // can just use the normal invoke() method.
  958. return this.v(t, e, n, r, i);
  959. },
  960. /**
  961. * Modifies the headers for a request, adding any authorization token if
  962. * present and any additional headers for the request.
  963. */
  964. t.prototype.T = function(t, e, n) {
  965. t["X-Goog-Api-Client"] = "gl-js/ fire/" + g,
  966. // Content-Type: text/plain will avoid preflight requests which might
  967. // mess with CORS and redirects by proxies. If we add custom headers
  968. // we will need to change this code to potentially use the $httpOverwrite
  969. // parameter supported by ESF to avoid triggering preflight requests.
  970. t["Content-Type"] = "text/plain", this.databaseInfo.appId && (t["X-Firebase-GMPID"] = this.databaseInfo.appId),
  971. e && e.headers.forEach((function(e, n) {
  972. return t[n] = e;
  973. })), n && n.headers.forEach((function(e, n) {
  974. return t[n] = e;
  975. }));
  976. }, t.prototype.I = function(t, e) {
  977. var n = vt[t];
  978. return "".concat(this.m, "/v1/").concat(e, ":").concat(n);
  979. }, t;
  980. }()), _t = function(t, e, n) {
  981. this.alias = t, this.$ = e, this.fieldPath = n;
  982. };
  983. /**
  984. * @license
  985. * Copyright 2020 Google LLC
  986. *
  987. * Licensed under the Apache License, Version 2.0 (the "License");
  988. * you may not use this file except in compliance with the License.
  989. * You may obtain a copy of the License at
  990. *
  991. * http://www.apache.org/licenses/LICENSE-2.0
  992. *
  993. * Unless required by applicable law or agreed to in writing, software
  994. * distributed under the License is distributed on an "AS IS" BASIS,
  995. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  996. * See the License for the specific language governing permissions and
  997. * limitations under the License.
  998. */
  999. /** Initializes the HTTP connection for the REST API. */
  1000. /**
  1001. * @license
  1002. * Copyright 2023 Google LLC
  1003. *
  1004. * Licensed under the Apache License, Version 2.0 (the "License");
  1005. * you may not use this file except in compliance with the License.
  1006. * You may obtain a copy of the License at
  1007. *
  1008. * http://www.apache.org/licenses/LICENSE-2.0
  1009. *
  1010. * Unless required by applicable law or agreed to in writing, software
  1011. * distributed under the License is distributed on an "AS IS" BASIS,
  1012. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1013. * See the License for the specific language governing permissions and
  1014. * limitations under the License.
  1015. */
  1016. /**
  1017. * Concrete implementation of the Aggregate type.
  1018. */
  1019. /**
  1020. * @license
  1021. * Copyright 2020 Google LLC
  1022. *
  1023. * Licensed under the Apache License, Version 2.0 (the "License");
  1024. * you may not use this file except in compliance with the License.
  1025. * You may obtain a copy of the License at
  1026. *
  1027. * http://www.apache.org/licenses/LICENSE-2.0
  1028. *
  1029. * Unless required by applicable law or agreed to in writing, software
  1030. * distributed under the License is distributed on an "AS IS" BASIS,
  1031. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1032. * See the License for the specific language governing permissions and
  1033. * limitations under the License.
  1034. */
  1035. /**
  1036. * Generates `nBytes` of random bytes.
  1037. *
  1038. * If `nBytes < 0` , an error will be thrown.
  1039. */
  1040. function bt(t) {
  1041. // Polyfills for IE and WebWorker by using `self` and `msCrypto` when `crypto` is not available.
  1042. var e =
  1043. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  1044. "undefined" != typeof self && (self.crypto || self.msCrypto), n = new Uint8Array(t);
  1045. if (e && "function" == typeof e.getRandomValues) e.getRandomValues(n); else
  1046. // Falls back to Math.random
  1047. for (var r = 0; r < t; r++) n[r] = Math.floor(256 * Math.random());
  1048. return n;
  1049. }
  1050. /**
  1051. * @license
  1052. * Copyright 2017 Google LLC
  1053. *
  1054. * Licensed under the Apache License, Version 2.0 (the "License");
  1055. * you may not use this file except in compliance with the License.
  1056. * You may obtain a copy of the License at
  1057. *
  1058. * http://www.apache.org/licenses/LICENSE-2.0
  1059. *
  1060. * Unless required by applicable law or agreed to in writing, software
  1061. * distributed under the License is distributed on an "AS IS" BASIS,
  1062. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1063. * See the License for the specific language governing permissions and
  1064. * limitations under the License.
  1065. */ var Tt = /** @class */ function() {
  1066. function t() {}
  1067. return t.N = function() {
  1068. for (
  1069. // Alphanumeric characters
  1070. var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", e = Math.floor(256 / t.length) * t.length, n = ""
  1071. // The largest byte value that is a multiple of `char.length`.
  1072. ; n.length < 20; ) for (var r = bt(40), i = 0; i < r.length; ++i)
  1073. // Only accept values that are [0, maxMultiple), this ensures they can
  1074. // be evenly mapped to indices of `chars` via a modulo operation.
  1075. n.length < 20 && r[i] < e && (n += t.charAt(r[i] % t.length));
  1076. return n;
  1077. }, t;
  1078. }();
  1079. function Et(t, e) {
  1080. return t < e ? -1 : t > e ? 1 : 0;
  1081. }
  1082. /** Helper to compare arrays using isEqual(). */ function St(t, e, n) {
  1083. return t.length === e.length && t.every((function(t, r) {
  1084. return n(t, e[r]);
  1085. }));
  1086. }
  1087. /**
  1088. * @license
  1089. * Copyright 2017 Google LLC
  1090. *
  1091. * Licensed under the Apache License, Version 2.0 (the "License");
  1092. * you may not use this file except in compliance with the License.
  1093. * You may obtain a copy of the License at
  1094. *
  1095. * http://www.apache.org/licenses/LICENSE-2.0
  1096. *
  1097. * Unless required by applicable law or agreed to in writing, software
  1098. * distributed under the License is distributed on an "AS IS" BASIS,
  1099. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1100. * See the License for the specific language governing permissions and
  1101. * limitations under the License.
  1102. */ function kt(t) {
  1103. var e = 0;
  1104. for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e++;
  1105. return e;
  1106. }
  1107. function It(t, e) {
  1108. for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e(n, t[n]);
  1109. }
  1110. /**
  1111. * @license
  1112. * Copyright 2023 Google LLC
  1113. *
  1114. * Licensed under the Apache License, Version 2.0 (the "License");
  1115. * you may not use this file except in compliance with the License.
  1116. * You may obtain a copy of the License at
  1117. *
  1118. * http://www.apache.org/licenses/LICENSE-2.0
  1119. *
  1120. * Unless required by applicable law or agreed to in writing, software
  1121. * distributed under the License is distributed on an "AS IS" BASIS,
  1122. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1123. * See the License for the specific language governing permissions and
  1124. * limitations under the License.
  1125. */
  1126. /**
  1127. * An error encountered while decoding base64 string.
  1128. */ var At = /** @class */ function(e) {
  1129. function n() {
  1130. var t = this;
  1131. return (t = e.apply(this, arguments) || this).name = "Base64DecodeError", t;
  1132. }
  1133. return t(n, e), n;
  1134. }(Error), Ft = /** @class */ function() {
  1135. function t(t) {
  1136. this.binaryString = t;
  1137. }
  1138. return t.fromBase64String = function(e) {
  1139. var n = function(t) {
  1140. try {
  1141. return atob(t);
  1142. } catch (t) {
  1143. // Check that `DOMException` is defined before using it to avoid
  1144. // "ReferenceError: Property 'DOMException' doesn't exist" in react-native.
  1145. // (https://github.com/firebase/firebase-js-sdk/issues/7115)
  1146. throw "undefined" != typeof DOMException && t instanceof DOMException ? new At("Invalid base64 string: " + t) : t;
  1147. }
  1148. }(e);
  1149. return new t(n);
  1150. }, t.fromUint8Array = function(e) {
  1151. // TODO(indexing); Remove the copy of the byte string here as this method
  1152. // is frequently called during indexing.
  1153. var n =
  1154. /**
  1155. * Helper function to convert an Uint8array to a binary string.
  1156. */
  1157. function(t) {
  1158. for (var e = "", n = 0; n < t.length; ++n) e += String.fromCharCode(t[n]);
  1159. return e;
  1160. }(e);
  1161. return new t(n);
  1162. }, t.prototype[Symbol.iterator] = function() {
  1163. var t = this, e = 0;
  1164. return {
  1165. next: function() {
  1166. return e < t.binaryString.length ? {
  1167. value: t.binaryString.charCodeAt(e++),
  1168. done: !1
  1169. } : {
  1170. value: void 0,
  1171. done: !0
  1172. };
  1173. }
  1174. };
  1175. }, t.prototype.toBase64 = function() {
  1176. return t = this.binaryString, btoa(t);
  1177. var t;
  1178. }, t.prototype.toUint8Array = function() {
  1179. return function(t) {
  1180. for (var e = new Uint8Array(t.length), n = 0; n < t.length; n++) e[n] = t.charCodeAt(n);
  1181. return e;
  1182. }(this.binaryString);
  1183. }, t.prototype.approximateByteSize = function() {
  1184. return 2 * this.binaryString.length;
  1185. }, t.prototype.compareTo = function(t) {
  1186. return Et(this.binaryString, t.binaryString);
  1187. }, t.prototype.isEqual = function(t) {
  1188. return this.binaryString === t.binaryString;
  1189. }, t;
  1190. }();
  1191. /**
  1192. * @license
  1193. * Copyright 2020 Google LLC
  1194. *
  1195. * Licensed under the Apache License, Version 2.0 (the "License");
  1196. * you may not use this file except in compliance with the License.
  1197. * You may obtain a copy of the License at
  1198. *
  1199. * http://www.apache.org/licenses/LICENSE-2.0
  1200. *
  1201. * Unless required by applicable law or agreed to in writing, software
  1202. * distributed under the License is distributed on an "AS IS" BASIS,
  1203. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1204. * See the License for the specific language governing permissions and
  1205. * limitations under the License.
  1206. */
  1207. /** Converts a Base64 encoded string to a binary string. */
  1208. /**
  1209. * @license
  1210. * Copyright 2020 Google LLC
  1211. *
  1212. * Licensed under the Apache License, Version 2.0 (the "License");
  1213. * you may not use this file except in compliance with the License.
  1214. * You may obtain a copy of the License at
  1215. *
  1216. * http://www.apache.org/licenses/LICENSE-2.0
  1217. *
  1218. * Unless required by applicable law or agreed to in writing, software
  1219. * distributed under the License is distributed on an "AS IS" BASIS,
  1220. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1221. * See the License for the specific language governing permissions and
  1222. * limitations under the License.
  1223. */
  1224. /**
  1225. * Immutable class that represents a "proto" byte string.
  1226. *
  1227. * Proto byte strings can either be Base64-encoded strings or Uint8Arrays when
  1228. * sent on the wire. This class abstracts away this differentiation by holding
  1229. * the proto byte string in a common class that must be converted into a string
  1230. * before being sent as a proto.
  1231. * @internal
  1232. */ Ft.EMPTY_BYTE_STRING = new Ft("");
  1233. var Pt = new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);
  1234. /**
  1235. * Converts the possible Proto values for a timestamp value into a "seconds and
  1236. * nanos" representation.
  1237. */ function Ot(t) {
  1238. // The json interface (for the browser) will return an iso timestamp string,
  1239. // while the proto js library (for node) will return a
  1240. // google.protobuf.Timestamp instance.
  1241. if (I(!!t), "string" == typeof t) {
  1242. // The date string can have higher precision (nanos) than the Date class
  1243. // (millis), so we do some custom parsing here.
  1244. // Parse the nanos right out of the string.
  1245. var e = 0, n = Pt.exec(t);
  1246. if (I(!!n), n[1]) {
  1247. // Pad the fraction out to 9 digits (nanos).
  1248. var r = n[1];
  1249. r = (r + "000000000").substr(0, 9), e = Number(r);
  1250. }
  1251. // Parse the date to get the seconds.
  1252. var i = new Date(t);
  1253. return {
  1254. seconds: Math.floor(i.getTime() / 1e3),
  1255. nanos: e
  1256. };
  1257. }
  1258. return {
  1259. seconds: Vt(t.seconds),
  1260. nanos: Vt(t.nanos)
  1261. };
  1262. }
  1263. /**
  1264. * Converts the possible Proto types for numbers into a JavaScript number.
  1265. * Returns 0 if the value is not numeric.
  1266. */ function Vt(t) {
  1267. // TODO(bjornick): Handle int64 greater than 53 bits.
  1268. return "number" == typeof t ? t : "string" == typeof t ? Number(t) : 0;
  1269. }
  1270. /** Converts the possible Proto types for Blobs into a ByteString. */ function Dt(t) {
  1271. return "string" == typeof t ? Ft.fromBase64String(t) : Ft.fromUint8Array(t);
  1272. }
  1273. /**
  1274. * @license
  1275. * Copyright 2017 Google LLC
  1276. *
  1277. * Licensed under the Apache License, Version 2.0 (the "License");
  1278. * you may not use this file except in compliance with the License.
  1279. * You may obtain a copy of the License at
  1280. *
  1281. * http://www.apache.org/licenses/LICENSE-2.0
  1282. *
  1283. * Unless required by applicable law or agreed to in writing, software
  1284. * distributed under the License is distributed on an "AS IS" BASIS,
  1285. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1286. * See the License for the specific language governing permissions and
  1287. * limitations under the License.
  1288. */
  1289. // The earliest date supported by Firestore timestamps (0001-01-01T00:00:00Z).
  1290. /**
  1291. * A `Timestamp` represents a point in time independent of any time zone or
  1292. * calendar, represented as seconds and fractions of seconds at nanosecond
  1293. * resolution in UTC Epoch time.
  1294. *
  1295. * It is encoded using the Proleptic Gregorian Calendar which extends the
  1296. * Gregorian calendar backwards to year one. It is encoded assuming all minutes
  1297. * are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second
  1298. * table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to
  1299. * 9999-12-31T23:59:59.999999999Z.
  1300. *
  1301. * For examples and further specifications, refer to the
  1302. * {@link https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto | Timestamp definition}.
  1303. */ var Nt = /** @class */ function() {
  1304. /**
  1305. * Creates a new timestamp.
  1306. *
  1307. * @param seconds - The number of seconds of UTC time since Unix epoch
  1308. * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
  1309. * 9999-12-31T23:59:59Z inclusive.
  1310. * @param nanoseconds - The non-negative fractions of a second at nanosecond
  1311. * resolution. Negative second values with fractions must still have
  1312. * non-negative nanoseconds values that count forward in time. Must be
  1313. * from 0 to 999,999,999 inclusive.
  1314. */
  1315. function t(
  1316. /**
  1317. * The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z.
  1318. */
  1319. t,
  1320. /**
  1321. * The fractions of a second at nanosecond resolution.*
  1322. */
  1323. e) {
  1324. if (this.seconds = t, this.nanoseconds = e, e < 0) throw new B(O, "Timestamp nanoseconds out of range: " + e);
  1325. if (e >= 1e9) throw new B(O, "Timestamp nanoseconds out of range: " + e);
  1326. if (t < -62135596800) throw new B(O, "Timestamp seconds out of range: " + t);
  1327. // This will break in the year 10,000.
  1328. if (t >= 253402300800) throw new B(O, "Timestamp seconds out of range: " + t);
  1329. }
  1330. /**
  1331. * Creates a new timestamp with the current date, with millisecond precision.
  1332. *
  1333. * @returns a new timestamp representing the current date.
  1334. */ return t.now = function() {
  1335. return t.fromMillis(Date.now());
  1336. },
  1337. /**
  1338. * Creates a new timestamp from the given date.
  1339. *
  1340. * @param date - The date to initialize the `Timestamp` from.
  1341. * @returns A new `Timestamp` representing the same point in time as the given
  1342. * date.
  1343. */
  1344. t.fromDate = function(e) {
  1345. return t.fromMillis(e.getTime());
  1346. },
  1347. /**
  1348. * Creates a new timestamp from the given number of milliseconds.
  1349. *
  1350. * @param milliseconds - Number of milliseconds since Unix epoch
  1351. * 1970-01-01T00:00:00Z.
  1352. * @returns A new `Timestamp` representing the same point in time as the given
  1353. * number of milliseconds.
  1354. */
  1355. t.fromMillis = function(e) {
  1356. var n = Math.floor(e / 1e3);
  1357. return new t(n, Math.floor(1e6 * (e - 1e3 * n)));
  1358. },
  1359. /**
  1360. * Converts a `Timestamp` to a JavaScript `Date` object. This conversion
  1361. * causes a loss of precision since `Date` objects only support millisecond
  1362. * precision.
  1363. *
  1364. * @returns JavaScript `Date` object representing the same point in time as
  1365. * this `Timestamp`, with millisecond precision.
  1366. */
  1367. t.prototype.toDate = function() {
  1368. return new Date(this.toMillis());
  1369. },
  1370. /**
  1371. * Converts a `Timestamp` to a numeric timestamp (in milliseconds since
  1372. * epoch). This operation causes a loss of precision.
  1373. *
  1374. * @returns The point in time corresponding to this timestamp, represented as
  1375. * the number of milliseconds since Unix epoch 1970-01-01T00:00:00Z.
  1376. */
  1377. t.prototype.toMillis = function() {
  1378. return 1e3 * this.seconds + this.nanoseconds / 1e6;
  1379. }, t.prototype._compareTo = function(t) {
  1380. return this.seconds === t.seconds ? Et(this.nanoseconds, t.nanoseconds) : Et(this.seconds, t.seconds);
  1381. },
  1382. /**
  1383. * Returns true if this `Timestamp` is equal to the provided one.
  1384. *
  1385. * @param other - The `Timestamp` to compare against.
  1386. * @returns true if this `Timestamp` is equal to the provided one.
  1387. */
  1388. t.prototype.isEqual = function(t) {
  1389. return t.seconds === this.seconds && t.nanoseconds === this.nanoseconds;
  1390. },
  1391. /** Returns a textual representation of this `Timestamp`. */ t.prototype.toString = function() {
  1392. return "Timestamp(seconds=" + this.seconds + ", nanoseconds=" + this.nanoseconds + ")";
  1393. },
  1394. /** Returns a JSON-serializable representation of this `Timestamp`. */ t.prototype.toJSON = function() {
  1395. return {
  1396. seconds: this.seconds,
  1397. nanoseconds: this.nanoseconds
  1398. };
  1399. },
  1400. /**
  1401. * Converts this object to a primitive string, which allows `Timestamp` objects
  1402. * to be compared using the `>`, `<=`, `>=` and `>` operators.
  1403. */
  1404. t.prototype.valueOf = function() {
  1405. // This method returns a string of the form <seconds>.<nanoseconds> where
  1406. // <seconds> is translated to have a non-negative value and both <seconds>
  1407. // and <nanoseconds> are left-padded with zeroes to be a consistent length.
  1408. // Strings with this format then have a lexiographical ordering that matches
  1409. // the expected ordering. The <seconds> translation is done to avoid having
  1410. // a leading negative sign (i.e. a leading '-' character) in its string
  1411. // representation, which would affect its lexiographical ordering.
  1412. var t = this.seconds - -62135596800;
  1413. // Note: Up to 12 decimal digits are required to represent all valid
  1414. // 'seconds' values.
  1415. return String(t).padStart(12, "0") + "." + String(this.nanoseconds).padStart(9, "0");
  1416. }, t;
  1417. }();
  1418. /**
  1419. * @license
  1420. * Copyright 2020 Google LLC
  1421. *
  1422. * Licensed under the Apache License, Version 2.0 (the "License");
  1423. * you may not use this file except in compliance with the License.
  1424. * You may obtain a copy of the License at
  1425. *
  1426. * http://www.apache.org/licenses/LICENSE-2.0
  1427. *
  1428. * Unless required by applicable law or agreed to in writing, software
  1429. * distributed under the License is distributed on an "AS IS" BASIS,
  1430. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1431. * See the License for the specific language governing permissions and
  1432. * limitations under the License.
  1433. */
  1434. /**
  1435. * Represents a locally-applied ServerTimestamp.
  1436. *
  1437. * Server Timestamps are backed by MapValues that contain an internal field
  1438. * `__type__` with a value of `server_timestamp`. The previous value and local
  1439. * write time are stored in its `__previous_value__` and `__local_write_time__`
  1440. * fields respectively.
  1441. *
  1442. * Notes:
  1443. * - ServerTimestampValue instances are created as the result of applying a
  1444. * transform. They can only exist in the local view of a document. Therefore
  1445. * they do not need to be parsed or serialized.
  1446. * - When evaluated locally (e.g. for snapshot.data()), they by default
  1447. * evaluate to `null`. This behavior can be configured by passing custom
  1448. * FieldValueOptions to value().
  1449. * - With respect to other ServerTimestampValues, they sort by their
  1450. * localWriteTime.
  1451. */ function qt(t) {
  1452. var e, n;
  1453. return "server_timestamp" === (null === (n = ((null === (e = null == t ? void 0 : t.mapValue) || void 0 === e ? void 0 : e.fields) || {}).__type__) || void 0 === n ? void 0 : n.stringValue);
  1454. }
  1455. /**
  1456. * Returns the value of the field before this ServerTimestamp was set.
  1457. *
  1458. * Preserving the previous values allows the user to display the last resoled
  1459. * value until the backend responds with the timestamp.
  1460. */ function Rt(t) {
  1461. var e = t.mapValue.fields.__previous_value__;
  1462. return qt(e) ? Rt(e) : e;
  1463. }
  1464. /**
  1465. * Returns the local time at which this timestamp was first set.
  1466. */ function xt(t) {
  1467. var e = Ot(t.mapValue.fields.__local_write_time__.timestampValue);
  1468. return new Nt(e.seconds, e.nanos);
  1469. }
  1470. /**
  1471. * @license
  1472. * Copyright 2020 Google LLC
  1473. *
  1474. * Licensed under the Apache License, Version 2.0 (the "License");
  1475. * you may not use this file except in compliance with the License.
  1476. * You may obtain a copy of the License at
  1477. *
  1478. * http://www.apache.org/licenses/LICENSE-2.0
  1479. *
  1480. * Unless required by applicable law or agreed to in writing, software
  1481. * distributed under the License is distributed on an "AS IS" BASIS,
  1482. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1483. * See the License for the specific language governing permissions and
  1484. * limitations under the License.
  1485. */ var Ct = {
  1486. fields: {
  1487. __type__: {
  1488. stringValue: "__max__"
  1489. }
  1490. }
  1491. };
  1492. /** Extracts the backend's type order for the provided value. */ function jt(t) {
  1493. return "nullValue" in t ? 0 /* TypeOrder.NullValue */ : "booleanValue" in t ? 1 /* TypeOrder.BooleanValue */ : "integerValue" in t || "doubleValue" in t ? 2 /* TypeOrder.NumberValue */ : "timestampValue" in t ? 3 /* TypeOrder.TimestampValue */ : "stringValue" in t ? 5 /* TypeOrder.StringValue */ : "bytesValue" in t ? 6 /* TypeOrder.BlobValue */ : "referenceValue" in t ? 7 /* TypeOrder.RefValue */ : "geoPointValue" in t ? 8 /* TypeOrder.GeoPointValue */ : "arrayValue" in t ? 9 /* TypeOrder.ArrayValue */ : "mapValue" in t ? qt(t) ? 4 /* TypeOrder.ServerTimestampValue */ :
  1494. /** Returns true if the Value represents the canonical {@link #MAX_VALUE} . */
  1495. function(t) {
  1496. return "__max__" === (((t.mapValue || {}).fields || {}).__type__ || {}).stringValue;
  1497. }(t) ? 9007199254740991 /* TypeOrder.MaxValue */ : 10 /* TypeOrder.ObjectValue */ : k();
  1498. }
  1499. /** Tests `left` and `right` for equality based on the backend semantics. */ function Lt(t, e) {
  1500. if (t === e) return !0;
  1501. var n = jt(t);
  1502. if (n !== jt(e)) return !1;
  1503. switch (n) {
  1504. case 0 /* TypeOrder.NullValue */ :
  1505. case 9007199254740991 /* TypeOrder.MaxValue */ :
  1506. return !0;
  1507. case 1 /* TypeOrder.BooleanValue */ :
  1508. return t.booleanValue === e.booleanValue;
  1509. case 4 /* TypeOrder.ServerTimestampValue */ :
  1510. return xt(t).isEqual(xt(e));
  1511. case 3 /* TypeOrder.TimestampValue */ :
  1512. return function(t, e) {
  1513. if ("string" == typeof t.timestampValue && "string" == typeof e.timestampValue && t.timestampValue.length === e.timestampValue.length)
  1514. // Use string equality for ISO 8601 timestamps
  1515. return t.timestampValue === e.timestampValue;
  1516. var n = Ot(t.timestampValue), r = Ot(e.timestampValue);
  1517. return n.seconds === r.seconds && n.nanos === r.nanos;
  1518. }(t, e);
  1519. case 5 /* TypeOrder.StringValue */ :
  1520. return t.stringValue === e.stringValue;
  1521. case 6 /* TypeOrder.BlobValue */ :
  1522. return function(t, e) {
  1523. return Dt(t.bytesValue).isEqual(Dt(e.bytesValue));
  1524. }(t, e);
  1525. case 7 /* TypeOrder.RefValue */ :
  1526. return t.referenceValue === e.referenceValue;
  1527. case 8 /* TypeOrder.GeoPointValue */ :
  1528. return function(t, e) {
  1529. return Vt(t.geoPointValue.latitude) === Vt(e.geoPointValue.latitude) && Vt(t.geoPointValue.longitude) === Vt(e.geoPointValue.longitude);
  1530. }(t, e);
  1531. case 2 /* TypeOrder.NumberValue */ :
  1532. return function(t, e) {
  1533. if ("integerValue" in t && "integerValue" in e) return Vt(t.integerValue) === Vt(e.integerValue);
  1534. if ("doubleValue" in t && "doubleValue" in e) {
  1535. var n = Vt(t.doubleValue), r = Vt(e.doubleValue);
  1536. return n === r ? dt(n) === dt(r) : isNaN(n) && isNaN(r);
  1537. }
  1538. return !1;
  1539. }(t, e);
  1540. case 9 /* TypeOrder.ArrayValue */ :
  1541. return St(t.arrayValue.values || [], e.arrayValue.values || [], Lt);
  1542. case 10 /* TypeOrder.ObjectValue */ :
  1543. return function(t, e) {
  1544. var n = t.mapValue.fields || {}, r = e.mapValue.fields || {};
  1545. if (kt(n) !== kt(r)) return !1;
  1546. for (var i in n) if (n.hasOwnProperty(i) && (void 0 === r[i] || !Lt(n[i], r[i]))) return !1;
  1547. return !0;
  1548. }(t, e);
  1549. default:
  1550. return k();
  1551. }
  1552. }
  1553. function Mt(t, e) {
  1554. return void 0 !== (t.values || []).find((function(t) {
  1555. return Lt(t, e);
  1556. }));
  1557. }
  1558. function Ut(t, e) {
  1559. if (t === e) return 0;
  1560. var n = jt(t), r = jt(e);
  1561. if (n !== r) return Et(n, r);
  1562. switch (n) {
  1563. case 0 /* TypeOrder.NullValue */ :
  1564. case 9007199254740991 /* TypeOrder.MaxValue */ :
  1565. return 0;
  1566. case 1 /* TypeOrder.BooleanValue */ :
  1567. return Et(t.booleanValue, e.booleanValue);
  1568. case 2 /* TypeOrder.NumberValue */ :
  1569. return function(t, e) {
  1570. var n = Vt(t.integerValue || t.doubleValue), r = Vt(e.integerValue || e.doubleValue);
  1571. return n < r ? -1 : n > r ? 1 : n === r ? 0 :
  1572. // one or both are NaN.
  1573. isNaN(n) ? isNaN(r) ? 0 : -1 : 1;
  1574. }(t, e);
  1575. case 3 /* TypeOrder.TimestampValue */ :
  1576. return Bt(t.timestampValue, e.timestampValue);
  1577. case 4 /* TypeOrder.ServerTimestampValue */ :
  1578. return Bt(xt(t), xt(e));
  1579. case 5 /* TypeOrder.StringValue */ :
  1580. return Et(t.stringValue, e.stringValue);
  1581. case 6 /* TypeOrder.BlobValue */ :
  1582. return function(t, e) {
  1583. var n = Dt(t), r = Dt(e);
  1584. return n.compareTo(r);
  1585. }(t.bytesValue, e.bytesValue);
  1586. case 7 /* TypeOrder.RefValue */ :
  1587. return function(t, e) {
  1588. for (var n = t.split("/"), r = e.split("/"), i = 0; i < n.length && i < r.length; i++) {
  1589. var o = Et(n[i], r[i]);
  1590. if (0 !== o) return o;
  1591. }
  1592. return Et(n.length, r.length);
  1593. }(t.referenceValue, e.referenceValue);
  1594. case 8 /* TypeOrder.GeoPointValue */ :
  1595. return function(t, e) {
  1596. var n = Et(Vt(t.latitude), Vt(e.latitude));
  1597. return 0 !== n ? n : Et(Vt(t.longitude), Vt(e.longitude));
  1598. }(t.geoPointValue, e.geoPointValue);
  1599. case 9 /* TypeOrder.ArrayValue */ :
  1600. return function(t, e) {
  1601. for (var n = t.values || [], r = e.values || [], i = 0; i < n.length && i < r.length; ++i) {
  1602. var o = Ut(n[i], r[i]);
  1603. if (o) return o;
  1604. }
  1605. return Et(n.length, r.length);
  1606. }(t.arrayValue, e.arrayValue);
  1607. case 10 /* TypeOrder.ObjectValue */ :
  1608. return function(t, e) {
  1609. if (t === Ct && e === Ct) return 0;
  1610. if (t === Ct) return 1;
  1611. if (e === Ct) return -1;
  1612. var n = t.fields || {}, r = Object.keys(n), i = e.fields || {}, o = Object.keys(i);
  1613. // Even though MapValues are likely sorted correctly based on their insertion
  1614. // order (e.g. when received from the backend), local modifications can bring
  1615. // elements out of order. We need to re-sort the elements to ensure that
  1616. // canonical IDs are independent of insertion order.
  1617. r.sort(), o.sort();
  1618. for (var a = 0; a < r.length && a < o.length; ++a) {
  1619. var s = Et(r[a], o[a]);
  1620. if (0 !== s) return s;
  1621. var u = Ut(n[r[a]], i[o[a]]);
  1622. if (0 !== u) return u;
  1623. }
  1624. return Et(r.length, o.length);
  1625. }(t.mapValue, e.mapValue);
  1626. default:
  1627. throw k();
  1628. }
  1629. }
  1630. function Bt(t, e) {
  1631. if ("string" == typeof t && "string" == typeof e && t.length === e.length) return Et(t, e);
  1632. var n = Ot(t), r = Ot(e), i = Et(n.seconds, r.seconds);
  1633. return 0 !== i ? i : Et(n.nanos, r.nanos);
  1634. }
  1635. function zt(t, e) {
  1636. return {
  1637. referenceValue: "projects/".concat(t.projectId, "/databases/").concat(t.database, "/documents/").concat(e.path.canonicalString())
  1638. };
  1639. }
  1640. /** Returns true if `value` is an ArrayValue. */ function Qt(t) {
  1641. return !!t && "arrayValue" in t;
  1642. }
  1643. /** Returns true if `value` is a NullValue. */ function Kt(t) {
  1644. return !!t && "nullValue" in t;
  1645. }
  1646. /** Returns true if `value` is NaN. */ function Gt(t) {
  1647. return !!t && "doubleValue" in t && isNaN(Number(t.doubleValue));
  1648. }
  1649. /** Returns true if `value` is a MapValue. */ function Wt(t) {
  1650. return !!t && "mapValue" in t;
  1651. }
  1652. /** Creates a deep copy of `source`. */ function Yt(t) {
  1653. if (t.geoPointValue) return {
  1654. geoPointValue: Object.assign({}, t.geoPointValue)
  1655. };
  1656. if (t.timestampValue && "object" == typeof t.timestampValue) return {
  1657. timestampValue: Object.assign({}, t.timestampValue)
  1658. };
  1659. if (t.mapValue) {
  1660. var e = {
  1661. mapValue: {
  1662. fields: {}
  1663. }
  1664. };
  1665. return It(t.mapValue.fields, (function(t, n) {
  1666. return e.mapValue.fields[t] = Yt(n);
  1667. })), e;
  1668. }
  1669. if (t.arrayValue) {
  1670. for (var n = {
  1671. arrayValue: {
  1672. values: []
  1673. }
  1674. }, r = 0; r < (t.arrayValue.values || []).length; ++r) n.arrayValue.values[r] = Yt(t.arrayValue.values[r]);
  1675. return n;
  1676. }
  1677. return Object.assign({}, t);
  1678. }
  1679. var Ht = function(t, e) {
  1680. this.position = t, this.inclusive = e;
  1681. };
  1682. function Jt(t, e) {
  1683. if (null === t) return null === e;
  1684. if (null === e) return !1;
  1685. if (t.inclusive !== e.inclusive || t.position.length !== e.position.length) return !1;
  1686. for (var n = 0; n < t.position.length; n++) if (!Lt(t.position[n], e.position[n])) return !1;
  1687. return !0;
  1688. }
  1689. /**
  1690. * @license
  1691. * Copyright 2022 Google LLC
  1692. *
  1693. * Licensed under the Apache License, Version 2.0 (the "License");
  1694. * you may not use this file except in compliance with the License.
  1695. * You may obtain a copy of the License at
  1696. *
  1697. * http://www.apache.org/licenses/LICENSE-2.0
  1698. *
  1699. * Unless required by applicable law or agreed to in writing, software
  1700. * distributed under the License is distributed on an "AS IS" BASIS,
  1701. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1702. * See the License for the specific language governing permissions and
  1703. * limitations under the License.
  1704. */ var Xt = function() {}, $t = /** @class */ function(e) {
  1705. function n(t, n, r) {
  1706. var i = this;
  1707. return (i = e.call(this) || this).field = t, i.op = n, i.value = r, i;
  1708. }
  1709. /**
  1710. * Creates a filter based on the provided arguments.
  1711. */ return t(n, e), n.create = function(t, e, r) {
  1712. return t.isKeyField() ? "in" /* Operator.IN */ === e || "not-in" /* Operator.NOT_IN */ === e ? this.createKeyFieldInFilter(t, e, r) : new ee(t, e, r) : "array-contains" /* Operator.ARRAY_CONTAINS */ === e ? new oe(t, r) : "in" /* Operator.IN */ === e ? new ae(t, r) : "not-in" /* Operator.NOT_IN */ === e ? new se(t, r) : "array-contains-any" /* Operator.ARRAY_CONTAINS_ANY */ === e ? new ue(t, r) : new n(t, e, r);
  1713. }, n.createKeyFieldInFilter = function(t, e, n) {
  1714. return "in" /* Operator.IN */ === e ? new ne(t, n) : new re(t, n);
  1715. }, n.prototype.matches = function(t) {
  1716. var e = t.data.field(this.field);
  1717. // Types do not have to match in NOT_EQUAL filters.
  1718. return "!=" /* Operator.NOT_EQUAL */ === this.op ? null !== e && this.matchesComparison(Ut(e, this.value)) : null !== e && jt(this.value) === jt(e) && this.matchesComparison(Ut(e, this.value));
  1719. // Only compare types with matching backend order (such as double and int).
  1720. }, n.prototype.matchesComparison = function(t) {
  1721. switch (this.op) {
  1722. case "<" /* Operator.LESS_THAN */ :
  1723. return t < 0;
  1724. case "<=" /* Operator.LESS_THAN_OR_EQUAL */ :
  1725. return t <= 0;
  1726. case "==" /* Operator.EQUAL */ :
  1727. return 0 === t;
  1728. case "!=" /* Operator.NOT_EQUAL */ :
  1729. return 0 !== t;
  1730. case ">" /* Operator.GREATER_THAN */ :
  1731. return t > 0;
  1732. case ">=" /* Operator.GREATER_THAN_OR_EQUAL */ :
  1733. return t >= 0;
  1734. default:
  1735. return k();
  1736. }
  1737. }, n.prototype.isInequality = function() {
  1738. return [ "<" /* Operator.LESS_THAN */ , "<=" /* Operator.LESS_THAN_OR_EQUAL */ , ">" /* Operator.GREATER_THAN */ , ">=" /* Operator.GREATER_THAN_OR_EQUAL */ , "!=" /* Operator.NOT_EQUAL */ , "not-in" /* Operator.NOT_IN */ ].indexOf(this.op) >= 0;
  1739. }, n.prototype.getFlattenedFilters = function() {
  1740. return [ this ];
  1741. }, n.prototype.getFilters = function() {
  1742. return [ this ];
  1743. }, n.prototype.getFirstInequalityField = function() {
  1744. return this.isInequality() ? this.field : null;
  1745. }, n;
  1746. }(Xt), Zt = /** @class */ function(e) {
  1747. function n(t, n) {
  1748. var r = this;
  1749. return (r = e.call(this) || this).filters = t, r.op = n, r.D = null, r;
  1750. }
  1751. /**
  1752. * Creates a filter based on the provided arguments.
  1753. */ return t(n, e), n.create = function(t, e) {
  1754. return new n(t, e);
  1755. }, n.prototype.matches = function(t) {
  1756. return "and" /* CompositeOperator.AND */ === this.op ? void 0 === this.filters.find((function(e) {
  1757. return !e.matches(t);
  1758. })) : void 0 !== this.filters.find((function(e) {
  1759. return e.matches(t);
  1760. }));
  1761. }, n.prototype.getFlattenedFilters = function() {
  1762. return null !== this.D || (this.D = this.filters.reduce((function(t, e) {
  1763. return t.concat(e.getFlattenedFilters());
  1764. }), [])), this.D;
  1765. },
  1766. // Returns a mutable copy of `this.filters`
  1767. n.prototype.getFilters = function() {
  1768. return Object.assign([], this.filters);
  1769. }, n.prototype.getFirstInequalityField = function() {
  1770. var t = this.F((function(t) {
  1771. return t.isInequality();
  1772. }));
  1773. return null !== t ? t.field : null;
  1774. },
  1775. // Performs a depth-first search to find and return the first FieldFilter in the composite filter
  1776. // that satisfies the predicate. Returns `null` if none of the FieldFilters satisfy the
  1777. // predicate.
  1778. n.prototype.F = function(t) {
  1779. for (var e = 0, n = this.getFlattenedFilters(); e < n.length; e++) {
  1780. var r = n[e];
  1781. if (t(r)) return r;
  1782. }
  1783. return null;
  1784. }, n;
  1785. }(Xt);
  1786. function te(t, e) {
  1787. return t instanceof $t ? function(t, e) {
  1788. return e instanceof $t && t.op === e.op && t.field.isEqual(e.field) && Lt(t.value, e.value);
  1789. }(t, e) : t instanceof Zt ? function(t, e) {
  1790. return e instanceof Zt && t.op === e.op && t.filters.length === e.filters.length && t.filters.reduce((function(t, n, r) {
  1791. return t && te(n, e.filters[r]);
  1792. }), !0);
  1793. }(t, e) : void k();
  1794. }
  1795. var ee = /** @class */ function(e) {
  1796. function n(t, n, r) {
  1797. var i = this;
  1798. return (i = e.call(this, t, n, r) || this).key = it.fromName(r.referenceValue),
  1799. i;
  1800. }
  1801. return t(n, e), n.prototype.matches = function(t) {
  1802. var e = it.comparator(t.key, this.key);
  1803. return this.matchesComparison(e);
  1804. }, n;
  1805. }($t), ne = /** @class */ function(e) {
  1806. function n(t, n) {
  1807. var r = this;
  1808. return (r = e.call(this, t, "in" /* Operator.IN */ , n) || this).keys = ie("in" /* Operator.IN */ , n),
  1809. r;
  1810. }
  1811. return t(n, e), n.prototype.matches = function(t) {
  1812. return this.keys.some((function(e) {
  1813. return e.isEqual(t.key);
  1814. }));
  1815. }, n;
  1816. }($t), re = /** @class */ function(e) {
  1817. function n(t, n) {
  1818. var r = this;
  1819. return (r = e.call(this, t, "not-in" /* Operator.NOT_IN */ , n) || this).keys = ie("not-in" /* Operator.NOT_IN */ , n),
  1820. r;
  1821. }
  1822. return t(n, e), n.prototype.matches = function(t) {
  1823. return !this.keys.some((function(e) {
  1824. return e.isEqual(t.key);
  1825. }));
  1826. }, n;
  1827. }($t);
  1828. /** Filter that matches on key fields within an array. */ function ie(t, e) {
  1829. var n;
  1830. return ((null === (n = e.arrayValue) || void 0 === n ? void 0 : n.values) || []).map((function(t) {
  1831. return it.fromName(t.referenceValue);
  1832. }));
  1833. }
  1834. /** A Filter that implements the array-contains operator. */ var oe = /** @class */ function(e) {
  1835. function n(t, n) {
  1836. return e.call(this, t, "array-contains" /* Operator.ARRAY_CONTAINS */ , n) || this;
  1837. }
  1838. return t(n, e), n.prototype.matches = function(t) {
  1839. var e = t.data.field(this.field);
  1840. return Qt(e) && Mt(e.arrayValue, this.value);
  1841. }, n;
  1842. }($t), ae = /** @class */ function(e) {
  1843. function n(t, n) {
  1844. return e.call(this, t, "in" /* Operator.IN */ , n) || this;
  1845. }
  1846. return t(n, e), n.prototype.matches = function(t) {
  1847. var e = t.data.field(this.field);
  1848. return null !== e && Mt(this.value.arrayValue, e);
  1849. }, n;
  1850. }($t), se = /** @class */ function(e) {
  1851. function n(t, n) {
  1852. return e.call(this, t, "not-in" /* Operator.NOT_IN */ , n) || this;
  1853. }
  1854. return t(n, e), n.prototype.matches = function(t) {
  1855. if (Mt(this.value.arrayValue, {
  1856. nullValue: "NULL_VALUE"
  1857. })) return !1;
  1858. var e = t.data.field(this.field);
  1859. return null !== e && !Mt(this.value.arrayValue, e);
  1860. }, n;
  1861. }($t), ue = /** @class */ function(e) {
  1862. function n(t, n) {
  1863. return e.call(this, t, "array-contains-any" /* Operator.ARRAY_CONTAINS_ANY */ , n) || this;
  1864. }
  1865. return t(n, e), n.prototype.matches = function(t) {
  1866. var e = this, n = t.data.field(this.field);
  1867. return !(!Qt(n) || !n.arrayValue.values) && n.arrayValue.values.some((function(t) {
  1868. return Mt(e.value.arrayValue, t);
  1869. }));
  1870. }, n;
  1871. }($t), ce = function(t, e /* Direction.ASCENDING */) {
  1872. void 0 === e && (e = "asc"), this.field = t, this.dir = e;
  1873. };
  1874. /** A Filter that implements the IN operator. */ function le(t, e) {
  1875. return t.dir === e.dir && t.field.isEqual(e.field);
  1876. }
  1877. /**
  1878. * @license
  1879. * Copyright 2017 Google LLC
  1880. *
  1881. * Licensed under the Apache License, Version 2.0 (the "License");
  1882. * you may not use this file except in compliance with the License.
  1883. * You may obtain a copy of the License at
  1884. *
  1885. * http://www.apache.org/licenses/LICENSE-2.0
  1886. *
  1887. * Unless required by applicable law or agreed to in writing, software
  1888. * distributed under the License is distributed on an "AS IS" BASIS,
  1889. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  1890. * See the License for the specific language governing permissions and
  1891. * limitations under the License.
  1892. */
  1893. /**
  1894. * A version of a document in Firestore. This corresponds to the version
  1895. * timestamp, such as update_time or read_time.
  1896. */ var fe = /** @class */ function() {
  1897. function t(t) {
  1898. this.timestamp = t;
  1899. }
  1900. return t.fromTimestamp = function(e) {
  1901. return new t(e);
  1902. }, t.min = function() {
  1903. return new t(new Nt(0, 0));
  1904. }, t.max = function() {
  1905. return new t(new Nt(253402300799, 999999999));
  1906. }, t.prototype.compareTo = function(t) {
  1907. return this.timestamp._compareTo(t.timestamp);
  1908. }, t.prototype.isEqual = function(t) {
  1909. return this.timestamp.isEqual(t.timestamp);
  1910. },
  1911. /** Returns a number representation of the version for use in spec tests. */ t.prototype.toMicroseconds = function() {
  1912. // Convert to microseconds.
  1913. return 1e6 * this.timestamp.seconds + this.timestamp.nanoseconds / 1e3;
  1914. }, t.prototype.toString = function() {
  1915. return "SnapshotVersion(" + this.timestamp.toString() + ")";
  1916. }, t.prototype.toTimestamp = function() {
  1917. return this.timestamp;
  1918. }, t;
  1919. }(), he = /** @class */ function() {
  1920. function t(t, e) {
  1921. this.comparator = t, this.root = e || de.EMPTY;
  1922. }
  1923. // Returns a copy of the map, with the specified key/value added or replaced.
  1924. return t.prototype.insert = function(e, n) {
  1925. return new t(this.comparator, this.root.insert(e, n, this.comparator).copy(null, null, de.BLACK, null, null));
  1926. },
  1927. // Returns a copy of the map, with the specified key removed.
  1928. t.prototype.remove = function(e) {
  1929. return new t(this.comparator, this.root.remove(e, this.comparator).copy(null, null, de.BLACK, null, null));
  1930. },
  1931. // Returns the value of the node with the given key, or null.
  1932. t.prototype.get = function(t) {
  1933. for (var e = this.root; !e.isEmpty(); ) {
  1934. var n = this.comparator(t, e.key);
  1935. if (0 === n) return e.value;
  1936. n < 0 ? e = e.left : n > 0 && (e = e.right);
  1937. }
  1938. return null;
  1939. },
  1940. // Returns the index of the element in this sorted map, or -1 if it doesn't
  1941. // exist.
  1942. t.prototype.indexOf = function(t) {
  1943. for (
  1944. // Number of nodes that were pruned when descending right
  1945. var e = 0, n = this.root; !n.isEmpty(); ) {
  1946. var r = this.comparator(t, n.key);
  1947. if (0 === r) return e + n.left.size;
  1948. r < 0 ? n = n.left : (
  1949. // Count all nodes left of the node plus the node itself
  1950. e += n.left.size + 1, n = n.right);
  1951. }
  1952. // Node not found
  1953. return -1;
  1954. }, t.prototype.isEmpty = function() {
  1955. return this.root.isEmpty();
  1956. }, Object.defineProperty(t.prototype, "size", {
  1957. // Returns the total number of nodes in the map.
  1958. get: function() {
  1959. return this.root.size;
  1960. },
  1961. enumerable: !1,
  1962. configurable: !0
  1963. }),
  1964. // Returns the minimum key in the map.
  1965. t.prototype.minKey = function() {
  1966. return this.root.minKey();
  1967. },
  1968. // Returns the maximum key in the map.
  1969. t.prototype.maxKey = function() {
  1970. return this.root.maxKey();
  1971. },
  1972. // Traverses the map in key order and calls the specified action function
  1973. // for each key/value pair. If action returns true, traversal is aborted.
  1974. // Returns the first truthy value returned by action, or the last falsey
  1975. // value returned by action.
  1976. t.prototype.inorderTraversal = function(t) {
  1977. return this.root.inorderTraversal(t);
  1978. }, t.prototype.forEach = function(t) {
  1979. this.inorderTraversal((function(e, n) {
  1980. return t(e, n), !1;
  1981. }));
  1982. }, t.prototype.toString = function() {
  1983. var t = [];
  1984. return this.inorderTraversal((function(e, n) {
  1985. return t.push("".concat(e, ":").concat(n)), !1;
  1986. })), "{".concat(t.join(", "), "}");
  1987. },
  1988. // Traverses the map in reverse key order and calls the specified action
  1989. // function for each key/value pair. If action returns true, traversal is
  1990. // aborted.
  1991. // Returns the first truthy value returned by action, or the last falsey
  1992. // value returned by action.
  1993. t.prototype.reverseTraversal = function(t) {
  1994. return this.root.reverseTraversal(t);
  1995. },
  1996. // Returns an iterator over the SortedMap.
  1997. t.prototype.getIterator = function() {
  1998. return new pe(this.root, null, this.comparator, !1);
  1999. }, t.prototype.getIteratorFrom = function(t) {
  2000. return new pe(this.root, t, this.comparator, !1);
  2001. }, t.prototype.getReverseIterator = function() {
  2002. return new pe(this.root, null, this.comparator, !0);
  2003. }, t.prototype.getReverseIteratorFrom = function(t) {
  2004. return new pe(this.root, t, this.comparator, !0);
  2005. }, t;
  2006. }(), pe = /** @class */ function() {
  2007. function t(t, e, n, r) {
  2008. this.isReverse = r, this.nodeStack = [];
  2009. for (var i = 1; !t.isEmpty(); ) if (i = e ? n(t.key, e) : 1,
  2010. // flip the comparison if we're going in reverse
  2011. e && r && (i *= -1), i < 0)
  2012. // This node is less than our start key. ignore it
  2013. t = this.isReverse ? t.left : t.right; else {
  2014. if (0 === i) {
  2015. // This node is exactly equal to our start key. Push it on the stack,
  2016. // but stop iterating;
  2017. this.nodeStack.push(t);
  2018. break;
  2019. }
  2020. // This node is greater than our start key, add it to the stack and move
  2021. // to the next one
  2022. this.nodeStack.push(t), t = this.isReverse ? t.right : t.left;
  2023. }
  2024. }
  2025. return t.prototype.getNext = function() {
  2026. var t = this.nodeStack.pop(), e = {
  2027. key: t.key,
  2028. value: t.value
  2029. };
  2030. if (this.isReverse) for (t = t.left; !t.isEmpty(); ) this.nodeStack.push(t), t = t.right; else for (t = t.right; !t.isEmpty(); ) this.nodeStack.push(t),
  2031. t = t.left;
  2032. return e;
  2033. }, t.prototype.hasNext = function() {
  2034. return this.nodeStack.length > 0;
  2035. }, t.prototype.peek = function() {
  2036. if (0 === this.nodeStack.length) return null;
  2037. var t = this.nodeStack[this.nodeStack.length - 1];
  2038. return {
  2039. key: t.key,
  2040. value: t.value
  2041. };
  2042. }, t;
  2043. }(), de = /** @class */ function() {
  2044. function t(e, n, r, i, o) {
  2045. this.key = e, this.value = n, this.color = null != r ? r : t.RED, this.left = null != i ? i : t.EMPTY,
  2046. this.right = null != o ? o : t.EMPTY, this.size = this.left.size + 1 + this.right.size;
  2047. }
  2048. // Returns a copy of the current node, optionally replacing pieces of it.
  2049. return t.prototype.copy = function(e, n, r, i, o) {
  2050. return new t(null != e ? e : this.key, null != n ? n : this.value, null != r ? r : this.color, null != i ? i : this.left, null != o ? o : this.right);
  2051. }, t.prototype.isEmpty = function() {
  2052. return !1;
  2053. },
  2054. // Traverses the tree in key order and calls the specified action function
  2055. // for each node. If action returns true, traversal is aborted.
  2056. // Returns the first truthy value returned by action, or the last falsey
  2057. // value returned by action.
  2058. t.prototype.inorderTraversal = function(t) {
  2059. return this.left.inorderTraversal(t) || t(this.key, this.value) || this.right.inorderTraversal(t);
  2060. },
  2061. // Traverses the tree in reverse key order and calls the specified action
  2062. // function for each node. If action returns true, traversal is aborted.
  2063. // Returns the first truthy value returned by action, or the last falsey
  2064. // value returned by action.
  2065. t.prototype.reverseTraversal = function(t) {
  2066. return this.right.reverseTraversal(t) || t(this.key, this.value) || this.left.reverseTraversal(t);
  2067. },
  2068. // Returns the minimum node in the tree.
  2069. t.prototype.min = function() {
  2070. return this.left.isEmpty() ? this : this.left.min();
  2071. },
  2072. // Returns the maximum key in the tree.
  2073. t.prototype.minKey = function() {
  2074. return this.min().key;
  2075. },
  2076. // Returns the maximum key in the tree.
  2077. t.prototype.maxKey = function() {
  2078. return this.right.isEmpty() ? this.key : this.right.maxKey();
  2079. },
  2080. // Returns new tree, with the key/value added.
  2081. t.prototype.insert = function(t, e, n) {
  2082. var r = this, i = n(t, r.key);
  2083. return (r = i < 0 ? r.copy(null, null, null, r.left.insert(t, e, n), null) : 0 === i ? r.copy(null, e, null, null, null) : r.copy(null, null, null, null, r.right.insert(t, e, n))).fixUp();
  2084. }, t.prototype.removeMin = function() {
  2085. if (this.left.isEmpty()) return t.EMPTY;
  2086. var e = this;
  2087. return e.left.isRed() || e.left.left.isRed() || (e = e.moveRedLeft()), (e = e.copy(null, null, null, e.left.removeMin(), null)).fixUp();
  2088. },
  2089. // Returns new tree, with the specified item removed.
  2090. t.prototype.remove = function(e, n) {
  2091. var r, i = this;
  2092. if (n(e, i.key) < 0) i.left.isEmpty() || i.left.isRed() || i.left.left.isRed() || (i = i.moveRedLeft()),
  2093. i = i.copy(null, null, null, i.left.remove(e, n), null); else {
  2094. if (i.left.isRed() && (i = i.rotateRight()), i.right.isEmpty() || i.right.isRed() || i.right.left.isRed() || (i = i.moveRedRight()),
  2095. 0 === n(e, i.key)) {
  2096. if (i.right.isEmpty()) return t.EMPTY;
  2097. r = i.right.min(), i = i.copy(r.key, r.value, null, null, i.right.removeMin());
  2098. }
  2099. i = i.copy(null, null, null, null, i.right.remove(e, n));
  2100. }
  2101. return i.fixUp();
  2102. }, t.prototype.isRed = function() {
  2103. return this.color;
  2104. },
  2105. // Returns new tree after performing any needed rotations.
  2106. t.prototype.fixUp = function() {
  2107. var t = this;
  2108. return t.right.isRed() && !t.left.isRed() && (t = t.rotateLeft()), t.left.isRed() && t.left.left.isRed() && (t = t.rotateRight()),
  2109. t.left.isRed() && t.right.isRed() && (t = t.colorFlip()), t;
  2110. }, t.prototype.moveRedLeft = function() {
  2111. var t = this.colorFlip();
  2112. return t.right.left.isRed() && (t = (t = (t = t.copy(null, null, null, null, t.right.rotateRight())).rotateLeft()).colorFlip()),
  2113. t;
  2114. }, t.prototype.moveRedRight = function() {
  2115. var t = this.colorFlip();
  2116. return t.left.left.isRed() && (t = (t = t.rotateRight()).colorFlip()), t;
  2117. }, t.prototype.rotateLeft = function() {
  2118. var e = this.copy(null, null, t.RED, null, this.right.left);
  2119. return this.right.copy(null, null, this.color, e, null);
  2120. }, t.prototype.rotateRight = function() {
  2121. var e = this.copy(null, null, t.RED, this.left.right, null);
  2122. return this.left.copy(null, null, this.color, null, e);
  2123. }, t.prototype.colorFlip = function() {
  2124. var t = this.left.copy(null, null, !this.left.color, null, null), e = this.right.copy(null, null, !this.right.color, null, null);
  2125. return this.copy(null, null, !this.color, t, e);
  2126. },
  2127. // For testing.
  2128. t.prototype.checkMaxDepth = function() {
  2129. var t = this.check();
  2130. return Math.pow(2, t) <= this.size + 1;
  2131. },
  2132. // In a balanced RB tree, the black-depth (number of black nodes) from root to
  2133. // leaves is equal on both sides. This function verifies that or asserts.
  2134. t.prototype.check = function() {
  2135. if (this.isRed() && this.left.isRed()) throw k();
  2136. if (this.right.isRed()) throw k();
  2137. var t = this.left.check();
  2138. if (t !== this.right.check()) throw k();
  2139. return t + (this.isRed() ? 0 : 1);
  2140. }, t;
  2141. }();
  2142. /**
  2143. * @license
  2144. * Copyright 2017 Google LLC
  2145. *
  2146. * Licensed under the Apache License, Version 2.0 (the "License");
  2147. * you may not use this file except in compliance with the License.
  2148. * You may obtain a copy of the License at
  2149. *
  2150. * http://www.apache.org/licenses/LICENSE-2.0
  2151. *
  2152. * Unless required by applicable law or agreed to in writing, software
  2153. * distributed under the License is distributed on an "AS IS" BASIS,
  2154. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  2155. * See the License for the specific language governing permissions and
  2156. * limitations under the License.
  2157. */
  2158. // An immutable sorted map implementation, based on a Left-leaning Red-Black
  2159. // tree.
  2160. // end LLRBNode
  2161. // Empty node is shared between all LLRB trees.
  2162. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  2163. de.EMPTY = null, de.RED = !0, de.BLACK = !1,
  2164. // end LLRBEmptyNode
  2165. de.EMPTY = new (/** @class */ function() {
  2166. function t() {
  2167. this.size = 0;
  2168. }
  2169. return Object.defineProperty(t.prototype, "key", {
  2170. get: function() {
  2171. throw k();
  2172. },
  2173. enumerable: !1,
  2174. configurable: !0
  2175. }), Object.defineProperty(t.prototype, "value", {
  2176. get: function() {
  2177. throw k();
  2178. },
  2179. enumerable: !1,
  2180. configurable: !0
  2181. }), Object.defineProperty(t.prototype, "color", {
  2182. get: function() {
  2183. throw k();
  2184. },
  2185. enumerable: !1,
  2186. configurable: !0
  2187. }), Object.defineProperty(t.prototype, "left", {
  2188. get: function() {
  2189. throw k();
  2190. },
  2191. enumerable: !1,
  2192. configurable: !0
  2193. }), Object.defineProperty(t.prototype, "right", {
  2194. get: function() {
  2195. throw k();
  2196. },
  2197. enumerable: !1,
  2198. configurable: !0
  2199. }),
  2200. // Returns a copy of the current node.
  2201. t.prototype.copy = function(t, e, n, r, i) {
  2202. return this;
  2203. },
  2204. // Returns a copy of the tree, with the specified key/value added.
  2205. t.prototype.insert = function(t, e, n) {
  2206. return new de(t, e);
  2207. },
  2208. // Returns a copy of the tree, with the specified key removed.
  2209. t.prototype.remove = function(t, e) {
  2210. return this;
  2211. }, t.prototype.isEmpty = function() {
  2212. return !0;
  2213. }, t.prototype.inorderTraversal = function(t) {
  2214. return !1;
  2215. }, t.prototype.reverseTraversal = function(t) {
  2216. return !1;
  2217. }, t.prototype.minKey = function() {
  2218. return null;
  2219. }, t.prototype.maxKey = function() {
  2220. return null;
  2221. }, t.prototype.isRed = function() {
  2222. return !1;
  2223. },
  2224. // For testing.
  2225. t.prototype.checkMaxDepth = function() {
  2226. return !0;
  2227. }, t.prototype.check = function() {
  2228. return 0;
  2229. }, t;
  2230. }());
  2231. /**
  2232. * @license
  2233. * Copyright 2017 Google LLC
  2234. *
  2235. * Licensed under the Apache License, Version 2.0 (the "License");
  2236. * you may not use this file except in compliance with the License.
  2237. * You may obtain a copy of the License at
  2238. *
  2239. * http://www.apache.org/licenses/LICENSE-2.0
  2240. *
  2241. * Unless required by applicable law or agreed to in writing, software
  2242. * distributed under the License is distributed on an "AS IS" BASIS,
  2243. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  2244. * See the License for the specific language governing permissions and
  2245. * limitations under the License.
  2246. */
  2247. /**
  2248. * SortedSet is an immutable (copy-on-write) collection that holds elements
  2249. * in order specified by the provided comparator.
  2250. *
  2251. * NOTE: if provided comparator returns 0 for two elements, we consider them to
  2252. * be equal!
  2253. */
  2254. var ye = /** @class */ function() {
  2255. function t(t) {
  2256. this.comparator = t, this.data = new he(this.comparator);
  2257. }
  2258. return t.prototype.has = function(t) {
  2259. return null !== this.data.get(t);
  2260. }, t.prototype.first = function() {
  2261. return this.data.minKey();
  2262. }, t.prototype.last = function() {
  2263. return this.data.maxKey();
  2264. }, Object.defineProperty(t.prototype, "size", {
  2265. get: function() {
  2266. return this.data.size;
  2267. },
  2268. enumerable: !1,
  2269. configurable: !0
  2270. }), t.prototype.indexOf = function(t) {
  2271. return this.data.indexOf(t);
  2272. },
  2273. /** Iterates elements in order defined by "comparator" */ t.prototype.forEach = function(t) {
  2274. this.data.inorderTraversal((function(e, n) {
  2275. return t(e), !1;
  2276. }));
  2277. },
  2278. /** Iterates over `elem`s such that: range[0] &lt;= elem &lt; range[1]. */ t.prototype.forEachInRange = function(t, e) {
  2279. for (var n = this.data.getIteratorFrom(t[0]); n.hasNext(); ) {
  2280. var r = n.getNext();
  2281. if (this.comparator(r.key, t[1]) >= 0) return;
  2282. e(r.key);
  2283. }
  2284. },
  2285. /**
  2286. * Iterates over `elem`s such that: start &lt;= elem until false is returned.
  2287. */
  2288. t.prototype.forEachWhile = function(t, e) {
  2289. var n;
  2290. for (n = void 0 !== e ? this.data.getIteratorFrom(e) : this.data.getIterator(); n.hasNext(); ) if (!t(n.getNext().key)) return;
  2291. },
  2292. /** Finds the least element greater than or equal to `elem`. */ t.prototype.firstAfterOrEqual = function(t) {
  2293. var e = this.data.getIteratorFrom(t);
  2294. return e.hasNext() ? e.getNext().key : null;
  2295. }, t.prototype.getIterator = function() {
  2296. return new me(this.data.getIterator());
  2297. }, t.prototype.getIteratorFrom = function(t) {
  2298. return new me(this.data.getIteratorFrom(t));
  2299. },
  2300. /** Inserts or updates an element */ t.prototype.add = function(t) {
  2301. return this.copy(this.data.remove(t).insert(t, !0));
  2302. },
  2303. /** Deletes an element */ t.prototype.delete = function(t) {
  2304. return this.has(t) ? this.copy(this.data.remove(t)) : this;
  2305. }, t.prototype.isEmpty = function() {
  2306. return this.data.isEmpty();
  2307. }, t.prototype.unionWith = function(t) {
  2308. var e = this;
  2309. // Make sure `result` always refers to the larger one of the two sets.
  2310. return e.size < t.size && (e = t, t = this), t.forEach((function(t) {
  2311. e = e.add(t);
  2312. })), e;
  2313. }, t.prototype.isEqual = function(e) {
  2314. if (!(e instanceof t)) return !1;
  2315. if (this.size !== e.size) return !1;
  2316. for (var n = this.data.getIterator(), r = e.data.getIterator(); n.hasNext(); ) {
  2317. var i = n.getNext().key, o = r.getNext().key;
  2318. if (0 !== this.comparator(i, o)) return !1;
  2319. }
  2320. return !0;
  2321. }, t.prototype.toArray = function() {
  2322. var t = [];
  2323. return this.forEach((function(e) {
  2324. t.push(e);
  2325. })), t;
  2326. }, t.prototype.toString = function() {
  2327. var t = [];
  2328. return this.forEach((function(e) {
  2329. return t.push(e);
  2330. })), "SortedSet(" + t.toString() + ")";
  2331. }, t.prototype.copy = function(e) {
  2332. var n = new t(this.comparator);
  2333. return n.data = e, n;
  2334. }, t;
  2335. }(), me = /** @class */ function() {
  2336. function t(t) {
  2337. this.iter = t;
  2338. }
  2339. return t.prototype.getNext = function() {
  2340. return this.iter.getNext().key;
  2341. }, t.prototype.hasNext = function() {
  2342. return this.iter.hasNext();
  2343. }, t;
  2344. }(), ve = /** @class */ function() {
  2345. function t(t) {
  2346. this.fields = t,
  2347. // TODO(dimond): validation of FieldMask
  2348. // Sort the field mask to support `FieldMask.isEqual()` and assert below.
  2349. t.sort(rt.comparator);
  2350. }
  2351. return t.empty = function() {
  2352. return new t([]);
  2353. },
  2354. /**
  2355. * Returns a new FieldMask object that is the result of adding all the given
  2356. * fields paths to this field mask.
  2357. */
  2358. t.prototype.unionWith = function(e) {
  2359. for (var n = new ye(rt.comparator), r = 0, i = this.fields; r < i.length; r++) {
  2360. var o = i[r];
  2361. n = n.add(o);
  2362. }
  2363. for (var a = 0, s = e; a < s.length; a++) {
  2364. var u = s[a];
  2365. n = n.add(u);
  2366. }
  2367. return new t(n.toArray());
  2368. },
  2369. /**
  2370. * Verifies that `fieldPath` is included by at least one field in this field
  2371. * mask.
  2372. *
  2373. * This is an O(n) operation, where `n` is the size of the field mask.
  2374. */
  2375. t.prototype.covers = function(t) {
  2376. for (var e = 0, n = this.fields; e < n.length; e++) {
  2377. if (n[e].isPrefixOf(t)) return !0;
  2378. }
  2379. return !1;
  2380. }, t.prototype.isEqual = function(t) {
  2381. return St(this.fields, t.fields, (function(t, e) {
  2382. return t.isEqual(e);
  2383. }));
  2384. }, t;
  2385. }(), ge = /** @class */ function() {
  2386. function t(t) {
  2387. this.value = t;
  2388. }
  2389. return t.empty = function() {
  2390. return new t({
  2391. mapValue: {}
  2392. });
  2393. },
  2394. /**
  2395. * Returns the value at the given path or null.
  2396. *
  2397. * @param path - the path to search
  2398. * @returns The value at the path or null if the path is not set.
  2399. */
  2400. t.prototype.field = function(t) {
  2401. if (t.isEmpty()) return this.value;
  2402. for (var e = this.value, n = 0; n < t.length - 1; ++n) if (!Wt(e = (e.mapValue.fields || {})[t.get(n)])) return null;
  2403. return (e = (e.mapValue.fields || {})[t.lastSegment()]) || null;
  2404. },
  2405. /**
  2406. * Sets the field to the provided value.
  2407. *
  2408. * @param path - The field path to set.
  2409. * @param value - The value to set.
  2410. */
  2411. t.prototype.set = function(t, e) {
  2412. this.getFieldsMap(t.popLast())[t.lastSegment()] = Yt(e);
  2413. },
  2414. /**
  2415. * Sets the provided fields to the provided values.
  2416. *
  2417. * @param data - A map of fields to values (or null for deletes).
  2418. */
  2419. t.prototype.setAll = function(t) {
  2420. var e = this, n = rt.emptyPath(), r = {}, i = [];
  2421. t.forEach((function(t, o) {
  2422. if (!n.isImmediateParentOf(o)) {
  2423. // Insert the accumulated changes at this parent location
  2424. var a = e.getFieldsMap(n);
  2425. e.applyChanges(a, r, i), r = {}, i = [], n = o.popLast();
  2426. }
  2427. t ? r[o.lastSegment()] = Yt(t) : i.push(o.lastSegment());
  2428. }));
  2429. var o = this.getFieldsMap(n);
  2430. this.applyChanges(o, r, i);
  2431. },
  2432. /**
  2433. * Removes the field at the specified path. If there is no field at the
  2434. * specified path, nothing is changed.
  2435. *
  2436. * @param path - The field path to remove.
  2437. */
  2438. t.prototype.delete = function(t) {
  2439. var e = this.field(t.popLast());
  2440. Wt(e) && e.mapValue.fields && delete e.mapValue.fields[t.lastSegment()];
  2441. }, t.prototype.isEqual = function(t) {
  2442. return Lt(this.value, t.value);
  2443. },
  2444. /**
  2445. * Returns the map that contains the leaf element of `path`. If the parent
  2446. * entry does not yet exist, or if it is not a map, a new map will be created.
  2447. */
  2448. t.prototype.getFieldsMap = function(t) {
  2449. var e = this.value;
  2450. e.mapValue.fields || (e.mapValue = {
  2451. fields: {}
  2452. });
  2453. for (var n = 0; n < t.length; ++n) {
  2454. var r = e.mapValue.fields[t.get(n)];
  2455. Wt(r) && r.mapValue.fields || (r = {
  2456. mapValue: {
  2457. fields: {}
  2458. }
  2459. }, e.mapValue.fields[t.get(n)] = r), e = r;
  2460. }
  2461. return e.mapValue.fields;
  2462. },
  2463. /**
  2464. * Modifies `fieldsMap` by adding, replacing or deleting the specified
  2465. * entries.
  2466. */
  2467. t.prototype.applyChanges = function(t, e, n) {
  2468. It(e, (function(e, n) {
  2469. return t[e] = n;
  2470. }));
  2471. for (var r = 0, i = n; r < i.length; r++) {
  2472. var o = i[r];
  2473. delete t[o];
  2474. }
  2475. }, t.prototype.clone = function() {
  2476. return new t(Yt(this.value));
  2477. }, t;
  2478. }(), we = /** @class */ function() {
  2479. function t(t, e, n, r, i, o, a) {
  2480. this.key = t, this.documentType = e, this.version = n, this.readTime = r, this.createTime = i,
  2481. this.data = o, this.documentState = a
  2482. /**
  2483. * Creates a document with no known version or data, but which can serve as
  2484. * base document for mutations.
  2485. */;
  2486. }
  2487. return t.newInvalidDocument = function(e) {
  2488. return new t(e, 0 /* DocumentType.INVALID */ ,
  2489. /* version */ fe.min(),
  2490. /* readTime */ fe.min(),
  2491. /* createTime */ fe.min(), ge.empty(), 0 /* DocumentState.SYNCED */);
  2492. },
  2493. /**
  2494. * Creates a new document that is known to exist with the given data at the
  2495. * given version.
  2496. */
  2497. t.newFoundDocument = function(e, n, r, i) {
  2498. return new t(e, 1 /* DocumentType.FOUND_DOCUMENT */ ,
  2499. /* version */ n,
  2500. /* readTime */ fe.min(),
  2501. /* createTime */ r, i, 0 /* DocumentState.SYNCED */);
  2502. },
  2503. /** Creates a new document that is known to not exist at the given version. */ t.newNoDocument = function(e, n) {
  2504. return new t(e, 2 /* DocumentType.NO_DOCUMENT */ ,
  2505. /* version */ n,
  2506. /* readTime */ fe.min(),
  2507. /* createTime */ fe.min(), ge.empty(), 0 /* DocumentState.SYNCED */);
  2508. },
  2509. /**
  2510. * Creates a new document that is known to exist at the given version but
  2511. * whose data is not known (e.g. a document that was updated without a known
  2512. * base document).
  2513. */
  2514. t.newUnknownDocument = function(e, n) {
  2515. return new t(e, 3 /* DocumentType.UNKNOWN_DOCUMENT */ ,
  2516. /* version */ n,
  2517. /* readTime */ fe.min(),
  2518. /* createTime */ fe.min(), ge.empty(), 2 /* DocumentState.HAS_COMMITTED_MUTATIONS */);
  2519. },
  2520. /**
  2521. * Changes the document type to indicate that it exists and that its version
  2522. * and data are known.
  2523. */
  2524. t.prototype.convertToFoundDocument = function(t, e) {
  2525. // If a document is switching state from being an invalid or deleted
  2526. // document to a valid (FOUND_DOCUMENT) document, either due to receiving an
  2527. // update from Watch or due to applying a local set mutation on top
  2528. // of a deleted document, our best guess about its createTime would be the
  2529. // version at which the document transitioned to a FOUND_DOCUMENT.
  2530. return !this.createTime.isEqual(fe.min()) || 2 /* DocumentType.NO_DOCUMENT */ !== this.documentType && 0 /* DocumentType.INVALID */ !== this.documentType || (this.createTime = t),
  2531. this.version = t, this.documentType = 1 /* DocumentType.FOUND_DOCUMENT */ , this.data = e,
  2532. this.documentState = 0 /* DocumentState.SYNCED */ , this;
  2533. },
  2534. /**
  2535. * Changes the document type to indicate that it doesn't exist at the given
  2536. * version.
  2537. */
  2538. t.prototype.convertToNoDocument = function(t) {
  2539. return this.version = t, this.documentType = 2 /* DocumentType.NO_DOCUMENT */ ,
  2540. this.data = ge.empty(), this.documentState = 0 /* DocumentState.SYNCED */ , this;
  2541. },
  2542. /**
  2543. * Changes the document type to indicate that it exists at a given version but
  2544. * that its data is not known (e.g. a document that was updated without a known
  2545. * base document).
  2546. */
  2547. t.prototype.convertToUnknownDocument = function(t) {
  2548. return this.version = t, this.documentType = 3 /* DocumentType.UNKNOWN_DOCUMENT */ ,
  2549. this.data = ge.empty(), this.documentState = 2 /* DocumentState.HAS_COMMITTED_MUTATIONS */ ,
  2550. this;
  2551. }, t.prototype.setHasCommittedMutations = function() {
  2552. return this.documentState = 2 /* DocumentState.HAS_COMMITTED_MUTATIONS */ , this;
  2553. }, t.prototype.setHasLocalMutations = function() {
  2554. return this.documentState = 1 /* DocumentState.HAS_LOCAL_MUTATIONS */ , this.version = fe.min(),
  2555. this;
  2556. }, t.prototype.setReadTime = function(t) {
  2557. return this.readTime = t, this;
  2558. }, Object.defineProperty(t.prototype, "hasLocalMutations", {
  2559. get: function() {
  2560. return 1 /* DocumentState.HAS_LOCAL_MUTATIONS */ === this.documentState;
  2561. },
  2562. enumerable: !1,
  2563. configurable: !0
  2564. }), Object.defineProperty(t.prototype, "hasCommittedMutations", {
  2565. get: function() {
  2566. return 2 /* DocumentState.HAS_COMMITTED_MUTATIONS */ === this.documentState;
  2567. },
  2568. enumerable: !1,
  2569. configurable: !0
  2570. }), Object.defineProperty(t.prototype, "hasPendingWrites", {
  2571. get: function() {
  2572. return this.hasLocalMutations || this.hasCommittedMutations;
  2573. },
  2574. enumerable: !1,
  2575. configurable: !0
  2576. }), t.prototype.isValidDocument = function() {
  2577. return 0 /* DocumentType.INVALID */ !== this.documentType;
  2578. }, t.prototype.isFoundDocument = function() {
  2579. return 1 /* DocumentType.FOUND_DOCUMENT */ === this.documentType;
  2580. }, t.prototype.isNoDocument = function() {
  2581. return 2 /* DocumentType.NO_DOCUMENT */ === this.documentType;
  2582. }, t.prototype.isUnknownDocument = function() {
  2583. return 3 /* DocumentType.UNKNOWN_DOCUMENT */ === this.documentType;
  2584. }, t.prototype.isEqual = function(e) {
  2585. return e instanceof t && this.key.isEqual(e.key) && this.version.isEqual(e.version) && this.documentType === e.documentType && this.documentState === e.documentState && this.data.isEqual(e.data);
  2586. }, t.prototype.mutableCopy = function() {
  2587. return new t(this.key, this.documentType, this.version, this.readTime, this.createTime, this.data.clone(), this.documentState);
  2588. }, t.prototype.toString = function() {
  2589. return "Document(".concat(this.key, ", ").concat(this.version, ", ").concat(JSON.stringify(this.data.value), ", {createTime: ").concat(this.createTime, "}), {documentType: ").concat(this.documentType, "}), {documentState: ").concat(this.documentState, "})");
  2590. }, t;
  2591. }(), _e = function(t, e, n, r, i, o, a) {
  2592. void 0 === e && (e = null), void 0 === n && (n = []), void 0 === r && (r = []),
  2593. void 0 === i && (i = null), void 0 === o && (o = null), void 0 === a && (a = null),
  2594. this.path = t, this.collectionGroup = e, this.orderBy = n, this.filters = r, this.limit = i,
  2595. this.startAt = o, this.endAt = a, this.S = null;
  2596. };
  2597. /**
  2598. * Initializes a Target with a path and optional additional query constraints.
  2599. * Path must currently be empty if this is a collection group query.
  2600. *
  2601. * NOTE: you should always construct `Target` from `Query.toTarget` instead of
  2602. * using this factory method, because `Query` provides an implicit `orderBy`
  2603. * property.
  2604. */
  2605. function be(t, e, n, r, i, o, a) {
  2606. return void 0 === e && (e = null), void 0 === n && (n = []), void 0 === r && (r = []),
  2607. void 0 === i && (i = null), void 0 === o && (o = null), void 0 === a && (a = null),
  2608. new _e(t, e, n, r, i, o, a);
  2609. }
  2610. /**
  2611. * @license
  2612. * Copyright 2017 Google LLC
  2613. *
  2614. * Licensed under the Apache License, Version 2.0 (the "License");
  2615. * you may not use this file except in compliance with the License.
  2616. * You may obtain a copy of the License at
  2617. *
  2618. * http://www.apache.org/licenses/LICENSE-2.0
  2619. *
  2620. * Unless required by applicable law or agreed to in writing, software
  2621. * distributed under the License is distributed on an "AS IS" BASIS,
  2622. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  2623. * See the License for the specific language governing permissions and
  2624. * limitations under the License.
  2625. */
  2626. /**
  2627. * Query encapsulates all the query attributes we support in the SDK. It can
  2628. * be run against the LocalStore, as well as be converted to a `Target` to
  2629. * query the RemoteStore results.
  2630. *
  2631. * Visible for testing.
  2632. */ var Te =
  2633. /**
  2634. * Initializes a Query with a path and optional additional query constraints.
  2635. * Path must currently be empty if this is a collection group query.
  2636. */
  2637. function(t, e, n, r, i, o /* LimitType.First */ , a, s) {
  2638. void 0 === e && (e = null), void 0 === n && (n = []), void 0 === r && (r = []),
  2639. void 0 === i && (i = null), void 0 === o && (o = "F"), void 0 === a && (a = null),
  2640. void 0 === s && (s = null), this.path = t, this.collectionGroup = e, this.explicitOrderBy = n,
  2641. this.filters = r, this.limit = i, this.limitType = o, this.startAt = a, this.endAt = s,
  2642. this.q = null,
  2643. // The corresponding `Target` of this `Query` instance.
  2644. this.O = null, this.startAt, this.endAt;
  2645. };
  2646. /** Creates a new Query for a query that matches all documents at `path` */ function Ee(t) {
  2647. return t.explicitOrderBy.length > 0 ? t.explicitOrderBy[0].field : null;
  2648. }
  2649. function Se(t) {
  2650. for (var e = 0, n = t.filters; e < n.length; e++) {
  2651. var r = n[e].getFirstInequalityField();
  2652. if (null !== r) return r;
  2653. }
  2654. return null;
  2655. }
  2656. /**
  2657. * Creates a new Query for a collection group query that matches all documents
  2658. * within the provided collection group.
  2659. */
  2660. /**
  2661. * Returns whether the query matches a collection group rather than a specific
  2662. * collection.
  2663. */ function ke(t) {
  2664. return null !== t.collectionGroup;
  2665. }
  2666. /**
  2667. * Returns the implicit order by constraint that is used to execute the Query,
  2668. * which can be different from the order by constraints the user provided (e.g.
  2669. * the SDK and backend always orders by `__name__`).
  2670. */ function Ie(t) {
  2671. var e = A(t);
  2672. if (null === e.q) {
  2673. e.q = [];
  2674. var n = Se(e), r = Ee(e);
  2675. if (null !== n && null === r)
  2676. // In order to implicitly add key ordering, we must also add the
  2677. // inequality filter field for it to be a valid query.
  2678. // Note that the default inequality field and key ordering is ascending.
  2679. n.isKeyField() || e.q.push(new ce(n)), e.q.push(new ce(rt.keyField(), "asc" /* Direction.ASCENDING */)); else {
  2680. for (var i = !1, o = 0, a = e.explicitOrderBy; o < a.length; o++) {
  2681. var s = a[o];
  2682. e.q.push(s), s.field.isKeyField() && (i = !0);
  2683. }
  2684. if (!i) {
  2685. // The order of the implicit key ordering always matches the last
  2686. // explicit order by
  2687. var u = e.explicitOrderBy.length > 0 ? e.explicitOrderBy[e.explicitOrderBy.length - 1].dir : "asc" /* Direction.ASCENDING */;
  2688. e.q.push(new ce(rt.keyField(), u));
  2689. }
  2690. }
  2691. }
  2692. return e.q;
  2693. }
  2694. /**
  2695. * Converts this `Query` instance to it's corresponding `Target` representation.
  2696. */ function Ae(t) {
  2697. var e = A(t);
  2698. if (!e.O) if ("F" /* LimitType.First */ === e.limitType) e.O = be(e.path, e.collectionGroup, Ie(e), e.filters, e.limit, e.startAt, e.endAt); else {
  2699. for (
  2700. // Flip the orderBy directions since we want the last results
  2701. var n = [], r = 0, i = Ie(e); r < i.length; r++) {
  2702. var o = i[r], a = "desc" /* Direction.DESCENDING */ === o.dir ? "asc" /* Direction.ASCENDING */ : "desc" /* Direction.DESCENDING */;
  2703. n.push(new ce(o.field, a));
  2704. }
  2705. // We need to swap the cursors to match the now-flipped query ordering.
  2706. var s = e.endAt ? new Ht(e.endAt.position, e.endAt.inclusive) : null, u = e.startAt ? new Ht(e.startAt.position, e.startAt.inclusive) : null;
  2707. // Now return as a LimitType.First query.
  2708. e.O = be(e.path, e.collectionGroup, n, e.filters, e.limit, s, u);
  2709. }
  2710. return e.O;
  2711. }
  2712. function Fe(t, e) {
  2713. e.getFirstInequalityField(), Se(t);
  2714. var n = t.filters.concat([ e ]);
  2715. return new Te(t.path, t.collectionGroup, t.explicitOrderBy.slice(), n, t.limit, t.limitType, t.startAt, t.endAt);
  2716. }
  2717. /**
  2718. * @license
  2719. * Copyright 2020 Google LLC
  2720. *
  2721. * Licensed under the Apache License, Version 2.0 (the "License");
  2722. * you may not use this file except in compliance with the License.
  2723. * You may obtain a copy of the License at
  2724. *
  2725. * http://www.apache.org/licenses/LICENSE-2.0
  2726. *
  2727. * Unless required by applicable law or agreed to in writing, software
  2728. * distributed under the License is distributed on an "AS IS" BASIS,
  2729. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  2730. * See the License for the specific language governing permissions and
  2731. * limitations under the License.
  2732. */
  2733. /**
  2734. * Returns an DoubleValue for `value` that is encoded based the serializer's
  2735. * `useProto3Json` setting.
  2736. */
  2737. /**
  2738. * Returns a value for a number that's appropriate to put into a proto.
  2739. * The return value is an IntegerValue if it can safely represent the value,
  2740. * otherwise a DoubleValue is returned.
  2741. */
  2742. function Pe(t, e) {
  2743. return function(t) {
  2744. return "number" == typeof t && Number.isInteger(t) && !dt(t) && t <= Number.MAX_SAFE_INTEGER && t >= Number.MIN_SAFE_INTEGER;
  2745. }(e) ?
  2746. /**
  2747. * Returns an IntegerValue for `value`.
  2748. */
  2749. function(t) {
  2750. return {
  2751. integerValue: "" + t
  2752. };
  2753. }(e) : function(t, e) {
  2754. if (t.useProto3Json) {
  2755. if (isNaN(e)) return {
  2756. doubleValue: "NaN"
  2757. };
  2758. if (e === 1 / 0) return {
  2759. doubleValue: "Infinity"
  2760. };
  2761. if (e === -1 / 0) return {
  2762. doubleValue: "-Infinity"
  2763. };
  2764. }
  2765. return {
  2766. doubleValue: dt(e) ? "-0" : e
  2767. };
  2768. }(t, e);
  2769. }
  2770. /**
  2771. * @license
  2772. * Copyright 2018 Google LLC
  2773. *
  2774. * Licensed under the Apache License, Version 2.0 (the "License");
  2775. * you may not use this file except in compliance with the License.
  2776. * You may obtain a copy of the License at
  2777. *
  2778. * http://www.apache.org/licenses/LICENSE-2.0
  2779. *
  2780. * Unless required by applicable law or agreed to in writing, software
  2781. * distributed under the License is distributed on an "AS IS" BASIS,
  2782. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  2783. * See the License for the specific language governing permissions and
  2784. * limitations under the License.
  2785. */
  2786. /** Used to represent a field transform on a mutation. */ var Oe = function() {
  2787. // Make sure that the structural type of `TransformOperation` is unique.
  2788. // See https://github.com/microsoft/TypeScript/issues/5451
  2789. this._ = void 0;
  2790. }, Ve = /** @class */ function(e) {
  2791. function n() {
  2792. return null !== e && e.apply(this, arguments) || this;
  2793. }
  2794. return t(n, e), n;
  2795. }(Oe), De = /** @class */ function(e) {
  2796. function n(t) {
  2797. var n = this;
  2798. return (n = e.call(this) || this).elements = t, n;
  2799. }
  2800. return t(n, e), n;
  2801. }(Oe), Ne = /** @class */ function(e) {
  2802. function n(t) {
  2803. var n = this;
  2804. return (n = e.call(this) || this).elements = t, n;
  2805. }
  2806. return t(n, e), n;
  2807. }(Oe), qe = /** @class */ function(e) {
  2808. function n(t, n) {
  2809. var r = this;
  2810. return (r = e.call(this) || this).serializer = t, r.k = n, r;
  2811. }
  2812. return t(n, e), n;
  2813. }(Oe), Re = function(t, e) {
  2814. this.field = t, this.transform = e;
  2815. }, xe = /** @class */ function() {
  2816. function t(t, e) {
  2817. this.updateTime = t, this.exists = e
  2818. /** Creates a new empty Precondition. */;
  2819. }
  2820. return t.none = function() {
  2821. return new t;
  2822. },
  2823. /** Creates a new Precondition with an exists flag. */ t.exists = function(e) {
  2824. return new t(void 0, e);
  2825. },
  2826. /** Creates a new Precondition based on a version a document exists at. */ t.updateTime = function(e) {
  2827. return new t(e);
  2828. }, Object.defineProperty(t.prototype, "isNone", {
  2829. /** Returns whether this Precondition is empty. */ get: function() {
  2830. return void 0 === this.updateTime && void 0 === this.exists;
  2831. },
  2832. enumerable: !1,
  2833. configurable: !0
  2834. }), t.prototype.isEqual = function(t) {
  2835. return this.exists === t.exists && (this.updateTime ? !!t.updateTime && this.updateTime.isEqual(t.updateTime) : !t.updateTime);
  2836. }, t;
  2837. }(), Ce = function() {}, je = /** @class */ function(e) {
  2838. function n(t, n, r, i) {
  2839. void 0 === i && (i = []);
  2840. var o = this;
  2841. return (o = e.call(this) || this).key = t, o.value = n, o.precondition = r, o.fieldTransforms = i,
  2842. o.type = 0 /* MutationType.Set */ , o;
  2843. }
  2844. return t(n, e), n.prototype.getFieldMask = function() {
  2845. return null;
  2846. }, n;
  2847. }(Ce), Le = /** @class */ function(e) {
  2848. function n(t, n, r, i, o) {
  2849. void 0 === o && (o = []);
  2850. var a = this;
  2851. return (a = e.call(this) || this).key = t, a.data = n, a.fieldMask = r, a.precondition = i,
  2852. a.fieldTransforms = o, a.type = 1 /* MutationType.Patch */ , a;
  2853. }
  2854. return t(n, e), n.prototype.getFieldMask = function() {
  2855. return this.fieldMask;
  2856. }, n;
  2857. }(Ce), Me = /** @class */ function(e) {
  2858. function n(t, n) {
  2859. var r = this;
  2860. return (r = e.call(this) || this).key = t, r.precondition = n, r.type = 2 /* MutationType.Delete */ ,
  2861. r.fieldTransforms = [], r;
  2862. }
  2863. return t(n, e), n.prototype.getFieldMask = function() {
  2864. return null;
  2865. }, n;
  2866. }(Ce), Ue = /** @class */ function(e) {
  2867. function n(t, n) {
  2868. var r = this;
  2869. return (r = e.call(this) || this).key = t, r.precondition = n, r.type = 3 /* MutationType.Verify */ ,
  2870. r.fieldTransforms = [], r;
  2871. }
  2872. return t(n, e), n.prototype.getFieldMask = function() {
  2873. return null;
  2874. }, n;
  2875. }(Ce), Be = {
  2876. asc: "ASCENDING",
  2877. desc: "DESCENDING"
  2878. }, ze = {
  2879. "<": "LESS_THAN",
  2880. "<=": "LESS_THAN_OR_EQUAL",
  2881. ">": "GREATER_THAN",
  2882. ">=": "GREATER_THAN_OR_EQUAL",
  2883. "==": "EQUAL",
  2884. "!=": "NOT_EQUAL",
  2885. "array-contains": "ARRAY_CONTAINS",
  2886. in: "IN",
  2887. "not-in": "NOT_IN",
  2888. "array-contains-any": "ARRAY_CONTAINS_ANY"
  2889. }, Qe = {
  2890. and: "AND",
  2891. or: "OR"
  2892. }, Ke = function(t, e) {
  2893. this.databaseId = t, this.useProto3Json = e;
  2894. };
  2895. /** Transforms a value into a server-generated timestamp. */
  2896. /**
  2897. * Returns a value for a number (or null) that's appropriate to put into
  2898. * a google.protobuf.Int32Value proto.
  2899. * DO NOT USE THIS FOR ANYTHING ELSE.
  2900. * This method cheats. It's typed as returning "number" because that's what
  2901. * our generated proto interfaces say Int32Value must be. But GRPC actually
  2902. * expects a { value: <number> } struct.
  2903. */
  2904. /**
  2905. * Returns a value for a Date that's appropriate to put into a proto.
  2906. */
  2907. function Ge(t, e) {
  2908. return t.useProto3Json ? "".concat(new Date(1e3 * e.seconds).toISOString().replace(/\.\d*/, "").replace("Z", ""), ".").concat(("000000000" + e.nanoseconds).slice(-9), "Z") : {
  2909. seconds: "" + e.seconds,
  2910. nanos: e.nanoseconds
  2911. };
  2912. }
  2913. /**
  2914. * Returns a value for bytes that's appropriate to put in a proto.
  2915. *
  2916. * Visible for testing.
  2917. */ function We(t, e) {
  2918. return t.useProto3Json ? e.toBase64() : e.toUint8Array();
  2919. }
  2920. function Ye(t, e) {
  2921. return Ge(t, e.toTimestamp());
  2922. }
  2923. function He(t) {
  2924. return I(!!t), fe.fromTimestamp(function(t) {
  2925. var e = Ot(t);
  2926. return new Nt(e.seconds, e.nanos);
  2927. }(t));
  2928. }
  2929. function Je(t, e) {
  2930. return function(t) {
  2931. return new et([ "projects", t.projectId, "databases", t.database ]);
  2932. }(t).child("documents").child(e).canonicalString();
  2933. }
  2934. function Xe(t, e) {
  2935. return Je(t.databaseId, e.path);
  2936. }
  2937. function $e(t, e) {
  2938. var n, r = function(t) {
  2939. var e = et.fromString(t);
  2940. return I(ln(e)), e;
  2941. }(e);
  2942. if (r.get(1) !== t.databaseId.projectId) throw new B(O, "Tried to deserialize key from different project: " + r.get(1) + " vs " + t.databaseId.projectId);
  2943. if (r.get(3) !== t.databaseId.database) throw new B(O, "Tried to deserialize key from different database: " + r.get(3) + " vs " + t.databaseId.database);
  2944. return new it((I((n = r).length > 4 && "documents" === n.get(4)), n.popFirst(5)));
  2945. }
  2946. function Ze(t, e) {
  2947. return Je(t.databaseId, e);
  2948. }
  2949. function tn(t) {
  2950. return new et([ "projects", t.databaseId.projectId, "databases", t.databaseId.database ]).canonicalString();
  2951. }
  2952. function en(t, e, n) {
  2953. return {
  2954. name: Xe(t, e),
  2955. fields: n.value.mapValue.fields
  2956. };
  2957. }
  2958. function nn(t, e) {
  2959. // Dissect the path into parent, collectionId, and optional key filter.
  2960. var n = {
  2961. structuredQuery: {}
  2962. }, r = e.path;
  2963. null !== e.collectionGroup ? (n.parent = Ze(t, r), n.structuredQuery.from = [ {
  2964. collectionId: e.collectionGroup,
  2965. allDescendants: !0
  2966. } ]) : (n.parent = Ze(t, r.popLast()), n.structuredQuery.from = [ {
  2967. collectionId: r.lastSegment()
  2968. } ]);
  2969. var i = function(t) {
  2970. if (0 !== t.length) return un(Zt.create(t, "and" /* CompositeOperator.AND */));
  2971. }(e.filters);
  2972. i && (n.structuredQuery.where = i);
  2973. var o = function(t) {
  2974. if (0 !== t.length) return t.map((function(t) {
  2975. // visible for testing
  2976. return function(t) {
  2977. return {
  2978. field: sn(t.field),
  2979. direction: rn(t.dir)
  2980. };
  2981. }(t);
  2982. }));
  2983. }(e.orderBy);
  2984. o && (n.structuredQuery.orderBy = o);
  2985. var a, s = function(t, e) {
  2986. return t.useProto3Json || pt(e) ? e : {
  2987. value: e
  2988. };
  2989. }(t, e.limit);
  2990. return null !== s && (n.structuredQuery.limit = s), e.startAt && (n.structuredQuery.startAt = {
  2991. before: (a = e.startAt).inclusive,
  2992. values: a.position
  2993. }), e.endAt && (n.structuredQuery.endAt = function(t) {
  2994. return {
  2995. before: !t.inclusive,
  2996. values: t.position
  2997. };
  2998. }(e.endAt)), n;
  2999. }
  3000. function rn(t) {
  3001. return Be[t];
  3002. }
  3003. // visible for testing
  3004. function on(t) {
  3005. return ze[t];
  3006. }
  3007. function an(t) {
  3008. return Qe[t];
  3009. }
  3010. function sn(t) {
  3011. return {
  3012. fieldPath: t.canonicalString()
  3013. };
  3014. }
  3015. function un(t) {
  3016. return t instanceof $t ? function(t) {
  3017. if ("==" /* Operator.EQUAL */ === t.op) {
  3018. if (Gt(t.value)) return {
  3019. unaryFilter: {
  3020. field: sn(t.field),
  3021. op: "IS_NAN"
  3022. }
  3023. };
  3024. if (Kt(t.value)) return {
  3025. unaryFilter: {
  3026. field: sn(t.field),
  3027. op: "IS_NULL"
  3028. }
  3029. };
  3030. } else if ("!=" /* Operator.NOT_EQUAL */ === t.op) {
  3031. if (Gt(t.value)) return {
  3032. unaryFilter: {
  3033. field: sn(t.field),
  3034. op: "IS_NOT_NAN"
  3035. }
  3036. };
  3037. if (Kt(t.value)) return {
  3038. unaryFilter: {
  3039. field: sn(t.field),
  3040. op: "IS_NOT_NULL"
  3041. }
  3042. };
  3043. }
  3044. return {
  3045. fieldFilter: {
  3046. field: sn(t.field),
  3047. op: on(t.op),
  3048. value: t.value
  3049. }
  3050. };
  3051. }(t) : t instanceof Zt ? function(t) {
  3052. var e = t.getFilters().map((function(t) {
  3053. return un(t);
  3054. }));
  3055. return 1 === e.length ? e[0] : {
  3056. compositeFilter: {
  3057. op: an(t.op),
  3058. filters: e
  3059. }
  3060. };
  3061. }(t) : k();
  3062. }
  3063. function cn(t) {
  3064. var e = [];
  3065. return t.fields.forEach((function(t) {
  3066. return e.push(t.canonicalString());
  3067. })), {
  3068. fieldPaths: e
  3069. };
  3070. }
  3071. function ln(t) {
  3072. // Resource names have at least 4 components (project ID, database ID)
  3073. return t.length >= 4 && "projects" === t.get(0) && "databases" === t.get(2);
  3074. }
  3075. /**
  3076. * @license
  3077. * Copyright 2020 Google LLC
  3078. *
  3079. * Licensed under the Apache License, Version 2.0 (the "License");
  3080. * you may not use this file except in compliance with the License.
  3081. * You may obtain a copy of the License at
  3082. *
  3083. * http://www.apache.org/licenses/LICENSE-2.0
  3084. *
  3085. * Unless required by applicable law or agreed to in writing, software
  3086. * distributed under the License is distributed on an "AS IS" BASIS,
  3087. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  3088. * See the License for the specific language governing permissions and
  3089. * limitations under the License.
  3090. */ function fn(t) {
  3091. return new Ke(t, /* useProto3Json= */ !0);
  3092. }
  3093. /**
  3094. * @license
  3095. * Copyright 2017 Google LLC
  3096. *
  3097. * Licensed under the Apache License, Version 2.0 (the "License");
  3098. * you may not use this file except in compliance with the License.
  3099. * You may obtain a copy of the License at
  3100. *
  3101. * http://www.apache.org/licenses/LICENSE-2.0
  3102. *
  3103. * Unless required by applicable law or agreed to in writing, software
  3104. * distributed under the License is distributed on an "AS IS" BASIS,
  3105. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  3106. * See the License for the specific language governing permissions and
  3107. * limitations under the License.
  3108. */
  3109. /**
  3110. * A helper for running delayed tasks following an exponential backoff curve
  3111. * between attempts.
  3112. *
  3113. * Each delay is made up of a "base" delay which follows the exponential
  3114. * backoff curve, and a +/- 50% "jitter" that is calculated and added to the
  3115. * base delay. This prevents clients from accidentally synchronizing their
  3116. * delays causing spikes of load to the backend.
  3117. */ var hn = /** @class */ function() {
  3118. function t(
  3119. /**
  3120. * The AsyncQueue to run backoff operations on.
  3121. */
  3122. t,
  3123. /**
  3124. * The ID to use when scheduling backoff operations on the AsyncQueue.
  3125. */
  3126. e,
  3127. /**
  3128. * The initial delay (used as the base delay on the first retry attempt).
  3129. * Note that jitter will still be applied, so the actual delay could be as
  3130. * little as 0.5*initialDelayMs.
  3131. */
  3132. n
  3133. /**
  3134. * The multiplier to use to determine the extended base delay after each
  3135. * attempt.
  3136. */ , r
  3137. /**
  3138. * The maximum base delay after which no further backoff is performed.
  3139. * Note that jitter will still be applied, so the actual delay could be as
  3140. * much as 1.5*maxDelayMs.
  3141. */ , i) {
  3142. void 0 === n && (n = 1e3), void 0 === r && (r = 1.5), void 0 === i && (i = 6e4),
  3143. this.C = t, this.timerId = e, this.M = n, this.L = r, this.U = i, this.j = 0, this.B = null,
  3144. /** The last backoff attempt, as epoch milliseconds. */
  3145. this.W = Date.now(), this.reset();
  3146. }
  3147. /**
  3148. * Resets the backoff delay.
  3149. *
  3150. * The very next backoffAndWait() will have no delay. If it is called again
  3151. * (i.e. due to an error), initialDelayMs (plus jitter) will be used, and
  3152. * subsequent ones will increase according to the backoffFactor.
  3153. */ return t.prototype.reset = function() {
  3154. this.j = 0;
  3155. },
  3156. /**
  3157. * Resets the backoff delay to the maximum delay (e.g. for use after a
  3158. * RESOURCE_EXHAUSTED error).
  3159. */
  3160. t.prototype.G = function() {
  3161. this.j = this.U;
  3162. },
  3163. /**
  3164. * Returns a promise that resolves after currentDelayMs, and increases the
  3165. * delay for any subsequent attempts. If there was a pending backoff operation
  3166. * already, it will be canceled.
  3167. */
  3168. t.prototype.K = function(t) {
  3169. var e = this;
  3170. // Cancel any pending backoff operation.
  3171. this.cancel();
  3172. // First schedule using the current base (which may be 0 and should be
  3173. // honored as such).
  3174. var n = Math.floor(this.j + this.Y()), r = Math.max(0, Date.now() - this.W), i = Math.max(0, n - r);
  3175. // Guard against lastAttemptTime being in the future due to a clock change.
  3176. i > 0 && b("ExponentialBackoff", "Backing off for ".concat(i, " ms (base delay: ").concat(this.j, " ms, delay with jitter: ").concat(n, " ms, last attempt: ").concat(r, " ms ago)")),
  3177. this.B = this.C.enqueueAfterDelay(this.timerId, i, (function() {
  3178. return e.W = Date.now(), t();
  3179. })),
  3180. // Apply backoff factor to determine next delay and ensure it is within
  3181. // bounds.
  3182. this.j *= this.L, this.j < this.M && (this.j = this.M), this.j > this.U && (this.j = this.U);
  3183. }, t.prototype.H = function() {
  3184. null !== this.B && (this.B.skipDelay(), this.B = null);
  3185. }, t.prototype.cancel = function() {
  3186. null !== this.B && (this.B.cancel(), this.B = null);
  3187. },
  3188. /** Returns a random value in the range [-currentBaseMs/2, currentBaseMs/2] */ t.prototype.Y = function() {
  3189. return (Math.random() - .5) * this.j;
  3190. }, t;
  3191. }(), pn = /** @class */ function(e) {
  3192. function n(t, n, r, i) {
  3193. var o = this;
  3194. return (o = e.call(this) || this).authCredentials = t, o.appCheckCredentials = n,
  3195. o.connection = r, o.serializer = i, o.J = !1, o;
  3196. }
  3197. return t(n, e), n.prototype.X = function() {
  3198. if (this.J) throw new B(x, "The client has already been terminated.");
  3199. },
  3200. /** Invokes the provided RPC with auth and AppCheck tokens. */ n.prototype.v = function(t, e, n) {
  3201. var r = this;
  3202. return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((function(i) {
  3203. var o = i[0], a = i[1];
  3204. return r.connection.v(t, e, n, o, a);
  3205. })).catch((function(t) {
  3206. throw "FirebaseError" === t.name ? (t.code === q && (r.authCredentials.invalidateToken(),
  3207. r.appCheckCredentials.invalidateToken()), t) : new B(P, t.toString());
  3208. }));
  3209. },
  3210. /** Invokes the provided RPC with streamed results with auth and AppCheck tokens. */ n.prototype.R = function(t, e, n, r) {
  3211. var i = this;
  3212. return this.X(), Promise.all([ this.authCredentials.getToken(), this.appCheckCredentials.getToken() ]).then((function(o) {
  3213. var a = o[0], s = o[1];
  3214. return i.connection.R(t, e, n, a, s, r);
  3215. })).catch((function(t) {
  3216. throw "FirebaseError" === t.name ? (t.code === q && (i.authCredentials.invalidateToken(),
  3217. i.appCheckCredentials.invalidateToken()), t) : new B(P, t.toString());
  3218. }));
  3219. }, n.prototype.terminate = function() {
  3220. this.J = !0;
  3221. }, n;
  3222. }((function() {}));
  3223. /**
  3224. * @license
  3225. * Copyright 2017 Google LLC
  3226. *
  3227. * Licensed under the Apache License, Version 2.0 (the "License");
  3228. * you may not use this file except in compliance with the License.
  3229. * You may obtain a copy of the License at
  3230. *
  3231. * http://www.apache.org/licenses/LICENSE-2.0
  3232. *
  3233. * Unless required by applicable law or agreed to in writing, software
  3234. * distributed under the License is distributed on an "AS IS" BASIS,
  3235. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  3236. * See the License for the specific language governing permissions and
  3237. * limitations under the License.
  3238. */
  3239. /**
  3240. * Datastore and its related methods are a wrapper around the external Google
  3241. * Cloud Datastore grpc API, which provides an interface that is more convenient
  3242. * for the rest of the client SDK architecture to consume.
  3243. */
  3244. /**
  3245. * An implementation of Datastore that exposes additional state for internal
  3246. * consumption.
  3247. */
  3248. // TODO(firestorexp): Make sure there is only one Datastore instance per
  3249. // firestore-exp client.
  3250. function dn(t, r) {
  3251. return e(this, void 0, void 0, (function() {
  3252. var e, i, o;
  3253. return n(this, (function(n) {
  3254. switch (n.label) {
  3255. case 0:
  3256. return e = A(t), i = tn(e.serializer) + "/documents", o = {
  3257. writes: r.map((function(t) {
  3258. return function(t, e) {
  3259. var n;
  3260. if (e instanceof je) n = {
  3261. update: en(t, e.key, e.value)
  3262. }; else if (e instanceof Me) n = {
  3263. delete: Xe(t, e.key)
  3264. }; else if (e instanceof Le) n = {
  3265. update: en(t, e.key, e.data),
  3266. updateMask: cn(e.fieldMask)
  3267. }; else {
  3268. if (!(e instanceof Ue)) return k();
  3269. n = {
  3270. verify: Xe(t, e.key)
  3271. };
  3272. }
  3273. return e.fieldTransforms.length > 0 && (n.updateTransforms = e.fieldTransforms.map((function(t) {
  3274. return function(t, e) {
  3275. var n = e.transform;
  3276. if (n instanceof Ve) return {
  3277. fieldPath: e.field.canonicalString(),
  3278. setToServerValue: "REQUEST_TIME"
  3279. };
  3280. if (n instanceof De) return {
  3281. fieldPath: e.field.canonicalString(),
  3282. appendMissingElements: {
  3283. values: n.elements
  3284. }
  3285. };
  3286. if (n instanceof Ne) return {
  3287. fieldPath: e.field.canonicalString(),
  3288. removeAllFromArray: {
  3289. values: n.elements
  3290. }
  3291. };
  3292. if (n instanceof qe) return {
  3293. fieldPath: e.field.canonicalString(),
  3294. increment: n.k
  3295. };
  3296. throw k();
  3297. }(0, t);
  3298. }))), e.precondition.isNone || (n.currentDocument = function(t, e) {
  3299. return void 0 !== e.updateTime ? {
  3300. updateTime: Ye(t, e.updateTime)
  3301. } : void 0 !== e.exists ? {
  3302. exists: e.exists
  3303. } : k();
  3304. }(t, e.precondition)), n;
  3305. }(e.serializer, t);
  3306. }))
  3307. }, [ 4 /*yield*/ , e.v("Commit", i, o) ];
  3308. case 1:
  3309. return n.sent(), [ 2 /*return*/ ];
  3310. }
  3311. }));
  3312. }));
  3313. }
  3314. function yn(t, r) {
  3315. return e(this, void 0, void 0, (function() {
  3316. var e, i, o, a, s, u;
  3317. return n(this, (function(n) {
  3318. switch (n.label) {
  3319. case 0:
  3320. return e = A(t), i = tn(e.serializer) + "/documents", o = {
  3321. documents: r.map((function(t) {
  3322. return Xe(e.serializer, t);
  3323. }))
  3324. }, [ 4 /*yield*/ , e.R("BatchGetDocuments", i, o, r.length) ];
  3325. case 1:
  3326. return a = n.sent(), s = new Map, a.forEach((function(t) {
  3327. var n = function(t, e) {
  3328. return "found" in e ? function(t, e) {
  3329. I(!!e.found), e.found.name, e.found.updateTime;
  3330. var n = $e(t, e.found.name), r = He(e.found.updateTime), i = e.found.createTime ? He(e.found.createTime) : fe.min(), o = new ge({
  3331. mapValue: {
  3332. fields: e.found.fields
  3333. }
  3334. });
  3335. return we.newFoundDocument(n, r, i, o);
  3336. }(t, e) : "missing" in e ? function(t, e) {
  3337. I(!!e.missing), I(!!e.readTime);
  3338. var n = $e(t, e.missing), r = He(e.readTime);
  3339. return we.newNoDocument(n, r);
  3340. }(t, e) : k();
  3341. }(e.serializer, t);
  3342. s.set(n.key.toString(), n);
  3343. })), u = [], [ 2 /*return*/ , (r.forEach((function(t) {
  3344. var e = s.get(t.toString());
  3345. I(!!e), u.push(e);
  3346. })), u) ];
  3347. }
  3348. }));
  3349. }));
  3350. }
  3351. /**
  3352. * @license
  3353. * Copyright 2020 Google LLC
  3354. *
  3355. * Licensed under the Apache License, Version 2.0 (the "License");
  3356. * you may not use this file except in compliance with the License.
  3357. * You may obtain a copy of the License at
  3358. *
  3359. * http://www.apache.org/licenses/LICENSE-2.0
  3360. *
  3361. * Unless required by applicable law or agreed to in writing, software
  3362. * distributed under the License is distributed on an "AS IS" BASIS,
  3363. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  3364. * See the License for the specific language governing permissions and
  3365. * limitations under the License.
  3366. */
  3367. var mn = new Map;
  3368. /**
  3369. * An instance map that ensures only one Datastore exists per Firestore
  3370. * instance.
  3371. */
  3372. /**
  3373. * Returns an initialized and started Datastore for the given Firestore
  3374. * instance. Callers must invoke removeComponents() when the Firestore
  3375. * instance is terminated.
  3376. */ function vn(t) {
  3377. if (t._terminated) throw new B(x, "The client has already been terminated.");
  3378. if (!mn.has(t)) {
  3379. b("ComponentProvider", "Initializing Datastore");
  3380. var e = function(t) {
  3381. return new wt(t, fetch.bind(null));
  3382. }((i = t._databaseId, o = t.app.options.appId || "", a = t._persistenceKey, s = t._freezeSettings(),
  3383. new $(i, o, a, s.host, s.ssl, s.experimentalForceLongPolling, s.experimentalAutoDetectLongPolling, ft(s.experimentalLongPollingOptions), s.useFetchStreams))), n = fn(t._databaseId), r = function(t, e, n, r) {
  3384. return new pn(t, e, n, r);
  3385. }(t._authCredentials, t._appCheckCredentials, e, n);
  3386. mn.set(t, r);
  3387. }
  3388. var i, o, a, s;
  3389. /**
  3390. * @license
  3391. * Copyright 2018 Google LLC
  3392. *
  3393. * Licensed under the Apache License, Version 2.0 (the "License");
  3394. * you may not use this file except in compliance with the License.
  3395. * You may obtain a copy of the License at
  3396. *
  3397. * http://www.apache.org/licenses/LICENSE-2.0
  3398. *
  3399. * Unless required by applicable law or agreed to in writing, software
  3400. * distributed under the License is distributed on an "AS IS" BASIS,
  3401. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  3402. * See the License for the specific language governing permissions and
  3403. * limitations under the License.
  3404. */ return mn.get(t);
  3405. }
  3406. /**
  3407. * Removes all components associated with the provided instance. Must be called
  3408. * when the `Firestore` instance is terminated.
  3409. */
  3410. /**
  3411. * A concrete type describing all the values that can be applied via a
  3412. * user-supplied `FirestoreSettings` object. This is a separate type so that
  3413. * defaults can be supplied and the value can be checked for equality.
  3414. */ var gn = /** @class */ function() {
  3415. function t(t) {
  3416. var e, n;
  3417. if (void 0 === t.host) {
  3418. if (void 0 !== t.ssl) throw new B(O, "Can't provide ssl option if host option is not set");
  3419. this.host = "firestore.googleapis.com", this.ssl = !0;
  3420. } else this.host = t.host, this.ssl = null === (e = t.ssl) || void 0 === e || e;
  3421. if (this.credentials = t.credentials, this.ignoreUndefinedProperties = !!t.ignoreUndefinedProperties,
  3422. this.cache = t.localCache, void 0 === t.cacheSizeBytes) this.cacheSizeBytes = 41943040; else {
  3423. if (-1 !== t.cacheSizeBytes && t.cacheSizeBytes < 1048576) throw new B(O, "cacheSizeBytes must be at least 1048576");
  3424. this.cacheSizeBytes = t.cacheSizeBytes;
  3425. }
  3426. !function(t, e, n, r) {
  3427. if (!0 === e && !0 === r) throw new B(O, "".concat("experimentalForceLongPolling", " and ").concat("experimentalAutoDetectLongPolling", " cannot be used together."));
  3428. }(0, t.experimentalForceLongPolling, 0, t.experimentalAutoDetectLongPolling), this.experimentalForceLongPolling = !!t.experimentalForceLongPolling,
  3429. this.experimentalForceLongPolling ? this.experimentalAutoDetectLongPolling = !1 : void 0 === t.experimentalAutoDetectLongPolling ? this.experimentalAutoDetectLongPolling = !0 :
  3430. // For backwards compatibility, coerce the value to boolean even though
  3431. // the TypeScript compiler has narrowed the type to boolean already.
  3432. // noinspection PointlessBooleanExpressionJS
  3433. this.experimentalAutoDetectLongPolling = !!t.experimentalAutoDetectLongPolling,
  3434. this.experimentalLongPollingOptions = ft(null !== (n = t.experimentalLongPollingOptions) && void 0 !== n ? n : {}),
  3435. function(t) {
  3436. if (void 0 !== t.timeoutSeconds) {
  3437. if (isNaN(t.timeoutSeconds)) throw new B(O, "invalid long polling timeout: ".concat(t.timeoutSeconds, " (must not be NaN)"));
  3438. if (t.timeoutSeconds < 5) throw new B(O, "invalid long polling timeout: ".concat(t.timeoutSeconds, " (minimum allowed value is 5)"));
  3439. if (t.timeoutSeconds > 30) throw new B(O, "invalid long polling timeout: ".concat(t.timeoutSeconds, " (maximum allowed value is 30)"));
  3440. }
  3441. }(this.experimentalLongPollingOptions), this.useFetchStreams = !!t.useFetchStreams;
  3442. }
  3443. return t.prototype.isEqual = function(t) {
  3444. return this.host === t.host && this.ssl === t.ssl && this.credentials === t.credentials && this.cacheSizeBytes === t.cacheSizeBytes && this.experimentalForceLongPolling === t.experimentalForceLongPolling && this.experimentalAutoDetectLongPolling === t.experimentalAutoDetectLongPolling && (e = this.experimentalLongPollingOptions,
  3445. n = t.experimentalLongPollingOptions, e.timeoutSeconds === n.timeoutSeconds) && this.ignoreUndefinedProperties === t.ignoreUndefinedProperties && this.useFetchStreams === t.useFetchStreams;
  3446. var e, n;
  3447. }, t;
  3448. }(), wn = /** @class */ function() {
  3449. /** @hideconstructor */
  3450. function t(t, e, n, r) {
  3451. this._authCredentials = t, this._appCheckCredentials = e, this._databaseId = n,
  3452. this._app = r,
  3453. /**
  3454. * Whether it's a Firestore or Firestore Lite instance.
  3455. */
  3456. this.type = "firestore-lite", this._persistenceKey = "(lite)", this._settings = new gn({}),
  3457. this._settingsFrozen = !1;
  3458. }
  3459. return Object.defineProperty(t.prototype, "app", {
  3460. /**
  3461. * The {@link @firebase/app#FirebaseApp} associated with this `Firestore` service
  3462. * instance.
  3463. */
  3464. get: function() {
  3465. if (!this._app) throw new B(x, "Firestore was not initialized using the Firebase SDK. 'app' is not available");
  3466. return this._app;
  3467. },
  3468. enumerable: !1,
  3469. configurable: !0
  3470. }), Object.defineProperty(t.prototype, "_initialized", {
  3471. get: function() {
  3472. return this._settingsFrozen;
  3473. },
  3474. enumerable: !1,
  3475. configurable: !0
  3476. }), Object.defineProperty(t.prototype, "_terminated", {
  3477. get: function() {
  3478. return void 0 !== this._terminateTask;
  3479. },
  3480. enumerable: !1,
  3481. configurable: !0
  3482. }), t.prototype._setSettings = function(t) {
  3483. if (this._settingsFrozen) throw new B(x, "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.");
  3484. this._settings = new gn(t), void 0 !== t.credentials && (this._authCredentials = function(t) {
  3485. if (!t) return new K;
  3486. switch (t.type) {
  3487. case "firstParty":
  3488. return new H(t.sessionIndex || "0", t.iamToken || null, t.authTokenFactory || null);
  3489. case "provider":
  3490. return t.client;
  3491. default:
  3492. throw new B(O, "makeAuthCredentialsProvider failed due to invalid credential type");
  3493. }
  3494. }(t.credentials));
  3495. }, t.prototype._getSettings = function() {
  3496. return this._settings;
  3497. }, t.prototype._freezeSettings = function() {
  3498. return this._settingsFrozen = !0, this._settings;
  3499. }, t.prototype._delete = function() {
  3500. return this._terminateTask || (this._terminateTask = this._terminate()), this._terminateTask;
  3501. },
  3502. /** Returns a JSON-serializable representation of this `Firestore` instance. */ t.prototype.toJSON = function() {
  3503. return {
  3504. app: this._app,
  3505. databaseId: this._databaseId,
  3506. settings: this._settings
  3507. };
  3508. },
  3509. /**
  3510. * Terminates all components used by this client. Subclasses can override
  3511. * this method to clean up their own dependencies, but must also call this
  3512. * method.
  3513. *
  3514. * Only ever called once.
  3515. */
  3516. t.prototype._terminate = function() {
  3517. return t = this, (e = mn.get(t)) && (b("ComponentProvider", "Removing Datastore"),
  3518. mn.delete(t), e.terminate()), Promise.resolve();
  3519. var t, e;
  3520. }, t;
  3521. }();
  3522. function _n(t, e, n) {
  3523. n || (n = "(default)");
  3524. var r = _getProvider(t, "firestore/lite");
  3525. if (r.isInitialized(n)) throw new B(x, "Firestore can only be initialized once per app.");
  3526. return r.initialize({
  3527. options: e,
  3528. instanceIdentifier: n
  3529. });
  3530. }
  3531. function bn(t, e) {
  3532. var n = "object" == typeof t ? t : s(), i = "string" == typeof t ? t : e || "(default)", o = _getProvider(n, "firestore/lite").getImmediate({
  3533. identifier: i
  3534. });
  3535. if (!o._initialized) {
  3536. var a = d("firestore");
  3537. a && Tn.apply(void 0, r([ o ], a, !1));
  3538. }
  3539. return o;
  3540. }
  3541. /**
  3542. * Modify this instance to communicate with the Cloud Firestore emulator.
  3543. *
  3544. * Note: This must be called before this instance has been used to do any
  3545. * operations.
  3546. *
  3547. * @param firestore - The `Firestore` instance to configure to connect to the
  3548. * emulator.
  3549. * @param host - the emulator host (ex: localhost).
  3550. * @param port - the emulator port (ex: 9000).
  3551. * @param options.mockUserToken - the mock auth token to use for unit testing
  3552. * Security Rules.
  3553. */ function Tn(t, e, n, r) {
  3554. var i;
  3555. void 0 === r && (r = {});
  3556. var o = (t = ct(t, wn))._getSettings(), a = "".concat(e, ":").concat(n);
  3557. if ("firestore.googleapis.com" !== o.host && o.host !== a && E("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),
  3558. t._setSettings(Object.assign(Object.assign({}, o), {
  3559. host: a,
  3560. ssl: !1
  3561. })), r.mockUserToken) {
  3562. var s, u;
  3563. if ("string" == typeof r.mockUserToken) s = r.mockUserToken, u = v.MOCK_USER; else {
  3564. // Let createMockUserToken validate first (catches common mistakes like
  3565. // invalid field "uid" and missing field "sub" / "user_id".)
  3566. s = y(r.mockUserToken, null === (i = t._app) || void 0 === i ? void 0 : i.options.projectId);
  3567. var c = r.mockUserToken.sub || r.mockUserToken.user_id;
  3568. if (!c) throw new B(O, "mockUserToken must contain 'sub' or 'user_id' field!");
  3569. u = new v(c);
  3570. }
  3571. t._authCredentials = new G(new Q(s, u));
  3572. }
  3573. }
  3574. /**
  3575. * Terminates the provided `Firestore` instance.
  3576. *
  3577. * After calling `terminate()` only the `clearIndexedDbPersistence()` functions
  3578. * may be used. Any other function will throw a `FirestoreError`. Termination
  3579. * does not cancel any pending writes, and any promises that are awaiting a
  3580. * response from the server will not be resolved.
  3581. *
  3582. * To restart after termination, create a new instance of `Firestore` with
  3583. * {@link (getFirestore:1)}.
  3584. *
  3585. * Note: Under normal circumstances, calling `terminate()` is not required. This
  3586. * function is useful only when you want to force this instance to release all of
  3587. * its resources or in combination with {@link clearIndexedDbPersistence} to
  3588. * ensure that all local state is destroyed between test runs.
  3589. *
  3590. * @param firestore - The `Firestore` instance to terminate.
  3591. * @returns A `Promise` that is resolved when the instance has been successfully
  3592. * terminated.
  3593. */ function En(t) {
  3594. return t = ct(t, wn), u(t.app, "firestore/lite"), t._delete();
  3595. }
  3596. /**
  3597. * @license
  3598. * Copyright 2020 Google LLC
  3599. *
  3600. * Licensed under the Apache License, Version 2.0 (the "License");
  3601. * you may not use this file except in compliance with the License.
  3602. * You may obtain a copy of the License at
  3603. *
  3604. * http://www.apache.org/licenses/LICENSE-2.0
  3605. *
  3606. * Unless required by applicable law or agreed to in writing, software
  3607. * distributed under the License is distributed on an "AS IS" BASIS,
  3608. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  3609. * See the License for the specific language governing permissions and
  3610. * limitations under the License.
  3611. */
  3612. /**
  3613. * @license
  3614. * Copyright 2022 Google LLC
  3615. *
  3616. * Licensed under the Apache License, Version 2.0 (the "License");
  3617. * you may not use this file except in compliance with the License.
  3618. * You may obtain a copy of the License at
  3619. *
  3620. * http://www.apache.org/licenses/LICENSE-2.0
  3621. *
  3622. * Unless required by applicable law or agreed to in writing, software
  3623. * distributed under the License is distributed on an "AS IS" BASIS,
  3624. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  3625. * See the License for the specific language governing permissions and
  3626. * limitations under the License.
  3627. */
  3628. /**
  3629. * Represents an aggregation that can be performed by Firestore.
  3630. */
  3631. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  3632. var Sn =
  3633. /**
  3634. * Create a new AggregateField<T>
  3635. * @param _aggregateType Specifies the type of aggregation operation to perform.
  3636. * @param _internalFieldPath Optionally specifies the field that is aggregated.
  3637. * @internal
  3638. */
  3639. function(
  3640. // TODO (sum/avg) make aggregateType public when the feature is supported
  3641. t, e) {
  3642. void 0 === t && (t = "count"), this._aggregateType = t, this._internalFieldPath = e,
  3643. /** A type string to uniquely identify instances of this class. */
  3644. this.type = "AggregateField";
  3645. }, kn = /** @class */ function() {
  3646. /** @hideconstructor */
  3647. function t(t, e, n) {
  3648. this._userDataWriter = e, this._data = n,
  3649. /** A type string to uniquely identify instances of this class. */
  3650. this.type = "AggregateQuerySnapshot", this.query = t
  3651. /**
  3652. * Returns the results of the aggregations performed over the underlying
  3653. * query.
  3654. *
  3655. * The keys of the returned object will be the same as those of the
  3656. * `AggregateSpec` object specified to the aggregation method, and the values
  3657. * will be the corresponding aggregation result.
  3658. *
  3659. * @returns The results of the aggregations performed over the underlying
  3660. * query.
  3661. */;
  3662. }
  3663. return t.prototype.data = function() {
  3664. return this._userDataWriter.convertObjectMap(this._data);
  3665. }, t;
  3666. }(), In = /** @class */ function() {
  3667. /** @hideconstructor */
  3668. function t(t,
  3669. /**
  3670. * If provided, the `FirestoreDataConverter` associated with this instance.
  3671. */
  3672. e, n) {
  3673. this.converter = e, this._key = n,
  3674. /** The type of this Firestore reference. */
  3675. this.type = "document", this.firestore = t;
  3676. }
  3677. return Object.defineProperty(t.prototype, "_path", {
  3678. get: function() {
  3679. return this._key.path;
  3680. },
  3681. enumerable: !1,
  3682. configurable: !0
  3683. }), Object.defineProperty(t.prototype, "id", {
  3684. /**
  3685. * The document's identifier within its collection.
  3686. */
  3687. get: function() {
  3688. return this._key.path.lastSegment();
  3689. },
  3690. enumerable: !1,
  3691. configurable: !0
  3692. }), Object.defineProperty(t.prototype, "path", {
  3693. /**
  3694. * A string representing the path of the referenced document (relative
  3695. * to the root of the database).
  3696. */
  3697. get: function() {
  3698. return this._key.path.canonicalString();
  3699. },
  3700. enumerable: !1,
  3701. configurable: !0
  3702. }), Object.defineProperty(t.prototype, "parent", {
  3703. /**
  3704. * The collection this `DocumentReference` belongs to.
  3705. */
  3706. get: function() {
  3707. return new Fn(this.firestore, this.converter, this._key.path.popLast());
  3708. },
  3709. enumerable: !1,
  3710. configurable: !0
  3711. }), t.prototype.withConverter = function(e) {
  3712. return new t(this.firestore, e, this._key);
  3713. }, t;
  3714. }(), An = /** @class */ function() {
  3715. // This is the lite version of the Query class in the main SDK.
  3716. /** @hideconstructor protected */
  3717. function t(t,
  3718. /**
  3719. * If provided, the `FirestoreDataConverter` associated with this instance.
  3720. */
  3721. e, n) {
  3722. this.converter = e, this._query = n,
  3723. /** The type of this Firestore reference. */
  3724. this.type = "query", this.firestore = t;
  3725. }
  3726. return t.prototype.withConverter = function(e) {
  3727. return new t(this.firestore, e, this._query);
  3728. }, t;
  3729. }(), Fn = /** @class */ function(e) {
  3730. /** @hideconstructor */
  3731. function n(t, n, r) {
  3732. var i = this;
  3733. return (i = e.call(this, t, n, new Te(r)) || this)._path = r,
  3734. /** The type of this Firestore reference. */
  3735. i.type = "collection", i;
  3736. }
  3737. return t(n, e), Object.defineProperty(n.prototype, "id", {
  3738. /** The collection's identifier. */ get: function() {
  3739. return this._query.path.lastSegment();
  3740. },
  3741. enumerable: !1,
  3742. configurable: !0
  3743. }), Object.defineProperty(n.prototype, "path", {
  3744. /**
  3745. * A string representing the path of the referenced collection (relative
  3746. * to the root of the database).
  3747. */
  3748. get: function() {
  3749. return this._query.path.canonicalString();
  3750. },
  3751. enumerable: !1,
  3752. configurable: !0
  3753. }), Object.defineProperty(n.prototype, "parent", {
  3754. /**
  3755. * A reference to the containing `DocumentReference` if this is a
  3756. * subcollection. If this isn't a subcollection, the reference is null.
  3757. */
  3758. get: function() {
  3759. var t = this._path.popLast();
  3760. return t.isEmpty() ? null : new In(this.firestore,
  3761. /* converter= */ null, new it(t));
  3762. },
  3763. enumerable: !1,
  3764. configurable: !0
  3765. }), n.prototype.withConverter = function(t) {
  3766. return new n(this.firestore, t, this._path);
  3767. }, n;
  3768. }(An);
  3769. /**
  3770. * The results of executing an aggregation query.
  3771. */ function Pn(t, e) {
  3772. for (var n = [], i = 2; i < arguments.length; i++) n[i - 2] = arguments[i];
  3773. if (t = p(t), ot("collection", "path", e), t instanceof wn) {
  3774. var o = et.fromString.apply(et, r([ e ], n, !1));
  3775. return st(o), new Fn(t, /* converter= */ null, o);
  3776. }
  3777. if (!(t instanceof In || t instanceof Fn)) throw new B(O, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
  3778. var a = t._path.child(et.fromString.apply(et, r([ e ], n, !1)));
  3779. return st(a), new Fn(t.firestore,
  3780. /* converter= */ null, a);
  3781. }
  3782. // TODO(firestorelite): Consider using ErrorFactory -
  3783. // https://github.com/firebase/firebase-js-sdk/blob/0131e1f/packages/util/src/errors.ts#L106
  3784. /**
  3785. * Creates and returns a new `Query` instance that includes all documents in the
  3786. * database that are contained in a collection or subcollection with the
  3787. * given `collectionId`.
  3788. *
  3789. * @param firestore - A reference to the root `Firestore` instance.
  3790. * @param collectionId - Identifies the collections to query over. Every
  3791. * collection or subcollection with this ID as the last segment of its path
  3792. * will be included. Cannot contain a slash.
  3793. * @returns The created `Query`.
  3794. */ function On(t, e) {
  3795. if (t = ct(t, wn), ot("collectionGroup", "collection id", e), e.indexOf("/") >= 0) throw new B(O, "Invalid collection ID '".concat(e, "' passed to function collectionGroup(). Collection IDs must not contain '/'."));
  3796. return new An(t,
  3797. /* converter= */ null, function(t) {
  3798. return new Te(et.emptyPath(), t);
  3799. }(e));
  3800. }
  3801. function Vn(t, e) {
  3802. for (var n = [], i = 2; i < arguments.length; i++) n[i - 2] = arguments[i];
  3803. if (t = p(t),
  3804. // We allow omission of 'pathString' but explicitly prohibit passing in both
  3805. // 'undefined' and 'null'.
  3806. 1 === arguments.length && (e = Tt.N()), ot("doc", "path", e), t instanceof wn) {
  3807. var o = et.fromString.apply(et, r([ e ], n, !1));
  3808. return at(o), new In(t,
  3809. /* converter= */ null, new it(o));
  3810. }
  3811. if (!(t instanceof In || t instanceof Fn)) throw new B(O, "Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");
  3812. var a = t._path.child(et.fromString.apply(et, r([ e ], n, !1)));
  3813. return at(a), new In(t.firestore, t instanceof Fn ? t.converter : null, new it(a));
  3814. }
  3815. /**
  3816. * Returns true if the provided references are equal.
  3817. *
  3818. * @param left - A reference to compare.
  3819. * @param right - A reference to compare.
  3820. * @returns true if the references point to the same location in the same
  3821. * Firestore database.
  3822. */ function Dn(t, e) {
  3823. return t = p(t), e = p(e), (t instanceof In || t instanceof Fn) && (e instanceof In || e instanceof Fn) && t.firestore === e.firestore && t.path === e.path && t.converter === e.converter
  3824. /**
  3825. * Returns true if the provided queries point to the same collection and apply
  3826. * the same constraints.
  3827. *
  3828. * @param left - A `Query` to compare.
  3829. * @param right - A `Query` to compare.
  3830. * @returns true if the references point to the same location in the same
  3831. * Firestore database.
  3832. */;
  3833. }
  3834. function Nn(t, e) {
  3835. return t = p(t), e = p(e), t instanceof An && e instanceof An && t.firestore === e.firestore && function(t, e) {
  3836. return function(t, e) {
  3837. if (t.limit !== e.limit) return !1;
  3838. if (t.orderBy.length !== e.orderBy.length) return !1;
  3839. for (var n = 0; n < t.orderBy.length; n++) if (!le(t.orderBy[n], e.orderBy[n])) return !1;
  3840. if (t.filters.length !== e.filters.length) return !1;
  3841. for (var r = 0; r < t.filters.length; r++) if (!te(t.filters[r], e.filters[r])) return !1;
  3842. return t.collectionGroup === e.collectionGroup && !!t.path.isEqual(e.path) && !!Jt(t.startAt, e.startAt) && Jt(t.endAt, e.endAt);
  3843. }(Ae(t), Ae(e)) && t.limitType === e.limitType;
  3844. }(t._query, e._query) && t.converter === e.converter
  3845. /**
  3846. * @license
  3847. * Copyright 2020 Google LLC
  3848. *
  3849. * Licensed under the Apache License, Version 2.0 (the "License");
  3850. * you may not use this file except in compliance with the License.
  3851. * You may obtain a copy of the License at
  3852. *
  3853. * http://www.apache.org/licenses/LICENSE-2.0
  3854. *
  3855. * Unless required by applicable law or agreed to in writing, software
  3856. * distributed under the License is distributed on an "AS IS" BASIS,
  3857. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  3858. * See the License for the specific language governing permissions and
  3859. * limitations under the License.
  3860. */
  3861. /**
  3862. * An immutable object representing an array of bytes.
  3863. */;
  3864. }
  3865. var qn = /** @class */ function() {
  3866. /** @hideconstructor */
  3867. function t(t) {
  3868. this._byteString = t;
  3869. }
  3870. /**
  3871. * Creates a new `Bytes` object from the given Base64 string, converting it to
  3872. * bytes.
  3873. *
  3874. * @param base64 - The Base64 string used to create the `Bytes` object.
  3875. */ return t.fromBase64String = function(e) {
  3876. try {
  3877. return new t(Ft.fromBase64String(e));
  3878. } catch (e) {
  3879. throw new B(O, "Failed to construct data from Base64 string: " + e);
  3880. }
  3881. },
  3882. /**
  3883. * Creates a new `Bytes` object from the given Uint8Array.
  3884. *
  3885. * @param array - The Uint8Array used to create the `Bytes` object.
  3886. */
  3887. t.fromUint8Array = function(e) {
  3888. return new t(Ft.fromUint8Array(e));
  3889. },
  3890. /**
  3891. * Returns the underlying bytes as a Base64-encoded string.
  3892. *
  3893. * @returns The Base64-encoded string created from the `Bytes` object.
  3894. */
  3895. t.prototype.toBase64 = function() {
  3896. return this._byteString.toBase64();
  3897. },
  3898. /**
  3899. * Returns the underlying bytes in a new `Uint8Array`.
  3900. *
  3901. * @returns The Uint8Array created from the `Bytes` object.
  3902. */
  3903. t.prototype.toUint8Array = function() {
  3904. return this._byteString.toUint8Array();
  3905. },
  3906. /**
  3907. * Returns a string representation of the `Bytes` object.
  3908. *
  3909. * @returns A string representation of the `Bytes` object.
  3910. */
  3911. t.prototype.toString = function() {
  3912. return "Bytes(base64: " + this.toBase64() + ")";
  3913. },
  3914. /**
  3915. * Returns true if this `Bytes` object is equal to the provided one.
  3916. *
  3917. * @param other - The `Bytes` object to compare against.
  3918. * @returns true if this `Bytes` object is equal to the provided one.
  3919. */
  3920. t.prototype.isEqual = function(t) {
  3921. return this._byteString.isEqual(t._byteString);
  3922. }, t;
  3923. }(), Rn = /** @class */ function() {
  3924. /**
  3925. * Creates a `FieldPath` from the provided field names. If more than one field
  3926. * name is provided, the path will point to a nested field in a document.
  3927. *
  3928. * @param fieldNames - A list of field names.
  3929. */
  3930. function t() {
  3931. for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
  3932. for (var n = 0; n < t.length; ++n) if (0 === t[n].length) throw new B(O, "Invalid field name at argument $(i + 1). Field names must not be empty.");
  3933. this._internalPath = new rt(t);
  3934. }
  3935. /**
  3936. * Returns true if this `FieldPath` is equal to the provided one.
  3937. *
  3938. * @param other - The `FieldPath` to compare against.
  3939. * @returns true if this `FieldPath` is equal to the provided one.
  3940. */ return t.prototype.isEqual = function(t) {
  3941. return this._internalPath.isEqual(t._internalPath);
  3942. }, t;
  3943. }();
  3944. /**
  3945. * @license
  3946. * Copyright 2020 Google LLC
  3947. *
  3948. * Licensed under the Apache License, Version 2.0 (the "License");
  3949. * you may not use this file except in compliance with the License.
  3950. * You may obtain a copy of the License at
  3951. *
  3952. * http://www.apache.org/licenses/LICENSE-2.0
  3953. *
  3954. * Unless required by applicable law or agreed to in writing, software
  3955. * distributed under the License is distributed on an "AS IS" BASIS,
  3956. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  3957. * See the License for the specific language governing permissions and
  3958. * limitations under the License.
  3959. */
  3960. /**
  3961. * A `FieldPath` refers to a field in a document. The path may consist of a
  3962. * single field name (referring to a top-level field in the document), or a
  3963. * list of field names (referring to a nested field in the document).
  3964. *
  3965. * Create a `FieldPath` by providing field names. If more than one field
  3966. * name is provided, the path will point to a nested field in a document.
  3967. */
  3968. /**
  3969. * Returns a special sentinel `FieldPath` to refer to the ID of a document.
  3970. * It can be used in queries to sort or filter by the document ID.
  3971. */
  3972. function xn() {
  3973. return new Rn("__name__");
  3974. }
  3975. /**
  3976. * @license
  3977. * Copyright 2020 Google LLC
  3978. *
  3979. * Licensed under the Apache License, Version 2.0 (the "License");
  3980. * you may not use this file except in compliance with the License.
  3981. * You may obtain a copy of the License at
  3982. *
  3983. * http://www.apache.org/licenses/LICENSE-2.0
  3984. *
  3985. * Unless required by applicable law or agreed to in writing, software
  3986. * distributed under the License is distributed on an "AS IS" BASIS,
  3987. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  3988. * See the License for the specific language governing permissions and
  3989. * limitations under the License.
  3990. */
  3991. /**
  3992. * Sentinel values that can be used when writing document fields with `set()`
  3993. * or `update()`.
  3994. */ var Cn =
  3995. /**
  3996. * @param _methodName - The public API endpoint that returns this class.
  3997. * @hideconstructor
  3998. */
  3999. function(t) {
  4000. this._methodName = t;
  4001. }, jn = /** @class */ function() {
  4002. /**
  4003. * Creates a new immutable `GeoPoint` object with the provided latitude and
  4004. * longitude values.
  4005. * @param latitude - The latitude as number between -90 and 90.
  4006. * @param longitude - The longitude as number between -180 and 180.
  4007. */
  4008. function t(t, e) {
  4009. if (!isFinite(t) || t < -90 || t > 90) throw new B(O, "Latitude must be a number between -90 and 90, but was: " + t);
  4010. if (!isFinite(e) || e < -180 || e > 180) throw new B(O, "Longitude must be a number between -180 and 180, but was: " + e);
  4011. this._lat = t, this._long = e;
  4012. }
  4013. return Object.defineProperty(t.prototype, "latitude", {
  4014. /**
  4015. * The latitude of this `GeoPoint` instance.
  4016. */
  4017. get: function() {
  4018. return this._lat;
  4019. },
  4020. enumerable: !1,
  4021. configurable: !0
  4022. }), Object.defineProperty(t.prototype, "longitude", {
  4023. /**
  4024. * The longitude of this `GeoPoint` instance.
  4025. */
  4026. get: function() {
  4027. return this._long;
  4028. },
  4029. enumerable: !1,
  4030. configurable: !0
  4031. }),
  4032. /**
  4033. * Returns true if this `GeoPoint` is equal to the provided one.
  4034. *
  4035. * @param other - The `GeoPoint` to compare against.
  4036. * @returns true if this `GeoPoint` is equal to the provided one.
  4037. */
  4038. t.prototype.isEqual = function(t) {
  4039. return this._lat === t._lat && this._long === t._long;
  4040. },
  4041. /** Returns a JSON-serializable representation of this GeoPoint. */ t.prototype.toJSON = function() {
  4042. return {
  4043. latitude: this._lat,
  4044. longitude: this._long
  4045. };
  4046. },
  4047. /**
  4048. * Actually private to JS consumers of our API, so this function is prefixed
  4049. * with an underscore.
  4050. */
  4051. t.prototype._compareTo = function(t) {
  4052. return Et(this._lat, t._lat) || Et(this._long, t._long);
  4053. }, t;
  4054. }(), Ln = /^__.*__$/, Mn = /** @class */ function() {
  4055. function t(t, e, n) {
  4056. this.data = t, this.fieldMask = e, this.fieldTransforms = n;
  4057. }
  4058. return t.prototype.toMutation = function(t, e) {
  4059. return null !== this.fieldMask ? new Le(t, this.data, this.fieldMask, e, this.fieldTransforms) : new je(t, this.data, e, this.fieldTransforms);
  4060. }, t;
  4061. }(), Un = /** @class */ function() {
  4062. function t(t,
  4063. // The fieldMask does not include document transforms.
  4064. e, n) {
  4065. this.data = t, this.fieldMask = e, this.fieldTransforms = n;
  4066. }
  4067. return t.prototype.toMutation = function(t, e) {
  4068. return new Le(t, this.data, this.fieldMask, e, this.fieldTransforms);
  4069. }, t;
  4070. }();
  4071. /**
  4072. * @license
  4073. * Copyright 2017 Google LLC
  4074. *
  4075. * Licensed under the Apache License, Version 2.0 (the "License");
  4076. * you may not use this file except in compliance with the License.
  4077. * You may obtain a copy of the License at
  4078. *
  4079. * http://www.apache.org/licenses/LICENSE-2.0
  4080. *
  4081. * Unless required by applicable law or agreed to in writing, software
  4082. * distributed under the License is distributed on an "AS IS" BASIS,
  4083. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  4084. * See the License for the specific language governing permissions and
  4085. * limitations under the License.
  4086. */
  4087. /**
  4088. * An immutable object representing a geographic location in Firestore. The
  4089. * location is represented as latitude/longitude pair.
  4090. *
  4091. * Latitude values are in the range of [-90, 90].
  4092. * Longitude values are in the range of [-180, 180].
  4093. */ function Bn(t) {
  4094. switch (t) {
  4095. case 0 /* UserDataSource.Set */ :
  4096. // fall through
  4097. case 2 /* UserDataSource.MergeSet */ :
  4098. // fall through
  4099. case 1 /* UserDataSource.Update */ :
  4100. return !0;
  4101. case 3 /* UserDataSource.Argument */ :
  4102. case 4 /* UserDataSource.ArrayArgument */ :
  4103. return !1;
  4104. default:
  4105. throw k();
  4106. }
  4107. }
  4108. /** A "context" object passed around while parsing user data. */ var zn = /** @class */ function() {
  4109. /**
  4110. * Initializes a ParseContext with the given source and path.
  4111. *
  4112. * @param settings - The settings for the parser.
  4113. * @param databaseId - The database ID of the Firestore instance.
  4114. * @param serializer - The serializer to use to generate the Value proto.
  4115. * @param ignoreUndefinedProperties - Whether to ignore undefined properties
  4116. * rather than throw.
  4117. * @param fieldTransforms - A mutable list of field transforms encountered
  4118. * while parsing the data.
  4119. * @param fieldMask - A mutable list of field paths encountered while parsing
  4120. * the data.
  4121. *
  4122. * TODO(b/34871131): We don't support array paths right now, so path can be
  4123. * null to indicate the context represents any location within an array (in
  4124. * which case certain features will not work and errors will be somewhat
  4125. * compromised).
  4126. */
  4127. function t(t, e, n, r, i, o) {
  4128. this.settings = t, this.databaseId = e, this.serializer = n, this.ignoreUndefinedProperties = r,
  4129. // Minor hack: If fieldTransforms is undefined, we assume this is an
  4130. // external call and we need to validate the entire path.
  4131. void 0 === i && this.tt(), this.fieldTransforms = i || [], this.fieldMask = o || [];
  4132. }
  4133. return Object.defineProperty(t.prototype, "path", {
  4134. get: function() {
  4135. return this.settings.path;
  4136. },
  4137. enumerable: !1,
  4138. configurable: !0
  4139. }), Object.defineProperty(t.prototype, "et", {
  4140. get: function() {
  4141. return this.settings.et;
  4142. },
  4143. enumerable: !1,
  4144. configurable: !0
  4145. }),
  4146. /** Returns a new context with the specified settings overwritten. */ t.prototype.nt = function(e) {
  4147. return new t(Object.assign(Object.assign({}, this.settings), e), this.databaseId, this.serializer, this.ignoreUndefinedProperties, this.fieldTransforms, this.fieldMask);
  4148. }, t.prototype.rt = function(t) {
  4149. var e, n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.nt({
  4150. path: n,
  4151. st: !1
  4152. });
  4153. return r.it(t), r;
  4154. }, t.prototype.ot = function(t) {
  4155. var e, n = null === (e = this.path) || void 0 === e ? void 0 : e.child(t), r = this.nt({
  4156. path: n,
  4157. st: !1
  4158. });
  4159. return r.tt(), r;
  4160. }, t.prototype.ut = function(t) {
  4161. // TODO(b/34871131): We don't support array paths right now; so make path
  4162. // undefined.
  4163. return this.nt({
  4164. path: void 0,
  4165. st: !0
  4166. });
  4167. }, t.prototype.ct = function(t) {
  4168. return cr(t, this.settings.methodName, this.settings.ht || !1, this.path, this.settings.lt);
  4169. },
  4170. /** Returns 'true' if 'fieldPath' was traversed when creating this context. */ t.prototype.contains = function(t) {
  4171. return void 0 !== this.fieldMask.find((function(e) {
  4172. return t.isPrefixOf(e);
  4173. })) || void 0 !== this.fieldTransforms.find((function(e) {
  4174. return t.isPrefixOf(e.field);
  4175. }));
  4176. }, t.prototype.tt = function() {
  4177. // TODO(b/34871131): Remove null check once we have proper paths for fields
  4178. // within arrays.
  4179. if (this.path) for (var t = 0; t < this.path.length; t++) this.it(this.path.get(t));
  4180. }, t.prototype.it = function(t) {
  4181. if (0 === t.length) throw this.ct("Document fields must not be empty");
  4182. if (Bn(this.et) && Ln.test(t)) throw this.ct('Document fields cannot begin and end with "__"');
  4183. }, t;
  4184. }(), Qn = /** @class */ function() {
  4185. function t(t, e, n) {
  4186. this.databaseId = t, this.ignoreUndefinedProperties = e, this.serializer = n || fn(t)
  4187. /** Creates a new top-level parse context. */;
  4188. }
  4189. return t.prototype.ft = function(t, e, n, r) {
  4190. return void 0 === r && (r = !1), new zn({
  4191. et: t,
  4192. methodName: e,
  4193. lt: n,
  4194. path: rt.emptyPath(),
  4195. st: !1,
  4196. ht: r
  4197. }, this.databaseId, this.serializer, this.ignoreUndefinedProperties);
  4198. }, t;
  4199. }();
  4200. /**
  4201. * Helper for parsing raw user input (provided via the API) into internal model
  4202. * classes.
  4203. */ function Kn(t) {
  4204. var e = t._freezeSettings(), n = fn(t._databaseId);
  4205. return new Qn(t._databaseId, !!e.ignoreUndefinedProperties, n);
  4206. }
  4207. /** Parse document data from a set() call. */ function Gn(t, e, n, r, i, o) {
  4208. void 0 === o && (o = {});
  4209. var a = t.ft(o.merge || o.mergeFields ? 2 /* UserDataSource.MergeSet */ : 0 /* UserDataSource.Set */ , e, n, i);
  4210. or("Data must be an object, but it was:", a, r);
  4211. var s, u, c = rr(r, a);
  4212. if (o.merge) s = new ve(a.fieldMask), u = a.fieldTransforms; else if (o.mergeFields) {
  4213. for (var l = [], f = 0, h = o.mergeFields; f < h.length; f++) {
  4214. var p = ar(e, h[f], n);
  4215. if (!a.contains(p)) throw new B(O, "Field '".concat(p, "' is specified in your field mask but missing from your input data."));
  4216. lr(l, p) || l.push(p);
  4217. }
  4218. s = new ve(l), u = a.fieldTransforms.filter((function(t) {
  4219. return s.covers(t.field);
  4220. }));
  4221. } else s = null, u = a.fieldTransforms;
  4222. return new Mn(new ge(c), s, u);
  4223. }
  4224. var Wn = /** @class */ function(e) {
  4225. function n() {
  4226. return null !== e && e.apply(this, arguments) || this;
  4227. }
  4228. return t(n, e), n.prototype._toFieldTransform = function(t) {
  4229. if (2 /* UserDataSource.MergeSet */ !== t.et) throw 1 /* UserDataSource.Update */ === t.et ? t.ct("".concat(this._methodName, "() can only appear at the top level of your update data")) : t.ct("".concat(this._methodName, "() cannot be used with set() unless you pass {merge:true}"));
  4230. // No transform to add for a delete, but we need to add it to our
  4231. // fieldMask so it gets deleted.
  4232. return t.fieldMask.push(t.path), null;
  4233. }, n.prototype.isEqual = function(t) {
  4234. return t instanceof n;
  4235. }, n;
  4236. }(Cn);
  4237. /**
  4238. * Creates a child context for parsing SerializableFieldValues.
  4239. *
  4240. * This is different than calling `ParseContext.contextWith` because it keeps
  4241. * the fieldTransforms and fieldMask separate.
  4242. *
  4243. * The created context has its `dataSource` set to `UserDataSource.Argument`.
  4244. * Although these values are used with writes, any elements in these FieldValues
  4245. * are not considered writes since they cannot contain any FieldValue sentinels,
  4246. * etc.
  4247. *
  4248. * @param fieldValue - The sentinel FieldValue for which to create a child
  4249. * context.
  4250. * @param context - The parent context.
  4251. * @param arrayElement - Whether or not the FieldValue has an array.
  4252. */ function Yn(t, e, n) {
  4253. return new zn({
  4254. et: 3 /* UserDataSource.Argument */ ,
  4255. lt: e.settings.lt,
  4256. methodName: t._methodName,
  4257. st: n
  4258. }, e.databaseId, e.serializer, e.ignoreUndefinedProperties);
  4259. }
  4260. var Hn = /** @class */ function(e) {
  4261. function n() {
  4262. return null !== e && e.apply(this, arguments) || this;
  4263. }
  4264. return t(n, e), n.prototype._toFieldTransform = function(t) {
  4265. return new Re(t.path, new Ve);
  4266. }, n.prototype.isEqual = function(t) {
  4267. return t instanceof n;
  4268. }, n;
  4269. }(Cn), Jn = /** @class */ function(e) {
  4270. function n(t, n) {
  4271. var r = this;
  4272. return (r = e.call(this, t) || this).dt = n, r;
  4273. }
  4274. return t(n, e), n.prototype._toFieldTransform = function(t) {
  4275. var e = Yn(this, t,
  4276. /*array=*/ !0), n = this.dt.map((function(t) {
  4277. return nr(t, e);
  4278. })), r = new De(n);
  4279. return new Re(t.path, r);
  4280. }, n.prototype.isEqual = function(t) {
  4281. // TODO(mrschmidt): Implement isEquals
  4282. return this === t;
  4283. }, n;
  4284. }(Cn), Xn = /** @class */ function(e) {
  4285. function n(t, n) {
  4286. var r = this;
  4287. return (r = e.call(this, t) || this).dt = n, r;
  4288. }
  4289. return t(n, e), n.prototype._toFieldTransform = function(t) {
  4290. var e = Yn(this, t,
  4291. /*array=*/ !0), n = this.dt.map((function(t) {
  4292. return nr(t, e);
  4293. })), r = new Ne(n);
  4294. return new Re(t.path, r);
  4295. }, n.prototype.isEqual = function(t) {
  4296. // TODO(mrschmidt): Implement isEquals
  4297. return this === t;
  4298. }, n;
  4299. }(Cn), $n = /** @class */ function(e) {
  4300. function n(t, n) {
  4301. var r = this;
  4302. return (r = e.call(this, t) || this).wt = n, r;
  4303. }
  4304. return t(n, e), n.prototype._toFieldTransform = function(t) {
  4305. var e = new qe(t.serializer, Pe(t.serializer, this.wt));
  4306. return new Re(t.path, e);
  4307. }, n.prototype.isEqual = function(t) {
  4308. // TODO(mrschmidt): Implement isEquals
  4309. return this === t;
  4310. }, n;
  4311. }(Cn);
  4312. /** Parse update data from an update() call. */ function Zn(t, e, n, r) {
  4313. var i = t.ft(1 /* UserDataSource.Update */ , e, n);
  4314. or("Data must be an object, but it was:", i, r);
  4315. var o = [], a = ge.empty();
  4316. It(r, (function(t, r) {
  4317. var s = ur(e, t, n);
  4318. // For Compat types, we have to "extract" the underlying types before
  4319. // performing validation.
  4320. r = p(r);
  4321. var u = i.ot(s);
  4322. if (r instanceof Wn)
  4323. // Add it to the field mask, but don't add anything to updateData.
  4324. o.push(s); else {
  4325. var c = nr(r, u);
  4326. null != c && (o.push(s), a.set(s, c));
  4327. }
  4328. }));
  4329. var s = new ve(o);
  4330. return new Un(a, s, i.fieldTransforms);
  4331. }
  4332. /** Parse update data from a list of field/value arguments. */ function tr(t, e, n, r, i, o) {
  4333. var a = t.ft(1 /* UserDataSource.Update */ , e, n), s = [ ar(e, r, n) ], u = [ i ];
  4334. if (o.length % 2 != 0) throw new B(O, "Function ".concat(e, "() needs to be called with an even number of arguments that alternate between field names and values."));
  4335. for (var c = 0; c < o.length; c += 2) s.push(ar(e, o[c])), u.push(o[c + 1]);
  4336. // We iterate in reverse order to pick the last value for a field if the
  4337. // user specified the field multiple times.
  4338. for (var l = [], f = ge.empty(), h = s.length - 1; h >= 0; --h) if (!lr(l, s[h])) {
  4339. var d = s[h], y = u[h];
  4340. // For Compat types, we have to "extract" the underlying types before
  4341. // performing validation.
  4342. y = p(y);
  4343. var m = a.ot(d);
  4344. if (y instanceof Wn)
  4345. // Add it to the field mask, but don't add anything to updateData.
  4346. l.push(d); else {
  4347. var v = nr(y, m);
  4348. null != v && (l.push(d), f.set(d, v));
  4349. }
  4350. }
  4351. var g = new ve(l);
  4352. return new Un(f, g, a.fieldTransforms);
  4353. }
  4354. /**
  4355. * Parse a "query value" (e.g. value in a where filter or a value in a cursor
  4356. * bound).
  4357. *
  4358. * @param allowArrays - Whether the query value is an array that may directly
  4359. * contain additional arrays (e.g. the operand of an `in` query).
  4360. */ function er(t, e, n, r) {
  4361. return void 0 === r && (r = !1), nr(n, t.ft(r ? 4 /* UserDataSource.ArrayArgument */ : 3 /* UserDataSource.Argument */ , e));
  4362. }
  4363. /**
  4364. * Parses user data to Protobuf Values.
  4365. *
  4366. * @param input - Data to be parsed.
  4367. * @param context - A context object representing the current path being parsed,
  4368. * the source of the data being parsed, etc.
  4369. * @returns The parsed value, or null if the value was a FieldValue sentinel
  4370. * that should not be included in the resulting parsed data.
  4371. */ function nr(t, e) {
  4372. if (ir(
  4373. // Unwrap the API type from the Compat SDK. This will return the API type
  4374. // from firestore-exp.
  4375. t = p(t))) return or("Unsupported field value:", e, t), rr(t, e);
  4376. if (t instanceof Cn)
  4377. // FieldValues usually parse into transforms (except deleteField())
  4378. // in which case we do not want to include this field in our parsed data
  4379. // (as doing so will overwrite the field directly prior to the transform
  4380. // trying to transform it). So we don't add this location to
  4381. // context.fieldMask and we return null as our parsing result.
  4382. /**
  4383. * "Parses" the provided FieldValueImpl, adding any necessary transforms to
  4384. * context.fieldTransforms.
  4385. */
  4386. return function(t, e) {
  4387. // Sentinels are only supported with writes, and not within arrays.
  4388. if (!Bn(e.et)) throw e.ct("".concat(t._methodName, "() can only be used with update() and set()"));
  4389. if (!e.path) throw e.ct("".concat(t._methodName, "() is not currently supported inside arrays"));
  4390. var n = t._toFieldTransform(e);
  4391. n && e.fieldTransforms.push(n);
  4392. }(t, e), null;
  4393. if (void 0 === t && e.ignoreUndefinedProperties)
  4394. // If the input is undefined it can never participate in the fieldMask, so
  4395. // don't handle this below. If `ignoreUndefinedProperties` is false,
  4396. // `parseScalarValue` will reject an undefined value.
  4397. return null;
  4398. if (
  4399. // If context.path is null we are inside an array and we don't support
  4400. // field mask paths more granular than the top-level array.
  4401. e.path && e.fieldMask.push(e.path), t instanceof Array) {
  4402. // TODO(b/34871131): Include the path containing the array in the error
  4403. // message.
  4404. // In the case of IN queries, the parsed data is an array (representing
  4405. // the set of values to be included for the IN query) that may directly
  4406. // contain additional arrays (each representing an individual field
  4407. // value), so we disable this validation.
  4408. if (e.settings.st && 4 /* UserDataSource.ArrayArgument */ !== e.et) throw e.ct("Nested arrays are not supported");
  4409. return function(t, e) {
  4410. for (var n = [], r = 0, i = 0, o = t; i < o.length; i++) {
  4411. var a = nr(o[i], e.ut(r));
  4412. null == a && (
  4413. // Just include nulls in the array for fields being replaced with a
  4414. // sentinel.
  4415. a = {
  4416. nullValue: "NULL_VALUE"
  4417. }), n.push(a), r++;
  4418. }
  4419. return {
  4420. arrayValue: {
  4421. values: n
  4422. }
  4423. };
  4424. }(t, e);
  4425. }
  4426. return function(t, e) {
  4427. if (null === (t = p(t))) return {
  4428. nullValue: "NULL_VALUE"
  4429. };
  4430. if ("number" == typeof t) return Pe(e.serializer, t);
  4431. if ("boolean" == typeof t) return {
  4432. booleanValue: t
  4433. };
  4434. if ("string" == typeof t) return {
  4435. stringValue: t
  4436. };
  4437. if (t instanceof Date) {
  4438. var n = Nt.fromDate(t);
  4439. return {
  4440. timestampValue: Ge(e.serializer, n)
  4441. };
  4442. }
  4443. if (t instanceof Nt) {
  4444. // Firestore backend truncates precision down to microseconds. To ensure
  4445. // offline mode works the same with regards to truncation, perform the
  4446. // truncation immediately without waiting for the backend to do that.
  4447. var r = new Nt(t.seconds, 1e3 * Math.floor(t.nanoseconds / 1e3));
  4448. return {
  4449. timestampValue: Ge(e.serializer, r)
  4450. };
  4451. }
  4452. if (t instanceof jn) return {
  4453. geoPointValue: {
  4454. latitude: t.latitude,
  4455. longitude: t.longitude
  4456. }
  4457. };
  4458. if (t instanceof qn) return {
  4459. bytesValue: We(e.serializer, t._byteString)
  4460. };
  4461. if (t instanceof In) {
  4462. var i = e.databaseId, o = t.firestore._databaseId;
  4463. if (!o.isEqual(i)) throw e.ct("Document reference is for database ".concat(o.projectId, "/").concat(o.database, " but should be for database ").concat(i.projectId, "/").concat(i.database));
  4464. return {
  4465. referenceValue: Je(t.firestore._databaseId || e.databaseId, t._key.path)
  4466. };
  4467. }
  4468. throw e.ct("Unsupported field value: ".concat(ut(t)));
  4469. }(t, e);
  4470. }
  4471. function rr(t, e) {
  4472. var n = {};
  4473. return function(t) {
  4474. for (var e in t) if (Object.prototype.hasOwnProperty.call(t, e)) return !1;
  4475. return !0;
  4476. }(t) ?
  4477. // If we encounter an empty object, we explicitly add it to the update
  4478. // mask to ensure that the server creates a map entry.
  4479. e.path && e.path.length > 0 && e.fieldMask.push(e.path) : It(t, (function(t, r) {
  4480. var i = nr(r, e.rt(t));
  4481. null != i && (n[t] = i);
  4482. })), {
  4483. mapValue: {
  4484. fields: n
  4485. }
  4486. };
  4487. }
  4488. function ir(t) {
  4489. return !("object" != typeof t || null === t || t instanceof Array || t instanceof Date || t instanceof Nt || t instanceof jn || t instanceof qn || t instanceof In || t instanceof Cn);
  4490. }
  4491. function or(t, e, n) {
  4492. if (!ir(n) || !function(t) {
  4493. return "object" == typeof t && null !== t && (Object.getPrototypeOf(t) === Object.prototype || null === Object.getPrototypeOf(t));
  4494. }(n)) {
  4495. var r = ut(n);
  4496. throw "an object" === r ? e.ct(t + " a custom object") : e.ct(t + " " + r);
  4497. }
  4498. }
  4499. /**
  4500. * Helper that calls fromDotSeparatedString() but wraps any error thrown.
  4501. */ function ar(t, e, n) {
  4502. if (
  4503. // If required, replace the FieldPath Compat class with with the firestore-exp
  4504. // FieldPath.
  4505. (e = p(e)) instanceof Rn) return e._internalPath;
  4506. if ("string" == typeof e) return ur(t, e);
  4507. throw cr("Field path arguments must be of type string or ", t,
  4508. /* hasConverter= */ !1,
  4509. /* path= */ void 0, n);
  4510. }
  4511. /**
  4512. * Matches any characters in a field path string that are reserved.
  4513. */ var sr = new RegExp("[~\\*/\\[\\]]");
  4514. /**
  4515. * Wraps fromDotSeparatedString with an error message about the method that
  4516. * was thrown.
  4517. * @param methodName - The publicly visible method name
  4518. * @param path - The dot-separated string form of a field path which will be
  4519. * split on dots.
  4520. * @param targetDoc - The document against which the field path will be
  4521. * evaluated.
  4522. */ function ur(t, e, n) {
  4523. if (e.search(sr) >= 0) throw cr("Invalid field path (".concat(e, "). Paths must not contain '~', '*', '/', '[', or ']'"), t,
  4524. /* hasConverter= */ !1,
  4525. /* path= */ void 0, n);
  4526. try {
  4527. return (new (Rn.bind.apply(Rn, r([ void 0 ], e.split("."), !1))))._internalPath;
  4528. } catch (r) {
  4529. throw cr("Invalid field path (".concat(e, "). Paths must not be empty, begin with '.', end with '.', or contain '..'"), t,
  4530. /* hasConverter= */ !1,
  4531. /* path= */ void 0, n);
  4532. }
  4533. }
  4534. function cr(t, e, n, r, i) {
  4535. var o = r && !r.isEmpty(), a = void 0 !== i, s = "Function ".concat(e, "() called with invalid data");
  4536. n && (s += " (via `toFirestore()`)"), s += ". ";
  4537. var u = "";
  4538. return (o || a) && (u += " (found", o && (u += " in field ".concat(r)), a && (u += " in document ".concat(i)),
  4539. u += ")"), new B(O, s + t + u)
  4540. /** Checks `haystack` if FieldPath `needle` is present. Runs in O(n). */;
  4541. }
  4542. function lr(t, e) {
  4543. return t.some((function(t) {
  4544. return t.isEqual(e);
  4545. }));
  4546. }
  4547. /**
  4548. * @license
  4549. * Copyright 2020 Google LLC
  4550. *
  4551. * Licensed under the Apache License, Version 2.0 (the "License");
  4552. * you may not use this file except in compliance with the License.
  4553. * You may obtain a copy of the License at
  4554. *
  4555. * http://www.apache.org/licenses/LICENSE-2.0
  4556. *
  4557. * Unless required by applicable law or agreed to in writing, software
  4558. * distributed under the License is distributed on an "AS IS" BASIS,
  4559. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  4560. * See the License for the specific language governing permissions and
  4561. * limitations under the License.
  4562. */
  4563. /**
  4564. * A `DocumentSnapshot` contains data read from a document in your Firestore
  4565. * database. The data can be extracted with `.data()` or `.get(<field>)` to
  4566. * get a specific field.
  4567. *
  4568. * For a `DocumentSnapshot` that points to a non-existing document, any data
  4569. * access will return 'undefined'. You can use the `exists()` method to
  4570. * explicitly verify a document's existence.
  4571. */ var fr = /** @class */ function() {
  4572. // Note: This class is stripped down version of the DocumentSnapshot in
  4573. // the legacy SDK. The changes are:
  4574. // - No support for SnapshotMetadata.
  4575. // - No support for SnapshotOptions.
  4576. /** @hideconstructor protected */
  4577. function t(t, e, n, r, i) {
  4578. this._firestore = t, this._userDataWriter = e, this._key = n, this._document = r,
  4579. this._converter = i;
  4580. }
  4581. return Object.defineProperty(t.prototype, "id", {
  4582. /** Property of the `DocumentSnapshot` that provides the document's ID. */ get: function() {
  4583. return this._key.path.lastSegment();
  4584. },
  4585. enumerable: !1,
  4586. configurable: !0
  4587. }), Object.defineProperty(t.prototype, "ref", {
  4588. /**
  4589. * The `DocumentReference` for the document included in the `DocumentSnapshot`.
  4590. */
  4591. get: function() {
  4592. return new In(this._firestore, this._converter, this._key);
  4593. },
  4594. enumerable: !1,
  4595. configurable: !0
  4596. }),
  4597. /**
  4598. * Signals whether or not the document at the snapshot's location exists.
  4599. *
  4600. * @returns true if the document exists.
  4601. */
  4602. t.prototype.exists = function() {
  4603. return null !== this._document;
  4604. },
  4605. /**
  4606. * Retrieves all fields in the document as an `Object`. Returns `undefined` if
  4607. * the document doesn't exist.
  4608. *
  4609. * @returns An `Object` containing all fields in the document or `undefined`
  4610. * if the document doesn't exist.
  4611. */
  4612. t.prototype.data = function() {
  4613. if (this._document) {
  4614. if (this._converter) {
  4615. // We only want to use the converter and create a new DocumentSnapshot
  4616. // if a converter has been provided.
  4617. var t = new hr(this._firestore, this._userDataWriter, this._key, this._document,
  4618. /* converter= */ null);
  4619. return this._converter.fromFirestore(t);
  4620. }
  4621. return this._userDataWriter.convertValue(this._document.data.value);
  4622. }
  4623. },
  4624. /**
  4625. * Retrieves the field specified by `fieldPath`. Returns `undefined` if the
  4626. * document or field doesn't exist.
  4627. *
  4628. * @param fieldPath - The path (for example 'foo' or 'foo.bar') to a specific
  4629. * field.
  4630. * @returns The data at the specified field location or undefined if no such
  4631. * field exists in the document.
  4632. */
  4633. // We are using `any` here to avoid an explicit cast by our users.
  4634. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  4635. t.prototype.get = function(t) {
  4636. if (this._document) {
  4637. var e = this._document.data.field(yr("DocumentSnapshot.get", t));
  4638. if (null !== e) return this._userDataWriter.convertValue(e);
  4639. }
  4640. }, t;
  4641. }(), hr = /** @class */ function(e) {
  4642. function n() {
  4643. return null !== e && e.apply(this, arguments) || this;
  4644. }
  4645. /**
  4646. * Retrieves all fields in the document as an `Object`.
  4647. *
  4648. * @override
  4649. * @returns An `Object` containing all fields in the document.
  4650. */ return t(n, e), n.prototype.data = function() {
  4651. return e.prototype.data.call(this);
  4652. }, n;
  4653. }(fr), pr = /** @class */ function() {
  4654. /** @hideconstructor */
  4655. function t(t, e) {
  4656. this._docs = e, this.query = t;
  4657. }
  4658. return Object.defineProperty(t.prototype, "docs", {
  4659. /** An array of all the documents in the `QuerySnapshot`. */ get: function() {
  4660. return r([], this._docs, !0);
  4661. },
  4662. enumerable: !1,
  4663. configurable: !0
  4664. }), Object.defineProperty(t.prototype, "size", {
  4665. /** The number of documents in the `QuerySnapshot`. */ get: function() {
  4666. return this.docs.length;
  4667. },
  4668. enumerable: !1,
  4669. configurable: !0
  4670. }), Object.defineProperty(t.prototype, "empty", {
  4671. /** True if there are no documents in the `QuerySnapshot`. */ get: function() {
  4672. return 0 === this.docs.length;
  4673. },
  4674. enumerable: !1,
  4675. configurable: !0
  4676. }),
  4677. /**
  4678. * Enumerates all of the documents in the `QuerySnapshot`.
  4679. *
  4680. * @param callback - A callback to be called with a `QueryDocumentSnapshot` for
  4681. * each document in the snapshot.
  4682. * @param thisArg - The `this` binding for the callback.
  4683. */
  4684. t.prototype.forEach = function(t, e) {
  4685. this._docs.forEach(t, e);
  4686. }, t;
  4687. }();
  4688. /**
  4689. * A `QueryDocumentSnapshot` contains data read from a document in your
  4690. * Firestore database as part of a query. The document is guaranteed to exist
  4691. * and its data can be extracted with `.data()` or `.get(<field>)` to get a
  4692. * specific field.
  4693. *
  4694. * A `QueryDocumentSnapshot` offers the same API surface as a
  4695. * `DocumentSnapshot`. Since query results contain only existing documents, the
  4696. * `exists` property will always be true and `data()` will never return
  4697. * 'undefined'.
  4698. */
  4699. /**
  4700. * Returns true if the provided snapshots are equal.
  4701. *
  4702. * @param left - A snapshot to compare.
  4703. * @param right - A snapshot to compare.
  4704. * @returns true if the snapshots are equal.
  4705. */
  4706. function dr(t, e) {
  4707. return t = p(t), e = p(e), t instanceof fr && e instanceof fr ? t._firestore === e._firestore && t._key.isEqual(e._key) && (null === t._document ? null === e._document : t._document.isEqual(e._document)) && t._converter === e._converter : t instanceof pr && e instanceof pr && Nn(t.query, e.query) && St(t.docs, e.docs, dr)
  4708. /**
  4709. * Helper that calls `fromDotSeparatedString()` but wraps any error thrown.
  4710. */;
  4711. }
  4712. function yr(t, e) {
  4713. return "string" == typeof e ? ur(t, e) : e instanceof Rn ? e._internalPath : e._delegate._internalPath;
  4714. }
  4715. /**
  4716. * @license
  4717. * Copyright 2020 Google LLC
  4718. *
  4719. * Licensed under the Apache License, Version 2.0 (the "License");
  4720. * you may not use this file except in compliance with the License.
  4721. * You may obtain a copy of the License at
  4722. *
  4723. * http://www.apache.org/licenses/LICENSE-2.0
  4724. *
  4725. * Unless required by applicable law or agreed to in writing, software
  4726. * distributed under the License is distributed on an "AS IS" BASIS,
  4727. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  4728. * See the License for the specific language governing permissions and
  4729. * limitations under the License.
  4730. */
  4731. /**
  4732. * An `AppliableConstraint` is an abstraction of a constraint that can be applied
  4733. * to a Firestore query.
  4734. */ var mr = function() {}, vr = /** @class */ function(e) {
  4735. function n() {
  4736. return null !== e && e.apply(this, arguments) || this;
  4737. }
  4738. return t(n, e), n;
  4739. }(mr);
  4740. /**
  4741. * A `QueryConstraint` is used to narrow the set of documents returned by a
  4742. * Firestore query. `QueryConstraint`s are created by invoking {@link where},
  4743. * {@link orderBy}, {@link (startAt:1)}, {@link (startAfter:1)}, {@link
  4744. * (endBefore:1)}, {@link (endAt:1)}, {@link limit}, {@link limitToLast} and
  4745. * can then be passed to {@link (query:1)} to create a new query instance that
  4746. * also contains this `QueryConstraint`.
  4747. */ function gr(t, e) {
  4748. for (var n = [], r = 2; r < arguments.length; r++) n[r - 2] = arguments[r];
  4749. var i = [];
  4750. e instanceof mr && i.push(e), function(t) {
  4751. var e = t.filter((function(t) {
  4752. return t instanceof br;
  4753. })).length, n = t.filter((function(t) {
  4754. return t instanceof wr;
  4755. })).length;
  4756. if (e > 1 || e > 0 && n > 0) throw new B(O, "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(...)))`.");
  4757. }(i = i.concat(n));
  4758. for (var o = 0, a = i; o < a.length; o++) {
  4759. var s = a[o];
  4760. t = s._apply(t);
  4761. }
  4762. return t;
  4763. }
  4764. /**
  4765. * A `QueryFieldFilterConstraint` is used to narrow the set of documents returned by
  4766. * a Firestore query by filtering on one or more document fields.
  4767. * `QueryFieldFilterConstraint`s are created by invoking {@link where} and can then
  4768. * be passed to {@link (query:1)} to create a new query instance that also contains
  4769. * this `QueryFieldFilterConstraint`.
  4770. */ var wr = /** @class */ function(e) {
  4771. /**
  4772. * @internal
  4773. */
  4774. function n(t, n, r) {
  4775. var i = this;
  4776. return (i = e.call(this) || this)._field = t, i._op = n, i._value = r,
  4777. /** The type of this query constraint */
  4778. i.type = "where", i;
  4779. }
  4780. return t(n, e), n._create = function(t, e, r) {
  4781. return new n(t, e, r);
  4782. }, n.prototype._apply = function(t) {
  4783. var e = this._parse(t);
  4784. return jr(t._query, e), new An(t.firestore, t.converter, Fe(t._query, e));
  4785. }, n.prototype._parse = function(t) {
  4786. var e = Kn(t.firestore), n = function(t, e, n, r, i, o, a) {
  4787. var s;
  4788. if (i.isKeyField()) {
  4789. if ("array-contains" /* Operator.ARRAY_CONTAINS */ === o || "array-contains-any" /* Operator.ARRAY_CONTAINS_ANY */ === o) throw new B(O, "Invalid Query. You can't perform '".concat(o, "' queries on documentId()."));
  4790. if ("in" /* Operator.IN */ === o || "not-in" /* Operator.NOT_IN */ === o) {
  4791. Cr(a, o);
  4792. for (var u = [], c = 0, l = a; c < l.length; c++) {
  4793. var f = l[c];
  4794. u.push(xr(r, t, f));
  4795. }
  4796. s = {
  4797. arrayValue: {
  4798. values: u
  4799. }
  4800. };
  4801. } else s = xr(r, t, a);
  4802. } else "in" /* Operator.IN */ !== o && "not-in" /* Operator.NOT_IN */ !== o && "array-contains-any" /* Operator.ARRAY_CONTAINS_ANY */ !== o || Cr(a, o),
  4803. s = er(n, "where", a,
  4804. /* allowArrays= */ "in" /* Operator.IN */ === o || "not-in" /* Operator.NOT_IN */ === o);
  4805. return $t.create(i, o, s);
  4806. }(t._query, 0, e, t.firestore._databaseId, this._field, this._op, this._value);
  4807. return n;
  4808. }, n;
  4809. }(vr);
  4810. /**
  4811. * Creates a {@link QueryFieldFilterConstraint} that enforces that documents
  4812. * must contain the specified field and that the value should satisfy the
  4813. * relation constraint provided.
  4814. *
  4815. * @param fieldPath - The path to compare
  4816. * @param opStr - The operation string (e.g "&lt;", "&lt;=", "==", "&lt;",
  4817. * "&lt;=", "!=").
  4818. * @param value - The value for comparison
  4819. * @returns The created {@link QueryFieldFilterConstraint}.
  4820. */ function _r(t, e, n) {
  4821. var r = e, i = yr("where", t);
  4822. return wr._create(i, r, n);
  4823. }
  4824. /**
  4825. * A `QueryCompositeFilterConstraint` is used to narrow the set of documents
  4826. * returned by a Firestore query by performing the logical OR or AND of multiple
  4827. * {@link QueryFieldFilterConstraint}s or {@link QueryCompositeFilterConstraint}s.
  4828. * `QueryCompositeFilterConstraint`s are created by invoking {@link or} or
  4829. * {@link and} and can then be passed to {@link (query:1)} to create a new query
  4830. * instance that also contains the `QueryCompositeFilterConstraint`.
  4831. */ var br = /** @class */ function(e) {
  4832. /**
  4833. * @internal
  4834. */
  4835. function n(
  4836. /** The type of this query constraint */
  4837. t, n) {
  4838. var r = this;
  4839. return (r = e.call(this) || this).type = t, r._queryConstraints = n, r;
  4840. }
  4841. return t(n, e), n._create = function(t, e) {
  4842. return new n(t, e);
  4843. }, n.prototype._parse = function(t) {
  4844. var e = this._queryConstraints.map((function(e) {
  4845. return e._parse(t);
  4846. })).filter((function(t) {
  4847. return t.getFilters().length > 0;
  4848. }));
  4849. return 1 === e.length ? e[0] : Zt.create(e, this._getOperator());
  4850. }, n.prototype._apply = function(t) {
  4851. var e = this._parse(t);
  4852. return 0 === e.getFilters().length ? t : (function(t, e) {
  4853. for (var n = t, r = 0, i = e.getFlattenedFilters(); r < i.length; r++) {
  4854. var o = i[r];
  4855. jr(n, o), n = Fe(n, o);
  4856. }
  4857. }(t._query, e), new An(t.firestore, t.converter, Fe(t._query, e)));
  4858. }, n.prototype._getQueryConstraints = function() {
  4859. return this._queryConstraints;
  4860. }, n.prototype._getOperator = function() {
  4861. return "and" === this.type ? "and" /* CompositeOperator.AND */ : "or" /* CompositeOperator.OR */;
  4862. }, n;
  4863. }(mr);
  4864. /**
  4865. * Creates a new {@link QueryCompositeFilterConstraint} that is a disjunction of
  4866. * the given filter constraints. A disjunction filter includes a document if it
  4867. * satisfies any of the given filters.
  4868. *
  4869. * @param queryConstraints - Optional. The list of
  4870. * {@link QueryFilterConstraint}s to perform a disjunction for. These must be
  4871. * created with calls to {@link where}, {@link or}, or {@link and}.
  4872. * @returns The newly created {@link QueryCompositeFilterConstraint}.
  4873. */ function Tr() {
  4874. for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
  4875. // Only support QueryFilterConstraints
  4876. return t.forEach((function(t) {
  4877. return Mr("or", t);
  4878. })), br._create("or" /* CompositeOperator.OR */ , t)
  4879. /**
  4880. * Creates a new {@link QueryCompositeFilterConstraint} that is a conjunction of
  4881. * the given filter constraints. A conjunction filter includes a document if it
  4882. * satisfies all of the given filters.
  4883. *
  4884. * @param queryConstraints - Optional. The list of
  4885. * {@link QueryFilterConstraint}s to perform a conjunction for. These must be
  4886. * created with calls to {@link where}, {@link or}, or {@link and}.
  4887. * @returns The newly created {@link QueryCompositeFilterConstraint}.
  4888. */;
  4889. }
  4890. function Er() {
  4891. for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
  4892. // Only support QueryFilterConstraints
  4893. return t.forEach((function(t) {
  4894. return Mr("and", t);
  4895. })), br._create("and" /* CompositeOperator.AND */ , t)
  4896. /**
  4897. * A `QueryOrderByConstraint` is used to sort the set of documents returned by a
  4898. * Firestore query. `QueryOrderByConstraint`s are created by invoking
  4899. * {@link orderBy} and can then be passed to {@link (query:1)} to create a new query
  4900. * instance that also contains this `QueryOrderByConstraint`.
  4901. *
  4902. * Note: Documents that do not contain the orderBy field will not be present in
  4903. * the query result.
  4904. */;
  4905. }
  4906. var Sr = /** @class */ function(e) {
  4907. /**
  4908. * @internal
  4909. */
  4910. function n(t, n) {
  4911. var r = this;
  4912. return (r = e.call(this) || this)._field = t, r._direction = n,
  4913. /** The type of this query constraint */
  4914. r.type = "orderBy", r;
  4915. }
  4916. return t(n, e), n._create = function(t, e) {
  4917. return new n(t, e);
  4918. }, n.prototype._apply = function(t) {
  4919. var e = function(t, e, n) {
  4920. if (null !== t.startAt) throw new B(O, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
  4921. if (null !== t.endAt) throw new B(O, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
  4922. var r = new ce(e, n);
  4923. return function(t, e) {
  4924. if (null === Ee(t)) {
  4925. // This is the first order by. It must match any inequality.
  4926. var n = Se(t);
  4927. null !== n && Lr(t, n, e.field);
  4928. }
  4929. }(t, r), r;
  4930. }(t._query, this._field, this._direction);
  4931. return new An(t.firestore, t.converter, function(t, e) {
  4932. // TODO(dimond): validate that orderBy does not list the same key twice.
  4933. var n = t.explicitOrderBy.concat([ e ]);
  4934. return new Te(t.path, t.collectionGroup, n, t.filters.slice(), t.limit, t.limitType, t.startAt, t.endAt);
  4935. }(t._query, e));
  4936. }, n;
  4937. }(vr);
  4938. /**
  4939. * Creates a {@link QueryOrderByConstraint} that sorts the query result by the
  4940. * specified field, optionally in descending order instead of ascending.
  4941. *
  4942. * Note: Documents that do not contain the specified field will not be present
  4943. * in the query result.
  4944. *
  4945. * @param fieldPath - The field to sort by.
  4946. * @param directionStr - Optional direction to sort by ('asc' or 'desc'). If
  4947. * not specified, order will be ascending.
  4948. * @returns The created {@link QueryOrderByConstraint}.
  4949. */ function kr(t, e) {
  4950. void 0 === e && (e = "asc");
  4951. var n = e, r = yr("orderBy", t);
  4952. return Sr._create(r, n);
  4953. }
  4954. /**
  4955. * A `QueryLimitConstraint` is used to limit the number of documents returned by
  4956. * a Firestore query.
  4957. * `QueryLimitConstraint`s are created by invoking {@link limit} or
  4958. * {@link limitToLast} and can then be passed to {@link (query:1)} to create a new
  4959. * query instance that also contains this `QueryLimitConstraint`.
  4960. */ var Ir = /** @class */ function(e) {
  4961. /**
  4962. * @internal
  4963. */
  4964. function n(
  4965. /** The type of this query constraint */
  4966. t, n, r) {
  4967. var i = this;
  4968. return (i = e.call(this) || this).type = t, i._limit = n, i._limitType = r, i;
  4969. }
  4970. return t(n, e), n._create = function(t, e, r) {
  4971. return new n(t, e, r);
  4972. }, n.prototype._apply = function(t) {
  4973. return new An(t.firestore, t.converter, function(t, e, n) {
  4974. return new Te(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), e, n, t.startAt, t.endAt);
  4975. }(t._query, this._limit, this._limitType));
  4976. }, n;
  4977. }(vr);
  4978. /**
  4979. * Creates a {@link QueryLimitConstraint} that only returns the first matching
  4980. * documents.
  4981. *
  4982. * @param limit - The maximum number of items to return.
  4983. * @returns The created {@link QueryLimitConstraint}.
  4984. */ function Ar(t) {
  4985. return lt("limit", t), Ir._create("limit", t, "F" /* LimitType.First */)
  4986. /**
  4987. * Creates a {@link QueryLimitConstraint} that only returns the last matching
  4988. * documents.
  4989. *
  4990. * You must specify at least one `orderBy` clause for `limitToLast` queries,
  4991. * otherwise an exception will be thrown during execution.
  4992. *
  4993. * @param limit - The maximum number of items to return.
  4994. * @returns The created {@link QueryLimitConstraint}.
  4995. */;
  4996. }
  4997. function Fr(t) {
  4998. return lt("limitToLast", t), Ir._create("limitToLast", t, "L" /* LimitType.Last */)
  4999. /**
  5000. * A `QueryStartAtConstraint` is used to exclude documents from the start of a
  5001. * result set returned by a Firestore query.
  5002. * `QueryStartAtConstraint`s are created by invoking {@link (startAt:1)} or
  5003. * {@link (startAfter:1)} and can then be passed to {@link (query:1)} to create a
  5004. * new query instance that also contains this `QueryStartAtConstraint`.
  5005. */;
  5006. }
  5007. var Pr = /** @class */ function(e) {
  5008. /**
  5009. * @internal
  5010. */
  5011. function n(
  5012. /** The type of this query constraint */
  5013. t, n, r) {
  5014. var i = this;
  5015. return (i = e.call(this) || this).type = t, i._docOrFields = n, i._inclusive = r,
  5016. i;
  5017. }
  5018. return t(n, e), n._create = function(t, e, r) {
  5019. return new n(t, e, r);
  5020. }, n.prototype._apply = function(t) {
  5021. var e = Rr(t, this.type, this._docOrFields, this._inclusive);
  5022. return new An(t.firestore, t.converter, function(t, e) {
  5023. return new Te(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, e, t.endAt);
  5024. }(t._query, e));
  5025. }, n;
  5026. }(vr);
  5027. function Or() {
  5028. for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
  5029. return Pr._create("startAt", t,
  5030. /*inclusive=*/ !0);
  5031. }
  5032. function Vr() {
  5033. for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
  5034. return Pr._create("startAfter", t,
  5035. /*inclusive=*/ !1);
  5036. }
  5037. /**
  5038. * A `QueryEndAtConstraint` is used to exclude documents from the end of a
  5039. * result set returned by a Firestore query.
  5040. * `QueryEndAtConstraint`s are created by invoking {@link (endAt:1)} or
  5041. * {@link (endBefore:1)} and can then be passed to {@link (query:1)} to create a new
  5042. * query instance that also contains this `QueryEndAtConstraint`.
  5043. */ var Dr = /** @class */ function(e) {
  5044. /**
  5045. * @internal
  5046. */
  5047. function n(
  5048. /** The type of this query constraint */
  5049. t, n, r) {
  5050. var i = this;
  5051. return (i = e.call(this) || this).type = t, i._docOrFields = n, i._inclusive = r,
  5052. i;
  5053. }
  5054. return t(n, e), n._create = function(t, e, r) {
  5055. return new n(t, e, r);
  5056. }, n.prototype._apply = function(t) {
  5057. var e = Rr(t, this.type, this._docOrFields, this._inclusive);
  5058. return new An(t.firestore, t.converter, function(t, e) {
  5059. return new Te(t.path, t.collectionGroup, t.explicitOrderBy.slice(), t.filters.slice(), t.limit, t.limitType, t.startAt, e);
  5060. }(t._query, e));
  5061. }, n;
  5062. }(vr);
  5063. function Nr() {
  5064. for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
  5065. return Dr._create("endBefore", t,
  5066. /*inclusive=*/ !1);
  5067. }
  5068. function qr() {
  5069. for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
  5070. return Dr._create("endAt", t,
  5071. /*inclusive=*/ !0);
  5072. }
  5073. /** Helper function to create a bound from a document or fields */ function Rr(t, e, n, r) {
  5074. if (n[0] = p(n[0]), n[0] instanceof fr) return function(t, e, n, r, i) {
  5075. if (!r) throw new B(D, "Can't use a DocumentSnapshot that doesn't exist for ".concat(n, "()."));
  5076. // Because people expect to continue/end a query at the exact document
  5077. // provided, we need to use the implicit sort order rather than the explicit
  5078. // sort order, because it's guaranteed to contain the document key. That way
  5079. // the position becomes unambiguous and the query continues/ends exactly at
  5080. // the provided document. Without the key (by using the explicit sort
  5081. // orders), multiple documents could match the position, yielding duplicate
  5082. // results.
  5083. for (var o = [], a = 0, s = Ie(t); a < s.length; a++) {
  5084. var u = s[a];
  5085. if (u.field.isKeyField()) o.push(zt(e, r.key)); else {
  5086. var c = r.data.field(u.field);
  5087. if (qt(c)) throw new B(O, 'Invalid query. You are trying to start or end a query using a document for which the field "' + u.field + '" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');
  5088. if (null === c) {
  5089. var l = u.field.canonicalString();
  5090. throw new B(O, "Invalid query. You are trying to start or end a query using a document for which the field '".concat(l, "' (used as the orderBy) does not exist."));
  5091. }
  5092. o.push(c);
  5093. }
  5094. }
  5095. return new Ht(o, i);
  5096. }(t._query, t.firestore._databaseId, e, n[0]._document, r);
  5097. var i = Kn(t.firestore);
  5098. return function(t, e, n, r, i, o) {
  5099. // Use explicit order by's because it has to match the query the user made
  5100. var a = t.explicitOrderBy;
  5101. if (i.length > a.length) throw new B(O, "Too many arguments provided to ".concat(r, "(). The number of arguments must be less than or equal to the number of orderBy() clauses"));
  5102. for (var s = [], u = 0; u < i.length; u++) {
  5103. var c = i[u];
  5104. if (a[u].field.isKeyField()) {
  5105. if ("string" != typeof c) throw new B(O, "Invalid query. Expected a string for document ID in ".concat(r, "(), but got a ").concat(typeof c));
  5106. if (!ke(t) && -1 !== c.indexOf("/")) throw new B(O, "Invalid query. When querying a collection and ordering by documentId(), the value passed to ".concat(r, "() must be a plain document ID, but '").concat(c, "' contains a slash."));
  5107. var l = t.path.child(et.fromString(c));
  5108. if (!it.isDocumentKey(l)) throw new B(O, "Invalid query. When querying a collection group and ordering by documentId(), the value passed to ".concat(r, "() must result in a valid document path, but '").concat(l, "' is not because it contains an odd number of segments."));
  5109. var f = new it(l);
  5110. s.push(zt(e, f));
  5111. } else {
  5112. var h = er(n, r, c);
  5113. s.push(h);
  5114. }
  5115. }
  5116. return new Ht(s, o);
  5117. }(t._query, t.firestore._databaseId, i, e, n, r);
  5118. }
  5119. function xr(t, e, n) {
  5120. if ("string" == typeof (n = p(n))) {
  5121. if ("" === n) throw new B(O, "Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");
  5122. if (!ke(e) && -1 !== n.indexOf("/")) throw new B(O, "Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '".concat(n, "' contains a '/' character."));
  5123. var r = e.path.child(et.fromString(n));
  5124. if (!it.isDocumentKey(r)) throw new B(O, "Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '".concat(r, "' is not because it has an odd number of segments (").concat(r.length, ")."));
  5125. return zt(t, new it(r));
  5126. }
  5127. if (n instanceof In) return zt(t, n._key);
  5128. throw new B(O, "Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ".concat(ut(n), "."));
  5129. }
  5130. /**
  5131. * Validates that the value passed into a disjunctive filter satisfies all
  5132. * array requirements.
  5133. */ function Cr(t, e) {
  5134. if (!Array.isArray(t) || 0 === t.length) throw new B(O, "Invalid Query. A non-empty array is required for '".concat(e.toString(), "' filters."));
  5135. }
  5136. /**
  5137. * Given an operator, returns the set of operators that cannot be used with it.
  5138. *
  5139. * This is not a comprehensive check, and this function should be removed in the
  5140. * long term. Validations should occur in the Firestore backend.
  5141. *
  5142. * Operators in a query must adhere to the following set of rules:
  5143. * 1. Only one inequality per query.
  5144. * 2. `NOT_IN` cannot be used with array, disjunctive, or `NOT_EQUAL` operators.
  5145. */ function jr(t, e) {
  5146. if (e.isInequality()) {
  5147. var n = Se(t), r = e.field;
  5148. if (null !== n && !n.isEqual(r)) throw new B(O, "Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '".concat(n.toString(), "' and '").concat(r.toString(), "'"));
  5149. var i = Ee(t);
  5150. null !== i && Lr(t, r, i);
  5151. }
  5152. var o = function(t, e) {
  5153. for (var n = 0, r = t; n < r.length; n++) for (var i = 0, o = r[n].getFlattenedFilters(); i < o.length; i++) {
  5154. var a = o[i];
  5155. if (e.indexOf(a.op) >= 0) return a.op;
  5156. }
  5157. return null;
  5158. }(t.filters, function(t) {
  5159. switch (t) {
  5160. case "!=" /* Operator.NOT_EQUAL */ :
  5161. return [ "!=" /* Operator.NOT_EQUAL */ , "not-in" /* Operator.NOT_IN */ ];
  5162. case "array-contains-any" /* Operator.ARRAY_CONTAINS_ANY */ :
  5163. case "in" /* Operator.IN */ :
  5164. return [ "not-in" /* Operator.NOT_IN */ ];
  5165. case "not-in" /* Operator.NOT_IN */ :
  5166. return [ "array-contains-any" /* Operator.ARRAY_CONTAINS_ANY */ , "in" /* Operator.IN */ , "not-in" /* Operator.NOT_IN */ , "!=" /* Operator.NOT_EQUAL */ ];
  5167. default:
  5168. return [];
  5169. }
  5170. }(e.op));
  5171. if (null !== o)
  5172. // Special case when it's a duplicate op to give a slightly clearer error message.
  5173. throw o === e.op ? new B(O, "Invalid query. You cannot use more than one '".concat(e.op.toString(), "' filter.")) : new B(O, "Invalid query. You cannot use '".concat(e.op.toString(), "' filters with '").concat(o.toString(), "' filters."));
  5174. }
  5175. function Lr(t, e, n) {
  5176. if (!n.isEqual(e)) throw new B(O, "Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '".concat(e.toString(), "' and so you must also use '").concat(e.toString(), "' as your first argument to orderBy(), but your first orderBy() is on field '").concat(n.toString(), "' instead."));
  5177. }
  5178. function Mr(t, e) {
  5179. if (!(e instanceof wr || e instanceof br)) throw new B(O, "Function ".concat(t, "() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'."));
  5180. }
  5181. /**
  5182. * @license
  5183. * Copyright 2020 Google LLC
  5184. *
  5185. * Licensed under the Apache License, Version 2.0 (the "License");
  5186. * you may not use this file except in compliance with the License.
  5187. * You may obtain a copy of the License at
  5188. *
  5189. * http://www.apache.org/licenses/LICENSE-2.0
  5190. *
  5191. * Unless required by applicable law or agreed to in writing, software
  5192. * distributed under the License is distributed on an "AS IS" BASIS,
  5193. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  5194. * See the License for the specific language governing permissions and
  5195. * limitations under the License.
  5196. */
  5197. /**
  5198. * Converts custom model object of type T into `DocumentData` by applying the
  5199. * converter if it exists.
  5200. *
  5201. * This function is used when converting user objects to `DocumentData`
  5202. * because we want to provide the user with a more specific error message if
  5203. * their `set()` or fails due to invalid data originating from a `toFirestore()`
  5204. * call.
  5205. */ function Ur(t, e, n) {
  5206. // Cast to `any` in order to satisfy the union type constraint on
  5207. // toFirestore().
  5208. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  5209. return t ? n && (n.merge || n.mergeFields) ? t.toFirestore(e, n) : t.toFirestore(e) : e;
  5210. }
  5211. var Br = /** @class */ function(e) {
  5212. function n(t) {
  5213. var n = this;
  5214. return (n = e.call(this) || this).firestore = t, n;
  5215. }
  5216. return t(n, e), n.prototype.convertBytes = function(t) {
  5217. return new qn(t);
  5218. }, n.prototype.convertReference = function(t) {
  5219. var e = this.convertDocumentKey(t, this.firestore._databaseId);
  5220. return new In(this.firestore, /* converter= */ null, e);
  5221. }, n;
  5222. }(/** @class */ function() {
  5223. function t() {}
  5224. return t.prototype.convertValue = function(t, e) {
  5225. switch (void 0 === e && (e = "none"), jt(t)) {
  5226. case 0 /* TypeOrder.NullValue */ :
  5227. return null;
  5228. case 1 /* TypeOrder.BooleanValue */ :
  5229. return t.booleanValue;
  5230. case 2 /* TypeOrder.NumberValue */ :
  5231. return Vt(t.integerValue || t.doubleValue);
  5232. case 3 /* TypeOrder.TimestampValue */ :
  5233. return this.convertTimestamp(t.timestampValue);
  5234. case 4 /* TypeOrder.ServerTimestampValue */ :
  5235. return this.convertServerTimestamp(t, e);
  5236. case 5 /* TypeOrder.StringValue */ :
  5237. return t.stringValue;
  5238. case 6 /* TypeOrder.BlobValue */ :
  5239. return this.convertBytes(Dt(t.bytesValue));
  5240. case 7 /* TypeOrder.RefValue */ :
  5241. return this.convertReference(t.referenceValue);
  5242. case 8 /* TypeOrder.GeoPointValue */ :
  5243. return this.convertGeoPoint(t.geoPointValue);
  5244. case 9 /* TypeOrder.ArrayValue */ :
  5245. return this.convertArray(t.arrayValue, e);
  5246. case 10 /* TypeOrder.ObjectValue */ :
  5247. return this.convertObject(t.mapValue, e);
  5248. default:
  5249. throw k();
  5250. }
  5251. }, t.prototype.convertObject = function(t, e) {
  5252. return this.convertObjectMap(t.fields, e);
  5253. },
  5254. /**
  5255. * @internal
  5256. */
  5257. t.prototype.convertObjectMap = function(t, e) {
  5258. var n = this;
  5259. void 0 === e && (e = "none");
  5260. var r = {};
  5261. return It(t, (function(t, i) {
  5262. r[t] = n.convertValue(i, e);
  5263. })), r;
  5264. }, t.prototype.convertGeoPoint = function(t) {
  5265. return new jn(Vt(t.latitude), Vt(t.longitude));
  5266. }, t.prototype.convertArray = function(t, e) {
  5267. var n = this;
  5268. return (t.values || []).map((function(t) {
  5269. return n.convertValue(t, e);
  5270. }));
  5271. }, t.prototype.convertServerTimestamp = function(t, e) {
  5272. switch (e) {
  5273. case "previous":
  5274. var n = Rt(t);
  5275. return null == n ? null : this.convertValue(n, e);
  5276. case "estimate":
  5277. return this.convertTimestamp(xt(t));
  5278. default:
  5279. return null;
  5280. }
  5281. }, t.prototype.convertTimestamp = function(t) {
  5282. var e = Ot(t);
  5283. return new Nt(e.seconds, e.nanos);
  5284. }, t.prototype.convertDocumentKey = function(t, e) {
  5285. var n = et.fromString(t);
  5286. I(ln(n));
  5287. var r = new Z(n.get(1), n.get(3)), i = new it(n.popFirst(5));
  5288. return r.isEqual(e) ||
  5289. // TODO(b/64130202): Somehow support foreign references.
  5290. T("Document ".concat(i, " contains a document reference within a different database (").concat(r.projectId, "/").concat(r.database, ") which is not supported. It will be treated as a reference in the current database (").concat(e.projectId, "/").concat(e.database, ") instead.")),
  5291. i;
  5292. }, t;
  5293. }());
  5294. /**
  5295. * Reads the document referred to by the specified document reference.
  5296. *
  5297. * All documents are directly fetched from the server, even if the document was
  5298. * previously read or modified. Recent modifications are only reflected in the
  5299. * retrieved `DocumentSnapshot` if they have already been applied by the
  5300. * backend. If the client is offline, the read fails. If you like to use
  5301. * caching or see local modifications, please use the full Firestore SDK.
  5302. *
  5303. * @param reference - The reference of the document to fetch.
  5304. * @returns A Promise resolved with a `DocumentSnapshot` containing the current
  5305. * document contents.
  5306. */ function zr(t) {
  5307. var e = vn((t = ct(t, In)).firestore), n = new Br(t.firestore);
  5308. return yn(e, [ t._key ]).then((function(e) {
  5309. I(1 === e.length);
  5310. var r = e[0];
  5311. return new fr(t.firestore, n, t._key, r.isFoundDocument() ? r : null, t.converter);
  5312. }));
  5313. }
  5314. /**
  5315. * Executes the query and returns the results as a {@link QuerySnapshot}.
  5316. *
  5317. * All queries are executed directly by the server, even if the the query was
  5318. * previously executed. Recent modifications are only reflected in the retrieved
  5319. * results if they have already been applied by the backend. If the client is
  5320. * offline, the operation fails. To see previously cached result and local
  5321. * modifications, use the full Firestore SDK.
  5322. *
  5323. * @param query - The `Query` to execute.
  5324. * @returns A Promise that will be resolved with the results of the query.
  5325. */ function Qr(t) {
  5326. !function(t) {
  5327. if ("L" /* LimitType.Last */ === t.limitType && 0 === t.explicitOrderBy.length) throw new B(L, "limitToLast() queries require specifying at least one orderBy() clause");
  5328. }((t = ct(t, An))._query);
  5329. var r = vn(t.firestore), i = new Br(t.firestore);
  5330. return function(t, r) {
  5331. return e(this, void 0, void 0, (function() {
  5332. var e, i;
  5333. return n(this, (function(n) {
  5334. switch (n.label) {
  5335. case 0:
  5336. return e = A(t), i = nn(e.serializer, Ae(r)), [ 4 /*yield*/ , e.R("RunQuery", i.parent, {
  5337. structuredQuery: i.structuredQuery
  5338. }) ];
  5339. case 1:
  5340. return [ 2 /*return*/ , n.sent().filter((function(t) {
  5341. return !!t.document;
  5342. })).map((function(t) {
  5343. return function(t, e, n) {
  5344. var r = $e(t, e.name), i = He(e.updateTime), o = e.createTime ? He(e.createTime) : fe.min(), a = new ge({
  5345. mapValue: {
  5346. fields: e.fields
  5347. }
  5348. });
  5349. return we.newFoundDocument(r, i, o, a);
  5350. }(e.serializer, t.document);
  5351. })) ];
  5352. }
  5353. }));
  5354. }));
  5355. }(r, t._query).then((function(e) {
  5356. var n = e.map((function(e) {
  5357. return new hr(t.firestore, i, e.key, e, t.converter);
  5358. }));
  5359. return "L" /* LimitType.Last */ === t._query.limitType &&
  5360. // Limit to last queries reverse the orderBy constraint that was
  5361. // specified by the user. As such, we need to reverse the order of the
  5362. // results to return the documents in the expected order.
  5363. n.reverse(), new pr(t, n);
  5364. }));
  5365. }
  5366. function Kr(t, e, n) {
  5367. var r = Ur((t = ct(t, In)).converter, e, n), i = Gn(Kn(t.firestore), "setDoc", t._key, r, null !== t.converter, n);
  5368. return dn(vn(t.firestore), [ i.toMutation(t._key, xe.none()) ]);
  5369. }
  5370. function Gr(t, e, n) {
  5371. for (var r = [], i = 3; i < arguments.length; i++) r[i - 3] = arguments[i];
  5372. var o, a = Kn((t = ct(t, In)).firestore);
  5373. // For Compat types, we have to "extract" the underlying types before
  5374. // performing validation.
  5375. return o = "string" == typeof (e = p(e)) || e instanceof Rn ? tr(a, "updateDoc", t._key, e, n, r) : Zn(a, "updateDoc", t._key, e),
  5376. dn(vn(t.firestore), [ o.toMutation(t._key, xe.exists(!0)) ]);
  5377. }
  5378. /**
  5379. * Deletes the document referred to by the specified `DocumentReference`.
  5380. *
  5381. * The deletion will only be reflected in document reads that occur after the
  5382. * returned promise resolves. If the client is offline, the
  5383. * delete fails. If you would like to see local modifications or buffer writes
  5384. * until the client is online, use the full Firestore SDK.
  5385. *
  5386. * @param reference - A reference to the document to delete.
  5387. * @returns A `Promise` resolved once the document has been successfully
  5388. * deleted from the backend.
  5389. */ function Wr(t) {
  5390. return dn(vn((t = ct(t, In)).firestore), [ new Me(t._key, xe.none()) ]);
  5391. }
  5392. /**
  5393. * Add a new document to specified `CollectionReference` with the given data,
  5394. * assigning it a document ID automatically.
  5395. *
  5396. * The result of this write will only be reflected in document reads that occur
  5397. * after the returned promise resolves. If the client is offline, the
  5398. * write fails. If you would like to see local modifications or buffer writes
  5399. * until the client is online, use the full Firestore SDK.
  5400. *
  5401. * @param reference - A reference to the collection to add this document to.
  5402. * @param data - An Object containing the data for the new document.
  5403. * @throws Error - If the provided input is not a valid Firestore document.
  5404. * @returns A `Promise` resolved with a `DocumentReference` pointing to the
  5405. * newly created document after it has been written to the backend.
  5406. */ function Yr(t, e) {
  5407. var n = Vn(t = ct(t, Fn)), r = Ur(t.converter, e), i = Gn(Kn(t.firestore), "addDoc", n._key, r, null !== n.converter, {});
  5408. return dn(vn(t.firestore), [ i.toMutation(n._key, xe.exists(!1)) ]).then((function() {
  5409. return n;
  5410. }));
  5411. }
  5412. /**
  5413. * @license
  5414. * Copyright 2022 Google LLC
  5415. *
  5416. * Licensed under the Apache License, Version 2.0 (the "License");
  5417. * you may not use this file except in compliance with the License.
  5418. * You may obtain a copy of the License at
  5419. *
  5420. * http://www.apache.org/licenses/LICENSE-2.0
  5421. *
  5422. * Unless required by applicable law or agreed to in writing, software
  5423. * distributed under the License is distributed on an "AS IS" BASIS,
  5424. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  5425. * See the License for the specific language governing permissions and
  5426. * limitations under the License.
  5427. */
  5428. /**
  5429. * Calculates the number of documents in the result set of the given query,
  5430. * without actually downloading the documents.
  5431. *
  5432. * Using this function to count the documents is efficient because only the
  5433. * final count, not the documents' data, is downloaded. This function can even
  5434. * count the documents if the result set would be prohibitively large to
  5435. * download entirely (e.g. thousands of documents).
  5436. *
  5437. * @param query - The query whose result set size to calculate.
  5438. * @returns A Promise that will be resolved with the count; the count can be
  5439. * retrieved from `snapshot.data().count`, where `snapshot` is the
  5440. * `AggregateQuerySnapshot` to which the returned Promise resolves.
  5441. */ function Hr(t) {
  5442. return Jr(t, {
  5443. count: Zr()
  5444. });
  5445. }
  5446. /**
  5447. * Calculates the specified aggregations over the documents in the result
  5448. * set of the given query, without actually downloading the documents.
  5449. *
  5450. * Using this function to perform aggregations is efficient because only the
  5451. * final aggregation values, not the documents' data, is downloaded. This
  5452. * function can even perform aggregations of the documents if the result set
  5453. * would be prohibitively large to download entirely (e.g. thousands of documents).
  5454. *
  5455. * @param query The query whose result set to aggregate over.
  5456. * @param aggregateSpec An `AggregateSpec` object that specifies the aggregates
  5457. * to perform over the result set. The AggregateSpec specifies aliases for each
  5458. * aggregate, which can be used to retrieve the aggregate result.
  5459. * @example
  5460. * ```typescript
  5461. * const aggregateSnapshot = await getAggregate(query, {
  5462. * countOfDocs: count(),
  5463. * totalHours: sum('hours'),
  5464. * averageScore: average('score')
  5465. * });
  5466. *
  5467. * const countOfDocs: number = aggregateSnapshot.data().countOfDocs;
  5468. * const totalHours: number = aggregateSnapshot.data().totalHours;
  5469. * const averageScore: number | null = aggregateSnapshot.data().averageScore;
  5470. * ```
  5471. * @internal TODO (sum/avg) remove when public
  5472. */ function Jr(t, r) {
  5473. var i = ct(t.firestore, wn), o = vn(i), a = function(t, e) {
  5474. var n = [];
  5475. for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && n.push(e(t[r], r));
  5476. return n;
  5477. }(r, (function(t, e) {
  5478. return new _t(e, t._aggregateType, t._internalFieldPath);
  5479. }));
  5480. // Run the aggregation and convert the results
  5481. return function(t, r, i) {
  5482. return e(this, void 0, void 0, (function() {
  5483. var e, o, a, s, u, c, l, f;
  5484. return n(this, (function(n) {
  5485. switch (n.label) {
  5486. case 0:
  5487. return o = A(t), a = function(t, e, n) {
  5488. var r = nn(t, e), i = {}, o = [], a = 0;
  5489. return n.forEach((function(t) {
  5490. // Map all client-side aliases to a unique short-form
  5491. // alias. This avoids issues with client-side aliases that
  5492. // exceed the 1500-byte string size limit.
  5493. var e = "aggregate_" + a++;
  5494. i[e] = t.alias, "count" === t.$ ? o.push({
  5495. alias: e,
  5496. count: {}
  5497. }) : "avg" === t.$ ? o.push({
  5498. alias: e,
  5499. avg: {
  5500. field: sn(t.fieldPath)
  5501. }
  5502. }) : "sum" === t.$ && o.push({
  5503. alias: e,
  5504. sum: {
  5505. field: sn(t.fieldPath)
  5506. }
  5507. });
  5508. })), {
  5509. request: {
  5510. structuredAggregationQuery: {
  5511. aggregations: o,
  5512. structuredQuery: r.structuredQuery
  5513. },
  5514. parent: r.parent
  5515. },
  5516. Z: i
  5517. };
  5518. }(o.serializer, Ae(r), i), s = a.request, u = a.Z, c = s.parent, o.connection.g || delete s.parent,
  5519. [ 4 /*yield*/ , o.R("RunAggregationQuery", c, s, /*expectedResponseCount=*/ 1) ];
  5520. case 1:
  5521. return l = n.sent().filter((function(t) {
  5522. return !!t.result;
  5523. })),
  5524. // Omit RunAggregationQueryResponse that only contain readTimes.
  5525. I(1 === l.length), f = null === (e = l[0].result) || void 0 === e ? void 0 : e.aggregateFields,
  5526. [ 2 /*return*/ , Object.keys(f).reduce((function(t, e) {
  5527. return t[u[e]] = f[e], t;
  5528. }), {}) ];
  5529. }
  5530. }));
  5531. }));
  5532. }(o, t._query, a).then((function(e) {
  5533. return function(t, e, n) {
  5534. var r = new Br(t);
  5535. return new kn(e, r, n);
  5536. }(i, t, e);
  5537. }));
  5538. }
  5539. function Xr(t) {
  5540. return new Sn("sum", ar("sum", t));
  5541. }
  5542. /**
  5543. * Create an AggregateField object that can be used to compute the average of
  5544. * a specified field over a range of documents in the result set of a query.
  5545. * @param field Specifies the field to average across the result set.
  5546. * @internal TODO (sum/avg) remove when public
  5547. */ function $r(t) {
  5548. return new Sn("avg", ar("average", t));
  5549. }
  5550. /**
  5551. * Create an AggregateField object that can be used to compute the count of
  5552. * documents in the result set of a query.
  5553. * @internal TODO (sum/avg) remove when public
  5554. */ function Zr() {
  5555. return new Sn("count");
  5556. }
  5557. /**
  5558. * Compares two 'AggregateField` instances for equality.
  5559. *
  5560. * @param left Compare this AggregateField to the `right`.
  5561. * @param right Compare this AggregateField to the `left`.
  5562. * @internal TODO (sum/avg) remove when public
  5563. */ function ti(t, e) {
  5564. var n, r;
  5565. return t instanceof Sn && e instanceof Sn && t._aggregateType === e._aggregateType && (null === (n = t._internalFieldPath) || void 0 === n ? void 0 : n.canonicalString()) === (null === (r = e._internalFieldPath) || void 0 === r ? void 0 : r.canonicalString());
  5566. }
  5567. /**
  5568. * Compares two `AggregateQuerySnapshot` instances for equality.
  5569. *
  5570. * Two `AggregateQuerySnapshot` instances are considered "equal" if they have
  5571. * underlying queries that compare equal, and the same data.
  5572. *
  5573. * @param left - The first `AggregateQuerySnapshot` to compare.
  5574. * @param right - The second `AggregateQuerySnapshot` to compare.
  5575. *
  5576. * @returns `true` if the objects are "equal", as defined above, or `false`
  5577. * otherwise.
  5578. */ function ei(t, e) {
  5579. return Nn(t.query, e.query) && m(t.data(), e.data());
  5580. }
  5581. /**
  5582. * @license
  5583. * Copyright 2020 Google LLC
  5584. *
  5585. * Licensed under the Apache License, Version 2.0 (the "License");
  5586. * you may not use this file except in compliance with the License.
  5587. * You may obtain a copy of the License at
  5588. *
  5589. * http://www.apache.org/licenses/LICENSE-2.0
  5590. *
  5591. * Unless required by applicable law or agreed to in writing, software
  5592. * distributed under the License is distributed on an "AS IS" BASIS,
  5593. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  5594. * See the License for the specific language governing permissions and
  5595. * limitations under the License.
  5596. */
  5597. /**
  5598. * Returns a sentinel for use with {@link @firebase/firestore/lite#(updateDoc:1)} or
  5599. * {@link @firebase/firestore/lite#(setDoc:1)} with `{merge: true}` to mark a field for deletion.
  5600. */ function ni() {
  5601. return new Wn("deleteField");
  5602. }
  5603. /**
  5604. * Returns a sentinel used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link @firebase/firestore/lite#(updateDoc:1)} to
  5605. * include a server-generated timestamp in the written data.
  5606. */ function ri() {
  5607. return new Hn("serverTimestamp");
  5608. }
  5609. /**
  5610. * Returns a special value that can be used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link
  5611. * @firebase/firestore/lite#(updateDoc:1)} that tells the server to union the given elements with any array
  5612. * value that already exists on the server. Each specified element that doesn't
  5613. * already exist in the array will be added to the end. If the field being
  5614. * modified is not already an array it will be overwritten with an array
  5615. * containing exactly the specified elements.
  5616. *
  5617. * @param elements - The elements to union into the array.
  5618. * @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
  5619. * `updateDoc()`.
  5620. */ function ii() {
  5621. for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
  5622. // NOTE: We don't actually parse the data until it's used in set() or
  5623. // update() since we'd need the Firestore instance to do this.
  5624. return new Jn("arrayUnion", t);
  5625. }
  5626. /**
  5627. * Returns a special value that can be used with {@link (setDoc:1)} or {@link
  5628. * updateDoc:1} that tells the server to remove the given elements from any
  5629. * array value that already exists on the server. All instances of each element
  5630. * specified will be removed from the array. If the field being modified is not
  5631. * already an array it will be overwritten with an empty array.
  5632. *
  5633. * @param elements - The elements to remove from the array.
  5634. * @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
  5635. * `updateDoc()`
  5636. */ function oi() {
  5637. for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
  5638. // NOTE: We don't actually parse the data until it's used in set() or
  5639. // update() since we'd need the Firestore instance to do this.
  5640. return new Xn("arrayRemove", t);
  5641. }
  5642. /**
  5643. * Returns a special value that can be used with {@link @firebase/firestore/lite#(setDoc:1)} or {@link
  5644. * @firebase/firestore/lite#(updateDoc:1)} that tells the server to increment the field's current value by
  5645. * the given value.
  5646. *
  5647. * If either the operand or the current field value uses floating point
  5648. * precision, all arithmetic follows IEEE 754 semantics. If both values are
  5649. * integers, values outside of JavaScript's safe number range
  5650. * (`Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`) are also subject to
  5651. * precision loss. Furthermore, once processed by the Firestore backend, all
  5652. * integer operations are capped between -2^63 and 2^63-1.
  5653. *
  5654. * If the current field value is not of type `number`, or if the field does not
  5655. * yet exist, the transformation sets the field to the given value.
  5656. *
  5657. * @param n - The value to increment by.
  5658. * @returns The `FieldValue` sentinel for use in a call to `setDoc()` or
  5659. * `updateDoc()`
  5660. */ function ai(t) {
  5661. return new $n("increment", t);
  5662. }
  5663. /**
  5664. * @license
  5665. * Copyright 2020 Google LLC
  5666. *
  5667. * Licensed under the Apache License, Version 2.0 (the "License");
  5668. * you may not use this file except in compliance with the License.
  5669. * You may obtain a copy of the License at
  5670. *
  5671. * http://www.apache.org/licenses/LICENSE-2.0
  5672. *
  5673. * Unless required by applicable law or agreed to in writing, software
  5674. * distributed under the License is distributed on an "AS IS" BASIS,
  5675. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  5676. * See the License for the specific language governing permissions and
  5677. * limitations under the License.
  5678. */
  5679. /**
  5680. * A write batch, used to perform multiple writes as a single atomic unit.
  5681. *
  5682. * A `WriteBatch` object can be acquired by calling {@link writeBatch}. It
  5683. * provides methods for adding writes to the write batch. None of the writes
  5684. * will be committed (or visible locally) until {@link WriteBatch.commit} is
  5685. * called.
  5686. */ var si = /** @class */ function() {
  5687. /** @hideconstructor */
  5688. function t(t, e) {
  5689. this._firestore = t, this._commitHandler = e, this._mutations = [], this._committed = !1,
  5690. this._dataReader = Kn(t);
  5691. }
  5692. return t.prototype.set = function(t, e, n) {
  5693. this._verifyNotCommitted();
  5694. var r = ui(t, this._firestore), i = Ur(r.converter, e, n), o = Gn(this._dataReader, "WriteBatch.set", r._key, i, null !== r.converter, n);
  5695. return this._mutations.push(o.toMutation(r._key, xe.none())), this;
  5696. }, t.prototype.update = function(t, e, n) {
  5697. for (var r = [], i = 3; i < arguments.length; i++) r[i - 3] = arguments[i];
  5698. this._verifyNotCommitted();
  5699. var o, a = ui(t, this._firestore);
  5700. // For Compat types, we have to "extract" the underlying types before
  5701. // performing validation.
  5702. return o = "string" == typeof (e = p(e)) || e instanceof Rn ? tr(this._dataReader, "WriteBatch.update", a._key, e, n, r) : Zn(this._dataReader, "WriteBatch.update", a._key, e),
  5703. this._mutations.push(o.toMutation(a._key, xe.exists(!0))), this;
  5704. },
  5705. /**
  5706. * Deletes the document referred to by the provided {@link DocumentReference}.
  5707. *
  5708. * @param documentRef - A reference to the document to be deleted.
  5709. * @returns This `WriteBatch` instance. Used for chaining method calls.
  5710. */
  5711. t.prototype.delete = function(t) {
  5712. this._verifyNotCommitted();
  5713. var e = ui(t, this._firestore);
  5714. return this._mutations = this._mutations.concat(new Me(e._key, xe.none())), this;
  5715. },
  5716. /**
  5717. * Commits all of the writes in this write batch as a single atomic unit.
  5718. *
  5719. * The result of these writes will only be reflected in document reads that
  5720. * occur after the returned promise resolves. If the client is offline, the
  5721. * write fails. If you would like to see local modifications or buffer writes
  5722. * until the client is online, use the full Firestore SDK.
  5723. *
  5724. * @returns A `Promise` resolved once all of the writes in the batch have been
  5725. * successfully written to the backend as an atomic unit (note that it won't
  5726. * resolve while you're offline).
  5727. */
  5728. t.prototype.commit = function() {
  5729. return this._verifyNotCommitted(), this._committed = !0, this._mutations.length > 0 ? this._commitHandler(this._mutations) : Promise.resolve();
  5730. }, t.prototype._verifyNotCommitted = function() {
  5731. if (this._committed) throw new B(x, "A write batch can no longer be used after commit() has been called.");
  5732. }, t;
  5733. }();
  5734. function ui(t, e) {
  5735. if ((t = p(t)).firestore !== e) throw new B(O, "Provided document reference is from a different Firestore instance.");
  5736. return t;
  5737. }
  5738. /**
  5739. * Creates a write batch, used for performing multiple writes as a single
  5740. * atomic operation. The maximum number of writes allowed in a single WriteBatch
  5741. * is 500.
  5742. *
  5743. * The result of these writes will only be reflected in document reads that
  5744. * occur after the returned promise resolves. If the client is offline, the
  5745. * write fails. If you would like to see local modifications or buffer writes
  5746. * until the client is online, use the full Firestore SDK.
  5747. *
  5748. * @returns A `WriteBatch` that can be used to atomically execute multiple
  5749. * writes.
  5750. */ function ci(t) {
  5751. var e = vn(t = ct(t, wn));
  5752. return new si(t, (function(t) {
  5753. return dn(e, t);
  5754. }));
  5755. }
  5756. /**
  5757. * @license
  5758. * Copyright 2017 Google LLC
  5759. *
  5760. * Licensed under the Apache License, Version 2.0 (the "License");
  5761. * you may not use this file except in compliance with the License.
  5762. * You may obtain a copy of the License at
  5763. *
  5764. * http://www.apache.org/licenses/LICENSE-2.0
  5765. *
  5766. * Unless required by applicable law or agreed to in writing, software
  5767. * distributed under the License is distributed on an "AS IS" BASIS,
  5768. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  5769. * See the License for the specific language governing permissions and
  5770. * limitations under the License.
  5771. */
  5772. /**
  5773. * Internal transaction object responsible for accumulating the mutations to
  5774. * perform and the base versions for any documents read.
  5775. */ var li = /** @class */ function() {
  5776. function t(t) {
  5777. this.datastore = t,
  5778. // The version of each document that was read during this transaction.
  5779. this.readVersions = new Map, this.mutations = [], this.committed = !1,
  5780. /**
  5781. * A deferred usage error that occurred previously in this transaction that
  5782. * will cause the transaction to fail once it actually commits.
  5783. */
  5784. this.lastWriteError = null,
  5785. /**
  5786. * Set of documents that have been written in the transaction.
  5787. *
  5788. * When there's more than one write to the same key in a transaction, any
  5789. * writes after the first are handled differently.
  5790. */
  5791. this.writtenDocs = new Set;
  5792. }
  5793. return t.prototype.lookup = function(t) {
  5794. return e(this, void 0, void 0, (function() {
  5795. var e, r = this;
  5796. return n(this, (function(n) {
  5797. switch (n.label) {
  5798. case 0:
  5799. if (this.ensureCommitNotCalled(), this.mutations.length > 0) throw new B(O, "Firestore transactions require all reads to be executed before all writes.");
  5800. return [ 4 /*yield*/ , yn(this.datastore, t) ];
  5801. case 1:
  5802. return [ 2 /*return*/ , ((e = n.sent()).forEach((function(t) {
  5803. return r.recordVersion(t);
  5804. })), e) ];
  5805. }
  5806. }));
  5807. }));
  5808. }, t.prototype.set = function(t, e) {
  5809. this.write(e.toMutation(t, this.precondition(t))), this.writtenDocs.add(t.toString());
  5810. }, t.prototype.update = function(t, e) {
  5811. try {
  5812. this.write(e.toMutation(t, this.preconditionForUpdate(t)));
  5813. } catch (t) {
  5814. this.lastWriteError = t;
  5815. }
  5816. this.writtenDocs.add(t.toString());
  5817. }, t.prototype.delete = function(t) {
  5818. this.write(new Me(t, this.precondition(t))), this.writtenDocs.add(t.toString());
  5819. }, t.prototype.commit = function() {
  5820. return e(this, void 0, void 0, (function() {
  5821. var t, e = this;
  5822. return n(this, (function(n) {
  5823. switch (n.label) {
  5824. case 0:
  5825. if (this.ensureCommitNotCalled(), this.lastWriteError) throw this.lastWriteError;
  5826. return t = this.readVersions,
  5827. // For each mutation, note that the doc was written.
  5828. this.mutations.forEach((function(e) {
  5829. t.delete(e.key.toString());
  5830. })),
  5831. // For each document that was read but not written to, we want to perform
  5832. // a `verify` operation.
  5833. t.forEach((function(t, n) {
  5834. var r = it.fromPath(n);
  5835. e.mutations.push(new Ue(r, e.precondition(r)));
  5836. })), [ 4 /*yield*/ , dn(this.datastore, this.mutations) ];
  5837. case 1:
  5838. // For each mutation, note that the doc was written.
  5839. return n.sent(), this.committed = !0, [ 2 /*return*/ ];
  5840. }
  5841. }));
  5842. }));
  5843. }, t.prototype.recordVersion = function(t) {
  5844. var e;
  5845. if (t.isFoundDocument()) e = t.version; else {
  5846. if (!t.isNoDocument()) throw k();
  5847. // Represent a deleted doc using SnapshotVersion.min().
  5848. e = fe.min();
  5849. }
  5850. var n = this.readVersions.get(t.key.toString());
  5851. if (n) {
  5852. if (!e.isEqual(n))
  5853. // This transaction will fail no matter what.
  5854. throw new B(C, "Document version changed between two reads.");
  5855. } else this.readVersions.set(t.key.toString(), e);
  5856. },
  5857. /**
  5858. * Returns the version of this document when it was read in this transaction,
  5859. * as a precondition, or no precondition if it was not read.
  5860. */
  5861. t.prototype.precondition = function(t) {
  5862. var e = this.readVersions.get(t.toString());
  5863. return !this.writtenDocs.has(t.toString()) && e ? e.isEqual(fe.min()) ? xe.exists(!1) : xe.updateTime(e) : xe.none();
  5864. },
  5865. /**
  5866. * Returns the precondition for a document if the operation is an update.
  5867. */
  5868. t.prototype.preconditionForUpdate = function(t) {
  5869. var e = this.readVersions.get(t.toString());
  5870. // The first time a document is written, we want to take into account the
  5871. // read time and existence
  5872. if (!this.writtenDocs.has(t.toString()) && e) {
  5873. if (e.isEqual(fe.min()))
  5874. // The document doesn't exist, so fail the transaction.
  5875. // This has to be validated locally because you can't send a
  5876. // precondition that a document does not exist without changing the
  5877. // semantics of the backend write to be an insert. This is the reverse
  5878. // of what we want, since we want to assert that the document doesn't
  5879. // exist but then send the update and have it fail. Since we can't
  5880. // express that to the backend, we have to validate locally.
  5881. // Note: this can change once we can send separate verify writes in the
  5882. // transaction.
  5883. throw new B(O, "Can't update a document that doesn't exist.");
  5884. // Document exists, base precondition on document update time.
  5885. return xe.updateTime(e);
  5886. }
  5887. // Document was not read, so we just use the preconditions for a blind
  5888. // update.
  5889. return xe.exists(!0);
  5890. }, t.prototype.write = function(t) {
  5891. this.ensureCommitNotCalled(), this.mutations.push(t);
  5892. }, t.prototype.ensureCommitNotCalled = function() {}, t;
  5893. }(), fi = {
  5894. maxAttempts: 5
  5895. }, hi = /** @class */ function() {
  5896. function t(t, e, n, r, i) {
  5897. this.asyncQueue = t, this.datastore = e, this.options = n, this.updateFunction = r,
  5898. this.deferred = i, this.yt = n.maxAttempts, this.gt = new hn(this.asyncQueue, "transaction_retry" /* TimerId.TransactionRetry */)
  5899. /** Runs the transaction and sets the result on deferred. */;
  5900. }
  5901. return t.prototype.run = function() {
  5902. this.yt -= 1, this._t();
  5903. }, t.prototype._t = function() {
  5904. var t = this;
  5905. this.gt.K((function() {
  5906. return e(t, void 0, void 0, (function() {
  5907. var t, e, r = this;
  5908. return n(this, (function(n) {
  5909. return t = new li(this.datastore), (e = this.vt(t)) && e.then((function(e) {
  5910. r.asyncQueue.enqueueAndForget((function() {
  5911. return t.commit().then((function() {
  5912. r.deferred.resolve(e);
  5913. })).catch((function(t) {
  5914. r.bt(t);
  5915. }));
  5916. }));
  5917. })).catch((function(t) {
  5918. r.bt(t);
  5919. })), [ 2 /*return*/ ];
  5920. }));
  5921. }));
  5922. }));
  5923. }, t.prototype.vt = function(t) {
  5924. try {
  5925. var e = this.updateFunction(t);
  5926. return !pt(e) && e.catch && e.then ? e : (this.deferred.reject(Error("Transaction callback must return a Promise")),
  5927. null);
  5928. } catch (t) {
  5929. // Do not retry errors thrown by user provided updateFunction.
  5930. return this.deferred.reject(t), null;
  5931. }
  5932. }, t.prototype.bt = function(t) {
  5933. var e = this;
  5934. this.yt > 0 && this.Et(t) ? (this.yt -= 1, this.asyncQueue.enqueueAndForget((function() {
  5935. return e._t(), Promise.resolve();
  5936. }))) : this.deferred.reject(t);
  5937. }, t.prototype.Et = function(t) {
  5938. if ("FirebaseError" === t.name) {
  5939. // In transactions, the backend will fail outdated reads with FAILED_PRECONDITION and
  5940. // non-matching document versions with ABORTED. These errors should be retried.
  5941. var e = t.code;
  5942. return "aborted" === e || "failed-precondition" === e || "already-exists" === e || !
  5943. /**
  5944. * Determines whether an error code represents a permanent error when received
  5945. * in response to a non-write operation.
  5946. *
  5947. * See isPermanentWriteError for classifying write errors.
  5948. */
  5949. function(t) {
  5950. switch (t) {
  5951. default:
  5952. return k();
  5953. case F:
  5954. case P:
  5955. case V:
  5956. case R:
  5957. case M:
  5958. case U:
  5959. // Unauthenticated means something went wrong with our token and we need
  5960. // to retry with new credentials which will happen automatically.
  5961. case q:
  5962. return !1;
  5963. case O:
  5964. case D:
  5965. case "already-exists":
  5966. case N:
  5967. case x:
  5968. // Aborted might be retried in some scenarios, but that is dependant on
  5969. // the context and should handled individually by the calling code.
  5970. // See https://cloud.google.com/apis/design/errors.
  5971. case C:
  5972. case j:
  5973. case L:
  5974. case "data-loss":
  5975. return !0;
  5976. }
  5977. }(e);
  5978. }
  5979. return !1;
  5980. }, t;
  5981. }();
  5982. /**
  5983. * @license
  5984. * Copyright 2022 Google LLC
  5985. *
  5986. * Licensed under the Apache License, Version 2.0 (the "License");
  5987. * you may not use this file except in compliance with the License.
  5988. * You may obtain a copy of the License at
  5989. *
  5990. * http://www.apache.org/licenses/LICENSE-2.0
  5991. *
  5992. * Unless required by applicable law or agreed to in writing, software
  5993. * distributed under the License is distributed on an "AS IS" BASIS,
  5994. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  5995. * See the License for the specific language governing permissions and
  5996. * limitations under the License.
  5997. */
  5998. /**
  5999. * @license
  6000. * Copyright 2020 Google LLC
  6001. *
  6002. * Licensed under the Apache License, Version 2.0 (the "License");
  6003. * you may not use this file except in compliance with the License.
  6004. * You may obtain a copy of the License at
  6005. *
  6006. * http://www.apache.org/licenses/LICENSE-2.0
  6007. *
  6008. * Unless required by applicable law or agreed to in writing, software
  6009. * distributed under the License is distributed on an "AS IS" BASIS,
  6010. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  6011. * See the License for the specific language governing permissions and
  6012. * limitations under the License.
  6013. */
  6014. /** The Platform's 'document' implementation or null if not available. */ function pi() {
  6015. // `document` is not always available, e.g. in ReactNative and WebWorkers.
  6016. // eslint-disable-next-line no-restricted-globals
  6017. return "undefined" != typeof document ? document : null;
  6018. }
  6019. /**
  6020. * @license
  6021. * Copyright 2017 Google LLC
  6022. *
  6023. * Licensed under the Apache License, Version 2.0 (the "License");
  6024. * you may not use this file except in compliance with the License.
  6025. * You may obtain a copy of the License at
  6026. *
  6027. * http://www.apache.org/licenses/LICENSE-2.0
  6028. *
  6029. * Unless required by applicable law or agreed to in writing, software
  6030. * distributed under the License is distributed on an "AS IS" BASIS,
  6031. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  6032. * See the License for the specific language governing permissions and
  6033. * limitations under the License.
  6034. */
  6035. /**
  6036. * Represents an operation scheduled to be run in the future on an AsyncQueue.
  6037. *
  6038. * It is created via DelayedOperation.createAndSchedule().
  6039. *
  6040. * Supports cancellation (via cancel()) and early execution (via skipDelay()).
  6041. *
  6042. * Note: We implement `PromiseLike` instead of `Promise`, as the `Promise` type
  6043. * in newer versions of TypeScript defines `finally`, which is not available in
  6044. * IE.
  6045. */ var di, yi = /** @class */ function() {
  6046. function t(t, e, n, r, i) {
  6047. this.asyncQueue = t, this.timerId = e, this.targetTimeMs = n, this.op = r, this.removalCallback = i,
  6048. this.deferred = new z, this.then = this.deferred.promise.then.bind(this.deferred.promise),
  6049. // It's normal for the deferred promise to be canceled (due to cancellation)
  6050. // and so we attach a dummy catch callback to avoid
  6051. // 'UnhandledPromiseRejectionWarning' log spam.
  6052. this.deferred.promise.catch((function(t) {}))
  6053. /**
  6054. * Creates and returns a DelayedOperation that has been scheduled to be
  6055. * executed on the provided asyncQueue after the provided delayMs.
  6056. *
  6057. * @param asyncQueue - The queue to schedule the operation on.
  6058. * @param id - A Timer ID identifying the type of operation this is.
  6059. * @param delayMs - The delay (ms) before the operation should be scheduled.
  6060. * @param op - The operation to run.
  6061. * @param removalCallback - A callback to be called synchronously once the
  6062. * operation is executed or canceled, notifying the AsyncQueue to remove it
  6063. * from its delayedOperations list.
  6064. * PORTING NOTE: This exists to prevent making removeDelayedOperation() and
  6065. * the DelayedOperation class public.
  6066. */;
  6067. }
  6068. return t.createAndSchedule = function(e, n, r, i, o) {
  6069. var a = new t(e, n, Date.now() + r, i, o);
  6070. return a.start(r), a;
  6071. },
  6072. /**
  6073. * Starts the timer. This is called immediately after construction by
  6074. * createAndSchedule().
  6075. */
  6076. t.prototype.start = function(t) {
  6077. var e = this;
  6078. this.timerHandle = setTimeout((function() {
  6079. return e.handleDelayElapsed();
  6080. }), t);
  6081. },
  6082. /**
  6083. * Queues the operation to run immediately (if it hasn't already been run or
  6084. * canceled).
  6085. */
  6086. t.prototype.skipDelay = function() {
  6087. return this.handleDelayElapsed();
  6088. },
  6089. /**
  6090. * Cancels the operation if it hasn't already been executed or canceled. The
  6091. * promise will be rejected.
  6092. *
  6093. * As long as the operation has not yet been run, calling cancel() provides a
  6094. * guarantee that the operation will not be run.
  6095. */
  6096. t.prototype.cancel = function(t) {
  6097. null !== this.timerHandle && (this.clearTimeout(), this.deferred.reject(new B(F, "Operation cancelled" + (t ? ": " + t : ""))));
  6098. }, t.prototype.handleDelayElapsed = function() {
  6099. var t = this;
  6100. this.asyncQueue.enqueueAndForget((function() {
  6101. return null !== t.timerHandle ? (t.clearTimeout(), t.op().then((function(e) {
  6102. return t.deferred.resolve(e);
  6103. }))) : Promise.resolve();
  6104. }));
  6105. }, t.prototype.clearTimeout = function() {
  6106. null !== this.timerHandle && (this.removalCallback(this), clearTimeout(this.timerHandle),
  6107. this.timerHandle = null);
  6108. }, t;
  6109. }(), mi = /** @class */ function() {
  6110. function t() {
  6111. var t = this;
  6112. // The last promise in the queue.
  6113. this.It = Promise.resolve(),
  6114. // A list of retryable operations. Retryable operations are run in order and
  6115. // retried with backoff.
  6116. this.Tt = [],
  6117. // Is this AsyncQueue being shut down? Once it is set to true, it will not
  6118. // be changed again.
  6119. this.At = !1,
  6120. // Operations scheduled to be queued in the future. Operations are
  6121. // automatically removed after they are run or canceled.
  6122. this.Rt = [],
  6123. // visible for testing
  6124. this.Pt = null,
  6125. // Flag set while there's an outstanding AsyncQueue operation, used for
  6126. // assertion sanity-checks.
  6127. this.Vt = !1,
  6128. // Enabled during shutdown on Safari to prevent future access to IndexedDB.
  6129. this.$t = !1,
  6130. // List of TimerIds to fast-forward delays for.
  6131. this.Nt = [],
  6132. // Backoff timer used to schedule retries for retryable operations
  6133. this.gt = new hn(this, "async_queue_retry" /* TimerId.AsyncQueueRetry */),
  6134. // Visibility handler that triggers an immediate retry of all retryable
  6135. // operations. Meant to speed up recovery when we regain file system access
  6136. // after page comes into foreground.
  6137. this.Dt = function() {
  6138. var e = pi();
  6139. e && b("AsyncQueue", "Visibility state changed to " + e.visibilityState), t.gt.H();
  6140. };
  6141. var e = pi();
  6142. e && "function" == typeof e.addEventListener && e.addEventListener("visibilitychange", this.Dt);
  6143. }
  6144. return Object.defineProperty(t.prototype, "isShuttingDown", {
  6145. get: function() {
  6146. return this.At;
  6147. },
  6148. enumerable: !1,
  6149. configurable: !0
  6150. }),
  6151. /**
  6152. * Adds a new operation to the queue without waiting for it to complete (i.e.
  6153. * we ignore the Promise result).
  6154. */
  6155. t.prototype.enqueueAndForget = function(t) {
  6156. // eslint-disable-next-line @typescript-eslint/no-floating-promises
  6157. this.enqueue(t);
  6158. }, t.prototype.enqueueAndForgetEvenWhileRestricted = function(t) {
  6159. this.Ft(),
  6160. // eslint-disable-next-line @typescript-eslint/no-floating-promises
  6161. this.xt(t);
  6162. }, t.prototype.enterRestrictedMode = function(t) {
  6163. if (!this.At) {
  6164. this.At = !0, this.$t = t || !1;
  6165. var e = pi();
  6166. e && "function" == typeof e.removeEventListener && e.removeEventListener("visibilitychange", this.Dt);
  6167. }
  6168. }, t.prototype.enqueue = function(t) {
  6169. var e = this;
  6170. if (this.Ft(), this.At)
  6171. // Return a Promise which never resolves.
  6172. return new Promise((function() {}));
  6173. // Create a deferred Promise that we can return to the callee. This
  6174. // allows us to return a "hanging Promise" only to the callee and still
  6175. // advance the queue even when the operation is not run.
  6176. var n = new z;
  6177. return this.xt((function() {
  6178. return e.At && e.$t ? Promise.resolve() : (t().then(n.resolve, n.reject), n.promise);
  6179. })).then((function() {
  6180. return n.promise;
  6181. }));
  6182. }, t.prototype.enqueueRetryable = function(t) {
  6183. var e = this;
  6184. this.enqueueAndForget((function() {
  6185. return e.Tt.push(t), e.St();
  6186. }));
  6187. },
  6188. /**
  6189. * Runs the next operation from the retryable queue. If the operation fails,
  6190. * reschedules with backoff.
  6191. */
  6192. t.prototype.St = function() {
  6193. return e(this, void 0, void 0, (function() {
  6194. var t, e = this;
  6195. return n(this, (function(n) {
  6196. switch (n.label) {
  6197. case 0:
  6198. if (0 === this.Tt.length) return [ 3 /*break*/ , 5 ];
  6199. n.label = 1;
  6200. case 1:
  6201. return n.trys.push([ 1, 3, , 4 ]), [ 4 /*yield*/ , this.Tt[0]() ];
  6202. case 2:
  6203. return n.sent(), this.Tt.shift(), this.gt.reset(), [ 3 /*break*/ , 4 ];
  6204. case 3:
  6205. if (t = n.sent(), "IndexedDbTransactionError" !== t.name) throw t;
  6206. // Failure will be handled by AsyncQueue
  6207. return b("AsyncQueue", "Operation failed with retryable error: " + t),
  6208. [ 3 /*break*/ , 4 ];
  6209. case 4:
  6210. this.Tt.length > 0 &&
  6211. // If there are additional operations, we re-schedule `retryNextOp()`.
  6212. // This is necessary to run retryable operations that failed during
  6213. // their initial attempt since we don't know whether they are already
  6214. // enqueued. If, for example, `op1`, `op2`, `op3` are enqueued and `op1`
  6215. // needs to be re-run, we will run `op1`, `op1`, `op2` using the
  6216. // already enqueued calls to `retryNextOp()`. `op3()` will then run in the
  6217. // call scheduled here.
  6218. // Since `backoffAndRun()` cancels an existing backoff and schedules a
  6219. // new backoff on every call, there is only ever a single additional
  6220. // operation in the queue.
  6221. this.gt.K((function() {
  6222. return e.St();
  6223. })), n.label = 5;
  6224. case 5:
  6225. return [ 2 /*return*/ ];
  6226. }
  6227. }));
  6228. }));
  6229. }, t.prototype.xt = function(t) {
  6230. var e = this, n = this.It.then((function() {
  6231. return e.Vt = !0, t().catch((function(t) {
  6232. e.Pt = t, e.Vt = !1;
  6233. var n =
  6234. /**
  6235. * Chrome includes Error.message in Error.stack. Other browsers do not.
  6236. * This returns expected output of message + stack when available.
  6237. * @param error - Error or FirestoreError
  6238. */
  6239. function(t) {
  6240. var e = t.message || "";
  6241. return t.stack && (e = t.stack.includes(t.message) ? t.stack : t.message + "\n" + t.stack),
  6242. e;
  6243. }(t);
  6244. // Re-throw the error so that this.tail becomes a rejected Promise and
  6245. // all further attempts to chain (via .then) will just short-circuit
  6246. // and return the rejected Promise.
  6247. throw T("INTERNAL UNHANDLED ERROR: ", n), t;
  6248. })).then((function(t) {
  6249. return e.Vt = !1, t;
  6250. }));
  6251. }));
  6252. return this.It = n, n;
  6253. }, t.prototype.enqueueAfterDelay = function(t, e, n) {
  6254. var r = this;
  6255. this.Ft(),
  6256. // Fast-forward delays for timerIds that have been overriden.
  6257. this.Nt.indexOf(t) > -1 && (e = 0);
  6258. var i = yi.createAndSchedule(this, t, e, n, (function(t) {
  6259. return r.qt(t);
  6260. }));
  6261. return this.Rt.push(i), i;
  6262. }, t.prototype.Ft = function() {
  6263. this.Pt && k();
  6264. }, t.prototype.verifyOperationInProgress = function() {},
  6265. /**
  6266. * Waits until all currently queued tasks are finished executing. Delayed
  6267. * operations are not run.
  6268. */
  6269. t.prototype.Ot = function() {
  6270. return e(this, void 0, void 0, (function() {
  6271. var t;
  6272. return n(this, (function(e) {
  6273. switch (e.label) {
  6274. case 0:
  6275. return [ 4 /*yield*/ , t = this.It ];
  6276. case 1:
  6277. e.sent(), e.label = 2;
  6278. case 2:
  6279. if (t !== this.It) return [ 3 /*break*/ , 0 ];
  6280. e.label = 3;
  6281. case 3:
  6282. return [ 2 /*return*/ ];
  6283. }
  6284. }));
  6285. }));
  6286. },
  6287. /**
  6288. * For Tests: Determine if a delayed operation with a particular TimerId
  6289. * exists.
  6290. */
  6291. t.prototype.kt = function(t) {
  6292. for (var e = 0, n = this.Rt; e < n.length; e++) {
  6293. if (n[e].timerId === t) return !0;
  6294. }
  6295. return !1;
  6296. },
  6297. /**
  6298. * For Tests: Runs some or all delayed operations early.
  6299. *
  6300. * @param lastTimerId - Delayed operations up to and including this TimerId
  6301. * will be drained. Pass TimerId.All to run all delayed operations.
  6302. * @returns a Promise that resolves once all operations have been run.
  6303. */
  6304. t.prototype.Ct = function(t) {
  6305. var e = this;
  6306. // Note that draining may generate more delayed ops, so we do that first.
  6307. return this.Ot().then((function() {
  6308. // Run ops in the same order they'd run if they ran naturally.
  6309. e.Rt.sort((function(t, e) {
  6310. return t.targetTimeMs - e.targetTimeMs;
  6311. }));
  6312. for (var n = 0, r = e.Rt; n < r.length; n++) {
  6313. var i = r[n];
  6314. if (i.skipDelay(), "all" /* TimerId.All */ !== t && i.timerId === t) break;
  6315. }
  6316. return e.Ot();
  6317. }));
  6318. },
  6319. /**
  6320. * For Tests: Skip all subsequent delays for a timer id.
  6321. */
  6322. t.prototype.Mt = function(t) {
  6323. this.Nt.push(t);
  6324. },
  6325. /** Called once a DelayedOperation is run or canceled. */ t.prototype.qt = function(t) {
  6326. // NOTE: indexOf / slice are O(n), but delayedOperations is expected to be small.
  6327. var e = this.Rt.indexOf(t);
  6328. this.Rt.splice(e, 1);
  6329. }, t;
  6330. }(), vi = /** @class */ function() {
  6331. /** @hideconstructor */
  6332. function t(t, e) {
  6333. this._firestore = t, this._transaction = e, this._dataReader = Kn(t)
  6334. /**
  6335. * Reads the document referenced by the provided {@link DocumentReference}.
  6336. *
  6337. * @param documentRef - A reference to the document to be read.
  6338. * @returns A `DocumentSnapshot` with the read data.
  6339. */;
  6340. }
  6341. return t.prototype.get = function(t) {
  6342. var e = this, n = ui(t, this._firestore), r = new Br(this._firestore);
  6343. return this._transaction.lookup([ n._key ]).then((function(t) {
  6344. if (!t || 1 !== t.length) return k();
  6345. var i = t[0];
  6346. if (i.isFoundDocument()) return new fr(e._firestore, r, i.key, i, n.converter);
  6347. if (i.isNoDocument()) return new fr(e._firestore, r, n._key, null, n.converter);
  6348. throw k();
  6349. }));
  6350. }, t.prototype.set = function(t, e, n) {
  6351. var r = ui(t, this._firestore), i = Ur(r.converter, e, n), o = Gn(this._dataReader, "Transaction.set", r._key, i, null !== r.converter, n);
  6352. return this._transaction.set(r._key, o), this;
  6353. }, t.prototype.update = function(t, e, n) {
  6354. for (var r = [], i = 3; i < arguments.length; i++) r[i - 3] = arguments[i];
  6355. var o, a = ui(t, this._firestore);
  6356. // For Compat types, we have to "extract" the underlying types before
  6357. // performing validation.
  6358. return o = "string" == typeof (e = p(e)) || e instanceof Rn ? tr(this._dataReader, "Transaction.update", a._key, e, n, r) : Zn(this._dataReader, "Transaction.update", a._key, e),
  6359. this._transaction.update(a._key, o), this;
  6360. },
  6361. /**
  6362. * Deletes the document referred to by the provided {@link DocumentReference}.
  6363. *
  6364. * @param documentRef - A reference to the document to be deleted.
  6365. * @returns This `Transaction` instance. Used for chaining method calls.
  6366. */
  6367. t.prototype.delete = function(t) {
  6368. var e = ui(t, this._firestore);
  6369. return this._transaction.delete(e._key), this;
  6370. }, t;
  6371. }();
  6372. /**
  6373. * @license
  6374. * Copyright 2020 Google LLC
  6375. *
  6376. * Licensed under the Apache License, Version 2.0 (the "License");
  6377. * you may not use this file except in compliance with the License.
  6378. * You may obtain a copy of the License at
  6379. *
  6380. * http://www.apache.org/licenses/LICENSE-2.0
  6381. *
  6382. * Unless required by applicable law or agreed to in writing, software
  6383. * distributed under the License is distributed on an "AS IS" BASIS,
  6384. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  6385. * See the License for the specific language governing permissions and
  6386. * limitations under the License.
  6387. */
  6388. /**
  6389. * Executes the given `updateFunction` and then attempts to commit the changes
  6390. * applied within the transaction. If any document read within the transaction
  6391. * has changed, Cloud Firestore retries the `updateFunction`. If it fails to
  6392. * commit after 5 attempts, the transaction fails.
  6393. *
  6394. * The maximum number of writes allowed in a single transaction is 500.
  6395. *
  6396. * @param firestore - A reference to the Firestore database to run this
  6397. * transaction against.
  6398. * @param updateFunction - The function to execute within the transaction
  6399. * context.
  6400. * @param options - An options object to configure maximum number of attempts to
  6401. * commit.
  6402. * @returns If the transaction completed successfully or was explicitly aborted
  6403. * (the `updateFunction` returned a failed promise), the promise returned by the
  6404. * `updateFunction `is returned here. Otherwise, if the transaction failed, a
  6405. * rejected promise with the corresponding failure error is returned.
  6406. */
  6407. function gi(t, e, n) {
  6408. var r = vn(t = ct(t, wn)), i = Object.assign(Object.assign({}, fi), n);
  6409. !function(t) {
  6410. if (t.maxAttempts < 1) throw new B(O, "Max attempts must be at least 1");
  6411. }(i);
  6412. var o = new z;
  6413. return new hi(new mi, r, i, (function(n) {
  6414. return e(new vi(t, n));
  6415. }), o).run(), o.promise
  6416. /**
  6417. * Firestore Lite
  6418. *
  6419. * @remarks Firestore Lite is a small online-only SDK that allows read
  6420. * and write access to your Firestore database. All operations connect
  6421. * directly to the backend, and `onSnapshot()` APIs are not supported.
  6422. * @packageDocumentation
  6423. */;
  6424. }
  6425. di = "".concat(i, "_lite"), g = di, o(new c("firestore/lite", (function(t, e) {
  6426. var n = e.instanceIdentifier, r = e.options, i = t.getProvider("app").getImmediate(), o = new wn(new W(t.getProvider("auth-internal")), new X(t.getProvider("app-check-internal")), function(t, e) {
  6427. if (!Object.prototype.hasOwnProperty.apply(t.options, [ "projectId" ])) throw new B(O, '"projectId" not provided in firebase.initializeApp.');
  6428. return new Z(t.options.projectId, e);
  6429. }(i, n), i);
  6430. return r && o._setSettings(r), o;
  6431. }), "PUBLIC").setMultipleInstances(!0)),
  6432. // RUNTIME_ENV and BUILD_TARGET are replaced by real values during the compilation
  6433. a("firestore-lite", "3.13.0", ""), a("firestore-lite", "3.13.0", "esm5");
  6434. export { Sn as AggregateField, kn as AggregateQuerySnapshot, qn as Bytes, Fn as CollectionReference, In as DocumentReference, fr as DocumentSnapshot, Rn as FieldPath, Cn as FieldValue, wn as Firestore, B as FirestoreError, jn as GeoPoint, An as Query, br as QueryCompositeFilterConstraint, vr as QueryConstraint, hr as QueryDocumentSnapshot, Dr as QueryEndAtConstraint, wr as QueryFieldFilterConstraint, Ir as QueryLimitConstraint, Sr as QueryOrderByConstraint, pr as QuerySnapshot, Pr as QueryStartAtConstraint, Nt as Timestamp, vi as Transaction, si as WriteBatch, Yr as addDoc, ti as aggregateFieldEqual, ei as aggregateQuerySnapshotEqual, Er as and, oi as arrayRemove, ii as arrayUnion, $r as average, Pn as collection, On as collectionGroup, Tn as connectFirestoreEmulator, Zr as count, Wr as deleteDoc, ni as deleteField, Vn as doc, xn as documentId, qr as endAt, Nr as endBefore, Jr as getAggregate, Hr as getCount, zr as getDoc, Qr as getDocs, bn as getFirestore, ai as increment, _n as initializeFirestore, Ar as limit, Fr as limitToLast, Tr as or, kr as orderBy, gr as query, Nn as queryEqual, Dn as refEqual, gi as runTransaction, ri as serverTimestamp, Kr as setDoc, _ as setLogLevel, dr as snapshotEqual, Vr as startAfter, Or as startAt, Xr as sum, En as terminate, Gr as updateDoc, _r as where, ci as writeBatch };
  6435. //# sourceMappingURL=index.browser.esm5.js.map